Skip to content

Commit b03335a

Browse files
committed
uefi: memory_map: streamline documentation
1 parent 1c8d6ec commit b03335a

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

uefi/src/mem/memory_map/api.rs

-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ use core::ops::{Index, IndexMut};
2727
///
2828
/// [0]: https://github.com/tianocore/edk2/blob/7142e648416ff5d3eac6c6d607874805f5de0ca8/MdeModulePkg/Core/PiSmmCore/Page.c#L1059
2929
pub trait MemoryMap: Debug + Index<usize, Output = MemoryDescriptor> {
30-
// TODO also require IntoIterator?! :)
31-
3230
/// Returns the associated [`MemoryMapMeta`].
3331
#[must_use]
3432
fn meta(&self) -> MemoryMapMeta;

uefi/src/mem/memory_map/iter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::*;
22

33
/// An iterator of [`MemoryDescriptor`]. The underlying memory map is always
4-
/// associated with a unique [`crate::table::boot::mmap::MemoryMapKey`].
4+
/// associated with a unique [`MemoryMapKey`].
55
#[derive(Debug, Clone)]
66
pub struct MemoryMapIter<'a> {
77
pub(crate) memory_map: &'a dyn MemoryMap,

uefi/src/mem/memory_map/mod.rs

+27-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,36 @@
1-
//! This module bundles all relevant types and helpers to work with the UEFI
2-
//! memory map. Specifically, it provides
1+
//! Bundles all relevant types and helpers to work with the UEFI memory map.
2+
//!
3+
//! To work with the memory map, you should use one of the structs
4+
//! [`MemoryMapOwned`], [`MemoryMapRef`], or [`MemoryMapRefMut`] - depending on
5+
//! your use-case. The traits [`MemoryMap`] and [`MemoryMapMut`] mainly exist
6+
//! to guarantee a streamlined API across these types. We recommend to work with
7+
//! the specific implementation.
8+
//!
9+
//! # Usecase: Obtain UEFI Memory Map
10+
//!
11+
//! You can use [`SystemTable::exit_boot_services`] or
12+
//! [`BootServices::memory_map`], which returns an properly initialized
13+
//! [`MemoryMapOwned`].
14+
//!
15+
//! # Usecase: Parse Memory Slice as UEFI Memory Map
16+
//!
17+
//! If you have a chunk of memory and want to parse it as UEFI memory map, which
18+
//! 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.
21+
//!
22+
//! # All relevant exports:
323
//!
424
//! - the traits [`MemoryMap`] and [`MemoryMapMut`],
525
//! - the trait implementations [`MemoryMapOwned`], [`MemoryMapRef`], and
626
//! [`MemoryMapRefMut`],
727
//! - the iterator [`MemoryMapIter`]
8-
//! - various associated helper types, such as [`MemoryMapKey`] and
28+
//! - various associated helper types, such as [`MemoryMapKey`] and
929
//! [`MemoryMapMeta`],
10-
//! - and re-exports the types [`MemoryDescriptor`], [`MemoryType`],
11-
//! [`MemoryAttribute`]
30+
//! - re-exports [`MemoryDescriptor`], [`MemoryType`], and [`MemoryAttribute`].
31+
//!
32+
//! [`SystemTable::exit_boot_services`]: uefi::table::SystemTable::exit_boot_services
33+
//! [`BootServices::memory_map`]: uefi::table::boot::BootServices::memory_map
1234
1335
mod api;
1436
mod impl_;

0 commit comments

Comments
 (0)