File tree Expand file tree Collapse file tree 1 file changed +60
-0
lines changed
uefi-test-runner/examples Expand file tree Collapse file tree 1 file changed +60
-0
lines changed Original file line number Diff line number Diff line change
1
+ // ANCHOR: all
2
+ // ANCHOR: features
3
+ #![ no_main]
4
+ #![ no_std]
5
+ // ANCHOR_END: features
6
+
7
+ // ANCHOR: use
8
+ use log:: info;
9
+ use uefi:: {
10
+ prelude:: * ,
11
+ proto:: shell_params:: ShellParameters ,
12
+ table:: boot:: { OpenProtocolAttributes , OpenProtocolParams , SearchType } ,
13
+ Identify ,
14
+ } ;
15
+ // ANCHOR_END: use
16
+
17
+ // ANCHOR: entry
18
+ #[ entry]
19
+ fn main ( _image_handle : Handle , mut system_table : SystemTable < Boot > ) -> Status {
20
+ // ANCHOR_END: entry
21
+ // ANCHOR: services
22
+ uefi_services:: init ( & mut system_table) . unwrap ( ) ;
23
+ let boot_services = system_table. boot_services ( ) ;
24
+ // ANCHOR_END: services
25
+
26
+ // ANCHOR: params
27
+ let shell_params_h = boot_services
28
+ . locate_handle_buffer ( SearchType :: ByProtocol ( & ShellParameters :: GUID ) )
29
+ . unwrap ( ) ;
30
+ info ! ( "Found {} ShellParams handles" , ( * shell_params_h) . len( ) ) ;
31
+ for handle in & * shell_params_h {
32
+ let params_handle = unsafe {
33
+ boot_services
34
+ . open_protocol :: < ShellParameters > (
35
+ OpenProtocolParams {
36
+ handle : * handle,
37
+ agent : boot_services. image_handle ( ) ,
38
+ controller : None ,
39
+ } ,
40
+ OpenProtocolAttributes :: GetProtocol ,
41
+ )
42
+ . expect ( "Failed to open ShellParams handle" )
43
+ } ;
44
+
45
+ // TODO: Ehm why are there two and one has no args?
46
+ // Maybe one is the shell itself?
47
+ if params_handle. argc == 0 {
48
+ continue ;
49
+ }
50
+
51
+ let args = params_handle. get_args ( ) ;
52
+ info ! ( "Args: {:?}" , args) ;
53
+ }
54
+ // ANCHOR_END: params
55
+
56
+ // ANCHOR: return
57
+ Status :: SUCCESS
58
+ }
59
+ // ANCHOR_END: return
60
+ // ANCHOR_END: all
You can’t perform that action at this time.
0 commit comments