4#include <l4/sys/consts.h>
6#include <l4/sys/task.h>
13template<
typename T >
class L4_EXPORT Cap;
57 bool is_valid() const noexcept {
return !(_c & L4_INVALID_CAP_BIT); }
59 explicit operator bool () const noexcept
60 {
return !(_c & L4_INVALID_CAP_BIT); }
93 bool operator == (
Cap_base const &o)
const noexcept
94 {
return _c == o._c; }
99 bool operator != (
Cap_base const &o)
const noexcept
100 {
return _c != o._c; }
217template<
typename T >
234 explicit Cap(T
const *p) noexcept
245 template<
typename From >
249 [[maybe_unused]] To* t =
static_cast<From*
>(
nullptr);
258 template<
typename From >
262 [[maybe_unused]] To *t =
static_cast<To *
>(
static_cast<From *
>(
nullptr));
269 template<
typename O >
271 { check_convertible_from<O>(); }
321 T *operator -> () const noexcept {
return reinterpret_cast<T*
>(_c); }
336class L4_EXPORT Cap<void> :
public Cap_base
340 explicit Cap(
void const *p) noexcept
346 Cap(Cap_type cap) noexcept : Cap_base(cap) {}
359 explicit Cap(No_init_type)
noexcept {}
361 template<
typename From >
362 static void check_convertible_from() noexcept {}
364 template<
typename From >
365 static void check_castable_from() noexcept {}
373 Cap move(Cap
const &src)
const
383 Cap copy(Cap
const &src)
const
389 template<
typename T >
390 Cap(Cap<T>
const &o) noexcept : Cap_base(o.cap()) {}
409template<
typename T,
typename F >
418template<
typename T >
420Cap<T>
cap_cast(Cap<L4::Kobject>
const &c)
noexcept
422 return Cap<T>(c.cap());
440template<
typename T,
typename F >
Base class for all kinds of capabilities.
void copy(Cap_base const &src) const
Copy a capability.
Cap_base(l4_default_caps_t cap) noexcept
Initialize capability with one of the default capabilities.
Cap_base(Cap_type cap) noexcept
Constructor to create an invalid capability.
l4_fpage_t fpage(unsigned rights=L4_CAP_FPAGE_RWS) const noexcept
Return flex-page for the capability.
l4_cap_idx_t _c
The C representation of a capability selector.
l4_cap_idx_t cap() const noexcept
Return capability selector.
bool is_valid() const noexcept
Test whether the capability is a valid capability index (i.e., not L4_INVALID_CAP).
void move(Cap_base const &src) const
Replace this capability with the contents of src.
Cap_type
Invalid capability type.
No_init_type
Special value for uninitialized capability objects.
Cap_base(l4_cap_idx_t c) noexcept
Generate a capability from its C representation.
Cap_base() noexcept
Create an uninitialized instance.
l4_umword_t snd_base(unsigned grant=L4_MAP_ITEM_MAP, l4_cap_idx_t base=L4_INVALID_CAP) const noexcept
Return send base.
C++ interface for capabilities.
Cap copy(Cap const &src) const
Copy a capability to this cap slot.
Cap(l4_cap_idx_t idx=L4_INVALID_CAP) noexcept
Initialize capability, defaults to the invalid capability selector.
Cap(No_init_type) noexcept
Create an uninitialized cap selector.
Cap(Cap_type cap) noexcept
Constructor to create an invalid capability selector.
static void check_castable_from() noexcept
Perform the type conversion that needs to compile in order for a capability of type From te be castab...
Cap(l4_default_caps_t cap) noexcept
Initialize capability with one of the default capability selectors.
Cap(Cap< O > const &o) noexcept
Create a copy from o, supporting implicit type casting.
Cap move(Cap const &src) const
Move a capability to this cap slot.
static void check_convertible_from() noexcept
Perform the type conversion that needs to compile in order for a capability of type From to be conver...
Base class for all kinds of kernel objects and remote objects, referenced by capabilities.
C++ interface of the Task kernel object, see Task for the C interface.
unsigned long l4_umword_t
Unsigned machine word.
unsigned long l4_cap_idx_t
Capability selector type.
l4_default_caps_t
Default capabilities setup for the initial tasks.
@ L4_BASE_TASK_CAP
Capability selector for the current task.
@ L4_INVALID_CAP
Invalid capability selector.
l4_fpage_t l4_obj_fpage(l4_cap_idx_t obj, unsigned int order, unsigned char rights) L4_NOTHROW
Create a kernel-object flex page.
@ L4_FPAGE_C_OBJ_RIGHTS
All Object-type specific right bits.
@ L4_CAP_FPAGE_RWSD
Full rights for capability flex-pages.
@ L4_CAP_FPAGE_RWS
Read, interface specific 'W', and 'S' rights for capability flex-pages.
l4_umword_t l4_map_obj_control(l4_umword_t spot, unsigned grant) L4_NOTHROW
Create the first word for a map item for the object space.
@ L4_MAP_ITEM_GRANT
Flag as grant instead of map operation.
@ L4_MAP_ITEM_MAP
Flag as usual map operation.
l4_msgtag_t l4_task_map(l4_cap_idx_t dst_task, l4_cap_idx_t src_task, l4_fpage_t snd_fpage, l4_umword_t snd_base) L4_NOTHROW
Map resources available in the source task to a destination task.
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
#define L4_EXPORT
Attribute to mark functions, variables, and data types as being exported from a library.
Common L4 ABI Data Types.
L4 low-level kernel interface.
Cap< T > cap_reinterpret_cast(Cap< F > const &c) noexcept
reinterpret_cast for capabilities.
Cap< T > cap_cast(Cap< F > const &c) noexcept
static_cast for capabilities.
Message tag data structure.