26 lines
732 B
Rust
26 lines
732 B
Rust
use lazy_static::lazy_static;
|
|
use x86_64::structures::idt::{InterruptStackFrame, InterruptDescriptorTable};
|
|
use crate::println;
|
|
|
|
lazy_static! {
|
|
static ref IDT: InterruptDescriptorTable = {
|
|
let mut idt = InterruptDescriptorTable::new();
|
|
idt.breakpoint.set_handler_fn(breakpoint_handler);
|
|
idt.double_fault.set_handler_fn(double_fault_handler);
|
|
idt
|
|
};
|
|
}
|
|
|
|
pub fn init_idt() {
|
|
IDT.load();
|
|
}
|
|
|
|
extern "x86-interrupt" fn breakpoint_handler(stack_frame: &mut InterruptStackFrame) {
|
|
|
|
println!("EXCEPTION - BREAKPOINT\n{:#?}", stack_frame);
|
|
}
|
|
|
|
extern "x86-interrupt" fn double_fault_handler(stack_frame: &mut InterruptStackFrame, code: u64) {
|
|
panic!("EXCEPTION - DOUBLE FAULT (code {})\n{:#?}", code, stack_frame);
|
|
}
|