19
19
//! [println_macro]: uefi::println!
20
20
21
21
use crate :: prelude:: { Boot , SystemTable } ;
22
- use crate :: Result ;
23
- use crate :: StatusExt ;
24
- use core:: ffi:: c_void;
25
- use core:: ptr;
26
- use core:: sync:: atomic:: { AtomicPtr , Ordering } ;
22
+ use crate :: { table, Result } ;
27
23
#[ doc( hidden) ]
28
24
pub use println:: _print;
29
- use uefi_raw:: Status ;
30
25
31
26
#[ cfg( feature = "global_allocator" ) ]
32
27
mod global_allocator;
@@ -36,25 +31,6 @@ mod logger;
36
31
mod panic_handler;
37
32
mod println;
38
33
39
- /// Reference to the system table.
40
- ///
41
- /// This table is only fully safe to use until UEFI boot services have been exited.
42
- /// After that, some fields and methods are unsafe to use, see the documentation of
43
- /// UEFI's ExitBootServices entry point for more details.
44
- static SYSTEM_TABLE : AtomicPtr < c_void > = AtomicPtr :: new ( core:: ptr:: null_mut ( ) ) ;
45
-
46
- #[ must_use]
47
- fn system_table_opt ( ) -> Option < SystemTable < Boot > > {
48
- let ptr = SYSTEM_TABLE . load ( Ordering :: Acquire ) ;
49
- // Safety: the `SYSTEM_TABLE` pointer either be null or a valid system
50
- // table.
51
- //
52
- // Null is the initial value, as well as the value set when exiting boot
53
- // services. Otherwise, the value is set by the call to `init`, which
54
- // requires a valid system table reference as input.
55
- unsafe { SystemTable :: from_ptr ( ptr) }
56
- }
57
-
58
34
/// Obtains a pointer to the system table.
59
35
///
60
36
/// This is meant to be used by higher-level libraries,
@@ -66,7 +42,7 @@ fn system_table_opt() -> Option<SystemTable<Boot>> {
66
42
#[ must_use]
67
43
// TODO do we want to keep this public?
68
44
pub fn system_table ( ) -> SystemTable < Boot > {
69
- system_table_opt ( ) . expect ( "The system table handle is not available " )
45
+ table :: system_table_boot ( ) . expect ( "boot services are not active " )
70
46
}
71
47
72
48
/// Initialize all helpers defined in [`uefi::helpers`] whose Cargo features
@@ -78,15 +54,8 @@ pub fn system_table() -> SystemTable<Boot> {
78
54
/// **PLEASE NOTE** that these helpers are meant for the pre exit boot service
79
55
/// epoch. Limited functionality might work after exiting them, such as logging
80
56
/// to the debugcon device.
57
+ #[ allow( unused_variables) ] // `st` is unused if logger and allocator are disabled
81
58
pub fn init ( st : & mut SystemTable < Boot > ) -> Result < ( ) > {
82
- if system_table_opt ( ) . is_some ( ) {
83
- // Avoid double initialization.
84
- return Status :: SUCCESS . to_result_with_val ( || ( ) ) ;
85
- }
86
-
87
- // Setup the system table singleton
88
- SYSTEM_TABLE . store ( st. as_ptr ( ) . cast_mut ( ) , Ordering :: Release ) ;
89
-
90
59
// Setup logging and memory allocation
91
60
92
61
#[ cfg( feature = "logger" ) ]
@@ -103,14 +72,6 @@ pub fn init(st: &mut SystemTable<Boot>) -> Result<()> {
103
72
}
104
73
105
74
pub ( crate ) fn exit ( ) {
106
- // DEBUG: The UEFI spec does not guarantee that this printout will work, as
107
- // the services used by logging might already have been shut down.
108
- // But it works on current OVMF, and can be used as a handy way to
109
- // check that the callback does get called.
110
- //
111
- // info!("Shutting down the UEFI utility library");
112
- SYSTEM_TABLE . store ( ptr:: null_mut ( ) , Ordering :: Release ) ;
113
-
114
75
#[ cfg( feature = "logger" ) ]
115
76
logger:: disable ( ) ;
116
77
0 commit comments