forked from AbleOS/ableos
24 lines
513 B
Rust
24 lines
513 B
Rust
|
use {core::fmt::Write, spin::Mutex};
|
||
|
|
||
|
const SERIAL_CONSOLE: Mutex<SerialConsole> = Mutex::new(SerialConsole {
|
||
|
uart: 0x09000000 as *mut u8,
|
||
|
});
|
||
|
|
||
|
struct SerialConsole {
|
||
|
uart: *mut u8,
|
||
|
}
|
||
|
|
||
|
impl core::fmt::Write for SerialConsole {
|
||
|
fn write_str(&mut self, s: &str) -> core::fmt::Result {
|
||
|
for c in s.chars() {
|
||
|
unsafe { *self.uart = c as u8 }
|
||
|
}
|
||
|
|
||
|
Ok(())
|
||
|
}
|
||
|
}
|
||
|
|
||
|
pub fn log(args: core::fmt::Arguments<'_>) -> core::fmt::Result {
|
||
|
SERIAL_CONSOLE.lock().write_fmt(args)
|
||
|
}
|