Kernel: Guard the IDT behind a mutex
This commit is contained in:
parent
21c5ef0822
commit
327fa0bd0c
@ -1,8 +1,9 @@
|
||||
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame, PageFaultErrorCode};
|
||||
use crate::try_println;
|
||||
use core::arch::asm;
|
||||
use spin::Mutex;
|
||||
|
||||
static mut IDT: InterruptDescriptorTable = InterruptDescriptorTable::new();
|
||||
static IDT: Mutex<InterruptDescriptorTable> = Mutex::new(InterruptDescriptorTable::new());
|
||||
|
||||
extern "x86-interrupt" fn breakpoint_handler(stack_frame: InterruptStackFrame)
|
||||
{
|
||||
@ -20,11 +21,12 @@ extern "x86-interrupt" fn double_fault_handler(stack_frame: InterruptStackFrame,
|
||||
|
||||
pub fn load()
|
||||
{
|
||||
IDT.lock().breakpoint.set_handler_fn(breakpoint_handler);
|
||||
IDT.lock().page_fault.set_handler_fn(page_fault_handler);
|
||||
IDT.lock().double_fault.set_handler_fn(double_fault_handler);
|
||||
|
||||
unsafe {
|
||||
IDT.breakpoint.set_handler_fn(breakpoint_handler);
|
||||
IDT.page_fault.set_handler_fn(page_fault_handler);
|
||||
IDT.double_fault.set_handler_fn(double_fault_handler);
|
||||
IDT.load();
|
||||
IDT.lock().load_unsafe();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user