From 9b61d543d60985b220e2126202e8e793720858fc Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 11 Jul 2019 02:35:02 -0700 Subject: [PATCH] Breakpoint interrupt --- src/interrupts.rs | 18 ++++++++++++++++-- src/main.rs | 11 ++++++++++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/interrupts.rs b/src/interrupts.rs index 3e82f38..3802522 100644 --- a/src/interrupts.rs +++ b/src/interrupts.rs @@ -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() { - let mut idt = InterruptDescriptorTable::new(); + IDT.load(); +} + +extern "x86-interrupt" fn breakpoint_handler(stack_frame: &mut InterruptStackFrame) { + + println!("EXCEPTION - BREAKPOINT\n{:#?}", stack_frame); } diff --git a/src/main.rs b/src/main.rs index 8038fb2..1f8ffc7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +#![feature(abi_x86_interrupt)] #![no_std] #![no_main] @@ -13,10 +14,18 @@ fn panic(info: &PanicInfo) -> !{ loop {} } +pub fn init() { + interrupts::init_idt(); +} + #[no_mangle] pub extern "C" fn _start() -> ! { + + init(); + x86_64::instructions::interrupts::int3(); + println!("Gamarjoba, munde: {}", 1); - panic!("A bad thing happened"); + //panic!("A bad thing happened"); loop {} }