Reduce OpenSBI trap debug message

This commit is contained in:
Rodrigo Arias 2024-07-12 17:45:57 +02:00
parent 7d9f375e4a
commit 384069130b

View File

@ -34,14 +34,14 @@ index 7b618de..65e42b0 100644
void sbi_timer_exit(struct sbi_scratch *scratch) void sbi_timer_exit(struct sbi_scratch *scratch)
diff --git a/lib/sbi/sbi_trap.c b/lib/sbi/sbi_trap.c diff --git a/lib/sbi/sbi_trap.c b/lib/sbi/sbi_trap.c
index b4f3a17..742eea6 100644 index b4f3a17..cde2073 100644
--- a/lib/sbi/sbi_trap.c --- a/lib/sbi/sbi_trap.c
+++ b/lib/sbi/sbi_trap.c +++ b/lib/sbi/sbi_trap.c
@@ -283,6 +283,7 @@ static int sbi_trap_aia_irq(void) @@ -283,6 +283,7 @@ static int sbi_trap_aia_irq(void)
*/ */
struct sbi_trap_context *sbi_trap_handler(struct sbi_trap_context *tcntx) struct sbi_trap_context *sbi_trap_handler(struct sbi_trap_context *tcntx)
{ {
+ sbi_printf("!"); + sbi_printf("<");
int rc = SBI_ENOTSUPP; int rc = SBI_ENOTSUPP;
const char *msg = "trap handler failed"; const char *msg = "trap handler failed";
struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();
@ -49,35 +49,59 @@ index b4f3a17..742eea6 100644
sbi_trap_set_context(scratch, tcntx); sbi_trap_set_context(scratch, tcntx);
if (mcause & MCAUSE_IRQ_MASK) { if (mcause & MCAUSE_IRQ_MASK) {
+ sbi_printf("OpenSBI: local interrupt"); + sbi_printf("i");
if (sbi_hart_has_extension(sbi_scratch_thishart_ptr(), if (sbi_hart_has_extension(sbi_scratch_thishart_ptr(),
SBI_HART_EXT_SMAIA)) SBI_HART_EXT_SMAIA))
rc = sbi_trap_aia_irq(); rc = sbi_trap_aia_irq();
@@ -306,15 +308,18 @@ struct sbi_trap_context *sbi_trap_handler(struct sbi_trap_context *tcntx) @@ -306,35 +308,42 @@ struct sbi_trap_context *sbi_trap_handler(struct sbi_trap_context *tcntx)
switch (mcause) { switch (mcause) {
case CAUSE_ILLEGAL_INSTRUCTION: case CAUSE_ILLEGAL_INSTRUCTION:
+ sbi_printf("OpenSBI: illegal instruction"); + sbi_printf("I");
rc = sbi_illegal_insn_handler(tcntx); rc = sbi_illegal_insn_handler(tcntx);
msg = "illegal instruction handler failed"; msg = "illegal instruction handler failed";
break; break;
case CAUSE_MISALIGNED_LOAD: case CAUSE_MISALIGNED_LOAD:
+ sbi_printf("OpenSBI: misaligned load"); + sbi_printf("L");
sbi_pmu_ctr_incr_fw(SBI_PMU_FW_MISALIGNED_LOAD); sbi_pmu_ctr_incr_fw(SBI_PMU_FW_MISALIGNED_LOAD);
rc = sbi_misaligned_load_handler(tcntx); rc = sbi_misaligned_load_handler(tcntx);
msg = "misaligned load handler failed"; msg = "misaligned load handler failed";
break; break;
case CAUSE_MISALIGNED_STORE: case CAUSE_MISALIGNED_STORE:
+ sbi_printf("OpenSBI: misaligned store"); + sbi_printf("S");
sbi_pmu_ctr_incr_fw(SBI_PMU_FW_MISALIGNED_STORE); sbi_pmu_ctr_incr_fw(SBI_PMU_FW_MISALIGNED_STORE);
rc = sbi_misaligned_store_handler(tcntx); rc = sbi_misaligned_store_handler(tcntx);
msg = "misaligned store handler failed"; msg = "misaligned store handler failed";
@@ -344,6 +349,8 @@ struct sbi_trap_context *sbi_trap_handler(struct sbi_trap_context *tcntx) break;
case CAUSE_SUPERVISOR_ECALL:
case CAUSE_MACHINE_ECALL:
+ sbi_printf("E");
rc = sbi_ecall_handler(tcntx);
msg = "ecall handler failed";
break;
case CAUSE_LOAD_ACCESS:
+ sbi_printf("l");
sbi_pmu_ctr_incr_fw(SBI_PMU_FW_ACCESS_LOAD);
rc = sbi_load_access_handler(tcntx);
msg = "load fault handler failed";
break;
case CAUSE_STORE_ACCESS:
+ sbi_printf("s");
sbi_pmu_ctr_incr_fw(SBI_PMU_FW_ACCESS_STORE);
rc = sbi_store_access_handler(tcntx);
msg = "store fault handler failed";
break;
default:
+ sbi_printf("R");
/* If the trap came from S or U mode, redirect it there */
msg = "trap redirect failed";
rc = sbi_trap_redirect(regs, trap);
@@ -344,6 +353,8 @@ struct sbi_trap_context *sbi_trap_handler(struct sbi_trap_context *tcntx)
trap_done: trap_done:
if (rc) if (rc)
sbi_trap_error(msg, rc, tcntx); sbi_trap_error(msg, rc, tcntx);
+ else + else
+ sbi_printf("$"); + sbi_printf(">");
if (((regs->mstatus & MSTATUS_MPP) >> MSTATUS_MPP_SHIFT) != PRV_M) if (((regs->mstatus & MSTATUS_MPP) >> MSTATUS_MPP_SHIFT) != PRV_M)
sbi_sse_process_pending_events(regs); sbi_sse_process_pending_events(regs);