use crate::arch;
use crate::synch::spinlock::SpinlockIrqSave;
use core::fmt;
pub struct Console(());
impl fmt::Write for Console {
fn write_str(&mut self, s: &str) -> fmt::Result {
if !s.is_empty() {
let buf = s.as_bytes();
arch::output_message_buf(buf);
}
Ok(())
}
fn write_char(&mut self, c: char) -> fmt::Result {
self.write_str(c.encode_utf8(&mut [0; 4]))
}
}
impl Console {
pub fn write_all(&mut self, buf: &[u8]) {
arch::output_message_buf(buf)
}
}
pub static CONSOLE: SpinlockIrqSave<Console> = SpinlockIrqSave::new(Console(()));
#[cfg(not(any(target_os = "none", target_os = "hermit")))]
#[test]
fn test_console() {
println!("HelloWorld");
}