diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-11-12 22:46:57 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-11-22 14:20:35 +0100 |
| commit | 27a58a338ad2f61a063df02488fc497405afc492 (patch) | |
| tree | d7464b9ea0c15ce7cf6a5481d79a473d937baf0e /arch | |
| parent | c3e178493607271a4e68c1a1427b3ac82671e72c (diff) | |
| download | kernel-27a58a338ad2f61a063df02488fc497405afc492.tar.xz kernel-27a58a338ad2f61a063df02488fc497405afc492.zip | |
dev/pcie: implement initial detection
Diffstat (limited to 'arch')
| -rw-r--r-- | arch/x86_64/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | arch/x86_64/kapi/devices/pci_express.cpp | 30 |
2 files changed, 31 insertions, 0 deletions
diff --git a/arch/x86_64/CMakeLists.txt b/arch/x86_64/CMakeLists.txt index 59df016e..b54fce95 100644 --- a/arch/x86_64/CMakeLists.txt +++ b/arch/x86_64/CMakeLists.txt @@ -19,6 +19,7 @@ target_sources("x86_64" PRIVATE "kapi/cio.cpp" "kapi/cpu.cpp" "kapi/devices.cpp" + "kapi/devices/pci_express.cpp" "kapi/interrupts.cpp" "kapi/memory.cpp" "kapi/system.cpp" diff --git a/arch/x86_64/kapi/devices/pci_express.cpp b/arch/x86_64/kapi/devices/pci_express.cpp new file mode 100644 index 00000000..ca566bf0 --- /dev/null +++ b/arch/x86_64/kapi/devices/pci_express.cpp @@ -0,0 +1,30 @@ +#include <kapi/devices/pci_express.hpp> + +#include <kapi/acpi.hpp> + +#include <acpi/acpi.hpp> + +#include <kstd/ranges.hpp> +#include <kstd/vector.hpp> + +#include <ranges> + +namespace kapi::devices +{ + + auto get_pci_express_segment_descriptors() -> kstd::vector<pcie_segment_descriptor> + { + auto mcfg_table = kapi::acpi::get_table<::acpi::table_signature_v<::acpi::mcfg>>(); + if (!mcfg_table) + { + return {}; + } + + return kstd::vector{kstd::from_range, *mcfg_table | std::views::transform([](auto & entry) { + return pcie_segment_descriptor{.base_address = entry.base_address(), + .first_bus = entry.start_bus_number(), + .last_bus = entry.end_bus_number()}; + })}; + } + +} // namespace kapi::devices
\ No newline at end of file |
