Skip to content

Commit

Permalink
mem/doc: minor documentation adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
phip1611 committed Mar 19, 2023
1 parent 646fe86 commit bbc030a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions uefi/src/table/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1990,8 +1990,11 @@ pub struct MemoryMapSize {
pub map_size: usize,
}

/// An iterator of [`MemoryDescriptor`] which returns elements in sorted order. The underlying memory map is always
/// associated with the unique [`MemoryMapKey`] contained in the struct.
/// An iterator of [`MemoryDescriptor`] that is always associated with the
/// unique [`MemoryMapKey`] contained in the struct.
///
/// To iterate over the entries, call [`MemoryMap::entries`]. To get a sorted
/// map, you manually have to call [`MemoryMap::sort`] first.
pub struct MemoryMap<'buf> {
key: MemoryMapKey,
buf: &'buf mut [u8],
Expand All @@ -2007,6 +2010,7 @@ impl<'buf> MemoryMap<'buf> {
}

/// Sorts the memory map by physical address in place.
/// This operation is optional and should be invoked only once.
pub fn sort(&mut self) {
unsafe {
self.qsort(0, self.len - 1);
Expand Down Expand Up @@ -2075,8 +2079,9 @@ impl<'buf> MemoryMap<'buf> {
elem.phys_start
}

/// Returns an iterator over the contained memory map. To get a sorted map,
/// call [`MemoryMap::sort`] first.
#[must_use]
/// Returns an iterator over the contained memory map
pub fn entries(&self) -> MemoryMapIter {
MemoryMapIter {
buffer: self.buf,
Expand Down Expand Up @@ -2356,7 +2361,6 @@ mod tests {
}

// Added for debug purposes on test failure
#[cfg(test)]
impl core::fmt::Display for MemoryMap<'_> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
writeln!(f)?;
Expand Down

0 comments on commit bbc030a

Please sign in to comment.