Skip to content

Commit c511c52

Browse files
committed
uefi: add MemoryMap::raw
1 parent d864ce7 commit c511c52

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

uefi/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
- Re-exported `CapsuleFlags`.
1818
- One can now specify in `TimeError` what fields of `Time` are outside its valid
1919
range. `Time::is_valid` has been updated accordingly.
20+
- `MemoryMap::as_raw` which provides raw access to the memory map. This is for
21+
example useful if you create your own Multiboot2 bootloader that embeds the
22+
EFI mmap in a Multiboot2 boot information structure.
2023

2124
## Changed
2225
- `SystemTable::exit_boot_services` is now `unsafe`. See that method's

uefi/src/table/boot.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,6 +1729,12 @@ impl MemoryMapBackingMemory {
17291729
self.0.as_ptr().cast()
17301730
}
17311731

1732+
/// Returns a slice to the underlying memory.
1733+
#[must_use]
1734+
pub fn as_slice(&self) -> &[u8] {
1735+
unsafe { self.0.as_ref() }
1736+
}
1737+
17321738
/// Returns a mutable slice to the underlying memory.
17331739
#[must_use]
17341740
pub fn as_mut_slice(&mut self) -> &mut [u8] {
@@ -1972,6 +1978,15 @@ impl MemoryMap {
19721978

19731979
Some(desc)
19741980
}
1981+
1982+
/// Provides access to the raw memory map.
1983+
///
1984+
/// This is for example useful if you want to embed the memory map into
1985+
/// another data structure, such as a Multiboot2 boot information.
1986+
#[must_use]
1987+
pub fn as_raw(&self) -> (&[u8], MemoryMapMeta) {
1988+
(self.buf.as_slice(), self.meta)
1989+
}
19751990
}
19761991

19771992
impl core::ops::Index<usize> for MemoryMap {

0 commit comments

Comments
 (0)