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