pcie/
lib.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! PCI Express definitions and emulators.
5
6#![forbid(unsafe_code)]
7
8pub(crate) mod port;
9pub mod root;
10pub mod switch;
11
12#[cfg(test)]
13mod test_helpers;
14
15const PAGE_SIZE: usize = 4096;
16const PAGE_SIZE64: u64 = 4096;
17const PAGE_OFFSET_MASK: u64 = PAGE_SIZE64 - 1;
18const PAGE_SHIFT: u32 = PAGE_SIZE.trailing_zeros();
19
20const VENDOR_ID: u16 = 0x1414;
21
22// Microsoft Device IDs assigned to OpenVMM virtual bridges and switch ports.
23const ROOT_PORT_DEVICE_ID: u16 = 0xC030;
24const UPSTREAM_SWITCH_PORT_DEVICE_ID: u16 = 0xC031;
25const DOWNSTREAM_SWITCH_PORT_DEVICE_ID: u16 = 0xC032;
26
27const MAX_FUNCTIONS_PER_BUS: usize = 256;
28
29const BDF_BUS_SHIFT: u16 = 8;
30const BDF_DEVICE_SHIFT: u16 = 3;
31const BDF_DEVICE_FUNCTION_MASK: u16 = 0x00FF;