mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-25 15:51:41 +01:00
lib: Print mtval in sbi_trap_error()
The mtval CSR is very useful information when debugging hence print it upon trap error in sbi_trap_error(). Signed-off-by: Anup Patel <anup.patel@wdc.com>
This commit is contained in:
@@ -21,13 +21,15 @@
|
|||||||
|
|
||||||
static void __attribute__((noreturn)) sbi_trap_error(const char *msg,
|
static void __attribute__((noreturn)) sbi_trap_error(const char *msg,
|
||||||
int rc, u32 hartid,
|
int rc, u32 hartid,
|
||||||
ulong mcause,
|
ulong mcause, ulong mtval,
|
||||||
struct sbi_trap_regs *regs)
|
struct sbi_trap_regs *regs)
|
||||||
{
|
{
|
||||||
sbi_printf("%s: hart%d: %s (error %d)\n",
|
sbi_printf("%s: hart%d: %s (error %d)\n",
|
||||||
__func__, hartid, msg, rc);
|
__func__, hartid, msg, rc);
|
||||||
sbi_printf("%s: hart%d: mcause=0x%lx mepc=0x%lx mstatus=0x%lx\n",
|
sbi_printf("%s: hart%d: mcause=0x%lx mtval=0x%lx\n",
|
||||||
__func__, hartid, mcause, regs->mepc, regs->mstatus);
|
__func__, hartid, mcause, mtval);
|
||||||
|
sbi_printf("%s: hart%d: mepc=0x%lx mstatus=0x%lx\n",
|
||||||
|
__func__, hartid, regs->mepc, regs->mstatus);
|
||||||
sbi_printf("%s: hart%d: %s=0x%lx %s=0x%lx\n",
|
sbi_printf("%s: hart%d: %s=0x%lx %s=0x%lx\n",
|
||||||
__func__, hartid, "ra", regs->ra, "sp", regs->sp);
|
__func__, hartid, "ra", regs->ra, "sp", regs->sp);
|
||||||
sbi_printf("%s: hart%d: %s=0x%lx %s=0x%lx\n",
|
sbi_printf("%s: hart%d: %s=0x%lx %s=0x%lx\n",
|
||||||
@@ -67,8 +69,8 @@ static void __attribute__((noreturn)) sbi_trap_error(const char *msg,
|
|||||||
void sbi_trap_handler(struct sbi_trap_regs *regs,
|
void sbi_trap_handler(struct sbi_trap_regs *regs,
|
||||||
struct sbi_scratch *scratch)
|
struct sbi_scratch *scratch)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc = SBI_ENOTSUPP;
|
||||||
const char *msg;
|
const char *msg = "trap handler failed";
|
||||||
u32 hartid = sbi_current_hartid();
|
u32 hartid = sbi_current_hartid();
|
||||||
ulong mcause = csr_read(mcause);
|
ulong mcause = csr_read(mcause);
|
||||||
|
|
||||||
@@ -82,15 +84,12 @@ void sbi_trap_handler(struct sbi_trap_regs *regs,
|
|||||||
sbi_ipi_process(scratch, hartid);
|
sbi_ipi_process(scratch, hartid);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sbi_trap_error("unhandled external interrupt",
|
msg = "unhandled external interrupt";
|
||||||
SBI_ENOTSUPP, hartid, mcause, regs);
|
goto trap_error;
|
||||||
break;
|
|
||||||
};
|
};
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = SBI_ENOTSUPP;
|
|
||||||
msg = "trap handler failed";
|
|
||||||
switch (mcause) {
|
switch (mcause) {
|
||||||
case CAUSE_ILLEGAL_INSTRUCTION:
|
case CAUSE_ILLEGAL_INSTRUCTION:
|
||||||
rc = sbi_illegal_insn_handler(hartid, mcause, regs, scratch);
|
rc = sbi_illegal_insn_handler(hartid, mcause, regs, scratch);
|
||||||
@@ -113,7 +112,8 @@ void sbi_trap_handler(struct sbi_trap_regs *regs,
|
|||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
trap_error:
|
||||||
if (rc) {
|
if (rc) {
|
||||||
sbi_trap_error(msg, rc, hartid, mcause, regs);
|
sbi_trap_error(msg, rc, hartid, mcause, csr_read(mtval), regs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user