MCPcopy Create free account
hub / github.com/LibertyOS-Development/kernel / usableframes

Method usableframes

src/mem.rs:163–177  ·  view source on GitHub ↗

This returns an iterator over usable frames, as specified by the memory map.

(&self)

Source from the content-addressed store, hash-verified

161
162 // This returns an iterator over usable frames, as specified by the memory map.
163 fn usableframes(&self) -> impl Iterator<Item = PhysFrame>
164 {
165 // This figures out which regions, from the memory map, are usable.
166 let regions = self.memmap.iter();
167 let usableregions = regions.filter(|r| r.region_type == MemoryRegionType::Usable);
168
169 // This maps each region to its respective address range.
170 let addr_ranges = usableregions.map(|r| r.range.start_addr()..r.range.end_addr());
171
172 // This transforms to an iterator of the frame start addresses.
173 let frameaddr = addr_ranges.flat_map(|r| r.step_by(4096));
174
175 // This creates a PhysFrame type from each start address.
176 frameaddr.map(|addr| PhysFrame::containing_address(PhysAddr::new(addr)))
177 }
178}
179
180

Callers 1

allocate_frameMethod · 0.80

Calls 1

mapMethod · 0.45

Tested by

no test coverage detected