x86_64::structures::paging::mapper

Struct MappedPageTable

Source
pub struct MappedPageTable<'a, P: PageTableFrameMapping> { /* private fields */ }
Expand description

A Mapper implementation that relies on a PhysAddr to VirtAddr conversion function.

This type requires that the all physical page table frames are mapped to some virtual address. Normally, this is done by mapping the complete physical address space into the virtual address space at some offset. Other mappings between physical and virtual memory are possible too, as long as they can be calculated as an PhysAddr to VirtAddr closure.

Implementations§

Source§

impl<'a, P: PageTableFrameMapping> MappedPageTable<'a, P>

Source

pub unsafe fn new( level_4_table: &'a mut PageTable, page_table_frame_mapping: P, ) -> Self

Creates a new MappedPageTable that uses the passed PageTableFrameMapping for converting virtual to physical addresses.

§Safety

This function is unsafe because the caller must guarantee that the passed page_table_frame_mapping PageTableFrameMapping 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.

Source

pub fn level_4_table(&self) -> &PageTable

Returns an immutable reference to the wrapped level 4 PageTable instance.

Source

pub fn level_4_table_mut(&mut self) -> &mut PageTable

Returns a mutable reference to the wrapped level 4 PageTable instance.

Source

pub fn page_table_frame_mapping(&self) -> &P

Returns the PageTableFrameMapping used for converting virtual to physical addresses.

Trait Implementations§

Source§

impl<'a, P: PageTableFrameMapping> CleanUp for MappedPageTable<'a, P>

Source§

unsafe fn clean_up<D>(&mut self, frame_deallocator: &mut D)

Remove all empty P1-P3 tables Read more
Source§

unsafe fn clean_up_addr_range<D>( &mut self, range: PageRangeInclusive, frame_deallocator: &mut D, )

Remove all empty P1-P3 tables in a certain range Read more
Source§

impl<'a, P: Debug + PageTableFrameMapping> Debug for MappedPageTable<'a, P>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a, P: PageTableFrameMapping> Mapper<Size1GiB> for MappedPageTable<'a, P>

Source§

unsafe fn map_to_with_table_flags<A>( &mut self, page: Page<Size1GiB>, frame: PhysFrame<Size1GiB>, flags: PageTableFlags, parent_table_flags: PageTableFlags, allocator: &mut A, ) -> Result<MapperFlush<Size1GiB>, MapToError<Size1GiB>>

Creates a new mapping in the page table. Read more
Source§

fn unmap( &mut self, page: Page<Size1GiB>, ) -> Result<(PhysFrame<Size1GiB>, MapperFlush<Size1GiB>), UnmapError>

Removes a mapping from the page table and returns the frame that used to be mapped. Read more
Source§

unsafe fn update_flags( &mut self, page: Page<Size1GiB>, flags: PageTableFlags, ) -> Result<MapperFlush<Size1GiB>, FlagUpdateError>

Updates the flags of an existing mapping. Read more
Source§

unsafe fn set_flags_p4_entry( &mut self, page: Page<Size1GiB>, flags: PageTableFlags, ) -> Result<MapperFlushAll, FlagUpdateError>

Set the flags of an existing page level 4 table entry Read more
Source§

unsafe fn set_flags_p3_entry( &mut self, _page: Page<Size1GiB>, _flags: PageTableFlags, ) -> Result<MapperFlushAll, FlagUpdateError>

Set the flags of an existing page table level 3 entry Read more
Source§

unsafe fn set_flags_p2_entry( &mut self, _page: Page<Size1GiB>, _flags: PageTableFlags, ) -> Result<MapperFlushAll, FlagUpdateError>

Set the flags of an existing page table level 2 entry Read more
Source§

fn translate_page( &self, page: Page<Size1GiB>, ) -> Result<PhysFrame<Size1GiB>, TranslateError>

Return the frame that the specified page is mapped to. Read more
Source§

unsafe fn map_to<A>( &mut self, page: Page<S>, frame: PhysFrame<S>, flags: PageTableFlags, frame_allocator: &mut A, ) -> Result<MapperFlush<S>, MapToError<S>>
where Self: Sized, A: FrameAllocator<Size4KiB> + ?Sized,

Creates a new mapping in the page table. Read more
Source§

unsafe fn identity_map<A>( &mut self, frame: PhysFrame<S>, flags: PageTableFlags, frame_allocator: &mut A, ) -> Result<MapperFlush<S>, MapToError<S>>
where Self: Sized + Mapper<S>, A: FrameAllocator<Size4KiB> + ?Sized, S: PageSize,

Maps the given frame to the virtual page with the same address. Read more
Source§

impl<'a, P: PageTableFrameMapping> Mapper<Size2MiB> for MappedPageTable<'a, P>

Source§

unsafe fn map_to_with_table_flags<A>( &mut self, page: Page<Size2MiB>, frame: PhysFrame<Size2MiB>, flags: PageTableFlags, parent_table_flags: PageTableFlags, allocator: &mut A, ) -> Result<MapperFlush<Size2MiB>, MapToError<Size2MiB>>

Creates a new mapping in the page table. Read more
Source§

fn unmap( &mut self, page: Page<Size2MiB>, ) -> Result<(PhysFrame<Size2MiB>, MapperFlush<Size2MiB>), UnmapError>

Removes a mapping from the page table and returns the frame that used to be mapped. Read more
Source§

unsafe fn update_flags( &mut self, page: Page<Size2MiB>, flags: PageTableFlags, ) -> Result<MapperFlush<Size2MiB>, FlagUpdateError>

Updates the flags of an existing mapping. Read more
Source§

unsafe fn set_flags_p4_entry( &mut self, page: Page<Size2MiB>, flags: PageTableFlags, ) -> Result<MapperFlushAll, FlagUpdateError>

Set the flags of an existing page level 4 table entry Read more
Source§

unsafe fn set_flags_p3_entry( &mut self, page: Page<Size2MiB>, flags: PageTableFlags, ) -> Result<MapperFlushAll, FlagUpdateError>

Set the flags of an existing page table level 3 entry Read more
Source§

unsafe fn set_flags_p2_entry( &mut self, _page: Page<Size2MiB>, _flags: PageTableFlags, ) -> Result<MapperFlushAll, FlagUpdateError>

Set the flags of an existing page table level 2 entry Read more
Source§

fn translate_page( &self, page: Page<Size2MiB>, ) -> Result<PhysFrame<Size2MiB>, TranslateError>

Return the frame that the specified page is mapped to. Read more
Source§

unsafe fn map_to<A>( &mut self, page: Page<S>, frame: PhysFrame<S>, flags: PageTableFlags, frame_allocator: &mut A, ) -> Result<MapperFlush<S>, MapToError<S>>
where Self: Sized, A: FrameAllocator<Size4KiB> + ?Sized,

Creates a new mapping in the page table. Read more
Source§

unsafe fn identity_map<A>( &mut self, frame: PhysFrame<S>, flags: PageTableFlags, frame_allocator: &mut A, ) -> Result<MapperFlush<S>, MapToError<S>>
where Self: Sized + Mapper<S>, A: FrameAllocator<Size4KiB> + ?Sized, S: PageSize,

Maps the given frame to the virtual page with the same address. Read more
Source§

impl<'a, P: PageTableFrameMapping> Mapper<Size4KiB> for MappedPageTable<'a, P>

Source§

unsafe fn map_to_with_table_flags<A>( &mut self, page: Page<Size4KiB>, frame: PhysFrame<Size4KiB>, flags: PageTableFlags, parent_table_flags: PageTableFlags, allocator: &mut A, ) -> Result<MapperFlush<Size4KiB>, MapToError<Size4KiB>>

Creates a new mapping in the page table. Read more
Source§

fn unmap( &mut self, page: Page<Size4KiB>, ) -> Result<(PhysFrame<Size4KiB>, MapperFlush<Size4KiB>), UnmapError>

Removes a mapping from the page table and returns the frame that used to be mapped. Read more
Source§

unsafe fn update_flags( &mut self, page: Page<Size4KiB>, flags: PageTableFlags, ) -> Result<MapperFlush<Size4KiB>, FlagUpdateError>

Updates the flags of an existing mapping. Read more
Source§

unsafe fn set_flags_p4_entry( &mut self, page: Page<Size4KiB>, flags: PageTableFlags, ) -> Result<MapperFlushAll, FlagUpdateError>

Set the flags of an existing page level 4 table entry Read more
Source§

unsafe fn set_flags_p3_entry( &mut self, page: Page<Size4KiB>, flags: PageTableFlags, ) -> Result<MapperFlushAll, FlagUpdateError>

Set the flags of an existing page table level 3 entry Read more
Source§

unsafe fn set_flags_p2_entry( &mut self, page: Page<Size4KiB>, flags: PageTableFlags, ) -> Result<MapperFlushAll, FlagUpdateError>

Set the flags of an existing page table level 2 entry Read more
Source§

fn translate_page( &self, page: Page<Size4KiB>, ) -> Result<PhysFrame<Size4KiB>, TranslateError>

Return the frame that the specified page is mapped to. Read more
Source§

unsafe fn map_to<A>( &mut self, page: Page<S>, frame: PhysFrame<S>, flags: PageTableFlags, frame_allocator: &mut A, ) -> Result<MapperFlush<S>, MapToError<S>>
where Self: Sized, A: FrameAllocator<Size4KiB> + ?Sized,

Creates a new mapping in the page table. Read more
Source§

unsafe fn identity_map<A>( &mut self, frame: PhysFrame<S>, flags: PageTableFlags, frame_allocator: &mut A, ) -> Result<MapperFlush<S>, MapToError<S>>
where Self: Sized + Mapper<S>, A: FrameAllocator<Size4KiB> + ?Sized, S: PageSize,

Maps the given frame to the virtual page with the same address. Read more
Source§

impl<'a, P: PageTableFrameMapping> Translate for MappedPageTable<'a, P>

Source§

fn translate(&self, addr: VirtAddr) -> TranslateResult

Return the frame that the given virtual address is mapped to and the offset within that frame. Read more
Source§

fn translate_addr(&self, addr: VirtAddr) -> Option<PhysAddr>

Translates the given virtual address to the physical address that it maps to. Read more

Auto Trait Implementations§

§

impl<'a, P> Freeze for MappedPageTable<'a, P>
where P: Freeze,

§

impl<'a, P> RefUnwindSafe for MappedPageTable<'a, P>
where P: RefUnwindSafe,

§

impl<'a, P> Send for MappedPageTable<'a, P>
where P: Send,

§

impl<'a, P> Sync for MappedPageTable<'a, P>
where P: Sync,

§

impl<'a, P> Unpin for MappedPageTable<'a, P>
where P: Unpin,

§

impl<'a, P> !UnwindSafe for MappedPageTable<'a, P>

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.
Source§

impl<T> MapperAllSizes for T