root / cpu-all.h @ 2a2af967
History | View | Annotate | Download (15.1 kB)
1 | 5a9fdfec | bellard | /*
|
---|---|---|---|
2 | 5a9fdfec | bellard | * defines common to all virtual CPUs
|
3 | 5fafdf24 | ths | *
|
4 | 5a9fdfec | bellard | * Copyright (c) 2003 Fabrice Bellard
|
5 | 5a9fdfec | bellard | *
|
6 | 5a9fdfec | bellard | * This library is free software; you can redistribute it and/or
|
7 | 5a9fdfec | bellard | * modify it under the terms of the GNU Lesser General Public
|
8 | 5a9fdfec | bellard | * License as published by the Free Software Foundation; either
|
9 | 5a9fdfec | bellard | * version 2 of the License, or (at your option) any later version.
|
10 | 5a9fdfec | bellard | *
|
11 | 5a9fdfec | bellard | * This library is distributed in the hope that it will be useful,
|
12 | 5a9fdfec | bellard | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 5a9fdfec | bellard | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | 5a9fdfec | bellard | * Lesser General Public License for more details.
|
15 | 5a9fdfec | bellard | *
|
16 | 5a9fdfec | 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 | 5a9fdfec | bellard | */
|
19 | 5a9fdfec | bellard | #ifndef CPU_ALL_H
|
20 | 5a9fdfec | bellard | #define CPU_ALL_H
|
21 | 5a9fdfec | bellard | |
22 | 7d99a001 | blueswir1 | #include "qemu-common.h" |
23 | b3c4bbe5 | Paolo Bonzini | #include "qemu-tls.h" |
24 | 1ad2134f | Paul Brook | #include "cpu-common.h" |
25 | 0ac4bd56 | bellard | |
26 | 5fafdf24 | ths | /* some important defines:
|
27 | 5fafdf24 | ths | *
|
28 | 0ac4bd56 | bellard | * WORDS_ALIGNED : if defined, the host cpu can only make word aligned
|
29 | 0ac4bd56 | bellard | * memory accesses.
|
30 | 5fafdf24 | ths | *
|
31 | e2542fe2 | Juan Quintela | * HOST_WORDS_BIGENDIAN : if defined, the host cpu is big endian and
|
32 | 0ac4bd56 | bellard | * otherwise little endian.
|
33 | 5fafdf24 | ths | *
|
34 | 0ac4bd56 | bellard | * (TARGET_WORDS_ALIGNED : same for target cpu (not supported yet))
|
35 | 5fafdf24 | ths | *
|
36 | 0ac4bd56 | bellard | * TARGET_WORDS_BIGENDIAN : same for target cpu
|
37 | 0ac4bd56 | bellard | */
|
38 | 0ac4bd56 | bellard | |
39 | e2542fe2 | Juan Quintela | #if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN)
|
40 | f193c797 | bellard | #define BSWAP_NEEDED
|
41 | f193c797 | bellard | #endif
|
42 | f193c797 | bellard | |
43 | f193c797 | bellard | #ifdef BSWAP_NEEDED
|
44 | f193c797 | bellard | |
45 | f193c797 | bellard | static inline uint16_t tswap16(uint16_t s) |
46 | f193c797 | bellard | { |
47 | f193c797 | bellard | return bswap16(s);
|
48 | f193c797 | bellard | } |
49 | f193c797 | bellard | |
50 | f193c797 | bellard | static inline uint32_t tswap32(uint32_t s) |
51 | f193c797 | bellard | { |
52 | f193c797 | bellard | return bswap32(s);
|
53 | f193c797 | bellard | } |
54 | f193c797 | bellard | |
55 | f193c797 | bellard | static inline uint64_t tswap64(uint64_t s) |
56 | f193c797 | bellard | { |
57 | f193c797 | bellard | return bswap64(s);
|
58 | f193c797 | bellard | } |
59 | f193c797 | bellard | |
60 | f193c797 | bellard | static inline void tswap16s(uint16_t *s) |
61 | f193c797 | bellard | { |
62 | f193c797 | bellard | *s = bswap16(*s); |
63 | f193c797 | bellard | } |
64 | f193c797 | bellard | |
65 | f193c797 | bellard | static inline void tswap32s(uint32_t *s) |
66 | f193c797 | bellard | { |
67 | f193c797 | bellard | *s = bswap32(*s); |
68 | f193c797 | bellard | } |
69 | f193c797 | bellard | |
70 | f193c797 | bellard | static inline void tswap64s(uint64_t *s) |
71 | f193c797 | bellard | { |
72 | f193c797 | bellard | *s = bswap64(*s); |
73 | f193c797 | bellard | } |
74 | f193c797 | bellard | |
75 | f193c797 | bellard | #else
|
76 | f193c797 | bellard | |
77 | f193c797 | bellard | static inline uint16_t tswap16(uint16_t s) |
78 | f193c797 | bellard | { |
79 | f193c797 | bellard | return s;
|
80 | f193c797 | bellard | } |
81 | f193c797 | bellard | |
82 | f193c797 | bellard | static inline uint32_t tswap32(uint32_t s) |
83 | f193c797 | bellard | { |
84 | f193c797 | bellard | return s;
|
85 | f193c797 | bellard | } |
86 | f193c797 | bellard | |
87 | f193c797 | bellard | static inline uint64_t tswap64(uint64_t s) |
88 | f193c797 | bellard | { |
89 | f193c797 | bellard | return s;
|
90 | f193c797 | bellard | } |
91 | f193c797 | bellard | |
92 | f193c797 | bellard | static inline void tswap16s(uint16_t *s) |
93 | f193c797 | bellard | { |
94 | f193c797 | bellard | } |
95 | f193c797 | bellard | |
96 | f193c797 | bellard | static inline void tswap32s(uint32_t *s) |
97 | f193c797 | bellard | { |
98 | f193c797 | bellard | } |
99 | f193c797 | bellard | |
100 | f193c797 | bellard | static inline void tswap64s(uint64_t *s) |
101 | f193c797 | bellard | { |
102 | f193c797 | bellard | } |
103 | f193c797 | bellard | |
104 | f193c797 | bellard | #endif
|
105 | f193c797 | bellard | |
106 | f193c797 | bellard | #if TARGET_LONG_SIZE == 4 |
107 | f193c797 | bellard | #define tswapl(s) tswap32(s)
|
108 | f193c797 | bellard | #define tswapls(s) tswap32s((uint32_t *)(s))
|
109 | 0a962c02 | bellard | #define bswaptls(s) bswap32s(s)
|
110 | f193c797 | bellard | #else
|
111 | f193c797 | bellard | #define tswapl(s) tswap64(s)
|
112 | f193c797 | bellard | #define tswapls(s) tswap64s((uint64_t *)(s))
|
113 | 0a962c02 | bellard | #define bswaptls(s) bswap64s(s)
|
114 | f193c797 | bellard | #endif
|
115 | f193c797 | bellard | |
116 | 61382a50 | bellard | /* CPU memory access without any memory or io remapping */
|
117 | 61382a50 | bellard | |
118 | 83d73968 | bellard | /*
|
119 | 83d73968 | bellard | * the generic syntax for the memory accesses is:
|
120 | 83d73968 | bellard | *
|
121 | 83d73968 | bellard | * load: ld{type}{sign}{size}{endian}_{access_type}(ptr)
|
122 | 83d73968 | bellard | *
|
123 | 83d73968 | bellard | * store: st{type}{size}{endian}_{access_type}(ptr, val)
|
124 | 83d73968 | bellard | *
|
125 | 83d73968 | bellard | * type is:
|
126 | 83d73968 | bellard | * (empty): integer access
|
127 | 83d73968 | bellard | * f : float access
|
128 | 5fafdf24 | ths | *
|
129 | 83d73968 | bellard | * sign is:
|
130 | 83d73968 | bellard | * (empty): for floats or 32 bit size
|
131 | 83d73968 | bellard | * u : unsigned
|
132 | 83d73968 | bellard | * s : signed
|
133 | 83d73968 | bellard | *
|
134 | 83d73968 | bellard | * size is:
|
135 | 83d73968 | bellard | * b: 8 bits
|
136 | 83d73968 | bellard | * w: 16 bits
|
137 | 83d73968 | bellard | * l: 32 bits
|
138 | 83d73968 | bellard | * q: 64 bits
|
139 | 5fafdf24 | ths | *
|
140 | 83d73968 | bellard | * endian is:
|
141 | 83d73968 | bellard | * (empty): target cpu endianness or 8 bit access
|
142 | 83d73968 | bellard | * r : reversed target cpu endianness (not implemented yet)
|
143 | 83d73968 | bellard | * be : big endian (not implemented yet)
|
144 | 83d73968 | bellard | * le : little endian (not implemented yet)
|
145 | 83d73968 | bellard | *
|
146 | 83d73968 | bellard | * access_type is:
|
147 | 83d73968 | bellard | * raw : host memory access
|
148 | 83d73968 | bellard | * user : user mode access using soft MMU
|
149 | 83d73968 | bellard | * kernel : kernel mode access using soft MMU
|
150 | 83d73968 | bellard | */
|
151 | 2df3b95d | bellard | |
152 | cbbab922 | Paolo Bonzini | /* target-endianness CPU memory access functions */
|
153 | 2df3b95d | bellard | #if defined(TARGET_WORDS_BIGENDIAN)
|
154 | 2df3b95d | bellard | #define lduw_p(p) lduw_be_p(p)
|
155 | 2df3b95d | bellard | #define ldsw_p(p) ldsw_be_p(p)
|
156 | 2df3b95d | bellard | #define ldl_p(p) ldl_be_p(p)
|
157 | 2df3b95d | bellard | #define ldq_p(p) ldq_be_p(p)
|
158 | 2df3b95d | bellard | #define ldfl_p(p) ldfl_be_p(p)
|
159 | 2df3b95d | bellard | #define ldfq_p(p) ldfq_be_p(p)
|
160 | 2df3b95d | bellard | #define stw_p(p, v) stw_be_p(p, v)
|
161 | 2df3b95d | bellard | #define stl_p(p, v) stl_be_p(p, v)
|
162 | 2df3b95d | bellard | #define stq_p(p, v) stq_be_p(p, v)
|
163 | 2df3b95d | bellard | #define stfl_p(p, v) stfl_be_p(p, v)
|
164 | 2df3b95d | bellard | #define stfq_p(p, v) stfq_be_p(p, v)
|
165 | 2df3b95d | bellard | #else
|
166 | 2df3b95d | bellard | #define lduw_p(p) lduw_le_p(p)
|
167 | 2df3b95d | bellard | #define ldsw_p(p) ldsw_le_p(p)
|
168 | 2df3b95d | bellard | #define ldl_p(p) ldl_le_p(p)
|
169 | 2df3b95d | bellard | #define ldq_p(p) ldq_le_p(p)
|
170 | 2df3b95d | bellard | #define ldfl_p(p) ldfl_le_p(p)
|
171 | 2df3b95d | bellard | #define ldfq_p(p) ldfq_le_p(p)
|
172 | 2df3b95d | bellard | #define stw_p(p, v) stw_le_p(p, v)
|
173 | 2df3b95d | bellard | #define stl_p(p, v) stl_le_p(p, v)
|
174 | 2df3b95d | bellard | #define stq_p(p, v) stq_le_p(p, v)
|
175 | 2df3b95d | bellard | #define stfl_p(p, v) stfl_le_p(p, v)
|
176 | 2df3b95d | bellard | #define stfq_p(p, v) stfq_le_p(p, v)
|
177 | 5a9fdfec | bellard | #endif
|
178 | 5a9fdfec | bellard | |
179 | 61382a50 | bellard | /* MMU memory access macros */
|
180 | 61382a50 | bellard | |
181 | 53a5960a | pbrook | #if defined(CONFIG_USER_ONLY)
|
182 | 0e62fd79 | aurel32 | #include <assert.h> |
183 | 0e62fd79 | aurel32 | #include "qemu-types.h" |
184 | 0e62fd79 | aurel32 | |
185 | 53a5960a | pbrook | /* On some host systems the guest address space is reserved on the host.
|
186 | 53a5960a | pbrook | * This allows the guest address space to be offset to a convenient location.
|
187 | 53a5960a | pbrook | */
|
188 | 379f6698 | Paul Brook | #if defined(CONFIG_USE_GUEST_BASE)
|
189 | 379f6698 | Paul Brook | extern unsigned long guest_base; |
190 | 379f6698 | Paul Brook | extern int have_guest_base; |
191 | 68a1c816 | Paul Brook | extern unsigned long reserved_va; |
192 | 379f6698 | Paul Brook | #define GUEST_BASE guest_base
|
193 | 18e9ea8a | Aurelien Jarno | #define RESERVED_VA reserved_va
|
194 | 379f6698 | Paul Brook | #else
|
195 | 379f6698 | Paul Brook | #define GUEST_BASE 0ul |
196 | 18e9ea8a | Aurelien Jarno | #define RESERVED_VA 0ul |
197 | 379f6698 | Paul Brook | #endif
|
198 | 53a5960a | pbrook | |
199 | 53a5960a | pbrook | /* All direct uses of g2h and h2g need to go away for usermode softmmu. */
|
200 | 53a5960a | pbrook | #define g2h(x) ((void *)((unsigned long)(x) + GUEST_BASE)) |
201 | b9f83121 | Richard Henderson | |
202 | b9f83121 | Richard Henderson | #if HOST_LONG_BITS <= TARGET_VIRT_ADDR_SPACE_BITS
|
203 | b9f83121 | Richard Henderson | #define h2g_valid(x) 1 |
204 | b9f83121 | Richard Henderson | #else
|
205 | b9f83121 | Richard Henderson | #define h2g_valid(x) ({ \
|
206 | b9f83121 | Richard Henderson | unsigned long __guest = (unsigned long)(x) - GUEST_BASE; \ |
207 | b9f83121 | Richard Henderson | __guest < (1ul << TARGET_VIRT_ADDR_SPACE_BITS); \
|
208 | b9f83121 | Richard Henderson | }) |
209 | b9f83121 | Richard Henderson | #endif
|
210 | b9f83121 | Richard Henderson | |
211 | 0e62fd79 | aurel32 | #define h2g(x) ({ \
|
212 | 0e62fd79 | aurel32 | unsigned long __ret = (unsigned long)(x) - GUEST_BASE; \ |
213 | 0e62fd79 | aurel32 | /* Check if given address fits target address space */ \
|
214 | b9f83121 | Richard Henderson | assert(h2g_valid(x)); \ |
215 | 0e62fd79 | aurel32 | (abi_ulong)__ret; \ |
216 | 0e62fd79 | aurel32 | }) |
217 | 53a5960a | pbrook | |
218 | 53a5960a | pbrook | #define saddr(x) g2h(x)
|
219 | 53a5960a | pbrook | #define laddr(x) g2h(x)
|
220 | 53a5960a | pbrook | |
221 | 53a5960a | pbrook | #else /* !CONFIG_USER_ONLY */ |
222 | c27004ec | bellard | /* NOTE: we use double casts if pointers and target_ulong have
|
223 | c27004ec | bellard | different sizes */
|
224 | 53a5960a | pbrook | #define saddr(x) (uint8_t *)(long)(x) |
225 | 53a5960a | pbrook | #define laddr(x) (uint8_t *)(long)(x) |
226 | 53a5960a | pbrook | #endif
|
227 | 53a5960a | pbrook | |
228 | 53a5960a | pbrook | #define ldub_raw(p) ldub_p(laddr((p)))
|
229 | 53a5960a | pbrook | #define ldsb_raw(p) ldsb_p(laddr((p)))
|
230 | 53a5960a | pbrook | #define lduw_raw(p) lduw_p(laddr((p)))
|
231 | 53a5960a | pbrook | #define ldsw_raw(p) ldsw_p(laddr((p)))
|
232 | 53a5960a | pbrook | #define ldl_raw(p) ldl_p(laddr((p)))
|
233 | 53a5960a | pbrook | #define ldq_raw(p) ldq_p(laddr((p)))
|
234 | 53a5960a | pbrook | #define ldfl_raw(p) ldfl_p(laddr((p)))
|
235 | 53a5960a | pbrook | #define ldfq_raw(p) ldfq_p(laddr((p)))
|
236 | 53a5960a | pbrook | #define stb_raw(p, v) stb_p(saddr((p)), v)
|
237 | 53a5960a | pbrook | #define stw_raw(p, v) stw_p(saddr((p)), v)
|
238 | 53a5960a | pbrook | #define stl_raw(p, v) stl_p(saddr((p)), v)
|
239 | 53a5960a | pbrook | #define stq_raw(p, v) stq_p(saddr((p)), v)
|
240 | 53a5960a | pbrook | #define stfl_raw(p, v) stfl_p(saddr((p)), v)
|
241 | 53a5960a | pbrook | #define stfq_raw(p, v) stfq_p(saddr((p)), v)
|
242 | c27004ec | bellard | |
243 | c27004ec | bellard | |
244 | 5fafdf24 | ths | #if defined(CONFIG_USER_ONLY)
|
245 | 61382a50 | bellard | |
246 | 61382a50 | bellard | /* if user mode, no other memory access functions */
|
247 | 61382a50 | bellard | #define ldub(p) ldub_raw(p)
|
248 | 61382a50 | bellard | #define ldsb(p) ldsb_raw(p)
|
249 | 61382a50 | bellard | #define lduw(p) lduw_raw(p)
|
250 | 61382a50 | bellard | #define ldsw(p) ldsw_raw(p)
|
251 | 61382a50 | bellard | #define ldl(p) ldl_raw(p)
|
252 | 61382a50 | bellard | #define ldq(p) ldq_raw(p)
|
253 | 61382a50 | bellard | #define ldfl(p) ldfl_raw(p)
|
254 | 61382a50 | bellard | #define ldfq(p) ldfq_raw(p)
|
255 | 61382a50 | bellard | #define stb(p, v) stb_raw(p, v)
|
256 | 61382a50 | bellard | #define stw(p, v) stw_raw(p, v)
|
257 | 61382a50 | bellard | #define stl(p, v) stl_raw(p, v)
|
258 | 61382a50 | bellard | #define stq(p, v) stq_raw(p, v)
|
259 | 61382a50 | bellard | #define stfl(p, v) stfl_raw(p, v)
|
260 | 61382a50 | bellard | #define stfq(p, v) stfq_raw(p, v)
|
261 | 61382a50 | bellard | |
262 | 61382a50 | bellard | #define ldub_code(p) ldub_raw(p)
|
263 | 61382a50 | bellard | #define ldsb_code(p) ldsb_raw(p)
|
264 | 61382a50 | bellard | #define lduw_code(p) lduw_raw(p)
|
265 | 61382a50 | bellard | #define ldsw_code(p) ldsw_raw(p)
|
266 | 61382a50 | bellard | #define ldl_code(p) ldl_raw(p)
|
267 | bc98a7ef | j_mayer | #define ldq_code(p) ldq_raw(p)
|
268 | 61382a50 | bellard | |
269 | 61382a50 | bellard | #define ldub_kernel(p) ldub_raw(p)
|
270 | 61382a50 | bellard | #define ldsb_kernel(p) ldsb_raw(p)
|
271 | 61382a50 | bellard | #define lduw_kernel(p) lduw_raw(p)
|
272 | 61382a50 | bellard | #define ldsw_kernel(p) ldsw_raw(p)
|
273 | 61382a50 | bellard | #define ldl_kernel(p) ldl_raw(p)
|
274 | bc98a7ef | j_mayer | #define ldq_kernel(p) ldq_raw(p)
|
275 | 0ac4bd56 | bellard | #define ldfl_kernel(p) ldfl_raw(p)
|
276 | 0ac4bd56 | bellard | #define ldfq_kernel(p) ldfq_raw(p)
|
277 | 61382a50 | bellard | #define stb_kernel(p, v) stb_raw(p, v)
|
278 | 61382a50 | bellard | #define stw_kernel(p, v) stw_raw(p, v)
|
279 | 61382a50 | bellard | #define stl_kernel(p, v) stl_raw(p, v)
|
280 | 61382a50 | bellard | #define stq_kernel(p, v) stq_raw(p, v)
|
281 | 0ac4bd56 | bellard | #define stfl_kernel(p, v) stfl_raw(p, v)
|
282 | 0ac4bd56 | bellard | #define stfq_kernel(p, vt) stfq_raw(p, v)
|
283 | 61382a50 | bellard | |
284 | 61382a50 | bellard | #endif /* defined(CONFIG_USER_ONLY) */ |
285 | 61382a50 | bellard | |
286 | 5a9fdfec | bellard | /* page related stuff */
|
287 | 5a9fdfec | bellard | |
288 | 03875444 | aurel32 | #define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS) |
289 | 5a9fdfec | bellard | #define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1) |
290 | 5a9fdfec | bellard | #define TARGET_PAGE_ALIGN(addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK) |
291 | 5a9fdfec | bellard | |
292 | 53a5960a | pbrook | /* ??? These should be the larger of unsigned long and target_ulong. */
|
293 | 83fb7adf | bellard | extern unsigned long qemu_real_host_page_size; |
294 | 83fb7adf | bellard | extern unsigned long qemu_host_page_size; |
295 | 83fb7adf | bellard | extern unsigned long qemu_host_page_mask; |
296 | 5a9fdfec | bellard | |
297 | 83fb7adf | bellard | #define HOST_PAGE_ALIGN(addr) (((addr) + qemu_host_page_size - 1) & qemu_host_page_mask) |
298 | 5a9fdfec | bellard | |
299 | 5a9fdfec | bellard | /* same as PROT_xxx */
|
300 | 5a9fdfec | bellard | #define PAGE_READ 0x0001 |
301 | 5a9fdfec | bellard | #define PAGE_WRITE 0x0002 |
302 | 5a9fdfec | bellard | #define PAGE_EXEC 0x0004 |
303 | 5a9fdfec | bellard | #define PAGE_BITS (PAGE_READ | PAGE_WRITE | PAGE_EXEC)
|
304 | 5a9fdfec | bellard | #define PAGE_VALID 0x0008 |
305 | 5a9fdfec | bellard | /* original state of the write flag (used when tracking self-modifying
|
306 | 5a9fdfec | bellard | code */
|
307 | 5fafdf24 | ths | #define PAGE_WRITE_ORG 0x0010 |
308 | 2e9a5713 | Paul Brook | #if defined(CONFIG_BSD) && defined(CONFIG_USER_ONLY)
|
309 | 2e9a5713 | Paul Brook | /* FIXME: Code that sets/uses this is broken and needs to go away. */
|
310 | 50a9569b | balrog | #define PAGE_RESERVED 0x0020 |
311 | 2e9a5713 | Paul Brook | #endif
|
312 | 5a9fdfec | bellard | |
313 | b480d9b7 | Paul Brook | #if defined(CONFIG_USER_ONLY)
|
314 | 5a9fdfec | bellard | void page_dump(FILE *f);
|
315 | 5cd2c5b6 | Richard Henderson | |
316 | b480d9b7 | Paul Brook | typedef int (*walk_memory_regions_fn)(void *, abi_ulong, |
317 | b480d9b7 | Paul Brook | abi_ulong, unsigned long); |
318 | 5cd2c5b6 | Richard Henderson | int walk_memory_regions(void *, walk_memory_regions_fn); |
319 | 5cd2c5b6 | Richard Henderson | |
320 | 53a5960a | pbrook | int page_get_flags(target_ulong address);
|
321 | 53a5960a | pbrook | void page_set_flags(target_ulong start, target_ulong end, int flags); |
322 | 3d97b40b | ths | int page_check_range(target_ulong start, target_ulong len, int flags); |
323 | b480d9b7 | Paul Brook | #endif
|
324 | 5a9fdfec | bellard | |
325 | c5be9f08 | ths | CPUState *cpu_copy(CPUState *env); |
326 | 950f1472 | Glauber Costa | CPUState *qemu_get_cpu(int cpu);
|
327 | c5be9f08 | ths | |
328 | f5c848ee | Jan Kiszka | #define CPU_DUMP_CODE 0x00010000 |
329 | f5c848ee | Jan Kiszka | |
330 | 9a78eead | Stefan Weil | void cpu_dump_state(CPUState *env, FILE *f, fprintf_function cpu_fprintf,
|
331 | 7fe48483 | bellard | int flags);
|
332 | 9a78eead | Stefan Weil | void cpu_dump_statistics(CPUState *env, FILE *f, fprintf_function cpu_fprintf,
|
333 | 9a78eead | Stefan Weil | int flags);
|
334 | 7fe48483 | bellard | |
335 | a5e50b26 | malc | void QEMU_NORETURN cpu_abort(CPUState *env, const char *fmt, ...) |
336 | 2c80e423 | Stefan Weil | GCC_FMT_ATTR(2, 3); |
337 | f0aca822 | bellard | extern CPUState *first_cpu;
|
338 | b3c4bbe5 | Paolo Bonzini | DECLARE_TLS(CPUState *,cpu_single_env); |
339 | 4a2dd92d | Jan Kiszka | #define cpu_single_env tls_var(cpu_single_env)
|
340 | db1a4972 | Paolo Bonzini | |
341 | 9c76219e | Richard Henderson | /* Flags for use in ENV->INTERRUPT_PENDING.
|
342 | 9c76219e | Richard Henderson | |
343 | 9c76219e | Richard Henderson | The numbers assigned here are non-sequential in order to preserve
|
344 | 9c76219e | Richard Henderson | binary compatibility with the vmstate dump. Bit 0 (0x0001) was
|
345 | 9c76219e | Richard Henderson | previously used for CPU_INTERRUPT_EXIT, and is cleared when loading
|
346 | 9c76219e | Richard Henderson | the vmstate dump. */
|
347 | 9c76219e | Richard Henderson | |
348 | 9c76219e | Richard Henderson | /* External hardware interrupt pending. This is typically used for
|
349 | 9c76219e | Richard Henderson | interrupts from devices. */
|
350 | 9c76219e | Richard Henderson | #define CPU_INTERRUPT_HARD 0x0002 |
351 | 9c76219e | Richard Henderson | |
352 | 9c76219e | Richard Henderson | /* Exit the current TB. This is typically used when some system-level device
|
353 | 9c76219e | Richard Henderson | makes some change to the memory mapping. E.g. the a20 line change. */
|
354 | 9c76219e | Richard Henderson | #define CPU_INTERRUPT_EXITTB 0x0004 |
355 | 9c76219e | Richard Henderson | |
356 | 9c76219e | Richard Henderson | /* Halt the CPU. */
|
357 | 9c76219e | Richard Henderson | #define CPU_INTERRUPT_HALT 0x0020 |
358 | 9c76219e | Richard Henderson | |
359 | 9c76219e | Richard Henderson | /* Debug event pending. */
|
360 | 9c76219e | Richard Henderson | #define CPU_INTERRUPT_DEBUG 0x0080 |
361 | 9c76219e | Richard Henderson | |
362 | 9c76219e | Richard Henderson | /* Several target-specific external hardware interrupts. Each target/cpu.h
|
363 | 9c76219e | Richard Henderson | should define proper names based on these defines. */
|
364 | 9c76219e | Richard Henderson | #define CPU_INTERRUPT_TGT_EXT_0 0x0008 |
365 | 9c76219e | Richard Henderson | #define CPU_INTERRUPT_TGT_EXT_1 0x0010 |
366 | 9c76219e | Richard Henderson | #define CPU_INTERRUPT_TGT_EXT_2 0x0040 |
367 | 9c76219e | Richard Henderson | #define CPU_INTERRUPT_TGT_EXT_3 0x0200 |
368 | 9c76219e | Richard Henderson | #define CPU_INTERRUPT_TGT_EXT_4 0x1000 |
369 | 9c76219e | Richard Henderson | |
370 | 9c76219e | Richard Henderson | /* Several target-specific internal interrupts. These differ from the
|
371 | 07f35073 | Dong Xu Wang | preceding target-specific interrupts in that they are intended to
|
372 | 9c76219e | Richard Henderson | originate from within the cpu itself, typically in response to some
|
373 | 9c76219e | Richard Henderson | instruction being executed. These, therefore, are not masked while
|
374 | 9c76219e | Richard Henderson | single-stepping within the debugger. */
|
375 | 9c76219e | Richard Henderson | #define CPU_INTERRUPT_TGT_INT_0 0x0100 |
376 | 9c76219e | Richard Henderson | #define CPU_INTERRUPT_TGT_INT_1 0x0400 |
377 | 9c76219e | Richard Henderson | #define CPU_INTERRUPT_TGT_INT_2 0x0800 |
378 | d362e757 | Jan Kiszka | #define CPU_INTERRUPT_TGT_INT_3 0x2000 |
379 | 9c76219e | Richard Henderson | |
380 | d362e757 | Jan Kiszka | /* First unused bit: 0x4000. */
|
381 | 9c76219e | Richard Henderson | |
382 | 3125f763 | Richard Henderson | /* The set of all bits that should be masked when single-stepping. */
|
383 | 3125f763 | Richard Henderson | #define CPU_INTERRUPT_SSTEP_MASK \
|
384 | 3125f763 | Richard Henderson | (CPU_INTERRUPT_HARD \ |
385 | 3125f763 | Richard Henderson | | CPU_INTERRUPT_TGT_EXT_0 \ |
386 | 3125f763 | Richard Henderson | | CPU_INTERRUPT_TGT_EXT_1 \ |
387 | 3125f763 | Richard Henderson | | CPU_INTERRUPT_TGT_EXT_2 \ |
388 | 3125f763 | Richard Henderson | | CPU_INTERRUPT_TGT_EXT_3 \ |
389 | 3125f763 | Richard Henderson | | CPU_INTERRUPT_TGT_EXT_4) |
390 | 98699967 | bellard | |
391 | ec6959d0 | Jan Kiszka | #ifndef CONFIG_USER_ONLY
|
392 | ec6959d0 | Jan Kiszka | typedef void (*CPUInterruptHandler)(CPUState *, int); |
393 | ec6959d0 | Jan Kiszka | |
394 | ec6959d0 | Jan Kiszka | extern CPUInterruptHandler cpu_interrupt_handler;
|
395 | ec6959d0 | Jan Kiszka | |
396 | ec6959d0 | Jan Kiszka | static inline void cpu_interrupt(CPUState *s, int mask) |
397 | ec6959d0 | Jan Kiszka | { |
398 | ec6959d0 | Jan Kiszka | cpu_interrupt_handler(s, mask); |
399 | ec6959d0 | Jan Kiszka | } |
400 | ec6959d0 | Jan Kiszka | #else /* USER_ONLY */ |
401 | ec6959d0 | Jan Kiszka | void cpu_interrupt(CPUState *env, int mask); |
402 | ec6959d0 | Jan Kiszka | #endif /* USER_ONLY */ |
403 | ec6959d0 | Jan Kiszka | |
404 | b54ad049 | bellard | void cpu_reset_interrupt(CPUState *env, int mask); |
405 | 68a79315 | bellard | |
406 | 3098dba0 | aurel32 | void cpu_exit(CPUState *s);
|
407 | 3098dba0 | aurel32 | |
408 | f3e27037 | Blue Swirl | bool qemu_cpu_has_work(CPUState *env);
|
409 | 6a4955a8 | aliguori | |
410 | a1d1bb31 | aliguori | /* Breakpoint/watchpoint flags */
|
411 | a1d1bb31 | aliguori | #define BP_MEM_READ 0x01 |
412 | a1d1bb31 | aliguori | #define BP_MEM_WRITE 0x02 |
413 | a1d1bb31 | aliguori | #define BP_MEM_ACCESS (BP_MEM_READ | BP_MEM_WRITE)
|
414 | 06d55cc1 | aliguori | #define BP_STOP_BEFORE_ACCESS 0x04 |
415 | 6e140f28 | aliguori | #define BP_WATCHPOINT_HIT 0x08 |
416 | a1d1bb31 | aliguori | #define BP_GDB 0x10 |
417 | 2dc9f411 | aliguori | #define BP_CPU 0x20 |
418 | a1d1bb31 | aliguori | |
419 | a1d1bb31 | aliguori | int cpu_breakpoint_insert(CPUState *env, target_ulong pc, int flags, |
420 | a1d1bb31 | aliguori | CPUBreakpoint **breakpoint); |
421 | a1d1bb31 | aliguori | int cpu_breakpoint_remove(CPUState *env, target_ulong pc, int flags); |
422 | a1d1bb31 | aliguori | void cpu_breakpoint_remove_by_ref(CPUState *env, CPUBreakpoint *breakpoint);
|
423 | a1d1bb31 | aliguori | void cpu_breakpoint_remove_all(CPUState *env, int mask); |
424 | a1d1bb31 | aliguori | int cpu_watchpoint_insert(CPUState *env, target_ulong addr, target_ulong len,
|
425 | a1d1bb31 | aliguori | int flags, CPUWatchpoint **watchpoint);
|
426 | a1d1bb31 | aliguori | int cpu_watchpoint_remove(CPUState *env, target_ulong addr,
|
427 | a1d1bb31 | aliguori | target_ulong len, int flags);
|
428 | a1d1bb31 | aliguori | void cpu_watchpoint_remove_by_ref(CPUState *env, CPUWatchpoint *watchpoint);
|
429 | a1d1bb31 | aliguori | void cpu_watchpoint_remove_all(CPUState *env, int mask); |
430 | 60897d36 | edgar_igl | |
431 | 60897d36 | edgar_igl | #define SSTEP_ENABLE 0x1 /* Enable simulated HW single stepping */ |
432 | 60897d36 | edgar_igl | #define SSTEP_NOIRQ 0x2 /* Do not use IRQ while single stepping */ |
433 | 60897d36 | edgar_igl | #define SSTEP_NOTIMER 0x4 /* Do not Timers while single stepping */ |
434 | 60897d36 | edgar_igl | |
435 | c33a346e | bellard | void cpu_single_step(CPUState *env, int enabled); |
436 | d95dc32d | bellard | void cpu_reset(CPUState *s);
|
437 | 3ae9501c | Marcelo Tosatti | int cpu_is_stopped(CPUState *env);
|
438 | e82bcec2 | Marcelo Tosatti | void run_on_cpu(CPUState *env, void (*func)(void *data), void *data); |
439 | 4c3a88a2 | bellard | |
440 | 5fafdf24 | ths | #define CPU_LOG_TB_OUT_ASM (1 << 0) |
441 | 9fddaa0c | bellard | #define CPU_LOG_TB_IN_ASM (1 << 1) |
442 | f193c797 | bellard | #define CPU_LOG_TB_OP (1 << 2) |
443 | f193c797 | bellard | #define CPU_LOG_TB_OP_OPT (1 << 3) |
444 | f193c797 | bellard | #define CPU_LOG_INT (1 << 4) |
445 | f193c797 | bellard | #define CPU_LOG_EXEC (1 << 5) |
446 | f193c797 | bellard | #define CPU_LOG_PCALL (1 << 6) |
447 | fd872598 | bellard | #define CPU_LOG_IOPORT (1 << 7) |
448 | 9fddaa0c | bellard | #define CPU_LOG_TB_CPU (1 << 8) |
449 | eca1bdf4 | aliguori | #define CPU_LOG_RESET (1 << 9) |
450 | f193c797 | bellard | |
451 | f193c797 | bellard | /* define log items */
|
452 | f193c797 | bellard | typedef struct CPULogItem { |
453 | f193c797 | bellard | int mask;
|
454 | f193c797 | bellard | const char *name; |
455 | f193c797 | bellard | const char *help; |
456 | f193c797 | bellard | } CPULogItem; |
457 | f193c797 | bellard | |
458 | c7cd6a37 | blueswir1 | extern const CPULogItem cpu_log_items[]; |
459 | f193c797 | bellard | |
460 | 34865134 | bellard | void cpu_set_log(int log_flags); |
461 | 34865134 | bellard | void cpu_set_log_filename(const char *filename); |
462 | f193c797 | bellard | int cpu_str_to_log_mask(const char *str); |
463 | 34865134 | bellard | |
464 | b3755a91 | Paul Brook | #if !defined(CONFIG_USER_ONLY)
|
465 | b3755a91 | Paul Brook | |
466 | 4fcc562b | Paul Brook | /* Return the physical page corresponding to a virtual one. Use it
|
467 | 4fcc562b | Paul Brook | only for debugging because no protection checks are done. Return -1
|
468 | 4fcc562b | Paul Brook | if no page found. */
|
469 | 4fcc562b | Paul Brook | target_phys_addr_t cpu_get_phys_page_debug(CPUState *env, target_ulong addr); |
470 | 4fcc562b | Paul Brook | |
471 | 33417e70 | bellard | /* memory API */
|
472 | 33417e70 | bellard | |
473 | edf75d59 | bellard | extern int phys_ram_fd; |
474 | c227f099 | Anthony Liguori | extern ram_addr_t ram_size;
|
475 | f471a17e | Alex Williamson | |
476 | cd19cfa2 | Huang Ying | /* RAM is pre-allocated and passed into qemu_ram_alloc_from_ptr */
|
477 | cd19cfa2 | Huang Ying | #define RAM_PREALLOC_MASK (1 << 0) |
478 | cd19cfa2 | Huang Ying | |
479 | f471a17e | Alex Williamson | typedef struct RAMBlock { |
480 | 7c637366 | Avi Kivity | struct MemoryRegion *mr;
|
481 | f471a17e | Alex Williamson | uint8_t *host; |
482 | f471a17e | Alex Williamson | ram_addr_t offset; |
483 | f471a17e | Alex Williamson | ram_addr_t length; |
484 | cd19cfa2 | Huang Ying | uint32_t flags; |
485 | cc9e98cb | Alex Williamson | char idstr[256]; |
486 | f471a17e | Alex Williamson | QLIST_ENTRY(RAMBlock) next; |
487 | 04b16653 | Alex Williamson | #if defined(__linux__) && !defined(TARGET_S390X)
|
488 | 04b16653 | Alex Williamson | int fd;
|
489 | 04b16653 | Alex Williamson | #endif
|
490 | f471a17e | Alex Williamson | } RAMBlock; |
491 | f471a17e | Alex Williamson | |
492 | f471a17e | Alex Williamson | typedef struct RAMList { |
493 | f471a17e | Alex Williamson | uint8_t *phys_dirty; |
494 | 85d59fef | Paolo Bonzini | QLIST_HEAD(, RAMBlock) blocks; |
495 | f471a17e | Alex Williamson | } RAMList; |
496 | f471a17e | Alex Williamson | extern RAMList ram_list;
|
497 | edf75d59 | bellard | |
498 | c902760f | Marcelo Tosatti | extern const char *mem_path; |
499 | c902760f | Marcelo Tosatti | extern int mem_prealloc; |
500 | c902760f | Marcelo Tosatti | |
501 | edf75d59 | bellard | /* physical memory access */
|
502 | 0f459d16 | pbrook | |
503 | 0f459d16 | pbrook | /* MMIO pages are identified by a combination of an IO device index and
|
504 | 0f459d16 | pbrook | 3 flags. The ROMD code stores the page ram offset in iotlb entry,
|
505 | 0f459d16 | pbrook | so only a limited number of ids are avaiable. */
|
506 | 0f459d16 | pbrook | |
507 | 11c7ef0c | Avi Kivity | #define IO_MEM_NB_ENTRIES (1 << TARGET_PAGE_BITS) |
508 | edf75d59 | bellard | |
509 | 0f459d16 | pbrook | /* Flags stored in the low bits of the TLB virtual address. These are
|
510 | 0f459d16 | pbrook | defined so that fast path ram access is all zeros. */
|
511 | 0f459d16 | pbrook | /* Zero if TLB entry is valid. */
|
512 | 0f459d16 | pbrook | #define TLB_INVALID_MASK (1 << 3) |
513 | 0f459d16 | pbrook | /* Set if TLB entry references a clean RAM page. The iotlb entry will
|
514 | 0f459d16 | pbrook | contain the page physical address. */
|
515 | 0f459d16 | pbrook | #define TLB_NOTDIRTY (1 << 4) |
516 | 0f459d16 | pbrook | /* Set if TLB entry is an IO callback. */
|
517 | 0f459d16 | pbrook | #define TLB_MMIO (1 << 5) |
518 | 0f459d16 | pbrook | |
519 | 04c504cc | bellard | void cpu_tlb_update_dirty(CPUState *env);
|
520 | 1ccde1cb | bellard | |
521 | 055403b2 | Stefan Weil | void dump_exec_info(FILE *f, fprintf_function cpu_fprintf);
|
522 | b3755a91 | Paul Brook | #endif /* !CONFIG_USER_ONLY */ |
523 | b3755a91 | Paul Brook | |
524 | b3755a91 | Paul Brook | int cpu_memory_rw_debug(CPUState *env, target_ulong addr,
|
525 | b3755a91 | Paul Brook | uint8_t *buf, int len, int is_write); |
526 | b3755a91 | Paul Brook | |
527 | 5a9fdfec | bellard | #endif /* CPU_ALL_H */ |