Skip to content

Commit e81dac9

Browse files
committed
uefi: mem: misc improvements
1 parent fff01fd commit e81dac9

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

uefi/src/mem/memory_map/api.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ pub trait MemoryMap: Debug + Index<usize, Output = MemoryDescriptor> {
3131
#[must_use]
3232
fn meta(&self) -> MemoryMapMeta;
3333

34-
/// Returns the associated [`MemoryMapKey`].
34+
/// Returns the associated [`MemoryMapKey`]. Note that this doesn't
35+
/// necessarily is the key of the latest valid UEFI memory map.
3536
#[must_use]
3637
fn key(&self) -> MemoryMapKey;
3738

@@ -67,6 +68,11 @@ pub trait MemoryMap: Debug + Index<usize, Output = MemoryDescriptor> {
6768
fn buffer(&self) -> &[u8];
6869

6970
/// Returns an Iterator of type [`MemoryMapIter`].
71+
///
72+
/// The underlying memory might contain an invalid/malformed memory map
73+
/// which can't be checked during construction of this type. The iterator
74+
/// might yield unexpected results.
75+
#[must_use]
7076
fn entries(&self) -> MemoryMapIter<'_>;
7177
}
7278

uefi/src/mem/memory_map/iter.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
use super::*;
22

3-
/// An iterator of [`MemoryDescriptor`]. The underlying memory map is always
4-
/// associated with a unique [`MemoryMapKey`].
3+
/// An iterator for [`MemoryMap`].
4+
///
5+
/// The underlying memory might contain an invalid/malformed memory map
6+
/// which can't be checked during construction of this type. The iterator
7+
/// might yield unexpected results.
58
#[derive(Debug, Clone)]
69
pub struct MemoryMapIter<'a> {
710
pub(crate) memory_map: &'a dyn MemoryMap,

uefi/src/mem/memory_map/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
//!
1717
//! If you have a chunk of memory and want to parse it as UEFI memory map, which
1818
//! might be the case if a bootloader such as GRUB or Limine passes its boot
19-
//! information, you can use [`MemoryMapRef`] or [`MemoryMapRefMut`].
20-
//! TODO add constructors.
19+
//! information, you can use [`MemoryMapRef`] or [`MemoryMapRefMut`].
2120
//!
2221
//! # All relevant exports:
2322
//!
@@ -50,12 +49,13 @@ impl Align for MemoryDescriptor {
5049
}
5150
}
5251

53-
/// A unique identifier of a memory map.
52+
/// A unique identifier of a UEFI memory map, used to tell the firmware that one
53+
/// has the latest valid memory map when exiting boot services.
5454
///
55-
/// If the memory map changes, this value is no longer valid.
56-
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
55+
/// If the memory map changes, due to any allocation or deallocation, this value
56+
/// is no longer valid, and exiting boot services will fail.
57+
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
5758
#[repr(C)]
58-
// TODO add some convenience?!
5959
pub struct MemoryMapKey(pub(crate) usize);
6060

6161
/// A structure containing the meta attributes associated with a call to

0 commit comments

Comments
 (0)