kernel/src/io/vga/mod.rs
2022-12-23 16:09:45 +01:00

31 lines
No EOL
752 B
Rust

pub mod colors;
pub mod buffer;
use core::fmt;
use lazy_static::lazy_static;
use spin::Mutex;
lazy_static! {
pub static ref WRITER: Mutex<buffer::Writer> = Mutex::new(buffer::Writer {
column_position: 0,
color_code: colors::ColorCode::new(colors::Color::Yellow, colors::Color::Black),
buffer: unsafe { &mut *(0xb8000 as *mut buffer::Buffer) },
});
}
#[macro_export]
macro_rules! println {
() => (print!("\n"));
($($arg:tt)*) => (print!("{}\n", format_args!($($arg)*)));
}
#[macro_export]
macro_rules! print {
($($arg:tt)*) => ($crate::io::vga::_print(format_args!($($arg)*)));
}
#[doc(hidden)]
pub fn _print(args: fmt::Arguments) {
use core::fmt::Write;
WRITER.lock().write_fmt(args).unwrap();
}