diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-04-08 13:54:52 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-04-08 13:54:52 +0200 |
| commit | 878852c94c4d56f303366cec177b3edef9b3b9c5 (patch) | |
| tree | b7c33b89201f6a8ae55fdc4ba041c4f1b9b97f99 /kapi/include | |
| parent | 0bbec5ceba0df5668ab1aedcbf2905bf599f6eba (diff) | |
| download | teachos-878852c94c4d56f303366cec177b3edef9b3b9c5.tar.xz teachos-878852c94c4d56f303366cec177b3edef9b3b9c5.zip | |
kapi: add basic support for MMIO mapping
Diffstat (limited to 'kapi/include')
| -rw-r--r-- | kapi/include/kapi/memory.hpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/kapi/include/kapi/memory.hpp b/kapi/include/kapi/memory.hpp index 914ca61..ae33904 100644 --- a/kapi/include/kapi/memory.hpp +++ b/kapi/include/kapi/memory.hpp @@ -79,6 +79,36 @@ namespace kapi::memory //! @param page The page to unmap auto unmap(page page) -> void; + //! Initialize the Memory-mapped I/O region system. + //! + //! @param base The base address for the MMIO region. + //! @param page_count The number of pages the MMIO region is spans. + auto init_mmio(linear_address base, std::size_t page_count) -> void; + + //! Allocate a Memory-mapped I/O region of the given size. + //! + //! @warning This function will panic if the MMIO system has not been initialized! + //! @param page_count The number of pages to allocate. + auto allocate_mmio_region(std::size_t page_count) -> linear_address; + + //! Map a region of Memory-mapped I/O address space to a given hardware address using the given flags. + //! + //! @warning This function will panic if no page mapper has been registered, or the page has already been mapped. + //! This function will not ensure that the frame is not already in use. + //! + //! This function will always set the @p uncached flag. + //! + //! @param base The base of the virtual region. + //! @param hw_base The base of the hardware region. + //! @param flags The flags to apply. + auto map_mmio_region(linear_address base, physical_address hw_base, page_mapper::flags flags = {}) -> std::byte *; + + //! Release a Memory-mapped I/O region. + //! + //! @warning This function will panic if the MMIO system has not been initialized! + //! @param base The start address of the region to release. + auto release_mmio_region(linear_address base) -> void; + //! @} //! @addtogroup kapi-memory-platform-defined |
