[U-Boot] [PATCH 18/19] riscv: Refactor handle_trap() a little for future extension
Auer, Lukas
lukas.auer at aisec.fraunhofer.de
Wed Nov 14 23:01:16 UTC 2018
Hi Bin,
On Tue, 2018-11-13 at 00:22 -0800, Bin Meng wrote:
> Use a variable 'code' to store the exception code to simplify the
> codes in handle_trap().
>
> Signed-off-by: Bin Meng <bmeng.cn at gmail.com>
> ---
>
> arch/riscv/lib/interrupts.c | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
Reviewed-by: Lukas Auer <lukas.auer at aisec.fraunhofer.de>
> diff --git a/arch/riscv/lib/interrupts.c
> b/arch/riscv/lib/interrupts.c
> index 5e09196..0c13588 100644
> --- a/arch/riscv/lib/interrupts.c
> +++ b/arch/riscv/lib/interrupts.c
> @@ -66,14 +66,18 @@ int disable_interrupts(void)
> ulong handle_trap(ulong mcause, ulong epc, struct pt_regs *regs)
> {
> ulong is_int;
> + ulong code;
>
> is_int = (mcause & MCAUSE_INT);
> - if ((is_int) && ((mcause & MCAUSE_CAUSE) == IRQ_M_EXT))
> - external_interrupt(0); /* handle_m_ext_interrupt */
> - else if ((is_int) && ((mcause & MCAUSE_CAUSE) == IRQ_M_TIMER))
> - timer_interrupt(0); /* handle_m_timer_interrupt
> */
> - else
> - _exit_trap(mcause & MCAUSE_CAUSE, epc, regs);
> + code = mcause & MCAUSE_CAUSE;
> + if (is_int) {
> + if (code == IRQ_M_EXT)
> + external_interrupt(0); /*
> handle_m_ext_interrupt */
> + else if (code == IRQ_M_TIMER)
> + timer_interrupt(0); /*
> handle_m_timer_interrupt */
> + } else {
> + _exit_trap(code, epc, regs);\
This should use mcause instead of code (see my comments on your
previous patch).
Thanks,
Lukas
> + }
>
> return epc;
> }
More information about the U-Boot
mailing list