AddressSpace

Struct AddressSpace 

Source
pub struct AddressSpace<'a, PTE, Mapper, Error>
where PTE: FromPrimitive + PrimInt + Unsigned, Mapper: PageTableMapper<PTE, Error>,
{ /* private fields */ }
Expand description

Abstracts a virtual address space.

Implementations§

Source§

impl<'a, PTE, Mapper, Error> AddressSpace<'a, PTE, Mapper, Error>
where PTE: FromPrimitive + PrimInt + Unsigned, Mapper: PageTableMapper<PTE, Error>,

Source

pub fn new( format: PageFormat<'a, PTE>, mapper: &'a mut Mapper, root: PTE, ) -> Self

Creates a new address space for the given page table format descripting the page table hierarchy, the page table mapper and the pointer to the root of the page table hierarchy.

Source

pub fn read_pte(&self, virt_addr: usize) -> Result<PTE, Error>

Reads the PTE for the given the virtual address if the virtual address is valid.

Source

pub fn write_pte(&mut self, virt_addr: usize, pte: PTE) -> Result<(), Error>

Writes the PTE for the given virtual address if the virtual address is valid.

Source

pub fn allocate_range( &mut self, range: Range<usize>, mask: PTE, ) -> Result<(), Error>

Allocates pages and the underlying page tables for a given range in the virtual address space. The pages are protected using the given mask.

Source

pub fn map_range(&mut self, range: Range<usize>, mask: PTE) -> Result<(), Error>

Maps the given range in the virtual address space range to the given physical address offset and mask. Allocates the underlying page tables if they are missing. This is useful for memory-mapped I/O.

Source

pub fn protect_range( &mut self, range: Range<usize>, mask: (PTE, PTE), ) -> Result<(), Error>

Changes the protection flags of the given range in the virtual address space. The first mask specifies the full mask to clear the bits. The second mask specifies the bits that should be set.

Source

pub fn free_range(&mut self, range: Range<usize>) -> Result<(), Error>

Frees the pages for the given range in the virtual address space. If the underlying page tables have been cleared, then this function also free the underlying page tables.

Source

pub fn unmap_range(&mut self, range: Range<usize>) -> Result<(), Error>

Unmaps the pages for the given range in the virtual address space without freeing the underlying pages. This is useful for memory-mapped I/O.

Source

pub fn copy_from( &mut self, data: &mut [u8], address: usize, ) -> Result<(), Error>

Copies bytes starting at the given address into the given buffer.

Source

pub fn copy_to(&mut self, address: usize, data: &[u8]) -> Result<(), Error>

Copies bytes from the given buffer to the given address.

Auto Trait Implementations§

§

impl<'a, PTE, Mapper, Error> Freeze for AddressSpace<'a, PTE, Mapper, Error>
where PTE: Freeze,

§

impl<'a, PTE, Mapper, Error> RefUnwindSafe for AddressSpace<'a, PTE, Mapper, Error>
where PTE: RefUnwindSafe, Mapper: RefUnwindSafe, Error: RefUnwindSafe,

§

impl<'a, PTE, Mapper, Error> Send for AddressSpace<'a, PTE, Mapper, Error>
where PTE: Send + Sync, Mapper: Send, Error: Send,

§

impl<'a, PTE, Mapper, Error> Sync for AddressSpace<'a, PTE, Mapper, Error>
where PTE: Sync, Mapper: Sync, Error: Sync,

§

impl<'a, PTE, Mapper, Error> Unpin for AddressSpace<'a, PTE, Mapper, Error>
where PTE: Unpin, Error: Unpin,

§

impl<'a, PTE, Mapper, Error> !UnwindSafe for AddressSpace<'a, PTE, Mapper, Error>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.