Skip to content

Commit f8d5670

Browse files
committed
uefi: add MemoryMap::raw
1 parent 89a0d7f commit f8d5670

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
@@ -1742,6 +1742,12 @@ impl MemoryMapBackingMemory {
17421742
self.0.as_ptr().cast()
17431743
}
17441744

1745+
/// Returns a slice to the underlying memory.
1746+
#[must_use]
1747+
pub fn as_slice(&self) -> &[u8] {
1748+
unsafe { self.0.as_ref() }
1749+
}
1750+
17451751
/// Returns a mutable slice to the underlying memory.
17461752
#[must_use]
17471753
pub fn as_mut_slice(&mut self) -> &mut [u8] {
@@ -1970,6 +1976,15 @@ impl MemoryMap {
19701976

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

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

0 commit comments

Comments
 (0)