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;
|
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
|
||||||
|
|
Loading…
Reference in a new issue