From 27a58a338ad2f61a063df02488fc497405afc492 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Thu, 12 Nov 2026 22:46:57 +0100 Subject: dev/pcie: implement initial detection --- kernel/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'kernel/CMakeLists.txt') diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index e105ae62..a8be3850 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -42,6 +42,7 @@ target_sources("kernel_lib" PRIVATE # Device Subsystem "kernel/devices/block_device_utils.cpp" "kernel/devices/init.cpp" + "kernel/devices/pci_express.cpp" "kernel/devices/pseudo.cpp" "kernel/devices/storage.cpp" -- cgit v1.2.3 From 45bf10f2ac489cc8253eb2f145c569edc16fc45a Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Mon, 16 Nov 2026 10:20:33 +0100 Subject: kapi/memory: replace mmio_region API with mmio_window Previously, allocation and mapping of MMIO regions was a multi-step process. The MMIO region API required its users to track and manage the lifetime of an MMIO region allocation manually. The new MMIO window API simplifies this by providing a single-step mapping interface and automatic lifetime management. Additionally, the new API adds strict bounds and alignment checks, to ensure that all MMIO accesses are within the requested range. The new API enforces these constraints at runtime via a system panic. Other contract violations, such as zero-sized mappings, are handled via runtime error codes. The new kapi::memory::mmio_window preserves the in-page offset of the hardware base within the window and bases all accesses on this offset. This means no user intervention is required to handle hardware ranges that are not aligned to a natural page boundary. The original pointer adjustment logic has been moved into the mmio_window class. Previous consumers of the region API (x86_64 LAPIC, PCIe) have been updated to the new mmio_window API. The behavior of the PCIe scan implementation has changed in that no windows are kept alive beyond the execution of the scan, since there are no consumers that would require persistent MMIO windows. Tests for the new infrastructure have been added, including a test support seam to allow for deinitialization of the MMIO subsystem in tests. --- kernel/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'kernel/CMakeLists.txt') diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index a8be3850..705f3a85 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -23,6 +23,7 @@ target_sources("kernel_lib" PRIVATE "kapi/filesystem.cpp" "kapi/interrupts.cpp" "kapi/memory.cpp" + "kapi/memory/mmio.cpp" "kapi/system.cpp" "kapi/tracked_mutex.cpp" -- cgit v1.2.3 From a42ab28f65e3ef5926137ddf4c62b188c33ca440 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Mon, 16 Nov 2026 15:50:15 +0100 Subject: kernel/devices: introduce PCI ecam_segment abstraction Previously, ECAM access was implemented "in-place" inside the PCI scan function. This meant that any checks were ad-hoc and not easily reusable or testable. Therefore, this change introduces a dedicated, reusable abstraction for ECAM segment access. It validates segment descriptors received from the platform and ensures no out-of-bounds buses are accessed at runtime. Construction of an ecam_segment will always succeed. If the firmware or platform data does not describe a valid segment, the ecam_segment will behave as if it had a size of zero, with a kernel log indicating the invalid segment. Attempting to map a bus that is out-of-bounds for a given ecam_segment will return a runtime error. If the system's MMIO space is insufficient to accommodate the mapping of a valid bus in an ecam_segment, a runtime error will be returned. Furthermore, this change introduces the kernel::devices::pci namespace. PCI initialization and scanning functionality, previously hosted in kernel/kernel/devices/pci_express.{cpp,hpp}, has been relocated and renamed to kernel/kernel/devices/pci/init.{cpp,hpp}. The initialization function of the PCI subsystem has been renamed from kernel::devices::init_pci_express_devices to kernel::devices::pci::init. The observable behavior of the PCI scan remains unchanged. Tests have been added to validate the behavior of ecam_segment against its contract. --- kernel/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'kernel/CMakeLists.txt') diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index 705f3a85..df65ed20 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -43,7 +43,8 @@ target_sources("kernel_lib" PRIVATE # Device Subsystem "kernel/devices/block_device_utils.cpp" "kernel/devices/init.cpp" - "kernel/devices/pci_express.cpp" + "kernel/devices/pci/ecam_segment.cpp" + "kernel/devices/pci/init.cpp" "kernel/devices/pseudo.cpp" "kernel/devices/storage.cpp" -- cgit v1.2.3 From 2f9972781b66fd350f1975b2975f8998d5d07f13 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Wed, 18 Nov 2026 08:39:07 +0100 Subject: kernel/devices: extract bus scanning implementation This change extracts the PCI bus scanning logic, which previously was hidden inside an anonymous namespace, into a dedicated function. This allows for the implementation to be tested independently. --- kernel/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'kernel/CMakeLists.txt') diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index df65ed20..7f418c61 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -45,6 +45,7 @@ target_sources("kernel_lib" PRIVATE "kernel/devices/init.cpp" "kernel/devices/pci/ecam_segment.cpp" "kernel/devices/pci/init.cpp" + "kernel/devices/pci/scan.cpp" "kernel/devices/pseudo.cpp" "kernel/devices/storage.cpp" -- cgit v1.2.3