mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-09-12 10:04:51 +00:00
Instead of defining some very generic resources as PioAddressRange or MmioAddressRange for each PCI BAR, let's move to the new Resource type PciBar in order to make things clearer. This allows the code for being more readable, but also removes the need for hard assumptions about the MMIO and PIO ranges. PioAddressRange and MmioAddressRange types can be used to describe everything except PCI BARs. BARs are very special as they can be relocated and have special information we want to carry along with them. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
62 lines
1.3 KiB
Rust
62 lines
1.3 KiB
Rust
// Copyright © 2020 Intel Corporation
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
#[macro_use]
|
|
extern crate serde_derive;
|
|
|
|
mod bus;
|
|
pub mod dma_mapping;
|
|
pub mod interrupt;
|
|
|
|
pub use self::bus::{Bus, BusDevice, Error as BusError};
|
|
|
|
/// Type of Message Signalled Interrupt
|
|
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
|
pub enum MsiIrqType {
|
|
/// PCI MSI IRQ numbers.
|
|
PciMsi,
|
|
/// PCI MSIx IRQ numbers.
|
|
PciMsix,
|
|
/// Generic MSI IRQ numbers.
|
|
GenericMsi,
|
|
}
|
|
|
|
#[derive(Copy, Clone, PartialEq, Serialize, Deserialize, Debug)]
|
|
pub enum PciBarType {
|
|
Io,
|
|
Mmio32,
|
|
Mmio64,
|
|
}
|
|
|
|
/// Enumeration for device resources.
|
|
#[allow(missing_docs)]
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub enum Resource {
|
|
/// IO Port address range.
|
|
PioAddressRange { base: u16, size: u16 },
|
|
/// Memory Mapped IO address range.
|
|
MmioAddressRange { base: u64, size: u64 },
|
|
/// PCI BAR
|
|
PciBar {
|
|
index: usize,
|
|
base: u64,
|
|
size: u64,
|
|
type_: PciBarType,
|
|
prefetchable: bool,
|
|
},
|
|
/// 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),
|
|
}
|