Add a double fault handler and test it

This commit is contained in:
Philipp Oppermann
2019-01-25 13:54:44 +01:00
parent b96636984c
commit 218cb9399e
2 changed files with 13 additions and 2 deletions

View File

@@ -11,6 +11,7 @@ lazy_static! {
static ref IDT: InterruptDescriptorTable = {
let mut idt = InterruptDescriptorTable::new();
idt.breakpoint.set_handler_fn(breakpoint_handler);
idt.double_fault.set_handler_fn(double_fault_handler);
idt
};
}
@@ -22,3 +23,11 @@ pub fn init_idt() {
extern "x86-interrupt" fn breakpoint_handler(stack_frame: &mut ExceptionStackFrame) {
println!("EXCEPTION: BREAKPOINT\n{:#?}", stack_frame);
}
extern "x86-interrupt" fn double_fault_handler(
stack_frame: &mut ExceptionStackFrame,
_error_code: u64,
) {
println!("EXCEPTION: DOUBLE FAULT\n{:#?}", stack_frame);
loop {}
}

View File

@@ -12,8 +12,10 @@ pub extern "C" fn _start() -> ! {
blog_os::interrupts::init_idt();
// invoke a breakpoint exception
x86_64::instructions::int3();
// trigger a page fault
unsafe {
*(0xdeadbeef as *mut u64) = 42;
};
println!("It did not crash!");
loop {}