1mod virtio_blk;
2
3pub use virtio_blk::VirtIOBlock;
4
5use crate::board::BlockDeviceImpl;
6use alloc::sync::Arc;
7use easy_fs::BlockDevice;
8use lazy_static::*;
9
10lazy_static! {
11 pub static ref BLOCK_DEVICE: Arc<dyn BlockDevice> = Arc::new(BlockDeviceImpl::new());
12}
13
14#[allow(unused)]
15pub fn block_device_test() {
16 let block_device = BLOCK_DEVICE.clone();
17 let mut write_buffer = [0u8; 512];
18 let mut read_buffer = [0u8; 512];
19 for i in 0..512 {
20 for byte in write_buffer.iter_mut() {
21 *byte = i as u8;
22 }
23 block_device.write_block(i as usize, &write_buffer);
24 block_device.read_block(i as usize, &mut read_buffer);
25 assert_eq!(write_buffer, read_buffer);
26 }
27 println!("block device test passed!");
28}