pub(crate) struct Vmm;Expand description
Namespace for all VMM methods
Implementations§
Source§impl Vmm
impl Vmm
Sourcepub fn lazy_map_region(
address_space: &mut AddressSpace,
virt: VirtAddr,
size: u64,
vma_flags: VmaFlags,
) -> Result<(), VmmError>
pub fn lazy_map_region( address_space: &mut AddressSpace, virt: VirtAddr, size: u64, vma_flags: VmaFlags, ) -> Result<(), VmmError>
Lazily map a virtual memory region by creating a VMA in the given AddressSpace
§Panics
Panics in debug builds if either virt is not aligned to FRAME_SIZE or size
is not a multiple of FRAME_SIZE
§Returns
Returns VmmError::VmaOverlap if the given region overlaps with an existing VMA
Sourcepub fn map_region(
pmm: &mut Pmm,
address_space: &mut AddressSpace,
virt: VirtAddr,
size: u64,
vma_flags: VmaFlags,
) -> Result<(), VmmError>
pub fn map_region( pmm: &mut Pmm, address_space: &mut AddressSpace, virt: VirtAddr, size: u64, vma_flags: VmaFlags, ) -> Result<(), VmmError>
Map a virtual memory region by creating a VMA in the given AddressSpace and then mapping matching pages
This method first calls Vmm::lazy_map_region to create the VMA and do the debug align check,
and then eagerly maps the necessary pages
§Panics
Panics in debug builds if either virt is not aligned to FRAME_SIZE or size
is not a multiple of FRAME_SIZE
§Returns
Returns VmmError::VmaOverlap if the given region overlaps with an existing VMA
Sourcepub unsafe fn unmap_region(
pmm: &mut Pmm,
address_space: &mut AddressSpace,
virt: VirtAddr,
) -> Result<(), VmmError>where
Self: VmmPaging,
pub unsafe fn unmap_region(
pmm: &mut Pmm,
address_space: &mut AddressSpace,
virt: VirtAddr,
) -> Result<(), VmmError>where
Self: VmmPaging,
Unmap a virtual memory region by removing its VMA from the given AddressSpace and
unmapping all currently mapped pages
§Safety
The caller must ensure that no live code or data holds references into any address mapped
within [virt, vma.end_addr) after this method call returns
§Panics
Panics in debug builds if virt is not aligned to FRAME_SIZE
§Returns
Returns VmmError::VmaNotFound if no VMA starting at virt exists
Sourcepub unsafe fn remap_region(
address_space: &mut AddressSpace,
virt: VirtAddr,
new_vma_flags: VmaFlags,
) -> Result<(), VmmError>where
Self: VmmPaging,
pub unsafe fn remap_region(
address_space: &mut AddressSpace,
virt: VirtAddr,
new_vma_flags: VmaFlags,
) -> Result<(), VmmError>where
Self: VmmPaging,
Remap a virtual memory region by changing its VMA’s flags from the given AddressSpace and
remapping all currently mapped pages to new matching page flags.
§Safety
The caller must ensure that for example when removing the WRITE flag,
no mutable references to the to be modified memory is held.
§Panics
Panics in debug builds if virt is not aligned to FRAME_SIZE
§Returns
Returns VmmError::VmaNotFound if no VMA starting at virt exists
Trait Implementations§
Source§impl VmmPaging for Vmm
impl VmmPaging for Vmm
type PageType = PageType
type PageTableFlags = PageTableFlags
Source§fn setup_kernel_paging(
sections: &KernelSectionInfo,
) -> (VirtAddr, [BootMapping; 4])
fn setup_kernel_paging( sections: &KernelSectionInfo, ) -> (VirtAddr, [BootMapping; 4])
Source§unsafe fn map_page(
pmm: &mut Pmm,
page_ptr: VirtAddr,
virt: VirtAddr,
phys: PhysAddr,
page_type: Self::PageType,
flags: Self::PageTableFlags,
) -> Result<(), VmmError>
unsafe fn map_page( pmm: &mut Pmm, page_ptr: VirtAddr, virt: VirtAddr, phys: PhysAddr, page_type: Self::PageType, flags: Self::PageTableFlags, ) -> Result<(), VmmError>
Source§unsafe fn map_range(
pmm: &mut Pmm,
page_ptr: VirtAddr,
virt: VirtAddr,
phys: PhysAddr,
size: u64,
flags: Self::PageTableFlags,
can_overmap: bool,
) -> Result<(), VmmError>
unsafe fn map_range( pmm: &mut Pmm, page_ptr: VirtAddr, virt: VirtAddr, phys: PhysAddr, size: u64, flags: Self::PageTableFlags, can_overmap: bool, ) -> Result<(), VmmError>
Source§unsafe fn unmap_page(page_ptr: VirtAddr, virt: VirtAddr) -> Result<(), VmmError>
unsafe fn unmap_page(page_ptr: VirtAddr, virt: VirtAddr) -> Result<(), VmmError>
Source§unsafe fn remap_page(
page_ptr: VirtAddr,
virt: VirtAddr,
new_flags: Self::PageTableFlags,
) -> Result<(), VmmError>
unsafe fn remap_page( page_ptr: VirtAddr, virt: VirtAddr, new_flags: Self::PageTableFlags, ) -> Result<(), VmmError>
Source§fn translate(page_ptr: VirtAddr, virt: VirtAddr) -> Option<PhysAddr>
fn translate(page_ptr: VirtAddr, virt: VirtAddr) -> Option<PhysAddr>
virt or None if the
address is not mappedSource§fn translate_with_size(
page_ptr: VirtAddr,
virt: VirtAddr,
) -> Option<(PhysAddr, u64)>
fn translate_with_size( page_ptr: VirtAddr, virt: VirtAddr, ) -> Option<(PhysAddr, u64)>
virt and the size of
the page virt is mapped in, or None if the address is not mapped