Struct MmioTransport
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§
§impl<'a> MmioTransport<'a>
impl<'a> MmioTransport<'a>
pub unsafe fn new(
header: NonNull<VirtIOHeader>,
mmio_size: usize,
) -> Result<MmioTransport<'a>, MmioError>
pub unsafe fn new( header: NonNull<VirtIOHeader>, mmio_size: usize, ) -> Result<MmioTransport<'a>, 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.
pub fn new_from_unique(
header: UniqueMmioPointer<'a, VirtIOHeader>,
config_space: UniqueMmioPointer<'a, [u8]>,
) -> Result<MmioTransport<'a>, MmioError>
pub fn new_from_unique( header: UniqueMmioPointer<'a, VirtIOHeader>, config_space: UniqueMmioPointer<'a, [u8]>, ) -> Result<MmioTransport<'a>, MmioError>
Constructs a new VirtIO MMIO transport, or returns an error if the header reports an unsupported version.
pub fn version(&self) -> MmioVersion
pub fn version(&self) -> MmioVersion
Gets the version of the VirtIO MMIO transport.
Trait Implementations§
§impl<'a> Debug for MmioTransport<'a>
impl<'a> Debug for MmioTransport<'a>
§impl Transport for MmioTransport<'_>
impl Transport for MmioTransport<'_>
§fn device_type(&self) -> DeviceType
fn device_type(&self) -> DeviceType
Gets the device type.
§fn read_device_features(&mut self) -> u64
fn read_device_features(&mut self) -> u64
Reads device features.
§fn write_driver_features(&mut self, driver_features: u64)
fn write_driver_features(&mut self, driver_features: u64)
Writes device features.
§fn max_queue_size(&mut self, queue: u16) -> u32
fn max_queue_size(&mut self, queue: u16) -> u32
Gets the max size of the given queue.
§fn get_status(&self) -> DeviceStatus
fn get_status(&self) -> DeviceStatus
Gets the device status.
§fn set_status(&mut self, status: DeviceStatus)
fn set_status(&mut self, status: DeviceStatus)
Sets the device status.
§fn set_guest_page_size(&mut self, guest_page_size: u32)
fn set_guest_page_size(&mut self, guest_page_size: u32)
Sets the guest page size.
§fn requires_legacy_layout(&self) -> bool
fn requires_legacy_layout(&self) -> bool
Returns whether the transport requires queues to use the legacy layout. Read more
§fn queue_set(
&mut self,
queue: u16,
size: u32,
descriptors: u64,
driver_area: u64,
device_area: u64,
)
fn queue_set( &mut self, queue: u16, size: u32, descriptors: u64, driver_area: u64, device_area: u64, )
Sets up the given queue.
§fn queue_unset(&mut self, queue: u16)
fn queue_unset(&mut self, queue: u16)
Disables and resets the given queue.
§fn queue_used(&mut self, queue: u16) -> bool
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.
§fn ack_interrupt(&mut self) -> InterruptStatus
fn ack_interrupt(&mut self) -> InterruptStatus
Acknowledges an interrupt. Read more
§fn read_config_generation(&self) -> u32
fn read_config_generation(&self) -> u32
Reads the configuration space generation.
§fn read_config_space<T>(&self, offset: usize) -> Result<T, Error>where
T: FromBytes + IntoBytes,
fn read_config_space<T>(&self, offset: usize) -> Result<T, Error>where
T: FromBytes + IntoBytes,
Reads a value from the device config space.
§fn write_config_space<T>(
&mut self,
offset: usize,
value: T,
) -> Result<(), Error>where
T: IntoBytes + Immutable,
fn write_config_space<T>(
&mut self,
offset: usize,
value: T,
) -> Result<(), Error>where
T: IntoBytes + Immutable,
Writes a value to the device config space.
§fn begin_init<F>(&mut self, supported_features: F) -> F
fn begin_init<F>(&mut self, supported_features: F) -> F
Begins initializing the device. Read more
§fn finish_init(&mut self)
fn finish_init(&mut self)
Finishes initializing the device.
§fn read_consistent<T>(
&self,
f: impl Fn() -> Result<T, Error>,
) -> Result<T, Error>
fn read_consistent<T>( &self, f: impl Fn() -> Result<T, Error>, ) -> Result<T, Error>
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.
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> UnsafeUnpin for MmioTransport<'a>
impl<'a> UnwindSafe for MmioTransport<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more