Begin porting the double faults post

This commit is contained in:
Philipp Oppermann
2018-06-17 23:39:12 +02:00
parent 803eafe632
commit 5499471279
6 changed files with 712 additions and 2 deletions

View File

@@ -21,8 +21,12 @@ pub extern "C" fn _start() -> ! {
init_idt();
// invoke a breakpoint exception
x86_64::instructions::int3();
fn stack_overflow() {
stack_overflow(); // for each recursion, the return address is pushed
}
// trigger a stack overflow
stack_overflow();
println!("It did not crash!");
loop {}
@@ -43,6 +47,7 @@ lazy_static! {
static ref IDT: Idt = {
let mut idt = Idt::new();
idt.breakpoint.set_handler_fn(breakpoint_handler);
idt.double_fault.set_handler_fn(double_fault_handler);
idt
};
}
@@ -54,3 +59,10 @@ 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 {}
}