The Pedigree Project 0.1
Resources.h
1/* Copyright (c) 2026, Pedigree Developers. SPDX-License-Identifier: ISC */
2#ifndef PEDIGREE_PCI_RESOURCES_H
3#define PEDIGREE_PCI_RESOURCES_H
4
5#include "pedigree/kernel/compiler.h"
6#include "pedigree/kernel/processor/types.h"
7
8class Device;
9
10namespace PciResources {
11// Call once after PCI enumeration, before publishing drivers. Existing BARs
12// and bridge windows are recorded in PCI bus address space.
13EXPORTED_PUBLIC bool initialize(Device* root = nullptr);
14
15// Runtime registration accepts only Type 0 leaves with unassigned BARs. Both
16// operations require decoding/BME off and no DMA domain or child controllers.
17// The caller serializes driver/topology changes and retains the node until
18// removeFunction() succeeds. Group-owned VFs use their PF's reservations.
19EXPORTED_PUBLIC bool addFunction(Device* device);
20EXPORTED_PUBLIC bool removeFunction(Device* device);
21
22// Reserve an already assigned MMIO interval, or allocate one in configured
23// firmware and upstream bridge windows. allocate() also reserves its result.
24EXPORTED_PUBLIC bool reserve(Device* owner, uint64_t base, uint64_t size, bool prefetchable);
25EXPORTED_PUBLIC bool allocate(Device* owner, uint64_t size, uint64_t alignment, bool prefetchable,
26 uint64_t maxAddress, uint64_t& outBase);
27EXPORTED_PUBLIC bool release(Device* owner, uint64_t base, uint64_t size);
28} // namespace PciResources
29
30#endif