mirror of
https://github.com/panpaul/tiny_os
synced 2024-09-20 09:45:19 +08:00
chore: kernel/riscv/trap: panic when trap in kernel mode
This commit is contained in:
parent
753515700f
commit
917629f16e
@ -18,8 +18,7 @@ extern "C" {
|
|||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
extern "C" fn kernel_trap_handler(tf: &mut TrapContext) {
|
extern "C" fn kernel_trap_handler(tf: &mut TrapContext) {
|
||||||
// No trap in kernel, except from IDLE thread
|
// No trap in kernel
|
||||||
// TODO: Replace CONSOLE Mutex to ReentrantLock
|
|
||||||
unsafe { CONSOLE.force_unlock() }
|
unsafe { CONSOLE.force_unlock() }
|
||||||
tf.handle_trap(true);
|
tf.handle_trap(true);
|
||||||
}
|
}
|
||||||
@ -76,6 +75,10 @@ impl TrapContextOps for TrapContext {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if from_kernel {
|
||||||
|
panic_fatal!("Buggy kernel: trap in kernel mode");
|
||||||
|
}
|
||||||
|
|
||||||
let tcb = self.as_object_mut();
|
let tcb = self.as_object_mut();
|
||||||
|
|
||||||
match scause.cause() {
|
match scause.cause() {
|
||||||
|
Loading…
Reference in New Issue
Block a user