diff options
Diffstat (limited to 'kernel/src/interrupts/exceptions.rs')
-rw-r--r-- | kernel/src/interrupts/exceptions.rs | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/kernel/src/interrupts/exceptions.rs b/kernel/src/interrupts/exceptions.rs index 5ec7588..08555c4 100644 --- a/kernel/src/interrupts/exceptions.rs +++ b/kernel/src/interrupts/exceptions.rs @@ -1,7 +1,40 @@ use crate::io::vga_text::OStream; -use x86_64::structures::idt::InterruptStackFrame; +use x86_64::structures::idt::{InterruptStackFrame, PageFaultErrorCode}; pub extern "x86-interrupt" fn breakpoint_handler(stack_frame: &mut InterruptStackFrame) { let mut stdout = OStream::new(); stdout.print(b"EXCEPTION: BREAKPOINT\n"); } + +pub extern "x86-interrupt" fn page_fault_handler( + stack_frame: &mut InterruptStackFrame, + error_code: PageFaultErrorCode, +) { + use x86_64::registers::control::Cr2; + + let mut stdout = OStream::new(); + stdout.print(b"EXCEPTION: PAGEFAULT\n"); + loop {} + panic!("PAGE FAULT"); + //println!("Accessed Address: {:?}", Cr2::read()); + //println!("Error Code: {:?}", error_code); + //println!("{:#?}", stack_frame); +} + +pub extern "x86-interrupt" fn segment_not_present_handler( + stack_frame: &mut InterruptStackFrame, + error_code: u64, +) { + loop {} + let mut stdout = OStream::new(); + stdout.print(b"EXCEPTION: SEGMENT NOT PRESENT\n"); +} + +extern "x86-interrupt" fn double_fault_handler( + stack_frame: &mut InterruptStackFrame, + _error_code: u64, +) { + let mut stdout = OStream::new(); + stdout.print(b"EXCEPTION: DOUBLE FAULT"); + loop {} +} |