33use super :: Revision ;
44use crate :: data_types:: { Align , PhysicalAddress } ;
55use crate :: proto:: device_path:: DevicePath ;
6+ use crate :: proto:: loaded_image:: LoadedImage ;
7+ use crate :: proto:: media:: fs:: SimpleFileSystem ;
68use crate :: proto:: { Protocol , ProtocolPointer } ;
79use crate :: { Char16 , Error , Event , Guid , Handle , Result , Status , StatusExt } ;
810use core:: cell:: UnsafeCell ;
@@ -12,12 +14,9 @@ use core::mem::{self, MaybeUninit};
1214use core:: ops:: { Deref , DerefMut } ;
1315use core:: ptr:: NonNull ;
1416use core:: { ptr, slice} ;
17+
1518#[ cfg( feature = "alloc" ) ]
16- use {
17- crate :: fs:: FileSystem ,
18- crate :: proto:: { loaded_image:: LoadedImage , media:: fs:: SimpleFileSystem } ,
19- :: alloc:: vec:: Vec ,
20- } ;
19+ use alloc:: vec:: Vec ;
2120
2221pub use uefi_raw:: table:: boot:: {
2322 EventType , InterfaceType , MemoryAttribute , MemoryDescriptor , MemoryType , Tpl ,
@@ -1344,6 +1343,38 @@ impl BootServices {
13441343 pub unsafe fn set_mem ( & self , buffer : * mut u8 , size : usize , value : u8 ) {
13451344 ( self . 0 . set_mem ) ( buffer, size, value) ;
13461345 }
1346+
1347+ /// Retrieves a [`SimpleFileSystem`] protocol associated with the device the given
1348+ /// image was loaded from.
1349+ ///
1350+ /// # Errors
1351+ ///
1352+ /// This function can return errors from [`open_protocol_exclusive`] and
1353+ /// [`locate_device_path`]. See those functions for more details.
1354+ ///
1355+ /// [`open_protocol_exclusive`]: Self::open_protocol_exclusive
1356+ /// [`locate_device_path`]: Self::locate_device_path
1357+ ///
1358+ /// * [`uefi::Status::INVALID_PARAMETER`]
1359+ /// * [`uefi::Status::UNSUPPORTED`]
1360+ /// * [`uefi::Status::ACCESS_DENIED`]
1361+ /// * [`uefi::Status::ALREADY_STARTED`]
1362+ /// * [`uefi::Status::NOT_FOUND`]
1363+ pub fn get_image_file_system (
1364+ & self ,
1365+ image_handle : Handle ,
1366+ ) -> Result < ScopedProtocol < SimpleFileSystem > > {
1367+ let loaded_image = self . open_protocol_exclusive :: < LoadedImage > ( image_handle) ?;
1368+
1369+ let device_handle = loaded_image
1370+ . device ( )
1371+ . ok_or ( Error :: new ( Status :: UNSUPPORTED , ( ) ) ) ?;
1372+ let device_path = self . open_protocol_exclusive :: < DevicePath > ( device_handle) ?;
1373+
1374+ let device_handle = self . locate_device_path :: < SimpleFileSystem > ( & mut & * device_path) ?;
1375+
1376+ self . open_protocol_exclusive ( device_handle)
1377+ }
13471378}
13481379
13491380#[ cfg( feature = "alloc" ) ]
@@ -1377,37 +1408,6 @@ impl BootServices {
13771408 // Emit output, with warnings
13781409 Ok ( handles)
13791410 }
1380-
1381- /// Retrieves a [`FileSystem`] protocol associated with the device the given
1382- /// image was loaded from.
1383- ///
1384- /// # Errors
1385- ///
1386- /// This function can return errors from [`open_protocol_exclusive`] and
1387- /// [`locate_device_path`]. See those functions for more details.
1388- ///
1389- /// [`open_protocol_exclusive`]: Self::open_protocol_exclusive
1390- /// [`locate_device_path`]: Self::locate_device_path
1391- /// [`FileSystem`]: uefi::fs::FileSystem
1392- ///
1393- /// * [`uefi::Status::INVALID_PARAMETER`]
1394- /// * [`uefi::Status::UNSUPPORTED`]
1395- /// * [`uefi::Status::ACCESS_DENIED`]
1396- /// * [`uefi::Status::ALREADY_STARTED`]
1397- /// * [`uefi::Status::NOT_FOUND`]
1398- pub fn get_image_file_system ( & self , image_handle : Handle ) -> Result < FileSystem > {
1399- let loaded_image = self . open_protocol_exclusive :: < LoadedImage > ( image_handle) ?;
1400-
1401- let device_handle = loaded_image
1402- . device ( )
1403- . ok_or ( Error :: new ( Status :: UNSUPPORTED , ( ) ) ) ?;
1404- let device_path = self . open_protocol_exclusive :: < DevicePath > ( device_handle) ?;
1405-
1406- let device_handle = self . locate_device_path :: < SimpleFileSystem > ( & mut & * device_path) ?;
1407-
1408- let protocol = self . open_protocol_exclusive ( device_handle) ?;
1409- Ok ( FileSystem :: new ( protocol) )
1410- }
14111411}
14121412
14131413impl super :: Table for BootServices {
0 commit comments