mirror of
https://github.com/mmueller41/genode.git
synced 2026-01-21 20:42:56 +01:00
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
92 lines
1.8 KiB
C++
92 lines
1.8 KiB
C++
/*
|
|
* \brief Native capability of base-hw
|
|
* \author Stefan Kalkowski
|
|
* \date 2015-05-15
|
|
*/
|
|
|
|
/*
|
|
* Copyright (C) 2015 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_
|
|
|
|
/* Genode includes */
|
|
#include <kernel/interface.h>
|
|
#include <base/stdint.h>
|
|
|
|
namespace Genode { class Native_capability; }
|
|
|
|
|
|
class Genode::Native_capability
|
|
{
|
|
public:
|
|
|
|
using Dst = Kernel::capid_t;
|
|
|
|
private:
|
|
|
|
Dst _dst;
|
|
|
|
void _inc() const;
|
|
void _dec() const;
|
|
|
|
public:
|
|
|
|
struct Raw { };
|
|
|
|
/**
|
|
* Create an invalid capability
|
|
*/
|
|
Native_capability() : _dst(Kernel::cap_id_invalid()) { }
|
|
|
|
/**
|
|
* Create a capability out of a kernel's capability id
|
|
*/
|
|
Native_capability(Kernel::capid_t dst) : _dst(dst) { _inc(); }
|
|
|
|
/**
|
|
* Create a capability from another one
|
|
*/
|
|
Native_capability(const Native_capability &o) : _dst(o._dst) { _inc(); }
|
|
|
|
~Native_capability() { _dec(); }
|
|
|
|
/**
|
|
* Returns true if it is a valid capability otherwise false
|
|
*/
|
|
bool valid() const { return (_dst != Kernel::cap_id_invalid()); }
|
|
|
|
|
|
/*****************
|
|
** Accessors **
|
|
*****************/
|
|
|
|
addr_t local_name() const { return _dst; }
|
|
Dst dst() const { return _dst; }
|
|
|
|
|
|
/**************************
|
|
** Operator overloads **
|
|
**************************/
|
|
|
|
bool operator==(const Native_capability &o) const {
|
|
return _dst == _dst; }
|
|
|
|
Native_capability& operator=(const Native_capability &o)
|
|
{
|
|
if (this == &o) return *this;
|
|
_dec();
|
|
_dst = o._dst;
|
|
_inc();
|
|
return *this;
|
|
}
|
|
|
|
Raw raw() const { return Raw(); }
|
|
};
|
|
|
|
#endif /* _INCLUDE__BASE__NATIVE_CAPABILITY_H_ */
|