CPU Exception

This commit is contained in:
2022-01-09 17:13:30 +08:00
parent c15df2a6a9
commit 70099da497
3 changed files with 37 additions and 0 deletions

19
src/interrupts.rs Normal file
View File

@@ -0,0 +1,19 @@
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame};
use crate::println;
use lazy_static::lazy_static;
lazy_static! {
static ref IDT: InterruptDescriptorTable = {
let mut idt = InterruptDescriptorTable::new();
idt.breakpoint.set_handler_fn(breakpoint_handler);
idt
};
}
pub fn init_idt() {
IDT.load();
}
extern "x86-interrupt" fn breakpoint_handler(stack_frame: InterruptStackFrame) {
println!("EXCEPTION: BREAKPOINT\n{:#?}", stack_frame);
}