arm: basic support for ARMv4/ARMv4T emulation
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).
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 | 24 ++++++++++++++++++++++++ target-arm/translate.c | 25 ++++++++++++++++++++++--- 3 files changed, 49 insertions(+), 4 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 +24 -0
@@ -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,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_V4T ); +set_feature (env,ARM_FEATURE_V5 );set_feature (env,ARM_FEATURE_OMAPCP ); env->cp15.c0_cpuid =ARM_CPUID_TI925T ;/* Depends on wiring. */ env->cp15.c0_cachetype =0x5109149 ;
@@ -173,6 +193,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 +206,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 );
target-arm/translate.c +22 -3
@@ -34,6 +34,8 @@#define GEN_HELPER 1#include "helpers.h" +#define ENABLE_ARCH_4T arm_feature(env, ARM_FEATURE_V4T) +#define ENABLE_ARCH_5 arm_feature(env, ARM_FEATURE_V5)#define ENABLE_ARCH_5J 0#define ENABLE_ARCH_6 arm_feature(env, ARM_FEATURE_V6)#define ENABLE_ARCH_6K arm_feature(env, ARM_FEATURE_V6K)
@@ -6129,6 +6131,7 @@ static void disas_arm_insn(CPUState * env, DisasContext *s) } }/* Otherwise PLD; v5TE+ */ +ARCH (5 );return ; } if (((insn & 0x0f70f000) == 0x0450f000) ||
@@ -6255,6 +6258,7 @@ static void disas_arm_insn(CPUState * env, DisasContext *s)/* branch link and change to thumb (blx <offset>) */ int32_t offset; +ARCH (5 ); val = (uint32_t )s->pc; tmp =tcg_temp_new_i32 ();tcg_gen_movi_i32 (tmp, val);
@@ -6268,6 +6272,7 @@ static void disas_arm_insn(CPUState * env, DisasContext *s)gen_bx_im (s, val);return ; }else if ((insn &0x0e000f00 ) ==0x0c000100 ) { +ARCH (5 );if (arm_feature (env,ARM_FEATURE_IWMMXT )) {/* iWMMXt register transfer. */ if (env->cp15.c15_cpar & (1 <<1 ))
@@ -6276,8 +6281,10 @@ static void disas_arm_insn(CPUState * env, DisasContext *s) } }else if ((insn &0x0fe00000 ) ==0x0c400000 ) {/* Coprocessor double register transfer. */ +ARCH (5 ); }else if ((insn &0x0f000010 ) ==0x0e000010 ) {/* Additional coprocessor register transfer. */ +ARCH (5 ); }else if ((insn &0x0ff10020 ) ==0x01000000 ) {uint32_t mask;uint32_t val;
@@ -6376,10 +6383,12 @@ static void disas_arm_insn(CPUState * env, DisasContext *s)case 0x1 :if (op1 ==1 ) {/* branch/exchange thumb (bx). */ + ARCH(4T); tmp =load_reg (s, rm);gen_bx (s, tmp); }else if (op1 ==3 ) {/* clz */ +ARCH (5 ); rd = (insn >>12 ) &0xf ; tmp =load_reg (s, rm);gen_helper_clz (tmp, tmp);
@@ -6402,6 +6411,7 @@ static void disas_arm_insn(CPUState * env, DisasContext *s)if (op1 !=1 ) goto illegal_op; +ARCH (5 );/* branch link/exchange thumb (blx) */ tmp =load_reg (s, rm); tmp2 =tcg_temp_new_i32 ();
@@ -6410,6 +6420,7 @@ static void disas_arm_insn(CPUState * env, DisasContext *s)gen_bx (s, tmp);break ;case 0x5 :/* saturating add/subtract */ +ARCH (5 ); rd = (insn >>12 ) &0xf ; rn = (insn >>16 ) &0xf ; tmp =load_reg (s, rm);
@@ -6431,12 +6442,14 @@ static void disas_arm_insn(CPUState * env, DisasContext *s) goto illegal_op; }/* bkpt */ +ARCH (5 );gen_exception_insn (s,4 ,EXCP_BKPT );break ;case 0x8 :/* signed multiply */ case 0xa :case 0xc :case 0xe : +ARCH (5 ); rs = (insn >>8 ) &0xf ; rn = (insn >>12 ) &0xf ; rd = (insn >>16 ) &0xf ;
@@ -6832,6 +6845,7 @@ static void disas_arm_insn(CPUState * env, DisasContext *s) } load =1 ; }else if (sh &2 ) { +ARCH (5 );/* doubleword */ if (sh &1 ) {/* store */
@@ -7172,10 +7186,11 @@ static void disas_arm_insn(CPUState * env, DisasContext *s) }if (insn & (1 <<20 )) {/* Complete the load. */ -if (rd ==15 ) +if (rd ==15 &&ENABLE_ARCH_4T ) {gen_bx (s, tmp); -else + }else {store_reg (s, rd, tmp); + } }break ;case 0x08 :
@@ -7229,7 +7244,11 @@ static void disas_arm_insn(CPUState * env, DisasContext *s)/* load */ tmp =gen_ld32 (addr,IS_USER (s));if (i ==15 ) { -gen_bx (s, tmp); +if (ENABLE_ARCH_4T ) { +gen_bx (s, tmp); + }else { +store_reg (s, i, tmp); + } }else if (user) { tmp2 =tcg_const_i32 (i);gen_helper_set_user_reg (tmp2, tmp);
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 | 2 + hw/strongarm.c | 1302 +++++++++++++++++++++++++++++++++++++++++++++++++++ hw/strongarm.h | 62 +++ target-arm/cpu.h | 3 + target-arm/helper.c | 9 + 5 files changed, 1378 insertions(+), 0 deletions(-) create mode 100644 hw/strongarm.c create mode 100644 hw/strongarm.h
Makefile.target +2 -0
@@ -328,6 +328,8 @@ 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-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/strongarm.c new file +1302 -0
1,302 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
@@ -215,6 +215,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 ;
@@ -375,6 +380,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" },
@@ -1546,6 +1553,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
[Qemu-devel] Re: [PATCH 2/3] Implement basic part of SA-1110/SA-1100
Quoted 34 lines · Dmitry Eremin-Solenikov
Basic implementation of DEC/Intel SA-1100/SA-1110 chips emulation. Implemented:
- IRQs
- GPIO
- PPC
- RTC
- UARTs (no IrDA/etc.)
- OST reused from pxa25xEverything else is TODO (esp. PM/idle/sleep!) - see the todo in the
hw/strongarm.cV2:
* removed all strongarm variants except latest
* dropped unused casts
* fixed PIC vmstate
* fixed new devices created withversion_id= 1Signed-off-by Dmitry Eremin-Solenikov <[email protected]>--- Makefile.target | 2 + hw/strongarm.c | 1302 +++++++++++++++++++++++++++++++++++++++++++++++++++ hw/strongarm.h | 62 +++ target-arm/cpu.h | 3 + target-arm/helper.c | 9 + 5 files changed, 1378 insertions(+), 0 deletions(-) create mode 100644 hw/strongarm.c create mode 100644 hw/strongarm.hMakefile.target +0
-0
Makefile.target obj-arm-y += framebuffer.o · line 332
Quoted 5 lines
Makefile.target +2
-0@@ -328,6 +328,8 @@ 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-arm-y += collie.o
You add collie.c on next patch. This would break bisect.
Later, Juan.
[Qemu-devel] Re: [PATCH 2/3] Implement basic part of SA-1110/SA-1100
Quoted 31 lines · Juan Quintela
Quoted 30 lines · Dmitry Eremin-Solenikov
Basic implementation of DEC/Intel SA-1100/SA-1110 chips emulation. Implemented:
- IRQs
- GPIO
- PPC
- RTC
- UARTs (no IrDA/etc.)
- OST reused from pxa25xEverything else is TODO (esp. PM/idle/sleep!) - see the todo in the
hw/strongarm.cV2:
* removed all strongarm variants except latest
* dropped unused casts
* fixed PIC vmstate
* fixed new devices created withversion_id= 1Signed-off-by Dmitry Eremin-Solenikov <[email protected]>--- Makefile.target | 2 + hw/strongarm.c | 1302 +++++++++++++++++++++++++++++++++++++++++++++++++++ hw/strongarm.h | 62 +++ target-arm/cpu.h | 3 + target-arm/helper.c | 9 + 5 files changed, 1378 insertions(+), 0 deletions(-) create mode 100644 hw/strongarm.c create mode 100644 hw/strongarm.h
Quoted 12 lines
Makefile.target obj-arm-y += framebuffer.o · line 332
Quoted 10 lines
Makefile.target +2
-0@@ -328,6 +328,8 @@ 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-arm-y += collie.oYou add
collie.con next patch. This would break bisect.
Oops. It seems it sneaked in through some git rebases ...
Signature · 2 lines
With best wishes Dmitry
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).
--- hw/collie.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 70 insertions(+), 0 deletions(-) create mode 100644 hw/collie.c
hw/collie.c new file +70 -0
@@ -0,0 +1,70 @@ +/* +* SA-1110-based Sharp Zaurus SL-5500 platform. +* +* Copyright (C) 2011 Dmitry Eremin-Solenikov +* +* This code is licensed under GNU GPL v2. +*/ +#include "hw.h" +#include "sysbus.h" +#include "boards.h" +#include "devices.h" +#include "strongarm.h" +#include "arm-misc.h" +#include "flash.h" +#include "blockdev.h" + +static struct arm_boot_info collie_binfo = { + .loader_start =SA_SDCS0 , + .ram_size =0x20000000 , +}; + +static void collie_init (ram_addr_t ram_size, +const char *boot_device, +const char *kernel_filename,const char *kernel_cmdline, +const char *initrd_filename,const char *cpu_model) +{ +StrongARMState *s; +DriveInfo *dinfo; +ram_addr_t phys_flash; + +if (!cpu_model) { + cpu_model ="sa1110" ; + } + + s =sa1110_init (collie_binfo.ram_size, cpu_model); + (void ) s; + + phys_flash =qemu_ram_alloc (NULL ,"collie.fl1" ,0x02000000 ); + dinfo =drive_get (IF_PFLASH ,0 ,0 ); +pflash_cfi01_register (SA_CS0 , phys_flash, + dinfo ? dinfo->bdrv :NULL , (64 *1024 ), +512 ,4 ,0x00 ,0x00 ,0x00 ,0x00 ,0 ); + + phys_flash =qemu_ram_alloc (NULL ,"collie.fl2" ,0x02000000 ); + dinfo =drive_get (IF_PFLASH ,0 ,1 ); +pflash_cfi01_register (SA_CS1 , phys_flash, + dinfo ? dinfo->bdrv :NULL , (64 *1024 ), +512 ,4 ,0x00 ,0x00 ,0x00 ,0x00 ,0 ); + +sysbus_create_simple ("scoop" ,0x40800000 ,NULL ); + + collie_binfo.kernel_filename = kernel_filename; + collie_binfo.kernel_cmdline = kernel_cmdline; + collie_binfo.initrd_filename = initrd_filename; + collie_binfo.board_id =0x208 ; +arm_load_kernel (s->env, &collie_binfo); +} + +static QEMUMachine collie_machine = { + .name ="collie" , + .desc ="Collie PDA (SA-1110)" , + .init = collie_init, +}; + +static void collie_machine_init (void ) +{ +qemu_register_machine (&collie_machine); +} + +machine_init (collie_machine_init)
Signature · 1 line
1.7.4.1