@@ -18,8 +18,8 @@ use super::media::file::FileInfo;
18
18
pub struct Shell {
19
19
execute : extern "efiapi" fn (
20
20
parent_image_handle : * const Handle ,
21
- commandline : * const CStr16 ,
22
- environment : * const * const CStr16 ,
21
+ commandline : * const Char16 ,
22
+ environment : * const * const Char16 ,
23
23
out_status : * mut Status ,
24
24
) -> Status ,
25
25
get_env : extern "efiapi" fn ( name : * const Char16 ) -> * const Char16 ,
@@ -52,19 +52,19 @@ pub struct Shell {
52
52
open_file_by_name : usize ,
53
53
close_file : extern "efiapi" fn ( file_handle : ShellFileHandle ) -> Status ,
54
54
create_file : extern "efiapi" fn (
55
- file_name : & CStr16 ,
55
+ file_name : * const Char16 ,
56
56
file_attribs : u64 ,
57
57
out_file_handle : ShellFileHandle ,
58
58
) -> Status ,
59
59
read_file : usize ,
60
60
write_file : usize ,
61
61
delete_file : extern "efiapi" fn ( file_handle : ShellFileHandle ) -> Status ,
62
- delete_file_by_name : extern "efiapi" fn ( file_name : & CStr16 ) -> Status ,
62
+ delete_file_by_name : extern "efiapi" fn ( file_name : * const Char16 ) -> Status ,
63
63
get_file_position : usize ,
64
64
set_file_position : usize ,
65
65
flush_file : extern "efiapi" fn ( file_handle : ShellFileHandle ) -> Status ,
66
66
find_files : extern "efiapi" fn (
67
- file_pattern : * const CStr16 ,
67
+ file_pattern : * const Char16 ,
68
68
out_file_list : * mut * mut ShellFileInfo ,
69
69
) -> Status ,
70
70
find_files_in_dir : extern "efiapi" fn (
@@ -132,16 +132,16 @@ impl Shell {
132
132
) -> Result < Status > {
133
133
let mut out_status: MaybeUninit < Status > = MaybeUninit :: uninit ( ) ;
134
134
// We have to do this in two parts, an `as` cast straight to *const *const CStr16 doesn't compile
135
- let environment = environment. as_ptr ( ) ;
136
- let environment = environment. cast :: < * const CStr16 > ( ) ;
137
-
138
- ( self . execute ) (
139
- & parent_image ,
140
- command_line ,
141
- environment ,
142
- out_status. as_mut_ptr ( ) ,
143
- )
144
- . to_result_with_val ( || unsafe { out_status . assume_init ( ) } )
135
+ // let environment = environment.as_ptr();
136
+ // let environment = environment.cast::<*const CStr16>();
137
+
138
+ let cl_ptr = command_line . as_ptr ( ) ;
139
+ unsafe {
140
+ let env_ptr : * const * const Char16 = ( & ( * environment . as_ptr ( ) ) . as_ptr ( ) ) . cast ( ) ;
141
+
142
+ ( self . execute ) ( & parent_image , cl_ptr , env_ptr , out_status. as_mut_ptr ( ) )
143
+ . to_result_with_val ( || out_status . assume_init ( ) )
144
+ }
145
145
}
146
146
147
147
/// Gets the environment variable or list of environment variables
@@ -300,8 +300,10 @@ impl Shell {
300
300
//let mut out_file_handle: MaybeUninit<Option<ShellFileHandle>> = MaybeUninit::zeroed();
301
301
// let mut file_handle: ShellFileHandle;
302
302
let file_handle = ptr:: null ( ) ;
303
+ let file_name_ptr = file_name. as_ptr ( ) ;
303
304
304
- ( self . create_file ) ( file_name, file_attribs, file_handle) . to_result_with_val ( || file_handle)
305
+ ( self . create_file ) ( file_name_ptr, file_attribs, file_handle)
306
+ . to_result_with_val ( || file_handle)
305
307
// Safety: if this call is successful, `out_file_handle`
306
308
// will always be initialized and valid.
307
309
// .to_result_with_val(|| unsafe { out_file_handle.assume_init() })
@@ -314,7 +316,7 @@ impl Shell {
314
316
315
317
/// TODO
316
318
pub fn delete_file_by_name ( & self , file_name : & CStr16 ) -> Result < ( ) > {
317
- ( self . delete_file_by_name ) ( file_name) . to_result ( )
319
+ ( self . delete_file_by_name ) ( file_name. as_ptr ( ) ) . to_result ( )
318
320
}
319
321
320
322
/// TODO
@@ -324,7 +326,8 @@ impl Shell {
324
326
if out_ptr. is_null ( ) {
325
327
panic ! ( "outptr null" ) ;
326
328
}
327
- ( self . find_files ) ( file_pattern, out_ptr) . to_result_with_val ( || {
329
+ let fp_ptr = file_pattern. as_ptr ( ) ;
330
+ ( self . find_files ) ( fp_ptr, out_ptr) . to_result_with_val ( || {
328
331
// safety: if we're here, out_list is valid, but maybe null
329
332
let out_list = unsafe { out_list. assume_init ( ) } ;
330
333
if out_list. is_null ( ) {
0 commit comments