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;
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;
118 typedef T value_type;
120 As_value()
noexcept {}
121 As_value(T v) noexcept : v(v) {}
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 *> {};
150 this->_value =
value;
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>
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,
l4_ret_t 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>
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 {};
643 : Clnt_noops<L4::Ipc::Rcv_fpage>
645 using Clnt_noops<L4::Ipc::Rcv_fpage>::to_msg;
647 static int to_msg(
char *msg,
unsigned offs,
unsigned limit,
648 L4::Ipc::Rcv_fpage arg, Dir_in, Cls_buffer)
noexcept
651 unsigned words = arg.forward_mappings() ? 3 : 2;
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>
667 typedef L4::Ipc::Rcv_fpage arg_type;
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>
679 typedef L4::Ipc::Small_buf arg_type;
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)
775 {
return !(_cap_n_rights & L4_INVALID_CAP_BIT); }
786{
return Cap<T>(cap, rights); }
832 Opt(Cap<T> value) noexcept : _value(value) {}
833 Opt(L4::Cap<T> value) noexcept : _value(value) {}
834 Opt &operator = (Cap<T> value)
noexcept
835 { this->_value = value;
return *
this; }
836 Opt &operator = (L4::Cap<T> value)
noexcept
837 { this->_value = value;
return *
this; }
839 Cap<T> value() const noexcept {
return this->_value; }
840 bool is_valid() const noexcept {
return this->_value.
is_valid(); }
849template<
typename A>
struct Class< Cap<A> > :
Cls_item {};
850template<
typename A>
struct Elem< Cap<A> >
852 enum { Is_optional =
false };
853 typedef Cap<A> arg_type;
854 typedef L4::Ipc::Snd_fpage svr_type;
855 typedef L4::Ipc::Snd_fpage svr_arg_type;
859template<
typename A,
typename CLASS>
864template<
typename A,
typename CLASS>
868 using Clnt_noops< Cap<A> >::to_msg;
870 static int to_msg(
char *msg,
unsigned offset,
unsigned limit,
871 Cap<A> arg, Dir_in, Cls_item)
noexcept
880 return msg_add(msg, offset, limit, arg.fpage());
885struct Elem<Out<L4::Cap<A> > >
887 enum { Is_optional =
false };
888 typedef L4::Cap<A> arg_type;
889 typedef Ipc::Cap<A> svr_type;
890 typedef svr_type &svr_arg_type;
893template<
typename A>
struct Direction< Out< L4::Cap<A> > > :
Dir_out {};
894template<
typename A>
struct Class< Out< L4::Cap<A> > > :
Cls_item {};
898 Clnt_noops< L4::Cap<A> >
900 using Clnt_noops< L4::Cap<A> >::to_msg;
901 static int to_msg(
char *msg,
unsigned offset,
unsigned limit,
902 L4::Cap<A> arg, Dir_in, Cls_buffer)
noexcept
906 return msg_add(msg, offset, limit, Small_buf(arg));
914 using Svr_noops<Cap<A> &>::from_svr;
915 static int from_svr(
char *msg,
unsigned offset,
unsigned limit,
long,
916 Cap<A> arg, Dir_out, Cls_item)
noexcept
920 return msg_add(msg, offset, limit, L4::Ipc::Snd_fpage(arg.cap(), 0));
922 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).
@ Invalid
Invalid capability selector.
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).
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< A > cap() const noexcept
unsigned rights() const noexcept
bool is_valid() const noexcept
Return true if this Cap is valid.
Cap(Cap< O > const &o) noexcept
Make copy with conversion.
l4_umword_t base_x() const noexcept
Return the raw base descriptor.
Type
Type of mapping object, see L4_fpage_type.
@ Io
Flexpage for I/O port spaces.
@ Special
Special flexpage, either l4_fpage_invalid() or l4_fpage_all(); only supported by selected interfaces.
@ Memory
Flexpage for memory spaces.
@ Obj
Flexpage for object spaces.
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.
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 mappin...
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 ite...
#define L4_FPAGE_C_OBJ_RIGHTS
All Object-type specific right bits.
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.
#define L4_CAP_MASK
Mask to get only the relevant bits of an l4_cap_idx_t.
@ 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...
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.
#define L4_INVALID_CAP
Invalid capability selector.
l4_int16_t l4_ret_t
Return value of an IPC call as well as an RPC call.
IPC Message related functionality.
constexpr bool check_size(unsigned offset, unsigned limit) noexcept
Check if there is enough space for T from offset to limit.
constexpr unsigned long align_to(unsigned long bytes, unsigned long align) noexcept
Pad bytes to the given alignment align (in bytes).
int msg_add(char *msg, unsigned offs, unsigned limit, T v) noexcept
Add some data to a message at offs.
IPC related functionality.
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.
Defines client-side handling of 'MTYPE' as RPC argument.
Marker type for receive buffer values.
Marker type for item values.
Marker type for input values.
Marker type for output values.
Type trait defining a valid RPC parameter type.
Defines server-side handling for MTYPE server arguments.
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.
Opt() noexcept
Make an absent optional argument.
T & value() noexcept
Get the value.
Mark an argument as a output value in an RPC signature.