Replace 'Native_capability::copy_to' by accessor

The 'copy_to' function turned out to be not flexible enough to
accommodate the Noux fork mechanism. This patch removes the function,
adds an accessor for the capability destination and a compound type
'Native_capability::Raw' to be used wherever plain capability
information must be communicated.
This commit is contained in:
Norman Feske
2012-03-26 14:32:16 +02:00
parent 22084dbfa5
commit d6e30c19de
18 changed files with 119 additions and 87 deletions

View File

@@ -43,11 +43,22 @@ namespace Genode {
template <typename POLICY>
class Native_capability_tpl
{
private:
public:
typedef typename POLICY::Dst Dst;
Dst _tid;
/**
* Compound object used to copy raw capability members
*
* This type is a utility solely used to communicate the
* information about the parent capability from the parent to the
* new process.
*/
struct Raw { Dst dst; long local_name; };
private:
Dst _dst;
long _local_name;
protected:
@@ -63,14 +74,14 @@ namespace Genode {
* \param ptr address of the local object
*/
Native_capability_tpl(void* ptr)
: _tid(POLICY::invalid()), _local_name((long)ptr) { }
: _dst(POLICY::invalid()), _local_name((long)ptr) { }
public:
/**
* Constructor for an invalid capability
*/
Native_capability_tpl() : _tid(POLICY::invalid()), _local_name(0) { }
Native_capability_tpl() : _dst(POLICY::invalid()), _local_name(0) { }
/**
* Publicly available constructor
@@ -80,12 +91,12 @@ namespace Genode {
* that corresponds to the capability.
*/
Native_capability_tpl(Dst tid, long local_name)
: _tid(tid), _local_name(local_name) { }
: _dst(tid), _local_name(local_name) { }
/**
* Return true when the capability is valid
*/
bool valid() const { return POLICY::valid(_tid); }
bool valid() const { return POLICY::valid(_dst); }
/**
* Return ID used to lookup the 'Rpc_object' by its capability
@@ -98,19 +109,9 @@ namespace Genode {
void* local() const { return (void*)_local_name; }
/**
* Copy this capability to another PD
* Return capability destination
*/
void copy_to(void* dst) { POLICY::copy(dst, this); }
/*****************************************
** Only used by platform-specific code **
*****************************************/
/**
* Return the kernel-specific capability destination
*/
Dst dst() const { return _tid; }
Dst dst() const { return _dst; }
};
}

View File

@@ -154,7 +154,7 @@ namespace Genode {
* meaningful capabilities obtained via its updated parent
* capability.
*/
void reload_parent_cap(Capability<Parent>);
void reload_parent_cap(Native_capability::Dst, long);
/*******************

View File

@@ -15,7 +15,8 @@
#include <base/crt0.h>
void Genode::Platform_env::reload_parent_cap(Capability<Parent> parent_cap)
void Genode::Platform_env::reload_parent_cap(Native_capability::Dst dst,
long local_name)
{
/*
* This function is unused during the normal operation of Genode. It is
@@ -35,7 +36,10 @@ void Genode::Platform_env::reload_parent_cap(Capability<Parent> parent_cap)
* Patch new parent capability into the original location as specified by
* the linker script.
*/
*(Capability<Parent> *)(&_parent_cap) = parent_cap;
Native_capability::Raw *raw = (Native_capability::Raw *)(&_parent_cap);
raw->dst = dst;
raw->local_name = local_name;
/*
* Re-initialize 'Platform_env' members

View File

@@ -122,7 +122,11 @@ static addr_t _setup_elf(Parent_capability parent_cap,
* data segment
*/
if (!parent_info) {
parent_cap.copy_to(ptr);
Native_capability::Raw *raw = (Native_capability::Raw *)ptr;
raw->dst = parent_cap.dst();
raw->local_name = parent_cap.local_name();
parent_info = true;
}