46 operator T ()
const {
return v; }
47 operator T & () {
return v; }
52template<
typename A>
struct Elem<
In_out<A *> > : Elem<A *>
54 static constexpr bool Is_input =
true;
55 static constexpr bool Is_output =
true;
59struct Is_valid_rpc_type< In_out<A *> > : Is_valid_rpc_type<A *> {};
86 Opt() noexcept = default;
103 T *operator -> () noexcept {
return &this->_value; }
105 T
const *operator -> () const noexcept {
return &this->_value; }
107 T
const &
value() const noexcept {
return this->_value; }
109 T &
value() noexcept {
return this->_value; }
111 bool is_valid() const noexcept {
return this->_valid; }
116template<
typename T>
struct Elem< Opt<T &> > : Elem<T &>
118 static constexpr bool Is_optional =
true;
119 using svr_arg_type = Opt<typename Elem<T &>::svr_type> &;
120 using svr_type = Opt<typename Elem<T &>::svr_type>;
123template<
typename T>
struct Elem< Opt<T *> > : Elem<T *>
125 static constexpr bool Is_optional =
true;
126 using svr_arg_type = Opt<typename Elem<T *>::svr_type> &;
127 using svr_type = Opt<typename Elem<T *>::svr_type>;
130template<
typename T>
struct Elem< Opt<T> > :
Elem<T>
138 static constexpr bool Is_optional =
true;
139 using arg_type = Opt<T const *>;
151 using Native = Detail::_Clnt_val_ops<T>;
152 using Plain = Detail::_Plain<T>;
154 static int to_msg_data(
char *msg,
unsigned offset,
unsigned limit,
155 Opt<T>
const &arg)
noexcept
158 return Native::to_msg_data(msg, offset, limit, Plain::deref(arg.value()));
162 static int to_msg_items(
char *msg,
unsigned offset,
unsigned limit,
163 Opt<T>
const &arg)
noexcept
166 return Native::to_msg_items(msg, offset, limit,
167 Plain::deref(arg.value()));
183 using Native = Svr_val_ops<T>;
189 static int reserve_data(
char *msg,
unsigned offset,
unsigned limit,
190 Opt<T> &arg)
noexcept
192 return Native::reserve_data(msg, offset, limit, arg.value());
195 static int from_svr_data(
char *msg,
unsigned offset,
unsigned limit,
196 Opt<T>
const &arg)
noexcept
199 return Native::from_svr_data(msg, offset, limit, arg.value());
203 static int from_svr_items(
char *msg,
unsigned offset,
unsigned limit,
204 Opt<T>
const &arg)
noexcept
207 return Native::from_svr_items(msg, offset, limit, arg.value());
276 : _base(base), _data(
data)
364 cap.fpage(rights).raw)
379 unsigned char rights,
385 map_type,
None, cont);
401 unsigned char rights,
422 unsigned char rights,
433 unsigned order() const noexcept {
return (_data >> 6) & 0x3f; }
437 unsigned snd_order() const noexcept {
return (_data >> 6) & 0x3f; }
441 unsigned rcv_order() const noexcept {
return (_base >> 6) & 0x3f; }
488 bool id_received() const noexcept {
return (_base & 0x3e) == 0x3c; }
624 : Clnt_noops<L4::Ipc::Snd_fpage>
626 static int to_msg_items(
char *msg,
unsigned offset,
unsigned limit,
630 static int from_msg_items(
char *msg,
unsigned offset,
unsigned limit,
639 static int to_svr_items(
char *msg,
unsigned offset,
unsigned limit,
640 L4::Ipc::Snd_fpage &arg)
noexcept
643 static int from_svr_items(
char *msg,
unsigned offset,
unsigned limit,
644 L4::Ipc::Snd_fpage
const &arg)
noexcept
645 {
return msg_add(msg, offset, limit, arg); }
657 static int to_msg_buffers(
char *brs,
unsigned offs,
unsigned limit,
658 L4::Ipc::Rcv_fpage
const &arg)
noexcept
661 unsigned words = arg.forward_mappings() ? 3 : 2;
664 auto *buf =
reinterpret_cast<l4_umword_t*
>(brs + offs);
665 *buf++ = arg.base_x();
667 if (arg.forward_mappings())
668 *buf++ = arg.rcv_task();
675template<>
struct Elem<L4::Ipc::Rcv_fpage>
677 using arg_type = L4::Ipc::Rcv_fpage;
681 static constexpr bool Is_input =
false;
694 static int to_msg_buffers(
char *brs,
unsigned offs,
unsigned limit,
695 L4::Ipc::Small_buf
const &arg)
noexcept
700template<>
struct Elem<L4::Ipc::Small_buf>
702 using arg_type = L4::Ipc::Small_buf;
706 static constexpr bool Is_input =
false;
724template<
typename T>
class Cap
726 template<
typename O>
friend class Cap;
762 Cap(Cap<O>
const &o) noexcept : _cap_n_rights(o._cap_n_rights)
835 {
return !(_cap_n_rights & L4_INVALID_CAP_BIT); }
846{
return Cap<T>(cap, rights); }
907 Opt(Cap<T> value) noexcept : _value(value) {}
908 Opt(L4::Cap<T> value) noexcept : _value(value) {}
909 Opt &operator = (Cap<T> value)
noexcept
910 { this->_value = value;
return *
this; }
911 Opt &operator = (L4::Cap<T> value)
noexcept
912 { this->_value = value;
return *
this; }
914 Cap<T> value() const noexcept {
return this->_value; }
915 bool is_valid() const noexcept {
return this->_value.
is_valid(); }
924template<
typename A>
struct Elem< Cap<A> >
927 using svr_type = L4::Ipc::Snd_fpage;
930 static constexpr bool Is_input =
true;
939 static int from_svr_items(
char *msg,
unsigned offset,
unsigned limit,
940 Cap<A>
const &arg)
noexcept
944 return msg_add(msg, offset, limit, L4::Ipc::Snd_fpage(arg.cap(), 0));
946 return msg_add(msg, offset, limit, arg.fpage());
954 static int to_msg_items(
char *msg,
unsigned offset,
unsigned limit,
955 Cap<A>
const &arg)
noexcept
961 return msg_add(msg, offset, limit, arg.fpage());
966struct Elem<Out<L4::Cap<A> > >
972 static constexpr bool Is_input =
false;
980 static int to_msg_buffers(
char *brs,
unsigned offset,
unsigned limit,
981 L4::Cap<A>
const &arg)
noexcept
985 return msg_add(brs, offset, limit, Small_buf(arg));
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(L4::Cap< T > cap, unsigned char rights, Map_type map_type) noexcept
Make a Cap from L4::Cap<T> with the given rights and map type.
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.
#define L4_INVALID_CAP
Invalid capability selector; see l4_cap_idx_t.
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_CONSTEXPR l4_fpage_t l4_iofpage(unsigned long port, unsigned int order) L4_NOTHROW
Create an IO-port flexpage.
L4_CONSTEXPR l4_fpage_t l4_fpage(l4_addr_t address, unsigned int order, unsigned char rights) L4_NOTHROW
Create a memory flexpage.
L4_CONSTEXPR 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_CONSTEXPR 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_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.
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.
int msg_get(char *msg, unsigned offs, unsigned limit, T &v) noexcept
Get some data from 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_grant(L4::Cap< T > cap) noexcept
Make an L4::IPC::Cap<T> for the given capability that shall be granted with full 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.
Mark an argument as in-out argument.
Empty client side marshalling code.
static constexpr int from_msg_items(char *msg, unsigned offset, unsigned limit, MTYPE &arg) noexcept
static constexpr int to_msg_buffers(char *brs, unsigned offset, unsigned limit, MTYPE const &arg) noexcept
static constexpr int to_msg_items(char *msg, unsigned offset, unsigned limit, MTYPE const &arg) noexcept
Defines client-side handling of 'MTYPE' as RPC argument.
static int to_msg_data(char *msg, unsigned offset, unsigned limit, MTYPE const &arg) noexcept
Copy a T into the message (arg must be either MTYPE or MTYPE const &).
Helper struct to describe various aspects of an IPC argument.
T svr_type
The data type used to store the T on the server-side.
static constexpr bool Is_output
Is the argument transferred from server to client?
T arg_type
The type used in client argument list.
static constexpr bool Is_optional
Is it an optional argument?
static constexpr bool Is_input
Is the argument transferred from client to server?
T svr_arg_type
The argument type for the server-side function.
Type trait defining a valid RPC parameter type.
Empty server side marshalling code.
static constexpr int to_svr_items(char *msg, unsigned offset, unsigned limit, MTYPE &arg) noexcept
static constexpr int from_svr_items(char *msg, unsigned offset, unsigned limit, MTYPE const &arg) noexcept
Defines server-side handling of 'MTYPE' as RPC argument.
static int from_svr_data(char *msg, unsigned offset, unsigned limit, MTYPE const &arg) noexcept
Copy a T into the message (arg must be either MTYPE or MTYPE const &).
static int reserve_data(char *, unsigned offs, unsigned limit, MTYPE &) noexcept
Prepare a T output operand (arg must be MTYPE &).
T const & value() const noexcept
void set_valid(bool valid=true) noexcept
Set the argument to present or absent.
bool is_valid() const noexcept
Get true if present, false if not.
Opt() noexcept=default
Make an absent optional argument.
T & value() noexcept
Get the value.
Mark an argument as a output value in an RPC signature.