From d342ef2f3df665b88c6a6f49ca3277e8ce16f001 Mon Sep 17 00:00:00 2001 From: Tom Dohrmann Date: Sun, 17 Oct 2021 19:28:03 +0200 Subject: [PATCH] revert Support mapping ranges --- testing/Cargo.toml | 2 +- ...pt_handling.rs => breakpoint_exception.rs} | 39 +++---------------- 2 files changed, 6 insertions(+), 35 deletions(-) rename testing/tests/{interrupt_handling.rs => breakpoint_exception.rs} (55%) diff --git a/testing/Cargo.toml b/testing/Cargo.toml index 7a32657c1..fe08cc67c 100644 --- a/testing/Cargo.toml +++ b/testing/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Philipp Oppermann "] edition = "2018" [[test]] -name = "interrupt_handling" +name = "breakpoint_exception" harness = false [[test]] diff --git a/testing/tests/interrupt_handling.rs b/testing/tests/breakpoint_exception.rs similarity index 55% rename from testing/tests/interrupt_handling.rs rename to testing/tests/breakpoint_exception.rs index 120f95515..573819030 100644 --- a/testing/tests/interrupt_handling.rs +++ b/testing/tests/breakpoint_exception.rs @@ -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() -> ! { @@ -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."); @@ -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 {} } @@ -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 }; } @@ -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); -}