mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
26 lines
647 B
Rust
26 lines
647 B
Rust
use crate::println;
|
|
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
|
|
};
|
|
}
|
|
|
|
pub fn init_idt() {
|
|
IDT.load();
|
|
}
|
|
|
|
extern "x86-interrupt" fn breakpoint_handler(stack_frame: &mut InterruptStackFrame) {
|
|
println!("EXCEPTION: BREAKPOINT\n{:#?}", stack_frame);
|
|
}
|
|
|
|
#[test_case]
|
|
fn test_breakpoint_exception() {
|
|
// invoke a breakpoint exception
|
|
x86_64::instructions::interrupts::int3();
|
|
}
|