mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Load and test our new IDT
This commit is contained in:
@@ -1,9 +1,17 @@
|
|||||||
use crate::println;
|
use crate::println;
|
||||||
|
use lazy_static::lazy_static;
|
||||||
use x86_64::structures::idt::{ExceptionStackFrame, InterruptDescriptorTable};
|
use x86_64::structures::idt::{ExceptionStackFrame, InterruptDescriptorTable};
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
static ref IDT: InterruptDescriptorTable = {
|
||||||
|
let mut idt = InterruptDescriptorTable::new();
|
||||||
|
idt.breakpoint.set_handler_fn(breakpoint_handler);
|
||||||
|
idt
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
pub fn init_idt() {
|
pub fn init_idt() {
|
||||||
let mut idt = InterruptDescriptorTable::new();
|
IDT.load();
|
||||||
idt.breakpoint.set_handler_fn(breakpoint_handler);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "x86-interrupt" fn breakpoint_handler(stack_frame: &mut ExceptionStackFrame) {
|
extern "x86-interrupt" fn breakpoint_handler(stack_frame: &mut ExceptionStackFrame) {
|
||||||
|
|||||||
@@ -10,6 +10,12 @@ use core::panic::PanicInfo;
|
|||||||
pub extern "C" fn _start() -> ! {
|
pub extern "C" fn _start() -> ! {
|
||||||
println!("Hello World{}", "!");
|
println!("Hello World{}", "!");
|
||||||
|
|
||||||
|
blog_os::interrupts::init_idt();
|
||||||
|
|
||||||
|
// invoke a breakpoint exception
|
||||||
|
x86_64::instructions::int3();
|
||||||
|
|
||||||
|
println!("It did not crash!");
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user