summaryrefslogtreecommitdiff
path: root/kernel/src/interrupts
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/src/interrupts')
-rw-r--r--kernel/src/interrupts/exceptions.rs7
-rw-r--r--kernel/src/interrupts/mod.rs2
-rw-r--r--kernel/src/interrupts/table.rs16
3 files changed, 25 insertions, 0 deletions
diff --git a/kernel/src/interrupts/exceptions.rs b/kernel/src/interrupts/exceptions.rs
new file mode 100644
index 0000000..5ec7588
--- /dev/null
+++ b/kernel/src/interrupts/exceptions.rs
@@ -0,0 +1,7 @@
+use crate::io::vga_text::OStream;
+use x86_64::structures::idt::InterruptStackFrame;
+
+pub extern "x86-interrupt" fn breakpoint_handler(stack_frame: &mut InterruptStackFrame) {
+ let mut stdout = OStream::new();
+ stdout.print(b"EXCEPTION: BREAKPOINT\n");
+}
diff --git a/kernel/src/interrupts/mod.rs b/kernel/src/interrupts/mod.rs
new file mode 100644
index 0000000..ae21761
--- /dev/null
+++ b/kernel/src/interrupts/mod.rs
@@ -0,0 +1,2 @@
+mod exceptions;
+pub mod table;
diff --git a/kernel/src/interrupts/table.rs b/kernel/src/interrupts/table.rs
new file mode 100644
index 0000000..47d6ead
--- /dev/null
+++ b/kernel/src/interrupts/table.rs
@@ -0,0 +1,16 @@
+use crate::io::vga_text::OStream;
+use lazy_static::lazy_static;
+use x86_64::structures::idt::InterruptDescriptorTable;
+
+lazy_static! {
+ static ref IDT: InterruptDescriptorTable = {
+ let mut idt = InterruptDescriptorTable::new();
+ idt.breakpoint
+ .set_handler_fn(super::exceptions::breakpoint_handler);
+ idt
+ };
+}
+
+pub fn init() {
+ IDT.load()
+}