1use core::fmt::{Arguments, Result, Write};
4
5#[def_plat_interface]
7pub trait ConsoleIf {
8 fn write_bytes(bytes: &[u8]);
10
11 fn read_bytes(bytes: &mut [u8]) -> usize;
15}
16
17struct EarlyConsole;
18
19impl Write for EarlyConsole {
20 fn write_str(&mut self, s: &str) -> Result {
21 write_bytes(s.as_bytes());
22 Ok(())
23 }
24}
25
26#[macro_export]
28macro_rules! console_print {
29 ($($arg:tt)*) => {
30 $crate::console::__simple_print(format_args!($($arg)*));
31 }
32}
33
34#[macro_export]
36macro_rules! console_println {
37 () => { $crate::ax_print!("\n") };
38 ($($arg:tt)*) => {
39 $crate::console::__simple_print(format_args!("{}\n", format_args!($($arg)*)));
40 }
41}
42
43#[doc(hidden)]
44pub fn __simple_print(fmt: Arguments) {
45 EarlyConsole.write_fmt(fmt).unwrap();
46}