Begin rewriting entry
This commit is contained in:
parent
20c0841a89
commit
9af10f2a8e
14
src/entry.rs
Normal file
14
src/entry.rs
Normal 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)
|
||||
);
|
||||
}
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
use core::panic::PanicInfo;
|
||||
|
||||
mod entry;
|
||||
mod heap;
|
||||
mod trap;
|
||||
mod uart;
|
||||
|
@ -120,8 +121,8 @@ fn panic(info: &PanicInfo) -> ! {
|
|||
|
||||
#[no_mangle]
|
||||
extern "C" fn abort() -> ! {
|
||||
use core::arch::asm;
|
||||
loop { unsafe { asm!("wfi"); } }
|
||||
// loop wait for interrupt
|
||||
loop { riscv::asm::wfi(); }
|
||||
}
|
||||
|
||||
// TODO unit testing
|
||||
|
|
Loading…
Reference in a new issue