mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Make print_error safe by using the global writer
This is now possible since we fixed the deadlock problem.
This commit is contained in:
@@ -43,16 +43,15 @@ pub fn clear_screen() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn print_error(fmt: fmt::Arguments) {
|
pub fn print_error(fmt: fmt::Arguments) {
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
|
use core::mem;
|
||||||
|
|
||||||
let mut writer = Writer {
|
let mut writer = WRITER.lock();
|
||||||
column_position: 0,
|
let red = ColorCode::new(Color::Red, Color::Black);
|
||||||
color_code: ColorCode::new(Color::Red, Color::Black),
|
let default_color = mem::replace(&mut writer.color_code, red);
|
||||||
buffer: Unique::new(0xb8000 as *mut _),
|
writer.write_fmt(fmt).unwrap();
|
||||||
};
|
writer.color_code = default_color;
|
||||||
writer.new_line();
|
|
||||||
writer.write_fmt(fmt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|||||||
Reference in New Issue
Block a user