Add extra debug messages

This commit is contained in:
Rodrigo Arias 2024-07-12 16:32:55 +02:00
parent 71c81f8dcd
commit c6e2db8c2d
2 changed files with 39 additions and 7 deletions

View File

@ -2204,3 +2204,19 @@ And with the OpenSBI regions (in reverse order):
Domain0 Region02 : 0x0000000080000000-0x000000008003ffff M: (R,X) S/U: () Domain0 Region02 : 0x0000000080000000-0x000000008003ffff M: (R,X) S/U: ()
Let's add some instrumentation in the code that handles the traps in OpenSBI. Let's add some instrumentation in the code that handles the traps in OpenSBI.
Memory regions:
0x8000_0000 to 0x8003_ffff : OpenSBI code
0x8004_0000 to 0x8005_ffff : OpenSBI data
0x8010_0000 to 0x801._.... : FDT
0x8020_0000 to 0x8020_.... : U-Boot (later kernel)
0x8020_1000 to 0x81fa_0b87 : Kernel image
80201000-80cb177f : Kernel code
81400000-819fffff : Kernel rodata
81c00000-81f18747 : Kernel data
81f19000-81fa0b87 : Kernel bss
0x8400_0000 to 0x84.._.... M: (R,W) S/U: () Linux kernel

View File

@ -34,34 +34,50 @@ 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..3c05a5b 100644 index b4f3a17..b60315f 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
@@ -306,15 +306,18 @@ struct sbi_trap_context *sbi_trap_handler(struct sbi_trap_context *tcntx) @@ -283,6 +283,7 @@ static int sbi_trap_aia_irq(void)
*/
struct sbi_trap_context *sbi_trap_handler(struct sbi_trap_context *tcntx)
{
+ sbi_printf("!");
int rc = SBI_ENOTSUPP;
const char *msg = "trap handler failed";
struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();
@@ -295,6 +296,7 @@ struct sbi_trap_context *sbi_trap_handler(struct sbi_trap_context *tcntx)
sbi_trap_set_context(scratch, tcntx);
if (mcause & MCAUSE_IRQ_MASK) {
+ sbi_printf("OpenSBI: local interrupt");
if (sbi_hart_has_extension(sbi_scratch_thishart_ptr(),
SBI_HART_EXT_SMAIA))
rc = sbi_trap_aia_irq();
@@ -306,15 +308,18 @@ 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: illegall instruction\n"); + sbi_printf("OpenSBI: illegal instruction");
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\n"); + sbi_printf("OpenSBI: misaligned load");
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\n"); + sbi_printf("OpenSBI: misaligned store");
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 +347,8 @@ struct sbi_trap_context *sbi_trap_handler(struct sbi_trap_context *tcntx) @@ -344,6 +349,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("OpenSBI: good trap\n"); + sbi_printf("$\n");
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);