Draw on VESA for console using ransid
This commit is contained in:
parent
53c71d9183
commit
d7d61f82af
1 changed files with 87 additions and 52 deletions
26
arch/x86_64/src/console.rs
Normal file
26
arch/x86_64/src/console.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
use core::fmt::{self, Write};
|
||||
use spin::Mutex;
|
||||
|
||||
use device::display::DISPLAY;
|
||||
use device::serial::COM1;
|
||||
|
||||
pub static CONSOLE: Mutex<Console> = Mutex::new(Console::new());
|
||||
|
||||
pub struct Console;
|
||||
|
||||
impl Console {
|
||||
const fn new() -> Self {
|
||||
Console
|
||||
}
|
||||
}
|
||||
|
||||
impl Write for Console {
|
||||
fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> {
|
||||
if let Some(ref mut display) = *DISPLAY.lock() {
|
||||
display.write(s.as_bytes());
|
||||
Ok(())
|
||||
} else {
|
||||
COM1.lock().write_str(s)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue