1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
mod bus;
mod caps;
mod config;
mod nodes;
pub mod pci_init_args;
mod pio;
use super::*;
use alloc::sync::*;
pub(crate) use nodes::*;
use pci_init_args::*;
use pio::*;
pub use self::bus::{
MmioPcieAddressProvider, PCIeBusDriver, PcieDeviceInfo, PcieDeviceKObject,
PioPcieAddressProvider,
};
pub use self::nodes::PcieIrqMode;
pub use self::pio::{pio_config_read, pio_config_write};
#[derive(PartialEq, Debug)]
#[allow(clippy::upper_case_acronyms)]
pub enum PciAddrSpace {
MMIO,
PIO,
}
pub struct PciEcamRegion {
pub phys_base: u64,
pub size: usize,
pub bus_start: u8,
pub bus_end: u8,
}
pub struct MappedEcamRegion {
ecam: PciEcamRegion,
vaddr: u64,
}
pub use constants::*;
#[allow(missing_docs)]
mod constants {
pub const PCI_MAX_DEVICES_PER_BUS: usize = 32;
pub const PCI_MAX_FUNCTIONS_PER_DEVICE: usize = 8;
pub const PCI_MAX_LEGACY_IRQ_PINS: usize = 4;
pub const PCI_MAX_FUNCTIONS_PER_BUS: usize =
PCI_MAX_FUNCTIONS_PER_DEVICE * PCI_MAX_DEVICES_PER_BUS;
pub const PCI_MAX_IRQS: usize = 224;
pub const PCI_NO_IRQ_MAPPING: u32 = u32::MAX;
pub const PCIE_PIO_ADDR_SPACE_MASK: u64 = 0xFFFF_FFFF;
pub const PCIE_MAX_BUSSES: usize = 256;
pub const PCIE_ECAM_BYTES_PER_BUS: usize =
4096 * PCI_MAX_DEVICES_PER_BUS * PCI_MAX_FUNCTIONS_PER_DEVICE;
pub const PCIE_INVALID_VENDOR_ID: usize = 0xFFFF;
pub const PCI_CFG_SPACE_TYPE_PIO: u8 = 0;
pub const PCI_CFG_SPACE_TYPE_MMIO: u8 = 1;
pub const PCIE_IRQRET_MASK: u32 = 0x1;
pub const PCIE_MAX_MSI_IRQS: u32 = 32;
}