19
19
//! [println_macro]: uefi::println!
20
20
21
21
use 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 } ;
26
23
#[ doc( hidden) ]
27
24
pub use println:: _print;
28
- use uefi_raw:: Status ;
29
25
30
26
#[ cfg( feature = "global_allocator" ) ]
31
27
mod global_allocator;
@@ -35,25 +31,6 @@ mod logger;
35
31
mod panic_handler;
36
32
mod println;
37
33
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
-
57
34
/// Obtains a pointer to the system table.
58
35
///
59
36
/// This is meant to be used by higher-level libraries,
@@ -63,9 +40,9 @@ fn system_table_opt() -> Option<SystemTable<Boot>> {
63
40
///
64
41
/// The returned pointer is only valid until boot services are exited.
65
42
#[ must_use]
66
- // TODO do we want to keep this public?
43
+ # [ deprecated ( note = "use uefi::table::system_table_boot instead" ) ]
67
44
pub 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 " )
69
46
}
70
47
71
48
/// Initialize all helpers defined in [`uefi::helpers`] whose Cargo features
@@ -77,15 +54,8 @@ pub fn system_table() -> SystemTable<Boot> {
77
54
/// **PLEASE NOTE** that these helpers are meant for the pre exit boot service
78
55
/// epoch. Limited functionality might work after exiting them, such as logging
79
56
/// to the debugcon device.
57
+ #[ allow( unused_variables) ] // `st` is unused if logger and allocator are disabled
80
58
pub 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
-
89
59
// Setup logging and memory allocation
90
60
91
61
#[ cfg( feature = "logger" ) ]
@@ -102,14 +72,6 @@ pub fn init(st: &mut SystemTable<Boot>) -> Result<()> {
102
72
}
103
73
104
74
pub ( 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
-
113
75
#[ cfg( feature = "logger" ) ]
114
76
logger:: disable ( ) ;
115
77
0 commit comments