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: u64Physical address of the vring base (written to QueuePFN >> 12).
vring_virt: u64Virtual (HHDM) address of the vring base.
queue_size: u16Queue size.
avail_idx: u16Next available index.
last_used_idx: u16Last observed used index.
Implementations§
Source§impl BootVirtqueue
impl BootVirtqueue
Sourceunsafe fn init(device_base: u64, queue_size: u16) -> Result<Self, &'static str>
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.
Sourceunsafe fn read_block(
&mut self,
device_base: u64,
lba: u64,
bounce_phys: u64,
bounce_virt: u64,
buf: &mut [u8],
) -> Result<(), ()>
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
impl Drop for BootVirtqueue
Auto Trait Implementations§
impl Freeze for BootVirtqueue
impl RefUnwindSafe for BootVirtqueue
impl Send for BootVirtqueue
impl Sync for BootVirtqueue
impl Unpin for BootVirtqueue
impl UnsafeUnpin for BootVirtqueue
impl UnwindSafe for BootVirtqueue
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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