Skip to main content

BootVirtqueue

Struct BootVirtqueue 

Source
struct BootVirtqueue {
    vring_phys: u64,
    vring_virt: u64,
    queue_size: u16,
    avail_idx: u16,
    last_used_idx: u16,
}
Expand description

Minimal boot-time virtqueue with a static vring allocation.

Legacy MMIO layout requires the vring to occupy physically-contiguous pages with the three sections page-aligned: ┌─ Page 0: descriptor table (page-aligned) ├─ Page 1: available ring (page-aligned) └─ Page 2: used ring (tail, may share page 3)

Fields§

§vring_phys: u64

Physical address of the vring base (written to QueuePFN >> 12).

§vring_virt: u64

Virtual (HHDM) address of the vring base.

§queue_size: u16

Queue size.

§avail_idx: u16

Next available index.

§last_used_idx: u16

Last observed used index.

Implementations§

Source§

impl BootVirtqueue

Source

unsafe fn init(device_base: u64, queue_size: u16) -> Result<Self, &'static str>

Allocate and initialise a boot-time virtqueue.

§Safety

device_base must be a valid MMIO VirtIO device address.

Source

unsafe fn read_block( &mut self, device_base: u64, lba: u64, bounce_phys: u64, bounce_virt: u64, buf: &mut [u8], ) -> Result<(), ()>

Submit a single-block read request and busy-poll for completion.

Uses a 3-descriptor chain: header (device-read) | data (device-write) | status (device-write).

§Safety

device_base must be a valid MMIO VirtIO device address.

Trait Implementations§

Source§

impl Drop for BootVirtqueue

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.