diff options
author | Anup Patel <anup.patel@wdc.com> | 2020-03-20 08:53:35 +0530 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2020-03-28 13:32:23 +0530 |
commit | 40b221baffd6bb348b63367784d4f6fcff53c24a (patch) | |
tree | 91e926f1b96ebfb59f34c080ba47beb69a91cb04 /lib/sbi/sbi_trap.c | |
parent | 7487116b41e6c06d3903b600a2231d2a68d0c4a4 (diff) |
lib: sbi_trap: Simplify sbi_trap_handler() API
This patch simplify sbi_trap_handler() API as follows:
1. Remove current hartid local variable because sbi_trap_handler()
itself does not need it.
2. Remove scratch parameter because none of the functions directly
called by sbi_trap_handler() require it.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'lib/sbi/sbi_trap.c')
-rw-r--r-- | lib/sbi/sbi_trap.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/lib/sbi/sbi_trap.c b/lib/sbi/sbi_trap.c index 7f8f30f..32fa699 100644 --- a/lib/sbi/sbi_trap.c +++ b/lib/sbi/sbi_trap.c @@ -16,13 +16,16 @@ #include <sbi/sbi_illegal_insn.h> #include <sbi/sbi_ipi.h> #include <sbi/sbi_misaligned_ldst.h> +#include <sbi/sbi_scratch.h> #include <sbi/sbi_timer.h> #include <sbi/sbi_trap.h> -static void __noreturn sbi_trap_error(const char *msg, int rc, u32 hartid, +static void __noreturn sbi_trap_error(const char *msg, int rc, ulong mcause, ulong mtval, ulong mtval2, ulong mtinst, struct sbi_trap_regs *regs) { + u32 hartid = current_hartid(); + sbi_printf("%s: hart%d: %s (error %d)\n", __func__, hartid, msg, rc); sbi_printf("%s: hart%d: mcause=0x%" PRILX " mtval=0x%" PRILX "\n", __func__, hartid, mcause, mtval); @@ -208,14 +211,11 @@ int sbi_trap_redirect(struct sbi_trap_regs *regs, * 7. Interrupts are disabled in MSTATUS CSR * * @param regs pointer to register state - * @param scratch pointer to sbi_scratch of current HART */ -void sbi_trap_handler(struct sbi_trap_regs *regs, - struct sbi_scratch *scratch) +void sbi_trap_handler(struct sbi_trap_regs *regs) { int rc = SBI_ENOTSUPP; const char *msg = "trap handler failed"; - u32 hartid = current_hartid(); ulong mcause = csr_read(CSR_MCAUSE); ulong mtval = csr_read(CSR_MTVAL), mtval2 = 0, mtinst = 0; struct sbi_trap_info trap; @@ -229,10 +229,10 @@ void sbi_trap_handler(struct sbi_trap_regs *regs, mcause &= ~(1UL << (__riscv_xlen - 1)); switch (mcause) { case IRQ_M_TIMER: - sbi_timer_process(scratch); + sbi_timer_process(sbi_scratch_thishart_ptr()); break; case IRQ_M_SOFT: - sbi_ipi_process(scratch); + sbi_ipi_process(sbi_scratch_thishart_ptr()); break; default: msg = "unhandled external interrupt"; @@ -271,8 +271,6 @@ void sbi_trap_handler(struct sbi_trap_regs *regs, }; trap_error: - if (rc) { - sbi_trap_error(msg, rc, hartid, mcause, mtval, - mtval2, mtinst, regs); - } + if (rc) + sbi_trap_error(msg, rc, mcause, mtval, mtval2, mtinst, regs); } |