target-microblaze: Misc configurability #2
v2 cover target-microblaze: Misc configurability #2
From: "Edgar E. Iglesias" <[email protected]>
This is another round of conversion from hardcoded regs to cpu properties.
The property names are taken from the device-tree bindings.
Cheers,
Edgar
ChangeLog:
v1 -> v2:
* Populate the pvr2 div-zero-exception bit
Edgar E. Iglesias (6):
target/microblaze: Add the opcode-0x0-illegal CPU property target/microblaze: Add the ill-opcode-exception property target/microblaze: Add the div-zero-exception property target/microblaze: Add the unaligned-exceptions property target/microblaze: Add the pvr-user1 property target/microblaze: Add the pvr-user2 property
target/microblaze/cpu.c | 24 ++++++++++++++++++++++-- target/microblaze/cpu.h | 6 ++++++ target/microblaze/op_helper.c | 5 +++-- target/microblaze/translate.c | 8 ++++---- 4 files changed, 35 insertions(+), 8 deletions(-)
Signature · 1 line
2.20.1
PATCH v2 1/6 target/microblaze: Add the opcode-0x0-illegal CPU property
From: "Edgar E. Iglesias" <[email protected]>
Add the opcode-0x0-illegal CPU property to control if the core should trap opcode zero as illegal.
--- target/microblaze/cpu.c | 6 +++++- target/microblaze/cpu.h | 1 + target/microblaze/translate.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-)
target/microblaze/cpu.c +5 -1
@@ -206,7 +206,9 @@ static void mb_cpu_realizefn(DeviceState *dev, Error **errp) (cpu->cfg.dopb_bus_exception ?PVR2_DOPB_BUS_EXC_MASK :0 ) | (cpu->cfg.iopb_bus_exception ? -PVR2_IOPB_BUS_EXC_MASK :0 ); +PVR2_IOPB_BUS_EXC_MASK :0 ) | + (cpu->cfg.opcode_0_illegal ? + PVR2_OPCODE_0x0_ILL_MASK :0 ); env->pvr.regs[5 ] |= cpu->cfg.dcache_writeback ?PVR5_DCACHE_WRITEBACK_MASK :0 ;
@@ -274,6 +276,8 @@ static Property mb_properties[] = {/* Enables bus exceptions on failed instruction fetches. */ DEFINE_PROP_BOOL ("iopb-bus-exception" , MicroBlazeCPU, cfg.iopb_bus_exception, false), +DEFINE_PROP_BOOL ("opcode-0x0-illegal" , MicroBlazeCPU, + cfg.opcode_0_illegal, false),DEFINE_PROP_STRING ("version" , MicroBlazeCPU, cfg.version),DEFINE_PROP_UINT8 ("pvr" , MicroBlazeCPU, cfg.pvr,C_PVR_FULL ), DEFINE_PROP_END_OF_LIST(),
target/microblaze/cpu.h +1 -0
@@ -303,6 +303,7 @@ struct MicroBlazeCPU {bool endi;bool dopb_bus_exception;bool iopb_bus_exception; +bool opcode_0_illegal;char *version;uint8_t pvr; } cfg;
target/microblaze/translate.c +1 -1
@@ -1573,7 +1573,7 @@ static inline void decode(DisasContext *dc, uint32_t ir)LOG_DIS ("%8.8x\t" , dc->ir);if (ir ==0 ) { -trap_illegal (dc, dc->cpu->env.pvr.regs[2 ] & PVR2_OPCODE_0x0_ILL_MASK); +trap_illegal (dc, dc->cpu->cfg.opcode_0_illegal);/* Don't decode nop/zero instructions any further. */ return ; }
Signature · 1 line
2.20.1
PATCH v2 2/6 target/microblaze: Add the ill-opcode-exception property
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
Add the ill-opcode-exception property to control if illegal instructions will raise exceptions.
--- target/microblaze/cpu.c | 4 ++++ target/microblaze/cpu.h | 1 + target/microblaze/translate.c | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-)
target/microblaze/cpu.c +4 -0
@@ -207,6 +207,8 @@ static void mb_cpu_realizefn(DeviceState *dev, Error **errp) PVR2_DOPB_BUS_EXC_MASK : 0) | (cpu->cfg.iopb_bus_exception ?PVR2_IOPB_BUS_EXC_MASK :0 ) | + (cpu->cfg.illegal_opcode_exception ? +PVR2_ILL_OPCODE_EXC_MASK :0 ) | (cpu->cfg.opcode_0_illegal ? PVR2_OPCODE_0x0_ILL_MASK :0 );
@@ -276,6 +278,8 @@ static Property mb_properties[] = {/* Enables bus exceptions on failed instruction fetches. */ DEFINE_PROP_BOOL ("iopb-bus-exception" , MicroBlazeCPU, cfg.iopb_bus_exception, false), +DEFINE_PROP_BOOL ("ill-opcode-exception" , MicroBlazeCPU, + cfg.illegal_opcode_exception, false),DEFINE_PROP_BOOL ("opcode-0x0-illegal" , MicroBlazeCPU, cfg.opcode_0_illegal, false), DEFINE_PROP_STRING("version", MicroBlazeCPU, cfg.version),
target/microblaze/cpu.h +1 -0
@@ -303,6 +303,7 @@ struct MicroBlazeCPU {bool endi;bool dopb_bus_exception;bool iopb_bus_exception; +bool illegal_opcode_exception;bool opcode_0_illegal;char *version;uint8_t pvr;
target/microblaze/translate.c +1 -1
@@ -185,7 +185,7 @@ static void write_carryi(DisasContext *dc, bool carry)static bool trap_illegal (DisasContext *dc,bool cond) {if (cond && (dc->tb_flags &MSR_EE_FLAG ) - && (dc->cpu->env.pvr.regs[2 ] &PVR2_ILL_OPCODE_EXC_MASK )) { + && dc->cpu->cfg.illegal_opcode_exception) {tcg_gen_movi_i64 (cpu_SR[SR_ESR ],ESR_EC_ILLEGAL_OP );t_gen_raise_exception (dc,EXCP_HW_EXCP ); }
Signature · 1 line
2.20.1
PATCH v2 3/6 target/microblaze: Add the div-zero-exception property
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
Add the div-zero-exception property to control if the core traps divizions by zero.
--- target/microblaze/cpu.c | 4 ++++ target/microblaze/cpu.h | 1 + target/microblaze/op_helper.c | 5 +++-- 3 files changed, 8 insertions(+), 2 deletions(-)
target/microblaze/cpu.c +4 -0
@@ -207,6 +207,8 @@ static void mb_cpu_realizefn(DeviceState *dev, Error **errp) PVR2_DOPB_BUS_EXC_MASK : 0) | (cpu->cfg.iopb_bus_exception ?PVR2_IOPB_BUS_EXC_MASK :0 ) | + (cpu->cfg.div_zero_exception ? +PVR2_DIV_ZERO_EXC_MASK :0 ) | (cpu->cfg.illegal_opcode_exception ? PVR2_ILL_OPCODE_EXC_MASK : 0) | (cpu->cfg.opcode_0_illegal ?
@@ -280,6 +282,8 @@ static Property mb_properties[] = { cfg.iopb_bus_exception, false),DEFINE_PROP_BOOL ("ill-opcode-exception" , MicroBlazeCPU, cfg.illegal_opcode_exception, false), +DEFINE_PROP_BOOL ("div-zero-exception" , MicroBlazeCPU, + cfg.div_zero_exception, false),DEFINE_PROP_BOOL ("opcode-0x0-illegal" , MicroBlazeCPU, cfg.opcode_0_illegal, false), DEFINE_PROP_STRING("version", MicroBlazeCPU, cfg.version),
target/microblaze/cpu.h +1 -0
@@ -305,6 +305,7 @@ struct MicroBlazeCPU {bool iopb_bus_exception;bool illegal_opcode_exception;bool opcode_0_illegal; +bool div_zero_exception;char *version;uint8_t pvr; } cfg;
target/microblaze/op_helper.c +3 -2
@@ -132,11 +132,12 @@ uint32_t helper_carry(uint32_t a, uint32_t b, uint32_t cf)static inline int div_prepare (CPUMBState *env,uint32_t a,uint32_t b) { +MicroBlazeCPU *cpu =env_archcpu (env); +if (b ==0 ) { env->sregs[SR_MSR ] |=MSR_DZ ; -if ((env->sregs[SR_MSR ] &MSR_EE ) - && !(env->pvr.regs[2 ] &PVR2_DIV_ZERO_EXC_MASK )) { +if ((env->sregs[SR_MSR ] &MSR_EE ) && cpu->cfg.div_zero_exception) { env->sregs[SR_ESR ] =ESR_EC_DIVZERO ;helper_raise_exception (env,EXCP_HW_EXCP ); }
Signature · 1 line
2.20.1
Re: [PATCH v2 3/6] target/microblaze: Add the div-zero-exception property
Quoted 7 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Add the div-zero-exception property to control if the core traps divizions by zero.
Signed-off-by Edgar E. Iglesias <[email protected]>
Alistair
Quoted 63 lines
--- target/microblaze/cpu.c | 4 ++++ target/microblaze/cpu.h | 1 + target/microblaze/op_helper.c | 5 +++-- 3 files changed, 8 insertions(+), 2 deletions(-)target/microblaze/cpu.c +4
-0@@ -207,6 +207,8 @@ static void mb_cpu_realizefn(DeviceState *dev, Error **errp) PVR2_DOPB_BUS_EXC_MASK : 0) | (cpu->cfg.iopb_bus_exception ?PVR2_IOPB_BUS_EXC_MASK :0 ) | + (cpu->cfg.div_zero_exception ? +PVR2_DIV_ZERO_EXC_MASK :0 ) | (cpu->cfg.illegal_opcode_exception ? PVR2_ILL_OPCODE_EXC_MASK : 0) | (cpu->cfg.opcode_0_illegal ?@@ -280,6 +282,8 @@ static Property mb_properties[] = { cfg.iopb_bus_exception, false),DEFINE_PROP_BOOL ("ill-opcode-exception" , MicroBlazeCPU, cfg.illegal_opcode_exception, false), +DEFINE_PROP_BOOL ("div-zero-exception" , MicroBlazeCPU, + cfg.div_zero_exception, false),DEFINE_PROP_BOOL ("opcode-0x0-illegal" , MicroBlazeCPU, cfg.opcode_0_illegal, false), DEFINE_PROP_STRING("version", MicroBlazeCPU, cfg.version),target/microblaze/cpu.h +1
-0@@ -305,6 +305,7 @@ struct MicroBlazeCPU {bool iopb_bus_exception;bool illegal_opcode_exception;bool opcode_0_illegal; +bool div_zero_exception;char *version;uint8_t pvr; } cfg;target/microblaze/op_helper.c +3
-3@@ -132,11 +132,12 @@ uint32_t helper_carry(uint32_t a, uint32_t b, uint32_t cf)static inline int div_prepare (CPUMBState *env,uint32_t a,uint32_t b) { +MicroBlazeCPU *cpu =env_archcpu (env); +if (b ==0 ) { env->sregs[SR_MSR ] |=MSR_DZ ; -if ((env->sregs[SR_MSR ] &MSR_EE ) - && !(env->pvr.regs[2 ] &PVR2_DIV_ZERO_EXC_MASK )) { +if ((env->sregs[SR_MSR ] &MSR_EE ) && cpu->cfg.div_zero_exception) { env->sregs[SR_ESR ] =ESR_EC_DIVZERO ;helper_raise_exception (env,EXCP_HW_EXCP ); } --2.20.1
Re: [PATCH v2 3/6] target/microblaze: Add the div-zero-exception property
In reply to Edgar E. IglesiasQuoted 6 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Add the div-zero-exception property to control if the core traps divizions by zero.
Signed-off-by Edgar E. Iglesias <[email protected]>
Quoted 60 lines
--- target/microblaze/cpu.c | 4 ++++ target/microblaze/cpu.h | 1 + target/microblaze/op_helper.c | 5 +++-- 3 files changed, 8 insertions(+), 2 deletions(-)target/microblaze/cpu.c +4
-0@@ -207,6 +207,8 @@ static void mb_cpu_realizefn(DeviceState *dev, Error **errp) PVR2_DOPB_BUS_EXC_MASK : 0) | (cpu->cfg.iopb_bus_exception ?PVR2_IOPB_BUS_EXC_MASK :0 ) | + (cpu->cfg.div_zero_exception ? +PVR2_DIV_ZERO_EXC_MASK :0 ) | (cpu->cfg.illegal_opcode_exception ? PVR2_ILL_OPCODE_EXC_MASK : 0) | (cpu->cfg.opcode_0_illegal ?@@ -280,6 +282,8 @@ static Property mb_properties[] = { cfg.iopb_bus_exception, false),DEFINE_PROP_BOOL ("ill-opcode-exception" , MicroBlazeCPU, cfg.illegal_opcode_exception, false), +DEFINE_PROP_BOOL ("div-zero-exception" , MicroBlazeCPU, + cfg.div_zero_exception, false),DEFINE_PROP_BOOL ("opcode-0x0-illegal" , MicroBlazeCPU, cfg.opcode_0_illegal, false), DEFINE_PROP_STRING("version", MicroBlazeCPU, cfg.version),target/microblaze/cpu.h +1
-0@@ -305,6 +305,7 @@ struct MicroBlazeCPU {bool iopb_bus_exception;bool illegal_opcode_exception;bool opcode_0_illegal; +bool div_zero_exception;char *version;uint8_t pvr; } cfg;target/microblaze/op_helper.c +3
-2@@ -132,11 +132,12 @@ uint32_t helper_carry(uint32_t a, uint32_t b, uint32_t cf)static inline int div_prepare (CPUMBState *env,uint32_t a,uint32_t b) { +MicroBlazeCPU *cpu =env_archcpu (env); +if (b ==0 ) { env->sregs[SR_MSR ] |=MSR_DZ ; -if ((env->sregs[SR_MSR ] &MSR_EE ) - && !(env->pvr.regs[2 ] &PVR2_DIV_ZERO_EXC_MASK )) { +if ((env->sregs[SR_MSR ] &MSR_EE ) && cpu->cfg.div_zero_exception) { env->sregs[SR_ESR ] =ESR_EC_DIVZERO ;helper_raise_exception (env,EXCP_HW_EXCP ); }
PATCH v2 4/6 target/microblaze: Add the unaligned-exceptions property
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
Add the unaligned-exceptions property to control if the core traps unaligned memory accesses.
--- target/microblaze/cpu.c | 4 ++++ target/microblaze/cpu.h | 1 + target/microblaze/translate.c | 4 ++-- 3 files changed, 7 insertions(+), 2 deletions(-)
target/microblaze/cpu.c +4 -0
@@ -211,6 +211,8 @@ static void mb_cpu_realizefn(DeviceState *dev, Error **errp) PVR2_DIV_ZERO_EXC_MASK : 0) | (cpu->cfg.illegal_opcode_exception ?PVR2_ILL_OPCODE_EXC_MASK :0 ) | + (cpu->cfg.unaligned_exceptions ? +PVR2_UNALIGNED_EXC_MASK :0 ) | (cpu->cfg.opcode_0_illegal ? PVR2_OPCODE_0x0_ILL_MASK :0 );
@@ -284,6 +286,8 @@ static Property mb_properties[] = { cfg.illegal_opcode_exception, false),DEFINE_PROP_BOOL ("div-zero-exception" , MicroBlazeCPU, cfg.div_zero_exception, false), +DEFINE_PROP_BOOL ("unaligned-exceptions" , MicroBlazeCPU, + cfg.unaligned_exceptions, false),DEFINE_PROP_BOOL ("opcode-0x0-illegal" , MicroBlazeCPU, cfg.opcode_0_illegal, false), DEFINE_PROP_STRING("version", MicroBlazeCPU, cfg.version),
target/microblaze/cpu.h +1 -0
@@ -306,6 +306,7 @@ struct MicroBlazeCPU {bool illegal_opcode_exception;bool opcode_0_illegal;bool div_zero_exception; +bool unaligned_exceptions;char *version;uint8_t pvr; } cfg;
target/microblaze/translate.c +2 -2
@@ -995,7 +995,7 @@ static void dec_load(DisasContext *dc) v =tcg_temp_new_i32 ();tcg_gen_qemu_ld_i32 (v, addr, mem_index, mop); -if ((dc->cpu->env.pvr.regs[2 ] &PVR2_UNALIGNED_EXC_MASK ) && size >1 ) { +if (dc->cpu->cfg.unaligned_exceptions && size >1 ) {TCGv_i32 t0 =tcg_const_i32 (0 );TCGv_i32 treg =tcg_const_i32 (dc->rd);TCGv_i32 tsize =tcg_const_i32 (size -1 );
@@ -1110,7 +1110,7 @@ static void dec_store(DisasContext *dc)tcg_gen_qemu_st_i32 (cpu_R[dc->rd], addr, mem_index, mop);/* Verify alignment if needed. */ -if ((dc->cpu->env.pvr.regs[2 ] &PVR2_UNALIGNED_EXC_MASK ) && size >1 ) { +if (dc->cpu->cfg.unaligned_exceptions && size >1 ) {TCGv_i32 t1 =tcg_const_i32 (1 );TCGv_i32 treg =tcg_const_i32 (dc->rd);TCGv_i32 tsize =tcg_const_i32 (size -1 );
Signature · 1 line
2.20.1
PATCH v2 5/6 target/microblaze: Add the pvr-user1 property
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
Add the pvr-user1 property to control the user-defined PVR0 User1 field.
--- target/microblaze/cpu.c | 4 +++- target/microblaze/cpu.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-)
target/microblaze/cpu.c +3 -1
@@ -193,7 +193,8 @@ static void mb_cpu_realizefn(DeviceState *dev, Error **errp) (cpu->cfg.use_mmu ?PVR0_USE_MMU_MASK :0 ) | (cpu->cfg.endi ?PVR0_ENDI_MASK :0 ) | (version_code <<PVR0_VERSION_SHIFT ) | - (cpu->cfg.pvr ==C_PVR_FULL ?PVR0_PVR_FULL_MASK :0 ); + (cpu->cfg.pvr ==C_PVR_FULL ?PVR0_PVR_FULL_MASK :0 ) | + cpu->cfg.pvr_user1; env->pvr.regs[2 ] |= (cpu->cfg.use_fpu ?PVR2_USE_FPU_MASK :0 ) | (cpu->cfg.use_fpu > 1 ? PVR2_USE_FPU2_MASK : 0) |
@@ -292,6 +293,7 @@ static Property mb_properties[] = { cfg.opcode_0_illegal, false),DEFINE_PROP_STRING ("version" , MicroBlazeCPU, cfg.version),DEFINE_PROP_UINT8 ("pvr" , MicroBlazeCPU, cfg.pvr,C_PVR_FULL ), +DEFINE_PROP_UINT8 ("pvr-user1" , MicroBlazeCPU, cfg.pvr_user1,0 ), DEFINE_PROP_END_OF_LIST(), };
target/microblaze/cpu.h +1 -0
@@ -307,6 +307,7 @@ struct MicroBlazeCPU {bool opcode_0_illegal;bool div_zero_exception;bool unaligned_exceptions; +uint8_t pvr_user1;char *version;uint8_t pvr; } cfg;
Signature · 1 line
2.20.1
PATCH v2 6/6 target/microblaze: Add the pvr-user2 property
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
Add the pvr-user2 property to control the user-defined PVR1 User2 register.
--- target/microblaze/cpu.c | 2 ++ target/microblaze/cpu.h | 1 + 2 files changed, 3 insertions(+)
target/microblaze/cpu.c +2 -0
@@ -196,6 +196,7 @@ static void mb_cpu_realizefn(DeviceState *dev, Error **errp) (cpu->cfg.pvr ==C_PVR_FULL ?PVR0_PVR_FULL_MASK :0 ) | cpu->cfg.pvr_user1; + env->pvr.regs[1 ] = cpu->cfg.pvr_user2; env->pvr.regs[2 ] |= (cpu->cfg.use_fpu ?PVR2_USE_FPU_MASK :0 ) | (cpu->cfg.use_fpu >1 ?PVR2_USE_FPU2_MASK :0 ) | (cpu->cfg.use_hw_mul ? PVR2_USE_HW_MUL_MASK : 0) |
@@ -294,6 +295,7 @@ static Property mb_properties[] = {DEFINE_PROP_STRING ("version" , MicroBlazeCPU, cfg.version),DEFINE_PROP_UINT8 ("pvr" , MicroBlazeCPU, cfg.pvr,C_PVR_FULL ),DEFINE_PROP_UINT8 ("pvr-user1" , MicroBlazeCPU, cfg.pvr_user1,0 ), +DEFINE_PROP_UINT32 ("pvr-user2" , MicroBlazeCPU, cfg.pvr_user2,0 ), DEFINE_PROP_END_OF_LIST(), };
target/microblaze/cpu.h +1 -0
@@ -308,6 +308,7 @@ struct MicroBlazeCPU {bool div_zero_exception;bool unaligned_exceptions;uint8_t pvr_user1; +uint32_t pvr_user2;char *version;uint8_t pvr; } cfg;
Signature · 1 line
2.20.1