Struct x86_64::structures::paging::mapper::OffsetPageTable
source · pub struct OffsetPageTable<'a> { /* private fields */ }
Expand description
A Mapper implementation that requires that the complete physically memory is mapped at some offset in the virtual address space.
Implementations§
source§impl<'a> OffsetPageTable<'a>
impl<'a> OffsetPageTable<'a>
sourcepub unsafe fn new(
level_4_table: &'a mut PageTable,
phys_offset: VirtAddr
) -> Self
pub unsafe fn new( level_4_table: &'a mut PageTable, phys_offset: VirtAddr ) -> Self
Creates a new OffsetPageTable
that uses the given offset for converting virtual
to physical addresses.
The complete physical memory must be mapped in the virtual address space starting at
address phys_offset
. This means that for example physical address 0x5000
can be
accessed through virtual address phys_offset + 0x5000
. This mapping is required because
the mapper needs to access page tables, which are not mapped into the virtual address
space by default.
§Safety
This function is unsafe because the caller must guarantee that the passed phys_offset
is correct. Also, the passed level_4_table
must point to the level 4 page table
of a valid page table hierarchy. Otherwise this function might break memory safety, e.g.
by writing to an illegal memory location.
sourcepub fn level_4_table(&self) -> &PageTable
pub fn level_4_table(&self) -> &PageTable
Returns an immutable reference to the wrapped level 4 PageTable
instance.
sourcepub fn level_4_table_mut(&mut self) -> &mut PageTable
pub fn level_4_table_mut(&mut self) -> &mut PageTable
Returns a mutable reference to the wrapped level 4 PageTable
instance.
sourcepub fn phys_offset(&self) -> VirtAddr
pub fn phys_offset(&self) -> VirtAddr
Returns the offset used for converting virtual to physical addresses.