root / cpu-all.h @ 977d5710
History | View | Annotate | Download (17.6 kB)
1 | 5a9fdfec | bellard | /*
|
---|---|---|---|
2 | 5a9fdfec | bellard | * defines common to all virtual CPUs
|
3 | 5a9fdfec | bellard | *
|
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 | 5a9fdfec | bellard | * License along with this library; if not, write to the Free Software
|
18 | 5a9fdfec | bellard | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19 | 5a9fdfec | bellard | */
|
20 | 5a9fdfec | bellard | #ifndef CPU_ALL_H
|
21 | 5a9fdfec | bellard | #define CPU_ALL_H
|
22 | 5a9fdfec | bellard | |
23 | 0ac4bd56 | bellard | #if defined(__arm__) || defined(__sparc__)
|
24 | 0ac4bd56 | bellard | #define WORDS_ALIGNED
|
25 | 0ac4bd56 | bellard | #endif
|
26 | 0ac4bd56 | bellard | |
27 | 0ac4bd56 | bellard | /* some important defines:
|
28 | 0ac4bd56 | bellard | *
|
29 | 0ac4bd56 | bellard | * WORDS_ALIGNED : if defined, the host cpu can only make word aligned
|
30 | 0ac4bd56 | bellard | * memory accesses.
|
31 | 0ac4bd56 | bellard | *
|
32 | 0ac4bd56 | bellard | * WORDS_BIGENDIAN : if defined, the host cpu is big endian and
|
33 | 0ac4bd56 | bellard | * otherwise little endian.
|
34 | 0ac4bd56 | bellard | *
|
35 | 0ac4bd56 | bellard | * (TARGET_WORDS_ALIGNED : same for target cpu (not supported yet))
|
36 | 0ac4bd56 | bellard | *
|
37 | 0ac4bd56 | bellard | * TARGET_WORDS_BIGENDIAN : same for target cpu
|
38 | 0ac4bd56 | bellard | */
|
39 | 0ac4bd56 | bellard | |
40 | f193c797 | bellard | #include "bswap.h" |
41 | f193c797 | bellard | |
42 | f193c797 | bellard | #if defined(WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN)
|
43 | f193c797 | bellard | #define BSWAP_NEEDED
|
44 | f193c797 | bellard | #endif
|
45 | f193c797 | bellard | |
46 | f193c797 | bellard | #ifdef BSWAP_NEEDED
|
47 | f193c797 | bellard | |
48 | f193c797 | bellard | static inline uint16_t tswap16(uint16_t s) |
49 | f193c797 | bellard | { |
50 | f193c797 | bellard | return bswap16(s);
|
51 | f193c797 | bellard | } |
52 | f193c797 | bellard | |
53 | f193c797 | bellard | static inline uint32_t tswap32(uint32_t s) |
54 | f193c797 | bellard | { |
55 | f193c797 | bellard | return bswap32(s);
|
56 | f193c797 | bellard | } |
57 | f193c797 | bellard | |
58 | f193c797 | bellard | static inline uint64_t tswap64(uint64_t s) |
59 | f193c797 | bellard | { |
60 | f193c797 | bellard | return bswap64(s);
|
61 | f193c797 | bellard | } |
62 | f193c797 | bellard | |
63 | f193c797 | bellard | static inline void tswap16s(uint16_t *s) |
64 | f193c797 | bellard | { |
65 | f193c797 | bellard | *s = bswap16(*s); |
66 | f193c797 | bellard | } |
67 | f193c797 | bellard | |
68 | f193c797 | bellard | static inline void tswap32s(uint32_t *s) |
69 | f193c797 | bellard | { |
70 | f193c797 | bellard | *s = bswap32(*s); |
71 | f193c797 | bellard | } |
72 | f193c797 | bellard | |
73 | f193c797 | bellard | static inline void tswap64s(uint64_t *s) |
74 | f193c797 | bellard | { |
75 | f193c797 | bellard | *s = bswap64(*s); |
76 | f193c797 | bellard | } |
77 | f193c797 | bellard | |
78 | f193c797 | bellard | #else
|
79 | f193c797 | bellard | |
80 | f193c797 | bellard | static inline uint16_t tswap16(uint16_t s) |
81 | f193c797 | bellard | { |
82 | f193c797 | bellard | return s;
|
83 | f193c797 | bellard | } |
84 | f193c797 | bellard | |
85 | f193c797 | bellard | static inline uint32_t tswap32(uint32_t s) |
86 | f193c797 | bellard | { |
87 | f193c797 | bellard | return s;
|
88 | f193c797 | bellard | } |
89 | f193c797 | bellard | |
90 | f193c797 | bellard | static inline uint64_t tswap64(uint64_t s) |
91 | f193c797 | bellard | { |
92 | f193c797 | bellard | return s;
|
93 | f193c797 | bellard | } |
94 | f193c797 | bellard | |
95 | f193c797 | bellard | static inline void tswap16s(uint16_t *s) |
96 | f193c797 | bellard | { |
97 | f193c797 | bellard | } |
98 | f193c797 | bellard | |
99 | f193c797 | bellard | static inline void tswap32s(uint32_t *s) |
100 | f193c797 | bellard | { |
101 | f193c797 | bellard | } |
102 | f193c797 | bellard | |
103 | f193c797 | bellard | static inline void tswap64s(uint64_t *s) |
104 | f193c797 | bellard | { |
105 | f193c797 | bellard | } |
106 | f193c797 | bellard | |
107 | f193c797 | bellard | #endif
|
108 | f193c797 | bellard | |
109 | f193c797 | bellard | #if TARGET_LONG_SIZE == 4 |
110 | f193c797 | bellard | #define tswapl(s) tswap32(s)
|
111 | f193c797 | bellard | #define tswapls(s) tswap32s((uint32_t *)(s))
|
112 | f193c797 | bellard | #else
|
113 | f193c797 | bellard | #define tswapl(s) tswap64(s)
|
114 | f193c797 | bellard | #define tswapls(s) tswap64s((uint64_t *)(s))
|
115 | f193c797 | bellard | #endif
|
116 | f193c797 | bellard | |
117 | 0ac4bd56 | bellard | /* NOTE: arm is horrible as double 32 bit words are stored in big endian ! */
|
118 | 0ac4bd56 | bellard | typedef union { |
119 | 0ac4bd56 | bellard | double d;
|
120 | 0ac4bd56 | bellard | #if !defined(WORDS_BIGENDIAN) && !defined(__arm__)
|
121 | 0ac4bd56 | bellard | struct {
|
122 | 0ac4bd56 | bellard | uint32_t lower; |
123 | 0ac4bd56 | bellard | uint32_t upper; |
124 | 0ac4bd56 | bellard | } l; |
125 | 0ac4bd56 | bellard | #else
|
126 | 0ac4bd56 | bellard | struct {
|
127 | 0ac4bd56 | bellard | uint32_t upper; |
128 | 0ac4bd56 | bellard | uint32_t lower; |
129 | 0ac4bd56 | bellard | } l; |
130 | 0ac4bd56 | bellard | #endif
|
131 | 0ac4bd56 | bellard | uint64_t ll; |
132 | 0ac4bd56 | bellard | } CPU_DoubleU; |
133 | 0ac4bd56 | bellard | |
134 | 61382a50 | bellard | /* CPU memory access without any memory or io remapping */
|
135 | 61382a50 | bellard | |
136 | 83d73968 | bellard | /*
|
137 | 83d73968 | bellard | * the generic syntax for the memory accesses is:
|
138 | 83d73968 | bellard | *
|
139 | 83d73968 | bellard | * load: ld{type}{sign}{size}{endian}_{access_type}(ptr)
|
140 | 83d73968 | bellard | *
|
141 | 83d73968 | bellard | * store: st{type}{size}{endian}_{access_type}(ptr, val)
|
142 | 83d73968 | bellard | *
|
143 | 83d73968 | bellard | * type is:
|
144 | 83d73968 | bellard | * (empty): integer access
|
145 | 83d73968 | bellard | * f : float access
|
146 | 83d73968 | bellard | *
|
147 | 83d73968 | bellard | * sign is:
|
148 | 83d73968 | bellard | * (empty): for floats or 32 bit size
|
149 | 83d73968 | bellard | * u : unsigned
|
150 | 83d73968 | bellard | * s : signed
|
151 | 83d73968 | bellard | *
|
152 | 83d73968 | bellard | * size is:
|
153 | 83d73968 | bellard | * b: 8 bits
|
154 | 83d73968 | bellard | * w: 16 bits
|
155 | 83d73968 | bellard | * l: 32 bits
|
156 | 83d73968 | bellard | * q: 64 bits
|
157 | 83d73968 | bellard | *
|
158 | 83d73968 | bellard | * endian is:
|
159 | 83d73968 | bellard | * (empty): target cpu endianness or 8 bit access
|
160 | 83d73968 | bellard | * r : reversed target cpu endianness (not implemented yet)
|
161 | 83d73968 | bellard | * be : big endian (not implemented yet)
|
162 | 83d73968 | bellard | * le : little endian (not implemented yet)
|
163 | 83d73968 | bellard | *
|
164 | 83d73968 | bellard | * access_type is:
|
165 | 83d73968 | bellard | * raw : host memory access
|
166 | 83d73968 | bellard | * user : user mode access using soft MMU
|
167 | 83d73968 | bellard | * kernel : kernel mode access using soft MMU
|
168 | 83d73968 | bellard | */
|
169 | c27004ec | bellard | static inline int ldub_p(void *ptr) |
170 | 5a9fdfec | bellard | { |
171 | 5a9fdfec | bellard | return *(uint8_t *)ptr;
|
172 | 5a9fdfec | bellard | } |
173 | 5a9fdfec | bellard | |
174 | c27004ec | bellard | static inline int ldsb_p(void *ptr) |
175 | 5a9fdfec | bellard | { |
176 | 5a9fdfec | bellard | return *(int8_t *)ptr;
|
177 | 5a9fdfec | bellard | } |
178 | 5a9fdfec | bellard | |
179 | c27004ec | bellard | static inline void stb_p(void *ptr, int v) |
180 | 5a9fdfec | bellard | { |
181 | 5a9fdfec | bellard | *(uint8_t *)ptr = v; |
182 | 5a9fdfec | bellard | } |
183 | 5a9fdfec | bellard | |
184 | 5a9fdfec | bellard | /* NOTE: on arm, putting 2 in /proc/sys/debug/alignment so that the
|
185 | 5a9fdfec | bellard | kernel handles unaligned load/stores may give better results, but
|
186 | 5a9fdfec | bellard | it is a system wide setting : bad */
|
187 | 0ac4bd56 | bellard | #if !defined(TARGET_WORDS_BIGENDIAN) && (defined(WORDS_BIGENDIAN) || defined(WORDS_ALIGNED))
|
188 | 5a9fdfec | bellard | |
189 | 5a9fdfec | bellard | /* conservative code for little endian unaligned accesses */
|
190 | c27004ec | bellard | static inline int lduw_p(void *ptr) |
191 | 5a9fdfec | bellard | { |
192 | 5a9fdfec | bellard | #ifdef __powerpc__
|
193 | 5a9fdfec | bellard | int val;
|
194 | 5a9fdfec | bellard | __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (ptr)); |
195 | 5a9fdfec | bellard | return val;
|
196 | 5a9fdfec | bellard | #else
|
197 | 5a9fdfec | bellard | uint8_t *p = ptr; |
198 | 5a9fdfec | bellard | return p[0] | (p[1] << 8); |
199 | 5a9fdfec | bellard | #endif
|
200 | 5a9fdfec | bellard | } |
201 | 5a9fdfec | bellard | |
202 | c27004ec | bellard | static inline int ldsw_p(void *ptr) |
203 | 5a9fdfec | bellard | { |
204 | 5a9fdfec | bellard | #ifdef __powerpc__
|
205 | 5a9fdfec | bellard | int val;
|
206 | 5a9fdfec | bellard | __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (ptr)); |
207 | 5a9fdfec | bellard | return (int16_t)val;
|
208 | 5a9fdfec | bellard | #else
|
209 | 5a9fdfec | bellard | uint8_t *p = ptr; |
210 | 5a9fdfec | bellard | return (int16_t)(p[0] | (p[1] << 8)); |
211 | 5a9fdfec | bellard | #endif
|
212 | 5a9fdfec | bellard | } |
213 | 5a9fdfec | bellard | |
214 | c27004ec | bellard | static inline int ldl_p(void *ptr) |
215 | 5a9fdfec | bellard | { |
216 | 5a9fdfec | bellard | #ifdef __powerpc__
|
217 | 5a9fdfec | bellard | int val;
|
218 | 5a9fdfec | bellard | __asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (ptr)); |
219 | 5a9fdfec | bellard | return val;
|
220 | 5a9fdfec | bellard | #else
|
221 | 5a9fdfec | bellard | uint8_t *p = ptr; |
222 | 5a9fdfec | bellard | return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); |
223 | 5a9fdfec | bellard | #endif
|
224 | 5a9fdfec | bellard | } |
225 | 5a9fdfec | bellard | |
226 | c27004ec | bellard | static inline uint64_t ldq_p(void *ptr) |
227 | 5a9fdfec | bellard | { |
228 | 5a9fdfec | bellard | uint8_t *p = ptr; |
229 | 5a9fdfec | bellard | uint32_t v1, v2; |
230 | c27004ec | bellard | v1 = ldl_p(p); |
231 | c27004ec | bellard | v2 = ldl_p(p + 4);
|
232 | 5a9fdfec | bellard | return v1 | ((uint64_t)v2 << 32); |
233 | 5a9fdfec | bellard | } |
234 | 5a9fdfec | bellard | |
235 | c27004ec | bellard | static inline void stw_p(void *ptr, int v) |
236 | 5a9fdfec | bellard | { |
237 | 5a9fdfec | bellard | #ifdef __powerpc__
|
238 | 5a9fdfec | bellard | __asm__ __volatile__ ("sthbrx %1,0,%2" : "=m" (*(uint16_t *)ptr) : "r" (v), "r" (ptr)); |
239 | 5a9fdfec | bellard | #else
|
240 | 5a9fdfec | bellard | uint8_t *p = ptr; |
241 | 5a9fdfec | bellard | p[0] = v;
|
242 | 5a9fdfec | bellard | p[1] = v >> 8; |
243 | 5a9fdfec | bellard | #endif
|
244 | 5a9fdfec | bellard | } |
245 | 5a9fdfec | bellard | |
246 | c27004ec | bellard | static inline void stl_p(void *ptr, int v) |
247 | 5a9fdfec | bellard | { |
248 | 5a9fdfec | bellard | #ifdef __powerpc__
|
249 | 5a9fdfec | bellard | __asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*(uint32_t *)ptr) : "r" (v), "r" (ptr)); |
250 | 5a9fdfec | bellard | #else
|
251 | 5a9fdfec | bellard | uint8_t *p = ptr; |
252 | 5a9fdfec | bellard | p[0] = v;
|
253 | 5a9fdfec | bellard | p[1] = v >> 8; |
254 | 5a9fdfec | bellard | p[2] = v >> 16; |
255 | 5a9fdfec | bellard | p[3] = v >> 24; |
256 | 5a9fdfec | bellard | #endif
|
257 | 5a9fdfec | bellard | } |
258 | 5a9fdfec | bellard | |
259 | c27004ec | bellard | static inline void stq_p(void *ptr, uint64_t v) |
260 | 5a9fdfec | bellard | { |
261 | 5a9fdfec | bellard | uint8_t *p = ptr; |
262 | c27004ec | bellard | stl_p(p, (uint32_t)v); |
263 | c27004ec | bellard | stl_p(p + 4, v >> 32); |
264 | 5a9fdfec | bellard | } |
265 | 5a9fdfec | bellard | |
266 | 5a9fdfec | bellard | /* float access */
|
267 | 5a9fdfec | bellard | |
268 | c27004ec | bellard | static inline float ldfl_p(void *ptr) |
269 | 5a9fdfec | bellard | { |
270 | 5a9fdfec | bellard | union {
|
271 | 5a9fdfec | bellard | float f;
|
272 | 5a9fdfec | bellard | uint32_t i; |
273 | 5a9fdfec | bellard | } u; |
274 | c27004ec | bellard | u.i = ldl_p(ptr); |
275 | 5a9fdfec | bellard | return u.f;
|
276 | 5a9fdfec | bellard | } |
277 | 5a9fdfec | bellard | |
278 | c27004ec | bellard | static inline void stfl_p(void *ptr, float v) |
279 | 5a9fdfec | bellard | { |
280 | 5a9fdfec | bellard | union {
|
281 | 5a9fdfec | bellard | float f;
|
282 | 5a9fdfec | bellard | uint32_t i; |
283 | 5a9fdfec | bellard | } u; |
284 | 5a9fdfec | bellard | u.f = v; |
285 | c27004ec | bellard | stl_p(ptr, u.i); |
286 | 5a9fdfec | bellard | } |
287 | 5a9fdfec | bellard | |
288 | c27004ec | bellard | static inline double ldfq_p(void *ptr) |
289 | 5a9fdfec | bellard | { |
290 | 0ac4bd56 | bellard | CPU_DoubleU u; |
291 | c27004ec | bellard | u.l.lower = ldl_p(ptr); |
292 | c27004ec | bellard | u.l.upper = ldl_p(ptr + 4);
|
293 | 5a9fdfec | bellard | return u.d;
|
294 | 5a9fdfec | bellard | } |
295 | 5a9fdfec | bellard | |
296 | c27004ec | bellard | static inline void stfq_p(void *ptr, double v) |
297 | 5a9fdfec | bellard | { |
298 | 0ac4bd56 | bellard | CPU_DoubleU u; |
299 | 5a9fdfec | bellard | u.d = v; |
300 | c27004ec | bellard | stl_p(ptr, u.l.lower); |
301 | c27004ec | bellard | stl_p(ptr + 4, u.l.upper);
|
302 | 5a9fdfec | bellard | } |
303 | 5a9fdfec | bellard | |
304 | 0ac4bd56 | bellard | #elif defined(TARGET_WORDS_BIGENDIAN) && (!defined(WORDS_BIGENDIAN) || defined(WORDS_ALIGNED))
|
305 | 93ac68bc | bellard | |
306 | c27004ec | bellard | static inline int lduw_p(void *ptr) |
307 | 93ac68bc | bellard | { |
308 | 83d73968 | bellard | #if defined(__i386__)
|
309 | 83d73968 | bellard | int val;
|
310 | 83d73968 | bellard | asm volatile ("movzwl %1, %0\n" |
311 | 83d73968 | bellard | "xchgb %b0, %h0\n"
|
312 | 83d73968 | bellard | : "=q" (val)
|
313 | 83d73968 | bellard | : "m" (*(uint16_t *)ptr));
|
314 | 83d73968 | bellard | return val;
|
315 | 83d73968 | bellard | #else
|
316 | 93ac68bc | bellard | uint8_t *b = (uint8_t *) ptr; |
317 | 83d73968 | bellard | return ((b[0] << 8) | b[1]); |
318 | 83d73968 | bellard | #endif
|
319 | 93ac68bc | bellard | } |
320 | 93ac68bc | bellard | |
321 | c27004ec | bellard | static inline int ldsw_p(void *ptr) |
322 | 93ac68bc | bellard | { |
323 | 83d73968 | bellard | #if defined(__i386__)
|
324 | 83d73968 | bellard | int val;
|
325 | 83d73968 | bellard | asm volatile ("movzwl %1, %0\n" |
326 | 83d73968 | bellard | "xchgb %b0, %h0\n"
|
327 | 83d73968 | bellard | : "=q" (val)
|
328 | 83d73968 | bellard | : "m" (*(uint16_t *)ptr));
|
329 | 83d73968 | bellard | return (int16_t)val;
|
330 | 83d73968 | bellard | #else
|
331 | 83d73968 | bellard | uint8_t *b = (uint8_t *) ptr; |
332 | 83d73968 | bellard | return (int16_t)((b[0] << 8) | b[1]); |
333 | 83d73968 | bellard | #endif
|
334 | 93ac68bc | bellard | } |
335 | 93ac68bc | bellard | |
336 | c27004ec | bellard | static inline int ldl_p(void *ptr) |
337 | 93ac68bc | bellard | { |
338 | 4f2ac237 | bellard | #if defined(__i386__) || defined(__x86_64__)
|
339 | 83d73968 | bellard | int val;
|
340 | 83d73968 | bellard | asm volatile ("movl %1, %0\n" |
341 | 83d73968 | bellard | "bswap %0\n"
|
342 | 83d73968 | bellard | : "=r" (val)
|
343 | 83d73968 | bellard | : "m" (*(uint32_t *)ptr));
|
344 | 83d73968 | bellard | return val;
|
345 | 83d73968 | bellard | #else
|
346 | 93ac68bc | bellard | uint8_t *b = (uint8_t *) ptr; |
347 | 83d73968 | bellard | return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3]; |
348 | 83d73968 | bellard | #endif
|
349 | 93ac68bc | bellard | } |
350 | 93ac68bc | bellard | |
351 | c27004ec | bellard | static inline uint64_t ldq_p(void *ptr) |
352 | 93ac68bc | bellard | { |
353 | 93ac68bc | bellard | uint32_t a,b; |
354 | c27004ec | bellard | a = ldl_p(ptr); |
355 | c27004ec | bellard | b = ldl_p(ptr+4);
|
356 | 93ac68bc | bellard | return (((uint64_t)a<<32)|b); |
357 | 93ac68bc | bellard | } |
358 | 93ac68bc | bellard | |
359 | c27004ec | bellard | static inline void stw_p(void *ptr, int v) |
360 | 93ac68bc | bellard | { |
361 | 83d73968 | bellard | #if defined(__i386__)
|
362 | 83d73968 | bellard | asm volatile ("xchgb %b0, %h0\n" |
363 | 83d73968 | bellard | "movw %w0, %1\n"
|
364 | 83d73968 | bellard | : "=q" (v)
|
365 | 83d73968 | bellard | : "m" (*(uint16_t *)ptr), "0" (v)); |
366 | 83d73968 | bellard | #else
|
367 | 93ac68bc | bellard | uint8_t *d = (uint8_t *) ptr; |
368 | 93ac68bc | bellard | d[0] = v >> 8; |
369 | 93ac68bc | bellard | d[1] = v;
|
370 | 83d73968 | bellard | #endif
|
371 | 93ac68bc | bellard | } |
372 | 93ac68bc | bellard | |
373 | c27004ec | bellard | static inline void stl_p(void *ptr, int v) |
374 | 93ac68bc | bellard | { |
375 | 4f2ac237 | bellard | #if defined(__i386__) || defined(__x86_64__)
|
376 | 83d73968 | bellard | asm volatile ("bswap %0\n" |
377 | 83d73968 | bellard | "movl %0, %1\n"
|
378 | 83d73968 | bellard | : "=r" (v)
|
379 | 83d73968 | bellard | : "m" (*(uint32_t *)ptr), "0" (v)); |
380 | 83d73968 | bellard | #else
|
381 | 93ac68bc | bellard | uint8_t *d = (uint8_t *) ptr; |
382 | 93ac68bc | bellard | d[0] = v >> 24; |
383 | 93ac68bc | bellard | d[1] = v >> 16; |
384 | 93ac68bc | bellard | d[2] = v >> 8; |
385 | 93ac68bc | bellard | d[3] = v;
|
386 | 83d73968 | bellard | #endif
|
387 | 93ac68bc | bellard | } |
388 | 93ac68bc | bellard | |
389 | c27004ec | bellard | static inline void stq_p(void *ptr, uint64_t v) |
390 | 93ac68bc | bellard | { |
391 | c27004ec | bellard | stl_p(ptr, v >> 32);
|
392 | c27004ec | bellard | stl_p(ptr + 4, v);
|
393 | 0ac4bd56 | bellard | } |
394 | 0ac4bd56 | bellard | |
395 | 0ac4bd56 | bellard | /* float access */
|
396 | 0ac4bd56 | bellard | |
397 | c27004ec | bellard | static inline float ldfl_p(void *ptr) |
398 | 0ac4bd56 | bellard | { |
399 | 0ac4bd56 | bellard | union {
|
400 | 0ac4bd56 | bellard | float f;
|
401 | 0ac4bd56 | bellard | uint32_t i; |
402 | 0ac4bd56 | bellard | } u; |
403 | c27004ec | bellard | u.i = ldl_p(ptr); |
404 | 0ac4bd56 | bellard | return u.f;
|
405 | 0ac4bd56 | bellard | } |
406 | 0ac4bd56 | bellard | |
407 | c27004ec | bellard | static inline void stfl_p(void *ptr, float v) |
408 | 0ac4bd56 | bellard | { |
409 | 0ac4bd56 | bellard | union {
|
410 | 0ac4bd56 | bellard | float f;
|
411 | 0ac4bd56 | bellard | uint32_t i; |
412 | 0ac4bd56 | bellard | } u; |
413 | 0ac4bd56 | bellard | u.f = v; |
414 | c27004ec | bellard | stl_p(ptr, u.i); |
415 | 0ac4bd56 | bellard | } |
416 | 0ac4bd56 | bellard | |
417 | c27004ec | bellard | static inline double ldfq_p(void *ptr) |
418 | 0ac4bd56 | bellard | { |
419 | 0ac4bd56 | bellard | CPU_DoubleU u; |
420 | c27004ec | bellard | u.l.upper = ldl_p(ptr); |
421 | c27004ec | bellard | u.l.lower = ldl_p(ptr + 4);
|
422 | 0ac4bd56 | bellard | return u.d;
|
423 | 0ac4bd56 | bellard | } |
424 | 0ac4bd56 | bellard | |
425 | c27004ec | bellard | static inline void stfq_p(void *ptr, double v) |
426 | 0ac4bd56 | bellard | { |
427 | 0ac4bd56 | bellard | CPU_DoubleU u; |
428 | 0ac4bd56 | bellard | u.d = v; |
429 | c27004ec | bellard | stl_p(ptr, u.l.upper); |
430 | c27004ec | bellard | stl_p(ptr + 4, u.l.lower);
|
431 | 93ac68bc | bellard | } |
432 | 93ac68bc | bellard | |
433 | 5a9fdfec | bellard | #else
|
434 | 5a9fdfec | bellard | |
435 | c27004ec | bellard | static inline int lduw_p(void *ptr) |
436 | 5a9fdfec | bellard | { |
437 | 5a9fdfec | bellard | return *(uint16_t *)ptr;
|
438 | 5a9fdfec | bellard | } |
439 | 5a9fdfec | bellard | |
440 | c27004ec | bellard | static inline int ldsw_p(void *ptr) |
441 | 5a9fdfec | bellard | { |
442 | 5a9fdfec | bellard | return *(int16_t *)ptr;
|
443 | 5a9fdfec | bellard | } |
444 | 5a9fdfec | bellard | |
445 | c27004ec | bellard | static inline int ldl_p(void *ptr) |
446 | 5a9fdfec | bellard | { |
447 | 5a9fdfec | bellard | return *(uint32_t *)ptr;
|
448 | 5a9fdfec | bellard | } |
449 | 5a9fdfec | bellard | |
450 | c27004ec | bellard | static inline uint64_t ldq_p(void *ptr) |
451 | 5a9fdfec | bellard | { |
452 | 5a9fdfec | bellard | return *(uint64_t *)ptr;
|
453 | 5a9fdfec | bellard | } |
454 | 5a9fdfec | bellard | |
455 | c27004ec | bellard | static inline void stw_p(void *ptr, int v) |
456 | 5a9fdfec | bellard | { |
457 | 5a9fdfec | bellard | *(uint16_t *)ptr = v; |
458 | 5a9fdfec | bellard | } |
459 | 5a9fdfec | bellard | |
460 | c27004ec | bellard | static inline void stl_p(void *ptr, int v) |
461 | 5a9fdfec | bellard | { |
462 | 5a9fdfec | bellard | *(uint32_t *)ptr = v; |
463 | 5a9fdfec | bellard | } |
464 | 5a9fdfec | bellard | |
465 | c27004ec | bellard | static inline void stq_p(void *ptr, uint64_t v) |
466 | 5a9fdfec | bellard | { |
467 | 5a9fdfec | bellard | *(uint64_t *)ptr = v; |
468 | 5a9fdfec | bellard | } |
469 | 5a9fdfec | bellard | |
470 | 5a9fdfec | bellard | /* float access */
|
471 | 5a9fdfec | bellard | |
472 | c27004ec | bellard | static inline float ldfl_p(void *ptr) |
473 | 5a9fdfec | bellard | { |
474 | 5a9fdfec | bellard | return *(float *)ptr; |
475 | 5a9fdfec | bellard | } |
476 | 5a9fdfec | bellard | |
477 | c27004ec | bellard | static inline double ldfq_p(void *ptr) |
478 | 5a9fdfec | bellard | { |
479 | 5a9fdfec | bellard | return *(double *)ptr; |
480 | 5a9fdfec | bellard | } |
481 | 5a9fdfec | bellard | |
482 | c27004ec | bellard | static inline void stfl_p(void *ptr, float v) |
483 | 5a9fdfec | bellard | { |
484 | 5a9fdfec | bellard | *(float *)ptr = v;
|
485 | 5a9fdfec | bellard | } |
486 | 5a9fdfec | bellard | |
487 | c27004ec | bellard | static inline void stfq_p(void *ptr, double v) |
488 | 5a9fdfec | bellard | { |
489 | 5a9fdfec | bellard | *(double *)ptr = v;
|
490 | 5a9fdfec | bellard | } |
491 | 5a9fdfec | bellard | #endif
|
492 | 5a9fdfec | bellard | |
493 | 61382a50 | bellard | /* MMU memory access macros */
|
494 | 61382a50 | bellard | |
495 | c27004ec | bellard | /* NOTE: we use double casts if pointers and target_ulong have
|
496 | c27004ec | bellard | different sizes */
|
497 | c27004ec | bellard | #define ldub_raw(p) ldub_p((uint8_t *)(long)(p)) |
498 | c27004ec | bellard | #define ldsb_raw(p) ldsb_p((uint8_t *)(long)(p)) |
499 | c27004ec | bellard | #define lduw_raw(p) lduw_p((uint8_t *)(long)(p)) |
500 | c27004ec | bellard | #define ldsw_raw(p) ldsw_p((uint8_t *)(long)(p)) |
501 | c27004ec | bellard | #define ldl_raw(p) ldl_p((uint8_t *)(long)(p)) |
502 | c27004ec | bellard | #define ldq_raw(p) ldq_p((uint8_t *)(long)(p)) |
503 | c27004ec | bellard | #define ldfl_raw(p) ldfl_p((uint8_t *)(long)(p)) |
504 | c27004ec | bellard | #define ldfq_raw(p) ldfq_p((uint8_t *)(long)(p)) |
505 | c27004ec | bellard | #define stb_raw(p, v) stb_p((uint8_t *)(long)(p), v) |
506 | c27004ec | bellard | #define stw_raw(p, v) stw_p((uint8_t *)(long)(p), v) |
507 | c27004ec | bellard | #define stl_raw(p, v) stl_p((uint8_t *)(long)(p), v) |
508 | c27004ec | bellard | #define stq_raw(p, v) stq_p((uint8_t *)(long)(p), v) |
509 | c27004ec | bellard | #define stfl_raw(p, v) stfl_p((uint8_t *)(long)(p), v) |
510 | c27004ec | bellard | #define stfq_raw(p, v) stfq_p((uint8_t *)(long)(p), v) |
511 | c27004ec | bellard | |
512 | c27004ec | bellard | |
513 | 61382a50 | bellard | #if defined(CONFIG_USER_ONLY)
|
514 | 61382a50 | bellard | |
515 | 61382a50 | bellard | /* if user mode, no other memory access functions */
|
516 | 61382a50 | bellard | #define ldub(p) ldub_raw(p)
|
517 | 61382a50 | bellard | #define ldsb(p) ldsb_raw(p)
|
518 | 61382a50 | bellard | #define lduw(p) lduw_raw(p)
|
519 | 61382a50 | bellard | #define ldsw(p) ldsw_raw(p)
|
520 | 61382a50 | bellard | #define ldl(p) ldl_raw(p)
|
521 | 61382a50 | bellard | #define ldq(p) ldq_raw(p)
|
522 | 61382a50 | bellard | #define ldfl(p) ldfl_raw(p)
|
523 | 61382a50 | bellard | #define ldfq(p) ldfq_raw(p)
|
524 | 61382a50 | bellard | #define stb(p, v) stb_raw(p, v)
|
525 | 61382a50 | bellard | #define stw(p, v) stw_raw(p, v)
|
526 | 61382a50 | bellard | #define stl(p, v) stl_raw(p, v)
|
527 | 61382a50 | bellard | #define stq(p, v) stq_raw(p, v)
|
528 | 61382a50 | bellard | #define stfl(p, v) stfl_raw(p, v)
|
529 | 61382a50 | bellard | #define stfq(p, v) stfq_raw(p, v)
|
530 | 61382a50 | bellard | |
531 | 61382a50 | bellard | #define ldub_code(p) ldub_raw(p)
|
532 | 61382a50 | bellard | #define ldsb_code(p) ldsb_raw(p)
|
533 | 61382a50 | bellard | #define lduw_code(p) lduw_raw(p)
|
534 | 61382a50 | bellard | #define ldsw_code(p) ldsw_raw(p)
|
535 | 61382a50 | bellard | #define ldl_code(p) ldl_raw(p)
|
536 | 61382a50 | bellard | |
537 | 61382a50 | bellard | #define ldub_kernel(p) ldub_raw(p)
|
538 | 61382a50 | bellard | #define ldsb_kernel(p) ldsb_raw(p)
|
539 | 61382a50 | bellard | #define lduw_kernel(p) lduw_raw(p)
|
540 | 61382a50 | bellard | #define ldsw_kernel(p) ldsw_raw(p)
|
541 | 61382a50 | bellard | #define ldl_kernel(p) ldl_raw(p)
|
542 | 0ac4bd56 | bellard | #define ldfl_kernel(p) ldfl_raw(p)
|
543 | 0ac4bd56 | bellard | #define ldfq_kernel(p) ldfq_raw(p)
|
544 | 61382a50 | bellard | #define stb_kernel(p, v) stb_raw(p, v)
|
545 | 61382a50 | bellard | #define stw_kernel(p, v) stw_raw(p, v)
|
546 | 61382a50 | bellard | #define stl_kernel(p, v) stl_raw(p, v)
|
547 | 61382a50 | bellard | #define stq_kernel(p, v) stq_raw(p, v)
|
548 | 0ac4bd56 | bellard | #define stfl_kernel(p, v) stfl_raw(p, v)
|
549 | 0ac4bd56 | bellard | #define stfq_kernel(p, vt) stfq_raw(p, v)
|
550 | 61382a50 | bellard | |
551 | 61382a50 | bellard | #endif /* defined(CONFIG_USER_ONLY) */ |
552 | 61382a50 | bellard | |
553 | 5a9fdfec | bellard | /* page related stuff */
|
554 | 5a9fdfec | bellard | |
555 | 5a9fdfec | bellard | #define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS) |
556 | 5a9fdfec | bellard | #define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1) |
557 | 5a9fdfec | bellard | #define TARGET_PAGE_ALIGN(addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK) |
558 | 5a9fdfec | bellard | |
559 | 83fb7adf | bellard | extern unsigned long qemu_real_host_page_size; |
560 | 83fb7adf | bellard | extern unsigned long qemu_host_page_bits; |
561 | 83fb7adf | bellard | extern unsigned long qemu_host_page_size; |
562 | 83fb7adf | bellard | extern unsigned long qemu_host_page_mask; |
563 | 5a9fdfec | bellard | |
564 | 83fb7adf | bellard | #define HOST_PAGE_ALIGN(addr) (((addr) + qemu_host_page_size - 1) & qemu_host_page_mask) |
565 | 5a9fdfec | bellard | |
566 | 5a9fdfec | bellard | /* same as PROT_xxx */
|
567 | 5a9fdfec | bellard | #define PAGE_READ 0x0001 |
568 | 5a9fdfec | bellard | #define PAGE_WRITE 0x0002 |
569 | 5a9fdfec | bellard | #define PAGE_EXEC 0x0004 |
570 | 5a9fdfec | bellard | #define PAGE_BITS (PAGE_READ | PAGE_WRITE | PAGE_EXEC)
|
571 | 5a9fdfec | bellard | #define PAGE_VALID 0x0008 |
572 | 5a9fdfec | bellard | /* original state of the write flag (used when tracking self-modifying
|
573 | 5a9fdfec | bellard | code */
|
574 | 5a9fdfec | bellard | #define PAGE_WRITE_ORG 0x0010 |
575 | 5a9fdfec | bellard | |
576 | 5a9fdfec | bellard | void page_dump(FILE *f);
|
577 | 5a9fdfec | bellard | int page_get_flags(unsigned long address); |
578 | 5a9fdfec | bellard | void page_set_flags(unsigned long start, unsigned long end, int flags); |
579 | 5a9fdfec | bellard | void page_unprotect_range(uint8_t *data, unsigned long data_size); |
580 | 5a9fdfec | bellard | |
581 | 5a9fdfec | bellard | #define SINGLE_CPU_DEFINES
|
582 | 5a9fdfec | bellard | #ifdef SINGLE_CPU_DEFINES
|
583 | 5a9fdfec | bellard | |
584 | 5a9fdfec | bellard | #if defined(TARGET_I386)
|
585 | 5a9fdfec | bellard | |
586 | 5a9fdfec | bellard | #define CPUState CPUX86State
|
587 | 5a9fdfec | bellard | #define cpu_init cpu_x86_init
|
588 | 5a9fdfec | bellard | #define cpu_exec cpu_x86_exec
|
589 | 5a9fdfec | bellard | #define cpu_gen_code cpu_x86_gen_code
|
590 | 5a9fdfec | bellard | #define cpu_signal_handler cpu_x86_signal_handler
|
591 | 5a9fdfec | bellard | |
592 | 5a9fdfec | bellard | #elif defined(TARGET_ARM)
|
593 | 5a9fdfec | bellard | |
594 | 5a9fdfec | bellard | #define CPUState CPUARMState
|
595 | 5a9fdfec | bellard | #define cpu_init cpu_arm_init
|
596 | 5a9fdfec | bellard | #define cpu_exec cpu_arm_exec
|
597 | 5a9fdfec | bellard | #define cpu_gen_code cpu_arm_gen_code
|
598 | 5a9fdfec | bellard | #define cpu_signal_handler cpu_arm_signal_handler
|
599 | 5a9fdfec | bellard | |
600 | 93ac68bc | bellard | #elif defined(TARGET_SPARC)
|
601 | 93ac68bc | bellard | |
602 | 93ac68bc | bellard | #define CPUState CPUSPARCState
|
603 | 93ac68bc | bellard | #define cpu_init cpu_sparc_init
|
604 | 93ac68bc | bellard | #define cpu_exec cpu_sparc_exec
|
605 | 93ac68bc | bellard | #define cpu_gen_code cpu_sparc_gen_code
|
606 | 93ac68bc | bellard | #define cpu_signal_handler cpu_sparc_signal_handler
|
607 | 93ac68bc | bellard | |
608 | 67867308 | bellard | #elif defined(TARGET_PPC)
|
609 | 67867308 | bellard | |
610 | 67867308 | bellard | #define CPUState CPUPPCState
|
611 | 67867308 | bellard | #define cpu_init cpu_ppc_init
|
612 | 67867308 | bellard | #define cpu_exec cpu_ppc_exec
|
613 | 67867308 | bellard | #define cpu_gen_code cpu_ppc_gen_code
|
614 | 67867308 | bellard | #define cpu_signal_handler cpu_ppc_signal_handler
|
615 | 67867308 | bellard | |
616 | 5a9fdfec | bellard | #else
|
617 | 5a9fdfec | bellard | |
618 | 5a9fdfec | bellard | #error unsupported target CPU
|
619 | 5a9fdfec | bellard | |
620 | 5a9fdfec | bellard | #endif
|
621 | 5a9fdfec | bellard | |
622 | 972ddf78 | bellard | #endif /* SINGLE_CPU_DEFINES */ |
623 | 972ddf78 | bellard | |
624 | 7fe48483 | bellard | void cpu_dump_state(CPUState *env, FILE *f,
|
625 | 7fe48483 | bellard | int (*cpu_fprintf)(FILE *f, const char *fmt, ...), |
626 | 7fe48483 | bellard | int flags);
|
627 | 7fe48483 | bellard | |
628 | 972ddf78 | bellard | void cpu_abort(CPUState *env, const char *fmt, ...); |
629 | e2f22898 | bellard | extern CPUState *cpu_single_env;
|
630 | 9acbed06 | bellard | extern int code_copy_enabled; |
631 | 5a9fdfec | bellard | |
632 | 9acbed06 | bellard | #define CPU_INTERRUPT_EXIT 0x01 /* wants exit from main loop */ |
633 | 9acbed06 | bellard | #define CPU_INTERRUPT_HARD 0x02 /* hardware interrupt pending */ |
634 | 9acbed06 | bellard | #define CPU_INTERRUPT_EXITTB 0x04 /* exit the current TB (use for x86 a20 case) */ |
635 | ef792f9d | bellard | #define CPU_INTERRUPT_TIMER 0x08 /* internal timer exception pending */ |
636 | 4690764b | bellard | void cpu_interrupt(CPUState *s, int mask); |
637 | b54ad049 | bellard | void cpu_reset_interrupt(CPUState *env, int mask); |
638 | 68a79315 | bellard | |
639 | 2e12669a | bellard | int cpu_breakpoint_insert(CPUState *env, target_ulong pc);
|
640 | 2e12669a | bellard | int cpu_breakpoint_remove(CPUState *env, target_ulong pc);
|
641 | c33a346e | bellard | void cpu_single_step(CPUState *env, int enabled); |
642 | d95dc32d | bellard | void cpu_reset(CPUState *s);
|
643 | 4c3a88a2 | bellard | |
644 | 13eb76e0 | bellard | /* Return the physical page corresponding to a virtual one. Use it
|
645 | 13eb76e0 | bellard | only for debugging because no protection checks are done. Return -1
|
646 | 13eb76e0 | bellard | if no page found. */
|
647 | 13eb76e0 | bellard | target_ulong cpu_get_phys_page_debug(CPUState *env, target_ulong addr); |
648 | 13eb76e0 | bellard | |
649 | 9fddaa0c | bellard | #define CPU_LOG_TB_OUT_ASM (1 << 0) |
650 | 9fddaa0c | bellard | #define CPU_LOG_TB_IN_ASM (1 << 1) |
651 | f193c797 | bellard | #define CPU_LOG_TB_OP (1 << 2) |
652 | f193c797 | bellard | #define CPU_LOG_TB_OP_OPT (1 << 3) |
653 | f193c797 | bellard | #define CPU_LOG_INT (1 << 4) |
654 | f193c797 | bellard | #define CPU_LOG_EXEC (1 << 5) |
655 | f193c797 | bellard | #define CPU_LOG_PCALL (1 << 6) |
656 | fd872598 | bellard | #define CPU_LOG_IOPORT (1 << 7) |
657 | 9fddaa0c | bellard | #define CPU_LOG_TB_CPU (1 << 8) |
658 | f193c797 | bellard | |
659 | f193c797 | bellard | /* define log items */
|
660 | f193c797 | bellard | typedef struct CPULogItem { |
661 | f193c797 | bellard | int mask;
|
662 | f193c797 | bellard | const char *name; |
663 | f193c797 | bellard | const char *help; |
664 | f193c797 | bellard | } CPULogItem; |
665 | f193c797 | bellard | |
666 | f193c797 | bellard | extern CPULogItem cpu_log_items[];
|
667 | f193c797 | bellard | |
668 | 34865134 | bellard | void cpu_set_log(int log_flags); |
669 | 34865134 | bellard | void cpu_set_log_filename(const char *filename); |
670 | f193c797 | bellard | int cpu_str_to_log_mask(const char *str); |
671 | 34865134 | bellard | |
672 | 09683d35 | bellard | /* IO ports API */
|
673 | 09683d35 | bellard | |
674 | 09683d35 | bellard | /* NOTE: as these functions may be even used when there is an isa
|
675 | 09683d35 | bellard | brige on non x86 targets, we always defined them */
|
676 | 09683d35 | bellard | #ifndef NO_CPU_IO_DEFS
|
677 | 09683d35 | bellard | void cpu_outb(CPUState *env, int addr, int val); |
678 | 09683d35 | bellard | void cpu_outw(CPUState *env, int addr, int val); |
679 | 09683d35 | bellard | void cpu_outl(CPUState *env, int addr, int val); |
680 | 09683d35 | bellard | int cpu_inb(CPUState *env, int addr); |
681 | 09683d35 | bellard | int cpu_inw(CPUState *env, int addr); |
682 | 09683d35 | bellard | int cpu_inl(CPUState *env, int addr); |
683 | 09683d35 | bellard | #endif
|
684 | 09683d35 | bellard | |
685 | 33417e70 | bellard | /* memory API */
|
686 | 33417e70 | bellard | |
687 | edf75d59 | bellard | extern int phys_ram_size; |
688 | edf75d59 | bellard | extern int phys_ram_fd; |
689 | edf75d59 | bellard | extern uint8_t *phys_ram_base;
|
690 | 1ccde1cb | bellard | extern uint8_t *phys_ram_dirty;
|
691 | edf75d59 | bellard | |
692 | edf75d59 | bellard | /* physical memory access */
|
693 | edf75d59 | bellard | #define IO_MEM_NB_ENTRIES 256 |
694 | edf75d59 | bellard | #define TLB_INVALID_MASK (1 << 3) |
695 | edf75d59 | bellard | #define IO_MEM_SHIFT 4 |
696 | edf75d59 | bellard | |
697 | edf75d59 | bellard | #define IO_MEM_RAM (0 << IO_MEM_SHIFT) /* hardcoded offset */ |
698 | edf75d59 | bellard | #define IO_MEM_ROM (1 << IO_MEM_SHIFT) /* hardcoded offset */ |
699 | edf75d59 | bellard | #define IO_MEM_UNASSIGNED (2 << IO_MEM_SHIFT) |
700 | 1ccde1cb | bellard | #define IO_MEM_CODE (3 << IO_MEM_SHIFT) /* used internally, never use directly */ |
701 | 1ccde1cb | bellard | #define IO_MEM_NOTDIRTY (4 << IO_MEM_SHIFT) /* used internally, never use directly */ |
702 | edf75d59 | bellard | |
703 | 7727994d | bellard | typedef void CPUWriteMemoryFunc(void *opaque, target_phys_addr_t addr, uint32_t value); |
704 | 7727994d | bellard | typedef uint32_t CPUReadMemoryFunc(void *opaque, target_phys_addr_t addr); |
705 | 33417e70 | bellard | |
706 | 2e12669a | bellard | void cpu_register_physical_memory(target_phys_addr_t start_addr,
|
707 | 2e12669a | bellard | unsigned long size, |
708 | 2e12669a | bellard | unsigned long phys_offset); |
709 | 33417e70 | bellard | int cpu_register_io_memory(int io_index, |
710 | 33417e70 | bellard | CPUReadMemoryFunc **mem_read, |
711 | 7727994d | bellard | CPUWriteMemoryFunc **mem_write, |
712 | 7727994d | bellard | void *opaque);
|
713 | 8926b517 | bellard | CPUWriteMemoryFunc **cpu_get_io_memory_write(int io_index);
|
714 | 8926b517 | bellard | CPUReadMemoryFunc **cpu_get_io_memory_read(int io_index);
|
715 | 33417e70 | bellard | |
716 | 2e12669a | bellard | void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf,
|
717 | 13eb76e0 | bellard | int len, int is_write); |
718 | 2e12669a | bellard | static inline void cpu_physical_memory_read(target_phys_addr_t addr, |
719 | 2e12669a | bellard | uint8_t *buf, int len)
|
720 | 8b1f24b0 | bellard | { |
721 | 8b1f24b0 | bellard | cpu_physical_memory_rw(addr, buf, len, 0);
|
722 | 8b1f24b0 | bellard | } |
723 | 2e12669a | bellard | static inline void cpu_physical_memory_write(target_phys_addr_t addr, |
724 | 2e12669a | bellard | const uint8_t *buf, int len) |
725 | 8b1f24b0 | bellard | { |
726 | 8b1f24b0 | bellard | cpu_physical_memory_rw(addr, (uint8_t *)buf, len, 1);
|
727 | 8b1f24b0 | bellard | } |
728 | 8b1f24b0 | bellard | |
729 | 8b1f24b0 | bellard | int cpu_memory_rw_debug(CPUState *env, target_ulong addr,
|
730 | 8b1f24b0 | bellard | uint8_t *buf, int len, int is_write); |
731 | 13eb76e0 | bellard | |
732 | 1ccde1cb | bellard | /* read dirty bit (return 0 or 1) */
|
733 | 1ccde1cb | bellard | static inline int cpu_physical_memory_is_dirty(target_ulong addr) |
734 | 1ccde1cb | bellard | { |
735 | 1ccde1cb | bellard | return phys_ram_dirty[addr >> TARGET_PAGE_BITS];
|
736 | 1ccde1cb | bellard | } |
737 | 1ccde1cb | bellard | |
738 | 1ccde1cb | bellard | static inline void cpu_physical_memory_set_dirty(target_ulong addr) |
739 | 1ccde1cb | bellard | { |
740 | 1ccde1cb | bellard | phys_ram_dirty[addr >> TARGET_PAGE_BITS] = 1;
|
741 | 1ccde1cb | bellard | } |
742 | 1ccde1cb | bellard | |
743 | 1ccde1cb | bellard | void cpu_physical_memory_reset_dirty(target_ulong start, target_ulong end);
|
744 | 1ccde1cb | bellard | |
745 | 5a9fdfec | bellard | #endif /* CPU_ALL_H */ |