Skip to content

Commit

Permalink
revert Support mapping ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
Freax13 committed Oct 17, 2021
1 parent 9921ad5 commit d342ef2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 35 deletions.
2 changes: 1 addition & 1 deletion testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Philipp Oppermann <[email protected]>"]
edition = "2018"

[[test]]
name = "interrupt_handling"
name = "breakpoint_exception"
harness = false

[[test]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ use core::sync::atomic::{AtomicUsize, Ordering};
use lazy_static::lazy_static;
use testing::{exit_qemu, serial_print, serial_println, QemuExitCode};

use x86_64::instructions::interrupts;

static BREAKPOINT_HANDLER_CALLED: AtomicUsize = AtomicUsize::new(0);
static INTERRUPT_HANDLER_CALLED: AtomicUsize = AtomicUsize::new(0);

#[no_mangle]
pub extern "C" fn _start() -> ! {
Expand All @@ -19,10 +16,13 @@ pub extern "C" fn _start() -> ! {
init_test_idt();

// invoke a breakpoint exception
interrupts::int3();
x86_64::instructions::interrupts::int3();

match BREAKPOINT_HANDLER_CALLED.load(Ordering::SeqCst) {
1 => {}
1 => {
serial_println!("[ok]");
exit_qemu(QemuExitCode::Success);
}
0 => {
serial_println!("[failed]");
serial_println!(" Breakpoint handler was not called.");
Expand All @@ -35,29 +35,6 @@ pub extern "C" fn _start() -> ! {
}
}

serial_print!("interrupt 42... ");
unsafe { interrupts::software_interrupt::<42>() };
serial_print!("interrupt 77... ");
unsafe { interrupts::software_interrupt::<77>() };
serial_print!("interrupt 42... ");
unsafe { interrupts::software_interrupt::<42>() };

match INTERRUPT_HANDLER_CALLED.load(Ordering::SeqCst) {
3 => {}
0 => {
serial_println!("[failed]");
serial_println!(" Interrupt handler was not called.");
exit_qemu(QemuExitCode::Failed);
}
other => {
serial_println!("[failed]");
serial_println!(" Interrupt handler was called {} times", other);
exit_qemu(QemuExitCode::Failed);
}
}

serial_println!("[ok]");
exit_qemu(QemuExitCode::Success);
loop {}
}

Expand All @@ -72,8 +49,6 @@ lazy_static! {
static ref TEST_IDT: InterruptDescriptorTable = {
let mut idt = InterruptDescriptorTable::new();
idt.breakpoint.set_handler_fn(breakpoint_handler);
idt[42].set_handler_fn(interrupt_handler);
idt[77].set_handler_fn(interrupt_handler);
idt
};
}
Expand All @@ -85,7 +60,3 @@ pub fn init_test_idt() {
extern "x86-interrupt" fn breakpoint_handler(_stack_frame: InterruptStackFrame) {
BREAKPOINT_HANDLER_CALLED.fetch_add(1, Ordering::SeqCst);
}

extern "x86-interrupt" fn interrupt_handler(_stack_frame: InterruptStackFrame) {
INTERRUPT_HANDLER_CALLED.fetch_add(1, Ordering::SeqCst);
}

0 comments on commit d342ef2

Please sign in to comment.