File tree Expand file tree Collapse file tree 5 files changed +71
-0
lines changed Expand file tree Collapse file tree 5 files changed +71
-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
+ #[ cfg( feature = "alloc" ) ]
9
+ use crate :: CStr16 ;
10
+ #[ cfg( feature = "alloc" ) ]
11
+ use alloc:: string:: String ;
12
+ #[ cfg( feature = "alloc" ) ]
13
+ use alloc:: string:: ToString ;
14
+
15
+ /// The ShellParameters protocol.
16
+ #[ derive( Debug ) ]
17
+ #[ repr( transparent) ]
18
+ #[ unsafe_protocol( ShellParametersProtocol :: GUID ) ]
19
+ pub struct ShellParameters ( ShellParametersProtocol ) ;
20
+
21
+ impl ShellParameters {
22
+ /// Get an iterator of the shell parameter arguments
23
+ #[ cfg( feature = "alloc" ) ]
24
+ pub fn get_args ( & self ) -> impl Iterator < Item = String > {
25
+ unsafe {
26
+ from_raw_parts (
27
+ self . 0 . argv . cast :: < * const data_types:: chars:: Char16 > ( ) ,
28
+ self . 0 . argc ,
29
+ )
30
+ . iter ( )
31
+ . map ( |x| CStr16 :: from_ptr ( * x) . to_string ( ) )
32
+ }
33
+ }
34
+
35
+ /// Get a slice of the args, as Char16 pointers
36
+ #[ must_use]
37
+ pub fn get_args_slice ( & self ) -> & [ * const Char16 ] {
38
+ unsafe {
39
+ from_raw_parts (
40
+ self . 0 . argv . cast :: < * const data_types:: chars:: Char16 > ( ) ,
41
+ self . 0 . argc ,
42
+ )
43
+ }
44
+ }
45
+ }
You can’t perform that action at this time.
0 commit comments