Interrupts: Handle double fault

This commit is contained in:
Greg Shuflin 2022-04-04 00:24:20 -07:00
parent 79efbdc5a0
commit 084945688b
2 changed files with 12 additions and 0 deletions

View File

@ -5,6 +5,7 @@ lazy_static! {
static ref IDT: InterruptDescriptorTable = { static ref IDT: InterruptDescriptorTable = {
let mut idt = InterruptDescriptorTable::new(); let mut idt = InterruptDescriptorTable::new();
idt.breakpoint.set_handler_fn(breakpoint_handler); idt.breakpoint.set_handler_fn(breakpoint_handler);
idt.double_fault.set_handler_fn(double_fault_handler);
idt idt
}; };
} }
@ -15,3 +16,11 @@ pub fn init_idt() {
extern "x86-interrupt" fn breakpoint_handler(stack_frame: InterruptStackFrame) { extern "x86-interrupt" fn breakpoint_handler(stack_frame: InterruptStackFrame) {
println!("EXCEPTION: Breakpoint\n{:#?}", stack_frame); println!("EXCEPTION: Breakpoint\n{:#?}", stack_frame);
} }
// The error code of the double-fault handler is always 0
extern "x86-interrupt" fn double_fault_handler(
stack_frame: InterruptStackFrame,
_error_code: u64,
) -> ! {
panic!("Exception: Double fault\n{:#?}", stack_frame)
}

View File

@ -31,6 +31,9 @@ pub extern "C" fn _start() -> ! {
x86_64::instructions::interrupts::int3(); x86_64::instructions::interrupts::int3();
println!("We're here now"); println!("We're here now");
unsafe {
*(0xff00ff00 as *mut u64) = 44;
}
loop {} loop {}
} }