Load and test our new IDT

This commit is contained in:
Philipp Oppermann
2019-01-25 13:50:33 +01:00
parent 9448b0e025
commit c6bd48e812
2 changed files with 16 additions and 2 deletions

View File

@@ -1,9 +1,17 @@
use crate::println;
use lazy_static::lazy_static;
use x86_64::structures::idt::{ExceptionStackFrame, InterruptDescriptorTable};
pub fn init_idt() {
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 ExceptionStackFrame) {

View File

@@ -10,6 +10,12 @@ use core::panic::PanicInfo;
pub extern "C" fn _start() -> ! {
println!("Hello World{}", "!");
blog_os::interrupts::init_idt();
// invoke a breakpoint exception
x86_64::instructions::int3();
println!("It did not crash!");
loop {}
}