From be4bc6e2706255c394e33cb8c6e1ca7372a70572 Mon Sep 17 00:00:00 2001 From: gil Date: Thu, 16 May 2024 10:39:53 -0500 Subject: [PATCH] Add to-do and set interrupt CSRs --- src/main.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main.rs b/src/main.rs index 4135497..a298937 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,6 +12,7 @@ mod uart; #[no_mangle] #[link_section = ".text.init"] unsafe extern "C" fn _enter() -> ! { + // TODO see if possible to replace this somehow... use core::arch::asm; asm!( // load hartid into t0; if t0 =/= 0, then jump to busy loop @@ -42,6 +43,11 @@ unsafe extern "C" fn _enter() -> ! { "bne t0, t1, 1b", "2:", // BSS is clear! + + // delegate all traps to S-mode trap handler + "li t5, 0xffff", + "csrw medeleg, t5", // delegate all machine exceptions + "csrw mideleg, t5", // delegate all machine interrupts "j 4f", // busy loop if hartid =/= 0