Begin rewriting entry

This commit is contained in:
gil 2024-05-18 09:26:17 -05:00
parent 20c0841a89
commit 9af10f2a8e
2 changed files with 17 additions and 2 deletions

14
src/entry.rs Normal file
View file

@ -0,0 +1,14 @@
unsafe extern "C" fn _enter() -> ! {
let id = riscv::register::mhartid::read();
crate::entry::write_tp(&id);
}
#[inline]
unsafe fn write_tp(id: &usize) -> ! {
use core::arch::asm;
asm!(
"csrw mhartid, {id}",
id = in(reg) id,
options(noreturn)
);
}

View file

@ -5,6 +5,7 @@
use core::panic::PanicInfo; use core::panic::PanicInfo;
mod entry;
mod heap; mod heap;
mod trap; mod trap;
mod uart; mod uart;
@ -120,8 +121,8 @@ fn panic(info: &PanicInfo) -> ! {
#[no_mangle] #[no_mangle]
extern "C" fn abort() -> ! { extern "C" fn abort() -> ! {
use core::arch::asm; // loop wait for interrupt
loop { unsafe { asm!("wfi"); } } loop { riscv::asm::wfi(); }
} }
// TODO unit testing // TODO unit testing