xous-core/kernel/src/arch/riscv.rs
Sean Cross ebf568dadd baremetal: slowly whittling down the number of errors
Signed-off-by: Sean Cross <sean@xobs.io>
2020-08-09 16:14:34 +08:00

29 lines
571 B
Rust

use riscv::register::{satp, sie, sstatus};
use xous::PID;
pub mod exception;
pub mod irq;
pub mod mem;
pub mod process;
pub mod syscall;
pub use process::Thread;
pub fn current_pid() -> PID {
PID::new(satp::read().asid() as _).unwrap()
}
pub fn init() {
unsafe {
sstatus::set_sie();
sie::set_ssoft();
sie::set_sext();
}
}
/// Put the core to sleep until an interrupt hits. Returns `true`
/// to indicate the kernel should not exit.
pub fn idle() -> bool {
unsafe { riscv::asm::wfi() };
true
}