@@ -116,7 +116,7 @@ pub unsafe fn raise_tpl(tpl: Tpl) -> TplGuard {
116
116
let bt = unsafe { bt. as_ref ( ) } ;
117
117
118
118
TplGuard {
119
- old_tpl : ( bt. raise_tpl ) ( tpl) ,
119
+ old_tpl : unsafe { ( bt. raise_tpl ) ( tpl) } ,
120
120
}
121
121
}
122
122
@@ -381,15 +381,17 @@ pub unsafe fn create_event(
381
381
382
382
// Safety: the argument types of the function pointers are defined
383
383
// differently, but are compatible and can be safely transmuted.
384
- let notify_fn: Option < uefi_raw:: table:: boot:: EventNotifyFn > = mem:: transmute ( notify_fn) ;
384
+ let notify_fn: Option < uefi_raw:: table:: boot:: EventNotifyFn > =
385
+ unsafe { mem:: transmute ( notify_fn) } ;
385
386
386
387
let notify_ctx = opt_nonnull_to_ptr ( notify_ctx) ;
387
388
388
389
// Now we're ready to call UEFI
389
- ( bt. create_event ) ( event_ty, notify_tpl, notify_fn, notify_ctx, & mut event) . to_result_with_val (
390
- // OK to unwrap: event is non-null for Status::SUCCESS.
391
- || Event :: from_ptr ( event) . unwrap ( ) ,
392
- )
390
+ unsafe { ( bt. create_event ) ( event_ty, notify_tpl, notify_fn, notify_ctx, & mut event) }
391
+ . to_result_with_val (
392
+ // OK to unwrap: event is non-null for Status::SUCCESS.
393
+ || unsafe { Event :: from_ptr ( event) } . unwrap ( ) ,
394
+ )
393
395
}
394
396
395
397
/// Creates an event in an event group.
@@ -451,19 +453,22 @@ pub unsafe fn create_event_ex(
451
453
452
454
// Safety: the argument types of the function pointers are defined
453
455
// differently, but are compatible and can be safely transmuted.
454
- let notify_fn: Option < uefi_raw:: table:: boot:: EventNotifyFn > = mem:: transmute ( notify_fn) ;
455
-
456
- ( bt. create_event_ex ) (
457
- event_type,
458
- notify_tpl,
459
- notify_fn,
460
- opt_nonnull_to_ptr ( notify_ctx) ,
461
- opt_nonnull_to_ptr ( event_group) ,
462
- & mut event,
463
- )
456
+ let notify_fn: Option < uefi_raw:: table:: boot:: EventNotifyFn > =
457
+ unsafe { mem:: transmute ( notify_fn) } ;
458
+
459
+ unsafe {
460
+ ( bt. create_event_ex ) (
461
+ event_type,
462
+ notify_tpl,
463
+ notify_fn,
464
+ opt_nonnull_to_ptr ( notify_ctx) ,
465
+ opt_nonnull_to_ptr ( event_group) ,
466
+ & mut event,
467
+ )
468
+ }
464
469
. to_result_with_val (
465
470
// OK to unwrap: event is non-null for Status::SUCCESS.
466
- || Event :: from_ptr ( event) . unwrap ( ) ,
471
+ || unsafe { Event :: from_ptr ( event) } . unwrap ( ) ,
467
472
)
468
473
}
469
474
@@ -696,13 +701,15 @@ pub unsafe fn install_protocol_interface(
696
701
let bt = unsafe { bt. as_ref ( ) } ;
697
702
698
703
let mut handle = Handle :: opt_to_ptr ( handle) ;
699
- ( ( bt. install_protocol_interface ) (
700
- & mut handle,
701
- protocol,
702
- InterfaceType :: NATIVE_INTERFACE ,
703
- interface,
704
- ) )
705
- . to_result_with_val ( || Handle :: from_ptr ( handle) . unwrap ( ) )
704
+ unsafe {
705
+ ( bt. install_protocol_interface ) (
706
+ & mut handle,
707
+ protocol,
708
+ InterfaceType :: NATIVE_INTERFACE ,
709
+ interface,
710
+ )
711
+ }
712
+ . to_result_with_val ( || unsafe { Handle :: from_ptr ( handle) } . unwrap ( ) )
706
713
}
707
714
708
715
/// Reinstalls a protocol interface on a device handle. `old_interface` is replaced with `new_interface`.
@@ -730,8 +737,10 @@ pub unsafe fn reinstall_protocol_interface(
730
737
let bt = boot_services_raw_panicking ( ) ;
731
738
let bt = unsafe { bt. as_ref ( ) } ;
732
739
733
- ( bt. reinstall_protocol_interface ) ( handle. as_ptr ( ) , protocol, old_interface, new_interface)
734
- . to_result ( )
740
+ unsafe {
741
+ ( bt. reinstall_protocol_interface ) ( handle. as_ptr ( ) , protocol, old_interface, new_interface)
742
+ }
743
+ . to_result ( )
735
744
}
736
745
737
746
/// Removes a protocol interface from a device handle.
@@ -757,7 +766,7 @@ pub unsafe fn uninstall_protocol_interface(
757
766
let bt = boot_services_raw_panicking ( ) ;
758
767
let bt = unsafe { bt. as_ref ( ) } ;
759
768
760
- ( bt. uninstall_protocol_interface ) ( handle. as_ptr ( ) , protocol, interface) . to_result ( )
769
+ unsafe { ( bt. uninstall_protocol_interface ) ( handle. as_ptr ( ) , protocol, interface) . to_result ( ) }
761
770
}
762
771
763
772
/// Registers `event` to be signaled whenever a protocol interface is registered for
@@ -1035,19 +1044,21 @@ pub unsafe fn open_protocol<P: ProtocolPointer + ?Sized>(
1035
1044
let bt = unsafe { bt. as_ref ( ) } ;
1036
1045
1037
1046
let mut interface = ptr:: null_mut ( ) ;
1038
- ( bt. open_protocol ) (
1039
- params. handle . as_ptr ( ) ,
1040
- & P :: GUID ,
1041
- & mut interface,
1042
- params. agent . as_ptr ( ) ,
1043
- Handle :: opt_to_ptr ( params. controller ) ,
1044
- attributes as u32 ,
1045
- )
1047
+ unsafe {
1048
+ ( bt. open_protocol ) (
1049
+ params. handle . as_ptr ( ) ,
1050
+ & P :: GUID ,
1051
+ & mut interface,
1052
+ params. agent . as_ptr ( ) ,
1053
+ Handle :: opt_to_ptr ( params. controller ) ,
1054
+ attributes as u32 ,
1055
+ )
1056
+ }
1046
1057
. to_result_with_val ( || {
1047
1058
let interface = if interface. is_null ( ) {
1048
1059
None
1049
1060
} else {
1050
- NonNull :: new ( P :: mut_ptr_from_ffi ( interface) )
1061
+ NonNull :: new ( unsafe { P :: mut_ptr_from_ffi ( interface) } )
1051
1062
} ;
1052
1063
ScopedProtocol {
1053
1064
interface,
@@ -1220,12 +1231,14 @@ pub unsafe fn exit(
1220
1231
let bt = boot_services_raw_panicking ( ) ;
1221
1232
let bt = unsafe { bt. as_ref ( ) } ;
1222
1233
1223
- ( bt. exit ) (
1224
- image_handle. as_ptr ( ) ,
1225
- exit_status,
1226
- exit_data_size,
1227
- exit_data. cast ( ) ,
1228
- )
1234
+ unsafe {
1235
+ ( bt. exit ) (
1236
+ image_handle. as_ptr ( ) ,
1237
+ exit_status,
1238
+ exit_data_size,
1239
+ exit_data. cast ( ) ,
1240
+ )
1241
+ }
1229
1242
}
1230
1243
1231
1244
/// Get the current memory map and exit boot services.
@@ -1241,7 +1254,7 @@ unsafe fn get_memory_map_and_exit_boot_services(buf: &mut [u8]) -> Result<Memory
1241
1254
// what boot services functions can be called. In UEFI 2.8 and earlier,
1242
1255
// only `get_memory_map` and `exit_boot_services` are allowed. Starting
1243
1256
// in UEFI 2.9 other memory allocation functions may also be called.
1244
- ( bt. exit_boot_services ) ( image_handle ( ) . as_ptr ( ) , memory_map. map_key . 0 )
1257
+ unsafe { ( bt. exit_boot_services ) ( image_handle ( ) . as_ptr ( ) , memory_map. map_key . 0 ) }
1245
1258
. to_result_with_val ( || memory_map)
1246
1259
}
1247
1260
@@ -1344,7 +1357,7 @@ pub unsafe fn install_configuration_table(
1344
1357
let bt = boot_services_raw_panicking ( ) ;
1345
1358
let bt = unsafe { bt. as_ref ( ) } ;
1346
1359
1347
- ( bt. install_configuration_table ) ( guid_entry, table_ptr) . to_result ( )
1360
+ unsafe { ( bt. install_configuration_table ) ( guid_entry, table_ptr) } . to_result ( )
1348
1361
}
1349
1362
1350
1363
/// Sets the watchdog timer.
0 commit comments