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
use core::fmt::{self, Write};
use crate::sbi;
struct Console;
impl Write for Console {
fn write_str(&mut self, string: &str) -> fmt::Result {
for char in string.bytes() {
sbi::console_putchar(char.into());
}
Ok(())
}
}
pub fn print(args: fmt::Arguments) {
Console.write_fmt(args).unwrap();
}
#[macro_export]
macro_rules! print {
($($arg:tt)*) => ($crate::console::print(format_args!($($arg)*)));
}
#[macro_export]
macro_rules! println {
() => ($crate::print!("\n"));
($($arg:tt)*) => ($crate::print!("{}\n", format_args!($($arg)*)));
}