@@ -94,7 +94,7 @@ struct BootServicesInternal {
94
94
95
95
// Protocol handlers
96
96
install_protocol_interface : unsafe extern "efiapi" fn (
97
- handle : & mut Option < Handle > ,
97
+ handle : * mut uefi_raw :: Handle ,
98
98
guid : & Guid ,
99
99
interface_type : InterfaceType ,
100
100
interface : * mut c_void ,
@@ -127,12 +127,12 @@ struct BootServicesInternal {
127
127
proto : Option < & Guid > ,
128
128
key : Option < ProtocolSearchKey > ,
129
129
buf_sz : & mut usize ,
130
- buf : * mut MaybeUninit < Handle > ,
130
+ buf : * mut uefi_raw :: Handle ,
131
131
) -> Status ,
132
132
locate_device_path : unsafe extern "efiapi" fn (
133
133
proto : & Guid ,
134
134
device_path : * mut * const uefi_raw:: protocol:: device_path:: DevicePathProtocol ,
135
- out_handle : & mut Option < Handle > ,
135
+ out_handle : * mut uefi_raw :: Handle ,
136
136
) -> Status ,
137
137
install_configuration_table :
138
138
unsafe extern "efiapi" fn ( guid_entry : & Guid , table_ptr : * const c_void ) -> Status ,
@@ -144,7 +144,7 @@ struct BootServicesInternal {
144
144
device_path : * const uefi_raw:: protocol:: device_path:: DevicePathProtocol ,
145
145
source_buffer : * const u8 ,
146
146
source_size : usize ,
147
- image_handle : & mut Option < Handle > ,
147
+ image_handle : * mut uefi_raw :: Handle ,
148
148
) -> Status ,
149
149
start_image : unsafe extern "efiapi" fn (
150
150
image_handle : uefi_raw:: Handle ,
@@ -174,14 +174,14 @@ struct BootServicesInternal {
174
174
// Driver support services
175
175
connect_controller : unsafe extern "efiapi" fn (
176
176
controller : uefi_raw:: Handle ,
177
- driver_image : Option < Handle > ,
177
+ driver_image : uefi_raw :: Handle ,
178
178
remaining_device_path : * const uefi_raw:: protocol:: device_path:: DevicePathProtocol ,
179
179
recursive : bool ,
180
180
) -> Status ,
181
181
disconnect_controller : unsafe extern "efiapi" fn (
182
182
controller : uefi_raw:: Handle ,
183
- driver_image : Option < Handle > ,
184
- child : Option < Handle > ,
183
+ driver_image : uefi_raw :: Handle ,
184
+ child : uefi_raw :: Handle ,
185
185
) -> Status ,
186
186
187
187
// Protocol open / close services
@@ -190,14 +190,14 @@ struct BootServicesInternal {
190
190
protocol : & Guid ,
191
191
interface : & mut * mut c_void ,
192
192
agent_handle : uefi_raw:: Handle ,
193
- controller_handle : Option < Handle > ,
193
+ controller_handle : uefi_raw :: Handle ,
194
194
attributes : u32 ,
195
195
) -> Status ,
196
196
close_protocol : unsafe extern "efiapi" fn (
197
197
handle : uefi_raw:: Handle ,
198
198
protocol : & Guid ,
199
199
agent_handle : uefi_raw:: Handle ,
200
- controller_handle : Option < Handle > ,
200
+ controller_handle : uefi_raw :: Handle ,
201
201
) -> Status ,
202
202
open_protocol_information : usize ,
203
203
@@ -212,7 +212,7 @@ struct BootServicesInternal {
212
212
proto : Option < & Guid > ,
213
213
key : Option < ProtocolSearchKey > ,
214
214
no_handles : & mut usize ,
215
- buf : & mut * mut Handle ,
215
+ buf : * mut * mut uefi_raw :: Handle ,
216
216
) -> Status ,
217
217
#[ deprecated = "open_protocol and open_protocol_exclusive are better alternatives and available since EFI 1.10 (2002)" ]
218
218
locate_protocol : unsafe extern "efiapi" fn (
@@ -756,19 +756,18 @@ impl BootServices {
756
756
/// * [`uefi::Status::INVALID_PARAMETER`]
757
757
pub unsafe fn install_protocol_interface (
758
758
& self ,
759
- mut handle : Option < Handle > ,
759
+ handle : Option < Handle > ,
760
760
protocol : & Guid ,
761
761
interface : * mut c_void ,
762
762
) -> Result < Handle > {
763
+ let mut handle = Handle :: opt_to_ptr ( handle) ;
763
764
( ( self . 0 . install_protocol_interface ) (
764
765
& mut handle,
765
766
protocol,
766
767
InterfaceType :: NATIVE_INTERFACE ,
767
768
interface,
768
769
) )
769
- // this `unwrapped_unchecked` is safe, `handle` is guaranteed to be Some() if this call is
770
- // successful
771
- . to_result_with_val ( || handle. unwrap_unchecked ( ) )
770
+ . to_result_with_val ( || Handle :: from_ptr ( handle) . unwrap ( ) )
772
771
}
773
772
774
773
/// Reinstalls a protocol interface on a device handle. `old_interface` is replaced with `new_interface`.
@@ -903,7 +902,8 @@ impl BootServices {
903
902
SearchType :: ByProtocol ( guid) => ( 2 , Some ( guid) , None ) ,
904
903
} ;
905
904
906
- let status = unsafe { ( self . 0 . locate_handle ) ( ty, guid, key, & mut buffer_size, buffer) } ;
905
+ let status =
906
+ unsafe { ( self . 0 . locate_handle ) ( ty, guid, key, & mut buffer_size, buffer. cast ( ) ) } ;
907
907
908
908
// Must convert the returned size (in bytes) to length (number of elements).
909
909
let buffer_len = buffer_size / handle_size;
@@ -935,15 +935,15 @@ impl BootServices {
935
935
& self ,
936
936
device_path : & mut & DevicePath ,
937
937
) -> Result < Handle > {
938
- let mut handle = None ;
938
+ let mut handle = ptr :: null_mut ( ) ;
939
939
let mut device_path_ptr: * const uefi_raw:: protocol:: device_path:: DevicePathProtocol =
940
940
device_path. as_ffi_ptr ( ) . cast ( ) ;
941
941
unsafe {
942
942
( self . 0 . locate_device_path ) ( & P :: GUID , & mut device_path_ptr, & mut handle)
943
943
. to_result_with_val ( || {
944
944
* device_path = DevicePath :: from_ffi_ptr ( device_path_ptr. cast ( ) ) ;
945
945
// OK to unwrap: handle is non-null for Status::SUCCESS.
946
- handle. unwrap ( )
946
+ Handle :: from_ptr ( handle) . unwrap ( )
947
947
} )
948
948
}
949
949
}
@@ -1056,7 +1056,7 @@ impl BootServices {
1056
1056
}
1057
1057
} ;
1058
1058
1059
- let mut image_handle = None ;
1059
+ let mut image_handle = ptr :: null_mut ( ) ;
1060
1060
unsafe {
1061
1061
( self . 0 . load_image ) (
1062
1062
boot_policy,
@@ -1068,7 +1068,7 @@ impl BootServices {
1068
1068
)
1069
1069
. to_result_with_val (
1070
1070
// OK to unwrap: image handle is non-null for Status::SUCCESS.
1071
- || image_handle. unwrap ( ) ,
1071
+ || Handle :: from_ptr ( image_handle) . unwrap ( ) ,
1072
1072
)
1073
1073
}
1074
1074
}
@@ -1268,7 +1268,7 @@ impl BootServices {
1268
1268
unsafe {
1269
1269
( self . 0 . connect_controller ) (
1270
1270
controller. as_ptr ( ) ,
1271
- driver_image,
1271
+ Handle :: opt_to_ptr ( driver_image) ,
1272
1272
remaining_device_path
1273
1273
. map ( |dp| dp. as_ffi_ptr ( ) )
1274
1274
. unwrap_or ( ptr:: null ( ) )
@@ -1296,8 +1296,14 @@ impl BootServices {
1296
1296
driver_image : Option < Handle > ,
1297
1297
child : Option < Handle > ,
1298
1298
) -> Result {
1299
- unsafe { ( self . 0 . disconnect_controller ) ( controller. as_ptr ( ) , driver_image, child) }
1300
- . to_result_with_err ( |_| ( ) )
1299
+ unsafe {
1300
+ ( self . 0 . disconnect_controller ) (
1301
+ controller. as_ptr ( ) ,
1302
+ Handle :: opt_to_ptr ( driver_image) ,
1303
+ Handle :: opt_to_ptr ( child) ,
1304
+ )
1305
+ }
1306
+ . to_result_with_err ( |_| ( ) )
1301
1307
}
1302
1308
1303
1309
/// Open a protocol interface for a handle.
@@ -1353,7 +1359,7 @@ impl BootServices {
1353
1359
& P :: GUID ,
1354
1360
& mut interface,
1355
1361
params. agent . as_ptr ( ) ,
1356
- params. controller ,
1362
+ Handle :: opt_to_ptr ( params. controller ) ,
1357
1363
attributes as u32 ,
1358
1364
)
1359
1365
. to_result_with_val ( || {
@@ -1424,7 +1430,7 @@ impl BootServices {
1424
1430
& P :: GUID ,
1425
1431
& mut interface,
1426
1432
params. agent . as_ptr ( ) ,
1427
- params. controller ,
1433
+ Handle :: opt_to_ptr ( params. controller ) ,
1428
1434
TEST_PROTOCOL ,
1429
1435
)
1430
1436
}
@@ -1479,7 +1485,7 @@ impl BootServices {
1479
1485
/// * [`uefi::Status::OUT_OF_RESOURCES`]
1480
1486
pub fn locate_handle_buffer ( & self , search_ty : SearchType ) -> Result < HandleBuffer > {
1481
1487
let mut num_handles: usize = 0 ;
1482
- let mut buffer: * mut Handle = ptr:: null_mut ( ) ;
1488
+ let mut buffer: * mut uefi_raw :: Handle = ptr:: null_mut ( ) ;
1483
1489
1484
1490
// Obtain the needed data from the parameters.
1485
1491
let ( ty, guid, key) = match search_ty {
@@ -1492,7 +1498,7 @@ impl BootServices {
1492
1498
. to_result_with_val ( || HandleBuffer {
1493
1499
boot_services : self ,
1494
1500
count : num_handles,
1495
- buffer,
1501
+ buffer : buffer . cast ( ) ,
1496
1502
} )
1497
1503
}
1498
1504
@@ -1872,7 +1878,7 @@ impl<'a, P: Protocol + ?Sized> Drop for ScopedProtocol<'a, P> {
1872
1878
self . open_params . handle . as_ptr ( ) ,
1873
1879
& P :: GUID ,
1874
1880
self . open_params . agent . as_ptr ( ) ,
1875
- self . open_params . controller ,
1881
+ Handle :: opt_to_ptr ( self . open_params . controller ) ,
1876
1882
)
1877
1883
} ;
1878
1884
// All of the error cases for close_protocol boil down to
0 commit comments