ARM7TDMI emulation
PATCH 1/1 ARM7TDMI emulation
Hi!
This patch adds ARM7TDMI emulation with Thumb v1 (no BLX, no BKPT, ignore bit 0 on POP PC) and without CP15.
CU
Uli
Signature · 1 line
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
Index: cpu.h
===================================================================
RCS file: /sources/qemu/qemu/target-arm/cpu.h,v
retrieving revision 1.28
cpu.h +4 -1
@@ -247,7 +247,9 @@ARM_FEATURE_AUXCR ,/* ARM1026 Auxiliary control register. */ ARM_FEATURE_XSCALE ,/* Intel XScale extensions. */ ARM_FEATURE_IWMMXT ,/* Intel iwMMXt extension. */ - ARM_FEATURE_MPU /* Only has Memory Protection Unit, not full MMU. */ +ARM_FEATURE_MPU ,/* Only has Memory Protection Unit, not full MMU. */ +ARM_FEATURE_THUMB1 ,/* Thumb v1 (ARM v4 with Thumb) */ + ARM_FEATURE_NO_CP15 /* ARM7TDMI, ARM7TDMI-S, ARM7EJ-S, and ARM9TDMI cores do not have a CP15 */ };static inline int arm_feature (CPUARMState *env,int feature)
@@ -262,6 +264,7 @@ ARMReadCPFunc *cp_read, ARMWriteCPFunc *cp_write, void *opaque); +#define ARM_CPUID_ARM7TDMI 0x41807000/* guess; no CP15 on ARM7TDMI */ #define ARM_CPUID_ARM1026 0x4106a262#define ARM_CPUID_ARM926 0x41069265#define ARM_CPUID_ARM946 0x41059461
Index: helper.c
===================================================================
RCS file: /sources/qemu/qemu/target-arm/helper.c,v retrieving revision 1.17
helper.c +6 -0
@@ -14,6 +14,11 @@ { env->cp15.c0_cpuid = id;switch (id) { +case ARM_CPUID_ARM7TDMI : +set_feature (env,ARM_FEATURE_THUMB1 ); +set_feature (env,ARM_FEATURE_NO_CP15 ); +/* no CP15 here */ +break ;case ARM_CPUID_ARM926 :set_feature (env,ARM_FEATURE_VFP ); env->vfp.xregs[ARM_VFP_FPSID ] =0x41011090 ;
@@ -98,6 +103,7 @@ };static const struct arm_cpu_t arm_cpu_names[] = { + {ARM_CPUID_ARM7TDMI ,"arm7tdmi" }, {ARM_CPUID_ARM926 ,"arm926" }, {ARM_CPUID_ARM946 ,"arm946" }, {ARM_CPUID_ARM1026 ,"arm1026" },
Index: translate.c
===================================================================
RCS file: /sources/qemu/qemu/target-arm/translate.c,v retrieving revision 1.53
translate.c +12 -5
@@ -1589,7 +1589,7 @@uint32_t rd;/* ??? Some cp15 registers are accessible from userspace. */ -if (IS_USER (s)) { +if (IS_USER (s) ||arm_feature (env,ARM_FEATURE_NO_CP15 )) {return 1 ; } if ((insn & 0x0fff0fff) == 0x0e070f90
@@ -2958,7 +2958,7 @@ } } -static void disas_thumb_insn (DisasContext *s) +static void disas_thumb_insn (CPUState *env,DisasContext *s) {uint32_t val, insn, op, rm, rn, rd, shift, cond;int32_t offset;
@@ -3058,6 +3058,7 @@break ;case 3 :/* branch [and link] exchange thumb register */ if (insn & (1 <<7 )) { +if (arm_feature (env,ARM_FEATURE_THUMB1 )) goto undef; val = (uint32_t )s->pc |1 ;gen_op_movl_T1_im (val);gen_movl_reg_T1 (s,14 );
@@ -3367,11 +3368,16 @@/* write back the new stack pointer */ gen_movl_reg_T1 (s,13 );/* set the new PC value */ -if ((insn &0x0900 ) ==0x0900 ) -gen_bx (s); +if ((insn &0x0900 ) ==0x0900 ) { +if (arm_feature (env,ARM_FEATURE_THUMB1 )) +gen_movl_reg_T0 (s,15 ); +else +gen_bx (s); + }break ;case 0xe :/* bkpt */ +if (arm_feature (env,ARM_FEATURE_THUMB1 )) goto undef;gen_op_movl_T0_im ((long )s->pc -2 ); gen_op_movl_reg_TN[0 ][15 ]();gen_op_bkpt ();
@@ -3442,6 +3448,7 @@/* unconditional branch */ if (insn & (1 <<11 )) {/* Second half of blx. */ +if (arm_feature (env,ARM_FEATURE_THUMB1 )) goto undef; offset = ((insn &0x7ff ) <<1 );gen_movl_T0_reg (s,14 );gen_op_movl_T1_im (offset);
@@ -3571,7 +3578,7 @@ }if (env->thumb) -disas_thumb_insn (dc); +disas_thumb_insn (env, dc);else disas_arm_insn (env, dc);
Quoted 4 lines · Ulrich Hecht
Hi!
This patch adds ARM7TDMI emulation with Thumb v1 (no BLX, no BKPT, ignore bit 0 on POP PC) and without CP15.
ARM_FEATURE_THUMB1 is a bad name for this. Thumb-1 covers both v4t and v5t. Thumb-2 is a completely new architecture revision which adds 32-bit instructions.
You should add/use ARM_FEATURE_V5/ARCH(5) instead.
For added confusion some older documentation refers to v5t as "thumb2", or the second revision of the Thumb ISA. This should be ignored :-)
The ARM7TDMI implements the base updated abort model. You should either implement that, or pick a core (eg. 920t) that uses the base restored abort model.
Paul
Quoted 1 line · Paul Brook
You should add/use ARM_FEATURE_V5/ARCH(5) instead.
Alright.
Quoted 1 line
The ARM7TDMI implements the base updated abort model.
Er, yes, but there is no MMU that could actually cause an abort, right?
Anyway, here's the 920T version. The magic numbers may or may not be correct.
CU
Uli
Signature · 1 line
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
Index: target-arm/cpu.h
===================================================================
RCS file: /sources/qemu/qemu/target-arm/cpu.h,v
retrieving revision 1.28
cpu.h +5 -1
@@ -247,7 +247,9 @@ARM_FEATURE_AUXCR ,/* ARM1026 Auxiliary control register. */ ARM_FEATURE_XSCALE ,/* Intel XScale extensions. */ ARM_FEATURE_IWMMXT ,/* Intel iwMMXt extension. */ - ARM_FEATURE_MPU /* Only has Memory Protection Unit, not full MMU. */ +ARM_FEATURE_MPU ,/* Only has Memory Protection Unit, not full MMU. */ +ARM_FEATURE_V5 ,/* ARM v5 instruction set */ + ARM_FEATURE_NO_CP15 /* ARM7TDMI, ARM7TDMI-S, ARM7EJ-S, and ARM9TDMI cores do not have a CP15 */ };static inline int arm_feature (CPUARMState *env,int feature)
@@ -262,7 +264,9 @@ ARMReadCPFunc *cp_read, ARMWriteCPFunc *cp_write, void *opaque); +#define ARM_CPUID_ARM7TDMI 0x41807000/* guess; no CP15 on ARM7TDMI */ #define ARM_CPUID_ARM1026 0x4106a262 +#define ARM_CPUID_ARM920T 0x41129200#define ARM_CPUID_ARM926 0x41069265#define ARM_CPUID_ARM946 0x41059461#define ARM_CPUID_PXA250 0x69052100
Index: target-arm/helper.c
===================================================================
RCS file: /sources/qemu/qemu/target-arm/helper.c,v retrieving revision 1.17
helper.c +10 -0
@@ -14,20 +14,27 @@ { env->cp15.c0_cpuid = id;switch (id) { +case ARM_CPUID_ARM920T : + env->cp15.c0_cachetype =0x0d172172 ; + env->cp15.c1_sys =0x00000078 ; +break ;case ARM_CPUID_ARM926 :set_feature (env,ARM_FEATURE_VFP ); +set_feature (env,ARM_FEATURE_V5 ); env->vfp.xregs[ARM_VFP_FPSID ] =0x41011090 ; env->cp15.c0_cachetype =0x1dd20d2 ; env->cp15.c1_sys =0x00090078 ;break ;case ARM_CPUID_ARM946 :set_feature (env,ARM_FEATURE_MPU ); +set_feature (env,ARM_FEATURE_V5 ); env->cp15.c0_cachetype =0x0f004006 ; env->cp15.c1_sys =0x00000078 ;break ;case ARM_CPUID_ARM1026 :set_feature (env,ARM_FEATURE_VFP );set_feature (env,ARM_FEATURE_AUXCR ); +set_feature (env,ARM_FEATURE_V5 ); env->vfp.xregs[ARM_VFP_FPSID ] =0x410110a0 ; env->cp15.c0_cachetype =0x1dd20d2 ; env->cp15.c1_sys =0x00090078 ;
@@ -38,6 +45,7 @@case ARM_CPUID_PXA261 :case ARM_CPUID_PXA262 :set_feature (env,ARM_FEATURE_XSCALE ); +set_feature (env,ARM_FEATURE_V5 );/* JTAG_ID is ((id << 28) | 0x09265013) */ env->cp15.c0_cachetype =0xd172172 ; env->cp15.c1_sys =0x00000078 ;
@@ -49,6 +57,7 @@case ARM_CPUID_PXA270_C0 :case ARM_CPUID_PXA270_C5 :set_feature (env,ARM_FEATURE_XSCALE ); +set_feature (env,ARM_FEATURE_V5 );/* JTAG_ID is ((id << 28) | 0x09265013) */ set_feature (env,ARM_FEATURE_IWMMXT ); env->iwmmxt.cregs[ARM_IWMMXT_wCID] =0x69051000 |'Q' ;
@@ -98,6 +107,7 @@ };static const struct arm_cpu_t arm_cpu_names[] = { + {ARM_CPUID_ARM920T ,"arm920t" }, {ARM_CPUID_ARM926 ,"arm926" }, {ARM_CPUID_ARM946 ,"arm946" }, {ARM_CPUID_ARM1026 ,"arm1026" },
Index: target-arm/translate.c
===================================================================
RCS file: /sources/qemu/qemu/target-arm/translate.c,v retrieving revision 1.53
translate.c +12 -5
@@ -1589,7 +1589,7 @@uint32_t rd;/* ??? Some cp15 registers are accessible from userspace. */ -if (IS_USER (s)) { +if (IS_USER (s) ||arm_feature (env,ARM_FEATURE_NO_CP15 )) {return 1 ; } if ((insn & 0x0fff0fff) == 0x0e070f90
@@ -2958,7 +2958,7 @@ } } -static void disas_thumb_insn (DisasContext *s) +static void disas_thumb_insn (CPUState *env,DisasContext *s) {uint32_t val, insn, op, rm, rn, rd, shift, cond;int32_t offset;
@@ -3058,6 +3058,7 @@break ;case 3 :/* branch [and link] exchange thumb register */ if (insn & (1 <<7 )) { +if (!arm_feature (env,ARM_FEATURE_V5 )) goto undef; val = (uint32_t )s->pc |1 ;gen_op_movl_T1_im (val);gen_movl_reg_T1 (s,14 );
@@ -3367,11 +3368,16 @@/* write back the new stack pointer */ gen_movl_reg_T1 (s,13 );/* set the new PC value */ -if ((insn &0x0900 ) ==0x0900 ) -gen_bx (s); +if ((insn &0x0900 ) ==0x0900 ) { +if (!arm_feature (env,ARM_FEATURE_V5 )) +gen_movl_reg_T0 (s,15 ); +else +gen_bx (s); + }break ;case 0xe :/* bkpt */ +if (!arm_feature (env,ARM_FEATURE_V5 )) goto undef;gen_op_movl_T0_im ((long )s->pc -2 ); gen_op_movl_reg_TN[0 ][15 ]();gen_op_bkpt ();
@@ -3442,6 +3448,7 @@/* unconditional branch */ if (insn & (1 <<11 )) {/* Second half of blx. */ +if (!arm_feature (env,ARM_FEATURE_V5 )) goto undef; offset = ((insn &0x7ff ) <<1 );gen_movl_T0_reg (s,14 );gen_op_movl_T1_im (offset);
@@ -3571,7 +3578,7 @@ }if (env->thumb) -disas_thumb_insn (dc); +disas_thumb_insn (env, dc);else disas_arm_insn (env, dc);
Quoted 2 lines · Ulrich Hecht
Anyway, here's the 920T version. The magic numbers may or may not be correct.
And here's an even better version that implements both 920T and 7TDMI (with base-updated aborts).
CU
Uli
Signature · 1 line
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
Index: target-arm/cpu.h
===================================================================
RCS file: /sources/qemu/qemu/target-arm/cpu.h,v
retrieving revision 1.28
cpu.h +6 -1
@@ -247,7 +247,10 @@ARM_FEATURE_AUXCR ,/* ARM1026 Auxiliary control register. */ ARM_FEATURE_XSCALE ,/* Intel XScale extensions. */ ARM_FEATURE_IWMMXT ,/* Intel iwMMXt extension. */ - ARM_FEATURE_MPU /* Only has Memory Protection Unit, not full MMU. */ +ARM_FEATURE_MPU ,/* Only has Memory Protection Unit, not full MMU. */ +ARM_FEATURE_V5 ,/* ARM v5 instruction set */ +ARM_FEATURE_NO_CP15 ,/* ARM7TDMI, ARM7TDMI-S, ARM7EJ-S, and ARM9TDMI cores do not have a CP15 */ + ARM_FEATURE_ABORT_BU /* base updated abort model, e.g. ARMxTDMI */ };static inline int arm_feature (CPUARMState *env,int feature)
@@ -262,7 +265,9 @@ ARMReadCPFunc *cp_read, ARMWriteCPFunc *cp_write, void *opaque); +#define ARM_CPUID_ARM7TDMI 0x41807000/* guess; no CP15 on ARM7TDMI */ #define ARM_CPUID_ARM1026 0x4106a262 +#define ARM_CPUID_ARM920T 0x41129200#define ARM_CPUID_ARM926 0x41069265#define ARM_CPUID_ARM946 0x41059461#define ARM_CPUID_PXA250 0x69052100
Index: target-arm/helper.c
===================================================================
RCS file: /sources/qemu/qemu/target-arm/helper.c,v retrieving revision 1.17
helper.c +15 -0
@@ -14,20 +14,31 @@ { env->cp15.c0_cpuid = id;switch (id) { +case ARM_CPUID_ARM7TDMI : +set_feature (env,ARM_FEATURE_ABORT_BU ); +set_feature (env,ARM_FEATURE_NO_CP15 ); +break ; +case ARM_CPUID_ARM920T : + env->cp15.c0_cachetype =0x0d172172 ; + env->cp15.c1_sys =0x00000078 ; +break ;case ARM_CPUID_ARM926 :set_feature (env,ARM_FEATURE_VFP ); +set_feature (env,ARM_FEATURE_V5 ); env->vfp.xregs[ARM_VFP_FPSID ] =0x41011090 ; env->cp15.c0_cachetype =0x1dd20d2 ; env->cp15.c1_sys =0x00090078 ;break ;case ARM_CPUID_ARM946 :set_feature (env,ARM_FEATURE_MPU ); +set_feature (env,ARM_FEATURE_V5 ); env->cp15.c0_cachetype =0x0f004006 ; env->cp15.c1_sys =0x00000078 ;break ;case ARM_CPUID_ARM1026 :set_feature (env,ARM_FEATURE_VFP );set_feature (env,ARM_FEATURE_AUXCR ); +set_feature (env,ARM_FEATURE_V5 ); env->vfp.xregs[ARM_VFP_FPSID ] =0x410110a0 ; env->cp15.c0_cachetype =0x1dd20d2 ; env->cp15.c1_sys =0x00090078 ;
@@ -38,6 +49,7 @@case ARM_CPUID_PXA261 :case ARM_CPUID_PXA262 :set_feature (env,ARM_FEATURE_XSCALE ); +set_feature (env,ARM_FEATURE_V5 );/* JTAG_ID is ((id << 28) | 0x09265013) */ env->cp15.c0_cachetype =0xd172172 ; env->cp15.c1_sys =0x00000078 ;
@@ -49,6 +61,7 @@case ARM_CPUID_PXA270_C0 :case ARM_CPUID_PXA270_C5 :set_feature (env,ARM_FEATURE_XSCALE ); +set_feature (env,ARM_FEATURE_V5 );/* JTAG_ID is ((id << 28) | 0x09265013) */ set_feature (env,ARM_FEATURE_IWMMXT ); env->iwmmxt.cregs[ARM_IWMMXT_wCID] =0x69051000 |'Q' ;
@@ -98,6 +111,8 @@ };static const struct arm_cpu_t arm_cpu_names[] = { + {ARM_CPUID_ARM7TDMI ,"arm7tdmi" }, + {ARM_CPUID_ARM920T ,"arm920t" }, {ARM_CPUID_ARM926 ,"arm926" }, {ARM_CPUID_ARM946 ,"arm946" }, {ARM_CPUID_ARM1026 ,"arm1026" },
Index: target-arm/translate.c
===================================================================
RCS file: /sources/qemu/qemu/target-arm/translate.c,v retrieving revision 1.53
translate.c +61 -26
160 lines not on this page · raw message
Quoted 4 lines · Ulrich Hecht
Quoted 2 lines · Ulrich Hecht
Anyway, here's the 920T version. The magic numbers may or may not be correct.
Quoted 9 lines
And here's an even better version that implements both 920T and 7TDMI (with base-updated aborts).
CU
Uli--
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
Hello,
this is a rewritten version of the original patch to work on the latest qemu git. Anything that needs to be done to get this merged?
ARM7TDMI emulation (ignore bit 0 on POP PC, no BLX, no CP15, base-updated data aborts).
Based on patch by Ulrich Hecht <[email protected]>.
Best regards,
Filip Navara
From b49a01d876d65d9ef456ebbcd8ac219e6d49ab0a Mon Sep 17 00:00:00 2001
From: Filip Navara <[email protected]>
Date: Mon, 15 Jun 2009 21:05:19 +0200
Subject: [PATCH] ARM7TDMI emulation (ignore bit 0 on POP PC, no BLX, no CP15, base-updated data aborts).
Based on patch by Ulrich Hecht <[email protected]>.
--- target-arm/cpu.h | 6 +++- target-arm/helper.c | 24 +++++++++++++ target-arm/translate.c | 87 ++++++++++++++++++++++++++++++++++------------- 3 files changed, 92 insertions(+), 25 deletions(-)
target-arm/cpu.h +5 -1
@@ -331,6 +331,7 @@ enum arm_features {ARM_FEATURE_AUXCR ,/* ARM1026 Auxiliary control register. */ ARM_FEATURE_XSCALE ,/* Intel XScale extensions. */ ARM_FEATURE_IWMMXT ,/* Intel iwMMXt extension. */ +ARM_FEATURE_V5 ,ARM_FEATURE_V6 ,ARM_FEATURE_V6K , ARM_FEATURE_V7,
@@ -341,7 +342,9 @@ enum arm_features {ARM_FEATURE_DIV ,ARM_FEATURE_M ,/* Microcontroller profile. */ ARM_FEATURE_OMAPCP ,/* OMAP specific CP15 ops handling. */ - ARM_FEATURE_THUMB2EE +ARM_FEATURE_THUMB2EE , +ARM_FEATURE_CP15 ,/* ARM7TDMI, ARM7TDMI-S, ARM7EJ-S, and ARM9TDMI cores do not have a CP15 */ + ARM_FEATURE_ABORT_BU /* base updated abort model, e.g. ARMxTDMI */ };static inline int arm_feature (CPUARMState *env,int feature)
@@ -367,6 +370,7 @@ void cpu_arm_set_cp_io(CPUARMState *env, int cpnum,#define IS_M (env) arm_feature(env, ARM_FEATURE_M)#define ARM_CPUID (env) (env->cp15.c0_cpuid) +#define ARM_CPUID_ARM7TDMI 0x41807000/* guess; no CP15 on ARM7TDMI */ #define ARM_CPUID_ARM1026 0x4106a262#define ARM_CPUID_ARM926 0x41069265#define ARM_CPUID_ARM946 0x41059461
target-arm/helper.c +24 -0
@@ -37,19 +37,28 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id) { env->cp15.c0_cpuid = id;switch (id) { +case ARM_CPUID_ARM7TDMI : +set_feature (env,ARM_FEATURE_ABORT_BU ); +break ;case ARM_CPUID_ARM926 : +set_feature (env,ARM_FEATURE_V5 );set_feature (env,ARM_FEATURE_VFP ); +set_feature (env,ARM_FEATURE_CP15 ); env->vfp.xregs[ARM_VFP_FPSID ] =0x41011090 ; env->cp15.c0_cachetype =0x1dd20d2 ; env->cp15.c1_sys =0x00090078 ;break ;case ARM_CPUID_ARM946 : +set_feature (env,ARM_FEATURE_V5 ); +set_feature (env,ARM_FEATURE_CP15 );set_feature (env,ARM_FEATURE_MPU ); env->cp15.c0_cachetype =0x0f004006 ; env->cp15.c1_sys =0x00000078 ;break ;case ARM_CPUID_ARM1026 : +set_feature (env,ARM_FEATURE_V5 );set_feature (env,ARM_FEATURE_VFP ); +set_feature (env,ARM_FEATURE_CP15 );set_feature (env,ARM_FEATURE_AUXCR ); env->vfp.xregs[ARM_VFP_FPSID ] =0x410110a0 ; env->cp15.c0_cachetype =0x1dd20d2 ;
@@ -57,8 +66,10 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)break ;case ARM_CPUID_ARM1136_R2 :case ARM_CPUID_ARM1136 : +set_feature (env,ARM_FEATURE_V5 );set_feature (env,ARM_FEATURE_V6 );set_feature (env,ARM_FEATURE_VFP ); +set_feature (env,ARM_FEATURE_CP15 );set_feature (env,ARM_FEATURE_AUXCR ); env->vfp.xregs[ARM_VFP_FPSID ] =0x410120b4 ; env->vfp.xregs[ARM_VFP_MVFR0 ] =0x11111111 ;
@@ -68,9 +79,11 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id) env->cp15.c0_cachetype =0x1dd20d2 ;break ;case ARM_CPUID_ARM11MPCORE : +set_feature (env,ARM_FEATURE_V5 );set_feature (env,ARM_FEATURE_V6 );set_feature (env,ARM_FEATURE_V6K );set_feature (env,ARM_FEATURE_VFP ); +set_feature (env,ARM_FEATURE_CP15 );set_feature (env,ARM_FEATURE_AUXCR ); env->vfp.xregs[ARM_VFP_FPSID ] =0x410120b4 ; env->vfp.xregs[ARM_VFP_MVFR0 ] =0x11111111 ;
@@ -80,9 +93,11 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id) env->cp15.c0_cachetype =0x1dd20d2 ;break ;case ARM_CPUID_CORTEXA8 : +set_feature (env,ARM_FEATURE_V5 );set_feature (env,ARM_FEATURE_V6 );set_feature (env,ARM_FEATURE_V6K );set_feature (env,ARM_FEATURE_V7 ); +set_feature (env,ARM_FEATURE_CP15 );set_feature (env,ARM_FEATURE_AUXCR );set_feature (env,ARM_FEATURE_THUMB2 );set_feature (env,ARM_FEATURE_VFP );
@@ -101,6 +116,7 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id) env->cp15.c0_ccsid[2 ] =0xf0000000 ;/* No L2 icache. */ break ;case ARM_CPUID_CORTEXM3 : +set_feature (env,ARM_FEATURE_V5 );set_feature (env,ARM_FEATURE_V6 );set_feature (env,ARM_FEATURE_THUMB2 );set_feature (env,ARM_FEATURE_V7 );
@@ -108,6 +124,7 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)set_feature (env,ARM_FEATURE_DIV );break ;case ARM_CPUID_ANY :/* For userspace emulation. */ +set_feature (env,ARM_FEATURE_V5 );set_feature (env,ARM_FEATURE_V6 );set_feature (env,ARM_FEATURE_V6K );set_feature (env,ARM_FEATURE_V7 );
@@ -120,6 +137,8 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)break ;case ARM_CPUID_TI915T :case ARM_CPUID_TI925T : +set_feature (env,ARM_FEATURE_V5 ); +set_feature (env,ARM_FEATURE_CP15 );set_feature (env,ARM_FEATURE_OMAPCP ); env->cp15.c0_cpuid =ARM_CPUID_TI925T ;/* Depends on wiring. */ env->cp15.c0_cachetype =0x5109149 ;
@@ -132,6 +151,8 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)case ARM_CPUID_PXA260 :case ARM_CPUID_PXA261 :case ARM_CPUID_PXA262 : +set_feature (env,ARM_FEATURE_V5 ); +set_feature (env,ARM_FEATURE_CP15 );set_feature (env,ARM_FEATURE_XSCALE );/* JTAG_ID is ((id << 28) | 0x09265013) */ env->cp15.c0_cachetype =0xd172172 ;
@@ -143,6 +164,8 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)case ARM_CPUID_PXA270_B1 :case ARM_CPUID_PXA270_C0 :case ARM_CPUID_PXA270_C5 : +set_feature (env,ARM_FEATURE_V5 ); +set_feature (env,ARM_FEATURE_CP15 );set_feature (env,ARM_FEATURE_XSCALE );/* JTAG_ID is ((id << 28) | 0x09265013) */ set_feature (env,ARM_FEATURE_IWMMXT );
@@ -277,6 +300,7 @@ struct arm_cpu_t { };static const struct arm_cpu_t arm_cpu_names[] = { + {ARM_CPUID_ARM7TDMI ,"arm7tdmi" }, {ARM_CPUID_ARM926 ,"arm926" }, {ARM_CPUID_ARM946 ,"arm946" }, {ARM_CPUID_ARM1026 ,"arm1026" },
target-arm/translate.c +63 -24
141 lines not on this page · raw message
Signature · 1 line
1.6.3.msysgit.0
Quoted 2 lines
this is a rewritten version of the original patch to work on the latest qemu git. Anything that needs to be done to get this merged?
You're missing quite a few bits here. For example load pc should do the same as pop pc, and there are many other instructions that aren't valid on v5t/v5te. See the recent arm920t patches (and corresponding discussion).
Paul
Quoted 6 lines · Paul Brook
Quoted 2 lines
this is a rewritten version of the original patch to work on the latest qemu git. Anything that needs to be done to get this merged?
You're missing quite a few bits here. For example load pc should do the same as pop pc, and there are many other instructions that aren't valid on v5t/v5te. See the recent arm920t patches (and corresponding discussion).
I'm thinking of adding ARMv4 (not v4T) support, so I can test that code needing to run on a real ARMv4 does not accidentally have any unsupported instructions.
While looking into that, I found it quite difficult to find which instructions are supported by different ARM architecture levels, and especially how PC is treated by different instructions on the different architectures.
Do you know of a good summary reference which lists which instructions are available in each ARM architecture level from ARMv4 up to ARMv7 and it's variants?
(Preferably without an ARM licensing agreement or NDA).
-- Jamie
Quoted 3 lines
Do you know of a good summary reference which lists which instructions are available in each ARM architecture level from ARMv4 up to ARMv7 and it's variants?
Other than the details I've already sent to this list, no.
Paul
Quoted 5 lines
Do you know of a good summary reference which lists which instructions are available in each ARM architecture level from ARMv4 up to ARMv7 and it's variants?
My main reference are the technical reference manuals for ARM processors downloaded from Atmel site. I'm not sure about the license, but it states "This document is Open Access. This document has no restriction on distribution." Other reference sources are Skyeye emulation (has to be taken with grain of salt and checked against the manuals, but it makes distinction between v4, v5 and v5e) and Paul Brook.
I've certainly missed handling BLX (at least on three places) in the patch and possibly more. I'll post an updated patch soon.
Best regards,
Filip Navara
Quoted 12 lines · Filip Navara
Do you know of a good summary reference which lists which instructions
Quoted 3 lines
are available in each ARM architecture level from ARMv4 up to ARMv7
and it's variants?My main reference are the technical reference manuals for ARM processors downloaded from Atmel site. I'm not sure about the license, but it states "This document is Open Access. This document has no restriction on distribution." Other reference sources are Skyeye emulation (has to be taken with grain of salt and checked against the manuals, but it makes distinction between v4, v5 and v5e) and Paul Brook.
Quoted 3 lines
I've certainly missed handling BLX (at least on three places) in the patch and possibly more. I'll post an updated patch soon.
The list may not be complete, but this is what I compiled from various sources, including ARM official documentation. For the ARMv4t emulation I'd need to do the following:
- Treat CDP2, LDC2, STC2, BLX, MRC2, MCR2, MCRR, SMUL, SMLA, SMULW, SMLAW, SMLAL, QADD, QSUB, QDADD, QDSUB, BKPT, 64-bit LDR/STR, PLD as undefined instructions.
- Do not change to/from Thumb mode on LDR/LDM/POP to r15 depending on the bit 0 of the value.
- Add the base updated data-abort model.
Other changes between ARMv5 and ARMv4 include:
- MULS, MLAS corrupt C flag
- UMULLS, UMLALS, SMULLS and SMLALS corrupt the C and V flags
I don't plan to implement corrupting the flags. Implementing ARMv4 instead of ARMv4t would then be matter of disabling the BX instruction. Anything I missed?
Best regards,
Filip Navara
Quoted 12 lines · Filip Navara
Do you know of a good summary reference which lists which instructions
Quoted 3 lines
are available in each ARM architecture level from ARMv4 up to ARMv7
and it's variants?My main reference are the technical reference manuals for ARM processors downloaded from Atmel site. I'm not sure about the license, but it states "This document is Open Access. This document has no restriction on distribution." Other reference sources are Skyeye emulation (has to be taken with grain of salt and checked against the manuals, but it makes distinction between v4, v5 and v5e) and Paul Brook.
Quoted 3 lines
I've certainly missed handling BLX (at least on three places) in the patch and possibly more. I'll post an updated patch soon.
... and here's the updated patch. Comments welcome.
I've added more checks for V5+ instructions and fixed about every LDR/LDM place I found to not call gen_bx to set r15.
Best regards,
Filip Navara
Best regards,
Filip Navara
Quoted 18 lines · Filip Navara
Quoted 12 lines · Filip Navara
Do you know of a good summary reference which lists which instructions
Quoted 3 lines
are available in each ARM architecture level from ARMv4 up to ARMv7
and it's variants?My main reference are the technical reference manuals for ARM processors downloaded from Atmel site. I'm not sure about the license, but it states "This document is Open Access. This document has no restriction on distribution." Other reference sources are Skyeye emulation (has to be taken with grain of salt and checked against the manuals, but it makes distinction between v4, v5 and v5e) and Paul Brook.
Quoted 3 lines
I've certainly missed handling BLX (at least on three places) in the patch and possibly more. I'll post an updated patch soon.
Quoted 8 lines
... and here's the updated patch. Comments welcome.
I've added more checks for V5+ instructions and fixed about every LDR/LDM place I found to not call
gen_bxto set r15.Best regards,
Filip Navara
Damn it, forgot to attach it. Thanks Laurent!
From e4ad4939178a464d50edcbdf7f1faa98e3e9cc3a Mon Sep 17 00:00:00 2001
From: Filip Navara <[email protected]>
Date: Mon, 15 Jun 2009 21:05:19 +0200
Subject: [PATCH] ARM7TDMI emulation (ignore bit 0 on POP PC, no BLX, no CP15, base-updated data aborts). Based on patch by Ulrich Hecht <[email protected]>.
--- target-arm/cpu.h | 6 ++- target-arm/helper.c | 24 ++++++++++ target-arm/translate.c | 116 ++++++++++++++++++++++++++++++++++-------------- 3 files changed, 112 insertions(+), 34 deletions(-)
target-arm/cpu.h +5 -1
@@ -331,6 +331,7 @@ enum arm_features {ARM_FEATURE_AUXCR ,/* ARM1026 Auxiliary control register. */ ARM_FEATURE_XSCALE ,/* Intel XScale extensions. */ ARM_FEATURE_IWMMXT ,/* Intel iwMMXt extension. */ +ARM_FEATURE_V5 ,ARM_FEATURE_V6 ,ARM_FEATURE_V6K , ARM_FEATURE_V7,
@@ -341,7 +342,9 @@ enum arm_features {ARM_FEATURE_DIV ,ARM_FEATURE_M ,/* Microcontroller profile. */ ARM_FEATURE_OMAPCP ,/* OMAP specific CP15 ops handling. */ - ARM_FEATURE_THUMB2EE +ARM_FEATURE_THUMB2EE , +ARM_FEATURE_CP15 ,/* ARM7TDMI, ARM7TDMI-S, ARM7EJ-S, and ARM9TDMI cores do not have a CP15 */ + ARM_FEATURE_ABORT_BU /* base updated abort model, e.g. ARMxTDMI */ };static inline int arm_feature (CPUARMState *env,int feature)
@@ -367,6 +370,7 @@ void cpu_arm_set_cp_io(CPUARMState *env, int cpnum,#define IS_M (env) arm_feature(env, ARM_FEATURE_M)#define ARM_CPUID (env) (env->cp15.c0_cpuid) +#define ARM_CPUID_ARM7TDMI 0x41807000/* guess; no CP15 on ARM7TDMI */ #define ARM_CPUID_ARM1026 0x4106a262#define ARM_CPUID_ARM926 0x41069265#define ARM_CPUID_ARM946 0x41059461
target-arm/helper.c +24 -0
@@ -37,19 +37,28 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id) { env->cp15.c0_cpuid = id;switch (id) { +case ARM_CPUID_ARM7TDMI : +set_feature (env,ARM_FEATURE_ABORT_BU ); +break ;case ARM_CPUID_ARM926 : +set_feature (env,ARM_FEATURE_V5 );set_feature (env,ARM_FEATURE_VFP ); +set_feature (env,ARM_FEATURE_CP15 ); env->vfp.xregs[ARM_VFP_FPSID ] =0x41011090 ; env->cp15.c0_cachetype =0x1dd20d2 ; env->cp15.c1_sys =0x00090078 ;break ;case ARM_CPUID_ARM946 : +set_feature (env,ARM_FEATURE_V5 ); +set_feature (env,ARM_FEATURE_CP15 );set_feature (env,ARM_FEATURE_MPU ); env->cp15.c0_cachetype =0x0f004006 ; env->cp15.c1_sys =0x00000078 ;break ;case ARM_CPUID_ARM1026 : +set_feature (env,ARM_FEATURE_V5 );set_feature (env,ARM_FEATURE_VFP ); +set_feature (env,ARM_FEATURE_CP15 );set_feature (env,ARM_FEATURE_AUXCR ); env->vfp.xregs[ARM_VFP_FPSID ] =0x410110a0 ; env->cp15.c0_cachetype =0x1dd20d2 ;
@@ -57,8 +66,10 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)break ;case ARM_CPUID_ARM1136_R2 :case ARM_CPUID_ARM1136 : +set_feature (env,ARM_FEATURE_V5 );set_feature (env,ARM_FEATURE_V6 );set_feature (env,ARM_FEATURE_VFP ); +set_feature (env,ARM_FEATURE_CP15 );set_feature (env,ARM_FEATURE_AUXCR ); env->vfp.xregs[ARM_VFP_FPSID ] =0x410120b4 ; env->vfp.xregs[ARM_VFP_MVFR0 ] =0x11111111 ;
@@ -68,9 +79,11 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id) env->cp15.c0_cachetype =0x1dd20d2 ;break ;case ARM_CPUID_ARM11MPCORE : +set_feature (env,ARM_FEATURE_V5 );set_feature (env,ARM_FEATURE_V6 );set_feature (env,ARM_FEATURE_V6K );set_feature (env,ARM_FEATURE_VFP ); +set_feature (env,ARM_FEATURE_CP15 );set_feature (env,ARM_FEATURE_AUXCR ); env->vfp.xregs[ARM_VFP_FPSID ] =0x410120b4 ; env->vfp.xregs[ARM_VFP_MVFR0 ] =0x11111111 ;
@@ -80,9 +93,11 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id) env->cp15.c0_cachetype =0x1dd20d2 ;break ;case ARM_CPUID_CORTEXA8 : +set_feature (env,ARM_FEATURE_V5 );set_feature (env,ARM_FEATURE_V6 );set_feature (env,ARM_FEATURE_V6K );set_feature (env,ARM_FEATURE_V7 ); +set_feature (env,ARM_FEATURE_CP15 );set_feature (env,ARM_FEATURE_AUXCR );set_feature (env,ARM_FEATURE_THUMB2 );set_feature (env,ARM_FEATURE_VFP );
@@ -101,6 +116,7 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id) env->cp15.c0_ccsid[2 ] =0xf0000000 ;/* No L2 icache. */ break ;case ARM_CPUID_CORTEXM3 : +set_feature (env,ARM_FEATURE_V5 );set_feature (env,ARM_FEATURE_V6 );set_feature (env,ARM_FEATURE_THUMB2 );set_feature (env,ARM_FEATURE_V7 );
@@ -108,6 +124,7 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)set_feature (env,ARM_FEATURE_DIV );break ;case ARM_CPUID_ANY :/* For userspace emulation. */ +set_feature (env,ARM_FEATURE_V5 );set_feature (env,ARM_FEATURE_V6 );set_feature (env,ARM_FEATURE_V6K );set_feature (env,ARM_FEATURE_V7 );
@@ -120,6 +137,8 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)break ;case ARM_CPUID_TI915T :case ARM_CPUID_TI925T : +set_feature (env,ARM_FEATURE_V5 ); +set_feature (env,ARM_FEATURE_CP15 );set_feature (env,ARM_FEATURE_OMAPCP ); env->cp15.c0_cpuid =ARM_CPUID_TI925T ;/* Depends on wiring. */ env->cp15.c0_cachetype =0x5109149 ;
@@ -132,6 +151,8 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)case ARM_CPUID_PXA260 :case ARM_CPUID_PXA261 :case ARM_CPUID_PXA262 : +set_feature (env,ARM_FEATURE_V5 ); +set_feature (env,ARM_FEATURE_CP15 );set_feature (env,ARM_FEATURE_XSCALE );/* JTAG_ID is ((id << 28) | 0x09265013) */ env->cp15.c0_cachetype =0xd172172 ;
@@ -143,6 +164,8 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)case ARM_CPUID_PXA270_B1 :case ARM_CPUID_PXA270_C0 :case ARM_CPUID_PXA270_C5 : +set_feature (env,ARM_FEATURE_V5 ); +set_feature (env,ARM_FEATURE_CP15 );set_feature (env,ARM_FEATURE_XSCALE );/* JTAG_ID is ((id << 28) | 0x09265013) */ set_feature (env,ARM_FEATURE_IWMMXT );
@@ -277,6 +300,7 @@ struct arm_cpu_t { };static const struct arm_cpu_t arm_cpu_names[] = { + {ARM_CPUID_ARM7TDMI ,"arm7tdmi" }, {ARM_CPUID_ARM926 ,"arm926" }, {ARM_CPUID_ARM946 ,"arm946" }, {ARM_CPUID_ARM1026 ,"arm1026" },
target-arm/translate.c +83 -33
253 lines not on this page · raw message
Signature · 1 line
1.6.3.msysgit.0