xous-core/kernel/src/arch/riscv.rs
Sean Cross bb17038bfe kernel: rename "xous" to "xous-kernel" in import
Cargo appears to cache packages in the workspace when multiple packages
use the same crate. Unfortunately, Xous uses different features
depending on whether it's running in the kernel or in userspace.

Pull the kernel version of "xous" in under a different namespace in
order to force it to use a different build.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-08-17 18:37:40 +08:00

29 lines
578 B
Rust

use riscv::register::{satp, sie, sstatus};
use xous_kernel::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
}