HhdmPhysMapper

Struct HhdmPhysMapper 

Source
pub struct HhdmPhysMapper;
Expand description

PhysMapper implementation for kernels with a higher-half direct map (HHDM).

This type allows you to convert a physical address to a usable pointer in the kernel’s virtual address space by adding HHDM_BASE to the physical address.

§Safety

  • The HHDM mapping must be present and cover the referenced physical range.
  • The returned pointer must only be used for valid, mapped, and writable memory.

§Example

use kernel_vmem::{addresses::PhysicalAddress, page_table::pt::PageTable, PhysMapper};
use kernel_alloc::phys_mapper::HhdmPhysMapper;
let phys = PhysicalAddress::new(0x1234_0000);
let mapper = HhdmPhysMapper;
unsafe {
    let table: &mut PageTable = mapper.phys_to_mut(phys);
}

Trait Implementations§

Source§

impl PhysMapper for HhdmPhysMapper

Source§

unsafe fn phys_to_mut<T>(&self, pa: PhysicalAddress) -> &mut T

Map a 4 KiB physical frame and get a mutable reference to type T. Read more

Auto Trait Implementations§

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> PhysMapperExt for T
where T: PhysMapper,

Source§

fn pml4_mut(&self, page: PhysicalPage<Size4K>) -> &mut PageMapLevel4

Borrow the PageMapLevel4 (PML4) located in the given 4 KiB physical frame. Read more
Source§

fn set_pml4(&self, page: PhysicalPage<Size4K>, pml4: PageMapLevel4)

Sets the provided PageMapLevel4 at the specified page.
Source§

fn zero_pml4(&self, page: PhysicalPage<Size4K>)

Sets the provided PageMapLevel4 at the specified page.
Source§

fn pdpt_mut(&self, page: PhysicalPage<Size4K>) -> &mut PageDirectoryPointerTable

Borrow a PageDirectoryPointerTable (PDPT) located in the given 4 KiB physical frame. Read more
Source§

fn set_pdpt(&self, page: PhysicalPage<Size4K>, pml4: PageDirectoryPointerTable)

Sets the provided PageDirectoryPointerTable at the specified page.
Source§

fn zero_pdpt(&self, page: PhysicalPage<Size4K>)

Sets the provided PageDirectoryPointerTable at the specified page.
Source§

fn pd_mut(&self, page: PhysicalPage<Size4K>) -> &mut PageDirectory

Borrow a PageDirectory (PD) located in the given 4 KiB physical frame. Read more
Source§

fn set_pd(&self, page: PhysicalPage<Size4K>, pml4: PageDirectory)

Sets the provided PageDirectory at the specified page.
Source§

fn zero_pd(&self, page: PhysicalPage<Size4K>)

Sets the provided PageDirectory at the specified page.
Source§

fn pt_mut(&self, page: PhysicalPage<Size4K>) -> &mut PageTable

Borrow a PageTable (PT) located in the given 4 KiB physical frame. Read more
Source§

fn set_pt(&self, page: PhysicalPage<Size4K>, pml4: PageTable)

Sets the provided PageTable at the specified page.
Source§

fn zero_pt(&self, page: PhysicalPage<Size4K>)

Sets the provided PageTable at the specified page.
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.