Skip to main content

VirtioDevice

Struct VirtioDevice 

Source
pub struct VirtioDevice {
    pub pci_dev: PciDevice,
    pub io_base: u16,
}
Expand description

VirtIO device base

Common functionality for all VirtIO devices

Fields§

§pci_dev: PciDevice

PCI device

§io_base: u16

I/O base address (BAR0 for legacy devices)

Implementations§

Source§

impl VirtioDevice

Source

pub unsafe fn new(pci_dev: PciDevice) -> Result<Self, &'static str>

Create a new VirtIO device from a PCI device

§Safety

The PCI device must be a valid VirtIO device

Source

pub fn read_reg_u8(&self, offset: u16) -> u8

Read an 8-bit value from a device register

Source

pub fn read_reg_u16(&self, offset: u16) -> u16

Read a 16-bit value from a device register

Source

pub fn read_reg_u32(&self, offset: u16) -> u32

Read a 32-bit value from a device register

Source

pub fn write_reg_u8(&self, offset: u16, value: u8)

Write an 8-bit value to a device register

Source

pub fn write_reg_u16(&self, offset: u16, value: u16)

Write a 16-bit value to a device register

Source

pub fn write_reg_u32(&self, offset: u16, value: u32)

Write a 32-bit value to a device register

Source

pub fn read_device_features(&self) -> u32

Read device features

Source

pub fn write_guest_features(&self, features: u32)

Write guest features

Source

pub fn get_status(&self) -> u8

Get device status

Source

pub fn set_status(&self, status: u8)

Set device status

Source

pub fn add_status(&self, status: u8)

Add status flags

Source

pub fn reset(&self)

Reset the device

Source

pub fn read_isr_status(&self) -> u8

Read ISR status (clears interrupt)

Source

pub fn ack_interrupt(&self)

Acknowledge interrupt (write 0 to ISR)

Source

pub fn setup_queue(&self, queue_index: u16, queue: &Virtqueue)

Setup a virtqueue

Source

pub fn notify_queue(&self, queue_index: u16)

Notify a queue

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.