hw: implement Core_region_map::detach

Ref 
This commit is contained in:
Stefan Kalkowski 2024-11-08 15:59:41 +01:00 committed by Christian Helmuth
parent 79ab0cf98e
commit 9a7fe5e775
2 changed files with 20 additions and 1 deletions
repos/base-hw/src/core

View File

@ -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);
}

View File

@ -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>(
[ ] (size_t s) { return s; },
[ ] (Size_at_error) { return 0U; });
}
/********************************
** Platform_generic interface **