L4Re - L4 Runtime Environment
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 throw ()
 Return capability selector. More...
 
bool is_valid () const throw ()
 Test whether the capability is a valid capability index (i.e., not L4_INVALID_CAP). More...
 
l4_fpage_t fpage (unsigned rights=L4_FPAGE_RWX) const throw ()
 Return flex-page for the capability. More...
 
l4_umword_t snd_base (unsigned grant=0, l4_cap_idx_t base=L4_INVALID_CAP) const throw ()
 Return send base. More...
 
bool operator== (Cap_base const &o) const throw ()
 Test if two capabilities are equal.
 
bool operator!= (Cap_base const &o) const throw ()
 Test if two capabilities are not equal.
 
l4_msgtag_t validate (l4_utcb_t *u=l4_utcb()) const throw ()
 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 throw ()
 Check whether a capability is present (refers to an object). More...
 
void invalidate () throw ()
 Set this capability to invalid (L4_INVALID_CAP).
 

Protected Member Functions

 Cap_base (l4_cap_idx_t c) throw ()
 Generate a capability from its C representation. More...
 
 Cap_base (Cap_type cap) throw ()
 Constructor to create an invalid capability.
 
 Cap_base (l4_default_caps_t cap) throw ()
 Initialize capability with one of the default capabilities. More...
 
 Cap_base () throw ()
 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

l4_cap_idx_t _c
 The C representation of a capability selector. More...
 

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)
throw (
)
inlineexplicitprotected

Generate a capability from its C representation.

Parameters
cThe C capability

Definition at line 144 of file capability.h.

◆ Cap_base() [2/2]

L4::Cap_base::Cap_base ( l4_default_caps_t  cap)
throw (
)
inlineexplicitprotected

Initialize capability with one of the default capabilities.

Parameters
capCapability.

Definition at line 155 of file capability.h.

Member Function Documentation

◆ cap()

l4_cap_idx_t L4::Cap_base::cap ( ) const
throw (
)
inline

Return capability selector.

Returns
Capability selector.

Definition at line 52 of file capability.h.

Referenced by L4::cap_cast(), L4::cap_reinterpret_cast(), and L4::Cap< L4Re::Video::Goos >::operator->().

+ Here is the caller graph for this function:

◆ 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 187 of file capability.h.

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

Referenced by L4::Cap< L4Re::Video::Goos >::copy(), and L4::Cap< L4Re::Video::Goos >::operator->().

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

◆ fpage()

l4_fpage_t L4::Cap_base::fpage ( unsigned  rights = L4_FPAGE_RWX) const
throw (
)
inline

Return flex-page for the capability.

Parameters
rightsRights, defaults to 'rwx'
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
throw (
)
inline

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/libs/l4re/c++/mem_alloc/ma+rm.cc, and examples/libs/l4re/c++/shared_ds/ds_clnt.cc.

Definition at line 60 of file capability.h.

Referenced by L4Re::Rm::attach(), copy(), and move().

+ 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 referd to by the source capability src, and the source capability no longer refers to an object.

Definition at line 171 of file capability.h.

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

Referenced by L4::Cap< L4Re::Video::Goos >::move(), and L4::Cap< L4Re::Video::Goos >::operator->().

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

◆ snd_base()

l4_umword_t L4::Cap_base::snd_base ( unsigned  grant = 0,
l4_cap_idx_t  base = L4_INVALID_CAP 
) const
throw (
)
inline

Return send base.

Parameters
grantTrue object should be granted.
baseBase capability (first in a bundle of aligned capabilities)
Returns
Map object.

Definition at line 83 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 ( l4_utcb_t u = l4_utcb()) const
throw (
)
inline

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

Parameters
uUTCB to be used for this operation, usually the UTCB of the calling thread.
Return values
tag.label()> 0 Capability is present (refers to an object).
tag.label()== 0 No 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.

◆ validate() [2/2]

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

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

Parameters
taskTask to check the capability in.
uUTCB to be used for this operation, usually the UTCB of the calling thread.
Return values
tag.label()> 0 Capability is present (refers to an object).
tag.label()== 0 No 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.

Field Documentation

◆ _c

l4_cap_idx_t L4::Cap_base::_c
protected

The C representation of a capability selector.

Definition at line 198 of file capability.h.


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