@@ -98,23 +98,26 @@ pub struct BootServices {
98
98
restore_tpl : unsafe extern "efiapi" fn ( old_tpl : Tpl ) ,
99
99
100
100
// Memory allocation functions
101
- allocate_pages : extern "efiapi" fn (
101
+ allocate_pages : unsafe extern "efiapi" fn (
102
102
alloc_ty : u32 ,
103
103
mem_ty : MemoryType ,
104
104
count : usize ,
105
105
addr : & mut PhysicalAddress ,
106
106
) -> Status ,
107
- free_pages : extern "efiapi" fn ( addr : PhysicalAddress , pages : usize ) -> Status ,
107
+ free_pages : unsafe extern "efiapi" fn ( addr : PhysicalAddress , pages : usize ) -> Status ,
108
108
get_memory_map : unsafe extern "efiapi" fn (
109
109
size : & mut usize ,
110
110
map : * mut MemoryDescriptor ,
111
111
key : & mut MemoryMapKey ,
112
112
desc_size : & mut usize ,
113
113
desc_version : & mut u32 ,
114
114
) -> Status ,
115
- allocate_pool :
116
- extern "efiapi" fn ( pool_type : MemoryType , size : usize , buffer : & mut * mut u8 ) -> Status ,
117
- free_pool : extern "efiapi" fn ( buffer : * mut u8 ) -> Status ,
115
+ allocate_pool : unsafe extern "efiapi" fn (
116
+ pool_type : MemoryType ,
117
+ size : usize ,
118
+ buffer : & mut * mut u8 ,
119
+ ) -> Status ,
120
+ free_pool : unsafe extern "efiapi" fn ( buffer : * mut u8 ) -> Status ,
118
121
119
122
// Event & timer functions
120
123
create_event : unsafe extern "efiapi" fn (
@@ -130,7 +133,7 @@ pub struct BootServices {
130
133
events : * mut Event ,
131
134
out_index : * mut usize ,
132
135
) -> Status ,
133
- signal_event : extern "efiapi" fn ( event : Event ) -> Status ,
136
+ signal_event : unsafe extern "efiapi" fn ( event : Event ) -> Status ,
134
137
close_event : unsafe extern "efiapi" fn ( event : Event ) -> Status ,
135
138
check_event : unsafe extern "efiapi" fn ( event : Event ) -> Status ,
136
139
@@ -153,10 +156,13 @@ pub struct BootServices {
153
156
interface : * mut c_void ,
154
157
) -> Status ,
155
158
#[ deprecated = "open_protocol and open_protocol_exclusive are better alternatives and available since EFI 1.10 (2002)" ]
156
- handle_protocol :
157
- extern "efiapi" fn ( handle : Handle , proto : & Guid , out_proto : & mut * mut c_void ) -> Status ,
159
+ handle_protocol : unsafe extern "efiapi" fn (
160
+ handle : Handle ,
161
+ proto : & Guid ,
162
+ out_proto : & mut * mut c_void ,
163
+ ) -> Status ,
158
164
_reserved : usize ,
159
- register_protocol_notify : extern "efiapi" fn (
165
+ register_protocol_notify : unsafe extern "efiapi" fn (
160
166
protocol : & Guid ,
161
167
event : Event ,
162
168
registration : * mut Option < ProtocolSearchKey > ,
@@ -174,7 +180,7 @@ pub struct BootServices {
174
180
out_handle : & mut Option < Handle > ,
175
181
) -> Status ,
176
182
install_configuration_table :
177
- extern "efiapi" fn ( guid_entry : & Guid , table_ptr : * const c_void ) -> Status ,
183
+ unsafe extern "efiapi" fn ( guid_entry : & Guid , table_ptr : * const c_void ) -> Status ,
178
184
179
185
// Image services
180
186
load_image : unsafe extern "efiapi" fn (
@@ -190,19 +196,19 @@ pub struct BootServices {
190
196
exit_data_size : * mut usize ,
191
197
exit_data : & mut * mut Char16 ,
192
198
) -> Status ,
193
- exit : extern "efiapi" fn (
199
+ exit : unsafe extern "efiapi" fn (
194
200
image_handle : Handle ,
195
201
exit_status : Status ,
196
202
exit_data_size : usize ,
197
203
exit_data : * mut Char16 ,
198
204
) -> !,
199
- unload_image : extern "efiapi" fn ( image_handle : Handle ) -> Status ,
205
+ unload_image : unsafe extern "efiapi" fn ( image_handle : Handle ) -> Status ,
200
206
exit_boot_services :
201
207
unsafe extern "efiapi" fn ( image_handle : Handle , map_key : MemoryMapKey ) -> Status ,
202
208
203
209
// Misc services
204
210
get_next_monotonic_count : usize ,
205
- stall : extern "efiapi" fn ( microseconds : usize ) -> Status ,
211
+ stall : unsafe extern "efiapi" fn ( microseconds : usize ) -> Status ,
206
212
set_watchdog_timer : unsafe extern "efiapi" fn (
207
213
timeout : usize ,
208
214
watchdog_code : u64 ,
@@ -224,15 +230,15 @@ pub struct BootServices {
224
230
) -> Status ,
225
231
226
232
// Protocol open / close services
227
- open_protocol : extern "efiapi" fn (
233
+ open_protocol : unsafe extern "efiapi" fn (
228
234
handle : Handle ,
229
235
protocol : & Guid ,
230
236
interface : & mut * mut c_void ,
231
237
agent_handle : Handle ,
232
238
controller_handle : Option < Handle > ,
233
239
attributes : u32 ,
234
240
) -> Status ,
235
- close_protocol : extern "efiapi" fn (
241
+ close_protocol : unsafe extern "efiapi" fn (
236
242
handle : Handle ,
237
243
protocol : & Guid ,
238
244
agent_handle : Handle ,
@@ -254,7 +260,7 @@ pub struct BootServices {
254
260
buf : & mut * mut Handle ,
255
261
) -> Status ,
256
262
#[ deprecated = "open_protocol and open_protocol_exclusive are better alternatives and available since EFI 1.10 (2002)" ]
257
- locate_protocol : extern "efiapi" fn (
263
+ locate_protocol : unsafe extern "efiapi" fn (
258
264
proto : & Guid ,
259
265
registration : * mut c_void ,
260
266
out_proto : & mut * mut c_void ,
@@ -367,7 +373,7 @@ impl BootServices {
367
373
AllocateType :: MaxAddress ( addr) => ( 1 , addr) ,
368
374
AllocateType :: Address ( addr) => ( 2 , addr) ,
369
375
} ;
370
- ( self . allocate_pages ) ( ty, mem_ty, count, & mut addr) . to_result_with_val ( || addr)
376
+ unsafe { ( self . allocate_pages ) ( ty, mem_ty, count, & mut addr) } . to_result_with_val ( || addr)
371
377
}
372
378
373
379
/// Frees memory pages allocated by UEFI.
@@ -379,7 +385,7 @@ impl BootServices {
379
385
/// * [`uefi::Status::NOT_FOUND`]
380
386
/// * [`uefi::Status::INVALID_PARAMETER`]
381
387
pub fn free_pages ( & self , addr : PhysicalAddress , count : usize ) -> Result {
382
- ( self . free_pages ) ( addr, count) . to_result ( )
388
+ unsafe { ( self . free_pages ) ( addr, count) } . to_result ( )
383
389
}
384
390
385
391
/// Returns struct which contains the size of a single memory descriptor
@@ -476,7 +482,7 @@ impl BootServices {
476
482
/// * [`uefi::Status::INVALID_PARAMETER`]
477
483
pub fn allocate_pool ( & self , mem_ty : MemoryType , size : usize ) -> Result < * mut u8 > {
478
484
let mut buffer = ptr:: null_mut ( ) ;
479
- ( self . allocate_pool ) ( mem_ty, size, & mut buffer) . to_result_with_val ( || buffer)
485
+ unsafe { ( self . allocate_pool ) ( mem_ty, size, & mut buffer) } . to_result_with_val ( || buffer)
480
486
}
481
487
482
488
/// Frees memory allocated from a pool.
@@ -486,8 +492,9 @@ impl BootServices {
486
492
/// See section `EFI_BOOT_SERVICES.FreePool()` in the UEFI Specification for more details.
487
493
///
488
494
/// * [`uefi::Status::INVALID_PARAMETER`]
495
+ #[ allow( clippy:: not_unsafe_ptr_arg_deref) ]
489
496
pub fn free_pool ( & self , addr : * mut u8 ) -> Result {
490
- ( self . free_pool ) ( addr) . to_result ( )
497
+ unsafe { ( self . free_pool ) ( addr) } . to_result ( )
491
498
}
492
499
493
500
/// Creates an event
@@ -1068,7 +1075,7 @@ impl BootServices {
1068
1075
/// * [`uefi::Status::UNSUPPORTED`]
1069
1076
/// * [`uefi::Status::INVALID_PARAMETER`]
1070
1077
pub fn unload_image ( & self , image_handle : Handle ) -> Result {
1071
- ( self . unload_image ) ( image_handle) . to_result ( )
1078
+ unsafe { ( self . unload_image ) ( image_handle) } . to_result ( )
1072
1079
}
1073
1080
1074
1081
/// Transfer control to a loaded image's entry point.
@@ -1139,7 +1146,7 @@ impl BootServices {
1139
1146
///
1140
1147
/// The time is in microseconds.
1141
1148
pub fn stall ( & self , time : usize ) {
1142
- assert_eq ! ( ( self . stall) ( time) , Status :: SUCCESS ) ;
1149
+ assert_eq ! ( unsafe { ( self . stall) ( time) } , Status :: SUCCESS ) ;
1143
1150
}
1144
1151
1145
1152
/// Adds, updates, or removes a configuration table entry
@@ -1389,14 +1396,16 @@ impl BootServices {
1389
1396
) -> Result < ( ) > {
1390
1397
const TEST_PROTOCOL : u32 = 0x04 ;
1391
1398
let mut interface = ptr:: null_mut ( ) ;
1392
- ( self . open_protocol ) (
1393
- params. handle ,
1394
- & P :: GUID ,
1395
- & mut interface,
1396
- params. agent ,
1397
- params. controller ,
1398
- TEST_PROTOCOL ,
1399
- )
1399
+ unsafe {
1400
+ ( self . open_protocol ) (
1401
+ params. handle ,
1402
+ & P :: GUID ,
1403
+ & mut interface,
1404
+ params. agent ,
1405
+ params. controller ,
1406
+ TEST_PROTOCOL ,
1407
+ )
1408
+ }
1400
1409
. to_result_with_val ( || ( ) )
1401
1410
}
1402
1411
@@ -1818,12 +1827,14 @@ pub struct ScopedProtocol<'a, P: Protocol + ?Sized> {
1818
1827
1819
1828
impl < ' a , P : Protocol + ?Sized > Drop for ScopedProtocol < ' a , P > {
1820
1829
fn drop ( & mut self ) {
1821
- let status = ( self . boot_services . close_protocol ) (
1822
- self . open_params . handle ,
1823
- & P :: GUID ,
1824
- self . open_params . agent ,
1825
- self . open_params . controller ,
1826
- ) ;
1830
+ let status = unsafe {
1831
+ ( self . boot_services . close_protocol ) (
1832
+ self . open_params . handle ,
1833
+ & P :: GUID ,
1834
+ self . open_params . agent ,
1835
+ self . open_params . controller ,
1836
+ )
1837
+ } ;
1827
1838
// All of the error cases for close_protocol boil down to
1828
1839
// calling it with a different set of parameters than what was
1829
1840
// passed to open_protocol. The public API prevents such errors,
0 commit comments