提交 943144d9 编写于 作者: B bellard

added raw/user/kernel memory accesses (faster emulation)


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@510 c046a42c-6fe2-441c-8c8c-71466251a162
上级 34e01bbf
...@@ -20,12 +20,40 @@ ...@@ -20,12 +20,40 @@
*/ */
#ifdef MEM_WRITE #ifdef MEM_WRITE
#if MEM_WRITE == 0
#if DATA_BITS == 8
#define MEM_SUFFIX b_raw
#elif DATA_BITS == 16
#define MEM_SUFFIX w_raw
#elif DATA_BITS == 32
#define MEM_SUFFIX l_raw
#endif
#elif MEM_WRITE == 1
#if DATA_BITS == 8
#define MEM_SUFFIX b_kernel
#elif DATA_BITS == 16
#define MEM_SUFFIX w_kernel
#elif DATA_BITS == 32
#define MEM_SUFFIX l_kernel
#endif
#elif MEM_WRITE == 2
#if DATA_BITS == 8 #if DATA_BITS == 8
#define MEM_SUFFIX b_mem #define MEM_SUFFIX b_user
#elif DATA_BITS == 16 #elif DATA_BITS == 16
#define MEM_SUFFIX w_mem #define MEM_SUFFIX w_user
#elif DATA_BITS == 32 #elif DATA_BITS == 32
#define MEM_SUFFIX l_mem #define MEM_SUFFIX l_user
#endif
#else
#error invalid MEM_WRITE
#endif #endif
#else #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)
T0 &= DATA_MASK; T0 &= DATA_MASK;
T0 = (T0 << count) | (T0 >> (DATA_BITS - count)); T0 = (T0 << count) | (T0 >> (DATA_BITS - count));
#ifdef MEM_WRITE #ifdef MEM_WRITE
glue(st, SUFFIX)((uint8_t *)A0, T0); glue(st, MEM_SUFFIX)((uint8_t *)A0, T0);
#else #else
/* gcc 3.2 workaround. This is really a bug in gcc. */ /* gcc 3.2 workaround. This is really a bug in gcc. */
asm volatile("" : : "r" (T0)); 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)
T0 &= DATA_MASK; T0 &= DATA_MASK;
T0 = (T0 >> count) | (T0 << (DATA_BITS - count)); T0 = (T0 >> count) | (T0 << (DATA_BITS - count));
#ifdef MEM_WRITE #ifdef MEM_WRITE
glue(st, SUFFIX)((uint8_t *)A0, T0); glue(st, MEM_SUFFIX)((uint8_t *)A0, T0);
#else #else
/* gcc 3.2 workaround. This is really a bug in gcc. */ /* gcc 3.2 workaround. This is really a bug in gcc. */
asm volatile("" : : "r" (T0)); 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)
T0 &= DATA_MASK; T0 &= DATA_MASK;
T0 = (T0 << count) | (T0 >> (DATA_BITS - count)); T0 = (T0 << count) | (T0 >> (DATA_BITS - count));
#ifdef MEM_WRITE #ifdef MEM_WRITE
glue(st, SUFFIX)((uint8_t *)A0, T0); glue(st, MEM_SUFFIX)((uint8_t *)A0, T0);
#endif #endif
} }
FORCE_RET(); 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)
T0 &= DATA_MASK; T0 &= DATA_MASK;
T0 = (T0 >> count) | (T0 << (DATA_BITS - count)); T0 = (T0 >> count) | (T0 << (DATA_BITS - count));
#ifdef MEM_WRITE #ifdef MEM_WRITE
glue(st, SUFFIX)((uint8_t *)A0, T0); glue(st, MEM_SUFFIX)((uint8_t *)A0, T0);
#endif #endif
} }
FORCE_RET(); 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)
res |= T0 >> (DATA_BITS + 1 - count); res |= T0 >> (DATA_BITS + 1 - count);
T0 = res; T0 = res;
#ifdef MEM_WRITE #ifdef MEM_WRITE
glue(st, SUFFIX)((uint8_t *)A0, T0); glue(st, MEM_SUFFIX)((uint8_t *)A0, T0);
#endif #endif
CC_SRC = (eflags & ~(CC_C | CC_O)) | CC_SRC = (eflags & ~(CC_C | CC_O)) |
(lshift(src ^ T0, 11 - (DATA_BITS - 1)) & CC_O) | (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)
res |= T0 << (DATA_BITS + 1 - count); res |= T0 << (DATA_BITS + 1 - count);
T0 = res; T0 = res;
#ifdef MEM_WRITE #ifdef MEM_WRITE
glue(st, SUFFIX)((uint8_t *)A0, T0); glue(st, MEM_SUFFIX)((uint8_t *)A0, T0);
#endif #endif
CC_SRC = (eflags & ~(CC_C | CC_O)) | CC_SRC = (eflags & ~(CC_C | CC_O)) |
(lshift(src ^ T0, 11 - (DATA_BITS - 1)) & CC_O) | (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)
src = (DATA_TYPE)T0 << (count - 1); src = (DATA_TYPE)T0 << (count - 1);
T0 = T0 << count; T0 = T0 << count;
#ifdef MEM_WRITE #ifdef MEM_WRITE
glue(st, SUFFIX)((uint8_t *)A0, T0); glue(st, MEM_SUFFIX)((uint8_t *)A0, T0);
#endif #endif
CC_SRC = src; CC_SRC = src;
CC_DST = T0; 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)
src = T0 >> (count - 1); src = T0 >> (count - 1);
T0 = T0 >> count; T0 = T0 >> count;
#ifdef MEM_WRITE #ifdef MEM_WRITE
glue(st, SUFFIX)((uint8_t *)A0, T0); glue(st, MEM_SUFFIX)((uint8_t *)A0, T0);
#endif #endif
CC_SRC = src; CC_SRC = src;
CC_DST = T0; 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)
T0 = src >> count; T0 = src >> count;
src = src >> (count - 1); src = src >> (count - 1);
#ifdef MEM_WRITE #ifdef MEM_WRITE
glue(st, SUFFIX)((uint8_t *)A0, T0); glue(st, MEM_SUFFIX)((uint8_t *)A0, T0);
#endif #endif
CC_SRC = src; CC_SRC = src;
CC_DST = T0; 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)
res |= T1 << (count - 16); res |= T1 << (count - 16);
T0 = res >> 16; T0 = res >> 16;
#ifdef MEM_WRITE #ifdef MEM_WRITE
glue(st, SUFFIX)((uint8_t *)A0, T0); glue(st, MEM_SUFFIX)((uint8_t *)A0, T0);
#endif #endif
CC_SRC = tmp; CC_SRC = tmp;
CC_DST = T0; 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)
res |= T1 << (count - 16); res |= T1 << (count - 16);
T0 = res >> 16; T0 = res >> 16;
#ifdef MEM_WRITE #ifdef MEM_WRITE
glue(st, SUFFIX)((uint8_t *)A0, T0); glue(st, MEM_SUFFIX)((uint8_t *)A0, T0);
#endif #endif
CC_SRC = tmp; CC_SRC = tmp;
CC_DST = T0; 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)
res |= T1 << (32 - count); res |= T1 << (32 - count);
T0 = res; T0 = res;
#ifdef MEM_WRITE #ifdef MEM_WRITE
glue(st, SUFFIX)((uint8_t *)A0, T0); glue(st, MEM_SUFFIX)((uint8_t *)A0, T0);
#endif #endif
CC_SRC = tmp; CC_SRC = tmp;
CC_DST = T0; 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)
res |= T1 << (32 - count); res |= T1 << (32 - count);
T0 = res; T0 = res;
#ifdef MEM_WRITE #ifdef MEM_WRITE
glue(st, SUFFIX)((uint8_t *)A0, T0); glue(st, MEM_SUFFIX)((uint8_t *)A0, T0);
#endif #endif
CC_SRC = tmp; CC_SRC = tmp;
CC_DST = T0; 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)
tmp = T0 << (count - 1); tmp = T0 << (count - 1);
T0 = (T0 << count) | (T1 >> (DATA_BITS - count)); T0 = (T0 << count) | (T1 >> (DATA_BITS - count));
#ifdef MEM_WRITE #ifdef MEM_WRITE
glue(st, SUFFIX)((uint8_t *)A0, T0); glue(st, MEM_SUFFIX)((uint8_t *)A0, T0);
#endif #endif
CC_SRC = tmp; CC_SRC = tmp;
CC_DST = T0; 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)
tmp = T0 << (count - 1); tmp = T0 << (count - 1);
T0 = (T0 << count) | (T1 >> (DATA_BITS - count)); T0 = (T0 << count) | (T1 >> (DATA_BITS - count));
#ifdef MEM_WRITE #ifdef MEM_WRITE
glue(st, SUFFIX)((uint8_t *)A0, T0); glue(st, MEM_SUFFIX)((uint8_t *)A0, T0);
#endif #endif
CC_SRC = tmp; CC_SRC = tmp;
CC_DST = T0; 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)
tmp = T0 >> (count - 1); tmp = T0 >> (count - 1);
T0 = (T0 >> count) | (T1 << (DATA_BITS - count)); T0 = (T0 >> count) | (T1 << (DATA_BITS - count));
#ifdef MEM_WRITE #ifdef MEM_WRITE
glue(st, SUFFIX)((uint8_t *)A0, T0); glue(st, MEM_SUFFIX)((uint8_t *)A0, T0);
#endif #endif
CC_SRC = tmp; CC_SRC = tmp;
CC_DST = T0; 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)
tmp = T0 >> (count - 1); tmp = T0 >> (count - 1);
T0 = (T0 >> count) | (T1 << (DATA_BITS - count)); T0 = (T0 >> count) | (T1 << (DATA_BITS - count));
#ifdef MEM_WRITE #ifdef MEM_WRITE
glue(st, SUFFIX)((uint8_t *)A0, T0); glue(st, MEM_SUFFIX)((uint8_t *)A0, T0);
#endif #endif
CC_SRC = tmp; CC_SRC = tmp;
CC_DST = T0; 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)
cf = cc_table[CC_OP].compute_c(); cf = cc_table[CC_OP].compute_c();
T0 = T0 + T1 + cf; T0 = T0 + T1 + cf;
#ifdef MEM_WRITE #ifdef MEM_WRITE
glue(st, SUFFIX)((uint8_t *)A0, T0); glue(st, MEM_SUFFIX)((uint8_t *)A0, T0);
#endif #endif
CC_SRC = T1; CC_SRC = T1;
CC_DST = T0; 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)
cf = cc_table[CC_OP].compute_c(); cf = cc_table[CC_OP].compute_c();
T0 = T0 - T1 - cf; T0 = T0 - T1 - cf;
#ifdef MEM_WRITE #ifdef MEM_WRITE
glue(st, SUFFIX)((uint8_t *)A0, T0); glue(st, MEM_SUFFIX)((uint8_t *)A0, T0);
#endif #endif
CC_SRC = T1; CC_SRC = T1;
CC_DST = T0; 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)
EAX = (EAX & ~DATA_MASK) | (T0 & DATA_MASK); EAX = (EAX & ~DATA_MASK) | (T0 & DATA_MASK);
} }
#ifdef MEM_WRITE #ifdef MEM_WRITE
glue(st, SUFFIX)((uint8_t *)A0, T0); glue(st, MEM_SUFFIX)((uint8_t *)A0, T0);
#endif #endif
CC_SRC = src; CC_SRC = src;
CC_DST = dst; CC_DST = dst;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册