Skip to content

Commit d8b7948

Browse files
phip1611nicholasbishop
authored andcommitted
uefi: simplify return type of memory_map
1 parent f297d00 commit d8b7948

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
- `UnalignedSlice` now implements `Clone`, and the `Debug` impl now
2424
prints the elements instead of the internal fields.
2525
- The unstable `negative_impls` feature is no longer required to use this library.
26+
- `BootServices::memory_map()` now returns `MemoryMapIter` instead of
27+
`impl Iterator` which simplifies usage.
28+
- `BootServices::exit_boot_services()` now returns `MemoryMapIter` instead of
29+
`impl Iterator` which simplifies usage.
2630

2731
### Removed
2832

uefi/src/table/boot.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,7 @@ impl BootServices {
424424
pub fn memory_map<'buf>(
425425
&self,
426426
buffer: &'buf mut [u8],
427-
) -> Result<(
428-
MemoryMapKey,
429-
impl ExactSizeIterator<Item = &'buf MemoryDescriptor> + Clone,
430-
)> {
427+
) -> Result<(MemoryMapKey, MemoryMapIter<'buf>)> {
431428
let mut map_size = buffer.len();
432429
MemoryDescriptor::assert_aligned(buffer);
433430
let map_buffer = buffer.as_mut_ptr().cast::<MemoryDescriptor>();
@@ -2077,9 +2074,10 @@ pub struct MemoryMapSize {
20772074
pub map_size: usize,
20782075
}
20792076

2080-
/// An iterator of memory descriptors
2077+
/// An iterator of [`MemoryDescriptor`]. The underlying memory map is always
2078+
/// associated with a unique [`MemoryMapKey`].
20812079
#[derive(Debug, Clone)]
2082-
struct MemoryMapIter<'buf> {
2080+
pub struct MemoryMapIter<'buf> {
20832081
buffer: &'buf [u8],
20842082
entry_size: usize,
20852083
index: usize,

uefi/src/table/system.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use core::{ptr, slice};
77
use crate::proto::console::text;
88
use crate::{CStr16, Char16, Handle, Result, ResultExt, Status};
99

10-
use super::boot::{BootServices, MemoryDescriptor};
10+
use super::boot::{BootServices, MemoryDescriptor, MemoryMapIter};
1111
use super::runtime::RuntimeServices;
1212
use super::{cfg, Header, Revision};
1313

@@ -182,10 +182,7 @@ impl SystemTable<Boot> {
182182
self,
183183
image: Handle,
184184
mmap_buf: &mut [u8],
185-
) -> Result<(
186-
SystemTable<Runtime>,
187-
impl ExactSizeIterator<Item = &MemoryDescriptor> + Clone,
188-
)> {
185+
) -> Result<(SystemTable<Runtime>, MemoryMapIter<'_>)> {
189186
unsafe {
190187
let boot_services = self.boot_services();
191188

0 commit comments

Comments
 (0)