@@ -222,7 +222,7 @@ impl BootServices {
222
222
}
223
223
224
224
/// Stores the current UEFI memory map in an UEFI-heap allocated buffer
225
- /// and returns a [`MemoryMap `].
225
+ /// and returns a [`MemoryMapOwned `].
226
226
///
227
227
/// # Parameters
228
228
///
@@ -237,7 +237,7 @@ impl BootServices {
237
237
///
238
238
/// * [`uefi::Status::BUFFER_TOO_SMALL`]
239
239
/// * [`uefi::Status::INVALID_PARAMETER`]
240
- pub fn memory_map ( & self , mt : MemoryType ) -> Result < MemoryMap > {
240
+ pub fn memory_map ( & self , mt : MemoryType ) -> Result < MemoryMapOwned > {
241
241
let mut buffer = MemoryMapBackingMemory :: new ( mt) ?;
242
242
243
243
let meta = self . get_memory_map ( buffer. as_mut_slice ( ) ) ?;
@@ -251,7 +251,7 @@ impl BootServices {
251
251
let len = map_size / desc_size;
252
252
assert_eq ! ( map_size % desc_size, 0 ) ;
253
253
assert_eq ! ( desc_version, MemoryDescriptor :: VERSION ) ;
254
- Ok ( MemoryMap {
254
+ Ok ( MemoryMapOwned {
255
255
key : map_key,
256
256
buf : buffer,
257
257
meta,
@@ -1663,7 +1663,7 @@ pub struct MemoryMapKey(usize);
1663
1663
/// The type is intended to be used like this:
1664
1664
/// 1. create it using [`MemoryMapBackingMemory::new`]
1665
1665
/// 2. pass it to [`BootServices::get_memory_map`]
1666
- /// 3. construct a [`MemoryMap `] from it
1666
+ /// 3. construct a [`MemoryMapOwned `] from it
1667
1667
#[ derive( Debug ) ]
1668
1668
#[ allow( clippy:: len_without_is_empty) ] // this type is never empty
1669
1669
pub ( crate ) struct MemoryMapBackingMemory ( NonNull < [ u8 ] > ) ;
@@ -1807,11 +1807,11 @@ impl MemoryMapMeta {
1807
1807
/// An accessory to the memory map that can be either iterated or
1808
1808
/// indexed like an array.
1809
1809
///
1810
- /// A [`MemoryMap `] is always associated with the unique [`MemoryMapKey`]
1810
+ /// A [`MemoryMapOwned `] is always associated with the unique [`MemoryMapKey`]
1811
1811
/// contained in the struct.
1812
1812
///
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.
1815
1815
///
1816
1816
/// ## UEFI pitfalls
1817
1817
/// **Please note** that when working with memory maps, the `entry_size` is
@@ -1821,21 +1821,21 @@ impl MemoryMapMeta {
1821
1821
///
1822
1822
/// [0]: https://github.com/tianocore/edk2/blob/7142e648416ff5d3eac6c6d607874805f5de0ca8/MdeModulePkg/Core/PiSmmCore/Page.c#L1059
1823
1823
#[ derive( Debug ) ]
1824
- pub struct MemoryMap {
1824
+ pub struct MemoryMapOwned {
1825
1825
/// Backing memory, properly initialized at this point.
1826
1826
buf : MemoryMapBackingMemory ,
1827
1827
key : MemoryMapKey ,
1828
1828
meta : MemoryMapMeta ,
1829
1829
len : usize ,
1830
1830
}
1831
1831
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
1834
1834
/// the buffer and the reported `desc_size` from UEFI.
1835
1835
pub ( crate ) fn from_initialized_mem ( buf : MemoryMapBackingMemory , meta : MemoryMapMeta ) -> Self {
1836
1836
assert ! ( meta. desc_size >= mem:: size_of:: <MemoryDescriptor >( ) ) ;
1837
1837
let len = meta. entry_count ( ) ;
1838
- MemoryMap {
1838
+ MemoryMapOwned {
1839
1839
key : MemoryMapKey ( 0 ) ,
1840
1840
buf,
1841
1841
meta,
@@ -1935,7 +1935,7 @@ impl MemoryMap {
1935
1935
1936
1936
/// Returns an [`MemoryMapIter`] emitting [`MemoryDescriptor`]s.
1937
1937
///
1938
- /// To get a sorted map, call [`MemoryMap ::sort`] first.
1938
+ /// To get a sorted map, call [`MemoryMapOwned ::sort`] first.
1939
1939
///
1940
1940
/// # UEFI pitfalls
1941
1941
/// Currently, only the descriptor version specified in
@@ -1995,15 +1995,15 @@ impl MemoryMap {
1995
1995
}
1996
1996
}
1997
1997
1998
- impl core:: ops:: Index < usize > for MemoryMap {
1998
+ impl core:: ops:: Index < usize > for MemoryMapOwned {
1999
1999
type Output = MemoryDescriptor ;
2000
2000
2001
2001
fn index ( & self , index : usize ) -> & Self :: Output {
2002
2002
self . get ( index) . unwrap ( )
2003
2003
}
2004
2004
}
2005
2005
2006
- impl core:: ops:: IndexMut < usize > for MemoryMap {
2006
+ impl core:: ops:: IndexMut < usize > for MemoryMapOwned {
2007
2007
fn index_mut ( & mut self , index : usize ) -> & mut Self :: Output {
2008
2008
self . get_mut ( index) . unwrap ( )
2009
2009
}
@@ -2013,7 +2013,7 @@ impl core::ops::IndexMut<usize> for MemoryMap {
2013
2013
/// associated with a unique [`MemoryMapKey`].
2014
2014
#[ derive( Debug , Clone ) ]
2015
2015
pub struct MemoryMapIter < ' a > {
2016
- memory_map : & ' a MemoryMap ,
2016
+ memory_map : & ' a MemoryMapOwned ,
2017
2017
index : usize ,
2018
2018
}
2019
2019
@@ -2170,18 +2170,18 @@ pub struct ProtocolSearchKey(NonNull<c_void>);
2170
2170
mod tests_mmap_artificial {
2171
2171
use core:: mem:: { size_of, size_of_val} ;
2172
2172
2173
- use crate :: table:: boot:: { MemoryAttribute , MemoryMap , MemoryType } ;
2173
+ use crate :: table:: boot:: { MemoryAttribute , MemoryMapOwned , MemoryType } ;
2174
2174
2175
2175
use super :: { MemoryDescriptor , MemoryMapIter } ;
2176
2176
2177
- fn buffer_to_map ( buffer : & mut [ MemoryDescriptor ] ) -> MemoryMap {
2177
+ fn buffer_to_map ( buffer : & mut [ MemoryDescriptor ] ) -> MemoryMapOwned {
2178
2178
let byte_buffer = {
2179
2179
unsafe {
2180
2180
core:: slice:: from_raw_parts_mut ( buffer. as_mut_ptr ( ) as * mut u8 , size_of_val ( buffer) )
2181
2181
}
2182
2182
} ;
2183
2183
2184
- MemoryMap :: from_raw ( byte_buffer, size_of :: < MemoryDescriptor > ( ) )
2184
+ MemoryMapOwned :: from_raw ( byte_buffer, size_of :: < MemoryDescriptor > ( ) )
2185
2185
}
2186
2186
2187
2187
#[ test]
@@ -2269,7 +2269,7 @@ mod tests_mmap_artificial {
2269
2269
}
2270
2270
2271
2271
// Added for debug purposes on test failure
2272
- impl core:: fmt:: Display for MemoryMap {
2272
+ impl core:: fmt:: Display for MemoryMapOwned {
2273
2273
fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
2274
2274
writeln ! ( f) ?;
2275
2275
for desc in self . entries ( ) {
@@ -2323,7 +2323,7 @@ mod tests_mmap_real {
2323
2323
let mut buf = MMAP_RAW ;
2324
2324
let buf =
2325
2325
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 ) ;
2327
2327
mmap. sort ( ) ;
2328
2328
2329
2329
let entries = mmap. entries ( ) . copied ( ) . collect :: < Vec < _ > > ( ) ;
0 commit comments