aboutsummaryrefslogtreecommitdiff
path: root/target/nios2
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2022-04-21 08:17:04 -0700
committerRichard Henderson <richard.henderson@linaro.org>2022-04-26 08:16:41 -0700
commit0e0824a1a94e02e15330261e4151faaa7cbb773d (patch)
tree796d69cbaf2a958e2ac37118f7dc2a0efb4a5108 /target/nios2
parentd8c5521cc4ae34e313455bdb1d3c93e51ad88ee6 (diff)
downloadqemu-0e0824a1a94e02e15330261e4151faaa7cbb773d.zip
qemu-0e0824a1a94e02e15330261e4151faaa7cbb773d.tar.gz
qemu-0e0824a1a94e02e15330261e4151faaa7cbb773d.tar.bz2
target/nios2: Hoist CPU_LOG_INT logging
Performing this early means that we can merge more cases within the non-logging switch statement. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220421151735.31996-34-richard.henderson@linaro.org>
Diffstat (limited to 'target/nios2')
-rw-r--r--target/nios2/helper.c58
1 files changed, 47 insertions, 11 deletions
diff --git a/target/nios2/helper.c b/target/nios2/helper.c
index 63971a8..c57ffd6 100644
--- a/target/nios2/helper.c
+++ b/target/nios2/helper.c
@@ -70,20 +70,64 @@ void nios2_cpu_do_interrupt(CPUState *cs)
Nios2CPU *cpu = NIOS2_CPU(cs);
CPUNios2State *env = &cpu->env;
+ if (qemu_loglevel_mask(CPU_LOG_INT)) {
+ const char *name = NULL;
+
+ switch (cs->exception_index) {
+ case EXCP_IRQ:
+ name = "interrupt";
+ break;
+ case EXCP_TLBD:
+ if (env->ctrl[CR_STATUS] & CR_STATUS_EH) {
+ name = "TLB MISS (double)";
+ } else {
+ name = "TLB MISS (fast)";
+ }
+ break;
+ case EXCP_TLBR:
+ case EXCP_TLBW:
+ case EXCP_TLBX:
+ name = "TLB PERM";
+ break;
+ case EXCP_SUPERA:
+ case EXCP_SUPERD:
+ name = "SUPERVISOR (address)";
+ break;
+ case EXCP_SUPERI:
+ name = "SUPERVISOR (insn)";
+ break;
+ case EXCP_ILLEGAL:
+ name = "ILLEGAL insn";
+ break;
+ case EXCP_TRAP:
+ name = "TRAP insn";
+ break;
+ case EXCP_BREAK:
+ name = "BREAK insn";
+ break;
+ case EXCP_SEMIHOST:
+ name = "SEMIHOST insn";
+ break;
+ }
+ if (name) {
+ qemu_log("%s at pc=0x%08x\n", name, env->pc);
+ } else {
+ qemu_log("Unknown exception %d at pc=0x%08x\n",
+ cs->exception_index, env->pc);
+ }
+ }
+
switch (cs->exception_index) {
case EXCP_IRQ:
- qemu_log_mask(CPU_LOG_INT, "interrupt at pc=%x\n", env->pc);
do_iic_irq(cpu);
break;
case EXCP_TLBD:
if ((env->ctrl[CR_STATUS] & CR_STATUS_EH) == 0) {
- qemu_log_mask(CPU_LOG_INT, "TLB MISS (fast) at pc=%x\n", env->pc);
env->ctrl[CR_TLBMISC] &= ~CR_TLBMISC_DBL;
env->ctrl[CR_TLBMISC] |= CR_TLBMISC_WE;
do_exception(cpu, cpu->fast_tlb_miss_addr, false);
} else {
- qemu_log_mask(CPU_LOG_INT, "TLB MISS (double) at pc=%x\n", env->pc);
env->ctrl[CR_TLBMISC] |= CR_TLBMISC_DBL;
do_exception(cpu, cpu->exception_addr, false);
}
@@ -92,7 +136,6 @@ void nios2_cpu_do_interrupt(CPUState *cs)
case EXCP_TLBR:
case EXCP_TLBW:
case EXCP_TLBX:
- qemu_log_mask(CPU_LOG_INT, "TLB PERM at pc=%x\n", env->pc);
if ((env->ctrl[CR_STATUS] & CR_STATUS_EH) == 0) {
env->ctrl[CR_TLBMISC] |= CR_TLBMISC_WE;
}
@@ -102,23 +145,16 @@ void nios2_cpu_do_interrupt(CPUState *cs)
case EXCP_SUPERA:
case EXCP_SUPERI:
case EXCP_SUPERD:
- qemu_log_mask(CPU_LOG_INT, "SUPERVISOR exception at pc=%x\n", env->pc);
- do_exception(cpu, cpu->exception_addr, false);
- break;
-
case EXCP_ILLEGAL:
case EXCP_TRAP:
- qemu_log_mask(CPU_LOG_INT, "TRAP exception at pc=%x\n", env->pc);
do_exception(cpu, cpu->exception_addr, false);
break;
case EXCP_BREAK:
- qemu_log_mask(CPU_LOG_INT, "BREAK exception at pc=%x\n", env->pc);
do_exception(cpu, cpu->exception_addr, true);
break;
case EXCP_SEMIHOST:
- qemu_log_mask(CPU_LOG_INT, "BREAK semihosting at pc=%x\n", env->pc);
env->pc += 4;
do_nios2_semihosting(env);
break;