2020-09-09 14:30:31 +00:00
|
|
|
// Copyright © 2020 Intel Corporation
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
//
|
|
|
|
|
2020-04-28 10:08:51 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate serde_derive;
|
2019-12-12 13:08:34 +00:00
|
|
|
|
2020-09-09 14:30:31 +00:00
|
|
|
mod bus;
|
2021-02-23 13:47:56 +00:00
|
|
|
pub mod dma_mapping;
|
2020-01-14 09:45:06 +00:00
|
|
|
pub mod interrupt;
|
|
|
|
|
2020-09-09 14:30:31 +00:00
|
|
|
pub use self::bus::{Bus, BusDevice, Error as BusError};
|
|
|
|
|
2020-09-22 11:31:42 +00:00
|
|
|
/// Type of Message Signalled Interrupt
|
2020-04-29 13:18:04 +00:00
|
|
|
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
2020-04-27 15:53:07 +00:00
|
|
|
pub enum MsiIrqType {
|
|
|
|
/// PCI MSI IRQ numbers.
|
|
|
|
PciMsi,
|
|
|
|
/// PCI MSIx IRQ numbers.
|
|
|
|
PciMsix,
|
|
|
|
/// Generic MSI IRQ numbers.
|
|
|
|
GenericMsi,
|
|
|
|
}
|
|
|
|
|
2022-04-15 09:27:53 +00:00
|
|
|
#[derive(Copy, Clone, PartialEq, Serialize, Deserialize, Debug)]
|
|
|
|
pub enum PciBarType {
|
|
|
|
Io,
|
|
|
|
Mmio32,
|
|
|
|
Mmio64,
|
|
|
|
}
|
|
|
|
|
2020-04-27 15:53:07 +00:00
|
|
|
/// Enumeration for device resources.
|
|
|
|
#[allow(missing_docs)]
|
2020-04-29 13:18:04 +00:00
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
2020-04-27 15:53:07 +00:00
|
|
|
pub enum Resource {
|
|
|
|
/// IO Port address range.
|
|
|
|
PioAddressRange { base: u16, size: u16 },
|
|
|
|
/// Memory Mapped IO address range.
|
|
|
|
MmioAddressRange { base: u64, size: u64 },
|
2022-04-15 09:27:53 +00:00
|
|
|
/// PCI BAR
|
|
|
|
PciBar {
|
|
|
|
index: usize,
|
|
|
|
base: u64,
|
|
|
|
size: u64,
|
|
|
|
type_: PciBarType,
|
|
|
|
prefetchable: bool,
|
|
|
|
},
|
2020-04-27 15:53:07 +00:00
|
|
|
/// 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),
|
|
|
|
}
|