diff options
author | Robert Morris <[email protected]> | 2020-10-05 06:59:33 -0400 |
---|---|---|
committer | Frans Kaashoek <[email protected]> | 2020-10-05 19:30:27 -0400 |
commit | c61cc694137035c58c1d2439a4c44e0f924d41db (patch) | |
tree | 9d8edd8bab973691b93b3e391fe3995e25c3ec7b /kernel/virtio_disk.c | |
parent | 3092fe2c9ecf285cbf3c631b484c88fe5071224e (diff) | |
download | xv6-labs-c61cc694137035c58c1d2439a4c44e0f924d41db.tar.gz xv6-labs-c61cc694137035c58c1d2439a4c44e0f924d41db.tar.bz2 xv6-labs-c61cc694137035c58c1d2439a4c44e0f924d41db.zip |
eliminate virtio DMA into kernel stacks.
Diffstat (limited to 'kernel/virtio_disk.c')
-rw-r--r-- | kernel/virtio_disk.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/kernel/virtio_disk.c b/kernel/virtio_disk.c index 070490a..cca44cb 100644 --- a/kernel/virtio_disk.c +++ b/kernel/virtio_disk.c @@ -64,6 +64,10 @@ static struct disk { struct buf *b; char status; } info[NUM]; + + // disk command headers. + // one-for-one with descriptors, for convenience. + struct virtio_blk_req ops[NUM]; struct spinlock vdisk_lock; @@ -219,19 +223,17 @@ virtio_disk_rw(struct buf *b, int write) // format the three descriptors. // qemu's virtio-blk.c reads them. - struct virtio_blk_req buf0; + struct virtio_blk_req *buf0 = &disk.ops[idx[0]]; if(write) - buf0.type = VIRTIO_BLK_T_OUT; // write the disk + buf0->type = VIRTIO_BLK_T_OUT; // write the disk else - buf0.type = VIRTIO_BLK_T_IN; // read the disk - buf0.reserved = 0; - buf0.sector = sector; - - // buf0 is on a kernel stack, which is not direct mapped, - // thus the call to kvmpa(). - disk.desc[idx[0]].addr = (uint64) kvmpa((uint64) &buf0); - disk.desc[idx[0]].len = sizeof(buf0); + buf0->type = VIRTIO_BLK_T_IN; // read the disk + buf0->reserved = 0; + buf0->sector = sector; + + disk.desc[idx[0]].addr = (uint64) buf0; + disk.desc[idx[0]].len = sizeof(struct virtio_blk_req); disk.desc[idx[0]].flags = VRING_DESC_F_NEXT; disk.desc[idx[0]].next = idx[1]; |