diff --git a/src/internals/errors.rs b/src/internals/errors.rs index 6c705fc..fc84314 100644 --- a/src/internals/errors.rs +++ b/src/internals/errors.rs @@ -1,8 +1,10 @@ use core::borrow::{BorrowMut}; +use x86_64::registers::control::Cr2; +use x86_64::structures::idt::PageFaultErrorCode; -use crate::{InterruptStackFrame, font, println}; +use crate::{InterruptStackFrame, font, println, print}; use crate::internals::WhyDoTheyCallItOvenWhenYouOfInTheColdFoodOfOutHotEatTheFood::{COMMUNIST_RED, CUM_WHITE, Colour}; use crate::serial::terminal::ST; @@ -10,5 +12,20 @@ pub extern "x86-interrupt" fn breakpoint_exception(stack_frame: InterruptStackFr println!("---KERNEL WARNING UWU---"); println!("breakpoint exception"); println!("stack frame: {:#?}", stack_frame); +} + +pub extern "x86-interrupt" fn double_fault(stack_frame: InterruptStackFrame, _error_code: u64) -> ! { + println!("---KERNEL FUCKY WUKKY UWU---"); + println!("double fault!"); + println!("stack frame: {:#?}", stack_frame); + loop {} +} + +pub extern "x86-interrupt" fn page_fault(stack_frame: InterruptStackFrame, error_code: PageFaultErrorCode) -> ! { + println!("---KERNEL FUCKY WUKKY UWU---"); + println!("page fault!"); + println!("accessed address: {:?}", Cr2::read()); + println!("error code: {:?}", error_code); + println!("stack frame: {:#?}", stack_frame); loop {} } \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 521d690..9b5c351 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -37,6 +37,8 @@ lazy_static! { static ref IDT: InterruptDescriptorTable = { let mut idt = InterruptDescriptorTable::new(); idt.breakpoint.set_handler_fn(internals::errors::breakpoint_exception); + idt.double_fault.set_handler_fn(internals::errors::double_fault); + idt.page_fault.set_handler_fn(internals::errors::page_fault); idt }; }