2020-03-11 09:49:03 +00:00
|
|
|
use riscv::register::{satp, sie, sstatus};
|
2020-08-17 10:37:40 +00:00
|
|
|
use xous_kernel::PID;
|
2020-03-10 04:04:17 +00:00
|
|
|
|
|
|
|
|
pub mod exception;
|
|
|
|
|
pub mod irq;
|
|
|
|
|
pub mod mem;
|
2020-03-16 10:22:59 +00:00
|
|
|
pub mod process;
|
2020-12-04 12:55:09 +00:00
|
|
|
pub mod rand;
|
2020-03-10 04:04:17 +00:00
|
|
|
pub mod syscall;
|
|
|
|
|
|
2020-08-09 08:14:34 +00:00
|
|
|
pub use process::Thread;
|
2020-03-10 04:04:17 +00:00
|
|
|
|
|
|
|
|
pub fn current_pid() -> PID {
|
2020-08-07 10:57:55 +00:00
|
|
|
PID::new(satp::read().asid() as _).unwrap()
|
2020-03-10 04:04:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn init() {
|
|
|
|
|
unsafe {
|
|
|
|
|
sstatus::set_sie();
|
|
|
|
|
sie::set_ssoft();
|
|
|
|
|
sie::set_sext();
|
|
|
|
|
}
|
2020-12-14 09:57:29 +00:00
|
|
|
rand::init();
|
2020-03-10 04:04:17 +00:00
|
|
|
}
|
|
|
|
|
|
2020-08-07 10:57:55 +00:00
|
|
|
/// Put the core to sleep until an interrupt hits. Returns `true`
|
|
|
|
|
/// to indicate the kernel should not exit.
|
|
|
|
|
pub fn idle() -> bool {
|
2020-03-11 09:49:03 +00:00
|
|
|
unsafe { riscv::asm::wfi() };
|
2020-08-07 10:57:55 +00:00
|
|
|
true
|
2020-03-11 09:49:03 +00:00
|
|
|
}
|