From 55bcc797361afc3c83e703345299a9b04c663f5d Mon Sep 17 00:00:00 2001 From: Stephen Marz Date: Sat, 28 Mar 2020 21:05:45 -0400 Subject: [PATCH] Added MmioDevice structure to put a structure to the MMIO virtio address space. --- risc_v/src/virtio.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/risc_v/src/virtio.rs b/risc_v/src/virtio.rs index 90805aa..1c73529 100755 --- a/risc_v/src/virtio.rs +++ b/risc_v/src/virtio.rs @@ -96,6 +96,38 @@ pub enum MmioOffsets { Config = 0x100, } +// This currently isn't used, but if anyone wants to try their hand at putting a structure +// to the MMIO address space, you can use the following. Remember that this is volatile! +#[repr(C)] +pub struct MmioDevice { + magic_value: u32, + version: u32, + device_id: u32, + vendor_id: u32, + host_features: u32, + host_features_sel: u32, + rsv1: [u8; 8], + guest_features: u32, + guest_features_sel: u32, + guest_page_size: u32, + rsv2: [u8; 4], + queue_sel: u32, + queue_num_max: u32, + queue_num: u32, + queue_align: u32, + queue_pfn: u64, + rsv3: [u8; 8], + queue_notify, + rsv4: [u8; 12], + interrupt_status: u32, + interrupt_ack: u32, + rsv5: [u8; 8], + uint32_t status: u32, + //rsv6: [u8; 140], + //uint32_t config[1]; + // The config space starts at 0x100, but it is device dependent. +} + #[repr(usize)] pub enum DeviceTypes { None = 0, @@ -124,6 +156,7 @@ impl MmioOffsets { pub fn scale32(self) -> usize { self.scaled(4) } + } pub enum StatusField {