mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Add a double fault handler and test it
This commit is contained in:
@@ -11,6 +11,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
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -22,3 +23,11 @@ pub fn init_idt() {
|
|||||||
extern "x86-interrupt" fn breakpoint_handler(stack_frame: &mut ExceptionStackFrame) {
|
extern "x86-interrupt" fn breakpoint_handler(stack_frame: &mut ExceptionStackFrame) {
|
||||||
println!("EXCEPTION: BREAKPOINT\n{:#?}", stack_frame);
|
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 {}
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,8 +12,10 @@ pub extern "C" fn _start() -> ! {
|
|||||||
|
|
||||||
blog_os::interrupts::init_idt();
|
blog_os::interrupts::init_idt();
|
||||||
|
|
||||||
// invoke a breakpoint exception
|
// trigger a page fault
|
||||||
x86_64::instructions::int3();
|
unsafe {
|
||||||
|
*(0xdeadbeef as *mut u64) = 42;
|
||||||
|
};
|
||||||
|
|
||||||
println!("It did not crash!");
|
println!("It did not crash!");
|
||||||
loop {}
|
loop {}
|
||||||
|
|||||||
Reference in New Issue
Block a user