pub unsafe fn initialize(memory_map: &InitMemoryMap) {
    let free_regions = LockFreeList::new();

    for range in memory_map.heap_usable().iter() {
        let addr = range.start;
        let len  = range.end - range.start;

        // Align physical base address to page size.
        let mut physical_base = align_up(addr, PAGE_SIZE);

        // Remove remainder from length and count pages.
        let mut pages = (len - (addr % PAGE_SIZE)) / PAGE_SIZE;

        // If the base starts before SAFE_BOUNDARY, remove the pages before that
        // (and make sure we still have pages left).
        if physical_base < SAFE_BOUNDARY {
            let diff = (SAFE_BOUNDARY - physical_base) / PAGE_SIZE;

            if diff < pages {
                physical_base += diff * PAGE_SIZE;
                pages         -= diff;
            } else {
                continue; // skip this entry
            }
        }

        // If the entry has at least one page, add it to the free regions.
        if pages > 0 {
            free_regions.push(Node::new(FreeRegion {
                start: physical_base,
                length: pages.into(),
            }));
        }
    }

    let total_page_count = free_regions.iter().fold(0,
        |s, r| s + r.length.load(Relaxed));

    REGION_STATE = Some(RegionState {
        total_page_count,
        free_page_count: total_page_count.into(),
        free_regions,
        alloc_regions: LockFreeList::new(),
    });
}
/// Loads the memory map information into the region tree in order to know where
/// in physical memory it's safe to allocate fresh pages.
Loads the memory map information into the region tree in order to know where
in physical memory it's safe to allocate fresh pages.
Loads the memory map information into the region tree in order to know where in physical memory it ' s safe to allocate fresh pages .
pub unsafe fn initialize(memory_map: &InitMemoryMap) {
    let free_regions = LockFreeList::new();
    for range in memory_map.heap_usable().iter() {
        let addr = range.start;
        let len  = range.end - range.start;
        // Align physical base address to page size.
        let mut physical_base = align_up(addr, PAGE_SIZE);
        // Remove remainder from length and count pages.
        let mut pages = (len - (addr % PAGE_SIZE)) / PAGE_SIZE;
        // If the base starts before SAFE_BOUNDARY, remove the pages before that
        // (and make sure we still have pages left).
        if physical_base < SAFE_BOUNDARY {
            let diff = (SAFE_BOUNDARY - physical_base) / PAGE_SIZE;
            if diff < pages {
                physical_base += diff * PAGE_SIZE;
                pages         -= diff;
            } else {
                continue; // skip this entry
            }
        }
        // If the entry has at least one page, add it to the free regions.
        if pages > 0 {
            free_regions.push(Node::new(FreeRegion {
                start: physical_base,
                length: pages.into(),
            }));
        }
    }
    let total_page_count = free_regions.iter().fold(0,
        |s, r| s + r.length.load(Relaxed));
    REGION_STATE = Some(RegionState {
        total_page_count,
        free_page_count: total_page_count.into(),
        free_regions,
        alloc_regions: LockFreeList::new(),
    });
}
pub unsafe fn initialize ( memory_map : & InitMemoryMap ) { let free_regions = LockFreeList :: new ( ) ; for range in memory_map . heap_usable ( ) . iter ( ) { let addr = range . start ; let len = range . end - range . start ; // Align physical base address to page size. let mut physical_base = align_up ( addr , PAGE_SIZE ) ; // Remove remainder from length and count pages. let mut pages = ( len - ( addr % PAGE_SIZE ) ) / PAGE_SIZE ; // If the base starts before SAFE_BOUNDARY, remove the pages before that // (and make sure we still have pages left). if physical_base < SAFE_BOUNDARY { let diff = ( SAFE_BOUNDARY - physical_base ) / PAGE_SIZE ; if diff < pages { physical_base += diff * PAGE_SIZE ; pages -= diff ; } else { continue ; // skip this entry } } // If the entry has at least one page, add it to the free regions. if pages > 0 { free_regions . push ( Node :: new ( FreeRegion { start : physical_base , length : pages . into ( ) , } ) ) ; } } let total_page_count = free_regions . iter ( ) . fold ( 0 , | s , r | s + r . length . load ( Relaxed ) ) ; REGION_STATE = Some ( RegionState { total_page_count , free_page_count : total_page_count . into ( ) , free_regions , alloc_regions : LockFreeList :: new ( ) , } ) ; }
Loads the memory map information into the region tree in order to know where
in physical memory it's safe to allocate fresh pages.
Loads the memory map information into the region tree in order to know where in physical memory it ' s safe to allocate fresh pages .
memory_map
&InitMemoryMap