@@ -6,8 +6,7 @@ use alloc::vec::Vec;
6
6
use log:: { debug, error, info, trace} ;
7
7
use uefi:: prelude:: BootServices ;
8
8
use uefi:: proto:: shell_params:: * ;
9
- use uefi:: table:: boot:: { OpenProtocolAttributes , OpenProtocolParams , SearchType } ;
10
- use uefi:: Identify ;
9
+ use uefi:: Handle ;
11
10
12
11
use crate :: chromium_ec:: commands:: SetGpuSerialMagic ;
13
12
use crate :: chromium_ec:: { CrosEcDriverType , HardwareDeviceType } ;
@@ -16,40 +15,13 @@ use crate::commandline::Cli;
16
15
use super :: { ConsoleArg , FpBrightnessArg , InputDeckModeArg , RebootEcArg , TabletModeArg } ;
17
16
18
17
/// 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 ( )
25
21
} 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 ! [ ]
51
24
}
52
- vec ! [ ]
53
25
}
54
26
55
27
pub fn parse ( args : & [ String ] ) -> Cli {
0 commit comments