core: kernel-agnostic 'Mapping' type

This patch unifies the core-internal 'Mapping' type across all base
platforms.

As one minor downside on seL4, the diagnostic error messages when
observing faults other than page faults no longer print the faulting
thread and PD names.

Issue #2243
This commit is contained in:
Norman Feske
2021-04-09 18:47:28 +02:00
parent 7ae1210531
commit dc89ebf978
23 changed files with 334 additions and 544 deletions

View File

@ -0,0 +1,37 @@
/*
* \brief Kernel-agnostic memory-mapping arguments
* \author Norman Feske
* \date 2021-04-12
*/
/*
* Copyright (C) 2021 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _CORE__INCLUDE__MAPPING_H_
#define _CORE__INCLUDE__MAPPING_H_
#include <base/stdint.h>
namespace Genode { struct Mapping; }
struct Genode::Mapping
{
addr_t dst_addr;
addr_t src_addr;
size_t size_log2;
bool cached; /* RAM caching policy */
bool io_mem; /* IO_MEM dataspace */
bool dma_buffer; /* must be mapped in IOMMU page tables */
bool write_combined; /* write-combined IO_MEM dataspace */
bool writeable;
bool executable;
void prepare_map_operation() const;
};
#endif /* _CORE__INCLUDE__MAPPING_H_ */

View File

@ -314,16 +314,16 @@ Mapping Region_map_component::create_map_item(Region_map_component *,
Rm_region &region,
addr_t const ds_offset,
addr_t const region_offset,
Dataspace_component &dsc,
Dataspace_component &dataspace,
addr_t const page_addr,
addr_t const dst_region_size)
{
addr_t const ds_base = dsc.map_src_addr();
addr_t const ds_base = dataspace.map_src_addr();
Fault_area src_fault_area(ds_base + ds_offset);
Fault_area dst_fault_area(page_addr);
src_fault_area.constrain(ds_base, dsc.size());
src_fault_area.constrain(ds_base, dataspace.size());
dst_fault_area.constrain(region_offset + region.base(), dst_region_size);
/*
@ -339,11 +339,16 @@ Mapping Region_map_component::create_map_item(Region_map_component *,
if (!src_fault_area.valid() || !dst_fault_area.valid())
error("invalid mapping");
return Mapping(dst_fault_area.base(), src_fault_area.base(),
dsc.cacheability(), dsc.io_mem(),
map_size_log2, region.write() && dsc.writable(),
region.executable());
};
return Mapping { .dst_addr = dst_fault_area.base(),
.src_addr = src_fault_area.base(),
.size_log2 = map_size_log2,
.cached = dataspace.cacheability() == CACHED,
.io_mem = dataspace.io_mem(),
.dma_buffer = dataspace.cacheability() != CACHED,
.write_combined = dataspace.cacheability() == WRITE_COMBINED,
.writeable = region.write() && dataspace.writable(),
.executable = region.executable() };
}
Region_map::Local_addr