1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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]))
}
}
pub static CONSOLE: SpinlockIrqSave<Console> = SpinlockIrqSave::new(Console);
#[test]
fn test_console() {
println!("HelloWorld");
}