IoPageTable

Struct IoPageTable 

Source
pub struct IoPageTable<F: IoPageTableFmt> { /* private fields */ }
Expand description

An io page table using a specific format.

§Invariants

The pointer references a valid io page table.

Implementations§

Source§

impl<F: IoPageTableFmt> IoPageTable<F>

Source

pub fn new( dev: &Device<Bound>, config: Config, ) -> impl PinInit<Devres<IoPageTable<F>>, Error> + '_

Create a new IoPageTable as a device resource.

Source

pub unsafe fn new_raw( dev: &Device<Bound>, config: Config, ) -> Result<IoPageTable<F>>

Create a new IoPageTable.

§Safety

If successful, then the returned IoPageTable must be dropped before the device is unbound.

Source

pub fn raw_ops(&self) -> *mut io_pgtable_ops

Obtain a raw pointer to the underlying struct io_pgtable_ops.

Source

pub fn raw_pgtable(&self) -> *mut io_pgtable

Obtain a raw pointer to the underlying struct io_pgtable.

Source

pub fn raw_cfg(&self) -> *mut io_pgtable_cfg

Obtain a raw pointer to the underlying struct io_pgtable_cfg.

Source

pub unsafe fn map_pages( &self, iova: usize, paddr: PhysAddr, pgsize: usize, pgcount: usize, prot: u32, flags: Flags, ) -> (usize, Result)

Map a physically contiguous range of pages of the same size.

Even if successful, this operation may not map the entire range. In that case, only a prefix of the range is mapped, and the returned integer indicates its length in bytes. In this case, the caller will usually call map_pages again for the remaining range.

The returned Result indicates whether an error was encountered while mapping pages. Note that this may return a non-zero length even if an error was encountered. The caller will usually unmap the relevant pages on error.

The caller must flush the TLB before using the pgtable to access the newly created mapping.

§Safety
  • No other io-pgtable operation may access the range iova .. iova+pgsize*pgcount while this map_pages operation executes.
  • This page table must not contain any mapping that overlaps with the mapping created by this call.
  • If this page table is live, then the caller must ensure that it’s okay to access the physical address being mapped for the duration in which it is mapped.
Source

pub unsafe fn unmap_pages( &self, iova: usize, pgsize: usize, pgcount: usize, ) -> usize

Unmap a range of virtually contiguous pages of the same size.

This may not unmap the entire range, and returns the length of the unmapped prefix in bytes.

§Safety
  • No other io-pgtable operation may access the range iova .. iova+pgsize*pgcount while this unmap_pages operation executes.
  • This page table must contain one or more consecutive mappings starting at iova whose total size is pgcount * pgsize.
Source§

impl IoPageTable<ARM64LPAES1>

Source

pub unsafe fn ttbr(&self) -> u64

Access the ttbr field of the configuration.

This is the physical address of the page table, which may be passed to the device that needs to use it.

§Safety

The caller must ensure that the device stops using the page table before dropping it.

Source

pub fn mair(&self) -> u64

Access the mair field of the configuration.

Trait Implementations§

Source§

impl<F: IoPageTableFmt> Drop for IoPageTable<F>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<F: IoPageTableFmt> Send for IoPageTable<F>

Source§

impl<F: IoPageTableFmt> Sync for IoPageTable<F>

Auto Trait Implementations§

§

impl<F> Freeze for IoPageTable<F>

§

impl<F> RefUnwindSafe for IoPageTable<F>
where F: RefUnwindSafe,

§

impl<F> Unpin for IoPageTable<F>
where F: Unpin,

§

impl<F> UnwindSafe for IoPageTable<F>
where F: UnwindSafe,

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> Init<T> for T

Source§

unsafe fn __init(self, slot: *mut T) -> Result<(), Infallible>

Initializes slot. Read more
Source§

fn chain<F>(self, f: F) -> ChainInit<Self, F, T, E>
where F: FnOnce(&mut T) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
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> PinInit<T> for T

Source§

unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>

Initializes slot. Read more
Source§

fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>
where F: FnOnce(Pin<&mut T>) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
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, U, const N: u32> TryIntoBounded<T, N> for U
where T: Integer, U: TryInto<T>,

Source§

fn try_into_bounded(self) -> Option<Bounded<T, N>>

Attempts to convert self into a Bounded using N bits. Read more