diff --git a/src/disk.rs b/src/disk.rs index dafcb02..31d6d99 100644 --- a/src/disk.rs +++ b/src/disk.rs @@ -11,7 +11,7 @@ pub fn init_disk() { Ok(block) => unsafe { DISK = Some(block); }, - Err(()) => panic!("Error: Disk initialization"), + Err(_err) => panic!("Error: Disk initialization"), } } diff --git a/src/virtio/block.rs b/src/virtio/block.rs index 7e5fcad..9397815 100644 --- a/src/virtio/block.rs +++ b/src/virtio/block.rs @@ -1,4 +1,6 @@ use super::header::VirtioHeader; +use super::queue::VirtioQueue; +use super::Error; use bitflags::bitflags; @@ -11,10 +13,11 @@ use bitflags::bitflags; /// ref: 5.2 Block Device pub struct VirtioBlock { header: &'static mut VirtioHeader, + queue: VirtioQueue, } impl VirtioBlock { - pub fn new(header: &'static mut VirtioHeader) -> Result { + pub fn new(header: &'static mut VirtioHeader) -> Result { header.begin_init(|features| { let features = BlockFeatures::from_bits_truncate(features); let disable_features = BlockFeatures::RO @@ -22,10 +25,12 @@ impl VirtioBlock { | BlockFeatures::RING_EVENT_IDX | BlockFeatures::RING_INDIRECT_DESC; (features - disable_features).bits() - }).ok(); + })?; + + let queue = VirtioQueue::new(header, 0, 8)?; header.end_init(); - Ok(Self { header }) + Ok(Self { header, queue }) } }