@@ -17,20 +17,10 @@ pub(crate) fn get_current_handle_protocol<T>(protocol_guid: Guid) -> Option<NonN
17
17
18
18
#[ repr( transparent) ]
19
19
pub ( crate ) struct Event {
20
- inner : NonNull < crate :: ffi :: c_void > ,
20
+ inner : r_efi :: efi :: Event ,
21
21
}
22
22
23
23
impl Event {
24
- #[ inline]
25
- fn new ( inner : NonNull < crate :: ffi:: c_void > ) -> Self {
26
- Self { inner }
27
- }
28
-
29
- #[ inline]
30
- fn from_raw_event ( ptr : r_efi:: efi:: Event ) -> Option < Self > {
31
- Some ( Self :: new ( NonNull :: new ( ptr) ?) )
32
- }
33
-
34
24
pub ( crate ) fn create (
35
25
event_type : u32 ,
36
26
event_tpl : Tpl ,
@@ -55,12 +45,7 @@ impl Event {
55
45
)
56
46
} ;
57
47
58
- if r. is_error ( ) {
59
- Err ( status_to_io_error ( r) )
60
- } else {
61
- Self :: from_raw_event ( event)
62
- . ok_or ( const_io_error ! ( io:: ErrorKind :: Other , "event is null" ) )
63
- }
48
+ if r. is_error ( ) { Err ( status_to_io_error ( r) ) } else { Ok ( Self { inner : event } ) }
64
49
}
65
50
66
51
pub ( crate ) fn create_timer ( ) -> io:: Result < Event > {
@@ -117,17 +102,17 @@ impl Event {
117
102
118
103
#[ inline]
119
104
pub ( crate ) fn as_raw_event ( & self ) -> r_efi:: efi:: Event {
120
- self . inner . as_ptr ( )
105
+ self . inner
121
106
}
122
107
}
123
108
124
- extern "efiapi" fn empty_notify ( _: r_efi:: efi:: Event , _: * mut crate :: ffi:: c_void ) { }
109
+ pub ( crate ) extern "efiapi" fn empty_notify ( _: r_efi:: efi:: Event , _: * mut crate :: ffi:: c_void ) { }
125
110
126
111
impl Drop for Event {
127
112
fn drop ( & mut self ) {
128
113
let boot_services = boot_services ( ) ;
129
114
// Always returns EFI_SUCCESS
130
- let _ = unsafe { ( ( * boot_services. as_ptr ( ) ) . close_event ) ( self . inner . as_ptr ( ) ) } ;
115
+ let _ = unsafe { ( ( * boot_services. as_ptr ( ) ) . close_event ) ( self . inner ) } ;
131
116
}
132
117
}
133
118
@@ -296,109 +281,164 @@ pub(crate) fn status_to_io_error(s: r_efi::efi::Status) -> io::Error {
296
281
use r_efi:: efi:: Status ;
297
282
298
283
// Keep the List in Alphabetical Order
284
+ // The Messages are taken from UEFI Specification Appendix D - Status Codes
299
285
match s {
300
286
Status :: ABORTED => {
301
- const_io_error ! ( ErrorKind :: ConnectionAborted , "EFI_ABORTED " )
287
+ const_io_error ! ( ErrorKind :: ConnectionAborted , "The operation was aborted. " )
302
288
}
303
289
Status :: ACCESS_DENIED => {
304
- const_io_error ! ( ErrorKind :: PermissionDenied , "EFI_ACCESS_DENIED " )
290
+ const_io_error ! ( ErrorKind :: PermissionDenied , "Access was denied. " )
305
291
}
306
292
Status :: ALREADY_STARTED => {
307
- const_io_error ! ( ErrorKind :: Other , "EFI_ALREADY_STARTED " )
293
+ const_io_error ! ( ErrorKind :: Other , "The protocol has already been started. " )
308
294
}
309
295
Status :: BAD_BUFFER_SIZE => {
310
- const_io_error ! ( ErrorKind :: InvalidData , "EFI_BAD_BUFFER_SIZE" )
296
+ const_io_error ! (
297
+ ErrorKind :: InvalidData ,
298
+ "The buffer was not the proper size for the request."
299
+ )
311
300
}
312
301
Status :: BUFFER_TOO_SMALL => {
313
- const_io_error ! ( ErrorKind :: FileTooLarge , "EFI_BUFFER_TOO_SMALL" )
302
+ const_io_error ! (
303
+ ErrorKind :: FileTooLarge ,
304
+ "The buffer is not large enough to hold the requested data. The required buffer size is returned in the appropriate parameter when this error occurs."
305
+ )
314
306
}
315
307
Status :: COMPROMISED_DATA => {
316
- const_io_error ! ( ErrorKind :: Other , "EFI_COMPRIMISED_DATA" )
308
+ const_io_error ! (
309
+ ErrorKind :: Other ,
310
+ "The security status of the data is unknown or compromised and the data must be updated or replaced to restore a valid security status."
311
+ )
317
312
}
318
313
Status :: CONNECTION_FIN => {
319
- const_io_error ! ( ErrorKind :: Other , "EFI_CONNECTION_FIN" )
314
+ const_io_error ! (
315
+ ErrorKind :: Other ,
316
+ "The receiving operation fails because the communication peer has closed the connection and there is no more data in the receive buffer of the instance."
317
+ )
320
318
}
321
319
Status :: CONNECTION_REFUSED => {
322
- const_io_error ! ( ErrorKind :: ConnectionRefused , "EFI_CONNECTION_REFUSED" )
320
+ const_io_error ! (
321
+ ErrorKind :: ConnectionRefused ,
322
+ "The receiving or transmission operation fails because this connection is refused."
323
+ )
323
324
}
324
325
Status :: CONNECTION_RESET => {
325
- const_io_error ! ( ErrorKind :: ConnectionReset , "EFI_CONNECTION_RESET" )
326
+ const_io_error ! (
327
+ ErrorKind :: ConnectionReset ,
328
+ "The connect fails because the connection is reset either by instance itself or the communication peer."
329
+ )
326
330
}
327
- Status :: CRC_ERROR => const_io_error ! ( ErrorKind :: InvalidData , "EFI_CRC_ERROR" ) ,
328
- Status :: DEVICE_ERROR => const_io_error ! ( ErrorKind :: Other , "EFI_DEVICE_ERROR" ) ,
331
+ Status :: CRC_ERROR => const_io_error ! ( ErrorKind :: Other , "A CRC error was detected." ) ,
332
+ Status :: DEVICE_ERROR => const_io_error ! (
333
+ ErrorKind :: Other ,
334
+ "The physical device reported an error while attempting the operation."
335
+ ) ,
329
336
Status :: END_OF_FILE => {
330
- const_io_error ! ( ErrorKind :: UnexpectedEof , "EFI_END_OF_FILE " )
337
+ const_io_error ! ( ErrorKind :: UnexpectedEof , "The end of the file was reached. " )
331
338
}
332
339
Status :: END_OF_MEDIA => {
333
- const_io_error ! ( ErrorKind :: UnexpectedEof , "EFI_END_OF_MEDIA " )
340
+ const_io_error ! ( ErrorKind :: Other , "Beginning or end of media was reached " )
334
341
}
335
342
Status :: HOST_UNREACHABLE => {
336
- const_io_error ! ( ErrorKind :: HostUnreachable , "EFI_HOST_UNREACHABLE " )
343
+ const_io_error ! ( ErrorKind :: HostUnreachable , "The remote host is not reachable. " )
337
344
}
338
345
Status :: HTTP_ERROR => {
339
- const_io_error ! ( ErrorKind :: NetworkUnreachable , "EFI_HTTP_ERROR " )
346
+ const_io_error ! ( ErrorKind :: Other , "A HTTP error occurred during the network operation. " )
340
347
}
341
348
Status :: ICMP_ERROR => {
342
- const_io_error ! ( ErrorKind :: Other , "EFI_ICMP_ERROR" )
349
+ const_io_error ! (
350
+ ErrorKind :: Other ,
351
+ "An ICMP error occurred during the network operation."
352
+ )
343
353
}
344
354
Status :: INCOMPATIBLE_VERSION => {
345
- const_io_error ! ( ErrorKind :: Other , "EFI_INCOMPATIBLE_VERSION" )
355
+ const_io_error ! (
356
+ ErrorKind :: Other ,
357
+ "The function encountered an internal version that was incompatible with a version requested by the caller."
358
+ )
346
359
}
347
360
Status :: INVALID_LANGUAGE => {
348
- const_io_error ! ( ErrorKind :: InvalidData , "EFI_INVALID_LANGUAGE " )
361
+ const_io_error ! ( ErrorKind :: InvalidData , "The language specified was invalid. " )
349
362
}
350
363
Status :: INVALID_PARAMETER => {
351
- const_io_error ! ( ErrorKind :: InvalidInput , "EFI_INVALID_PARAMETER " )
364
+ const_io_error ! ( ErrorKind :: InvalidInput , "A parameter was incorrect. " )
352
365
}
353
366
Status :: IP_ADDRESS_CONFLICT => {
354
- const_io_error ! ( ErrorKind :: AddrInUse , "EFI_IP_ADDRESS_CONFLICT " )
367
+ const_io_error ! ( ErrorKind :: AddrInUse , "There is an address conflict address allocation " )
355
368
}
356
369
Status :: LOAD_ERROR => {
357
- const_io_error ! ( ErrorKind :: Other , "EFI_LOAD_ERROR " )
370
+ const_io_error ! ( ErrorKind :: Other , "The image failed to load. " )
358
371
}
359
372
Status :: MEDIA_CHANGED => {
360
- const_io_error ! ( ErrorKind :: StaleNetworkFileHandle , "EFI_MEDIA_CHANGED" )
373
+ const_io_error ! (
374
+ ErrorKind :: Other ,
375
+ "The medium in the device has changed since the last access."
376
+ )
361
377
}
362
378
Status :: NETWORK_UNREACHABLE => {
363
- const_io_error ! ( ErrorKind :: NetworkUnreachable , "EFI_NETWORK_UNREACHABLE" )
379
+ const_io_error ! (
380
+ ErrorKind :: NetworkUnreachable ,
381
+ "The network containing the remote host is not reachable."
382
+ )
364
383
}
365
384
Status :: NO_MAPPING => {
366
- const_io_error ! ( ErrorKind :: Other , "EFI_NO_MAPPING " )
385
+ const_io_error ! ( ErrorKind :: Other , "A mapping to a device does not exist. " )
367
386
}
368
387
Status :: NO_MEDIA => {
369
- const_io_error ! ( ErrorKind :: Other , "EFI_NO_MEDIA" )
388
+ const_io_error ! (
389
+ ErrorKind :: Other ,
390
+ "The device does not contain any medium to perform the operation."
391
+ )
370
392
}
371
393
Status :: NO_RESPONSE => {
372
- const_io_error ! ( ErrorKind :: HostUnreachable , "EFI_NO_RESPONSE" )
394
+ const_io_error ! (
395
+ ErrorKind :: HostUnreachable ,
396
+ "The server was not found or did not respond to the request."
397
+ )
398
+ }
399
+ Status :: NOT_FOUND => const_io_error ! ( ErrorKind :: NotFound , "The item was not found." ) ,
400
+ Status :: NOT_READY => {
401
+ const_io_error ! ( ErrorKind :: ResourceBusy , "There is no data pending upon return." )
402
+ }
403
+ Status :: NOT_STARTED => {
404
+ const_io_error ! ( ErrorKind :: Other , "The protocol has not been started." )
373
405
}
374
- Status :: NOT_FOUND => const_io_error ! ( ErrorKind :: NotFound , "EFI_NOT_FOUND" ) ,
375
- Status :: NOT_READY => const_io_error ! ( ErrorKind :: ResourceBusy , "EFI_NOT_READY" ) ,
376
- Status :: NOT_STARTED => const_io_error ! ( ErrorKind :: Other , "EFI_NOT_STARTED" ) ,
377
406
Status :: OUT_OF_RESOURCES => {
378
- const_io_error ! ( ErrorKind :: OutOfMemory , "EFI_OUT_OF_RESOURCES " )
407
+ const_io_error ! ( ErrorKind :: OutOfMemory , "A resource has run out. " )
379
408
}
380
409
Status :: PROTOCOL_ERROR => {
381
- const_io_error ! ( ErrorKind :: Other , "EFI_PROTOCOL_ERROR" )
410
+ const_io_error ! (
411
+ ErrorKind :: Other ,
412
+ "A protocol error occurred during the network operation."
413
+ )
382
414
}
383
415
Status :: PROTOCOL_UNREACHABLE => {
384
- const_io_error ! ( ErrorKind :: Other , "EFI_PROTOCOL_UNREACHABLE " )
416
+ const_io_error ! ( ErrorKind :: Other , "An ICMP protocol unreachable error is received. " )
385
417
}
386
418
Status :: SECURITY_VIOLATION => {
387
- const_io_error ! ( ErrorKind :: PermissionDenied , "EFI_SECURITY_VIOLATION" )
419
+ const_io_error ! (
420
+ ErrorKind :: PermissionDenied ,
421
+ "The function was not performed due to a security violation."
422
+ )
423
+ }
424
+ Status :: TFTP_ERROR => {
425
+ const_io_error ! ( ErrorKind :: Other , "A TFTP error occurred during the network operation." )
388
426
}
389
- Status :: TFTP_ERROR => const_io_error ! ( ErrorKind :: Other , "EFI_TFTP_ERROR" ) ,
390
- Status :: TIMEOUT => const_io_error ! ( ErrorKind :: TimedOut , "EFI_TIMEOUT" ) ,
427
+ Status :: TIMEOUT => const_io_error ! ( ErrorKind :: TimedOut , "The timeout time expired." ) ,
391
428
Status :: UNSUPPORTED => {
392
- const_io_error ! ( ErrorKind :: Unsupported , "EFI_UNSUPPORTED " )
429
+ const_io_error ! ( ErrorKind :: Unsupported , "The operation is not supported. " )
393
430
}
394
431
Status :: VOLUME_FULL => {
395
- const_io_error ! ( ErrorKind :: StorageFull , "EFI_VOLUME_FULL " )
432
+ const_io_error ! ( ErrorKind :: StorageFull , "There is no more space on the file system. " )
396
433
}
397
434
Status :: VOLUME_CORRUPTED => {
398
- const_io_error ! ( ErrorKind :: Other , "EFI_VOLUME_CORRUPTED" )
435
+ const_io_error ! (
436
+ ErrorKind :: Other ,
437
+ "An inconstancy was detected on the file system causing the operating to fail."
438
+ )
399
439
}
400
440
Status :: WRITE_PROTECTED => {
401
- const_io_error ! ( ErrorKind :: ReadOnlyFilesystem , "EFI_WRITE_PROTECTED " )
441
+ const_io_error ! ( ErrorKind :: ReadOnlyFilesystem , "The device cannot be written to. " )
402
442
}
403
443
_ => io:: Error :: new ( ErrorKind :: Uncategorized , format ! ( "Status: {}" , s. as_usize( ) ) ) ,
404
444
}
0 commit comments