Commit 943144d91af00c0ece95e1b2e64d8eed4d2c38ec
1 parent
34e01bbf
added raw/user/kernel memory accesses (faster emulation)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@510 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
51 additions
and
23 deletions
target-i386/ops_template_mem.h
@@ -20,12 +20,40 @@ | @@ -20,12 +20,40 @@ | ||
20 | */ | 20 | */ |
21 | #ifdef MEM_WRITE | 21 | #ifdef MEM_WRITE |
22 | 22 | ||
23 | +#if MEM_WRITE == 0 | ||
24 | + | ||
25 | +#if DATA_BITS == 8 | ||
26 | +#define MEM_SUFFIX b_raw | ||
27 | +#elif DATA_BITS == 16 | ||
28 | +#define MEM_SUFFIX w_raw | ||
29 | +#elif DATA_BITS == 32 | ||
30 | +#define MEM_SUFFIX l_raw | ||
31 | +#endif | ||
32 | + | ||
33 | +#elif MEM_WRITE == 1 | ||
34 | + | ||
35 | +#if DATA_BITS == 8 | ||
36 | +#define MEM_SUFFIX b_kernel | ||
37 | +#elif DATA_BITS == 16 | ||
38 | +#define MEM_SUFFIX w_kernel | ||
39 | +#elif DATA_BITS == 32 | ||
40 | +#define MEM_SUFFIX l_kernel | ||
41 | +#endif | ||
42 | + | ||
43 | +#elif MEM_WRITE == 2 | ||
44 | + | ||
23 | #if DATA_BITS == 8 | 45 | #if DATA_BITS == 8 |
24 | -#define MEM_SUFFIX b_mem | 46 | +#define MEM_SUFFIX b_user |
25 | #elif DATA_BITS == 16 | 47 | #elif DATA_BITS == 16 |
26 | -#define MEM_SUFFIX w_mem | 48 | +#define MEM_SUFFIX w_user |
27 | #elif DATA_BITS == 32 | 49 | #elif DATA_BITS == 32 |
28 | -#define MEM_SUFFIX l_mem | 50 | +#define MEM_SUFFIX l_user |
51 | +#endif | ||
52 | + | ||
53 | +#else | ||
54 | + | ||
55 | +#error invalid MEM_WRITE | ||
56 | + | ||
29 | #endif | 57 | #endif |
30 | 58 | ||
31 | #else | 59 | #else |
@@ -43,7 +71,7 @@ void OPPROTO glue(glue(op_rol, MEM_SUFFIX), _T0_T1_cc)(void) | @@ -43,7 +71,7 @@ void OPPROTO glue(glue(op_rol, MEM_SUFFIX), _T0_T1_cc)(void) | ||
43 | T0 &= DATA_MASK; | 71 | T0 &= DATA_MASK; |
44 | T0 = (T0 << count) | (T0 >> (DATA_BITS - count)); | 72 | T0 = (T0 << count) | (T0 >> (DATA_BITS - count)); |
45 | #ifdef MEM_WRITE | 73 | #ifdef MEM_WRITE |
46 | - glue(st, SUFFIX)((uint8_t *)A0, T0); | 74 | + glue(st, MEM_SUFFIX)((uint8_t *)A0, T0); |
47 | #else | 75 | #else |
48 | /* gcc 3.2 workaround. This is really a bug in gcc. */ | 76 | /* gcc 3.2 workaround. This is really a bug in gcc. */ |
49 | asm volatile("" : : "r" (T0)); | 77 | asm volatile("" : : "r" (T0)); |
@@ -65,7 +93,7 @@ void OPPROTO glue(glue(op_ror, MEM_SUFFIX), _T0_T1_cc)(void) | @@ -65,7 +93,7 @@ void OPPROTO glue(glue(op_ror, MEM_SUFFIX), _T0_T1_cc)(void) | ||
65 | T0 &= DATA_MASK; | 93 | T0 &= DATA_MASK; |
66 | T0 = (T0 >> count) | (T0 << (DATA_BITS - count)); | 94 | T0 = (T0 >> count) | (T0 << (DATA_BITS - count)); |
67 | #ifdef MEM_WRITE | 95 | #ifdef MEM_WRITE |
68 | - glue(st, SUFFIX)((uint8_t *)A0, T0); | 96 | + glue(st, MEM_SUFFIX)((uint8_t *)A0, T0); |
69 | #else | 97 | #else |
70 | /* gcc 3.2 workaround. This is really a bug in gcc. */ | 98 | /* gcc 3.2 workaround. This is really a bug in gcc. */ |
71 | asm volatile("" : : "r" (T0)); | 99 | asm volatile("" : : "r" (T0)); |
@@ -86,7 +114,7 @@ void OPPROTO glue(glue(op_rol, MEM_SUFFIX), _T0_T1)(void) | @@ -86,7 +114,7 @@ void OPPROTO glue(glue(op_rol, MEM_SUFFIX), _T0_T1)(void) | ||
86 | T0 &= DATA_MASK; | 114 | T0 &= DATA_MASK; |
87 | T0 = (T0 << count) | (T0 >> (DATA_BITS - count)); | 115 | T0 = (T0 << count) | (T0 >> (DATA_BITS - count)); |
88 | #ifdef MEM_WRITE | 116 | #ifdef MEM_WRITE |
89 | - glue(st, SUFFIX)((uint8_t *)A0, T0); | 117 | + glue(st, MEM_SUFFIX)((uint8_t *)A0, T0); |
90 | #endif | 118 | #endif |
91 | } | 119 | } |
92 | FORCE_RET(); | 120 | FORCE_RET(); |
@@ -100,7 +128,7 @@ void OPPROTO glue(glue(op_ror, MEM_SUFFIX), _T0_T1)(void) | @@ -100,7 +128,7 @@ void OPPROTO glue(glue(op_ror, MEM_SUFFIX), _T0_T1)(void) | ||
100 | T0 &= DATA_MASK; | 128 | T0 &= DATA_MASK; |
101 | T0 = (T0 >> count) | (T0 << (DATA_BITS - count)); | 129 | T0 = (T0 >> count) | (T0 << (DATA_BITS - count)); |
102 | #ifdef MEM_WRITE | 130 | #ifdef MEM_WRITE |
103 | - glue(st, SUFFIX)((uint8_t *)A0, T0); | 131 | + glue(st, MEM_SUFFIX)((uint8_t *)A0, T0); |
104 | #endif | 132 | #endif |
105 | } | 133 | } |
106 | FORCE_RET(); | 134 | FORCE_RET(); |
@@ -126,7 +154,7 @@ void OPPROTO glue(glue(op_rcl, MEM_SUFFIX), _T0_T1_cc)(void) | @@ -126,7 +154,7 @@ void OPPROTO glue(glue(op_rcl, MEM_SUFFIX), _T0_T1_cc)(void) | ||
126 | res |= T0 >> (DATA_BITS + 1 - count); | 154 | res |= T0 >> (DATA_BITS + 1 - count); |
127 | T0 = res; | 155 | T0 = res; |
128 | #ifdef MEM_WRITE | 156 | #ifdef MEM_WRITE |
129 | - glue(st, SUFFIX)((uint8_t *)A0, T0); | 157 | + glue(st, MEM_SUFFIX)((uint8_t *)A0, T0); |
130 | #endif | 158 | #endif |
131 | CC_SRC = (eflags & ~(CC_C | CC_O)) | | 159 | CC_SRC = (eflags & ~(CC_C | CC_O)) | |
132 | (lshift(src ^ T0, 11 - (DATA_BITS - 1)) & CC_O) | | 160 | (lshift(src ^ T0, 11 - (DATA_BITS - 1)) & CC_O) | |
@@ -156,7 +184,7 @@ void OPPROTO glue(glue(op_rcr, MEM_SUFFIX), _T0_T1_cc)(void) | @@ -156,7 +184,7 @@ void OPPROTO glue(glue(op_rcr, MEM_SUFFIX), _T0_T1_cc)(void) | ||
156 | res |= T0 << (DATA_BITS + 1 - count); | 184 | res |= T0 << (DATA_BITS + 1 - count); |
157 | T0 = res; | 185 | T0 = res; |
158 | #ifdef MEM_WRITE | 186 | #ifdef MEM_WRITE |
159 | - glue(st, SUFFIX)((uint8_t *)A0, T0); | 187 | + glue(st, MEM_SUFFIX)((uint8_t *)A0, T0); |
160 | #endif | 188 | #endif |
161 | CC_SRC = (eflags & ~(CC_C | CC_O)) | | 189 | CC_SRC = (eflags & ~(CC_C | CC_O)) | |
162 | (lshift(src ^ T0, 11 - (DATA_BITS - 1)) & CC_O) | | 190 | (lshift(src ^ T0, 11 - (DATA_BITS - 1)) & CC_O) | |
@@ -174,7 +202,7 @@ void OPPROTO glue(glue(op_shl, MEM_SUFFIX), _T0_T1_cc)(void) | @@ -174,7 +202,7 @@ void OPPROTO glue(glue(op_shl, MEM_SUFFIX), _T0_T1_cc)(void) | ||
174 | src = (DATA_TYPE)T0 << (count - 1); | 202 | src = (DATA_TYPE)T0 << (count - 1); |
175 | T0 = T0 << count; | 203 | T0 = T0 << count; |
176 | #ifdef MEM_WRITE | 204 | #ifdef MEM_WRITE |
177 | - glue(st, SUFFIX)((uint8_t *)A0, T0); | 205 | + glue(st, MEM_SUFFIX)((uint8_t *)A0, T0); |
178 | #endif | 206 | #endif |
179 | CC_SRC = src; | 207 | CC_SRC = src; |
180 | CC_DST = T0; | 208 | CC_DST = T0; |
@@ -192,7 +220,7 @@ void OPPROTO glue(glue(op_shr, MEM_SUFFIX), _T0_T1_cc)(void) | @@ -192,7 +220,7 @@ void OPPROTO glue(glue(op_shr, MEM_SUFFIX), _T0_T1_cc)(void) | ||
192 | src = T0 >> (count - 1); | 220 | src = T0 >> (count - 1); |
193 | T0 = T0 >> count; | 221 | T0 = T0 >> count; |
194 | #ifdef MEM_WRITE | 222 | #ifdef MEM_WRITE |
195 | - glue(st, SUFFIX)((uint8_t *)A0, T0); | 223 | + glue(st, MEM_SUFFIX)((uint8_t *)A0, T0); |
196 | #endif | 224 | #endif |
197 | CC_SRC = src; | 225 | CC_SRC = src; |
198 | CC_DST = T0; | 226 | CC_DST = T0; |
@@ -210,7 +238,7 @@ void OPPROTO glue(glue(op_sar, MEM_SUFFIX), _T0_T1_cc)(void) | @@ -210,7 +238,7 @@ void OPPROTO glue(glue(op_sar, MEM_SUFFIX), _T0_T1_cc)(void) | ||
210 | T0 = src >> count; | 238 | T0 = src >> count; |
211 | src = src >> (count - 1); | 239 | src = src >> (count - 1); |
212 | #ifdef MEM_WRITE | 240 | #ifdef MEM_WRITE |
213 | - glue(st, SUFFIX)((uint8_t *)A0, T0); | 241 | + glue(st, MEM_SUFFIX)((uint8_t *)A0, T0); |
214 | #endif | 242 | #endif |
215 | CC_SRC = src; | 243 | CC_SRC = src; |
216 | CC_DST = T0; | 244 | CC_DST = T0; |
@@ -234,7 +262,7 @@ void OPPROTO glue(glue(op_shld, MEM_SUFFIX), _T0_T1_im_cc)(void) | @@ -234,7 +262,7 @@ void OPPROTO glue(glue(op_shld, MEM_SUFFIX), _T0_T1_im_cc)(void) | ||
234 | res |= T1 << (count - 16); | 262 | res |= T1 << (count - 16); |
235 | T0 = res >> 16; | 263 | T0 = res >> 16; |
236 | #ifdef MEM_WRITE | 264 | #ifdef MEM_WRITE |
237 | - glue(st, SUFFIX)((uint8_t *)A0, T0); | 265 | + glue(st, MEM_SUFFIX)((uint8_t *)A0, T0); |
238 | #endif | 266 | #endif |
239 | CC_SRC = tmp; | 267 | CC_SRC = tmp; |
240 | CC_DST = T0; | 268 | CC_DST = T0; |
@@ -254,7 +282,7 @@ void OPPROTO glue(glue(op_shld, MEM_SUFFIX), _T0_T1_ECX_cc)(void) | @@ -254,7 +282,7 @@ void OPPROTO glue(glue(op_shld, MEM_SUFFIX), _T0_T1_ECX_cc)(void) | ||
254 | res |= T1 << (count - 16); | 282 | res |= T1 << (count - 16); |
255 | T0 = res >> 16; | 283 | T0 = res >> 16; |
256 | #ifdef MEM_WRITE | 284 | #ifdef MEM_WRITE |
257 | - glue(st, SUFFIX)((uint8_t *)A0, T0); | 285 | + glue(st, MEM_SUFFIX)((uint8_t *)A0, T0); |
258 | #endif | 286 | #endif |
259 | CC_SRC = tmp; | 287 | CC_SRC = tmp; |
260 | CC_DST = T0; | 288 | CC_DST = T0; |
@@ -276,7 +304,7 @@ void OPPROTO glue(glue(op_shrd, MEM_SUFFIX), _T0_T1_im_cc)(void) | @@ -276,7 +304,7 @@ void OPPROTO glue(glue(op_shrd, MEM_SUFFIX), _T0_T1_im_cc)(void) | ||
276 | res |= T1 << (32 - count); | 304 | res |= T1 << (32 - count); |
277 | T0 = res; | 305 | T0 = res; |
278 | #ifdef MEM_WRITE | 306 | #ifdef MEM_WRITE |
279 | - glue(st, SUFFIX)((uint8_t *)A0, T0); | 307 | + glue(st, MEM_SUFFIX)((uint8_t *)A0, T0); |
280 | #endif | 308 | #endif |
281 | CC_SRC = tmp; | 309 | CC_SRC = tmp; |
282 | CC_DST = T0; | 310 | CC_DST = T0; |
@@ -297,7 +325,7 @@ void OPPROTO glue(glue(op_shrd, MEM_SUFFIX), _T0_T1_ECX_cc)(void) | @@ -297,7 +325,7 @@ void OPPROTO glue(glue(op_shrd, MEM_SUFFIX), _T0_T1_ECX_cc)(void) | ||
297 | res |= T1 << (32 - count); | 325 | res |= T1 << (32 - count); |
298 | T0 = res; | 326 | T0 = res; |
299 | #ifdef MEM_WRITE | 327 | #ifdef MEM_WRITE |
300 | - glue(st, SUFFIX)((uint8_t *)A0, T0); | 328 | + glue(st, MEM_SUFFIX)((uint8_t *)A0, T0); |
301 | #endif | 329 | #endif |
302 | CC_SRC = tmp; | 330 | CC_SRC = tmp; |
303 | CC_DST = T0; | 331 | CC_DST = T0; |
@@ -317,7 +345,7 @@ void OPPROTO glue(glue(op_shld, MEM_SUFFIX), _T0_T1_im_cc)(void) | @@ -317,7 +345,7 @@ void OPPROTO glue(glue(op_shld, MEM_SUFFIX), _T0_T1_im_cc)(void) | ||
317 | tmp = T0 << (count - 1); | 345 | tmp = T0 << (count - 1); |
318 | T0 = (T0 << count) | (T1 >> (DATA_BITS - count)); | 346 | T0 = (T0 << count) | (T1 >> (DATA_BITS - count)); |
319 | #ifdef MEM_WRITE | 347 | #ifdef MEM_WRITE |
320 | - glue(st, SUFFIX)((uint8_t *)A0, T0); | 348 | + glue(st, MEM_SUFFIX)((uint8_t *)A0, T0); |
321 | #endif | 349 | #endif |
322 | CC_SRC = tmp; | 350 | CC_SRC = tmp; |
323 | CC_DST = T0; | 351 | CC_DST = T0; |
@@ -333,7 +361,7 @@ void OPPROTO glue(glue(op_shld, MEM_SUFFIX), _T0_T1_ECX_cc)(void) | @@ -333,7 +361,7 @@ void OPPROTO glue(glue(op_shld, MEM_SUFFIX), _T0_T1_ECX_cc)(void) | ||
333 | tmp = T0 << (count - 1); | 361 | tmp = T0 << (count - 1); |
334 | T0 = (T0 << count) | (T1 >> (DATA_BITS - count)); | 362 | T0 = (T0 << count) | (T1 >> (DATA_BITS - count)); |
335 | #ifdef MEM_WRITE | 363 | #ifdef MEM_WRITE |
336 | - glue(st, SUFFIX)((uint8_t *)A0, T0); | 364 | + glue(st, MEM_SUFFIX)((uint8_t *)A0, T0); |
337 | #endif | 365 | #endif |
338 | CC_SRC = tmp; | 366 | CC_SRC = tmp; |
339 | CC_DST = T0; | 367 | CC_DST = T0; |
@@ -351,7 +379,7 @@ void OPPROTO glue(glue(op_shrd, MEM_SUFFIX), _T0_T1_im_cc)(void) | @@ -351,7 +379,7 @@ void OPPROTO glue(glue(op_shrd, MEM_SUFFIX), _T0_T1_im_cc)(void) | ||
351 | tmp = T0 >> (count - 1); | 379 | tmp = T0 >> (count - 1); |
352 | T0 = (T0 >> count) | (T1 << (DATA_BITS - count)); | 380 | T0 = (T0 >> count) | (T1 << (DATA_BITS - count)); |
353 | #ifdef MEM_WRITE | 381 | #ifdef MEM_WRITE |
354 | - glue(st, SUFFIX)((uint8_t *)A0, T0); | 382 | + glue(st, MEM_SUFFIX)((uint8_t *)A0, T0); |
355 | #endif | 383 | #endif |
356 | CC_SRC = tmp; | 384 | CC_SRC = tmp; |
357 | CC_DST = T0; | 385 | CC_DST = T0; |
@@ -368,7 +396,7 @@ void OPPROTO glue(glue(op_shrd, MEM_SUFFIX), _T0_T1_ECX_cc)(void) | @@ -368,7 +396,7 @@ void OPPROTO glue(glue(op_shrd, MEM_SUFFIX), _T0_T1_ECX_cc)(void) | ||
368 | tmp = T0 >> (count - 1); | 396 | tmp = T0 >> (count - 1); |
369 | T0 = (T0 >> count) | (T1 << (DATA_BITS - count)); | 397 | T0 = (T0 >> count) | (T1 << (DATA_BITS - count)); |
370 | #ifdef MEM_WRITE | 398 | #ifdef MEM_WRITE |
371 | - glue(st, SUFFIX)((uint8_t *)A0, T0); | 399 | + glue(st, MEM_SUFFIX)((uint8_t *)A0, T0); |
372 | #endif | 400 | #endif |
373 | CC_SRC = tmp; | 401 | CC_SRC = tmp; |
374 | CC_DST = T0; | 402 | CC_DST = T0; |
@@ -386,7 +414,7 @@ void OPPROTO glue(glue(op_adc, MEM_SUFFIX), _T0_T1_cc)(void) | @@ -386,7 +414,7 @@ void OPPROTO glue(glue(op_adc, MEM_SUFFIX), _T0_T1_cc)(void) | ||
386 | cf = cc_table[CC_OP].compute_c(); | 414 | cf = cc_table[CC_OP].compute_c(); |
387 | T0 = T0 + T1 + cf; | 415 | T0 = T0 + T1 + cf; |
388 | #ifdef MEM_WRITE | 416 | #ifdef MEM_WRITE |
389 | - glue(st, SUFFIX)((uint8_t *)A0, T0); | 417 | + glue(st, MEM_SUFFIX)((uint8_t *)A0, T0); |
390 | #endif | 418 | #endif |
391 | CC_SRC = T1; | 419 | CC_SRC = T1; |
392 | CC_DST = T0; | 420 | CC_DST = T0; |
@@ -399,7 +427,7 @@ void OPPROTO glue(glue(op_sbb, MEM_SUFFIX), _T0_T1_cc)(void) | @@ -399,7 +427,7 @@ void OPPROTO glue(glue(op_sbb, MEM_SUFFIX), _T0_T1_cc)(void) | ||
399 | cf = cc_table[CC_OP].compute_c(); | 427 | cf = cc_table[CC_OP].compute_c(); |
400 | T0 = T0 - T1 - cf; | 428 | T0 = T0 - T1 - cf; |
401 | #ifdef MEM_WRITE | 429 | #ifdef MEM_WRITE |
402 | - glue(st, SUFFIX)((uint8_t *)A0, T0); | 430 | + glue(st, MEM_SUFFIX)((uint8_t *)A0, T0); |
403 | #endif | 431 | #endif |
404 | CC_SRC = T1; | 432 | CC_SRC = T1; |
405 | CC_DST = T0; | 433 | CC_DST = T0; |
@@ -418,7 +446,7 @@ void OPPROTO glue(glue(op_cmpxchg, MEM_SUFFIX), _T0_T1_EAX_cc)(void) | @@ -418,7 +446,7 @@ void OPPROTO glue(glue(op_cmpxchg, MEM_SUFFIX), _T0_T1_EAX_cc)(void) | ||
418 | EAX = (EAX & ~DATA_MASK) | (T0 & DATA_MASK); | 446 | EAX = (EAX & ~DATA_MASK) | (T0 & DATA_MASK); |
419 | } | 447 | } |
420 | #ifdef MEM_WRITE | 448 | #ifdef MEM_WRITE |
421 | - glue(st, SUFFIX)((uint8_t *)A0, T0); | 449 | + glue(st, MEM_SUFFIX)((uint8_t *)A0, T0); |
422 | #endif | 450 | #endif |
423 | CC_SRC = src; | 451 | CC_SRC = src; |
424 | CC_DST = dst; | 452 | CC_DST = dst; |