File tree 3 files changed +15
-3
lines changed
3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ extern crate alloc;
10
10
11
11
use alloc:: string:: ToString ;
12
12
use alloc:: vec:: Vec ;
13
- use uefi:: mem:: memory_map:: { MemoryMap , MemoryType } ;
13
+ use uefi:: mem:: memory_map:: MemoryMap ;
14
14
use uefi:: prelude:: * ;
15
15
use uefi:: proto:: console:: serial:: Serial ;
16
16
use uefi:: proto:: device_path:: build:: { self , DevicePathBuilder } ;
@@ -209,7 +209,7 @@ fn shutdown() -> ! {
209
209
info ! ( "Testing complete, exiting boot services..." ) ;
210
210
211
211
// Exit boot services as a proof that it works :)
212
- let mmap = unsafe { uefi:: boot:: exit_boot_services ( MemoryType :: LOADER_DATA ) } ;
212
+ let mmap = unsafe { uefi:: boot:: exit_boot_services ( None ) } ;
213
213
214
214
info ! ( "Memory Map:" ) ;
215
215
for desc in mmap. entries ( ) {
Original file line number Diff line number Diff line change 16
16
` &self ` .
17
17
- ** Breaking:** The ` pxe::Mode ` struct is now opaque. Use method calls to access
18
18
mode data instead of direct field access.
19
+ - ** Breaking:** ` exit_boot_services ` now consumes a ` Option<MemoryType> ` which
20
+ defaults to the recommended value of ` MemoryType::LOADER_DATA ` .
19
21
- ` boot::memory_map() ` will never return ` Status::BUFFER_TOO_SMALL ` from now on,
20
22
as this is considered a hard internal error where users can't do anything
21
23
about it anyway. It will panic instead.
Original file line number Diff line number Diff line change @@ -1283,6 +1283,13 @@ unsafe fn get_memory_map_and_exit_boot_services(buf: &mut [u8]) -> Result<Memory
1283
1283
/// `global_allocator` feature is enabled, attempting to use the allocator
1284
1284
/// after exiting boot services will panic.
1285
1285
///
1286
+ /// # Arguments
1287
+ /// - `custom_memory_type`: The [`MemoryType`] for the UEFI allocation that will
1288
+ /// store the final memory map. If you pass `None`, this defaults to the
1289
+ /// recommended default value of [`MemoryType::LOADER_DATA`]. If you want a
1290
+ /// specific memory region for the memory map, you can pass the desired
1291
+ /// [`MemoryType`].
1292
+ ///
1286
1293
/// # Safety
1287
1294
///
1288
1295
/// The caller is responsible for ensuring that no references to
@@ -1313,7 +1320,10 @@ unsafe fn get_memory_map_and_exit_boot_services(buf: &mut [u8]) -> Result<Memory
1313
1320
/// [`Output`]: crate::proto::console::text::Output
1314
1321
/// [`PoolString`]: crate::proto::device_path::text::PoolString
1315
1322
#[ must_use]
1316
- pub unsafe fn exit_boot_services ( memory_type : MemoryType ) -> MemoryMapOwned {
1323
+ pub unsafe fn exit_boot_services ( custom_memory_type : Option < MemoryType > ) -> MemoryMapOwned {
1324
+ // LOADER_DATA is the default and also used by the Linux kernel:
1325
+ // https://elixir.bootlin.com/linux/v6.13.7/source/drivers/firmware/efi/libstub/mem.c#L24
1326
+ let memory_type = custom_memory_type. unwrap_or ( MemoryType :: LOADER_DATA ) ;
1317
1327
crate :: helpers:: exit ( ) ;
1318
1328
1319
1329
let mut buf = MemoryMapBackingMemory :: new ( memory_type) . expect ( "Failed to allocate memory" ) ;
You can’t perform that action at this time.
0 commit comments