Struct PciIommu

Source
pub struct PciIommu<'a> { /* private fields */ }
Expand description

Represents an IOMMU that controls DMA done by some PCI function, device, or group of devices.

You’ll probably need std::sync::atomic::fence or use types like AtomicU32 somewhere to synchronize accesses properly with the device.

Implementations§

Source§

impl PciIommu<'_>

Source

pub fn alignment(&self) -> usize

Both iova and process address must be aligned to this value.

This is always a power of 2, and never less than the system’s page size.

Source

pub fn valid_iova_ranges(&self) -> &[Range<u64>]

IOVA ranges given to PciIommu::map must be contained in one of the ranges that this method returns.

Source

pub fn max_num_mappings(&self) -> u32

The maximum number of mappings that may be in effect simultaneously.

Source

pub unsafe fn map( &self, iova: u64, length: usize, address: *const u8, device_permissions: Permissions, ) -> Result<()>

Add the given mapping to the IOMMU.

  • iova is the start address of the region in the device’s address space.
  • size is the length of the region.
  • address is a pointer (in the current process’ address space) to the start of the region to be mapped.

TODO: Alignment constraints?

§Safety

Must make sense.

Source

pub fn unmap(&self, iova: u64, size: usize) -> Result<()>

Remove the given mapping from the IOMMU.

TODO: Alignment constraints?

Must unmap exactly a full range that was previously mapped using PciIommu::map, or several full ranges as long as they are contiguous. Otherwise, this fails.

Auto Trait Implementations§

§

impl<'a> Freeze for PciIommu<'a>

§

impl<'a> !RefUnwindSafe for PciIommu<'a>

§

impl<'a> !Send for PciIommu<'a>

§

impl<'a> !Sync for PciIommu<'a>

§

impl<'a> Unpin for PciIommu<'a>

§

impl<'a> !UnwindSafe for PciIommu<'a>

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.