Kernel: Guard the IDT behind a mutex

This commit is contained in:
apio 2022-11-01 12:34:15 +01:00
parent 21c5ef0822
commit 327fa0bd0c

View File

@ -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();
}
}