27 lines
788 B
Rust
27 lines
788 B
Rust
use lazy_static::lazy_static;
|
|
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame};
|
|
|
|
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: InterruptStackFrame) {
|
|
println!("EXCEPTION: Breakpoint\n{:#?}", stack_frame);
|
|
}
|
|
|
|
// The error code of the double-fault handler is always 0
|
|
extern "x86-interrupt" fn double_fault_handler(
|
|
stack_frame: InterruptStackFrame,
|
|
_error_code: u64,
|
|
) -> ! {
|
|
panic!("Exception: Double fault\n{:#?}", stack_frame)
|
|
}
|