pub struct AddressSpace<'a, PTE, Mapper, Error>{ /* private fields */ }Expand description
Abstracts a virtual address space.
Implementations§
Source§impl<'a, PTE, Mapper, Error> AddressSpace<'a, PTE, Mapper, Error>
impl<'a, PTE, Mapper, Error> AddressSpace<'a, PTE, Mapper, Error>
Sourcepub fn new(
format: PageFormat<'a, PTE>,
mapper: &'a mut Mapper,
root: PTE,
) -> Self
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.
Sourcepub fn read_pte(&self, virt_addr: usize) -> Result<PTE, Error>
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.
Sourcepub fn write_pte(&mut self, virt_addr: usize, pte: PTE) -> Result<(), Error>
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.
Sourcepub fn allocate_range(
&mut self,
range: Range<usize>,
mask: PTE,
) -> Result<(), Error>
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.
Sourcepub fn map_range(&mut self, range: Range<usize>, mask: PTE) -> Result<(), Error>
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.
Sourcepub fn protect_range(
&mut self,
range: Range<usize>,
mask: (PTE, PTE),
) -> Result<(), Error>
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.
Sourcepub fn free_range(&mut self, range: Range<usize>) -> Result<(), Error>
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.
Sourcepub fn unmap_range(&mut self, range: Range<usize>) -> Result<(), Error>
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.