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 x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame, PageFaultErrorCode};
|
||||||
use crate::try_println;
|
use crate::try_println;
|
||||||
use core::arch::asm;
|
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)
|
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()
|
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 {
|
unsafe {
|
||||||
IDT.breakpoint.set_handler_fn(breakpoint_handler);
|
IDT.lock().load_unsafe();
|
||||||
IDT.page_fault.set_handler_fn(page_fault_handler);
|
|
||||||
IDT.double_fault.set_handler_fn(double_fault_handler);
|
|
||||||
IDT.load();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user