33use super :: Revision ;
44use crate :: data_types:: { Align , PhysicalAddress } ;
55use crate :: proto:: device_path:: DevicePath ;
6+ use crate :: proto:: media:: fs:: SimpleFileSystem ;
67use crate :: proto:: { Protocol , ProtocolPointer } ;
78use crate :: { Char16 , Error , Event , Guid , Handle , Result , Status , StatusExt } ;
89use core:: cell:: UnsafeCell ;
@@ -13,11 +14,7 @@ use core::ops::{Deref, DerefMut};
1314use core:: ptr:: NonNull ;
1415use core:: { ptr, slice} ;
1516#[ cfg( feature = "alloc" ) ]
16- use {
17- crate :: fs:: FileSystem ,
18- crate :: proto:: { loaded_image:: LoadedImage , media:: fs:: SimpleFileSystem } ,
19- :: alloc:: vec:: Vec ,
20- } ;
17+ use { crate :: proto:: loaded_image:: LoadedImage , :: alloc:: vec:: Vec } ;
2118
2219pub use uefi_raw:: table:: boot:: {
2320 EventType , InterfaceType , MemoryAttribute , MemoryDescriptor , MemoryType , Tpl ,
@@ -1344,6 +1341,38 @@ impl BootServices {
13441341 pub unsafe fn set_mem ( & self , buffer : * mut u8 , size : usize , value : u8 ) {
13451342 ( self . 0 . set_mem ) ( buffer, size, value) ;
13461343 }
1344+
1345+ /// Retrieves a [`SimpleFileSystem`] protocol associated with the device the given
1346+ /// image was loaded from.
1347+ ///
1348+ /// # Errors
1349+ ///
1350+ /// This function can return errors from [`open_protocol_exclusive`] and
1351+ /// [`locate_device_path`]. See those functions for more details.
1352+ ///
1353+ /// [`open_protocol_exclusive`]: Self::open_protocol_exclusive
1354+ /// [`locate_device_path`]: Self::locate_device_path
1355+ ///
1356+ /// * [`uefi::Status::INVALID_PARAMETER`]
1357+ /// * [`uefi::Status::UNSUPPORTED`]
1358+ /// * [`uefi::Status::ACCESS_DENIED`]
1359+ /// * [`uefi::Status::ALREADY_STARTED`]
1360+ /// * [`uefi::Status::NOT_FOUND`]
1361+ pub fn get_image_file_system (
1362+ & self ,
1363+ image_handle : Handle ,
1364+ ) -> Result < ScopedProtocol < SimpleFileSystem > > {
1365+ let loaded_image = self . open_protocol_exclusive :: < LoadedImage > ( image_handle) ?;
1366+
1367+ let device_handle = loaded_image
1368+ . device ( )
1369+ . ok_or ( Error :: new ( Status :: UNSUPPORTED , ( ) ) ) ?;
1370+ let device_path = self . open_protocol_exclusive :: < DevicePath > ( device_handle) ?;
1371+
1372+ let device_handle = self . locate_device_path :: < SimpleFileSystem > ( & mut & * device_path) ?;
1373+
1374+ self . open_protocol_exclusive ( device_handle)
1375+ }
13471376}
13481377
13491378#[ cfg( feature = "alloc" ) ]
@@ -1377,37 +1406,6 @@ impl BootServices {
13771406 // Emit output, with warnings
13781407 Ok ( handles)
13791408 }
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- }
14111409}
14121410
14131411impl super :: Table for BootServices {
0 commit comments