@@ -7,10 +7,7 @@ use core::sync::atomic::{AtomicUsize, Ordering};
77use lazy_static:: lazy_static;
88use testing:: { exit_qemu, serial_print, serial_println, QemuExitCode } ;
99
10- use x86_64:: instructions:: interrupts;
11-
1210static BREAKPOINT_HANDLER_CALLED : AtomicUsize = AtomicUsize :: new ( 0 ) ;
13- static INTERRUPT_HANDLER_CALLED : AtomicUsize = AtomicUsize :: new ( 0 ) ;
1411
1512#[ no_mangle]
1613pub extern "C" fn _start ( ) -> ! {
@@ -19,10 +16,13 @@ pub extern "C" fn _start() -> ! {
1916 init_test_idt ( ) ;
2017
2118 // invoke a breakpoint exception
22- interrupts:: int3 ( ) ;
19+ x86_64 :: instructions :: interrupts:: int3 ( ) ;
2320
2421 match BREAKPOINT_HANDLER_CALLED . load ( Ordering :: SeqCst ) {
25- 1 => { }
22+ 1 => {
23+ serial_println ! ( "[ok]" ) ;
24+ exit_qemu ( QemuExitCode :: Success ) ;
25+ }
2626 0 => {
2727 serial_println ! ( "[failed]" ) ;
2828 serial_println ! ( " Breakpoint handler was not called." ) ;
@@ -35,29 +35,6 @@ pub extern "C" fn _start() -> ! {
3535 }
3636 }
3737
38- serial_print ! ( "interrupt 42... " ) ;
39- unsafe { interrupts:: software_interrupt :: < 42 > ( ) } ;
40- serial_print ! ( "interrupt 77... " ) ;
41- unsafe { interrupts:: software_interrupt :: < 77 > ( ) } ;
42- serial_print ! ( "interrupt 42... " ) ;
43- unsafe { interrupts:: software_interrupt :: < 42 > ( ) } ;
44-
45- match INTERRUPT_HANDLER_CALLED . load ( Ordering :: SeqCst ) {
46- 3 => { }
47- 0 => {
48- serial_println ! ( "[failed]" ) ;
49- serial_println ! ( " Interrupt handler was not called." ) ;
50- exit_qemu ( QemuExitCode :: Failed ) ;
51- }
52- other => {
53- serial_println ! ( "[failed]" ) ;
54- serial_println ! ( " Interrupt handler was called {} times" , other) ;
55- exit_qemu ( QemuExitCode :: Failed ) ;
56- }
57- }
58-
59- serial_println ! ( "[ok]" ) ;
60- exit_qemu ( QemuExitCode :: Success ) ;
6138 loop { }
6239}
6340
@@ -72,8 +49,6 @@ lazy_static! {
7249 static ref TEST_IDT : InterruptDescriptorTable = {
7350 let mut idt = InterruptDescriptorTable :: new( ) ;
7451 idt. breakpoint. set_handler_fn( breakpoint_handler) ;
75- idt[ 42 ] . set_handler_fn( interrupt_handler) ;
76- idt[ 77 ] . set_handler_fn( interrupt_handler) ;
7752 idt
7853 } ;
7954}
@@ -85,7 +60,3 @@ pub fn init_test_idt() {
8560extern "x86-interrupt" fn breakpoint_handler ( _stack_frame : InterruptStackFrame ) {
8661 BREAKPOINT_HANDLER_CALLED . fetch_add ( 1 , Ordering :: SeqCst ) ;
8762}
88-
89- extern "x86-interrupt" fn interrupt_handler ( _stack_frame : InterruptStackFrame ) {
90- INTERRUPT_HANDLER_CALLED . fetch_add ( 1 , Ordering :: SeqCst ) ;
91- }
0 commit comments