Skip to content

Commit

Permalink
Merge pull request rust-osdev#1360 from nicholasbishop/bishop-update-…
Browse files Browse the repository at this point in the history
…println

uefi: Update println to use the global system table
  • Loading branch information
phip1611 authored Aug 26, 2024
2 parents 273a39e + 1320691 commit 5d52fd8
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 5d52fd8

Please sign in to comment.