mod trap;
pub use trap::{GeneralRegs, TrapFrame, UserContext};
use crate::cpu_local_cell;
cpu_local_cell! {
static IS_KERNEL_INTERRUPTED: bool = false;
}
pub unsafe fn init(on_bsp: bool) {
self::trap::init();
}
pub fn is_kernel_interrupted() -> bool {
IS_KERNEL_INTERRUPTED.load()
}
#[no_mangle]
extern "C" fn trap_handler(f: &mut TrapFrame) {
use riscv::register::scause::Trap;
match riscv::register::scause::read().cause() {
Trap::Interrupt(_) => {
IS_KERNEL_INTERRUPTED.store(true);
todo!();
IS_KERNEL_INTERRUPTED.store(false);
}
Trap::Exception(e) => {
let stval = riscv::register::stval::read();
panic!(
"Cannot handle kernel cpu exception: {e:?}. stval: {stval:#x}, trapframe: {f:#x?}.",
);
}
}
}