add interrupt
This commit is contained in:
@ -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 \
|
||||
|
20
nel_os_kernel/src/interrupt/idt.rs
Normal file
20
nel_os_kernel/src/interrupt/idt.rs
Normal 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);
|
||||
}
|
1
nel_os_kernel/src/interrupt/mod.rs
Normal file
1
nel_os_kernel/src/interrupt/mod.rs
Normal file
@ -0,0 +1 @@
|
||||
pub mod idt;
|
@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user