root / include / exec / cpu-defs.h @ e85ef538
History | View | Annotate | Download (7.4 kB)
1 | ab93bbe2 | bellard | /*
|
---|---|---|---|
2 | ab93bbe2 | bellard | * common defines for all CPUs
|
3 | 5fafdf24 | ths | *
|
4 | ab93bbe2 | bellard | * Copyright (c) 2003 Fabrice Bellard
|
5 | ab93bbe2 | bellard | *
|
6 | ab93bbe2 | bellard | * This library is free software; you can redistribute it and/or
|
7 | ab93bbe2 | bellard | * modify it under the terms of the GNU Lesser General Public
|
8 | ab93bbe2 | bellard | * License as published by the Free Software Foundation; either
|
9 | ab93bbe2 | bellard | * version 2 of the License, or (at your option) any later version.
|
10 | ab93bbe2 | bellard | *
|
11 | ab93bbe2 | bellard | * This library is distributed in the hope that it will be useful,
|
12 | ab93bbe2 | bellard | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | ab93bbe2 | bellard | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | ab93bbe2 | bellard | * Lesser General Public License for more details.
|
15 | ab93bbe2 | bellard | *
|
16 | ab93bbe2 | bellard | * You should have received a copy of the GNU Lesser General Public
|
17 | 8167ee88 | Blue Swirl | * License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
18 | ab93bbe2 | bellard | */
|
19 | ab93bbe2 | bellard | #ifndef CPU_DEFS_H
|
20 | ab93bbe2 | bellard | #define CPU_DEFS_H
|
21 | ab93bbe2 | bellard | |
22 | 87ecb68b | pbrook | #ifndef NEED_CPU_H
|
23 | 87ecb68b | pbrook | #error cpu.h included from common code
|
24 | 87ecb68b | pbrook | #endif
|
25 | 87ecb68b | pbrook | |
26 | ab93bbe2 | bellard | #include "config.h" |
27 | ab93bbe2 | bellard | #include <setjmp.h> |
28 | ed1c0bcb | bellard | #include <inttypes.h> |
29 | 1de7afc9 | Paolo Bonzini | #include "qemu/osdep.h" |
30 | 1de7afc9 | Paolo Bonzini | #include "qemu/queue.h" |
31 | 022c62cb | Paolo Bonzini | #include "exec/hwaddr.h" |
32 | ab93bbe2 | bellard | |
33 | 35b66fc4 | bellard | #ifndef TARGET_LONG_BITS
|
34 | 35b66fc4 | bellard | #error TARGET_LONG_BITS must be defined before including this header
|
35 | 35b66fc4 | bellard | #endif
|
36 | 35b66fc4 | bellard | |
37 | 35b66fc4 | bellard | #define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8) |
38 | 35b66fc4 | bellard | |
39 | ab6d960f | bellard | /* target_ulong is the type of a virtual address */
|
40 | 35b66fc4 | bellard | #if TARGET_LONG_SIZE == 4 |
41 | 6cfd9b52 | Paolo Bonzini | typedef int32_t target_long;
|
42 | 6cfd9b52 | Paolo Bonzini | typedef uint32_t target_ulong;
|
43 | c27004ec | bellard | #define TARGET_FMT_lx "%08x" |
44 | b62b461b | j_mayer | #define TARGET_FMT_ld "%d" |
45 | 71c8b8fd | j_mayer | #define TARGET_FMT_lu "%u" |
46 | 35b66fc4 | bellard | #elif TARGET_LONG_SIZE == 8 |
47 | 6cfd9b52 | Paolo Bonzini | typedef int64_t target_long;
|
48 | 6cfd9b52 | Paolo Bonzini | typedef uint64_t target_ulong;
|
49 | 26a76461 | bellard | #define TARGET_FMT_lx "%016" PRIx64 |
50 | b62b461b | j_mayer | #define TARGET_FMT_ld "%" PRId64 |
51 | 71c8b8fd | j_mayer | #define TARGET_FMT_lu "%" PRIu64 |
52 | 35b66fc4 | bellard | #else
|
53 | 35b66fc4 | bellard | #error TARGET_LONG_SIZE undefined
|
54 | 35b66fc4 | bellard | #endif
|
55 | 35b66fc4 | bellard | |
56 | 2be0071f | bellard | #define EXCP_INTERRUPT 0x10000 /* async interruption */ |
57 | 2be0071f | bellard | #define EXCP_HLT 0x10001 /* hlt instruction reached */ |
58 | 2be0071f | bellard | #define EXCP_DEBUG 0x10002 /* cpu stopped after a breakpoint or singlestep */ |
59 | 5a1e3cfc | bellard | #define EXCP_HALTED 0x10003 /* cpu is halted (waiting for external event) */ |
60 | ab93bbe2 | bellard | |
61 | a316d335 | bellard | #define TB_JMP_CACHE_BITS 12 |
62 | a316d335 | bellard | #define TB_JMP_CACHE_SIZE (1 << TB_JMP_CACHE_BITS) |
63 | a316d335 | bellard | |
64 | b362e5e0 | pbrook | /* Only the bottom TB_JMP_PAGE_BITS of the jump cache hash bits vary for
|
65 | b362e5e0 | pbrook | addresses on the same page. The top bits are the same. This allows
|
66 | b362e5e0 | pbrook | TLB invalidation to quickly clear a subset of the hash table. */
|
67 | b362e5e0 | pbrook | #define TB_JMP_PAGE_BITS (TB_JMP_CACHE_BITS / 2) |
68 | b362e5e0 | pbrook | #define TB_JMP_PAGE_SIZE (1 << TB_JMP_PAGE_BITS) |
69 | b362e5e0 | pbrook | #define TB_JMP_ADDR_MASK (TB_JMP_PAGE_SIZE - 1) |
70 | b362e5e0 | pbrook | #define TB_JMP_PAGE_MASK (TB_JMP_CACHE_SIZE - TB_JMP_PAGE_SIZE)
|
71 | b362e5e0 | pbrook | |
72 | 20cb400d | Paul Brook | #if !defined(CONFIG_USER_ONLY)
|
73 | 84b7b8e7 | bellard | #define CPU_TLB_BITS 8 |
74 | 84b7b8e7 | bellard | #define CPU_TLB_SIZE (1 << CPU_TLB_BITS) |
75 | ab93bbe2 | bellard | |
76 | 355b1943 | Paul Brook | #if HOST_LONG_BITS == 32 && TARGET_LONG_BITS == 32 |
77 | d656469f | bellard | #define CPU_TLB_ENTRY_BITS 4 |
78 | d656469f | bellard | #else
|
79 | d656469f | bellard | #define CPU_TLB_ENTRY_BITS 5 |
80 | d656469f | bellard | #endif
|
81 | d656469f | bellard | |
82 | ab93bbe2 | bellard | typedef struct CPUTLBEntry { |
83 | 0f459d16 | pbrook | /* bit TARGET_LONG_BITS to TARGET_PAGE_BITS : virtual address
|
84 | 0f459d16 | pbrook | bit TARGET_PAGE_BITS-1..4 : Nonzero for accesses that should not
|
85 | 0f459d16 | pbrook | go directly to ram.
|
86 | db8d7466 | bellard | bit 3 : indicates that the entry is invalid
|
87 | db8d7466 | bellard | bit 2..0 : zero
|
88 | db8d7466 | bellard | */
|
89 | 5fafdf24 | ths | target_ulong addr_read; |
90 | 5fafdf24 | ths | target_ulong addr_write; |
91 | 5fafdf24 | ths | target_ulong addr_code; |
92 | 355b1943 | Paul Brook | /* Addend to virtual address to get host address. IO accesses
|
93 | ee50add9 | pbrook | use the corresponding iotlb value. */
|
94 | 3b2992e4 | Stefan Weil | uintptr_t addend; |
95 | d656469f | bellard | /* padding to get a power of two size */
|
96 | 3b2992e4 | Stefan Weil | uint8_t dummy[(1 << CPU_TLB_ENTRY_BITS) -
|
97 | 3b2992e4 | Stefan Weil | (sizeof(target_ulong) * 3 + |
98 | 3b2992e4 | Stefan Weil | ((-sizeof(target_ulong) * 3) & (sizeof(uintptr_t) - 1)) + |
99 | 3b2992e4 | Stefan Weil | sizeof(uintptr_t))];
|
100 | ab93bbe2 | bellard | } CPUTLBEntry; |
101 | ab93bbe2 | bellard | |
102 | e85ef538 | Richard Henderson | QEMU_BUILD_BUG_ON(sizeof(CPUTLBEntry) != (1 << CPU_TLB_ENTRY_BITS)); |
103 | 355b1943 | Paul Brook | |
104 | 20cb400d | Paul Brook | #define CPU_COMMON_TLB \
|
105 | 20cb400d | Paul Brook | /* The meaning of the MMU modes is defined in the target code. */ \
|
106 | 20cb400d | Paul Brook | CPUTLBEntry tlb_table[NB_MMU_MODES][CPU_TLB_SIZE]; \ |
107 | a8170e5e | Avi Kivity | hwaddr iotlb[NB_MMU_MODES][CPU_TLB_SIZE]; \ |
108 | d4c430a8 | Paul Brook | target_ulong tlb_flush_addr; \ |
109 | d4c430a8 | Paul Brook | target_ulong tlb_flush_mask; |
110 | 20cb400d | Paul Brook | |
111 | 20cb400d | Paul Brook | #else
|
112 | 20cb400d | Paul Brook | |
113 | 20cb400d | Paul Brook | #define CPU_COMMON_TLB
|
114 | 20cb400d | Paul Brook | |
115 | 20cb400d | Paul Brook | #endif
|
116 | 20cb400d | Paul Brook | |
117 | 20cb400d | Paul Brook | |
118 | e2542fe2 | Juan Quintela | #ifdef HOST_WORDS_BIGENDIAN
|
119 | 2e70f6ef | pbrook | typedef struct icount_decr_u16 { |
120 | 2e70f6ef | pbrook | uint16_t high; |
121 | 2e70f6ef | pbrook | uint16_t low; |
122 | 2e70f6ef | pbrook | } icount_decr_u16; |
123 | 2e70f6ef | pbrook | #else
|
124 | 2e70f6ef | pbrook | typedef struct icount_decr_u16 { |
125 | 2e70f6ef | pbrook | uint16_t low; |
126 | 2e70f6ef | pbrook | uint16_t high; |
127 | 2e70f6ef | pbrook | } icount_decr_u16; |
128 | 2e70f6ef | pbrook | #endif
|
129 | 2e70f6ef | pbrook | |
130 | a1d1bb31 | aliguori | typedef struct CPUBreakpoint { |
131 | a1d1bb31 | aliguori | target_ulong pc; |
132 | a1d1bb31 | aliguori | int flags; /* BP_* */ |
133 | 72cf2d4f | Blue Swirl | QTAILQ_ENTRY(CPUBreakpoint) entry; |
134 | a1d1bb31 | aliguori | } CPUBreakpoint; |
135 | a1d1bb31 | aliguori | |
136 | a1d1bb31 | aliguori | typedef struct CPUWatchpoint { |
137 | a1d1bb31 | aliguori | target_ulong vaddr; |
138 | a1d1bb31 | aliguori | target_ulong len_mask; |
139 | a1d1bb31 | aliguori | int flags; /* BP_* */ |
140 | 72cf2d4f | Blue Swirl | QTAILQ_ENTRY(CPUWatchpoint) entry; |
141 | a1d1bb31 | aliguori | } CPUWatchpoint; |
142 | a1d1bb31 | aliguori | |
143 | a20e31dc | blueswir1 | #define CPU_TEMP_BUF_NLONGS 128 |
144 | a316d335 | bellard | #define CPU_COMMON \
|
145 | a316d335 | bellard | /* soft mmu support */ \
|
146 | 2e70f6ef | pbrook | /* in order to avoid passing too many arguments to the MMIO \
|
147 | 2e70f6ef | pbrook | helpers, we store some rarely used information in the CPU \
|
148 | a316d335 | bellard | context) */ \
|
149 | 20503968 | Blue Swirl | uintptr_t mem_io_pc; /* host pc at which the memory was \
|
150 | 20503968 | Blue Swirl | accessed */ \
|
151 | 2e70f6ef | pbrook | target_ulong mem_io_vaddr; /* target virtual addr at which the \
|
152 | 2e70f6ef | pbrook | memory was accessed */ \
|
153 | 20cb400d | Paul Brook | CPU_COMMON_TLB \ |
154 | a316d335 | bellard | struct TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE]; \
|
155 | a20e31dc | blueswir1 | /* buffer for temporaries in the code generator */ \
|
156 | a20e31dc | blueswir1 | long temp_buf[CPU_TEMP_BUF_NLONGS]; \
|
157 | a316d335 | bellard | \ |
158 | 2e70f6ef | pbrook | int64_t icount_extra; /* Instructions until next timer event. */ \
|
159 | 2e70f6ef | pbrook | /* Number of cycles left, with interrupt flag in high bit. \
|
160 | 2e70f6ef | pbrook | This allows a single read-compare-cbranch-write sequence to test \
|
161 | 2e70f6ef | pbrook | for both decrementer underflow and exceptions. */ \
|
162 | 2e70f6ef | pbrook | union { \
|
163 | 2e70f6ef | pbrook | uint32_t u32; \ |
164 | 2e70f6ef | pbrook | icount_decr_u16 u16; \ |
165 | 2e70f6ef | pbrook | } icount_decr; \ |
166 | 2e70f6ef | pbrook | uint32_t can_do_io; /* nonzero if memory mapped IO is safe. */ \
|
167 | 2e70f6ef | pbrook | \ |
168 | a316d335 | bellard | /* from this point: preserved by CPU reset */ \
|
169 | a316d335 | bellard | /* ice debug support */ \
|
170 | 72cf2d4f | Blue Swirl | QTAILQ_HEAD(breakpoints_head, CPUBreakpoint) breakpoints; \ |
171 | a316d335 | bellard | int singlestep_enabled; \
|
172 | a316d335 | bellard | \ |
173 | 72cf2d4f | Blue Swirl | QTAILQ_HEAD(watchpoints_head, CPUWatchpoint) watchpoints; \ |
174 | a1d1bb31 | aliguori | CPUWatchpoint *watchpoint_hit; \ |
175 | 56aebc89 | pbrook | \ |
176 | 56aebc89 | pbrook | struct GDBRegisterState *gdb_regs; \
|
177 | 6658ffb8 | pbrook | \ |
178 | 9133e39b | bellard | /* Core interrupt code */ \
|
179 | 6ab7e546 | Peter Maydell | sigjmp_buf jmp_env; \ |
180 | acb6685f | Anthony Liguori | int exception_index; \
|
181 | 9133e39b | bellard | \ |
182 | 9349b4f9 | Andreas Färber | CPUArchState *next_cpu; /* next CPU sharing TB cache */ \
|
183 | a316d335 | bellard | /* user data */ \
|
184 | 01ba9816 | ths | void *opaque; \
|
185 | 01ba9816 | ths | \ |
186 | f7575c96 | Andreas Färber | const char *cpu_model_str; |
187 | a316d335 | bellard | |
188 | ab93bbe2 | bellard | #endif |