Skip to content

Commit 91583e6

Browse files
committed
uefi: add MemoryMap::raw
1 parent eceb41a commit 91583e6

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
@@ -11,6 +11,9 @@
1111
- Added `table::{set_system_table, system_table_boot, system_table_runtime}`.
1212
This provides an initial API for global tables that do not require passing
1313
around a reference.
14+
- `MemoryMap::as_raw` which provides raw access to the memory map. This is for
15+
example useful if you create your own Multiboot2 bootloader that embeds the
16+
EFI mmap in a Multiboot2 boot information structure.
1417

1518
## Changed
1619
- `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
@@ -1738,6 +1738,12 @@ impl MemoryMapBackingMemory {
17381738
self.0.as_ptr().cast()
17391739
}
17401740

1741+
/// Returns a slice to the underlying memory.
1742+
#[must_use]
1743+
pub fn as_slice(&self) -> &[u8] {
1744+
unsafe { self.0.as_ref() }
1745+
}
1746+
17411747
/// Returns a mutable slice to the underlying memory.
17421748
#[must_use]
17431749
pub fn as_mut_slice(&mut self) -> &mut [u8] {
@@ -1966,6 +1972,15 @@ impl MemoryMap {
19661972

19671973
Some(desc)
19681974
}
1975+
1976+
/// Provides access to the raw memory map.
1977+
///
1978+
/// This is for example useful if you want to embed the memory map into
1979+
/// another data structure, such as a Multiboot2 boot information.
1980+
#[must_use]
1981+
pub fn as_raw(&self) -> (&[u8], MemoryMapMeta) {
1982+
(self.buf.as_slice(), self.meta)
1983+
}
19691984
}
19701985

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

0 commit comments

Comments
 (0)