diff --git a/src/lib.rs b/src/lib.rs index 7bc92a5..78e2898 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,20 +1,22 @@ #![no_std] #![no_main] +mod vga; use core::panic::PanicInfo; +use vga::Color; #[panic_handler] fn panic_handler(info: &PanicInfo) -> ! { + vga::change_color(Color::LightRed, Color::Black); println!("{}", info); loop {} } -mod vga; #[no_mangle] pub extern "C" fn julios_main() -> ! { println!("Hello World!"); println!("{}", "***JuliOS***"); - panic!("Test panick"); + panic!("Test panic"); loop {} } diff --git a/src/vga.rs b/src/vga.rs index aa171a2..fb15e34 100644 --- a/src/vga.rs +++ b/src/vga.rs @@ -9,7 +9,7 @@ const BUFFER_WIDTH: usize = 80; lazy_static! { pub static ref WRITER: Mutex = Mutex::new(Writer { column: 0, - color_code: ColorCode::new(Color::Green, Color::Black), + color_code: ColorCode::new(Color::LightBlue, Color::Black), buffer: unsafe { &mut *(0xb8000 as *mut VgaBuffer) } }); } @@ -30,6 +30,9 @@ pub fn _print(args: fmt::Arguments) { use core::fmt::Write; WRITER.lock().write_fmt(args).unwrap(); } +pub fn change_color(fg: Color, bg: Color) { + WRITER.lock().change_color(ColorCode::new(fg, bg)) +} #[allow(dead_code)] @@ -133,6 +136,10 @@ impl Writer { self.buffer.chars[row][col].write(blank); } } + + fn change_color(&mut self, color: ColorCode) { + self.color_code = color; + } } impl fmt::Write for Writer {