From: Yongbok Kim <yongbok.kim@imgtec.com>
Update BadInstr{P} registers on nanoMIPS
Signed-off-by: Yongbok Kim <yongbok.kim@mips.com>
---
target/mips/helper.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/target/mips/helper.c b/target/mips/helper.c
index e215af9..5299f21 100644
--- a/target/mips/helper.c
+++ b/target/mips/helper.c
@@ -683,7 +683,28 @@ static void set_hflags_for_handler (CPUMIPSState *env)
static inline void set_badinstr_registers(CPUMIPSState *env)
{
if (env->hflags & MIPS_HFLAG_M16) {
- /* TODO: add BadInstr support for microMIPS */
+ uint32_t instr;
+ if (!(env->insn_flags & ISA_NANOMIPS32)) {
+ /* TODO: add BadInstr support for pre-nanoMIPS */
+ return;
+ }
+ if (env->CP0_Config3 & (1 << CP0C3_BI)) {
+ instr = (cpu_lduw_code(env, env->active_tc.PC)) << 16;
+ if ((env->insn_flags & ISA_NANOMIPS32) &&
+ ((instr & 0x10000000) == 0)) {
+ instr |= cpu_lduw_code(env, env->active_tc.PC + 2);
+ }
+ env->CP0_BadInstr = instr;
+ }
+ if ((env->CP0_Config3 & (1 << CP0C3_BP)) &&
+ (env->hflags & MIPS_HFLAG_BMASK)) {
+ if (!(env->hflags & MIPS_HFLAG_B16)) {
+ env->CP0_BadInstrP = cpu_ldl_code(env, env->active_tc.PC - 4);
+ } else {
+ env->CP0_BadInstrP =
+ (cpu_lduw_code(env, env->active_tc.PC - 2)) << 16;
+ }
+ }
return;
}
if (env->CP0_Config3 & (1 << CP0C3_BI)) {
--
1.9.1