From 32bd8cdef93410188681718d20e4570c3e4cf2cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rom=C3=A1n=20C=C3=A1rdenas=20Rodr=C3=ADguez?= Date: Fri, 7 Jun 2024 18:51:52 +0200 Subject: [PATCH] adapt riscv-rt to new approach --- riscv-rt/src/lib.rs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/riscv-rt/src/lib.rs b/riscv-rt/src/lib.rs index 7d6a6d59..97b45f06 100644 --- a/riscv-rt/src/lib.rs +++ b/riscv-rt/src/lib.rs @@ -523,23 +523,21 @@ pub unsafe extern "C" fn start_trap_rust(trap_frame: *const TrapFrame) { fn _dispatch_interrupt(code: usize); } - let cause = xcause::read(); - let code = cause.code(); - - if cause.is_exception() { - let trap_frame = &*trap_frame; - if code < __EXCEPTIONS.len() { - let h = &__EXCEPTIONS[code]; - if let Some(handler) = h { - handler(trap_frame); + match xcause::read().cause() { + xcause::Trap::Interrupt(code) => _dispatch_interrupt(code), + xcause::Trap::Exception(code) => { + let trap_frame = &*trap_frame; + if code < __EXCEPTIONS.len() { + let h = &__EXCEPTIONS[code]; + if let Some(handler) = h { + handler(trap_frame); + } else { + ExceptionHandler(trap_frame); + } } else { ExceptionHandler(trap_frame); } - } else { - ExceptionHandler(trap_frame); } - } else { - _dispatch_interrupt(code); } }