MCPcopy Create free account
hub / github.com/Ruddle/Fomos / usable_frames

Method usable_frames

bootloader/kernel/src/memory.rs:67–77  ·  view source on GitHub ↗

Returns an iterator over the usable frames specified in the memory map.

(&self)

Source from the content-addressed store, hash-verified

65
66 /// Returns an iterator over the usable frames specified in the memory map.
67 fn usable_frames(&self) -> impl Iterator<Item = PhysFrame> {
68 // get usable regions from memory map
69 let regions = self.memory_map.iter();
70 let usable_regions = regions.filter(|r| r.kind == MemoryRegionKind::Usable);
71 // map each region to its address range
72 let addr_ranges = usable_regions.map(|r| r.start..r.end);
73 // transform to an iterator of frame start addresses
74 let frame_addresses = addr_ranges.flat_map(|r| r.step_by(4096));
75 // create `PhysFrame` types from the start addresses
76 frame_addresses.map(|addr| PhysFrame::containing_address(PhysAddr::new(addr)))
77 }
78}
79
80unsafe impl FrameAllocator<Size4KiB> for BootInfoFrameAllocator {

Callers 1

allocate_frameMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected