fn can_map_as_large_page(
        &mut self,
        pdpt_entry: PDPTEntry,
        pbase: PAddr,
        psize: usize,
        vbase: VAddr,
        _rights: MapAction,
    ) -> bool {
        let pml4_idx = pml4_index(vbase);
        let pdpt_idx = pdpt_index(vbase);
        let pd_idx = pd_index(vbase);
        let pd_entry = {
            let pd = self.get_pd(pdpt_entry);
            pd[pd_idx]
        };

        // The virtual address corresponding to the current position within the page-table
        let vaddr_pos: VAddr = VAddr::from(
            PML4_SLOT_SIZE * pml4_idx + HUGE_PAGE_SIZE * pdpt_idx + LARGE_PAGE_SIZE * pd_idx,
        );

        let want_to_map_here = vbase == vaddr_pos;
        let physical_frame_is_aligned = pbase % LARGE_PAGE_SIZE == 0;
        let want_to_map_at_least_2mib = psize >= LARGE_PAGE_SIZE;

        if !want_to_map_here || !physical_frame_is_aligned || !want_to_map_at_least_2mib {
            return false;
        }

        let no_underlying_4kib_mappings = if !pd_entry.is_present() {
            true
        } else {
            // We go and check if the underlying page-table is emtpy
            // (previous mappings could've left a PT here which since has been emptied)
            let mut all_entries_empty: bool = true;
            let pt = self.get_pt(pd_entry);
            for i in 0..pt.len() {
                all_entries_empty &= !pt[i].is_present();
            }

            if all_entries_empty {
                // Reclaim PT page back to pager
                //warn!("TODO: pager.release_base_page()");
                let pd = self.get_pd_mut(pdpt_entry);
                pd[pd_idx] = PDEntry::new(PAddr::from(0x0), PDFlags::empty());
            }
            all_entries_empty
        };

        no_underlying_4kib_mappings
    }
/// Check if we can just insert a large page for the current mapping
Check if we can just insert a large page for the current mapping
Check if we can just insert a large page for the current mapping
fn can_map_as_large_page(
        &mut self,
        pdpt_entry: PDPTEntry,
        pbase: PAddr,
        psize: usize,
        vbase: VAddr,
        _rights: MapAction,
    ) -> bool {
        let pml4_idx = pml4_index(vbase);
        let pdpt_idx = pdpt_index(vbase);
        let pd_idx = pd_index(vbase);
        let pd_entry = {
            let pd = self.get_pd(pdpt_entry);
            pd[pd_idx]
        };
        // The virtual address corresponding to the current position within the page-table
        let vaddr_pos: VAddr = VAddr::from(
            PML4_SLOT_SIZE * pml4_idx + HUGE_PAGE_SIZE * pdpt_idx + LARGE_PAGE_SIZE * pd_idx,
        );
        let want_to_map_here = vbase == vaddr_pos;
        let physical_frame_is_aligned = pbase % LARGE_PAGE_SIZE == 0;
        let want_to_map_at_least_2mib = psize >= LARGE_PAGE_SIZE;
        if !want_to_map_here || !physical_frame_is_aligned || !want_to_map_at_least_2mib {
            return false;
        }
        let no_underlying_4kib_mappings = if !pd_entry.is_present() {
            true
        } else {
            // We go and check if the underlying page-table is emtpy
            // (previous mappings could've left a PT here which since has been emptied)
            let mut all_entries_empty: bool = true;
            let pt = self.get_pt(pd_entry);
            for i in 0..pt.len() {
                all_entries_empty &= !pt[i].is_present();
            }
            if all_entries_empty {
                // Reclaim PT page back to pager
                //warn!("TODO: pager.release_base_page()");
                let pd = self.get_pd_mut(pdpt_entry);
                pd[pd_idx] = PDEntry::new(PAddr::from(0x0), PDFlags::empty());
            }
            all_entries_empty
        };
        no_underlying_4kib_mappings
    }
fn can_map_as_large_page ( & mut self , pdpt_entry : PDPTEntry , pbase : PAddr , psize : usize , vbase : VAddr , _rights : MapAction , ) -> bool { let pml4_idx = pml4_index ( vbase ) ; let pdpt_idx = pdpt_index ( vbase ) ; let pd_idx = pd_index ( vbase ) ; let pd_entry = { let pd = self . get_pd ( pdpt_entry ) ; pd [ pd_idx ] } ; // The virtual address corresponding to the current position within the page-table let vaddr_pos : VAddr = VAddr :: from ( PML4_SLOT_SIZE * pml4_idx + HUGE_PAGE_SIZE * pdpt_idx + LARGE_PAGE_SIZE * pd_idx , ) ; let want_to_map_here = vbase == vaddr_pos ; let physical_frame_is_aligned = pbase % LARGE_PAGE_SIZE == 0 ; let want_to_map_at_least_2mib = psize >= LARGE_PAGE_SIZE ; if ! want_to_map_here || ! physical_frame_is_aligned || ! want_to_map_at_least_2mib { return false ; } let no_underlying_4kib_mappings = if ! pd_entry . is_present ( ) { true } else { // We go and check if the underlying page-table is emtpy // (previous mappings could've left a PT here which since has been emptied) let mut all_entries_empty : bool = true ; let pt = self . get_pt ( pd_entry ) ; for i in 0 .. pt . len ( ) { all_entries_empty &= ! pt [ i ] . is_present ( ) ; } if all_entries_empty { // Reclaim PT page back to pager //warn!("TODO: pager.release_base_page()"); let pd = self . get_pd_mut ( pdpt_entry ) ; pd [ pd_idx ] = PDEntry :: new ( PAddr :: from ( 0x0 ) , PDFlags :: empty ( ) ) ; } all_entries_empty } ; no_underlying_4kib_mappings }
Check if we can just insert a large page for the current mapping
Check if we can just insert a large page for the current mapping
&mut self
pdpt_entry
PDPTEntry
pbase
PAddr
psize
usize
vbase
VAddr
_rights
MapAction
&mut self
pdpt_entry
PDPTEntry
pbase
PAddr
psize
usize
vbase
VAddr
_rights
MapAction