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