Files
genode/repos/base-sel4/include/base/native_capability.h
Norman Feske d71f0a9606 Cleanup of parent-cap handling
This patch alleviates the need for a Native_capability::Dst at the API
level. The former use case of this type as argument to
Deprecated_env::reinit uses the opaque Native_capability::Raw type
instead. The 'Raw' type contains the portion of the capability that is
transferred as-is when delegating the capability (i.e., when installing
the parent capability into a new component, or when installing a new
parent capability into a new forked Noux process). This information can
be retrieved via the new Native_capability::raw method.

Furthermore, this patch moves the functions for retriving the parent
capability to base/internal/parent_cap.h, which is meant to be
implemented in platform-specific ways. It replaces the former set of
startup/internal/_main_parent_cap.h headers.

Issue #1993
2016-07-11 13:05:27 +02:00

103 lines
1.8 KiB
C++

/*
* \brief Platform-specific capability type
* \author Norman Feske
* \date 2014-10-14
*/
/*
* Copyright (C) 2013 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _INCLUDE__BASE__NATIVE_CAPABILITY_H_
#define _INCLUDE__BASE__NATIVE_CAPABILITY_H_
#include <base/stdint.h>
namespace Genode {
class Native_capability
{
public:
/*
* Platform-specific raw information of the capability that is
* transferred as-is when the capability is delegated.
*/
struct Raw { long v[4]; };
/**
* Forward declaration of the platform-specific internal capability
* representation
*/
class Data;
private:
Data *_data = nullptr;
protected:
void _inc();
void _dec();
public:
/**
* Default constructor creates an invalid capability
*/
Native_capability() { }
/**
* Copy constructor
*/
Native_capability(const Native_capability &other)
: _data(other._data) { _inc(); }
/**
* Construct capability manually
*
* This constructor is used internally.
*
* \noapi
*/
Native_capability(Data &data) : _data(&data) { _inc(); }
/**
* Destructor
*/
~Native_capability() { _dec(); }
Data const *data() const { return _data; }
/**
* Overloaded comparision operator
*/
bool operator == (const Native_capability &o) const
{
return _data == o._data;
}
Native_capability& operator = (const Native_capability &o)
{
if (this == &o)
return *this;
_dec();
_data = o._data;
_inc();
return *this;
}
long local_name() const;
bool valid() const;
Raw raw() const { return { { 0, 0, 0, 0 } }; }
};
}
#endif /* _INCLUDE__BASE__NATIVE_CAPABILITY_H_ */