@@ -105,6 +105,10 @@ FIELD(CR_STATUS, NMI, 22, 1)
#define CR_CPUID 5
#define CR_CTL6 6
#define CR_EXCEPTION 7
+
+FIELD(CR_EXCEPTION, CAUSE, 2, 5)
+FIELD(CR_EXCEPTION, ECCFTL, 31, 1)
+
#define CR_PTEADDR 8
#define CR_PTEADDR_PTBASE_SHIFT 22
#define CR_PTEADDR_PTBASE_MASK (0x3FF << CR_PTEADDR_PTBASE_SHIFT)
@@ -64,9 +64,6 @@ void nios2_cpu_do_interrupt(CPUState *cs)
env->status |= CR_STATUS_IH;
env->status &= ~(CR_STATUS_PIE | CR_STATUS_U);
- env->exception &= ~(0x1F << 2);
- env->exception |= (cs->exception_index & 0x1F) << 2;
-
env->regs[R_EA] = env->pc + 4;
env->pc = cpu->exception_addr;
break;
@@ -83,9 +80,6 @@ void nios2_cpu_do_interrupt(CPUState *cs)
env->status |= CR_STATUS_EH;
env->status &= ~(CR_STATUS_PIE | CR_STATUS_U);
- env->exception &= ~(0x1F << 2);
- env->exception |= (cs->exception_index & 0x1F) << 2;
-
env->tlbmisc &= ~CR_TLBMISC_DBL;
env->tlbmisc |= CR_TLBMISC_WR;
@@ -98,9 +92,6 @@ void nios2_cpu_do_interrupt(CPUState *cs)
env->status |= CR_STATUS_EH;
env->status &= ~(CR_STATUS_PIE | CR_STATUS_U);
- env->exception &= ~(0x1F << 2);
- env->exception |= (cs->exception_index & 0x1F) << 2;
-
env->tlbmisc |= CR_TLBMISC_DBL;
env->pc = cpu->exception_addr;
@@ -116,9 +107,6 @@ void nios2_cpu_do_interrupt(CPUState *cs)
env->status |= CR_STATUS_EH;
env->status &= ~(CR_STATUS_PIE | CR_STATUS_U);
- env->exception &= ~(0x1F << 2);
- env->exception |= (cs->exception_index & 0x1F) << 2;
-
if ((env->status & CR_STATUS_EH) == 0) {
env->tlbmisc |= CR_TLBMISC_WR;
}
@@ -140,9 +128,6 @@ void nios2_cpu_do_interrupt(CPUState *cs)
env->status |= CR_STATUS_EH;
env->status &= ~(CR_STATUS_PIE | CR_STATUS_U);
- env->exception &= ~(0x1F << 2);
- env->exception |= (cs->exception_index & 0x1F) << 2;
-
env->pc = cpu->exception_addr;
break;
@@ -158,9 +143,6 @@ void nios2_cpu_do_interrupt(CPUState *cs)
env->status |= CR_STATUS_EH;
env->status &= ~(CR_STATUS_PIE | CR_STATUS_U);
- env->exception &= ~(0x1F << 2);
- env->exception |= (cs->exception_index & 0x1F) << 2;
-
env->pc = cpu->exception_addr;
break;
@@ -183,9 +165,6 @@ void nios2_cpu_do_interrupt(CPUState *cs)
env->status |= CR_STATUS_EH;
env->status &= ~(CR_STATUS_PIE | CR_STATUS_U);
- env->exception &= ~(0x1F << 2);
- env->exception |= (cs->exception_index & 0x1F) << 2;
-
env->pc = cpu->exception_addr;
break;
@@ -194,6 +173,9 @@ void nios2_cpu_do_interrupt(CPUState *cs)
cs->exception_index);
break;
}
+
+ env->exception = FIELD_DP32(env->exception, CR_EXCEPTION, CAUSE,
+ cs->exception_index);
}
hwaddr nios2_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
Sink the set of env->exception to the end of nios2_cpu_do_interrupt. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- target/nios2/cpu.h | 4 ++++ target/nios2/helper.c | 24 +++--------------------- 2 files changed, 7 insertions(+), 21 deletions(-)