pub struct VirtioBlockDevice {
base_addr: usize,
virtqueues: Mutex<[VirtQueue<'static>; 1]>,
capacity: RwLock<u64>,
sector_size: RwLock<u32>,
features: RwLock<u32>,
read_only: RwLock<bool>,
request_queue: Mutex<Vec<Box<BlockIORequest>>>,
}
Fields§
§base_addr: usize
§virtqueues: Mutex<[VirtQueue<'static>; 1]>
§capacity: RwLock<u64>
§sector_size: RwLock<u32>
§features: RwLock<u32>
§read_only: RwLock<bool>
§request_queue: Mutex<Vec<Box<BlockIORequest>>>
Implementations§
Source§impl VirtioBlockDevice
impl VirtioBlockDevice
pub fn new(base_addr: usize) -> Self
fn process_request(&self, req: &mut BlockIORequest) -> Result<(), &'static str>
Trait Implementations§
Source§impl BlockDevice for VirtioBlockDevice
impl BlockDevice for VirtioBlockDevice
Source§fn get_disk_name(&self) -> &'static str
fn get_disk_name(&self) -> &'static str
Get the disk name
Source§fn get_disk_size(&self) -> usize
fn get_disk_size(&self) -> usize
Get the disk size in bytes
Source§fn enqueue_request(&self, request: Box<BlockIORequest>)
fn enqueue_request(&self, request: Box<BlockIORequest>)
Enqueue a block I/O request
Source§fn process_requests(&self) -> Vec<BlockIOResult>
fn process_requests(&self) -> Vec<BlockIOResult>
Process all queued requests Read more
Source§impl Device for VirtioBlockDevice
impl Device for VirtioBlockDevice
fn device_type(&self) -> DeviceType
fn name(&self) -> &'static str
fn as_any(&self) -> &dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Source§fn as_block_device(&self) -> Option<&dyn BlockDevice>
fn as_block_device(&self) -> Option<&dyn BlockDevice>
Cast to BlockDevice if this device is a block device
Source§fn as_char_device(&self) -> Option<&dyn CharDevice>
fn as_char_device(&self) -> Option<&dyn CharDevice>
Cast to CharDevice if this device is a character device
Source§impl VirtioDevice for VirtioBlockDevice
impl VirtioDevice for VirtioBlockDevice
fn get_base_addr(&self) -> usize
fn get_virtqueue_count(&self) -> usize
Source§fn get_supported_features(&self, device_features: u32) -> u32
fn get_supported_features(&self, device_features: u32) -> u32
Get device features supported by this driver Read more
Source§fn get_queue_desc_addr(&self, queue_idx: usize) -> Option<u64>
fn get_queue_desc_addr(&self, queue_idx: usize) -> Option<u64>
Get the descriptor address for a virtqueue
Source§fn get_queue_driver_addr(&self, queue_idx: usize) -> Option<u64>
fn get_queue_driver_addr(&self, queue_idx: usize) -> Option<u64>
Get the driver area address for a virtqueue
Source§fn get_queue_device_addr(&self, queue_idx: usize) -> Option<u64>
fn get_queue_device_addr(&self, queue_idx: usize) -> Option<u64>
Get the device area address for a virtqueue
Source§fn acknowledge(&mut self)
fn acknowledge(&mut self)
Set ACKNOWLEDGE status bit
Source§fn set_failed(&mut self)
fn set_failed(&mut self)
Set FAILED status bit
Source§fn negotiate_features(&mut self) -> bool
fn negotiate_features(&mut self) -> bool
Negotiate device features Read more
Source§fn setup_queue(&mut self, queue_idx: usize) -> bool
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
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)
fn write_config<T: Sized>(&self, offset: usize, value: T)
Write device-specific configuration Read more
Source§fn get_device_info(&self) -> (u32, u32)
fn get_device_info(&self) -> (u32, u32)
Get device and vendor IDs Read more
Source§fn get_interrupt_status(&self) -> u32
fn get_interrupt_status(&self) -> u32
Get interrupt status Read more
Source§fn process_interrupts(&mut self) -> u32
fn process_interrupts(&mut self) -> u32
Process interrupts (polling method) Read more
Source§fn memory_barrier(&self)
fn memory_barrier(&self)
Memory barrier for ensuring memory operations ordering
Source§fn notify(&self, virtqueue_idx: usize)
fn notify(&self, virtqueue_idx: usize)
Notify the device about new buffers in a specified virtqueue Read more
Source§fn read32_register(&self, register: Register) -> u32
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)
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
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)
fn write64_register(&self, register: Register, value: u64)
Write a 64-bit value to a device register Read more