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
56/*****************************************************************************
57 *** IPC result checking
58 *****************************************************************************/
59
76{
83 L4_IPC_RETIMEOUT = 0x03,
86 L4_IPC_SETIMEOUT = 0x02,
89 L4_IPC_RECANCELED = 0x07,
92 L4_IPC_SECANCELED = 0x06,
95 L4_IPC_REMAPFAILED = 0x11,
99 L4_IPC_SEMAPFAILED = 0x10,
102 L4_IPC_RESNDPFTO = 0x0b,
106 L4_IPC_SESNDPFTO = 0x0a,
110 L4_IPC_RERCVPFTO = 0x0d,
114 L4_IPC_SERCVPFTO = 0x0c,
118 L4_IPC_REABORTED = 0x0f,
121 L4_IPC_SEABORTED = 0x0e,
131
138};
139
140
153
154
171L4_INLINE long
173
174L4_INLINE long
175l4_error_u(l4_msgtag_t tag, l4_utcb_t *utcb) L4_NOTHROW;
176
177/*****************************************************************************
178 *** IPC results
179 *****************************************************************************/
180
191
202
213
220L4_INLINE long l4_ipc_to_errno(unsigned long ipc_error_code) L4_NOTHROW;
221
222
223/*****************************************************************************
224 *** IPC calls
225 *****************************************************************************/
226
257 l4_timeout_t timeout) L4_NOTHROW;
258
259
287l4_ipc_wait(l4_utcb_t *utcb, l4_umword_t *label,
288 l4_timeout_t timeout) L4_NOTHROW;
289
290
317 l4_timeout_t timeout) L4_NOTHROW;
318
342 l4_timeout_t timeout) L4_NOTHROW;
343
344
372 l4_umword_t *label, l4_timeout_t timeout) L4_NOTHROW;
373
404 l4_umword_t *label, l4_timeout_t timeout) L4_NOTHROW;
405
412#if 0
424l4_ipc_wait_next_period(l4_utcb_t *utcb,
425 l4_umword_t *label,
426 l4_timeout_t timeout);
427
428#endif
429
451 l4_utcb_t *utcb,
452 l4_umword_t flags,
453 l4_umword_t slabel,
454 l4_msgtag_t tag,
455 l4_umword_t *rlabel,
456 l4_timeout_t timeout) L4_NOTHROW;
457
476
494l4_ipc_sleep_ms(unsigned ms) L4_NOTHROW;
495
513l4_ipc_sleep_us(unsigned us) L4_NOTHROW;
514
529L4_INLINE int
530l4_sndfpage_add(l4_fpage_t const snd_fpage, unsigned long snd_base,
532
533/*
534 * \internal
535 * \ingroup l4_ipc_api
536 */
537L4_INLINE int
538l4_sndfpage_add_u(l4_fpage_t const snd_fpage, unsigned long snd_base,
539 l4_msgtag_t *tag, l4_utcb_t *utcb) L4_NOTHROW;
540
541
542/************************************************************************
543 * Implementations
544 **********************/
545
546L4_INLINE long l4_ipc_to_errno(unsigned long ipc_error_code) L4_NOTHROW
547{ return -(L4_EIPC_LO + ipc_error_code); }
548
551 l4_msgtag_t tag,
552 l4_timeout_t timeout) L4_NOTHROW
553{
554 return l4_ipc(dest, utcb, L4_SYSF_CALL, 0, tag, 0, timeout);
555}
556
559 l4_umword_t *label,
560 l4_timeout_t timeout) L4_NOTHROW
561{
562 return l4_ipc(L4_INVALID_CAP, utcb, L4_SYSF_REPLY_AND_WAIT, 0, tag, label, timeout);
563}
564
567 l4_msgtag_t tag,
568 l4_umword_t *src,
569 l4_timeout_t timeout) L4_NOTHROW
570{
571 return l4_ipc(dest, utcb, L4_SYSF_SEND_AND_WAIT, 0, tag, src, timeout);
572}
573
576 l4_msgtag_t tag,
577 l4_timeout_t timeout) L4_NOTHROW
578{
579 return l4_ipc(dest, utcb, L4_SYSF_SEND, 0, tag, 0, timeout);
580}
581
584 l4_timeout_t timeout) L4_NOTHROW
585{
586 l4_msgtag_t t;
587 t.raw = 0;
588 return l4_ipc(L4_INVALID_CAP, utcb, L4_SYSF_WAIT, 0, t, src, timeout);
589}
590
593 l4_timeout_t timeout) L4_NOTHROW
594{
595 l4_msgtag_t t;
596 t.raw = 0;
597 return l4_ipc(src, utcb, L4_SYSF_RECV, 0, t, 0, timeout);
598}
599
602{ return l4_ipc_receive(L4_INVALID_CAP, NULL, timeout); }
603
606{
608 l4_timeout_from_us(ms * 1000)));
609}
610
613{
615 l4_timeout_from_us(us)));
616}
617
620{
621 if (!l4_msgtag_has_error(tag))
622 return 0;
623 return l4_utcb_tcr_u(utcb)->error & L4_IPC_ERROR_MASK;
624}
625
626L4_INLINE long
627l4_error_u(l4_msgtag_t tag, l4_utcb_t *u) L4_NOTHROW
628{
629 if (l4_msgtag_has_error(tag))
630 return l4_ipc_to_errno(l4_utcb_tcr_u(u)->error & L4_IPC_ERROR_MASK);
631
632 return l4_msgtag_label(tag);
633}
634
635L4_INLINE long
637{
638 return l4_error_u(tag, l4_utcb());
639}
640
641
643{ return (l4_utcb_tcr_u(u)->error & 1) == 0; }
644
646{ return l4_utcb_tcr_u(u)->error & 1; }
647
649{ return l4_utcb_tcr_u(u)->error & L4_IPC_ERROR_MASK; }
650
651
652/*
653 * \internal
654 * \ingroup l4_ipc_api
655 */
656L4_INLINE int
657l4_sndfpage_add_u(l4_fpage_t const snd_fpage, unsigned long snd_base,
658 l4_msgtag_t *tag, l4_utcb_t *utcb) L4_NOTHROW
659{
660 l4_msg_regs_t *v = l4_utcb_mr_u(utcb);
661 int i = l4_msgtag_words(*tag) + 2 * l4_msgtag_items(*tag);
662
663 if (i >= L4_UTCB_GENERIC_DATA_SIZE - 1)
664 return -L4_ENOMEM;
665
666 v->mr[i] = snd_base | L4_ITEM_MAP | L4_ITEM_CONT;
667 v->mr[i + 1] = snd_fpage.raw;
668
669 *tag = l4_msgtag(l4_msgtag_label(*tag), l4_msgtag_words(*tag),
670 l4_msgtag_items(*tag) + 1, l4_msgtag_flags(*tag));
671 return 0;
672}
673
674L4_INLINE int
675l4_sndfpage_add(l4_fpage_t const snd_fpage, unsigned long snd_base,
677{
678 return l4_sndfpage_add_u(snd_fpage, snd_base, tag, l4_utcb());
679}
680
681
682#endif /* ! __L4SYS__INCLUDE__L4API_FIASCO__IPC_H__ */
Error codes.
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:51
unsigned long l4_cap_idx_t
Capability selector type.
Definition types.h:358
@ L4_INVALID_CAP
Invalid capability selector.
Definition consts.h:168
@ L4_EIPC_LO
Communication error-range low.
Definition err.h:70
@ 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:558
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:592
l4_msgtag_t l4_ipc_sleep_ms(unsigned ms) L4_NOTHROW
Sleep for a certain amount of milliseconds.
Definition ipc.h:605
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:566
l4_msgtag_t l4_ipc_sleep_us(unsigned us) L4_NOTHROW
Sleep for a certain amount of microseconds.
Definition ipc.h:612
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:575
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:550
l4_msgtag_t l4_ipc_sleep(l4_timeout_t timeout) L4_NOTHROW
Sleep for an amount of time.
Definition ipc.h:601
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:675
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:583
@ 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:636
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:642
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:648
l4_ipc_tcr_error_t
Error codes in the error TCR.
Definition ipc.h:76
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:645
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:619
@ L4_IPC_SEABORTED
Send operation aborted.
Definition ipc.h:121
@ L4_IPC_SND_ERR_MASK
Send error mask.
Definition ipc.h:78
@ L4_IPC_RECANCELED
Receive operation canceled.
Definition ipc.h:89
@ L4_IPC_SESNDPFTO
Send-pagefault timeout in send operation.
Definition ipc.h:106
@ L4_IPC_SETIMEOUT
Timeout during send operation.
Definition ipc.h:86
@ L4_IPC_ENOT_EXISTENT
Non-existing destination or source.
Definition ipc.h:80
@ L4_IPC_ERROR_MASK
Mask for error bits.
Definition ipc.h:77
@ L4_IPC_REMAPFAILED
Map flexpage failed in receive operation.
Definition ipc.h:95
@ L4_IPC_SEMAPFAILED
Map flexpage failed in send operation.
Definition ipc.h:99
@ L4_IPC_SECANCELED
Send operation canceled.
Definition ipc.h:92
@ L4_IPC_REABORTED
Receive operation aborted.
Definition ipc.h:118
@ L4_IPC_SERCVPFTO
Receive-pagefault timeout in send operation.
Definition ipc.h:114
@ L4_IPC_SEMSGCUT
Sent message truncated.
Definition ipc.h:137
@ L4_IPC_REMSGCUT
Received message truncated.
Definition ipc.h:130
@ L4_IPC_RETIMEOUT
Timeout during receive operation.
Definition ipc.h:83
@ L4_IPC_RESNDPFTO
Send-pagefault timeout in receive operation.
Definition ipc.h:102
@ L4_IPC_RERCVPFTO
Receive-pagefault timeout in receive operation.
Definition ipc.h:110
@ 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:447
unsigned l4_msgtag_has_error(l4_msgtag_t t) L4_NOTHROW
Test for error indicator flag.
Definition types.h:456
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:427
unsigned l4_msgtag_words(l4_msgtag_t t) L4_NOTHROW
Get the number of untyped words.
Definition types.h:443
unsigned l4_msgtag_flags(l4_msgtag_t t) L4_NOTHROW
Get the flags.
Definition types.h:451
long l4_msgtag_label(l4_msgtag_t t) L4_NOTHROW
Get the protocol of tag.
Definition types.h:439
#define L4_IPC_TIMEOUT_NEVER
never timeout
Definition __timeout.h:80
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:219
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_INLINE
L4 Inline function attribute.
Definition compiler.h:62
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:546
Common L4 ABI Data Types.
Message tag data structure.
Definition types.h:163
l4_mword_t raw
raw value
Definition types.h:164
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:59