1use core::fmt;
2use x86_64::instructions::port::Port;
3
4pub struct QemuDebug;
5
6impl fmt::Write for QemuDebug {
7 fn write_str(&mut self, s: &str) -> fmt::Result {
8 let mut port = Port::new(0xe9);
9 for &byte in s.as_bytes() {
10 unsafe {
11 port.write(byte);
12 }
13 }
14 Ok(())
15 }
16}
17
18#[macro_export]
19macro_rules! e9_print {
20 ($($arg:tt)*) => {
21 {
22 use core::fmt::Write;
23 let _ = write!($crate::debug::QemuDebug, $($arg)*);
24 }
25 };
26}
27
28#[macro_export]
29macro_rules! e9_println {
30 () => ($crate::e9_print!("\n"));
31 ($($arg:tt)*) => ($crate::e9_print!("{}\n", format_args!($($arg)*)));
32}
33
34#[macro_export]
38macro_rules! boot_milestone {
39 ($($arg:tt)*) => {
40 $crate::serial_println!(
41 "[boot +{:>6}ms] {}",
42 $crate::arch::x86_64::boot_timestamp::elapsed_ms(),
43 format_args!($($arg)*)
44 );
45 };
46}