/// Create a FrameAllocator from the passed memory map.
///
/// This function is unsafe because the caller must guarantee that the passed
/// memory map is valid. The main requirement is that all frames that are marked
/// as `USABLE` in it are really unused.
Create a FrameAllocator from the passed memory map.
This function is unsafe because the caller must guarantee that the passed
memory map is valid. The main requirement is that all frames that are marked
as `USABLE` in it are really unused.
Create a FrameAllocator from the passed memory map . This function is unsafe because the caller must guarantee that the passed memory map is valid . The main requirement is that all frames that are marked as ` USABLE ` in it are really unused .
pub unsafe fn init(memory_regions: &'static MemoryRegions) -> Self {
        // get usable regions from memory map
        let regions = memory_regions.iter();
        let usable_regions = regions.filter(|r| r.kind == MemoryRegionKind::Usable);
        // map each region to its address range
        let addr_ranges = usable_regions.map(|r| (r.start)..(r.end));
        // transform to an iterator of frame start addresses
        let frame_addresses = addr_ranges.flat_map(|r| r.step_by(Size4KiB::SIZE as usize));
        // create `PhysFrame` types from the start addresses
        let iter = frame_addresses.map(|addr| PhysFrame::containing_address(PhysAddr::new(addr)));
        GlobalFrameAllocator {
            iter,
            deallocated: None,
        }
    }
pub unsafe fn init ( memory_regions : & ' static MemoryRegions ) -> Self { // get usable regions from memory map let regions = memory_regions . iter ( ) ; let usable_regions = regions . filter ( | r | r . kind == MemoryRegionKind :: Usable ) ; // map each region to its address range let addr_ranges = usable_regions . map ( | r | ( r . start ) .. ( r . end ) ) ; // transform to an iterator of frame start addresses let frame_addresses = addr_ranges . flat_map ( | r | r . step_by ( Size4KiB :: SIZE as usize ) ) ; // create `PhysFrame` types from the start addresses let iter = frame_addresses . map ( | addr | PhysFrame :: containing_address ( PhysAddr :: new ( addr ) ) ) ; GlobalFrameAllocator { iter , deallocated : None , } }
Create a FrameAllocator from the passed memory map.
Create a FrameAllocator from the passed memory map .
memory_regions
&'static MemoryRegions