add interrupt

This commit is contained in:
mii443
2025-07-04 18:29:33 +09:00
parent c9cb527840
commit 43a47d8322
4 changed files with 27 additions and 1 deletions

View File

@ -8,7 +8,6 @@ EFI_BINARY="$1"
qemu-system-x86_64 -enable-kvm \
-m 4G \
-serial mon:stdio \
-nographic \
-no-reboot \
-drive if=pflash,format=raw,readonly=on,file=OVMF_CODE.fd \
-drive if=pflash,format=raw,readonly=on,file=OVMF_VARS.fd \

View File

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

View File

@ -0,0 +1 @@
pub mod idt;

View File

@ -1,11 +1,13 @@
#![no_std]
#![no_main]
#![feature(abi_x86_interrupt)]
extern crate alloc;
pub mod constant;
pub mod cpuid;
pub mod graphics;
pub mod interrupt;
pub mod logging;
pub mod memory;
pub mod serial;
@ -66,6 +68,8 @@ fn hlt_loop() -> ! {
#[unsafe(no_mangle)]
pub extern "sysv64" fn main(boot_info: &nel_os_common::BootInfo) {
interrupt::idt::init_idt();
let virt = VirtAddr::new(
x86_64::registers::control::Cr3::read()
.0
@ -136,5 +140,7 @@ pub extern "sysv64" fn main(boot_info: &nel_os_common::BootInfo) {
usable_frame as f64 * 4. / 1024. / 1024.
);
x86_64::instructions::interrupts::int3();
hlt_loop();
}