@@ -32,41 +32,45 @@ pub unsafe fn init_globals(handle: NonNull<c_void>, system_table: NonNull<c_void
3232}
3333
3434/// Get the SystemTable Pointer.
35+ /// If you want to use `BootServices` then please use [`boot_services`] as it performs some
36+ /// additional checks.
37+ ///
3538/// Note: This function panics if the System Table or Image Handle is not initialized
3639pub fn system_table ( ) -> NonNull < c_void > {
3740 try_system_table ( ) . unwrap ( )
3841}
3942
4043/// Get the ImageHandle Pointer.
44+ ///
4145/// Note: This function panics if the System Table or Image Handle is not initialized
4246pub fn image_handle ( ) -> NonNull < c_void > {
4347 try_image_handle ( ) . unwrap ( )
4448}
4549
46- /// Get the SystemTable Pointer.
47- /// This function is mostly intended for places where panic is not an option
48- pub ( crate ) fn try_system_table ( ) -> Option < NonNull < crate :: ffi:: c_void > > {
49- GLOBALS . get ( ) . map ( |x| x. 0 )
50- }
51-
52- /// Get the SystemHandle Pointer.
53- /// This function is mostly intended for places where panic is not an option
54- pub ( crate ) fn try_image_handle ( ) -> Option < NonNull < crate :: ffi:: c_void > > {
55- GLOBALS . get ( ) . map ( |x| x. 1 )
56- }
57-
5850/// Get the BootServices Pointer.
5951/// This function also checks if `ExitBootServices` has already been called.
60- pub ( crate ) fn boot_services ( ) -> Option < NonNull < r_efi :: efi :: BootServices > > {
52+ pub fn boot_services ( ) -> Option < NonNull < c_void > > {
6153 if BOOT_SERVICES_FLAG . get ( ) {
6254 let system_table: NonNull < r_efi:: efi:: SystemTable > = try_system_table ( ) ?. cast ( ) ;
6355 let boot_services = unsafe { ( * system_table. as_ptr ( ) ) . boot_services } ;
64- NonNull :: new ( boot_services)
56+ NonNull :: new ( boot_services) . map ( |x| x . cast ( ) )
6557 } else {
6658 None
6759 }
6860}
6961
62+ /// Get the SystemTable Pointer.
63+ /// This function is mostly intended for places where panic is not an option
64+ pub ( crate ) fn try_system_table ( ) -> Option < NonNull < c_void > > {
65+ GLOBALS . get ( ) . map ( |x| x. 0 )
66+ }
67+
68+ /// Get the SystemHandle Pointer.
69+ /// This function is mostly intended for places where panic is not an option
70+ pub ( crate ) fn try_image_handle ( ) -> Option < NonNull < c_void > > {
71+ GLOBALS . get ( ) . map ( |x| x. 1 )
72+ }
73+
7074pub ( crate ) fn enable_boot_services ( ) {
7175 BOOT_SERVICES_FLAG . set ( true ) ;
7276}
0 commit comments