Skip to content

Commit

Permalink
fix(uefi): enable console struct
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kröning <[email protected]>
  • Loading branch information
mkroening committed Apr 9, 2024
1 parent 8ac66f5 commit bee5b4b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
3 changes: 3 additions & 0 deletions src/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ pub struct Console(());

impl fmt::Write for Console {
fn write_str(&mut self, s: &str) -> fmt::Result {
#[cfg(target_os = "none")]
crate::arch::write_to_console(s.as_bytes());
#[cfg(target_os = "uefi")]
uefi_services::system_table().stdout().write_str(s)?;
Ok(())
}
}
Expand Down
26 changes: 6 additions & 20 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,9 @@
/// [`std::print`]: https://doc.rust-lang.org/stable/std/macro.print.html
#[macro_export]
macro_rules! print {
($($arg:tt)*) => {
#[cfg(target_os = "none")]
{
$crate::_print(::core::format_args!($($arg)*));
}
#[cfg(target_os = "uefi")]
{
::uefi_services::print!($($arg)*);
}
};
($($arg:tt)*) => {{
$crate::_print(::core::format_args!($($arg)*));
}};
}

/// Prints to the standard output, with a newline.
Expand All @@ -27,16 +20,9 @@ macro_rules! println {
() => {
$crate::print!("\n")
};
($($arg:tt)*) => {
#[cfg(target_os = "none")]
{
$crate::_print(::core::format_args!("{}\n", format_args!($($arg)*)));
}
#[cfg(target_os = "uefi")]
{
::uefi_services::println!($($arg)*);
}
};
($($arg:tt)*) => {{
$crate::_print(::core::format_args!("{}\n", format_args!($($arg)*)));
}};
}

/// Prints and returns the value of a given expression for quick and dirty
Expand Down
2 changes: 0 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ mod macros;
#[cfg(target_os = "none")]
mod allocator;
mod arch;
#[cfg(target_os = "none")]
mod console;
#[cfg(target_os = "none")]
mod log;
Expand All @@ -26,7 +25,6 @@ mod uefi;
))]
extern crate alloc;

#[cfg(target_os = "none")]
#[doc(hidden)]
fn _print(args: core::fmt::Arguments<'_>) {
use core::fmt::Write;
Expand Down

0 comments on commit bee5b4b

Please sign in to comment.