mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-22 23:12:24 +00:00
88b358c5ef
This patch establishes the sole use of generic headers across all kernels. The common 'native_capability.h' is based on the version of base-sel4. All traditional L4 kernels and Linux use the same implementation of the capability-lifetime management. On base-hw, NOVA, Fiasco.OC, and seL4, custom implementations (based on their original mechanisms) are used, with the potential to unify them further in the future. This change achieves binary compatibility of dynamically linked programs across all kernels. Furthermore, the patch introduces a Native_capability::print method, which allows the easy output of the kernel-specific capability representation using the base/log.h API. Issue #1993
48 lines
1.1 KiB
C++
48 lines
1.1 KiB
C++
/*
|
|
* \brief Capability helper
|
|
* \author Norman Feske
|
|
* \date 2016-06-27
|
|
*/
|
|
|
|
/*
|
|
* Copyright (C) 2016 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__NOVA__CAPABILITY_SPACE_H_
|
|
#define _INCLUDE__NOVA__CAPABILITY_SPACE_H_
|
|
|
|
/* Genode includes */
|
|
#include <base/capability.h>
|
|
|
|
/* NOVA includes */
|
|
#include <nova/syscalls.h>
|
|
|
|
namespace Genode { namespace Capability_space {
|
|
|
|
enum { INVALID_INDEX = ~0UL };
|
|
|
|
typedef Nova::Crd Ipc_cap_data;
|
|
|
|
static inline Nova::Crd crd(Native_capability const &cap)
|
|
{
|
|
/*
|
|
* We store the 'Nova::Crd' value in place of the 'Data' pointer.
|
|
*/
|
|
addr_t value = (addr_t)cap.data();
|
|
Nova::Crd crd = *(Nova::Crd *)&value;
|
|
return crd;
|
|
}
|
|
|
|
static inline Native_capability import(addr_t sel, unsigned rights = 0x1f)
|
|
{
|
|
Nova::Obj_crd const crd = (sel == INVALID_INDEX)
|
|
? Nova::Obj_crd() : Nova::Obj_crd(sel, 0, rights);
|
|
return Native_capability(*(Native_capability::Data *)crd.value());
|
|
}
|
|
} }
|
|
|
|
#endif /* _INCLUDE__NOVA__CAPABILITY_SPACE_H_ */
|