@@ -37,42 +37,40 @@ pub unsafe fn set_system_table(ptr: *const uefi_raw::table::system::SystemTable)
37
37
///
38
38
/// # Panics
39
39
///
40
- /// Panics if the system table has not been set with `set_system_table`, or if
41
- /// boot services are not available (e.g. if [`exit_boot_services`] has been
42
- /// called).
40
+ /// Panics if the system table has not been set with [`set_system_table`].
43
41
///
44
42
/// [`exit_boot_services`]: SystemTable::exit_boot_services
45
- pub fn system_table_boot ( ) -> SystemTable < Boot > {
43
+ pub fn system_table_boot ( ) -> Option < SystemTable < Boot > > {
46
44
let st = SYSTEM_TABLE . load ( Ordering :: Acquire ) ;
47
45
assert ! ( !st. is_null( ) ) ;
48
46
49
47
// SAFETY: the system table is valid per the requirements of `set_system_table`.
50
48
unsafe {
51
49
if ( * st) . boot_services . is_null ( ) {
52
- panic ! ( "boot services are not active" ) ;
50
+ None
51
+ } else {
52
+ Some ( SystemTable :: < Boot > :: from_ptr ( st. cast ( ) ) . unwrap ( ) )
53
53
}
54
-
55
- SystemTable :: < Boot > :: from_ptr ( st. cast ( ) ) . unwrap ( )
56
54
}
57
55
}
58
56
59
- /// Get the system table while runtime services are active.
57
+ /// Get the system table while runtime services are active. This only returns
58
+ /// `Some` after boot services have been exited.
60
59
///
61
60
/// # Panics
62
61
///
63
- /// Panics if the system table has not been set with `set_system_table`, or if
64
- /// runtime services are not available.
65
- pub fn system_table_runtime ( ) -> SystemTable < Runtime > {
62
+ /// Panics if the system table has not been set with [`set_system_table`].
63
+ pub fn system_table_runtime ( ) -> Option < SystemTable < Runtime > > {
66
64
let st = SYSTEM_TABLE . load ( Ordering :: Acquire ) ;
67
65
assert ! ( !st. is_null( ) ) ;
68
66
69
67
// SAFETY: the system table is valid per the requirements of `set_system_table`.
70
68
unsafe {
71
69
if ( * st) . runtime_services . is_null ( ) {
72
- panic ! ( "runtime services are not active" ) ;
70
+ None
71
+ } else {
72
+ Some ( SystemTable :: < Runtime > :: from_ptr ( st. cast ( ) ) . unwrap ( ) )
73
73
}
74
-
75
- SystemTable :: < Runtime > :: from_ptr ( st. cast ( ) ) . unwrap ( )
76
74
}
77
75
}
78
76
0 commit comments