refactor: ByteOffset newtype for window/register/ring offsets; named virtio-gpu cmd fields
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
use crate::mmio::{MmioAccess, REG_QUEUE_NOTIFY};
|
||||
use core::sync::atomic::{Ordering, fence};
|
||||
use libkos::Window;
|
||||
use types::address::ByteOffset;
|
||||
|
||||
pub const QUEUE_SIZE: usize = 8;
|
||||
const DESC_SIZE: usize = 16;
|
||||
const TIMEOUT: u32 = 10_000_000;
|
||||
/// Where the legacy layout puts the available and used rings.
|
||||
const AVAIL: usize = QUEUE_SIZE * DESC_SIZE;
|
||||
const USED: usize = 4096;
|
||||
const AVAIL: ByteOffset = ByteOffset::new(QUEUE_SIZE * DESC_SIZE);
|
||||
const USED: ByteOffset = ByteOffset::new(4096);
|
||||
|
||||
pub struct Descriptor {
|
||||
pub addr: u64,
|
||||
@@ -32,7 +33,7 @@ impl VirtioQueue {
|
||||
}
|
||||
let r = &self.rings;
|
||||
for (i, d) in descs.iter().enumerate() {
|
||||
let at = i * DESC_SIZE;
|
||||
let at = ByteOffset::new(i * DESC_SIZE);
|
||||
let last = i == descs.len() - 1;
|
||||
let flags: u16 = if d.writable { 2 } else { 0 } | if !last { 1 } else { 0 };
|
||||
r.write(at, d.addr);
|
||||
|
||||
Reference in New Issue
Block a user