1919//! [println_macro]: uefi::println!
2020
2121use crate :: prelude:: { Boot , SystemTable } ;
22- use crate :: { Result , StatusExt } ;
23- use core:: ffi:: c_void;
24- use core:: ptr;
25- use core:: sync:: atomic:: { AtomicPtr , Ordering } ;
22+ use crate :: { table, Result } ;
2623#[ doc( hidden) ]
2724pub use println:: _print;
28- use uefi_raw:: Status ;
2925
3026#[ cfg( feature = "global_allocator" ) ]
3127mod global_allocator;
@@ -35,25 +31,6 @@ mod logger;
3531mod panic_handler;
3632mod println;
3733
38- /// Reference to the system table.
39- ///
40- /// This table is only fully safe to use until UEFI boot services have been exited.
41- /// After that, some fields and methods are unsafe to use, see the documentation of
42- /// UEFI's ExitBootServices entry point for more details.
43- static SYSTEM_TABLE : AtomicPtr < c_void > = AtomicPtr :: new ( core:: ptr:: null_mut ( ) ) ;
44-
45- #[ must_use]
46- fn system_table_opt ( ) -> Option < SystemTable < Boot > > {
47- let ptr = SYSTEM_TABLE . load ( Ordering :: Acquire ) ;
48- // Safety: the `SYSTEM_TABLE` pointer either be null or a valid system
49- // table.
50- //
51- // Null is the initial value, as well as the value set when exiting boot
52- // services. Otherwise, the value is set by the call to `init`, which
53- // requires a valid system table reference as input.
54- unsafe { SystemTable :: from_ptr ( ptr) }
55- }
56-
5734/// Obtains a pointer to the system table.
5835///
5936/// This is meant to be used by higher-level libraries,
@@ -65,7 +42,7 @@ fn system_table_opt() -> Option<SystemTable<Boot>> {
6542#[ must_use]
6643// TODO do we want to keep this public?
6744pub fn system_table ( ) -> SystemTable < Boot > {
68- system_table_opt ( ) . expect ( "The system table handle is not available " )
45+ table :: system_table_boot ( ) . expect ( "boot services are not active " )
6946}
7047
7148/// Initialize all helpers defined in [`uefi::helpers`] whose Cargo features
@@ -77,15 +54,8 @@ pub fn system_table() -> SystemTable<Boot> {
7754/// **PLEASE NOTE** that these helpers are meant for the pre exit boot service
7855/// epoch. Limited functionality might work after exiting them, such as logging
7956/// to the debugcon device.
57+ #[ allow( unused_variables) ] // `st` is unused if logger and allocator are disabled
8058pub fn init ( st : & mut SystemTable < Boot > ) -> Result < ( ) > {
81- if system_table_opt ( ) . is_some ( ) {
82- // Avoid double initialization.
83- return Status :: SUCCESS . to_result_with_val ( || ( ) ) ;
84- }
85-
86- // Setup the system table singleton
87- SYSTEM_TABLE . store ( st. as_ptr ( ) . cast_mut ( ) , Ordering :: Release ) ;
88-
8959 // Setup logging and memory allocation
9060
9161 #[ cfg( feature = "logger" ) ]
@@ -102,14 +72,6 @@ pub fn init(st: &mut SystemTable<Boot>) -> Result<()> {
10272}
10373
10474pub ( crate ) fn exit ( ) {
105- // DEBUG: The UEFI spec does not guarantee that this printout will work, as
106- // the services used by logging might already have been shut down.
107- // But it works on current OVMF, and can be used as a handy way to
108- // check that the callback does get called.
109- //
110- // info!("Shutting down the UEFI utility library");
111- SYSTEM_TABLE . store ( ptr:: null_mut ( ) , Ordering :: Release ) ;
112-
11375 #[ cfg( feature = "logger" ) ]
11476 logger:: disable ( ) ;
11577
0 commit comments