46 operator T ()
const {
return v; }
47 operator T & () {
return v; }
51template<
typename A>
struct Elem<
In_out<A *> > : Elem<A *> {};
54struct Svr_xmit< In_out<A *> > : Svr_xmit<A *>, Svr_xmit<A const *>
56 using Svr_xmit<A *>::from_svr;
57 using Svr_xmit<A
const *>::to_svr;
61struct Clnt_xmit< In_out<A *> > : Clnt_xmit<A *>, Clnt_xmit<A const *>
63 using Clnt_xmit<A *>::from_msg;
64 using Clnt_xmit<A
const *>::to_msg;
68struct Is_valid_rpc_type< In_out<A *> > : Is_valid_rpc_type<A *> {};
72#ifdef CONFIG_ALLOW_REFS
73template<
typename A>
struct Elem< In_out<A &> > : Elem<A &> {};
76struct Svr_xmit< In_out<A &> > : Svr_xmit<A &>, Svr_xmit<A const &>
78 using Svr_xmit<A &>::from_svr;
79 using Svr_xmit<A
const &>::to_svr;
83struct Clnt_xmit< In_out<A &> > : Clnt_xmit<A &>, Clnt_xmit<A const &>
85 using Clnt_xmit<A &>::from_msg;
86 using Clnt_xmit<A
const &>::to_msg;
90struct Is_valid_rpc_type< In_out<A &> > : Is_valid_rpc_type<A &> {};
118 typedef T value_type;
122 operator T ()
const noexcept {
return v; }
123 operator T & ()
noexcept {
return v; }
127template<
typename T>
struct Class<
As_value<T> > : Cls_data {};
128template<
typename T>
struct Elem< As_value<T> > : Elem<T> {};
129template<
typename T>
struct Elem< As_value<T> *> : Elem<T *> {};
142 Opt() noexcept : _valid(false) {}
145 Opt(T value) noexcept : _value(value), _valid(
true) {}
148 Opt &operator = (T value)
noexcept
150 this->_value = value;
148 Opt &operator = (T value)
noexcept {
…}
156 void set_valid(
bool valid =
true) noexcept { _valid = valid; }
159 T *operator -> () noexcept {
return &this->_value; }
161 T
const *operator -> () const noexcept {
return &this->_value; }
163 T
value() const noexcept {
return this->_value; }
165 T &
value() noexcept {
return this->_value; }
167 bool is_valid() const noexcept {
return this->_valid; }
171template<
typename T>
struct Elem< Opt<T &> > : Elem<T &>
173 enum { Is_optional =
true };
174 typedef Opt<typename Elem<T &>::svr_type> &svr_arg_type;
175 typedef Opt<typename Elem<T &>::svr_type> svr_type;
178template<
typename T>
struct Elem< Opt<T *> > : Elem<T *>
180 enum { Is_optional =
true };
181 typedef Opt<typename Elem<T *>::svr_type> &svr_arg_type;
182 typedef Opt<typename Elem<T *>::svr_type> svr_type;
187template<
typename T,
typename CLASS>
188struct Svr_val_ops<Opt<T>, Dir_out, CLASS> : Svr_noops< Opt<T> >
190 typedef Opt<T> svr_type;
191 typedef Svr_val_ops<T, Dir_out, CLASS> Native;
193 using Svr_noops< Opt<T> >::to_svr;
194 static int to_svr(
char *msg,
unsigned offset,
unsigned limit,
195 Opt<T> &arg, Dir_out, CLASS)
noexcept
197 return Native::to_svr(msg, offset, limit, arg.value(), Dir_out(), CLASS());
200 using Svr_noops< Opt<T> >::from_svr;
201 static int from_svr(
char *msg,
unsigned offset,
unsigned limit,
long ret,
202 svr_type &arg, Dir_out, CLASS)
noexcept
205 return Native::from_svr(msg, offset, limit, ret, arg.value(),
211template<
typename T>
struct Elem< Opt<T> > : Elem<T>
213 enum { Is_optional =
true };
214 typedef Opt<T> arg_type;
217template<
typename T>
struct Elem< Opt<T const *> > : Elem<T const *>
219 enum { Is_optional =
true };
220 typedef Opt<T const *> arg_type;
226template<
typename T,
typename CLASS>
227struct Clnt_val_ops<Opt<T>, Dir_in, CLASS> : Clnt_noops< Opt<T> >
229 typedef Opt<T> arg_type;
230 typedef Detail::_Clnt_val_ops<typename Elem<T>::arg_type, Dir_in, CLASS> Native;
232 using Clnt_noops< Opt<T> >::to_msg;
233 static int to_msg(
char *msg,
unsigned offset,
unsigned limit,
234 arg_type arg, Dir_in, CLASS)
noexcept
237 return Native::to_msg(msg, offset, limit,
238 Detail::_Plain<T>::deref(arg.value()),
244template<
typename T>
struct Class< Opt<T> > :
245 Class< typename Detail::_Plain<T>::type > {};
246template<
typename T>
struct Direction< Opt<T> > : Direction<T> {};
300 : _base(base), _data(data)
388 cap.fpage(rights).raw)
403 unsigned char rights,
409 map_type,
None, cont);
425 unsigned char rights,
446 unsigned char rights,
457 unsigned order() const noexcept {
return (_data >> 6) & 0x3f; }
461 unsigned snd_order() const noexcept {
return (_data >> 6) & 0x3f; }
465 unsigned rcv_order() const noexcept {
return (_base >> 6) & 0x3f; }
512 bool id_received() const noexcept {
return (_base & 0x3e) == 0x3c; }
639template<>
struct Class<
L4::Ipc::Rcv_fpage> : Cls_buffer {};
642struct Clnt_val_ops<
L4::Ipc::Rcv_fpage, Dir_in, Cls_buffer>
643 : Clnt_noops<L4::Ipc::Rcv_fpage>
647 static int to_msg(
char *msg,
unsigned offs,
unsigned limit,
650 offs = align_to<l4_umword_t>(offs);
651 unsigned words = arg.forward_mappings() ? 3 : 2;
652 if (
L4_UNLIKELY(!check_size<l4_umword_t>(offs, limit, words)))
654 auto *buf =
reinterpret_cast<l4_umword_t*
>(msg + offs);
655 *buf++ = arg.base_x();
657 if (arg.forward_mappings())
658 *buf++ = arg.rcv_task();
665template<>
struct Elem<
L4::Ipc::Rcv_fpage>
668 typedef void svr_type;
669 typedef void svr_arg_type;
670 enum { Is_optional =
false };
674template<>
struct Class<
L4::Ipc::Small_buf> : Cls_buffer {};
677template<>
struct Elem<
L4::Ipc::Small_buf>
680 typedef void svr_type;
681 typedef void svr_arg_type;
682 enum { Is_optional =
false };
698template<
typename T>
class Cap
700 template<
typename O>
friend class Cap;
722 Cap(
Cap<O> const &o) noexcept : _cap_n_rights(o._cap_n_rights)
722 Cap(
Cap<O> const &o) noexcept : _cap_n_rights(o._cap_n_rights) {
…}
775 {
return !(_cap_n_rights & L4_INVALID_CAP_BIT); }
698template<
typename T>
class Cap {
…};
786{
return Cap<T>(cap, rights); }
831 Opt(Cap<T> value) noexcept : _value(value) {}
832 Opt(
L4::Cap<T> value) noexcept : _value(value) {}
833 Opt &operator = (Cap<T> value)
noexcept
834 { this->_value = value;
return *
this; }
836 { this->_value = value;
return *
this; }
838 Cap<T> value() const noexcept {
return this->_value; }
839 bool is_valid() const noexcept {
return this->_value.
is_valid(); }
848template<
typename A>
struct Class< Cap<A> > : Cls_item {};
849template<
typename A>
struct Elem< Cap<A> >
851 enum { Is_optional =
false };
852 typedef Cap<A> arg_type;
858template<
typename A,
typename CLASS>
859struct Svr_val_ops<Cap<A>, Dir_in, CLASS> :
860 Svr_val_ops<L4::Ipc::Snd_fpage, Dir_in, CLASS>
863template<
typename A,
typename CLASS>
864struct Clnt_val_ops<Cap<A>, Dir_in, CLASS> :
867 using Clnt_noops< Cap<A> >::to_msg;
869 static int to_msg(
char *msg,
unsigned offset,
unsigned limit,
870 Cap<A> arg, Dir_in, Cls_item)
noexcept
879 return msg_add(msg, offset, limit, arg.fpage());
884struct Elem<Out<
L4::Cap<A> > >
886 enum { Is_optional =
false };
888 typedef Ipc::Cap<A> svr_type;
889 typedef svr_type &svr_arg_type;
892template<
typename A>
struct Direction< Out<
L4::Cap<A> > > : Dir_out {};
893template<
typename A>
struct Class< Out<
L4::Cap<A> > > : Cls_item {};
896struct Clnt_val_ops<
L4::Cap<A>, Dir_out, Cls_item > :
897 Clnt_noops< L4::Cap<A> >
900 static int to_msg(
char *msg,
unsigned offset,
unsigned limit,
905 return msg_add(msg, offset, limit, Small_buf(arg));
910struct Svr_val_ops<
L4::Ipc::Cap<A>, Dir_out, Cls_item > :
913 using Svr_noops<Cap<A> &>::from_svr;
914 static int from_svr(
char *msg,
unsigned offset,
unsigned limit,
long,
915 Cap<A> arg, Dir_out, Cls_item)
noexcept
921 return msg_add(msg, offset, limit, arg.fpage());
bool is_valid() const noexcept
Test whether the capability is a valid capability index (i.e., not L4_INVALID_CAP).
C++ interface for capabilities.
Capability type for RPC interfaces (see L4::Cap<T>).
Cap(L4::Cap< T > cap) noexcept
Make a Cap from L4::Cap<T>, with minimal rights.
Cap(L4::Cap< T > cap, unsigned char rights) noexcept
Make a Cap from L4::Cap<T> with the given rights.
static Cap from_ci(l4_cap_idx_t c) noexcept
Create an IPC capability from a C capability index plus rights.
L4::Ipc::Snd_fpage fpage() const noexcept
Return the send flexpage for this Cap (see l4_fpage_t)
@ Rights_mask
Mask for rights bits stored internally.
@ Cap_mask
Mask for significant capability bits.
Cap(L4::Cap< O > cap) noexcept
Make IPC Cap from L4::Cap with conversion (and minimal rights).
Cap() noexcept
Make an invalid cap.
L4::Cap< T > cap() const noexcept
Return the L4::Cap<T> of this Cap.
unsigned rights() const noexcept
Return the rights bits stored in this IPC cap.
bool is_valid() const noexcept
Return true if this Cap is valid.
Cap(Cap< O > const &o) noexcept
Make copy with conversion.
Generic RPC base for typed message items.
l4_umword_t base_x() const noexcept
Return the raw base descriptor.
Type
Type of mapping object, see L4_fpage_type.
Gen_fpage(l4_umword_t base, l4_umword_t data) noexcept
Construct from raw values.
l4_umword_t data() const noexcept
Return the raw flexpage descriptor.
static Rcv_fpage obj(l4_cap_idx_t base, int order, l4_addr_t snd_base=0, L4::Cap< void > rcv_task=L4::Cap< void >::Invalid) noexcept
Construct a non-small receive item for the object space.
static Rcv_fpage mem(l4_addr_t base, int order, l4_addr_t snd_base=0, L4::Cap< void > rcv_task=L4::Cap< void >::Invalid) noexcept
Construct a receive item for the memory space.
static Rcv_fpage io(unsigned long base, int order, l4_addr_t snd_base=0, L4::Cap< void > rcv_task=L4::Cap< void >::Invalid) noexcept
Construct a receive item for the I/O port space.
Rcv_fpage(l4_fpage_t const &fp, l4_addr_t snd_base=0, l4_cap_idx_t rcv_task=L4_INVALID_CAP) noexcept
Construct a non-small receive item.
bool forward_mappings() const noexcept
Check if rcv_task() shall be used as destination for received capabilities.
l4_cap_idx_t rcv_task() const
Get the capability index of the destination task for received capabilities.
Rcv_fpage() noexcept
Construct a void receive item.
A receive item for receiving a single object capability.
Small_buf(l4_cap_idx_t cap, unsigned long flags=0) noexcept
Create a receive item from a C cap.
l4_umword_t raw() const noexcept
Return the raw data.
Small_buf(L4::Cap< void > cap, unsigned long flags=0) noexcept
Create a receive item from a C++ cap.
Send item or return item.
bool id_received() const noexcept
*(Defined for return items only.)* Check if an IPC gate label has been received instead of a mapping.
unsigned snd_order() const noexcept
*(Defined only if send item or if local_id_received() is true.)* Get log₂ size.
Snd_fpage(L4::Cap< void > cap, unsigned rights, Map_type map_type=Map) noexcept
Construct a send item for the object space.
Snd_fpage(l4_fpage_t const &fp, l4_addr_t snd_base=0, Map_type map_type=Map, Cacheopt cache=None, Continue cont=Last) noexcept
Construct a send item for the memory space.
bool local_id_received() const noexcept
*(Defined for return items only.)* Check if a raw object flexpage has been received instead of a mapp...
Map_type
*(Defined for send items only.)* Kind of mapping.
@ Map
Flag as usual map operation.
@ Grant
Flag as grant instead of map operation.
bool is_compound() const noexcept
Check if the item has the compound bit set, see Continue.
unsigned rcv_order() const noexcept
*(Defined for return items only.)* Get log₂ size.
bool is_valid() const noexcept
Check if the capability is valid.
l4_addr_t base() const noexcept
*(Defined only if send item or if local_id_received() is true.)* Get the start of the item (i....
Cacheopt
*(Defined for memory send items only.)* Caching options, see l4_fpage_cacheability_opt_t.
@ Buffered
Cacheability option to enable buffered writes for the mapping.
@ Cached
Cacheability option to enable caches for the mapping.
@ None
Copy options from sender.
@ Uncached
Cacheability option to disable caching for the mapping.
Snd_fpage(l4_umword_t base=0, l4_umword_t data=0) noexcept
Construct from raw values.
l4_addr_t snd_base() const noexcept
Get the position in receive window for the case that this item has a different size than the correspo...
static Snd_fpage obj(l4_cap_idx_t base, int order, unsigned char rights, l4_addr_t snd_base=0, Map_type map_type=Map, Continue cont=Last) noexcept
Construct a send item for the object space.
unsigned order() const noexcept
*(Defined only if send item or if local_id_received() is true.)* Get log₂ size.
static Snd_fpage io(unsigned long base, int order, unsigned char rights, l4_addr_t snd_base=0, Map_type map_type=Map, Continue cont=Last) noexcept
Construct a send item for the I/O port space.
void snd_base(l4_addr_t b) noexcept
Set the position in receive window for the case that this item has a different size than the correspo...
Continue
Specify if the following item is associated with the same receive item as this one,...
@ More
Alias for Compound.
@ Single
Inverse of Compound.
@ Compound
Denote that the following item shall be put into the same receive item as this one.
static Snd_fpage mem(l4_addr_t base, int order, unsigned char rights, l4_addr_t snd_base=0, Map_type map_type=Map, Cacheopt cache=None, Continue cont=Last) noexcept
Construct a send item for the memory space.
bool cap_received() const noexcept
*(Defined for return items only.)* Check if at least one object capability has been mapped for this i...
unsigned long l4_umword_t
Unsigned machine word.
unsigned long l4_addr_t
Address type.
unsigned long l4_cap_idx_t
Capability selector type.
unsigned l4_is_valid_cap(l4_cap_idx_t c) L4_NOTHROW
Test if a capability selector is a valid selector.
@ L4_CAP_MASK
Mask to get only the relevant bits of an l4_cap_idx_t.
@ L4_INVALID_CAP
Invalid capability selector.
@ L4_EMSGMISSARG
Message has invalid capability.
@ L4_EMSGTOOLONG
Message too long.
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_fpage_t l4_fpage_set_rights(l4_fpage_t src, unsigned char new_rights) L4_NOTHROW
Set new right in a flexpage.
l4_fpage_t l4_fpage(l4_addr_t address, unsigned int order, unsigned char rights) L4_NOTHROW
Create a memory flexpage.
l4_fpage_t l4_iofpage(unsigned long port, unsigned int order) L4_NOTHROW
Create an IO-port flexpage.
@ L4_FPAGE_MEMORY
Flexpage for memory spaces.
@ L4_FPAGE_IO
Flexpage for I/O port spaces.
@ L4_FPAGE_OBJ
Flexpage for object spaces.
@ L4_FPAGE_SPECIAL
Special flexpage, either l4_fpage_invalid() or l4_fpage_all(); only supported by selected interfaces.
@ L4_CAP_FPAGE_R
Read right for capability flexpages.
@ L4_CAP_FPAGE_RW
Read and interface specific 'W' right for capability flexpages.
@ L4_CAP_FPAGE_RWSD
Full rights for capability flexpages.
@ L4_CAP_FPAGE_RWS
Read, interface specific 'W', and 'S' rights for capability flexpages.
@ L4_FPAGE_CACHEABLE
Cacheability option to enable caches for the mapping.
@ L4_FPAGE_UNCACHEABLE
Cacheability option to disable caching for the mapping.
@ L4_FPAGE_BUFFERABLE
Cacheability option to enable buffered writes for the mapping.
@ L4_MAP_ITEM_GRANT
Flag as grant instead of map operation.
@ L4_RCV_ITEM_FORWARD_MAPPINGS
This flag specifies if received capabilities shall be mapped to a particular task instead of the invo...
@ L4_ITEM_MAP
Identify a message item as map item.
@ L4_ITEM_CONT
Denote that the following item shall be put into the same receive item as this one.
@ L4_MAP_ITEM_MAP
Flag as usual map operation.
@ L4_RCV_ITEM_SINGLE_CAP
Mark the receive buffer to be a small receive item that describes a buffer for a single object capabi...
@ L4_FPAGE_C_OBJ_RIGHTS
All Object-type specific right bits.
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
#define L4_UNLIKELY(x)
Expression is unlikely to execute.
#define L4_EXPORT
Attribute to mark functions, variables, and data types as being exported from a library.
int msg_add(char *msg, unsigned offs, unsigned limit, T v) noexcept
Add some data to a message at offs.
Cap< T > make_cap(L4::Cap< T > cap, unsigned rights) noexcept
Make an L4::Ipc::Cap<T> for the given capability and rights.
Cap< T > make_cap_full(L4::Cap< T > cap) noexcept
Make an L4::IPC::Cap<T> for the given capability with full fpage and object-specific rights.
Cap< T > make_cap_rw(L4::Cap< T > cap) noexcept
Make an L4::Ipc::Cap<T> for the given capability with L4_CAP_FPAGE_RW rights.
Cap< T > make_cap_rws(L4::Cap< T > cap) noexcept
Make an L4::Ipc::Cap<T> for the given capability with L4_CAP_FPAGE_RWS rights.
L4 low-level kernel interface.
int Opcode
Data type for RPC opcodes.
Pass the argument as plain data value.
Mark an argument as in-out argument.
Attribute for defining an optional RPC argument.
void set_valid(bool valid=true) noexcept
Set the argument to present or absent.
Opt(T value) noexcept
Make a present optional argument with the given value.
bool is_valid() const noexcept
Get true if present, false if not.
T value() const noexcept
Get the value.
Opt() noexcept
Make an absent optional argument.
T & value() noexcept
Get the value.
bool _valid
True if the optional argument is present, false else.
Mark an argument as a output value in an RPC signature.