Skip to contentSkip to conversation

M68k emulation

RFC New Andreas Schwab 1 participant 1 message Jul 2, 2007

lore
Share & tools
lore
#0 lore raw

RFC 1/1 M68k emulation

This patch extends the m68k emulation to include most m68k insns. While it is still incomplete, it is good enough to execute code generated by gcc. Any comments appreciated.

Andreas.

Index: target-m68k/cpu.h
===================================================================
RCS file: /sources/qemu/qemu/target-m68k/cpu.h,v
retrieving revision 1.11

cpu.h +28 -6
diff -u -a -p -r1.11 cpu.h
@@ -86,7 +86,10 @@ typedef struct CPUM68KState {
     /* Temporary storage for DIV helpers.  */
     uint32_t div1;
     uint32_t div2;
-    
+
+    /* Upper 32 bits of a 64bit operand for quad MUL/DIV.  */
+    uint32_t quadh;
+
     /* MMU status.  */
     struct {
         uint32_t ar;
@@ -133,14 +136,26 @@ enum {
     CC_OP_DYNAMIC, /* Use env->cc_op  */
     CC_OP_FLAGS, /* CC_DEST = CVZN, CC_SRC = unused */
     CC_OP_LOGIC, /* CC_DEST = result, CC_SRC = unused */
+    CC_OP_ADDB,  /* CC_DEST = result, CC_SRC = source */
+    CC_OP_ADDW,  /* CC_DEST = result, CC_SRC = source */
     CC_OP_ADD,   /* CC_DEST = result, CC_SRC = source */
+    CC_OP_SUBB,  /* CC_DEST = result, CC_SRC = source */
+    CC_OP_SUBW,  /* CC_DEST = result, CC_SRC = source */
     CC_OP_SUB,   /* CC_DEST = result, CC_SRC = source */
-    CC_OP_CMPB,  /* CC_DEST = result, CC_SRC = source */
-    CC_OP_CMPW,  /* CC_DEST = result, CC_SRC = source */
+    CC_OP_ADDXB, /* CC_DEST = result, CC_SRC = source */
+    CC_OP_ADDXW, /* CC_DEST = result, CC_SRC = source */
     CC_OP_ADDX,  /* CC_DEST = result, CC_SRC = source */
+    CC_OP_SUBXB, /* CC_DEST = result, CC_SRC = source */
+    CC_OP_SUBXW, /* CC_DEST = result, CC_SRC = source */
     CC_OP_SUBX,  /* CC_DEST = result, CC_SRC = source */
+    CC_OP_SHLB,  /* CC_DEST = source, CC_SRC = shift */
+    CC_OP_SHLW,  /* CC_DEST = source, CC_SRC = shift */
     CC_OP_SHL,   /* CC_DEST = source, CC_SRC = shift */
+    CC_OP_SHRB,  /* CC_DEST = source, CC_SRC = shift */
+    CC_OP_SHRW,  /* CC_DEST = source, CC_SRC = shift */
     CC_OP_SHR,   /* CC_DEST = source, CC_SRC = shift */
+    CC_OP_SARB,  /* CC_DEST = source, CC_SRC = shift */
+    CC_OP_SARW,  /* CC_DEST = source, CC_SRC = shift */
     CC_OP_SAR,   /* CC_DEST = source, CC_SRC = shift */
 };
 
@@ -189,6 +204,7 @@ void do_m68k_semihosting(CPUM68KState *e
    ISA revisions mentioned.  */
 
 enum m68k_features {
+    M68K_FEATURE_M68000,
     M68K_FEATURE_CF_ISA_A,
     M68K_FEATURE_CF_ISA_B, /* (ISA B or C).  */
     M68K_FEATURE_CF_ISA_APLUSC, /* BIT/BITREV, FF1, STRLDSR (ISA A+ or C).  */
@@ -199,7 +215,13 @@ enum m68k_features {
     M68K_FEATURE_CF_EMAC_B, /* Revision B EMAC (dual accumulate).  */
     M68K_FEATURE_USP, /* User Stack Pointer.  (ISA A+, B or C).  */
     M68K_FEATURE_EXT_FULL, /* 68020+ full extension word.  */
-    M68K_FEATURE_WORD_INDEX /* word sized address index registers.  */
+    M68K_FEATURE_WORD_INDEX, /* word sized address index registers.  */
+    M68K_FEATURE_SCALED_INDEX, /* scaled address index registers.  */
+    M68K_FEATURE_LONG_MULDIV,	/* 32 bit multiply/divide. */
+    M68K_FEATURE_QUAD_MULDIV,	/* 64 bit multiply/divide. */
+    M68K_FEATURE_BCCL,		/* Long conditional branches.  */
+    M68K_FEATURE_BITFIELD,	/* Bit field insns.  */
+    M68K_FEATURE_FPU
 };
 
 static inline int m68k_feature(CPUM68KState *env, int feature)
@@ -210,8 +232,8 @@ static inline int m68k_feature(CPUM68KSt
 void register_m68k_insns (CPUM68KState *env);
 
 #ifdef CONFIG_USER_ONLY
-/* Linux uses 8k pages.  */
-#define TARGET_PAGE_BITS 13
+/* Linux uses 4k pages.  */
+#define TARGET_PAGE_BITS 12
 #else
 /* Smallest TLB entry size is 1k.  */ 
 #define TARGET_PAGE_BITS 10

Index: target-m68k/exec.h
===================================================================
RCS file: /sources/qemu/qemu/target-m68k/exec.h,v
retrieving revision 1.3

exec.h +4 -0
diff -u -a -p -r1.3 exec.h
@@ -48,6 +48,10 @@ void cpu_m68k_flush_flags(CPUM68KState *
 float64 helper_sub_cmpf64(CPUM68KState *env, float64 src0, float64 src1);
 void helper_movec(CPUM68KState *env, int reg, uint32_t val);
 
+extern const uint8_t rox8_table[64];
+extern const uint8_t rox16_table[64];
+extern const uint8_t rox32_table[64];
+
 void cpu_loop_exit(void);
 
 static inline int cpu_halted(CPUState *env) {

Index: target-m68k/helper.c
===================================================================
RCS file: /sources/qemu/qemu/target-m68k/helper.c,v retrieving revision 1.6

helper.c +190 -46

317 lines not on this page · raw message

Index: target-m68k/op-hacks.h
===================================================================
RCS file: /sources/qemu/qemu/target-m68k/op-hacks.h,v retrieving revision 1.3

op-hacks.h +30 -0
diff -u -a -p -r1.3 op-hacks.h
@@ -89,6 +89,36 @@ static inline void gen_op_sar_im_cc(int 
     gen_op_sar_cc(val, gen_im32(shift));
 }
 
+static inline void gen_op_shl8_im_cc(int dest, int src, int shift)
+{
+    gen_op_shl8_cc(dest, src, gen_im32(shift));
+}
+
+static inline void gen_op_shr8_im_cc(int dest, int src, int shift)
+{
+    gen_op_shr8_cc(dest, src, gen_im32(shift));
+}
+
+static inline void gen_op_sar8_im_cc(int dest, int src, int shift)
+{
+    gen_op_sar8_cc(dest, src, gen_im32(shift));
+}
+
+static inline void gen_op_shl16_im_cc(int dest, int src, int shift)
+{
+    gen_op_shl16_cc(dest, src, gen_im32(shift));
+}
+
+static inline void gen_op_shr16_im_cc(int dest, int src, int shift)
+{
+    gen_op_shr16_cc(dest, src, gen_im32(shift));
+}
+
+static inline void gen_op_sar16_im_cc(int dest, int src, int shift)
+{
+    gen_op_sar16_cc(dest, src, gen_im32(shift));
+}
+
 #ifdef USE_DIRECT_JUMP
 #define TBPARAM(x)
 #else

Index: target-m68k/op.c
===================================================================
RCS file: /sources/qemu/qemu/target-m68k/op.c,v
retrieving revision 1.11

op.c +445 -13

527 lines not on this page · raw message

Index: target-m68k/qregs.def
===================================================================
RCS file: /sources/qemu/qemu/target-m68k/qregs.def,v retrieving revision 1.3

qregs.def +1 -0
diff -u -a -p -r1.3 qregs.def
@@ -32,6 +32,7 @@ DEFO32(CC_SRC, cc_src)
 DEFO32(CC_X, cc_x)
 DEFO32(DIV1, div1)
 DEFO32(DIV2, div2)
+DEFO32(QUADH, quadh)
 DEFO32(EXCEPTION, exception_index)
 DEFO32(MACSR, macsr)
 DEFO32(MAC_MASK, mac_mask)

Index: target-m68k/translate.c
===================================================================
RCS file: /sources/qemu/qemu/target-m68k/translate.c,v retrieving revision 1.17

translate.c +1036 -128

1,544 lines not on this page · raw message

Signature · 5 lines
-- 
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."