57 bool is_valid() const noexcept {
return !(
_c & L4_INVALID_CAP_BIT); }
64 explicit operator bool () const noexcept
65 {
return !(_c & L4_INVALID_CAP_BIT); }
98 bool operator == (
Cap_base const &o)
const noexcept
99 {
return _c == o._c; }
104 bool operator != (
Cap_base const &o)
const noexcept
105 {
return _c != o._c; }
218 return !other.is_valid();
220 if (other.is_valid())
247template<
typename T >
264 explicit Cap(T
const *p) noexcept
275 template<
typename From >
279 [[maybe_unused]] To* t =
static_cast<From*
>(
nullptr);
288 template<
typename From >
292 [[maybe_unused]] To *t =
static_cast<To *
>(
static_cast<From *
>(
nullptr));
299 template<
typename O >
329 bool move(Cap
const &src)
const noexcept
335 bool copy(Cap
const &src)
const noexcept
347 T *operator -> () const noexcept
349 static_assert(
sizeof(
_c) <=
sizeof(T*));
350 return reinterpret_cast<T*
>(
_c);
366class L4_EXPORT Cap<void> :
public Cap_base
370 explicit Cap(
void const *p) noexcept
376 Cap(Cap_type cap) noexcept : Cap_base(cap) {}
389 explicit Cap(No_init_type)
noexcept {}
391 template<
typename From >
392 static void check_convertible_from() noexcept {}
394 template<
typename From >
395 static void check_castable_from() noexcept {}
400 bool move(Cap
const &src)
const noexcept
401 {
return Cap_base::move(src); }
406 bool copy(Cap
const &src)
const noexcept
407 {
return Cap_base::copy(src); }
412 bool is_equal(Cap
const &other)
const noexcept
413 {
return Cap_base::is_equal(other); }
415 template<
typename T >
416 Cap(Cap<T>
const &o) noexcept : Cap_base(o.cap()) {}
435template<
typename T,
typename F >
444template<
typename T >
446Cap<T>
cap_cast(Cap<L4::Kobject>
const &c)
noexcept
448 return Cap<T>(c.cap());
466template<
typename T,
typename F >
481 constexpr explicit Reply_cap_idx() noexcept : _i(
L4_INVALID_CAP) {}
482 constexpr explicit Reply_cap_idx(
l4_cap_idx_t i) noexcept
488 explicit constexpr operator l4_cap_idx_t()
const noexcept
491 explicit constexpr operator bool()
const noexcept
492 {
return !(_i & L4_INVALID_CAP_BIT); }
494 constexpr bool operator==(Reply_cap_idx o)
const noexcept
495 {
return _i == o._i; }
497 constexpr bool operator!=(Reply_cap_idx o)
const noexcept
498 {
return _i != o._i; }
508 friend class Reply_cap;
511 constexpr Reply_cap_alloc() =
default;
518 Reply_cap_alloc(Reply_cap_alloc
const &) =
delete;
519 Reply_cap_alloc &operator = (Reply_cap_alloc
const &) =
delete;
526 virtual Reply_cap
alloc() noexcept = 0;
563 : _cap(cap), _alloc(
alloc)
580 : _cap(o._cap), _alloc(o._alloc)
586 Reply_cap &operator=(Reply_cap &&o)
noexcept
588 reset(o._cap, o._alloc);
589 o._cap = Reply_cap_idx();
610 if (is_valid()) [[likely]]
618 if (err) [[unlikely]]
633 constexpr bool is_valid() const noexcept
634 {
return static_cast<bool>(_cap); }
636 explicit constexpr operator bool () const noexcept
637 {
return is_valid(); }
639 constexpr bool operator==(Reply_cap
const &o)
const noexcept
640 {
return _cap == o._cap; }
642 constexpr bool operator==(Reply_cap_idx o)
const noexcept
643 {
return _cap == o; }
645 constexpr bool operator!=(Reply_cap
const &o)
const noexcept
646 {
return _cap != o._cap; }
648 constexpr bool operator!=(Reply_cap_idx o)
const noexcept
649 {
return _cap != o; }
660 if (is_valid()) [[unlikely]]
bool copy(Cap_base const &src) const noexcept
Copy a capability.
Cap_base(l4_default_caps_t cap) noexcept
Initialize capability with one of the default capabilities.
void invalidate() noexcept
Set this capability to invalid (L4_INVALID_CAP).
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 flexpage for the capability.
bool move(Cap_base const &src) const noexcept
Replace this capability with the contents of src.
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).
Cap_type
Invalid capability type.
@ Invalid
Invalid capability selector.
int invalid_cap_error() const noexcept
Return the transported error code in an invalid capability index.
No_init_type
Special value for uninitialized capability objects.
@ No_init
Special value for constructing uninitialized Cap 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.
bool is_equal(Cap_base const &other) const noexcept
Test whether this capability points to the same object with the same permissions as other.
C++ interface for capabilities.
bool move(Cap const &src) const noexcept
Replace this capability with the contents of src.
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...
bool is_equal(Cap const &other) const noexcept
Test whether this capability points to the same object with the same permissions as other.
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.
bool copy(Cap const &src) const noexcept
Copy a capability.
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.
Interface to a reply capability allocator.
virtual void free(Reply_cap_idx cap) noexcept=0
Free reply capability slot.
virtual Reply_cap alloc() noexcept=0
Allocate new reply capability slot.
Value class for a reply capability index.
An explicit reply capability.
l4_ret_t reply(l4_msgtag_t tag, l4_utcb_t *utcb=l4_utcb()) noexcept
Reply with this reply capability.
constexpr Reply_cap_idx get() const noexcept
Get reply capability index.
~Reply_cap()
Destroy reply capability.
void reset(Reply_cap_idx cap=Reply_cap_idx(), Reply_cap_alloc *alloc=nullptr) noexcept
Replace reply capability.
constexpr Reply_cap() noexcept=default
Construct an invalid reply capability.
C++ interface of the Task kernel object, see Task for the C interface.
#define L4_FPAGE_C_OBJ_RIGHTS
All Object-type specific right bits.
unsigned long l4_umword_t
Unsigned machine word.
unsigned long l4_cap_idx_t
Capability selector type.
#define L4_INVALID_CAP
Invalid capability selector; see l4_cap_idx_t.
l4_default_caps_t
Default capabilities setup for the initial tasks.
@ L4_BASE_TASK_CAP
Capability selector for the current task.
@ L4_EDROPREPLY
Server dropped reply capability.
L4_CONSTEXPR l4_fpage_t l4_obj_fpage(l4_cap_idx_t obj, unsigned int order, unsigned char rights) L4_NOTHROW
Create a kernel-object flexpage.
@ L4_CAP_FPAGE_RWSD
Full rights for capability flexpages.
@ L4_CAP_FPAGE_RWS
Read, interface specific 'W', and 'S' rights for capability flexpages.
l4_msgtag_t l4_ipc_reply(l4_cap_idx_t reply_cap, l4_utcb_t *utcb, l4_msgtag_t tag, l4_timeout_t timeout) L4_NOTHROW
Reply operation (uses a reply capability).
l4_ret_t l4_error(l4_msgtag_t tag) L4_NOTHROW
Get IPC error code if any or message tag label otherwise for an IPC call.
l4_umword_t l4_ipc_error(l4_msgtag_t tag, l4_utcb_t *utcb) L4_NOTHROW
Get the IPC error code for an IPC operation.
@ L4_IPC_ENOT_EXISTENT
Non-existing destination or source.
L4_CONSTEXPR l4_umword_t l4_map_obj_control(l4_umword_t spot, unsigned grant) L4_NOTHROW
Create the first word for a map item that is a send 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_msgtag(long label, unsigned words, unsigned items, unsigned flags) L4_NOTHROW
Create a message tag from the specified values.
l4_msgtag_t l4_task_cap_equal(l4_cap_idx_t task, l4_cap_idx_t cap_a, l4_cap_idx_t cap_b) L4_NOTHROW
Test whether two capabilities point to the same object with the same permissions (only considering se...
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.
#define L4_IPC_BOTH_TIMEOUT_0
0 receive and send timeout
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.
L4_CONSTEXPR l4_ret_t l4_ipc_to_errno(unsigned long ipc_error_code) L4_NOTHROW
Get a negative error code for the given IPC error code.
Common task related definitions.
Common L4 ABI Data Types.
l4_int16_t l4_ret_t
Return value of an IPC call as well as an RPC call.
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.
long label() const L4_NOTHROW
Get the protocol value.