@@ -6,8 +6,7 @@ use alloc::vec::Vec;
66use log:: { debug, error, info, trace} ;
77use uefi:: prelude:: BootServices ;
88use uefi:: proto:: shell_params:: * ;
9- use uefi:: table:: boot:: { OpenProtocolAttributes , OpenProtocolParams , SearchType } ;
10- use uefi:: Identify ;
9+ use uefi:: Handle ;
1110
1211use crate :: chromium_ec:: commands:: SetGpuSerialMagic ;
1312use crate :: chromium_ec:: { CrosEcDriverType , HardwareDeviceType } ;
@@ -16,40 +15,13 @@ use crate::commandline::Cli;
1615use super :: { ConsoleArg , FpBrightnessArg , InputDeckModeArg , RebootEcArg , TabletModeArg } ;
1716
1817/// Get commandline arguments from UEFI environment
19- pub fn get_args ( boot_services : & BootServices ) -> Vec < String > {
20- // TODO: I think i should open this from the ImageHandle?
21- let shell_params_h =
22- boot_services. locate_handle_buffer ( SearchType :: ByProtocol ( & ShellParameters :: GUID ) ) ;
23- let shell_params_h = if let Ok ( shell_params_h) = shell_params_h {
24- shell_params_h
18+ pub fn get_args ( bs : & BootServices , image_handle : Handle ) -> Vec < String > {
19+ if let Ok ( shell_params) = bs. open_protocol_exclusive :: < ShellParameters > ( image_handle) {
20+ shell_params. get_args ( )
2521 } else {
26- error ! ( "ShellParameters protocol not found" ) ;
27- return vec ! [ ] ;
28- } ;
29-
30- for handle in & * shell_params_h {
31- let params_handle = unsafe {
32- boot_services
33- . open_protocol :: < ShellParameters > (
34- OpenProtocolParams {
35- handle : * handle,
36- agent : boot_services. image_handle ( ) ,
37- controller : None ,
38- } ,
39- OpenProtocolAttributes :: GetProtocol ,
40- )
41- . expect ( "Failed to open ShellParameters handle" )
42- } ;
43-
44- // Ehm why are there two and one has no args?
45- // Maybe one is the shell itself?
46- if params_handle. argc == 0 {
47- continue ;
48- }
49-
50- return params_handle. get_args ( ) ;
22+ // No protocol found if the application wasn't executed by the shell
23+ vec ! [ ]
5124 }
52- vec ! [ ]
5325}
5426
5527pub fn parse ( args : & [ String ] ) -> Cli {
0 commit comments