Skip to content

Commit 69bea25

Browse files
committed
uefi: MemoryMap -> MemoryMapOwned
1 parent c80c232 commit 69bea25

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

uefi/src/table/boot.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ impl BootServices {
222222
}
223223

224224
/// Stores the current UEFI memory map in an UEFI-heap allocated buffer
225-
/// and returns a [`MemoryMap`].
225+
/// and returns a [`MemoryMapOwned`].
226226
///
227227
/// # Parameters
228228
///
@@ -237,7 +237,7 @@ impl BootServices {
237237
///
238238
/// * [`uefi::Status::BUFFER_TOO_SMALL`]
239239
/// * [`uefi::Status::INVALID_PARAMETER`]
240-
pub fn memory_map(&self, mt: MemoryType) -> Result<MemoryMap> {
240+
pub fn memory_map(&self, mt: MemoryType) -> Result<MemoryMapOwned> {
241241
let mut buffer = MemoryMapBackingMemory::new(mt)?;
242242

243243
let meta = self.get_memory_map(buffer.as_mut_slice())?;
@@ -251,7 +251,7 @@ impl BootServices {
251251
let len = map_size / desc_size;
252252
assert_eq!(map_size % desc_size, 0);
253253
assert_eq!(desc_version, MemoryDescriptor::VERSION);
254-
Ok(MemoryMap {
254+
Ok(MemoryMapOwned {
255255
key: map_key,
256256
buf: buffer,
257257
meta,
@@ -1663,7 +1663,7 @@ pub struct MemoryMapKey(usize);
16631663
/// The type is intended to be used like this:
16641664
/// 1. create it using [`MemoryMapBackingMemory::new`]
16651665
/// 2. pass it to [`BootServices::get_memory_map`]
1666-
/// 3. construct a [`MemoryMap`] from it
1666+
/// 3. construct a [`MemoryMapOwned`] from it
16671667
#[derive(Debug)]
16681668
#[allow(clippy::len_without_is_empty)] // this type is never empty
16691669
pub(crate) struct MemoryMapBackingMemory(NonNull<[u8]>);
@@ -1807,11 +1807,11 @@ impl MemoryMapMeta {
18071807
/// An accessory to the memory map that can be either iterated or
18081808
/// indexed like an array.
18091809
///
1810-
/// A [`MemoryMap`] is always associated with the unique [`MemoryMapKey`]
1810+
/// A [`MemoryMapOwned`] is always associated with the unique [`MemoryMapKey`]
18111811
/// contained in the struct.
18121812
///
1813-
/// To iterate over the entries, call [`MemoryMap::entries`]. To get a sorted
1814-
/// map, you manually have to call [`MemoryMap::sort`] first.
1813+
/// To iterate over the entries, call [`MemoryMapOwned::entries`]. To get a sorted
1814+
/// map, you manually have to call [`MemoryMapOwned::sort`] first.
18151815
///
18161816
/// ## UEFI pitfalls
18171817
/// **Please note** that when working with memory maps, the `entry_size` is
@@ -1821,21 +1821,21 @@ impl MemoryMapMeta {
18211821
///
18221822
/// [0]: https://github.com/tianocore/edk2/blob/7142e648416ff5d3eac6c6d607874805f5de0ca8/MdeModulePkg/Core/PiSmmCore/Page.c#L1059
18231823
#[derive(Debug)]
1824-
pub struct MemoryMap {
1824+
pub struct MemoryMapOwned {
18251825
/// Backing memory, properly initialized at this point.
18261826
buf: MemoryMapBackingMemory,
18271827
key: MemoryMapKey,
18281828
meta: MemoryMapMeta,
18291829
len: usize,
18301830
}
18311831

1832-
impl MemoryMap {
1833-
/// Creates a [`MemoryMap`] from the give initialized memory map behind
1832+
impl MemoryMapOwned {
1833+
/// Creates a [`MemoryMapOwned`] from the give initialized memory map behind
18341834
/// the buffer and the reported `desc_size` from UEFI.
18351835
pub(crate) fn from_initialized_mem(buf: MemoryMapBackingMemory, meta: MemoryMapMeta) -> Self {
18361836
assert!(meta.desc_size >= mem::size_of::<MemoryDescriptor>());
18371837
let len = meta.entry_count();
1838-
MemoryMap {
1838+
MemoryMapOwned {
18391839
key: MemoryMapKey(0),
18401840
buf,
18411841
meta,
@@ -1935,7 +1935,7 @@ impl MemoryMap {
19351935

19361936
/// Returns an [`MemoryMapIter`] emitting [`MemoryDescriptor`]s.
19371937
///
1938-
/// To get a sorted map, call [`MemoryMap::sort`] first.
1938+
/// To get a sorted map, call [`MemoryMapOwned::sort`] first.
19391939
///
19401940
/// # UEFI pitfalls
19411941
/// Currently, only the descriptor version specified in
@@ -1995,15 +1995,15 @@ impl MemoryMap {
19951995
}
19961996
}
19971997

1998-
impl core::ops::Index<usize> for MemoryMap {
1998+
impl core::ops::Index<usize> for MemoryMapOwned {
19991999
type Output = MemoryDescriptor;
20002000

20012001
fn index(&self, index: usize) -> &Self::Output {
20022002
self.get(index).unwrap()
20032003
}
20042004
}
20052005

2006-
impl core::ops::IndexMut<usize> for MemoryMap {
2006+
impl core::ops::IndexMut<usize> for MemoryMapOwned {
20072007
fn index_mut(&mut self, index: usize) -> &mut Self::Output {
20082008
self.get_mut(index).unwrap()
20092009
}
@@ -2013,7 +2013,7 @@ impl core::ops::IndexMut<usize> for MemoryMap {
20132013
/// associated with a unique [`MemoryMapKey`].
20142014
#[derive(Debug, Clone)]
20152015
pub struct MemoryMapIter<'a> {
2016-
memory_map: &'a MemoryMap,
2016+
memory_map: &'a MemoryMapOwned,
20172017
index: usize,
20182018
}
20192019

@@ -2170,18 +2170,18 @@ pub struct ProtocolSearchKey(NonNull<c_void>);
21702170
mod tests_mmap_artificial {
21712171
use core::mem::{size_of, size_of_val};
21722172

2173-
use crate::table::boot::{MemoryAttribute, MemoryMap, MemoryType};
2173+
use crate::table::boot::{MemoryAttribute, MemoryMapOwned, MemoryType};
21742174

21752175
use super::{MemoryDescriptor, MemoryMapIter};
21762176

2177-
fn buffer_to_map(buffer: &mut [MemoryDescriptor]) -> MemoryMap {
2177+
fn buffer_to_map(buffer: &mut [MemoryDescriptor]) -> MemoryMapOwned {
21782178
let byte_buffer = {
21792179
unsafe {
21802180
core::slice::from_raw_parts_mut(buffer.as_mut_ptr() as *mut u8, size_of_val(buffer))
21812181
}
21822182
};
21832183

2184-
MemoryMap::from_raw(byte_buffer, size_of::<MemoryDescriptor>())
2184+
MemoryMapOwned::from_raw(byte_buffer, size_of::<MemoryDescriptor>())
21852185
}
21862186

21872187
#[test]
@@ -2269,7 +2269,7 @@ mod tests_mmap_artificial {
22692269
}
22702270

22712271
// Added for debug purposes on test failure
2272-
impl core::fmt::Display for MemoryMap {
2272+
impl core::fmt::Display for MemoryMapOwned {
22732273
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
22742274
writeln!(f)?;
22752275
for desc in self.entries() {
@@ -2323,7 +2323,7 @@ mod tests_mmap_real {
23232323
let mut buf = MMAP_RAW;
23242324
let buf =
23252325
unsafe { slice::from_raw_parts_mut(buf.as_mut_ptr().cast::<u8>(), MMAP_META.map_size) };
2326-
let mut mmap = MemoryMap::from_raw(buf, MMAP_META.desc_size);
2326+
let mut mmap = MemoryMapOwned::from_raw(buf, MMAP_META.desc_size);
23272327
mmap.sort();
23282328

23292329
let entries = mmap.entries().copied().collect::<Vec<_>>();

uefi/src/table/system.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use uefi::table::boot::{MemoryMapBackingMemory, MemoryMapMeta};
77
use crate::proto::console::text;
88
use crate::{CStr16, Result, Status, StatusExt};
99

10-
use super::boot::{BootServices, MemoryDescriptor, MemoryMap, MemoryType};
10+
use super::boot::{BootServices, MemoryDescriptor, MemoryMapOwned, MemoryType};
1111
use super::runtime::{ResetType, RuntimeServices};
1212
use super::{cfg, Revision};
1313

@@ -230,7 +230,7 @@ impl SystemTable<Boot> {
230230
pub unsafe fn exit_boot_services(
231231
self,
232232
memory_type: MemoryType,
233-
) -> (SystemTable<Runtime>, MemoryMap) {
233+
) -> (SystemTable<Runtime>, MemoryMapOwned) {
234234
crate::helpers::exit();
235235

236236
// Reboot the device.
@@ -255,7 +255,7 @@ impl SystemTable<Boot> {
255255
table: self.table,
256256
_marker: PhantomData,
257257
};
258-
return (st, MemoryMap::from_initialized_mem(buf, memory_map));
258+
return (st, MemoryMapOwned::from_initialized_mem(buf, memory_map));
259259
}
260260
Err(err) => {
261261
log::error!("Error retrieving the memory map for exiting the boot services");

0 commit comments

Comments
 (0)