Use latest virtio-drivers && add huge_write_mt but it cannot work now
This commit is contained in:
parent
c6db34e2c7
commit
fef12c79f1
4 changed files with 67 additions and 10 deletions
|
@ -12,8 +12,7 @@ lazy_static = { version = "1.4.0", features = ["spin_no_std"] }
|
|||
buddy_system_allocator = "0.6"
|
||||
bitflags = "1.2.1"
|
||||
xmas-elf = "0.7.0"
|
||||
#virtio-drivers = { git = "https://github.com/wyfcyx/virtio-drivers" }
|
||||
virtio-drivers = { path = "../../virtio-drivers" }
|
||||
virtio-drivers = { git = "https://github.com/rcore-os/virtio-drivers" }
|
||||
k210-pac = { git = "https://github.com/wyfcyx/k210-pac" }
|
||||
k210-hal = { git = "https://github.com/wyfcyx/k210-hal" }
|
||||
k210-soc = { git = "https://github.com/wyfcyx/k210-soc" }
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::mm::{
|
|||
};
|
||||
use crate::sync::{UPSafeCell, Condvar};
|
||||
use lazy_static::*;
|
||||
use virtio_drivers::{VirtIOBlk, VirtIOHeader};
|
||||
use virtio_drivers::{VirtIOBlk, VirtIOHeader, BlkResp, RespStatus};
|
||||
use crate::DEV_NON_BLOCKING_ACCESS;
|
||||
use alloc::collections::BTreeMap;
|
||||
use alloc::vec::Vec;
|
||||
|
@ -27,11 +27,13 @@ impl BlockDevice for VirtIOBlock {
|
|||
let nb = *DEV_NON_BLOCKING_ACCESS.exclusive_access();
|
||||
if nb {
|
||||
let mut blk = self.virtio_blk.exclusive_access();
|
||||
let mut resp = 0xffu8;
|
||||
let token = blk.read_block_nb(block_id, buf, &mut resp).unwrap();
|
||||
let mut resp = BlkResp::default();
|
||||
let token = unsafe {
|
||||
blk.read_block_nb(block_id, buf, &mut resp).unwrap()
|
||||
};
|
||||
drop(blk);
|
||||
self.condvars.get(&token).unwrap().wait();
|
||||
assert_eq!(resp, 0x0, "Error when reading VirtIOBlk");
|
||||
assert_eq!(resp.status(), RespStatus::Ok, "Error when reading VirtIOBlk");
|
||||
} else {
|
||||
self.virtio_blk
|
||||
.exclusive_access()
|
||||
|
@ -43,11 +45,13 @@ impl BlockDevice for VirtIOBlock {
|
|||
let nb = *DEV_NON_BLOCKING_ACCESS.exclusive_access();
|
||||
if nb {
|
||||
let mut blk = self.virtio_blk.exclusive_access();
|
||||
let mut resp = 0xffu8;
|
||||
let token = blk.write_block_nb(block_id, buf, &mut resp).unwrap();
|
||||
let mut resp = BlkResp::default();
|
||||
let token = unsafe {
|
||||
blk.write_block_nb(block_id, buf, &mut resp).unwrap()
|
||||
};
|
||||
drop(blk);
|
||||
self.condvars.get(&token).unwrap().wait();
|
||||
assert_eq!(resp, 0x0, "Error when reading VirtIOBlk");
|
||||
assert_eq!(resp.status(), RespStatus::Ok, "Error when writing VirtIOBlk");
|
||||
} else {
|
||||
self.virtio_blk
|
||||
.exclusive_access()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue