@@ -19,13 +19,8 @@ use core::fmt::Debug;
19
19
use core:: mem:: { self , MaybeUninit } ;
20
20
use core:: ops:: { Deref , DerefMut } ;
21
21
use core:: ptr:: NonNull ;
22
- use core:: sync:: atomic:: { AtomicPtr , Ordering } ;
23
22
use core:: { ptr, slice} ;
24
23
25
- /// Global image handle. This is only set by `BootServices::set_image_handle`,
26
- /// and it is only read by `BootServices::image_handle`.
27
- static IMAGE_HANDLE : AtomicPtr < c_void > = AtomicPtr :: new ( ptr:: null_mut ( ) ) ;
28
-
29
24
/// Size in bytes of a UEFI page.
30
25
///
31
26
/// Note that this is not necessarily the processor's page size. The UEFI page
@@ -85,31 +80,19 @@ pub struct BootServices(uefi_raw::table::boot::BootServices);
85
80
impl BootServices {
86
81
/// Get the [`Handle`] of the currently-executing image.
87
82
pub fn image_handle ( & self ) -> Handle {
88
- let ptr = IMAGE_HANDLE . load ( Ordering :: Acquire ) ;
89
- // Safety: the image handle must be valid. We know it is, because it was
90
- // set by `set_image_handle`, which has that same safety requirement.
91
- unsafe { Handle :: from_ptr ( ptr) } . expect ( "set_image_handle has not been called" )
83
+ uefi:: boot:: image_handle ( )
92
84
}
93
85
94
86
/// Update the global image [`Handle`].
95
87
///
96
- /// This is called automatically in the `main` entry point as part
97
- /// of [`uefi::entry`]. It should not be called at any other
98
- /// point in time, unless the executable does not use
99
- /// [`uefi::entry`], in which case it should be called once
100
- /// before calling other `BootServices` functions.
88
+ /// This is the same as calling [`uefi::boot::set_image_handle`]. See that
89
+ /// function for details.
101
90
///
102
91
/// # Safety
103
92
///
104
- /// This function should only be called as described above,
105
- /// and the `image_handle` must be a valid image [`Handle`]. Then
106
- /// safety guarantees of [`BootServices::open_protocol_exclusive`]
107
- /// rely on the global image handle being correct.
93
+ /// See [`uefi::boot::set_image_handle`] for safety requirements.
108
94
pub unsafe fn set_image_handle ( & self , image_handle : Handle ) {
109
- // As with `image_handle`, `&self` isn't actually used, but it
110
- // enforces that this function is only called while boot
111
- // services are active.
112
- IMAGE_HANDLE . store ( image_handle. as_ptr ( ) , Ordering :: Release ) ;
95
+ uefi:: boot:: set_image_handle ( image_handle)
113
96
}
114
97
115
98
/// Raises a task's priority level and returns its previous level.
0 commit comments