feat(vga): add vga change color interface
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
Julien CLEMENT 2021-12-02 20:28:15 +01:00
parent 70e7b48bfe
commit be8f3f2a0f
2 changed files with 12 additions and 3 deletions

@ -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 {}
}

@ -9,7 +9,7 @@ const BUFFER_WIDTH: usize = 80;
lazy_static! {
pub static ref WRITER: Mutex<Writer> = 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 {