aboutsummaryrefslogtreecommitdiff
path: root/kapi
diff options
context:
space:
mode:
Diffstat (limited to 'kapi')
-rw-r--r--kapi/kapi/memory.hpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/kapi/kapi/memory.hpp b/kapi/kapi/memory.hpp
index 2ae8b91b..4cdd6ac1 100644
--- a/kapi/kapi/memory.hpp
+++ b/kapi/kapi/memory.hpp
@@ -10,6 +10,7 @@
#include <kapi/memory/page_mapper.hpp> // IWYU pragma: export
#include <kstd/memory.hpp>
+#include <kstd/result.hpp>
#include <cstddef>
#include <optional>
@@ -94,8 +95,10 @@ namespace kapi::memory
//! 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) -> mmio_region;
+ //! @return The newly allocated MMIO region on success, an error otherwise.
+ auto allocate_mmio_region(std::size_t page_count) -> kstd::result<mmio_region>;
//! Map a region of Memory-mapped I/O address space to a given hardware address using the given flags.
//!
@@ -107,10 +110,15 @@ namespace kapi::memory
//! @param region The region to map.
//! @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.
auto map_mmio_region(mmio_region region, physical_address hw_base, page_mapper::flags flags = {})
- -> kstd::observer_ptr<std::byte>;
+ -> kstd::result<kstd::observer_ptr<std::byte>>;
- //! Release a Memory-mapped I/O region.
+ //! Release (unmap and free) a Memory-mapped I/O region.
+ //!
+ //! This function is tolerant of partially mapped regions and will unmap any mapped pages within the region before
+ //! releasing the MMIO region.
//!
//! @warning This function will panic if the MMIO system has not been initialized!
//! @param region The region to release.