MmioTransport

Struct MmioTransport 

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

MMIO Device Register Interface.

Ref: 4.2.2 MMIO Device Register Layout and 4.2.4 Legacy interface

Implementations§

Source§

impl<'a> MmioTransport<'a>

Source

pub unsafe fn new( header: NonNull<VirtIOHeader>, mmio_size: usize, ) -> Result<Self, MmioError>

Constructs a new VirtIO MMIO transport, or returns an error if the header reports an unsupported version.

§Safety

header must point to a properly aligned valid VirtIO MMIO region, which must remain valid for the lifetime 'a. This includes the config space following the header, if any.

Source

pub fn new_from_unique( header: UniqueMmioPointer<'a, VirtIOHeader>, config_space: UniqueMmioPointer<'a, [u8]>, ) -> Result<Self, MmioError>

Constructs a new VirtIO MMIO transport, or returns an error if the header reports an unsupported version.

Source

pub fn version(&self) -> MmioVersion

Gets the version of the VirtIO MMIO transport.

Source

pub fn vendor_id(&self) -> u32

Gets the vendor ID.

Trait Implementations§

Source§

impl<'a> Debug for MmioTransport<'a>

Source§

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

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

impl Drop for MmioTransport<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'a> From<MmioTransport<'a>> for SomeTransport<'a>

Source§

fn from(mmio: MmioTransport<'a>) -> Self

Converts to this type from the input type.
Source§

impl Transport for MmioTransport<'_>

Source§

fn device_type(&self) -> DeviceType

Gets the device type.
Source§

fn read_device_features(&mut self) -> u64

Reads device features.
Source§

fn write_driver_features(&mut self, driver_features: u64)

Writes device features.
Source§

fn max_queue_size(&mut self, queue: u16) -> u32

Gets the max size of the given queue.
Source§

fn notify(&mut self, queue: u16)

Notifies the given queue on the device.
Source§

fn get_status(&self) -> DeviceStatus

Gets the device status.
Source§

fn set_status(&mut self, status: DeviceStatus)

Sets the device status.
Source§

fn set_guest_page_size(&mut self, guest_page_size: u32)

Sets the guest page size.
Source§

fn requires_legacy_layout(&self) -> bool

Returns whether the transport requires queues to use the legacy layout. Read more
Source§

fn queue_set( &mut self, queue: u16, size: u32, descriptors: PhysAddr, driver_area: PhysAddr, device_area: PhysAddr, )

Sets up the given queue.
Source§

fn queue_unset(&mut self, queue: u16)

Disables and resets the given queue.
Source§

fn queue_used(&mut self, queue: u16) -> bool

Returns whether the queue is in use, i.e. has a nonzero PFN or is marked as ready.
Source§

fn ack_interrupt(&mut self) -> InterruptStatus

Acknowledges an interrupt. Read more
Source§

fn read_config_generation(&self) -> u32

Reads the configuration space generation.
Source§

fn read_config_space<T: FromBytes + IntoBytes>( &self, offset: usize, ) -> Result<T, Error>

Reads a value from the device config space.
Source§

fn write_config_space<T: IntoBytes + Immutable>( &mut self, offset: usize, value: T, ) -> Result<(), Error>

Writes a value to the device config space.
Source§

fn begin_init<F: Flags<Bits = u64> + BitAnd<Output = F> + Debug>( &mut self, supported_features: F, ) -> F

Begins initializing the device. Read more
Source§

fn finish_init(&mut self)

Finishes initializing the device.
Source§

fn read_consistent<T>(&self, f: impl Fn() -> Result<T>) -> Result<T>

Safely reads multiple fields from config space by ensuring that the config generation is the same before and after all reads, and retrying if not.
Source§

impl Sync for MmioTransport<'_>

Auto Trait Implementations§

§

impl<'a> Freeze for MmioTransport<'a>

§

impl<'a> RefUnwindSafe for MmioTransport<'a>

§

impl<'a> Send for MmioTransport<'a>

§

impl<'a> Unpin for MmioTransport<'a>

§

impl<'a> UnwindSafe for MmioTransport<'a>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.