Skip to main content

AddressSpace

Struct AddressSpace 

Source
pub struct AddressSpace {
    page_ptr: VirtAddr,
    vmas: BTreeSet<Vma>,
}
Expand description

Type to represent the memory of a process or the kernel by holding a pointer to its page tables and VMAs

Fields§

§page_ptr: VirtAddr§vmas: BTreeSet<Vma>

Implementations§

Source§

impl AddressSpace

Source

pub fn empty(page_ptr: VirtAddr) -> Self

Creates a new AddressSpace instance which contains the given page table pointer and no VMAs

Source

pub unsafe fn new_user_addr_space() -> Self

Create a new address space with a zeroed root page, and copy the kernel mappings into the higher half

§Safety

The caller must guarantee that boot stage 2 has already been completed

Source

pub fn page_ptr(&self) -> VirtAddr

Getter for AddressSpace::page_ptr

Source

pub fn vmas(&self) -> &BTreeSet<Vma>

Getter for AddressSpace::vmas

Source

pub fn setup_kernel_vmas( &mut self, boot_mappings: &[BootMapping; 4], ) -> Result<(), VmmError>

Initializes Kernel VMAs on self Do not call this ever, unless you are initializing the kernel’s address space

Source

pub fn insert_vma(&mut self, vma: Vma) -> Result<(), VmmError>

Add a VMA to the AddressSpace

Source

pub fn remove_vma(&mut self, vma_start_addr: VirtAddr) -> Option<Vma>

Remove a VMA from the AddressSpace Returns whether the element to remove existed and could be removed or not

Source

pub fn find_vma(&self, addr: VirtAddr) -> Option<&Vma>

Search for a VMA in the AddressSpace which applies VMA flags to the given VirtAddr Returns a reference to the VMA wrapped in an option incase it is not found

Source

pub fn find_free_range( &self, from: VirtAddr, to: VirtAddr, size: u64, ) -> Option<VirtAddr>

Search for a VMA-free range of size bytes in [from, to) Returns the lowest address where such a range fits, or [None] if such a range couldn’t be found between VMAs

Auto Trait Implementations§

§

impl Freeze for AddressSpace

§

impl RefUnwindSafe for AddressSpace

§

impl Send for AddressSpace

§

impl Sync for AddressSpace

§

impl Unpin for AddressSpace

§

impl UnsafeUnpin for AddressSpace

§

impl UnwindSafe for AddressSpace

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.