pub fn map_memory<T: Mapper<Size4KiB> + Mapper<Size2MiB>>(
        &mut self,
        mapper: &mut T,
        map_from: PhysAddr,
        map_to: VirtAddr,
        size: usize,
        flags: PageTableFlags,
        parent_flags: PageTableFlags,
    ) -> Result<(), AllocateError> {
        if size == 0 {
            return Err(AllocateError::ZeroSize);
        }

        let frame_range_from = {
            let start = map_from;
            let end = start + size - 1u64;
            let start_frame = PhysFrame::<Size4KiB>::containing_address(start);
            let end_frame = PhysFrame::<Size4KiB>::containing_address(end);
            PhysFrame::range_inclusive(start_frame, end_frame)
        };

        let page_range_to = {
            let start = map_to;
            let end = start + size - 1u64;
            let start_page = Page::<Size4KiB>::containing_address(start);
            let end_page = Page::<Size4KiB>::containing_address(end);
            Page::range_inclusive(start_page, end_page)
        };

        for (frame_from, page_to) in frame_range_from.zip(page_range_to) {
            unsafe {
                mapper
                    .map_to_with_table_flags(page_to, frame_from, flags, parent_flags, self)
                    .map_err(|e| match e {
                        MapToError::FrameAllocationFailed => AllocateError::OutOfMemory,
                        MapToError::ParentEntryHugePage => AllocateError::ParentEntryHugePage,
                        MapToError::PageAlreadyMapped(_) => AllocateError::PageAlreadyMapped,
                    })?
                    .ignore();
            }
        }
        flush_all();

        Ok(())
    }
/// Map physical memory to the given virtual address
///
/// FIXME: change PhysAddr to ShimPhysAddr to ensure encrypted memory
Map physical memory to the given virtual address
FIXME: change PhysAddr to ShimPhysAddr to ensure encrypted memory
Map physical memory to the given virtual address FIXME : change PhysAddr to ShimPhysAddr to ensure encrypted memory
pub fn map_memory<T: Mapper<Size4KiB> + Mapper<Size2MiB>>(
        &mut self,
        mapper: &mut T,
        map_from: PhysAddr,
        map_to: VirtAddr,
        size: usize,
        flags: PageTableFlags,
        parent_flags: PageTableFlags,
    ) -> Result<(), AllocateError> {
        if size == 0 {
            return Err(AllocateError::ZeroSize);
        }
        let frame_range_from = {
            let start = map_from;
            let end = start + size - 1u64;
            let start_frame = PhysFrame::<Size4KiB>::containing_address(start);
            let end_frame = PhysFrame::<Size4KiB>::containing_address(end);
            PhysFrame::range_inclusive(start_frame, end_frame)
        };
        let page_range_to = {
            let start = map_to;
            let end = start + size - 1u64;
            let start_page = Page::<Size4KiB>::containing_address(start);
            let end_page = Page::<Size4KiB>::containing_address(end);
            Page::range_inclusive(start_page, end_page)
        };
        for (frame_from, page_to) in frame_range_from.zip(page_range_to) {
            unsafe {
                mapper
                    .map_to_with_table_flags(page_to, frame_from, flags, parent_flags, self)
                    .map_err(|e| match e {
                        MapToError::FrameAllocationFailed => AllocateError::OutOfMemory,
                        MapToError::ParentEntryHugePage => AllocateError::ParentEntryHugePage,
                        MapToError::PageAlreadyMapped(_) => AllocateError::PageAlreadyMapped,
                    })?
                    .ignore();
            }
        }
        flush_all();
        Ok(())
    }
pub fn map_memory < T : Mapper < Size4KiB > + Mapper < Size2MiB > > ( & mut self , mapper : & mut T , map_from : PhysAddr , map_to : VirtAddr , size : usize , flags : PageTableFlags , parent_flags : PageTableFlags , ) -> Result < ( ) , AllocateError > { if size == 0 { return Err ( AllocateError :: ZeroSize ) ; } let frame_range_from = { let start = map_from ; let end = start + size - 1u64 ; let start_frame = PhysFrame :: < Size4KiB > :: containing_address ( start ) ; let end_frame = PhysFrame :: < Size4KiB > :: containing_address ( end ) ; PhysFrame :: range_inclusive ( start_frame , end_frame ) } ; let page_range_to = { let start = map_to ; let end = start + size - 1u64 ; let start_page = Page :: < Size4KiB > :: containing_address ( start ) ; let end_page = Page :: < Size4KiB > :: containing_address ( end ) ; Page :: range_inclusive ( start_page , end_page ) } ; for ( frame_from , page_to ) in frame_range_from . zip ( page_range_to ) { unsafe { mapper . map_to_with_table_flags ( page_to , frame_from , flags , parent_flags , self ) . map_err ( | e | match e { MapToError :: FrameAllocationFailed => AllocateError :: OutOfMemory , MapToError :: ParentEntryHugePage => AllocateError :: ParentEntryHugePage , MapToError :: PageAlreadyMapped ( _ ) => AllocateError :: PageAlreadyMapped , } ) ? . ignore ( ) ; } } flush_all ( ) ; Ok ( ( ) ) }
Map physical memory to the given virtual address
FIXME: change PhysAddr to ShimPhysAddr to ensure encrypted memory
Map physical memory to the given virtual address FIXME : change PhysAddr to ShimPhysAddr to ensure encrypted memory
&mut self
mapper
&mut T
map_from
PhysAddr
map_to
VirtAddr
size
usize
flags
PageTableFlags
parent_flags
PageTableFlags
&mut self
mapper
&mut T
map_from
PhysAddr
map_to
VirtAddr
size
usize
flags
PageTableFlags
parent_flags
PageTableFlags