From a6fde0bb1cd672e37abc76edafad9e2ad621d4f2 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Mon, 27 Apr 2020 17:53:07 +0200 Subject: [PATCH] vm-device: Define a Resource Based on rust-vmm code, we copy the Resource structure as it will be used to define the set of resources associated with a device. Signed-off-by: Sebastien Boeuf --- vm-device/src/lib.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/vm-device/src/lib.rs b/vm-device/src/lib.rs index 3b6f4c765..457efb9de 100644 --- a/vm-device/src/lib.rs +++ b/vm-device/src/lib.rs @@ -7,6 +7,39 @@ use vm_memory::{ MemoryRegionAddress, }; +/// Type of Message Singaled Interrupt +#[derive(Copy, Clone, PartialEq)] +pub enum MsiIrqType { + /// PCI MSI IRQ numbers. + PciMsi, + /// PCI MSIx IRQ numbers. + PciMsix, + /// Generic MSI IRQ numbers. + GenericMsi, +} + +/// Enumeration for device resources. +#[allow(missing_docs)] +#[derive(Clone)] +pub enum Resource { + /// IO Port address range. + PioAddressRange { base: u16, size: u16 }, + /// Memory Mapped IO address range. + MmioAddressRange { base: u64, size: u64 }, + /// Legacy IRQ number. + LegacyIrq(u32), + /// Message Signaled Interrupt + MsiIrq { + ty: MsiIrqType, + base: u32, + size: u32, + }, + /// Network Interface Card MAC address. + MacAddress(String), + /// KVM memslot index. + KvmMemSlot(u32), +} + /// Trait meant for triggering the DMA mapping update related to an external /// device not managed fully through virtio. It is dedicated to virtio-iommu /// in order to trigger the map update anytime the mapping is updated from the