diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-11-14 19:03:39 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-11-22 14:20:36 +0100 |
| commit | 9a17b94c3cc3397152092da7f40a17682440fd78 (patch) | |
| tree | 13d69401b8a5f72449777597d762466ef0538eb1 | |
| parent | dc5edf2193c14b17939ba9afe9eef4a907da053f (diff) | |
| download | kernel-9a17b94c3cc3397152092da7f40a17682440fd78.tar.xz kernel-9a17b94c3cc3397152092da7f40a17682440fd78.zip | |
kapi/memory: carry hw_base offset forward in mapping
| -rw-r--r-- | kapi/kapi/memory.hpp | 7 | ||||
| -rw-r--r-- | kernel/kapi/memory.cpp | 3 |
2 files changed, 6 insertions, 4 deletions
diff --git a/kapi/kapi/memory.hpp b/kapi/kapi/memory.hpp index 7979c7e1..ece85203 100644 --- a/kapi/kapi/memory.hpp +++ b/kapi/kapi/memory.hpp @@ -110,11 +110,12 @@ namespace kapi::memory //! //! This function will always set the @p uncached, @p global, and @p supervisor_only flags. //! - //! @param region The region to map. + //! @param region The region to map. This region must cover the in-page offset of hw_base plus the range to be + //! accessed. //! @param hw_base The base of the hardware region. //! @param flags The flags to apply. - //! @return A result containing a pointer to the first byte of the mapped region on success, an error otherwise, in - //! which case any partial mappings have been rolled back. + //! @return A pointer into the mapped region, including any frame offset, on success, an error otherwise, in which + //! case any partial mappings have been rolled back. auto map_mmio_region(mmio_region region, physical_address hw_base, page_mapper::flags flags = {}) -> kstd::result<kstd::observer_ptr<std::byte>>; diff --git a/kernel/kapi/memory.cpp b/kernel/kapi/memory.cpp index 83b32f0d..12e9e23f 100644 --- a/kernel/kapi/memory.cpp +++ b/kernel/kapi/memory.cpp @@ -194,6 +194,7 @@ namespace kapi::memory auto start_page = page::containing(start); auto start_frame = frame::containing(hw_base); + auto frame_offset = hw_base.raw() % frame::size.value; flags |= page_mapper::flags::uncached | page_mapper::flags::supervisor_only | page_mapper::flags::global; @@ -217,7 +218,7 @@ namespace kapi::memory } } - return kstd::success(first_mapped_page); + return kstd::success(first_mapped_page + frame_offset); } auto release_mmio_region(mmio_region region) -> void |
