Skip to main content

Vmm

Struct Vmm 

Source
pub(crate) struct Vmm;
Expand description

Namespace for all VMM methods

Implementations§

Source§

impl Vmm

Source

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

Source

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

Source

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

Source

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

Source§

type PageType = PageType

Source§

type PageTableFlags = PageTableFlags

Source§

fn setup_kernel_paging( sections: &KernelSectionInfo, ) -> (VirtAddr, [BootMapping; 4])

Initialize the kernel page tables and load them Read more
Source§

unsafe fn map_page( pmm: &mut Pmm, page_ptr: VirtAddr, virt: VirtAddr, phys: PhysAddr, page_type: Self::PageType, flags: Self::PageTableFlags, ) -> Result<(), VmmError>

Map one virtual page to a physical frame. PRESENT is forced on regardless of flags. Read more
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>

Map a certain block of physical memory to virtual pages calculated by the method Read more
Source§

unsafe fn unmap_page(page_ptr: VirtAddr, virt: VirtAddr) -> Result<(), VmmError>

Unmap one virtual page Read more
Source§

unsafe fn remap_page( page_ptr: VirtAddr, virt: VirtAddr, new_flags: Self::PageTableFlags, ) -> Result<(), VmmError>

Change page table flags of an already mapped page Read more
Source§

fn translate(page_ptr: VirtAddr, virt: VirtAddr) -> Option<PhysAddr>

Walk the page tables and return the phys address mapped at virt or None if the address is not mapped
Source§

fn translate_with_size( page_ptr: VirtAddr, virt: VirtAddr, ) -> Option<(PhysAddr, u64)>

Walk the page tables and return a tuple of the phys address mapped at virt and the size of the page virt is mapped in, or None if the address is not mapped
Source§

fn vma_flags_to_page_flags(vma_flags: VmaFlags) -> Self::PageTableFlags

Translate VMA flags to arch-specific page table flags
Source§

unsafe fn clone_kernel_mappings(dst: VirtAddr)

Clone the kernel page’s mappings into a user page Read more

Auto Trait Implementations§

§

impl Freeze for Vmm

§

impl RefUnwindSafe for Vmm

§

impl Send for Vmm

§

impl Sync for Vmm

§

impl Unpin for Vmm

§

impl UnsafeUnpin for Vmm

§

impl UnwindSafe for Vmm

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = !

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.