Struct VirtualMemoryManager

Source
pub struct VirtualMemoryManager {
    memmap: Vec<VirtualMemoryMap>,
    asid: usize,
}

Fields§

§memmap: Vec<VirtualMemoryMap>§asid: usize

Implementations§

Source§

impl VirtualMemoryManager

Source

pub fn new() -> Self

Creates a new virtual memory manager.

§Returns

A new virtual memory manager with default values.

Source

pub fn set_asid(&mut self, asid: usize)

Sets the ASID (Address Space ID) for the virtual memory manager.

§Arguments
  • asid - The ASID to set
Source

pub fn get_asid(&self) -> usize

Returns the ASID (Address Space ID) for the virtual memory manager.

§Returns

The ASID for the virtual memory manager.

Source

pub fn get_memmap(&self) -> &Vec<VirtualMemoryMap>

Source

pub fn add_memory_map( &mut self, map: VirtualMemoryMap, ) -> Result<(), &'static str>

Adds a memory map to the virtual memory manager.

§Arguments
  • map - The memory map to add
§Returns

A result indicating success or failure.

Source

pub fn get_memory_map(&self, idx: usize) -> Option<&VirtualMemoryMap>

Returns the memory map at the given index.

§Arguments
  • idx - The index of the memory map to retrieve
§Returns

The memory map at the given index, if it exists.

Source

pub fn remove_memory_map(&mut self, idx: usize) -> Option<VirtualMemoryMap>

Removes the memory map at the given index.

§Arguments
  • idx - The index of the memory map to remove
§Returns

The removed memory map, if it exists.

Source

pub fn remove_all_memory_maps(&mut self) -> Vec<VirtualMemoryMap>

Removes all memory maps.

§Returns

The removed memory maps.

Source

pub fn restore_memory_maps( &mut self, maps: Vec<VirtualMemoryMap>, ) -> Result<(), &'static str>

Restores the memory maps from a given vector.

§Arguments
  • maps - The vector of memory maps to restore
§Returns

A result indicating success or failure.

Source

pub fn search_memory_map(&self, vaddr: usize) -> Option<&VirtualMemoryMap>

Searches for a memory map containing the given virtual address.

§Arguments
  • vaddr - The virtual address to search for
§Returns

The memory map containing the given virtual address, if it exists.

Source

pub fn search_memory_map_idx(&self, vaddr: usize) -> Option<usize>

Searches for the index of a memory map containing the given virtual address.

§Arguments
  • vaddr - The virtual address to search for
§Returns

The index of the memory map containing the given virtual address, if it exists.

Source

pub fn get_root_page_table(&self) -> Option<&mut PageTable>

Returns the root page table for the current address space.

§Returns

The root page table for the current address space, if it exists.

Source

pub fn translate_vaddr(&self, vaddr: usize) -> Option<usize>

Translate a virtual address to physical address

§Arguments
  • vaddr - The virtual address to translate
§Returns

The translated physical address. Returns None if no mapping exists for the address

Trait Implementations§

Source§

impl Clone for VirtualMemoryManager

Source§

fn clone(&self) -> VirtualMemoryManager

Returns a copy of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VirtualMemoryManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for VirtualMemoryManager

§

impl RefUnwindSafe for VirtualMemoryManager

§

impl Send for VirtualMemoryManager

§

impl Sync for VirtualMemoryManager

§

impl Unpin for VirtualMemoryManager

§

impl UnwindSafe for VirtualMemoryManager

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> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.