From 3836768bb8b95188e6657ab69027d1d9e4b13a77 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Mon, 3 Apr 2023 14:06:30 +1000 Subject: new pipeline working(?), but the dac eludes me --- src/memory/include/himem.hpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/memory/include/himem.hpp') diff --git a/src/memory/include/himem.hpp b/src/memory/include/himem.hpp index f71e912f..517ebfdf 100644 --- a/src/memory/include/himem.hpp +++ b/src/memory/include/himem.hpp @@ -57,21 +57,26 @@ class MappableRegion { } auto Get() -> cpp::span { - if (bytes_ != nullptr) { + if (bytes_ == nullptr) { return {}; } return {bytes_, size}; } auto Map(const HimemAlloc& alloc) -> cpp::span { - if (bytes_ != nullptr) { - ESP_ERROR_CHECK(esp_himem_unmap(range_handle, bytes_, size)); - } + assert(bytes_ == nullptr); ESP_ERROR_CHECK(esp_himem_map(alloc.handle, range_handle, 0, 0, size, 0, reinterpret_cast(&bytes_))); return Get(); } + auto Unmap() -> void { + if (bytes_ != nullptr) { + ESP_ERROR_CHECK(esp_himem_unmap(range_handle, bytes_, size)); + bytes_ = nullptr; + } + } + // Not copyable or movable. MappableRegion(const MappableRegion&) = delete; MappableRegion& operator=(const MappableRegion&) = delete; -- cgit v1.2.3