The Pedigree Project 0.1
PciFirmware.h
1/* Copyright (c) 2026, Pedigree Developers. SPDX-License-Identifier: ISC */
2#ifndef PEDIGREE_PCI_FIRMWARE_H
3#define PEDIGREE_PCI_FIRMWARE_H
4
5#include "pedigree/kernel/compiler.h"
6#include "pedigree/kernel/processor/types.h"
7
8namespace PciFirmware {
9constexpr size_t MaxWindows = 16;
10
11struct Window {
12 uint64_t pciBase = 0;
13 uint64_t cpuBase = 0;
14 uint64_t size = 0;
15 bool io = false;
16 bool prefetchable = false;
17};
18
19struct Root {
20 uint16_t segment = 0;
21 uint8_t firstBus = 0;
22 uint8_t lastBus = 0;
23 Window windows[MaxWindows] = {};
24 size_t windowCount = 0;
25};
26
27constexpr uint32_t NativeHotplug = 1U << 0;
28constexpr uint32_t NativeAer = 1U << 3;
29constexpr uint32_t NativePcieCapability = 1U << 4;
30
31EXPORTED_PUBLIC bool discover();
32EXPORTED_PUBLIC const Root* rootForBus(uint8_t bus);
33EXPORTED_PUBLIC bool requestNativeControl(uint8_t bus, uint32_t bits);
34EXPORTED_PUBLIC uint32_t nativeControl(uint8_t bus);
35} // namespace PciFirmware
36
37#endif