L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
ipc.h
Go to the documentation of this file.
1
6/*
7 * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
8 * Alexander Warg <warg@os.inf.tu-dresden.de>,
9 * Björn Döbel <doebel@os.inf.tu-dresden.de>,
10 * Torsten Frenzel <frenzel@os.inf.tu-dresden.de>
11 * economic rights: Technische Universität Dresden (Germany)
12 *
13 * This file is part of TUD:OS and distributed under the terms of the
14 * GNU General Public License 2.
15 * Please see the COPYING-GPL-2 file for details.
16 *
17 * As a special exception, you may use this file as part of a free software
18 * library without restriction. Specifically, if other files instantiate
19 * templates or use macros or inline functions from this file, or you compile
20 * this file and link it with other files to produce an executable, this
21 * file does not by itself cause the resulting executable to be covered by
22 * the GNU General Public License. This exception does not however
23 * invalidate any other reasons why the executable file might be covered by
24 * the GNU General Public License.
25 */
26#ifndef __L4SYS__INCLUDE__L4API_FIASCO__IPC_H__
27#define __L4SYS__INCLUDE__L4API_FIASCO__IPC_H__
28
29#include <l4/sys/types.h>
30#include <l4/sys/utcb.h>
31#include <l4/sys/err.h>
32
73/*****************************************************************************
74 *** IPC result checking
75 *****************************************************************************/
76
93{
100 L4_IPC_RETIMEOUT = 0x03,
103 L4_IPC_SETIMEOUT = 0x02,
106 L4_IPC_RECANCELED = 0x07,
109 L4_IPC_SECANCELED = 0x06,
112 L4_IPC_REMAPFAILED = 0x11,
116 L4_IPC_SEMAPFAILED = 0x10,
119 L4_IPC_RESNDPFTO = 0x0b,
123 L4_IPC_SESNDPFTO = 0x0a,
127 L4_IPC_RERCVPFTO = 0x0d,
131 L4_IPC_SERCVPFTO = 0x0c,
135 L4_IPC_REABORTED = 0x0f,
138 L4_IPC_SEABORTED = 0x0e,
148
155};
156
157
170
171
188L4_INLINE long
190
191L4_INLINE long
192l4_error_u(l4_msgtag_t tag, l4_utcb_t *utcb) L4_NOTHROW;
193
194/*****************************************************************************
195 *** IPC results
196 *****************************************************************************/
197
208
219
230
237L4_INLINE long l4_ipc_to_errno(unsigned long ipc_error_code) L4_NOTHROW;
238
239
240/*****************************************************************************
241 *** IPC calls
242 *****************************************************************************/
243
274 l4_timeout_t timeout) L4_NOTHROW;
275
276
304l4_ipc_wait(l4_utcb_t *utcb, l4_umword_t *label,
305 l4_timeout_t timeout) L4_NOTHROW;
306
307
334 l4_timeout_t timeout) L4_NOTHROW;
335
368 l4_timeout_t timeout) L4_NOTHROW;
369
370
398 l4_umword_t *label, l4_timeout_t timeout) L4_NOTHROW;
399
430 l4_umword_t *label, l4_timeout_t timeout) L4_NOTHROW;
431
438#if 0
450l4_ipc_wait_next_period(l4_utcb_t *utcb,
451 l4_umword_t *label,
452 l4_timeout_t timeout);
453
454#endif
455
477 l4_utcb_t *utcb,
478 l4_umword_t flags,
479 l4_umword_t slabel,
480 l4_msgtag_t tag,
481 l4_umword_t *rlabel,
482 l4_timeout_t timeout) L4_NOTHROW;
483
502
521
540
555L4_INLINE int
556l4_sndfpage_add(l4_fpage_t const snd_fpage, unsigned long snd_base,
558
559/*
560 * \internal
561 * \ingroup l4_ipc_api
562 */
563L4_INLINE int
564l4_sndfpage_add_u(l4_fpage_t const snd_fpage, unsigned long snd_base,
565 l4_msgtag_t *tag, l4_utcb_t *utcb) L4_NOTHROW;
566
567
568/************************************************************************
569 * Implementations
570 **********************/
571
572L4_INLINE long l4_ipc_to_errno(unsigned long ipc_error_code) L4_NOTHROW
573{ return -(L4_EIPC_LO + ipc_error_code); }
574
577 l4_timeout_t timeout) L4_NOTHROW
578{
579 return l4_ipc(object, utcb, L4_SYSF_CALL, 0, tag, 0, timeout);
580}
581
584 l4_umword_t *label, l4_timeout_t timeout) L4_NOTHROW
585{
586 return l4_ipc(L4_INVALID_CAP, utcb, L4_SYSF_REPLY_AND_WAIT, 0, tag, label, timeout);
587}
588
591 l4_umword_t *label, l4_timeout_t timeout) L4_NOTHROW
592{
593 return l4_ipc(dest, utcb, L4_SYSF_SEND_AND_WAIT, 0, tag, label, timeout);
594}
595
598 l4_timeout_t timeout) L4_NOTHROW
599{
600 return l4_ipc(dest, utcb, L4_SYSF_SEND, 0, tag, 0, timeout);
601}
602
605 l4_timeout_t timeout) L4_NOTHROW
606{
607 l4_msgtag_t t;
608 t.raw = 0;
609 return l4_ipc(L4_INVALID_CAP, utcb, L4_SYSF_WAIT, 0, t, label, timeout);
610}
611
614 l4_timeout_t timeout) L4_NOTHROW
615{
616 l4_msgtag_t t;
617 t.raw = 0;
618 return l4_ipc(object, utcb, L4_SYSF_RECV, 0, t, 0, timeout);
619}
620
623{ return l4_ipc_receive(L4_INVALID_CAP, NULL, timeout); }
624
627{
628 l4_uint64_t us = ms * 1000ULL; // cannot overflow because ms < 2^32
629 return l4_ipc_sleep(l4_timeout(L4_IPC_TIMEOUT_NEVER, l4_timeout_from_us(us)));
630}
631
634{
636 l4_timeout_from_us(us)));
637}
638
641{
643 return 0;
644 return l4_utcb_tcr_u(utcb)->error & L4_IPC_ERROR_MASK;
645}
646
647L4_INLINE long
648l4_error_u(l4_msgtag_t tag, l4_utcb_t *u) L4_NOTHROW
649{
651 return l4_ipc_to_errno(l4_utcb_tcr_u(u)->error & L4_IPC_ERROR_MASK);
652
653 return l4_msgtag_label(tag);
654}
655
656L4_INLINE long
658{
659 return l4_error_u(tag, l4_utcb());
660}
661
662
664{ return (l4_utcb_tcr_u(u)->error & 1) == 0; }
665
667{ return l4_utcb_tcr_u(u)->error & 1; }
668
670{ return l4_utcb_tcr_u(u)->error & L4_IPC_ERROR_MASK; }
671
672
673/*
674 * \internal
675 * \ingroup l4_ipc_api
676 */
677L4_INLINE int
678l4_sndfpage_add_u(l4_fpage_t const snd_fpage, unsigned long snd_base,
679 l4_msgtag_t *tag, l4_utcb_t *utcb) L4_NOTHROW
680{
681 l4_msg_regs_t *v = l4_utcb_mr_u(utcb);
682 int i = l4_msgtag_words(*tag) + 2 * l4_msgtag_items(*tag);
683
684 if (i >= L4_UTCB_GENERIC_DATA_SIZE - 1)
685 return -L4_ENOMEM;
686
687 v->mr[i] = snd_base | L4_ITEM_MAP | L4_ITEM_CONT;
688 v->mr[i + 1] = snd_fpage.raw;
689
690 *tag = l4_msgtag(l4_msgtag_label(*tag), l4_msgtag_words(*tag),
691 l4_msgtag_items(*tag) + 1, l4_msgtag_flags(*tag));
692 return 0;
693}
694
695L4_INLINE int
696l4_sndfpage_add(l4_fpage_t const snd_fpage, unsigned long snd_base,
698{
699 return l4_sndfpage_add_u(snd_fpage, snd_base, tag, l4_utcb());
700}
701
702
703#endif /* ! __L4SYS__INCLUDE__L4API_FIASCO__IPC_H__ */
Error codes.
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:51
unsigned int l4_uint32_t
Unsigned 32bit value.
Definition l4int.h:40
unsigned long long l4_uint64_t
Unsigned 64bit value.
Definition l4int.h:42
unsigned long l4_cap_idx_t
Capability selector type.
Definition types.h:359
@ L4_INVALID_CAP
Invalid capability selector.
Definition consts.h:168
@ L4_EIPC_LO
Communication error-range low.
Definition err.h:71
@ L4_ENOMEM
No memory.
Definition err.h:50
l4_msgtag_t l4_ipc_reply_and_wait(l4_utcb_t *utcb, l4_msgtag_t tag, l4_umword_t *label, l4_timeout_t timeout) L4_NOTHROW
Reply and wait operation (uses the reply capability).
Definition ipc.h:583
l4_msgtag_t l4_ipc(l4_cap_idx_t dest, l4_utcb_t *utcb, l4_umword_t flags, l4_umword_t slabel, l4_msgtag_t tag, l4_umword_t *rlabel, l4_timeout_t timeout) L4_NOTHROW
Generic L4 object invocation.
Definition ipc.h:33
l4_msgtag_t l4_ipc_receive(l4_cap_idx_t object, l4_utcb_t *utcb, l4_timeout_t timeout) L4_NOTHROW
Wait for a message from a specific source.
Definition ipc.h:613
l4_msgtag_t l4_ipc_sleep_us(l4_uint64_t us) L4_NOTHROW
Sleep for a certain amount of microseconds.
Definition ipc.h:633
l4_msgtag_t l4_ipc_send_and_wait(l4_cap_idx_t dest, l4_utcb_t *utcb, l4_msgtag_t tag, l4_umword_t *label, l4_timeout_t timeout) L4_NOTHROW
Send a message and do an open wait.
Definition ipc.h:590
l4_msgtag_t l4_ipc_send(l4_cap_idx_t dest, l4_utcb_t *utcb, l4_msgtag_t tag, l4_timeout_t timeout) L4_NOTHROW
Send a message to an object (do not wait for a reply).
Definition ipc.h:597
l4_msgtag_t l4_ipc_call(l4_cap_idx_t object, l4_utcb_t *utcb, l4_msgtag_t tag, l4_timeout_t timeout) L4_NOTHROW
Object call (usual invocation).
Definition ipc.h:576
l4_msgtag_t l4_ipc_sleep(l4_timeout_t timeout) L4_NOTHROW
Sleep for an amount of time.
Definition ipc.h:622
int l4_sndfpage_add(l4_fpage_t const snd_fpage, unsigned long snd_base, l4_msgtag_t *tag) L4_NOTHROW
Add a flex-page to be sent to the UTCB.
Definition ipc.h:696
l4_msgtag_t l4_ipc_wait(l4_utcb_t *utcb, l4_umword_t *label, l4_timeout_t timeout) L4_NOTHROW
Wait for an incoming message from any possible sender.
Definition ipc.h:604
l4_msgtag_t l4_ipc_sleep_ms(l4_uint32_t ms) L4_NOTHROW
Sleep for a certain amount of milliseconds.
Definition ipc.h:626
@ L4_SYSF_SEND_AND_WAIT
Send-and-wait flags.
Definition consts.h:139
@ L4_SYSF_WAIT
Wait flags (combines receive and open wait).
Definition consts.h:131
@ L4_SYSF_CALL
Call flags (combines send and receive).
Definition consts.h:123
@ L4_SYSF_SEND
Send-phase flag.
Definition consts.h:84
@ L4_SYSF_REPLY_AND_WAIT
Reply-and-wait flags.
Definition consts.h:147
@ L4_SYSF_RECV
Receive-phase flag.
Definition consts.h:95
long l4_error(l4_msgtag_t tag) L4_NOTHROW
Get IPC error code if any or message tag label otherwise for an IPC call.
Definition ipc.h:657
int l4_ipc_is_snd_error(l4_utcb_t *utcb) L4_NOTHROW
Returns whether an error occurred in send phase of an invocation.
Definition ipc.h:663
int l4_ipc_error_code(l4_utcb_t *utcb) L4_NOTHROW
Get the error condition of the last invocation from the TCR.
Definition ipc.h:669
l4_ipc_tcr_error_t
Error codes in the error TCR.
Definition ipc.h:93
int l4_ipc_is_rcv_error(l4_utcb_t *utcb) L4_NOTHROW
Returns whether an error occurred in receive phase of an invocation.
Definition ipc.h:666
l4_umword_t l4_ipc_error(l4_msgtag_t tag, l4_utcb_t *utcb) L4_NOTHROW
Get the IPC error code for an IPC operation.
Definition ipc.h:640
@ L4_IPC_SEABORTED
Send operation aborted.
Definition ipc.h:138
@ L4_IPC_SND_ERR_MASK
Send error mask.
Definition ipc.h:95
@ L4_IPC_RECANCELED
Receive operation canceled.
Definition ipc.h:106
@ L4_IPC_SESNDPFTO
Send-pagefault timeout in send operation.
Definition ipc.h:123
@ L4_IPC_SETIMEOUT
Timeout during send operation.
Definition ipc.h:103
@ L4_IPC_ENOT_EXISTENT
Non-existing destination or source.
Definition ipc.h:97
@ L4_IPC_ERROR_MASK
Mask for error bits.
Definition ipc.h:94
@ L4_IPC_REMAPFAILED
Map flexpage failed in receive operation.
Definition ipc.h:112
@ L4_IPC_SEMAPFAILED
Map flexpage failed in send operation.
Definition ipc.h:116
@ L4_IPC_SECANCELED
Send operation canceled.
Definition ipc.h:109
@ L4_IPC_REABORTED
Receive operation aborted.
Definition ipc.h:135
@ L4_IPC_SERCVPFTO
Receive-pagefault timeout in send operation.
Definition ipc.h:131
@ L4_IPC_SEMSGCUT
Sent message truncated.
Definition ipc.h:154
@ L4_IPC_REMSGCUT
Received message truncated.
Definition ipc.h:147
@ L4_IPC_RETIMEOUT
Timeout during receive operation.
Definition ipc.h:100
@ L4_IPC_RESNDPFTO
Send-pagefault timeout in receive operation.
Definition ipc.h:119
@ L4_IPC_RERCVPFTO
Receive-pagefault timeout in receive operation.
Definition ipc.h:127
@ L4_ITEM_MAP
Identify a message item as map item.
Definition consts.h:226
@ L4_ITEM_CONT
Denote that the following item shall be put into the same receive item as this one.
Definition consts.h:232
unsigned l4_msgtag_items(l4_msgtag_t t) L4_NOTHROW
Get the number of typed items.
Definition types.h:448
unsigned l4_msgtag_has_error(l4_msgtag_t t) L4_NOTHROW
Test for error indicator flag.
Definition types.h:457
l4_msgtag_t l4_msgtag(long label, unsigned words, unsigned items, unsigned flags) L4_NOTHROW
Create a message tag from the specified values.
Definition types.h:428
unsigned l4_msgtag_words(l4_msgtag_t t) L4_NOTHROW
Get the number of untyped words.
Definition types.h:444
unsigned l4_msgtag_flags(l4_msgtag_t t) L4_NOTHROW
Get the flags.
Definition types.h:452
long l4_msgtag_label(l4_msgtag_t t) L4_NOTHROW
Get the protocol of tag.
Definition types.h:440
#define L4_IPC_TIMEOUT_NEVER
never timeout
Definition __timeout.h:82
L4_CONSTEXPR l4_timeout_t l4_timeout(l4_timeout_s snd, l4_timeout_s rcv) L4_NOTHROW
Combine send and receive timeout in a timeout.
Definition __timeout.h:221
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:67
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition utcb.h:340
#define L4_ALWAYS_INLINE
Always inline a function.
Definition compiler.h:69
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition compiler.h:188
#define L4_UNLIKELY(x)
Expression is unlikely to execute.
Definition compiler.h:296
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:62
#define L4_LIKELY(x)
Expression is likely to execute.
Definition compiler.h:295
long l4_ipc_to_errno(unsigned long ipc_error_code) L4_NOTHROW
Get a negative error code for the given IPC error code.
Definition ipc.h:572
Common L4 ABI Data Types.
Message tag data structure.
Definition types.h:164
l4_mword_t raw
raw value
Definition types.h:165
l4_umword_t error
System call error codes.
Definition utcb.h:113
L4 flexpage type.
Definition __l4_fpage.h:85
Encapsulation of the message-register block in the UTCB.
Definition utcb.h:79
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition utcb.h:80
Timeout pair.
Definition __timeout.h:61