3
3
use super :: Revision ;
4
4
use crate :: data_types:: { Align , PhysicalAddress } ;
5
5
use crate :: proto:: device_path:: DevicePath ;
6
+ use crate :: proto:: media:: fs:: SimpleFileSystem ;
6
7
use crate :: proto:: { Protocol , ProtocolPointer } ;
7
8
use crate :: { Char16 , Error , Event , Guid , Handle , Result , Status , StatusExt } ;
8
9
use core:: cell:: UnsafeCell ;
@@ -13,11 +14,7 @@ use core::ops::{Deref, DerefMut};
13
14
use core:: ptr:: NonNull ;
14
15
use core:: { ptr, slice} ;
15
16
#[ 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 } ;
21
18
22
19
pub use uefi_raw:: table:: boot:: {
23
20
EventType , InterfaceType , MemoryAttribute , MemoryDescriptor , MemoryType , Tpl ,
@@ -1344,6 +1341,38 @@ impl BootServices {
1344
1341
pub unsafe fn set_mem ( & self , buffer : * mut u8 , size : usize , value : u8 ) {
1345
1342
( self . 0 . set_mem ) ( buffer, size, value) ;
1346
1343
}
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
+ }
1347
1376
}
1348
1377
1349
1378
#[ cfg( feature = "alloc" ) ]
@@ -1377,37 +1406,6 @@ impl BootServices {
1377
1406
// Emit output, with warnings
1378
1407
Ok ( handles)
1379
1408
}
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
- }
1411
1409
}
1412
1410
1413
1411
impl super :: Table for BootServices {
0 commit comments