22using L4::Types::False;
30constexpr unsigned long align_to(
unsigned long bytes,
unsigned long align)
noexcept
31{
return (bytes + align - 1) & ~(align - 1); }
40constexpr unsigned long align_to(
unsigned long bytes)
noexcept
41{
return align_to(bytes, __alignof(T)); }
53constexpr bool check_size(
unsigned offset,
unsigned limit)
noexcept
55 return offset +
sizeof(T) <= limit;
70template<
typename T,
typename CTYPE>
71inline bool check_size(
unsigned offset,
unsigned limit, CTYPE cnt)
noexcept
73 if (
L4_UNLIKELY(
sizeof(CTYPE) <=
sizeof(
unsigned) &&
74 ~0U /
sizeof(T) <=
static_cast<unsigned>(cnt)))
78 static_cast<CTYPE
>(~0U /
sizeof(T)) <= cnt))
81 return sizeof(T) * cnt <= limit - offset;
114inline int msg_add(
char *msg,
unsigned offs,
unsigned limit, T v)
noexcept
119 *
reinterpret_cast<L4::Types::Remove_const_t<T> *
>(msg + offs) = v;
120 return offs +
sizeof(T);
135inline int msg_get(
char *msg,
unsigned offs,
unsigned limit, T &v)
noexcept
140 v = *
reinterpret_cast<T *
>(msg + offs);
141 return offs +
sizeof(T);
171template<
typename T>
struct _Plain
174 static T deref(T v)
noexcept {
return v; }
177template<
typename T>
struct _Plain<T *>
180 static T &deref(T *v)
noexcept {
return *v; }
183template<
typename T>
struct _Plain<T &>
186 static T &deref(T &v)
noexcept {
return v; }
190template<
typename T>
struct _Plain<T const &>
193 static T
const &deref(T
const &v)
noexcept {
return v; }
196template<
typename T>
struct _Plain<T const *>
199 static T
const &deref(T
const *v)
noexcept {
return *v; }
210template<
typename MTYPE,
typename DIR,
typename CLASS>
struct Clnt_val_ops;
219template<
typename T>
struct Clnt_noops
221 template<
typename A,
typename B>
222 static constexpr int to_msg(
char *,
unsigned offset,
unsigned, T, A, B)
noexcept
226 template<
typename A,
typename B>
227 static constexpr int from_msg(
char *,
unsigned offset,
unsigned,
long, T
const &, A, B)
noexcept
238template<
typename T>
struct Svr_noops
240 template<
typename A,
typename B>
241 static constexpr int from_svr(
char *,
unsigned offset,
unsigned,
long, T, A, B)
noexcept
245 template<
typename A,
typename B>
246 static constexpr int to_svr(
char *,
unsigned offset,
unsigned, T
const &, A, B)
noexcept
252template<
typename MTYPE,
typename CLASS>
255 using Clnt_noops<MTYPE>::to_msg;
257 static int to_msg(
char *msg,
unsigned offset,
unsigned limit,
258 MTYPE arg, Dir_in, CLASS)
noexcept
264template<
typename MTYPE,
typename CLASS>
267 using Clnt_noops<MTYPE>::from_msg;
269 static int from_msg(
char *msg,
unsigned offset,
unsigned limit,
long,
270 MTYPE &arg, Dir_out, CLASS)
noexcept
281template<
typename MTYPE,
typename DIR,
typename CLASS>
struct Svr_val_ops;
285template<
typename MTYPE,
typename CLASS>
288 using Svr_noops<MTYPE>::to_svr;
290 static int to_svr(
char *msg,
unsigned offset,
unsigned limit,
291 MTYPE &arg,
Dir_in, CLASS)
noexcept
297template<
typename MTYPE,
typename CLASS>
298struct Svr_val_ops<MTYPE, Dir_out, CLASS> : Svr_noops<MTYPE>
301 using Svr_noops<MTYPE>::to_svr;
302 static int to_svr(
char *,
unsigned offs,
unsigned limit,
303 MTYPE &, Dir_out, CLASS)
noexcept
308 return offs +
sizeof(MTYPE);
311 using Svr_noops<MTYPE>::from_svr;
313 static int from_svr(
char *msg,
unsigned offset,
unsigned limit,
long,
314 MTYPE arg, Dir_out, CLASS)
noexcept
318template<
typename T>
struct Elem
325 using svr_arg_type = T;
327 enum { Is_optional =
false };
331template<
typename T>
struct Elem<T &>
333 using arg_type = T &;
336 using svr_arg_type = T &;
337 enum { Is_optional =
false };
340template<
typename T>
struct Elem<T const &>
342 using arg_type = T
const &;
346 using svr_arg_type = T
const &;
347 enum { Is_optional =
false };
350template<
typename T>
struct Elem<T *> : Elem<T &>
352 using arg_type = T *;
355template<
typename T>
struct Elem<T const *> : Elem<T const &>
357 using arg_type = T
const *;
366template<
typename T,
bool B>
struct Error_invalid_rpc_parameter_used;
367template<
typename T>
struct Error_invalid_rpc_parameter_used<T, true> {};
369#if __cplusplus >= 201103L
371struct _Elem : Elem<T>
373 static_assert(Is_valid_rpc_type<T>::value,
374 "L4::Ipc::Msg::_Elem<T>: type T is not a valid RPC parameter type.");
378struct _Elem : Elem<T>,
379 Error_invalid_rpc_parameter_used<T, Is_valid_rpc_type<T>::value>
384template<
typename T>
struct Class : Cls_data {};
385template<
typename T>
struct Direction :
Dir_in {};
386template<
typename T>
struct Direction<T const &> :
Dir_in {};
387template<
typename T>
struct Direction<T const *> :
Dir_in {};
388template<
typename T>
struct Direction<T &> :
Dir_out {};
389template<
typename T>
struct Direction<T *> :
Dir_out {};
391template<
typename T>
struct _Clnt_noops :
392 Clnt_noops<typename Detail::_Plain<typename _Elem<T>::arg_type>::type>
397template<
typename T,
typename DIR,
typename CLASS>
398struct _Clnt_val_ops :
399 Clnt_val_ops<typename Detail::_Plain<T>::type, DIR, CLASS> {};
402 typename ELEM = _Elem<T>,
403 typename CLNT_OPS = _Clnt_val_ops<
typename ELEM::arg_type,
404 typename Direction<T>::type,
405 typename Class<typename Detail::_Plain<T>::type>::type>
407struct _Clnt_xmit : CLNT_OPS {};
410 typename ELEM = _Elem<T>,
411 typename SVR_OPS = Svr_val_ops<
typename ELEM::svr_type,
412 typename Direction<T>::type,
413 typename Class<typename Detail::_Plain<T>::type>::type>
415struct _Svr_xmit : SVR_OPS {};
422template<
typename T>
struct Clnt_xmit : Detail::_Clnt_xmit<T> {};
426template<
typename T>
struct Svr_xmit : Detail::_Svr_xmit<T> {};
unsigned long l4_umword_t
Unsigned machine word.
@ L4_EMSGTOOLONG
Message too long.
@ L4_EMSGTOOSHORT
Message too short.
#define L4_UNLIKELY(x)
Expression is unlikely to execute.
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).
@ Br_bytes
number of bytes available in the UTCB buffer registers
@ Item_words
number of message words for one message item
@ Mr_bytes
number of bytes available in the UTCB message registers
@ Item_bytes
number of bytes for one message item
@ Word_bytes
number of bytes for one message word
@ Mr_words
number of message words available in the UTCB
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.
L4 low-level kernel interface.
Defines client-side handling of 'MTYPE' as RPC argument.
Marker type for receive buffer values.
Marker type for data values.
Marker type for item values.
Marker type for input values.
Marker type for output values.
Marker for receive buffers.
Type trait defining a valid RPC parameter type.
Defines server-side handling for MTYPE server arguments.