mirror of
https://github.com/mmueller41/genode.git
synced 2026-01-21 12:32:56 +01:00
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:
@@ -22,64 +22,12 @@
|
||||
|
||||
/* core-local includes */
|
||||
#include <kip.h>
|
||||
#include <mapping.h>
|
||||
|
||||
/* base-internal includes */
|
||||
#include <base/internal/pistachio.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
class Mapping;
|
||||
class Ipc_pager;
|
||||
}
|
||||
|
||||
|
||||
class Genode::Mapping
|
||||
{
|
||||
private:
|
||||
|
||||
union {
|
||||
Pistachio::L4_MapItem_t _map_item;
|
||||
Pistachio::L4_GrantItem_t _grant_item;
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Mapping(addr_t dst_addr, addr_t src_addr, Cache, bool io_mem,
|
||||
unsigned l2size, bool rw, bool executable);
|
||||
|
||||
/**
|
||||
* Construct invalid mapping
|
||||
*/
|
||||
Mapping();
|
||||
|
||||
addr_t _dst_addr() const { return Pistachio::L4_SndBase(_map_item); }
|
||||
|
||||
Pistachio::L4_Fpage_t fpage() const {
|
||||
return Pistachio::L4_MapItemSndFpage(_map_item); }
|
||||
|
||||
Pistachio::L4_MapItem_t map_item() const { return _map_item; };
|
||||
|
||||
/**
|
||||
* Prepare map operation
|
||||
*
|
||||
* On Pistachio, we need to map a page locally to be able to map it
|
||||
* to another address space.
|
||||
*/
|
||||
void prepare_map_operation()
|
||||
{
|
||||
using namespace Pistachio;
|
||||
unsigned char volatile *core_local_addr =
|
||||
(unsigned char volatile *)L4_Address(_map_item.X.snd_fpage);
|
||||
|
||||
if (L4_Rights(_map_item.X.snd_fpage) & L4_Writable)
|
||||
touch_read_write(core_local_addr);
|
||||
else
|
||||
touch_read(core_local_addr);
|
||||
}
|
||||
};
|
||||
namespace Genode { class Ipc_pager; }
|
||||
|
||||
|
||||
class Genode::Ipc_pager
|
||||
@@ -133,7 +81,16 @@ class Genode::Ipc_pager
|
||||
/**
|
||||
* Set parameters for next reply
|
||||
*/
|
||||
void set_reply_mapping(Mapping m) { _map_item = m.map_item(); }
|
||||
void set_reply_mapping(Mapping const &mapping)
|
||||
{
|
||||
using namespace Pistachio;
|
||||
|
||||
L4_Fpage_t fpage = L4_FpageLog2(mapping.src_addr, mapping.size_log2);
|
||||
|
||||
fpage += mapping.writeable ? L4_FullyAccessible : L4_Readable;
|
||||
|
||||
_map_item = L4_MapItem(fpage, mapping.dst_addr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set destination for next reply
|
||||
|
||||
@@ -32,25 +32,20 @@ using namespace Pistachio;
|
||||
** Mapping **
|
||||
*************/
|
||||
|
||||
Mapping::Mapping(addr_t dst_addr, addr_t src_addr, Cache, bool,
|
||||
unsigned l2size, bool rw, bool)
|
||||
/**
|
||||
* Prepare map operation
|
||||
*
|
||||
* On Pistachio, we need to map a page locally to be able to map it to another
|
||||
* address space.
|
||||
*/
|
||||
void Mapping::prepare_map_operation() const
|
||||
{
|
||||
bool const grant = false;
|
||||
uint8_t * const core_local_addr = (uint8_t *)src_addr;
|
||||
|
||||
L4_Fpage_t fpage = L4_FpageLog2(src_addr, l2size);
|
||||
|
||||
fpage += rw ? L4_FullyAccessible : L4_Readable;
|
||||
|
||||
if (grant)
|
||||
_grant_item = L4_GrantItem(fpage, dst_addr);
|
||||
if (writeable)
|
||||
touch_read_write(core_local_addr);
|
||||
else
|
||||
_map_item = L4_MapItem(fpage, dst_addr);
|
||||
}
|
||||
|
||||
|
||||
Mapping::Mapping()
|
||||
{
|
||||
_map_item = L4_MapItem(L4_Nilpage, 0);
|
||||
touch_read(core_local_addr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user