2020-09-09 14:30:31 +00:00
|
|
|
// Copyright © 2020 Intel Corporation
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
//
|
|
|
|
|
2022-06-30 16:34:04 +00:00
|
|
|
#![allow(clippy::significant_drop_in_scrutinee)]
|
|
|
|
|
2022-05-17 21:04:38 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
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
|
2022-06-30 15:41:46 +00:00
|
|
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, 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-06-30 15:41:46 +00:00
|
|
|
#[derive(Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
|
2022-04-15 09:27:53 +00:00
|
|
|
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),
|
|
|
|
}
|