aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/x86_64/CMakeLists.txt1
-rw-r--r--arch/x86_64/kapi/devices/pci_express.cpp30
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