@@ -10,7 +10,7 @@ use core::ops::{Deref, DerefMut};
10
10
use core:: ptr:: { self , NonNull } ;
11
11
use core:: slice;
12
12
use core:: sync:: atomic:: { AtomicPtr , Ordering } ;
13
- use uefi:: { table, Handle , Result , Status , StatusExt } ;
13
+ use uefi:: { table, Char16 , Handle , Result , Status , StatusExt } ;
14
14
15
15
#[ cfg( doc) ]
16
16
use {
@@ -446,6 +446,35 @@ pub fn start_image(image_handle: Handle) -> Result {
446
446
}
447
447
}
448
448
449
+ /// Exits the UEFI application and returns control to the UEFI component
450
+ /// that started the UEFI application.
451
+ ///
452
+ /// # Safety
453
+ ///
454
+ /// The caller must ensure that resources owned by the application are properly
455
+ /// cleaned up.
456
+ ///
457
+ /// Note that event callbacks installed by the application are not automatically
458
+ /// uninstalled. If such a callback is invoked after exiting the application,
459
+ /// the function's code may no longer be loaded in memory, leading to a crash or
460
+ /// other unexpected behavior.
461
+ pub unsafe fn exit (
462
+ image_handle : Handle ,
463
+ exit_status : Status ,
464
+ exit_data_size : usize ,
465
+ exit_data : * mut Char16 ,
466
+ ) -> ! {
467
+ let bt = boot_services_raw_panicking ( ) ;
468
+ let bt = unsafe { bt. as_ref ( ) } ;
469
+
470
+ ( bt. exit ) (
471
+ image_handle. as_ptr ( ) ,
472
+ exit_status,
473
+ exit_data_size,
474
+ exit_data. cast ( ) ,
475
+ )
476
+ }
477
+
449
478
/// A buffer returned by [`locate_handle_buffer`] that contains an array of
450
479
/// [`Handle`]s that support the requested protocol.
451
480
#[ derive( Debug , Eq , PartialEq ) ]
0 commit comments