⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

VirtioPciTransport

Struct VirtioPciTransport 

Source
pub struct VirtioPciTransport { /* private fields */ }
Expand description

Virtio PCI transport handle.

Wraps the BAR0 I/O port base address for a legacy virtio PCI device and provides typed accessors for the common virtio register set.

Implementations§

Source§

impl VirtioPciTransport

Source

pub fn new(io_base: u16) -> Self

Create a new transport from the BAR0 I/O base address.

Source

pub fn io_base(&self) -> u16

Get the I/O base address.

Source

pub fn read_device_features(&self) -> u32

Read the device-offered feature bits (32-bit).

Source

pub fn write_guest_features(&self, features: u32)

Write the driver-accepted feature bits (32-bit).

Source

pub fn read_queue_size(&self) -> u16

Read the queue size for the currently selected queue.

Source

pub fn select_queue(&self, index: u16)

Select a virtqueue by index.

Source

pub fn write_queue_address(&self, pfn: u32)

Set the physical page frame number (PFN) of the selected virtqueue.

The device uses this to locate the virtqueue descriptor table, available ring, and used ring in guest physical memory. The address is pfn * 4096.

Source

pub fn notify_queue(&self, queue_index: u16)

Notify (kick) the device that new buffers are available in the given queue.

Source

pub fn read_status(&self) -> u8

Read the device status register.

Source

pub fn write_status(&self, status: u8)

Write the device status register.

Source

pub fn read_isr(&self) -> u8

Read the ISR status register (clears interrupt flag on read).

Source

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

Read a byte from device-specific configuration space.

Source

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

Read a 32-bit word from device-specific configuration space.

Source

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

Read a 64-bit value from device-specific configuration space (two 32-bit reads).

Source

pub fn reset(&self)

Reset the device by writing zero to the status register.

Source

pub fn begin_init(&self)

Perform the standard legacy device initialization sequence.

  1. Reset device
  2. Set ACKNOWLEDGE
  3. Set DRIVER

After calling this, the driver should read device features, negotiate, then call set_features_ok() and set_driver_ok().

Source

pub fn set_features_ok(&self) -> bool

Signal that feature negotiation is complete.

Returns true if the device accepted FEATURES_OK; false means the device does not support the selected feature subset and initialization should be aborted.

Source

pub fn set_driver_ok(&self)

Signal that the driver is fully initialized and ready.

Source

pub fn set_failed(&self)

Mark the device as failed.

Trait Implementations§

Source§

impl Clone for VirtioPciTransport

Source§

fn clone(&self) -> VirtioPciTransport

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VirtioPciTransport

Source§

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

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

impl Copy for VirtioPciTransport

Auto Trait Implementations§

§

impl Freeze for VirtioPciTransport

§

impl RefUnwindSafe for VirtioPciTransport

§

impl Send for VirtioPciTransport

§

impl Sync for VirtioPciTransport

§

impl Unpin for VirtioPciTransport

§

impl UnwindSafe for VirtioPciTransport

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> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

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.