From 4c0ce08bc88bca70de481fd0402018b11035ba1d Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 11 Jul 2019 02:51:00 -0700 Subject: [PATCH] Double fault --- src/interrupts.rs | 5 +++++ src/main.rs | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/interrupts.rs b/src/interrupts.rs index 3802522..fa67843 100644 --- a/src/interrupts.rs +++ b/src/interrupts.rs @@ -6,6 +6,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 }; } @@ -18,3 +19,7 @@ extern "x86-interrupt" fn breakpoint_handler(stack_frame: &mut InterruptStackFra println!("EXCEPTION - BREAKPOINT\n{:#?}", stack_frame); } + +extern "x86-interrupt" fn double_fault_handler(stack_frame: &mut InterruptStackFrame, code: u64) { + panic!("EXCEPTION - DOUBLE FAULT (code {})\n{:#?}", code, stack_frame); +} diff --git a/src/main.rs b/src/main.rs index 71dbf8b..5febffc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,15 +22,14 @@ pub fn init() { pub extern "C" fn _start() -> ! { init(); - x86_64::instructions::interrupts::int3(); + //x86_64::instructions::interrupts::int3(); unsafe { - asm!("mov dx, 0; div dx" ::: "ax", "dx" : "volatile", "intel") + *(0xf0f0b8b8 as *mut u64) = 10; } println!("Gamarjoba, munde: {}", 1); println!("Gamarjoba, munde: {}", 2); - panic!("A bad thing happened"); loop {} }