fix(pit): fix interrupt race conditions

Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
juju committed 2021-12-04 22:57:51 +01:00
1 parent 618e528f35
commit 019dca5e7d
4 files changed
+22 -6

No files matched your search

+3
View File
@@ -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());
}
}
+7 -1
View File
@@ -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() {
+7 -4
View File
@@ -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.
+5 -1
View File
@@ -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)
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.