arm: basic support for ARMv4/ARMv4T emulation
PATCH 3/3 Basic implementation of Sharp Zaurus SL-5500 collie PDA
In reply to Dmitry Eremin-SolenikovAdd very basic implementation of collie PDA emulation. The system lacks LoCoMo and graphics/sound emulation. Linux kernel boots up to mounting rootfs (theoretically it can be provided in pflash images).
--- Makefile.target | 1 + hw/collie.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 0 deletions(-) create mode 100644 hw/collie.c
Makefile.target +1 -0
@@ -329,6 +329,7 @@ obj-arm-y += syborg.o syborg_fb.o syborg_interrupt.o syborg_keyboard.o obj-arm-y += syborg_serial.o syborg_timer.o syborg_pointer.o syborg_rtc.o obj-arm-y += syborg_virtio.o obj-arm-y += strongarm.o +obj-arm-y += collie.o obj-sh4-y = shix.o r2d.o sh7750.o sh7750_regnames.o tc58128.o obj-sh4-y += sh_timer.o sh_serial.o sh_intc.o sh_pci.o sm501.o
hw/collie.c new file +70 -0
70 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH 1/3 arm: basic support for ARMv4/ARMv4T emulation
Currently target-arm/ assumes at least ARMv5 core. Add support for handling also ARMv4/ARMv4T. This changes the following instructions:
BX(v4T and later)
BKPT, BLX, CDP2, CLZ, LDC2, LDRD, MCRR, MCRR2, MRRC, MCRR, MRC2, MRRC, MRRC2, PLD QADD, QDADD, QDSUB, QSUB, STRD, SMLAxy, SMLALxy, SMLAWxy, SMULxy, SMULWxy, STC2 (v5 and later)
All instructions that are "v5TE and later" are also bound to just v5, as that's how it was before.
This patch doesn _not_ include disabling of cp15 access and base-updated data abort model (that will be required to emulate chips based on a ARM7TDMI), because:
* no ARM7TDMI chips are currently emulated (or planned)
* those features aren't strictly necessary for my purposes (SA-1 core emulation).
All v5 models are handled as they are v5T. Internally we still have a check if the model is a v5(T) or v5TE, but as all emulated cores are v5TE, those two cases are simply aliased (for now).
Patch is heavily based on patch by Filip Navara <[email protected]> which in turn is based on work by Ulrich Hecht <[email protected]> and Vincent Sanders <[email protected]>.
--- target-arm/cpu.h | 4 ++- target-arm/helper.c | 28 ++++++++++++++++++++++- target-arm/translate.c | 59 +++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 79 insertions(+), 12 deletions(-)
target-arm/cpu.h +3 -1
@@ -360,7 +360,9 @@ enum arm_features {ARM_FEATURE_M ,/* Microcontroller profile. */ ARM_FEATURE_OMAPCP ,/* OMAP specific CP15 ops handling. */ ARM_FEATURE_THUMB2EE , - ARM_FEATURE_V7MP /* v7 Multiprocessing Extensions */ +ARM_FEATURE_V7MP ,/* v7 Multiprocessing Extensions */ +ARM_FEATURE_V4T , + ARM_FEATURE_V5, };static inline int arm_feature (CPUARMState *env,int feature)
target-arm/helper.c +28 -1
@@ -48,17 +48,23 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id) env->cp15.c0_cpuid = id;switch (id) {case ARM_CPUID_ARM926 : +set_feature (env,ARM_FEATURE_V4T ); +set_feature (env,ARM_FEATURE_V5 );set_feature (env,ARM_FEATURE_VFP ); 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_V4T ); +set_feature (env,ARM_FEATURE_V5 );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_V4T ); +set_feature (env,ARM_FEATURE_V5 );set_feature (env,ARM_FEATURE_VFP );set_feature (env,ARM_FEATURE_AUXCR ); env->vfp.xregs[ARM_VFP_FPSID ] =0x410110a0 ;
@@ -67,6 +73,8 @@ 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_V4T ); +set_feature (env,ARM_FEATURE_V5 );set_feature (env,ARM_FEATURE_V6 );set_feature (env,ARM_FEATURE_VFP );set_feature (env,ARM_FEATURE_AUXCR );
@@ -79,6 +87,8 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id) env->cp15.c1_sys =0x00050078 ;break ;case ARM_CPUID_ARM11MPCORE : +set_feature (env,ARM_FEATURE_V4T ); +set_feature (env,ARM_FEATURE_V5 );set_feature (env,ARM_FEATURE_V6 );set_feature (env,ARM_FEATURE_V6K );set_feature (env,ARM_FEATURE_VFP );
@@ -91,6 +101,8 @@ 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_V4T ); +set_feature (env,ARM_FEATURE_V5 );set_feature (env,ARM_FEATURE_V6 );set_feature (env,ARM_FEATURE_V6K );set_feature (env,ARM_FEATURE_V7 );
@@ -113,6 +125,8 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id) env->cp15.c1_sys =0x00c50078 ;break ;case ARM_CPUID_CORTEXA9 : +set_feature (env,ARM_FEATURE_V4T ); +set_feature (env,ARM_FEATURE_V5 );set_feature (env,ARM_FEATURE_V6 );set_feature (env,ARM_FEATURE_V6K );set_feature (env,ARM_FEATURE_V7 );
@@ -140,6 +154,8 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id) env->cp15.c1_sys =0x00c50078 ;break ;case ARM_CPUID_CORTEXM3 : +set_feature (env,ARM_FEATURE_V4T ); +set_feature (env,ARM_FEATURE_V5 );set_feature (env,ARM_FEATURE_V6 );set_feature (env,ARM_FEATURE_THUMB2 );set_feature (env,ARM_FEATURE_V7 );
@@ -147,6 +163,8 @@ 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_V4T ); +set_feature (env,ARM_FEATURE_V5 );set_feature (env,ARM_FEATURE_V6 );set_feature (env,ARM_FEATURE_V6K );set_feature (env,ARM_FEATURE_V7 );
@@ -161,6 +179,7 @@ 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_V4T );set_feature (env,ARM_FEATURE_OMAPCP ); env->cp15.c0_cpuid =ARM_CPUID_TI925T ;/* Depends on wiring. */ env->cp15.c0_cachetype =0x5109149 ;
@@ -173,6 +192,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_V4T ); +set_feature (env,ARM_FEATURE_V5 );set_feature (env,ARM_FEATURE_XSCALE );/* JTAG_ID is ((id << 28) | 0x09265013) */ env->cp15.c0_cachetype =0xd172172 ;
@@ -184,6 +205,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_V4T ); +set_feature (env,ARM_FEATURE_V5 );set_feature (env,ARM_FEATURE_XSCALE );/* JTAG_ID is ((id << 28) | 0x09265013) */ set_feature (env,ARM_FEATURE_IWMMXT );
@@ -856,7 +879,11 @@ void do_interrupt(CPUARMState *env)/* Switch to the new mode, and to the correct instruction set. */ env->uncached_cpsr = (env->uncached_cpsr & ~CPSR_M ) | new_mode; env->uncached_cpsr |= mask; - env->thumb = (env->cp15.c1_sys & (1 <<30 )) !=0 ; +/* this is a lie, as the was no c1_sys on V4T/V5, but who cares +* and we should just guard the thumb mode on V4 */ +if (arm_feature (env,ARM_FEATURE_V4T )) { + env->thumb = (env->cp15.c1_sys & (1 <<30 )) !=0 ; + } env->regs[14 ] = env->regs[15 ] + offset; env->regs[15 ] = addr; env->interrupt_request |=CPU_INTERRUPT_EXITTB ;
target-arm/translate.c +49 -10
194 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH 2/3 Implement basic part of SA-1110/SA-1100
Basic implementation of DEC/Intel SA-1100/SA-1110 chips emulation. Implemented:
- IRQs
- GPIO
- PPC
- RTC
- UARTs (no IrDA/etc.)
- OST reused from pxa25x
Everything else is TODO (esp. PM/idle/sleep!) - see the todo in the hw/strongarm.c
V2:
* removed all strongarm variants except latest
* dropped unused casts
* fixed PIC vmstate
* fixed new devices created with version_id = 1
--- Makefile.target | 1 + hw/strongarm.c | 1301 +++++++++++++++++++++++++++++++++++++++++++++++++++ hw/strongarm.h | 62 +++ target-arm/cpu.h | 3 + target-arm/helper.c | 9 + 5 files changed, 1376 insertions(+), 0 deletions(-) create mode 100644 hw/strongarm.c create mode 100644 hw/strongarm.h
Makefile.target +1 -0
@@ -328,6 +328,7 @@ obj-arm-y += framebuffer.o obj-arm-y += syborg.o syborg_fb.o syborg_interrupt.o syborg_keyboard.o obj-arm-y += syborg_serial.o syborg_timer.o syborg_pointer.o syborg_rtc.o obj-arm-y += syborg_virtio.o +obj-arm-y += strongarm.o obj-sh4-y = shix.o r2d.o sh7750.o sh7750_regnames.o tc58128.o obj-sh4-y += sh_timer.o sh_serial.o sh_intc.o sh_pci.o sm501.o
hw/strongarm.c new file +1301 -0
1,301 lines not on this page · raw message
hw/strongarm.h new file +62 -0
62 lines not on this page · raw message
target-arm/cpu.h +3 -0
@@ -363,6 +363,7 @@ enum arm_features {ARM_FEATURE_V7MP ,/* v7 Multiprocessing Extensions */ ARM_FEATURE_V4T ,ARM_FEATURE_V5 , + ARM_FEATURE_STRONGARM, };static inline int arm_feature (CPUARMState *env,int feature)
@@ -393,6 +394,8 @@ void cpu_arm_set_cp_io(CPUARMState *env, int cpnum,#define ARM_CPUID_ARM946 0x41059461#define ARM_CPUID_TI915T 0x54029152#define ARM_CPUID_TI925T 0x54029252 +#define ARM_CPUID_SA1100 0x4401A11B +#define ARM_CPUID_SA1110 0x6901B119#define ARM_CPUID_PXA250 0x69052100#define ARM_CPUID_PXA255 0x69052d00#define ARM_CPUID_PXA260 0x69052903
target-arm/helper.c +9 -0
@@ -214,6 +214,11 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id) env->cp15.c0_cachetype =0xd172172 ; env->cp15.c1_sys =0x00000078 ;break ; +case ARM_CPUID_SA1100 : +case ARM_CPUID_SA1110 : +set_feature (env,ARM_FEATURE_STRONGARM ); + env->cp15.c1_sys =0x00000070 ; +break ;default :cpu_abort (env,"Bad CPU ID: %x\n" , id);break ;
@@ -374,6 +379,8 @@ static const struct arm_cpu_t arm_cpu_names[] = { { ARM_CPUID_CORTEXA9, "cortex-a9"}, { ARM_CPUID_TI925T, "ti925t" }, { ARM_CPUID_PXA250, "pxa250" }, + { ARM_CPUID_SA1100, "sa1100" }, + { ARM_CPUID_SA1110, "sa1110" }, { ARM_CPUID_PXA255, "pxa255" }, { ARM_CPUID_PXA260, "pxa260" }, { ARM_CPUID_PXA261, "pxa261" },
@@ -1548,6 +1555,8 @@ void HELPER(set_cp15)(CPUState *env, uint32_t insn, uint32_t val)case 9 :if (arm_feature (env,ARM_FEATURE_OMAPCP ))break ; +if (arm_feature (env,ARM_FEATURE_STRONGARM )) +break ;/* Ignore ReadBuffer access */ switch (crm) {case 0 :/* Cache lockdown. */ switch (op1) {
Signature · 1 line
1.7.4.1
Quoted 11 lines · Dmitry Eremin-Solenikov
target-arm/translate.c +1
-4@@ -7172,10 +7210,7 @@ static void disas_arm_insn(CPUState * env, DisasContext *s) } if (insn & (1 << 20)) { /* Complete the load. */ - if (rd == 15) - gen_bx(s, tmp); - else - store_reg(s, rd, tmp); + store_reg_from_load(env, s, rn, tmp); } break;
Quoted 1 line
case
0x08:
Shouldn't the argument to store_reg_from_load() be 'rd', not 'rn'?
I'm otherwise happy with this patch. Thanks for doing all the changes.
-- PMM
Quoted 17 lines · Peter Maydell
Quoted 12 lines · Dmitry Eremin-Solenikov
target-arm/translate.c +1
-4@@ -7172,10 +7210,7 @@ static void disas_arm_insn(CPUState * env, DisasContext *s) }if (insn & (1 <<20 )) {/* Complete the load. */ -if (rd ==15 ) -gen_bx (s, tmp); -else -store_reg (s, rd, tmp); +store_reg_from_load (env, s, rn, tmp); }break ;Quoted 1 line
case 0x08:Shouldn't the argument to
store_reg_from_load()be 'rd', not 'rn'?
Yeah, it seems so :)
Please commit the fixed patch.
Signature · 2 lines
With best wishes Dmitry
Quoted 19 lines · Dmitry Eremin-Solenikov
Quoted 17 lines · Peter Maydell
Quoted 12 lines · Dmitry Eremin-Solenikov
target-arm/translate.c +1
-4@@ -7172,10 +7210,7 @@ static void disas_arm_insn(CPUState * env, DisasContext *s) }if (insn & (1 <<20 )) {/* Complete the load. */ -if (rd ==15 ) -gen_bx (s, tmp); -else -store_reg (s, rd, tmp); +store_reg_from_load (env, s, rn, tmp); }break ;Quoted 1 line
case 0x08:Shouldn't the argument to
store_reg_from_load()be 'rd', not 'rn'?
Quoted 2 lines
Yeah, it seems so :)
Please commit the fixed patch.
Do I need to send the fixed patchset?
Signature · 2 lines
With best wishes Dmitry
Quoted 5 lines · Dmitry Eremin-Solenikov
Quoted 2 lines · Dmitry Eremin-Solenikov
Yeah, it seems so :)
Please commit the fixed patch.Do I need to send the fixed patchset?
I think that would probably be best.
-- PMM