summaryrefslogtreecommitdiff
path: root/kernel/src/interrupts
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/src/interrupts')
-rw-r--r--kernel/src/interrupts/exceptions.rs35
-rw-r--r--kernel/src/interrupts/table.rs4
2 files changed, 38 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 {}
+}
diff --git a/kernel/src/interrupts/table.rs b/kernel/src/interrupts/table.rs
index 47d6ead..6472014 100644
--- a/kernel/src/interrupts/table.rs
+++ b/kernel/src/interrupts/table.rs
@@ -7,6 +7,10 @@ lazy_static! {
let mut idt = InterruptDescriptorTable::new();
idt.breakpoint
.set_handler_fn(super::exceptions::breakpoint_handler);
+ idt.page_fault
+ .set_handler_fn(super::exceptions::page_fault_handler);
+ idt.segment_not_present
+ .set_handler_fn(super::exceptions::segment_not_present_handler);
idt
};
}