morpheus_network::driver::virtio_blk

Struct VirtioBlkDriver

Source
pub struct VirtioBlkDriver {
    mmio_base: u64,
    transport: VirtioTransport,
    features: u64,
    info: BlockDeviceInfo,
    queue: VirtqueueState,
    in_flight: [InFlightRequest; 32],
    next_desc_set: u16,
    headers_cpu: *mut VirtioBlkReqHeader,
    status_cpu: *mut u8,
}
Expand description

VirtIO block device driver.

Fields§

§mmio_base: u64

MMIO base address (legacy) or common_cfg (PCI Modern)

§transport: VirtioTransport

Transport handle for device operations

§features: u64

Negotiated features

§info: BlockDeviceInfo

Device info

§queue: VirtqueueState

Virtqueue state

§in_flight: [InFlightRequest; 32]

In-flight requests

§next_desc_set: u16

Next free descriptor set (each request uses 3)

§headers_cpu: *mut VirtioBlkReqHeader

Headers CPU pointer

§status_cpu: *mut u8

Status CPU pointer

Implementations§

Source§

impl VirtioBlkDriver

Source

pub unsafe fn new( mmio_base: u64, config: VirtioBlkConfig, ) -> Result<Self, VirtioBlkInitError>

Create and initialize VirtIO-blk driver.

§Safety
  • mmio_base must be valid VirtIO-blk MMIO address
  • config must contain valid physical addresses
Source

pub unsafe fn new_with_transport( transport: VirtioTransport, config: VirtioBlkConfig, _tsc_freq: u64, ) -> Result<Self, VirtioBlkInitError>

Create and initialize VirtIO-blk driver using transport abstraction.

This supports both MMIO (legacy) and PCI Modern transports.

§Safety
  • Transport addresses must be valid
  • config must contain valid physical addresses
Source

fn alloc_desc_set(&mut self) -> Option<(u16, u32)>

Allocate a descriptor set (3 consecutive descriptors).

Source

fn header_phys(&self, slot_idx: usize) -> u64

Get header physical address for a descriptor set.

Source

fn status_phys(&self, slot_idx: usize) -> u64

Get status physical address for a descriptor set.

Source

fn read_status(&self, slot_idx: usize) -> u8

Read status byte for a slot.

Trait Implementations§

Source§

impl BlockDriver for VirtioBlkDriver

Source§

fn info(&self) -> BlockDeviceInfo

Get device information.
Source§

fn can_submit(&self) -> bool

Check if device can accept a new request.
Source§

fn submit_read( &mut self, sector: u64, buffer_phys: u64, num_sectors: u32, request_id: u32, ) -> Result<(), BlockError>

Submit a read request. Read more
Source§

fn submit_write( &mut self, sector: u64, buffer_phys: u64, num_sectors: u32, request_id: u32, ) -> Result<(), BlockError>

Submit a write request. Read more
Source§

fn poll_completion(&mut self) -> Option<BlockCompletion>

Poll for completed requests. Read more
Source§

fn notify(&mut self)

Notify device that requests are pending. Read more
Source§

fn flush(&mut self) -> Result<(), BlockError>

Flush any pending writes (if supported).
Source§

impl BlockDriverInit for VirtioBlkDriver

Source§

type Error = VirtioBlkInitError

Error type for initialization failures.
Source§

type Config = VirtioBlkConfig

Configuration type.
Source§

fn supported_vendors() -> &'static [u16]

PCI vendor IDs this driver supports.
Source§

fn supported_devices() -> &'static [u16]

PCI device IDs this driver supports.
Source§

unsafe fn create( mmio_base: u64, config: Self::Config, ) -> Result<Self, Self::Error>

Create driver from MMIO base and configuration. Read more
Source§

fn supports_device(vendor: u16, device: u16) -> bool

Check if driver supports a PCI device.
Source§

impl Send for VirtioBlkDriver

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, 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.