diff --git a/repos/base-hw/src/core/core_region_map.cc b/repos/base-hw/src/core/core_region_map.cc index 8965688c8a..f56d302efb 100644 --- a/repos/base-hw/src/core/core_region_map.cc +++ b/repos/base-hw/src/core/core_region_map.cc @@ -82,4 +82,11 @@ Core_region_map::attach(Dataspace_capability ds_cap, Attr const &attr) } -void Core_region_map::detach(addr_t) { } +void Core_region_map::detach(addr_t core_local_addr) +{ + size_t size = platform_specific().region_alloc_size_at((void *)core_local_addr); + + unmap_local(core_local_addr, size >> get_page_size_log2()); + + platform().region_alloc().free((void *)core_local_addr); +} diff --git a/repos/base-hw/src/core/platform.h b/repos/base-hw/src/core/platform.h index de24fa5150..62fd61469e 100644 --- a/repos/base-hw/src/core/platform.h +++ b/repos/base-hw/src/core/platform.h @@ -119,6 +119,18 @@ class Core::Platform : public Platform_generic static addr_t core_page_table(); static Hw::Page_table::Allocator & core_page_table_allocator(); + /** + * Determine size of a core local mapping required for a + * Core_region_map::detach(). + */ + size_t region_alloc_size_at(void * addr) + { + using Size_at_error = Allocator_avl::Size_at_error; + + return (_core_mem_alloc.virt_alloc())()->size_at(addr).convert( + [ ] (size_t s) { return s; }, + [ ] (Size_at_error) { return 0U; }); + } /******************************** ** Platform_generic interface **