L4Re Operating System Framework – Interface and Usage Documentation
Loading...
Searching...
No Matches
L4::Cap_base Class Reference

Base class for all kinds of capabilities. More...

#include <l4/sys/capability>

+ Inheritance diagram for L4::Cap_base:
+ Collaboration diagram for L4::Cap_base:

Public Types

enum  No_init_type { No_init }
 Special value for uninitialized capability objects. More...
 
enum  Cap_type { Invalid = L4_INVALID_CAP }
 Invalid capability type. More...
 

Public Member Functions

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).
 
l4_fpage_t fpage (unsigned rights=L4_CAP_FPAGE_RWS) const noexcept
 Return flex-page for the capability.
 
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 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).
 
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).
 
void invalidate () noexcept
 Set this capability to invalid (L4_INVALID_CAP).
 

Protected Member Functions

 Cap_base (l4_cap_idx_t c) noexcept
 Generate a capability from its C representation.
 
 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.
 
 Cap_base () noexcept
 Create an uninitialized instance.
 
void move (Cap_base const &src) const
 Replace this capability with the contents of src.
 
void copy (Cap_base const &src) const
 Copy a capability.
 

Protected Attributes

l4_cap_idx_t _c
 The C representation of a capability selector.
 

Detailed Description

Base class for all kinds of capabilities.

Attention
This class is not for direct use, use L4::Cap instead.

This class contains all the things that are independent of the type of the object referred by the capability.

See also
L4::Cap for typed capabilities.

Definition at line 25 of file capability.h.

Member Enumeration Documentation

◆ Cap_type

Invalid capability type.

Enumerator
Invalid 

Invalid capability selector.

Definition at line 43 of file capability.h.

◆ No_init_type

Special value for uninitialized capability objects.

Enumerator
No_init 

Special value for constructing uninitialized Cap objects.

Definition at line 32 of file capability.h.

Constructor & Destructor Documentation

◆ Cap_base() [1/2]

L4::Cap_base::Cap_base ( l4_cap_idx_t  c)
inlineexplicitprotectednoexcept

Generate a capability from its C representation.

Parameters
cThe C capability

Definition at line 147 of file capability.h.

◆ Cap_base() [2/2]

L4::Cap_base::Cap_base ( l4_default_caps_t  cap)
inlineexplicitprotectednoexcept

Initialize capability with one of the default capabilities.

Parameters
capCapability.

Definition at line 158 of file capability.h.

Member Function Documentation

◆ cap()

◆ copy()

void L4::Cap_base::copy ( Cap_base const &  src) const
inlineprotected

Copy a capability.

Parameters
srcthe source capability.

After this operation this capability refers to the same object as src.

Definition at line 190 of file capability.h.

References fpage(), is_valid(), L4_BASE_TASK_CAP, L4_CAP_FPAGE_RWSD, L4_FPAGE_C_OBJ_RIGHTS, and l4_task_map().

+ Here is the call graph for this function:

◆ fpage()

l4_fpage_t L4::Cap_base::fpage ( unsigned  rights = L4_CAP_FPAGE_RWS) const
inlinenoexcept

Return flex-page for the capability.

Parameters
rightsRights, defaults to 'rws'
Returns
flex-page

Definition at line 72 of file capability.h.

References l4_obj_fpage().

Referenced by copy(), and move().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_valid()

bool L4::Cap_base::is_valid ( ) const
inlinenoexcept

Test whether the capability is a valid capability index (i.e., not L4_INVALID_CAP).

Returns
True if capability is not invalid, false if invalid
Examples
examples/clntsrv/client.cc, examples/libs/l4re/c++/mem_alloc/ma+rm.cc, examples/libs/l4re/c++/shared_ds/ds_clnt.cc, and examples/libs/l4re/streammap/client.cc.

Definition at line 60 of file capability.h.

Referenced by copy(), L4Re::Smart_count_cap< Unmap_flags >::copy(), L4Re::Util::Smart_cap_auto< Unmap_flags >::free(), L4Re::Util::Smart_cap_auto< Unmap_flags >::invalidate(), L4Re::Rm::Unique_region< T >::is_valid(), move(), L4Re::Rm::Unique_region< T >::operator=(), L4Re::Rm::Unique_region< T >::reset(), L4Re::Video::View::valid(), and L4Re::Rm::Unique_region< T >::~Unique_region().

+ Here is the caller graph for this function:

◆ move()

void L4::Cap_base::move ( Cap_base const &  src) const
inlineprotected

Replace this capability with the contents of src.

Parameters
srcthe source capability.

After the operation this capability refers to the object formerly referred to by the source capability src, and the source capability no longer refers to an object.

Definition at line 174 of file capability.h.

References fpage(), is_valid(), L4_BASE_TASK_CAP, L4_CAP_FPAGE_RWSD, L4_FPAGE_C_OBJ_RIGHTS, L4_MAP_ITEM_GRANT, and l4_task_map().

+ Here is the call graph for this function:

◆ snd_base()

l4_umword_t L4::Cap_base::snd_base ( unsigned  grant = L4_MAP_ITEM_MAP,
l4_cap_idx_t  base = L4_INVALID_CAP 
) const
inlinenoexcept

Return send base.

Parameters
grantIndicates if object shall be granted. Allowed values: L4_MAP_ITEM_MAP, L4_MAP_ITEM_GRANT.
baseBase capability (first in a bundle of aligned capabilities)
Returns
Map object.

Definition at line 84 of file capability.h.

References L4_INVALID_CAP, and l4_map_obj_control().

+ Here is the call graph for this function:

◆ validate() [1/2]

l4_msgtag_t L4::Cap_base::validate ( Cap< Task task,
l4_utcb_t u = l4_utcb() 
) const
inlinenoexcept

Check whether a capability is present (refers to an object).

Parameters
taskTask to check the capability in.
uUTCB to be used for this operation, shall be the UTCB of the calling thread. See l4_utcb.
Return values
l4_msgtag_t::label() > 0Capability is present (refers to an object).
l4_msgtag_t::label() == 0No capability present (void object or invalid capability slot).

A capability is considered present when it refers to an existing kernel object.

Definition at line 83 of file capability.

References l4_msgtag().

+ Here is the call graph for this function:

◆ validate() [2/2]

l4_msgtag_t L4::Cap_base::validate ( l4_utcb_t u = l4_utcb()) const
inlinenoexcept

Check whether a capability is present (refers to an object).

Parameters
uUTCB to be used for this operation, shall be the UTCB of the calling thread. See l4_utcb.
Return values
l4_msgtag_t::label() > 0Capability is present (refers to an object).
l4_msgtag_t::label() == 0No capability present (void object or invalid capability slot).

A capability is considered present when it refers to an existing kernel object.

Definition at line 90 of file capability.

References L4_BASE_TASK_CAP, and l4_msgtag().

+ Here is the call graph for this function:

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