@@ -4,14 +4,25 @@ use core::fmt::Write;
4
4
/// INTERNAL API! Helper for print macros.
5
5
#[ doc( hidden) ]
6
6
pub fn _print ( args : core:: fmt:: Arguments ) {
7
- system_table_boot ( )
8
- . expect ( "boot services are not active" )
9
- . stdout ( )
10
- . write_fmt ( args)
11
- . expect ( "Failed to write to stdout" ) ;
7
+ if let Some ( mut bs) = system_table_boot ( ) {
8
+ bs. stdout ( )
9
+ . write_fmt ( args)
10
+ . expect ( "Failed to write to stdout" ) ;
11
+ } else {
12
+ // Ease debugging: Depending on logger, this might write to serial or
13
+ // debugcon.
14
+ log:: debug!( "You are using `print!` after the boot services have been exited." ) ;
15
+ }
12
16
}
13
17
14
- /// Prints to the standard output.
18
+ /// Prints to the standard output of the UEFI boot service console.
19
+ ///
20
+ /// # Usage
21
+ /// Use this similar to `print!` from the Rust standard library, but only
22
+ /// as long as boot services have not been exited.
23
+ ///
24
+ /// You should never use this macro in a custom Logger ([`log::Log`] impl) to
25
+ /// prevent a circular runtime dependency.
15
26
///
16
27
/// # Panics
17
28
/// Will panic if `SYSTEM_TABLE` is `None` (Before [`uefi::helpers::init()`] and
@@ -28,7 +39,15 @@ macro_rules! print {
28
39
( $( $arg: tt) * ) => ( $crate:: helpers:: _print( core:: format_args!( $( $arg) * ) ) ) ;
29
40
}
30
41
31
- /// Prints to the standard output, with a newline.
42
+ /// Prints to the standard output of the UEFI boot service console, but with a
43
+ /// newline.
44
+ ///
45
+ /// # Usage
46
+ /// Use this similar to `println!` from the Rust standard library, but only
47
+ /// as long as boot services have not been exited.
48
+ ///
49
+ /// You should never use this macro in a custom Logger ([`log::Log`] impl) to
50
+ /// prevent a circular runtime dependency.
32
51
///
33
52
/// # Panics
34
53
/// Will panic if `SYSTEM_TABLE` is `None` (Before [`uefi::helpers::init()`] and
0 commit comments