L4Re – L4 Runtime Environment
L4::Cap< T > Class Template Reference

C++ interface for capabilities. More...

#include <capability.h>

+ Inheritance diagram for L4::Cap< T >:
+ Collaboration diagram for L4::Cap< T >:

Public Member Functions

template<typename O >
 Cap (Cap< O > const &o) noexcept
 Create a copy from o, supporting implicit type casting. More...
 
 Cap (Cap_type cap) noexcept
 Constructor to create an invalid capability selector. More...
 
 Cap (l4_default_caps_t cap) noexcept
 Initialize capability with one of the default capability selectors. More...
 
 Cap (l4_cap_idx_t idx=L4_INVALID_CAP) noexcept
 Initialize capability, defaults to the invalid capability selector. More...
 
 Cap (No_init_type) noexcept
 Create an uninitialized cap selector.
 
Cap move (Cap const &src) const
 Move a capability to this cap slot. More...
 
Cap copy (Cap const &src) const
 Copy a capability to this cap slot. More...
 
T * operator-> () const noexcept
 Member access of a T.
 
- Public Member Functions inherited from L4::Cap_base
l4_cap_idx_t cap () const noexcept
 Return capability selector. More...
 
bool is_valid () const noexcept
 Test whether the capability is a valid capability index (i.e., not L4_INVALID_CAP). More...
 
l4_fpage_t fpage (unsigned rights=L4_CAP_FPAGE_RWS) const noexcept
 Return flex-page for the capability. More...
 
l4_umword_t snd_base (unsigned grant=0, l4_cap_idx_t base=L4_INVALID_CAP) const noexcept
 Return send base. More...
 
bool operator== (Cap_base const &o) const noexcept
 Test if two capabilities are equal.
 
bool operator!= (Cap_base const &o) const noexcept
 Test if two capabilities are not equal.
 
l4_msgtag_t validate (l4_utcb_t *u=l4_utcb()) const noexcept
 Check whether a capability is present (refers to an object). More...
 
l4_msgtag_t validate (Cap< Task > task, l4_utcb_t *u=l4_utcb()) const noexcept
 Check whether a capability is present (refers to an object). More...
 
void invalidate () noexcept
 Set this capability to invalid (L4_INVALID_CAP).
 

Friends

class L4::Kobject
 

Additional Inherited Members

- Public Types inherited from L4::Cap_base
enum  No_init_type { No_init }
 Special value for uninitialized capability objects. More...
 
enum  Cap_type { Invalid = L4_INVALID_CAP }
 Invalid capability type. More...
 
- Protected Member Functions inherited from L4::Cap_base
 Cap_base (l4_cap_idx_t c) noexcept
 Generate a capability from its C representation. More...
 
 Cap_base (Cap_type cap) noexcept
 Constructor to create an invalid capability.
 
 Cap_base (l4_default_caps_t cap) noexcept
 Initialize capability with one of the default capabilities. More...
 
 Cap_base () noexcept
 Create an uninitialized instance.
 
void move (Cap_base const &src) const
 Replace this capability with the contents of src. More...
 
void copy (Cap_base const &src) const
 Copy a capability. More...
 
- Protected Attributes inherited from L4::Cap_base
l4_cap_idx_t _c
 The C representation of a capability selector.
 

Detailed Description

template<typename T>
class L4::Cap< T >

C++ interface for capabilities.

Template Parameters
TType of the object the capability points to.

The C++ version of a capability is comparable to a pointer, in fact it is a kind of smart pointer for our kernel objects and the objects derived from the kernel objects (L4::Kobject).

Add

#include <l4/sys/capability>

to your code to use the capability interface.

Examples
examples/clntsrv/client.cc, examples/libs/l4re/c++/shared_ds/ds_clnt.cc, and examples/libs/l4re/streammap/client.cc.

Definition at line 218 of file capability.h.

Constructor & Destructor Documentation

◆ Cap() [1/4]

template<typename T >
template<typename O >
L4::Cap< T >::Cap ( Cap< O > const &  o)
inlinenoexcept

Create a copy from o, supporting implicit type casting.

Parameters
oThe source selector that shall be copied (and casted).

Definition at line 244 of file capability.h.

◆ Cap() [2/4]

template<typename T >
L4::Cap< T >::Cap ( Cap_type  cap)
inlinenoexcept

Constructor to create an invalid capability selector.

Parameters
capCapability selector.

Definition at line 251 of file capability.h.

◆ Cap() [3/4]

template<typename T >
L4::Cap< T >::Cap ( l4_default_caps_t  cap)
inlinenoexcept

Initialize capability with one of the default capability selectors.

Parameters
capCapability selector.

Definition at line 257 of file capability.h.

◆ Cap() [4/4]

template<typename T >
L4::Cap< T >::Cap ( l4_cap_idx_t  idx = L4_INVALID_CAP)
inlineexplicitnoexcept

Initialize capability, defaults to the invalid capability selector.

Parameters
idxCapability selector.

Definition at line 263 of file capability.h.

Member Function Documentation

◆ copy()

template<typename T >
Cap L4::Cap< T >::copy ( Cap< T > const &  src) const
inline

Copy a capability to this cap slot.

Parameters
srcthe source capability slot.

Definition at line 286 of file capability.h.

References L4::Cap_base::copy().

+ Here is the call graph for this function:

◆ move()

template<typename T >
Cap L4::Cap< T >::move ( Cap< T > const &  src) const
inline

Move a capability to this cap slot.

Parameters
srcthe source capability slot.

After this operation the source slot is no longer valid.

Definition at line 276 of file capability.h.

References L4::Cap_base::move().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: