fn map_to_4kib<A>(
        &mut self,
        page: Page<Size4KiB>,
        frame: PhysFrame<Size4KiB>,
        flags: PageTableFlags,
        attr: PageTableAttribute,
        allocator: &mut A,
    ) -> Result<MapperFlush<Size4KiB>, MapToError>
    where
        A: FrameAllocator<Size4KiB>,
    {
        let p4 = &mut self.level_4_table;
        let p3 = self
            .page_table_walker
            .create_next_table(&mut p4[page.p4_index()], allocator)?;
        let p2 = self
            .page_table_walker
            .create_next_table(&mut p3[page.p3_index()], allocator)?;
        let p1 = self
            .page_table_walker
            .create_next_table(&mut p2[page.p2_index()], allocator)?;

        if !p1[page.p1_index()].is_unused() {
            return Err(MapToError::PageAlreadyMapped);
        }
        p1[page.p1_index()].set_frame(frame, flags, attr);

        Ok(MapperFlush::new(page))
    }
/// Helper function for implementing Mapper. Safe to limit the scope of unsafe, see
/// https://github.com/rust-lang/rfcs/pull/2585.
Helper function for implementing Mapper.
Helper function for implementing Mapper .
fn map_to_4kib<A>(
        &mut self,
        page: Page<Size4KiB>,
        frame: PhysFrame<Size4KiB>,
        flags: PageTableFlags,
        attr: PageTableAttribute,
        allocator: &mut A,
    ) -> Result<MapperFlush<Size4KiB>, MapToError>
    where
        A: FrameAllocator<Size4KiB>,
    {
        let p4 = &mut self.level_4_table;
        let p3 = self
            .page_table_walker
            .create_next_table(&mut p4[page.p4_index()], allocator)?;
        let p2 = self
            .page_table_walker
            .create_next_table(&mut p3[page.p3_index()], allocator)?;
        let p1 = self
            .page_table_walker
            .create_next_table(&mut p2[page.p2_index()], allocator)?;
        if !p1[page.p1_index()].is_unused() {
            return Err(MapToError::PageAlreadyMapped);
        }
        p1[page.p1_index()].set_frame(frame, flags, attr);
        Ok(MapperFlush::new(page))
    }
fn map_to_4kib < A > ( & mut self , page : Page < Size4KiB > , frame : PhysFrame < Size4KiB > , flags : PageTableFlags , attr : PageTableAttribute , allocator : & mut A , ) -> Result < MapperFlush < Size4KiB > , MapToError > where A : FrameAllocator < Size4KiB > , { let p4 = & mut self . level_4_table ; let p3 = self . page_table_walker . create_next_table ( & mut p4 [ page . p4_index ( ) ] , allocator ) ? ; let p2 = self . page_table_walker . create_next_table ( & mut p3 [ page . p3_index ( ) ] , allocator ) ? ; let p1 = self . page_table_walker . create_next_table ( & mut p2 [ page . p2_index ( ) ] , allocator ) ? ; if ! p1 [ page . p1_index ( ) ] . is_unused ( ) { return Err ( MapToError :: PageAlreadyMapped ) ; } p1 [ page . p1_index ( ) ] . set_frame ( frame , flags , attr ) ; Ok ( MapperFlush :: new ( page ) ) }
Helper function for implementing Mapper.
Helper function for implementing Mapper .
&mut self
page
Page<Size4KiB>
frame
PhysFrame<Size4KiB>
flags
PageTableFlags
attr
PageTableAttribute
allocator
&mut A