lx_kit: get buffer dataspace from virt addr

Introduce a method to access the dataspace capability of the underlying
backing store for a memory allocation. This is necessary for drivers
where the memory is managed manually and the capability needs to be
given to a client.

Issue #4325.
This commit is contained in:
Josef Söntgen 2021-11-05 17:38:53 +01:00 committed by Christian Helmuth
parent cd7a65a313
commit 327ec61ee3
2 changed files with 14 additions and 0 deletions

View File

@ -105,6 +105,7 @@ class Lx_kit::Mem_allocator
Cache cache_attr);
Attached_dataspace & alloc_dataspace(size_t size);
Dataspace_capability attached_dataspace_cap(void *addr);
void * alloc(size_t size, size_t align);
addr_t dma_addr(void * addr);

View File

@ -49,6 +49,19 @@ Genode::Attached_dataspace & Lx_kit::Mem_allocator::alloc_dataspace(size_t size)
}
Genode::Dataspace_capability Lx_kit::Mem_allocator::attached_dataspace_cap(void * addr)
{
Genode::Dataspace_capability ret { };
_virt_to_dma.apply(Buffer_info::Query_addr(addr),
[&] (Buffer_info const & info) {
ret = info.buffer.ds().cap();
});
return ret;
}
void * Lx_kit::Mem_allocator::alloc(size_t size, size_t align)
{
if (!size)