File tree Expand file tree Collapse file tree 5 files changed +66
-0
lines changed Expand file tree Collapse file tree 5 files changed +66
-0
lines changed Original file line number Diff line number Diff line change 19
19
- Added ` core::error::Error ` implementations to all error types.
20
20
- ` SystemTable::exit_boot_services ` now takes one param ` memory_type ` to ensure
21
21
the memory type of memory map.
22
+ - Added the ` ShellParams ` protocol
22
23
23
24
### Removed
24
25
- ` BootServices::memmove ` and ` BootServices::set_mem ` have been removed, use
Original file line number Diff line number Diff line change @@ -12,3 +12,4 @@ pub mod driver;
12
12
pub mod loaded_image;
13
13
pub mod memory_protection;
14
14
pub mod rng;
15
+ pub mod shell_params;
Original file line number Diff line number Diff line change
1
+ use crate :: { guid, Char16 , Guid } ;
2
+ use core:: ffi:: c_void;
3
+
4
+ pub type ShellFileHandle = * const c_void ;
5
+
6
+ #[ derive( Debug ) ]
7
+ #[ repr( C ) ]
8
+ pub struct ShellParametersProtocol {
9
+ /// Pointer to a list of arguments.
10
+ pub argv : * const * const Char16 ,
11
+ /// Number of arguments.
12
+ pub argc : usize ,
13
+ /// Handle of the standard input.
14
+ pub std_in : ShellFileHandle ,
15
+ /// Handle of the standard output.
16
+ pub std_out : ShellFileHandle ,
17
+ /// Handle of the standard error output.
18
+ pub std_err : ShellFileHandle ,
19
+ }
20
+
21
+ impl ShellParametersProtocol {
22
+ pub const GUID : Guid = guid ! ( "752f3136-4e16-4fdc-a22a-e5f46812f4ca" ) ;
23
+ }
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ pub mod network;
76
76
pub mod pi;
77
77
pub mod rng;
78
78
pub mod security;
79
+ pub mod shell_params;
79
80
pub mod shim;
80
81
pub mod string;
81
82
pub mod tcg;
Original file line number Diff line number Diff line change
1
+ //! `ShellParams` protocol
2
+
3
+ use crate :: proto:: unsafe_protocol;
4
+ use crate :: { data_types, Char16 } ;
5
+ use core:: slice:: from_raw_parts;
6
+ use uefi_raw:: protocol:: shell_params:: ShellParametersProtocol ;
7
+
8
+ use crate :: CStr16 ;
9
+
10
+ /// The ShellParameters protocol.
11
+ #[ derive( Debug ) ]
12
+ #[ repr( transparent) ]
13
+ #[ unsafe_protocol( ShellParametersProtocol :: GUID ) ]
14
+ pub struct ShellParameters ( ShellParametersProtocol ) ;
15
+
16
+ impl ShellParameters {
17
+ /// Get the number of shell parameter arguments
18
+ #[ must_use]
19
+ pub fn args_len ( & self ) -> usize {
20
+ self . 0 . argc
21
+ }
22
+
23
+ /// Get an iterator of the shell parameter arguments
24
+ pub fn args ( & self ) -> impl Iterator < Item = & CStr16 > {
25
+ self . args_slice ( )
26
+ . iter ( )
27
+ . map ( |x| unsafe { CStr16 :: from_ptr ( * x) } )
28
+ }
29
+
30
+ /// Get a slice of the args, as Char16 pointers
31
+ #[ must_use]
32
+ fn args_slice ( & self ) -> & [ * const Char16 ] {
33
+ unsafe {
34
+ from_raw_parts (
35
+ self . 0 . argv . cast :: < * const data_types:: chars:: Char16 > ( ) ,
36
+ self . 0 . argc ,
37
+ )
38
+ }
39
+ }
40
+ }
You can’t perform that action at this time.
0 commit comments