@@ -18,16 +18,14 @@ use uefi::proto::device_path::build::{self, DevicePathBuilder};
1818use uefi:: proto:: device_path:: { DevicePath , DeviceSubType , DeviceType , LoadedImageDevicePath } ;
1919use uefi:: proto:: loaded_image:: LoadedImage ;
2020use uefi:: table:: boot:: LoadImageSource ;
21+ use uefi:: { boot, Result } ;
2122
2223/// Get the device path of the shell app. This is the same as the
2324/// currently-loaded image's device path, but with the file path part changed.
24- fn get_shell_app_device_path < ' a > (
25- boot_services : & BootServices ,
26- storage : & ' a mut Vec < u8 > ,
27- ) -> & ' a DevicePath {
28- let loaded_image_device_path = boot_services
29- . open_protocol_exclusive :: < LoadedImageDevicePath > ( boot_services. image_handle ( ) )
30- . expect ( "failed to open LoadedImageDevicePath protocol" ) ;
25+ fn get_shell_app_device_path ( storage : & mut Vec < u8 > ) -> & DevicePath {
26+ let loaded_image_device_path =
27+ boot:: open_protocol_exclusive :: < LoadedImageDevicePath > ( boot:: image_handle ( ) )
28+ . expect ( "failed to open LoadedImageDevicePath protocol" ) ;
3129
3230 let mut builder = DevicePathBuilder :: with_vec ( storage) ;
3331 for node in loaded_image_device_path. node_iter ( ) {
@@ -44,29 +42,25 @@ fn get_shell_app_device_path<'a>(
4442 builder. finalize ( ) . unwrap ( )
4543}
4644
47- #[ entry]
48- fn efi_main ( image : Handle , mut st : SystemTable < Boot > ) -> Status {
49- uefi:: helpers:: init ( & mut st) . unwrap ( ) ;
50- let boot_services = st. boot_services ( ) ;
45+ fn main ( ) -> Result {
46+ uefi:: helpers:: init_v2 ( ) . unwrap ( ) ;
5147
5248 let mut storage = Vec :: new ( ) ;
53- let shell_image_path = get_shell_app_device_path ( boot_services , & mut storage) ;
49+ let shell_image_path = get_shell_app_device_path ( & mut storage) ;
5450
5551 // Load the shell app.
56- let shell_image_handle = boot_services
57- . load_image (
58- image,
59- LoadImageSource :: FromDevicePath {
60- device_path : shell_image_path,
61- from_boot_manager : false ,
62- } ,
63- )
64- . expect ( "failed to load shell app" ) ;
52+ let shell_image_handle = boot:: load_image (
53+ boot:: image_handle ( ) ,
54+ LoadImageSource :: FromDevicePath {
55+ device_path : shell_image_path,
56+ from_boot_manager : false ,
57+ } ,
58+ )
59+ . expect ( "failed to load shell app" ) ;
6560
6661 // Set the command line passed to the shell app so that it will run the
6762 // test-runner app. This automatically turns off the five-second delay.
68- let mut shell_loaded_image = boot_services
69- . open_protocol_exclusive :: < LoadedImage > ( shell_image_handle)
63+ let mut shell_loaded_image = boot:: open_protocol_exclusive :: < LoadedImage > ( shell_image_handle)
7064 . expect ( "failed to open LoadedImage protocol" ) ;
7165 let load_options = cstr16 ! ( r"shell.efi test_runner.efi arg1 arg2" ) ;
7266 unsafe {
@@ -77,9 +71,9 @@ fn efi_main(image: Handle, mut st: SystemTable<Boot>) -> Status {
7771 }
7872
7973 info ! ( "launching the shell app" ) ;
80- boot_services
81- . start_image ( shell_image_handle)
82- . expect ( "failed to launch the shell app" ) ;
74+ boot:: start_image ( shell_image_handle) . expect ( "failed to launch the shell app" ) ;
8375
84- Status :: SUCCESS
76+ Ok ( ( ) )
8577}
78+
79+ uefi:: set_main!( main) ;
0 commit comments