Skip to content

Commit 32bd8cd

Browse files
committed
adapt riscv-rt to new approach
1 parent 36b29ec commit 32bd8cd

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

riscv-rt/src/lib.rs

+11-13
Original file line numberDiff line numberDiff line change
@@ -523,23 +523,21 @@ pub unsafe extern "C" fn start_trap_rust(trap_frame: *const TrapFrame) {
523523
fn _dispatch_interrupt(code: usize);
524524
}
525525

526-
let cause = xcause::read();
527-
let code = cause.code();
528-
529-
if cause.is_exception() {
530-
let trap_frame = &*trap_frame;
531-
if code < __EXCEPTIONS.len() {
532-
let h = &__EXCEPTIONS[code];
533-
if let Some(handler) = h {
534-
handler(trap_frame);
526+
match xcause::read().cause() {
527+
xcause::Trap::Interrupt(code) => _dispatch_interrupt(code),
528+
xcause::Trap::Exception(code) => {
529+
let trap_frame = &*trap_frame;
530+
if code < __EXCEPTIONS.len() {
531+
let h = &__EXCEPTIONS[code];
532+
if let Some(handler) = h {
533+
handler(trap_frame);
534+
} else {
535+
ExceptionHandler(trap_frame);
536+
}
535537
} else {
536538
ExceptionHandler(trap_frame);
537539
}
538-
} else {
539-
ExceptionHandler(trap_frame);
540540
}
541-
} else {
542-
_dispatch_interrupt(code);
543541
}
544542
}
545543

0 commit comments

Comments
 (0)