mirror of
https://github.com/sgmarz/osblog.git
synced 2024-11-24 02:16:19 +04:00
move index so that it has more time to write
This commit is contained in:
parent
9623de2e50
commit
5b2e780484
@ -12,7 +12,6 @@ use crate::{kmem::{kfree, kmalloc},
|
|||||||
StatusField,
|
StatusField,
|
||||||
VIRTIO_RING_SIZE}};
|
VIRTIO_RING_SIZE}};
|
||||||
use core::mem::size_of;
|
use core::mem::size_of;
|
||||||
use crate::plic;
|
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct Geometry {
|
pub struct Geometry {
|
||||||
@ -301,6 +300,7 @@ pub fn write(dev: usize, buffer: *mut u8, size: u32, offset: u64) {
|
|||||||
let head_idx = fill_next_descriptor(bdev, desc);
|
let head_idx = fill_next_descriptor(bdev, desc);
|
||||||
(*blk_request).header.sector = sector;
|
(*blk_request).header.sector = sector;
|
||||||
(*blk_request).header.blktype = VIRTIO_BLK_T_OUT;
|
(*blk_request).header.blktype = VIRTIO_BLK_T_OUT;
|
||||||
|
(*blk_request).header.reserved = 0;
|
||||||
(*blk_request).data.data = buffer;
|
(*blk_request).data.data = buffer;
|
||||||
(*blk_request).status.status = 111;
|
(*blk_request).status.status = 111;
|
||||||
let desc =
|
let desc =
|
||||||
@ -347,6 +347,7 @@ pub fn pending(bd: &mut BlockDevice) {
|
|||||||
while bd.ack_used_idx != queue.used.idx {
|
while bd.ack_used_idx != queue.used.idx {
|
||||||
// println!("ACK = {}, Used = {}", bd.ack_used_idx, queue.used.idx);
|
// println!("ACK = {}, Used = {}", bd.ack_used_idx, queue.used.idx);
|
||||||
let ref elem = queue.used.ring[bd.ack_used_idx as usize];
|
let ref elem = queue.used.ring[bd.ack_used_idx as usize];
|
||||||
|
bd.ack_used_idx = (bd.ack_used_idx + 1) % VIRTIO_RING_SIZE as u16;
|
||||||
let idx = elem.id as usize;
|
let idx = elem.id as usize;
|
||||||
let len = elem.len as usize;
|
let len = elem.len as usize;
|
||||||
// println!("Elem id = {}, Len = {}", idx, len);
|
// println!("Elem id = {}, Len = {}", idx, len);
|
||||||
@ -356,7 +357,6 @@ pub fn pending(bd: &mut BlockDevice) {
|
|||||||
// println!("Status returned as {}", (*addr).status.status);
|
// println!("Status returned as {}", (*addr).status.status);
|
||||||
// println!("Freeing {:p}", addr);
|
// println!("Freeing {:p}", addr);
|
||||||
kfree(addr as *mut u8);
|
kfree(addr as *mut u8);
|
||||||
bd.ack_used_idx = (bd.ack_used_idx + 1) % VIRTIO_RING_SIZE as u16;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user