Skip to content

Commit

Permalink
uefi: Update println to use the global system table
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasbishop committed Aug 25, 2024
1 parent d3eec85 commit 1320691
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions uefi/src/helpers/println.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use crate::table::system_table_boot;
use crate::{boot, system};
use core::fmt::Write;

/// INTERNAL API! Helper for print macros.
#[doc(hidden)]
pub fn _print(args: core::fmt::Arguments) {
if let Some(mut bs) = system_table_boot() {
bs.stdout()
.write_fmt(args)
.expect("Failed to write to stdout");
if boot::are_boot_services_active() {
system::with_stdout(|stdout| {
stdout.write_fmt(args).expect("Failed to write to stdout");
});
} else {
// Ease debugging: Depending on logger, this might write to serial or
// debugcon.
Expand All @@ -25,8 +25,7 @@ pub fn _print(args: core::fmt::Arguments) {
/// prevent a circular runtime dependency.
///
/// # Panics
/// Will panic if `SYSTEM_TABLE` is `None` (Before [`uefi::helpers::init()`] and
/// after [`uefi::prelude::SystemTable::exit_boot_services()`]).
/// Will panic if the system table's `stdout` is not set, or if writing fails.
///
/// # Examples
/// ```
Expand All @@ -50,8 +49,7 @@ macro_rules! print {
/// prevent a circular runtime dependency.
///
/// # Panics
/// Will panic if `SYSTEM_TABLE` is `None` (Before [`uefi::helpers::init()`] and
/// after [`uefi::prelude::SystemTable::exit_boot_services()`]).
/// Will panic if the system table's `stdout` is not set, or if writing fails.
///
/// # Examples
/// ```
Expand Down

0 comments on commit 1320691

Please sign in to comment.