@@ -125,7 +125,7 @@ pub fn error_string(errno: RawOsError) -> String {
125125}
126126
127127pub fn getcwd ( ) -> io:: Result < PathBuf > {
128- match uefi_shell :: open_shell ( ) {
128+ match helpers :: open_shell ( ) {
129129 Some ( shell) => {
130130 // SAFETY: path_ptr is managed by UEFI shell and should not be deallocated
131131 let path_ptr = unsafe { ( ( * shell. as_ptr ( ) ) . get_cur_dir ) ( crate :: ptr:: null_mut ( ) ) } ;
@@ -144,7 +144,7 @@ pub fn getcwd() -> io::Result<PathBuf> {
144144}
145145
146146pub fn chdir ( p : & path:: Path ) -> io:: Result < ( ) > {
147- let shell = uefi_shell :: open_shell ( ) . ok_or ( unsupported_err ( ) ) ?;
147+ let shell = helpers :: open_shell ( ) . ok_or ( unsupported_err ( ) ) ?;
148148
149149 let mut p = helpers:: os_string_to_raw ( p. as_os_str ( ) )
150150 . ok_or ( io:: const_io_error!( io:: ErrorKind :: InvalidData , "Invalid path" ) ) ?;
@@ -275,40 +275,6 @@ pub fn getpid() -> u32 {
275275 panic ! ( "no pids on this platform" )
276276}
277277
278- mod uefi_shell {
279- use r_efi:: protocols:: shell;
280-
281- use super :: super :: helpers;
282- use crate :: ptr:: NonNull ;
283- use crate :: sync:: atomic:: { AtomicPtr , Ordering } ;
284-
285- pub fn open_shell ( ) -> Option < NonNull < shell:: Protocol > > {
286- static LAST_VALID_HANDLE : AtomicPtr < crate :: ffi:: c_void > =
287- AtomicPtr :: new ( crate :: ptr:: null_mut ( ) ) ;
288-
289- if let Some ( handle) = NonNull :: new ( LAST_VALID_HANDLE . load ( Ordering :: Acquire ) ) {
290- if let Ok ( protocol) = helpers:: open_protocol :: < shell:: Protocol > (
291- handle,
292- r_efi:: protocols:: shell:: PROTOCOL_GUID ,
293- ) {
294- return Some ( protocol) ;
295- }
296- }
297-
298- let handles = helpers:: locate_handles ( shell:: PROTOCOL_GUID ) . ok ( ) ?;
299- for handle in handles {
300- if let Ok ( protocol) =
301- helpers:: open_protocol :: < shell:: Protocol > ( handle, shell:: PROTOCOL_GUID )
302- {
303- LAST_VALID_HANDLE . store ( handle. as_ptr ( ) , Ordering :: Release ) ;
304- return Some ( protocol) ;
305- }
306- }
307-
308- None
309- }
310- }
311-
312278mod uefi_env {
313279 use crate :: ffi:: { OsStr , OsString } ;
314280 use crate :: io;
0 commit comments