Struct VirtioBlockDevice

Source
pub struct VirtioBlockDevice {
    base_addr: usize,
    virtqueues: [VirtQueue<'static>; 1],
    capacity: u64,
    sector_size: u32,
    features: u32,
    read_only: bool,
    request_queue: Vec<Box<BlockIORequest>>,
}

Fields§

§base_addr: usize§virtqueues: [VirtQueue<'static>; 1]§capacity: u64§sector_size: u32§features: u32§read_only: bool§request_queue: Vec<Box<BlockIORequest>>

Implementations§

Source§

impl VirtioBlockDevice

Source

pub fn new(base_addr: usize) -> Self

Source

fn process_request( &mut self, req: &mut BlockIORequest, ) -> Result<(), &'static str>

Trait Implementations§

Source§

impl BlockDevice for VirtioBlockDevice

Source§

fn get_id(&self) -> usize

Get the device identifier
Source§

fn get_disk_name(&self) -> &'static str

Get the disk name
Source§

fn get_disk_size(&self) -> usize

Get the disk size in bytes
Source§

fn enqueue_request(&mut self, request: Box<BlockIORequest>)

Enqueue a block I/O request
Source§

fn process_requests(&mut self) -> Vec<BlockIOResult>

Process all queued requests Read more
Source§

impl Device for VirtioBlockDevice

Source§

fn device_type(&self) -> DeviceType

Source§

fn name(&self) -> &'static str

Source§

fn id(&self) -> usize

Source§

fn as_any(&self) -> &dyn Any

Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Source§

fn as_block_device(&mut self) -> Option<&mut dyn BlockDevice>

Cast to BlockDevice if this device is a block device
Source§

fn as_char_device(&mut self) -> Option<&mut dyn CharDevice>

Cast to CharDevice if this device is a character device
Source§

impl VirtioDevice for VirtioBlockDevice

Source§

fn get_base_addr(&self) -> usize

Source§

fn get_virtqueue_count(&self) -> usize

Source§

fn get_virtqueue(&self, queue_idx: usize) -> &VirtQueue<'_>

Source§

fn get_supported_features(&self, device_features: u32) -> u32

Get device features supported by this driver Read more
Source§

fn init(&mut self) -> Result<(), &'static str>

Initialize the device Read more
Source§

fn reset(&mut self)

Reset the device by writing 0 to the Status register
Source§

fn acknowledge(&mut self)

Set ACKNOWLEDGE status bit
Source§

fn driver(&mut self)

Set DRIVER status bit
Source§

fn driver_ok(&mut self)

Set DRIVER_OK status bit
Source§

fn set_failed(&mut self)

Set FAILED status bit
Source§

fn negotiate_features(&mut self) -> bool

Negotiate device features Read more
Source§

fn setup_queue(&mut self, queue_idx: usize) -> bool

Set up a virtqueue Read more
Source§

fn read_config<T: Sized>(&self, offset: usize) -> T

Read device-specific configuration Read more
Source§

fn write_config<T: Sized>(&self, offset: usize, value: T)

Write device-specific configuration Read more
Source§

fn get_device_info(&self) -> (u32, u32)

Get device and vendor IDs Read more
Source§

fn get_interrupt_status(&self) -> u32

Get interrupt status Read more
Source§

fn process_interrupts(&mut self) -> u32

Process interrupts (polling method) Read more
Source§

fn memory_barrier(&self)

Memory barrier for ensuring memory operations ordering
Source§

fn notify(&mut self, virtqueue_idx: usize)

Notify the device about new buffers in a specified virtqueue Read more
Source§

fn read32_register(&self, register: Register) -> u32

Read a 32-bit value from a device register Read more
Source§

fn write32_register(&self, register: Register, value: u32)

Write a 32-bit value to a device register Read more
Source§

fn read64_register(&self, register: Register) -> u64

Read a 64-bit value from a device register Read more
Source§

fn write64_register(&self, register: Register, value: u64)

Write a 64-bit value to a device register Read more

Auto Trait Implementations§

§

impl Freeze for VirtioBlockDevice

§

impl RefUnwindSafe for VirtioBlockDevice

§

impl Send for VirtioBlockDevice

§

impl Sync for VirtioBlockDevice

§

impl Unpin for VirtioBlockDevice

§

impl !UnwindSafe for VirtioBlockDevice

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