fix(pit): fix interrupt race conditions
Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
		
							parent
							
								
									618e528f35
								
							
						
					
					
						commit
						019dca5e7d
					
				@ -66,4 +66,7 @@ extern "x86-interrupt" fn timer_interrupt_handler(
 | 
			
		||||
    _stack_frame: InterruptStackFrame)
 | 
			
		||||
{
 | 
			
		||||
    print!(".");
 | 
			
		||||
    unsafe {
 | 
			
		||||
        PICS.lock().notify_end_of_interrupt(InterruptIndex::Timer.as_u8());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -14,7 +14,13 @@ use vga::{Color, ColorCode};
 | 
			
		||||
fn panic_handler(info: &PanicInfo) -> ! {
 | 
			
		||||
    vga::change_color(ColorCode::new(Color::LightRed, Color::Black));
 | 
			
		||||
    println!("{}", info);
 | 
			
		||||
    loop {}
 | 
			
		||||
    hlt_loop();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub fn hlt_loop() -> ! {
 | 
			
		||||
    loop {
 | 
			
		||||
        x86_64::instructions::hlt();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub fn init() {
 | 
			
		||||
 | 
			
		||||
@ -35,10 +35,13 @@ lazy_static! {
 | 
			
		||||
#[doc(hidden)]
 | 
			
		||||
pub fn _print(args: ::core::fmt::Arguments) {
 | 
			
		||||
    use core::fmt::Write;
 | 
			
		||||
    SERIAL1
 | 
			
		||||
        .lock()
 | 
			
		||||
        .write_fmt(args)
 | 
			
		||||
        .expect("Printing to serial failed");
 | 
			
		||||
    use x86_64::instructions::interrupts;
 | 
			
		||||
    interrupts::without_interrupts(|| {
 | 
			
		||||
        SERIAL1
 | 
			
		||||
            .lock()
 | 
			
		||||
            .write_fmt(args)
 | 
			
		||||
            .expect("Printing to serial failed");
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Prints to the host through the serial interface.
 | 
			
		||||
 | 
			
		||||
@ -28,7 +28,11 @@ macro_rules! println {
 | 
			
		||||
#[doc(hidden)]
 | 
			
		||||
pub fn _print(args: fmt::Arguments) {
 | 
			
		||||
    use core::fmt::Write;
 | 
			
		||||
    WRITER.lock().write_fmt(args).unwrap();
 | 
			
		||||
    use x86_64::instructions::interrupts;
 | 
			
		||||
 | 
			
		||||
    interrupts::without_interrupts(|| {
 | 
			
		||||
        WRITER.lock().write_fmt(args).unwrap();
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
pub fn change_color(color: ColorCode) {
 | 
			
		||||
    WRITER.lock().change_color(color)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user