Breakpoint interrupt

This commit is contained in:
greg 2019-07-11 02:35:02 -07:00
parent c07949da0e
commit 9b61d543d6
2 changed files with 26 additions and 3 deletions

View File

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

View File

@ -1,3 +1,4 @@
#![feature(abi_x86_interrupt)]
#![no_std] #![no_std]
#![no_main] #![no_main]
@ -13,10 +14,18 @@ fn panic(info: &PanicInfo) -> !{
loop {} loop {}
} }
pub fn init() {
interrupts::init_idt();
}
#[no_mangle] #[no_mangle]
pub extern "C" fn _start() -> ! { pub extern "C" fn _start() -> ! {
init();
x86_64::instructions::interrupts::int3();
println!("Gamarjoba, munde: {}", 1); println!("Gamarjoba, munde: {}", 1);
panic!("A bad thing happened"); //panic!("A bad thing happened");
loop {} loop {}
} }