Start off the interrupts driver (3h17m)

This commit is contained in:
Conzer 2024-12-03 18:44:41 -05:00
parent cbd2cfc1d4
commit af973e8c8e
3 changed files with 31 additions and 0 deletions

20
src/interrupts.rs Normal file
View file

@ -0,0 +1,20 @@
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame};
use crate::println;
use lazy_static::lazy_static;
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: InterruptStackFrame)
{
println!("EXCEPTION: BREAKPOINT\n{:#?}", stack_frame);
}

View file

@ -4,9 +4,15 @@
#![feature(custom_test_frameworks)]
#![test_runner(crate::test_runner)]
#![reexport_test_harness_main = "test_main"]
#![feature(abi_x86_interrupt)]
pub fn init() {
interrupts::init_idt();
}
pub mod serial;
pub mod vga_buffer;
pub mod interrupts;
use core::panic::PanicInfo;

View file

@ -11,9 +11,14 @@ use donald::println;
pub extern "C" fn _start() -> ! {
println!("Hello World{}", "!");
donald::init();
x86_64::instructions::interrupts::int3();
#[cfg(test)]
test_main();
println!("It did not crash!");
loop {}
}