]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4sys/include/ARCH-ppc32/L4API-l4f/ipc.h
update
[l4.git] / l4 / pkg / l4sys / include / ARCH-ppc32 / L4API-l4f / ipc.h
1 /*!
2  * \file
3  * \brief   L4 IPC System Calls, PPC
4  * \ingroup api_calls
5  */
6 /*
7  * (c) 2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>
8  *     economic rights: Technische Universität Dresden (Germany)
9  *
10  * This file is part of TUD:OS and distributed under the terms of the
11  * GNU General Public License 2.
12  * Please see the COPYING-GPL-2 file for details.
13  *
14  * As a special exception, you may use this file as part of a free software
15  * library without restriction.  Specifically, if other files instantiate
16  * templates or use macros or inline functions from this file, or you compile
17  * this file and link it with other files to produce an executable, this
18  * file does not by itself cause the resulting executable to be covered by
19  * the GNU General Public License.  This exception does not however
20  * invalidate any other reasons why the executable file might be covered by
21  * the GNU General Public License.
22  */
23 #pragma once
24
25 #ifdef __GNUC__
26
27 #include <l4/sys/compiler.h>
28
29 #include_next <l4/sys/ipc.h>
30
31 #define L4_IPC_CAPMAPMSG_BASE 0xf0000100   ///< Capability mapmsg base
32
33 #ifndef L4_SYSCALL_MAGIC_OFFSET 
34 #  define L4_SYSCALL_MAGIC_OFFSET       8
35 #endif
36 #define L4_SYSCALL_INVOKE               (-0x00000004-L4_SYSCALL_MAGIC_OFFSET)
37
38 L4_INLINE l4_msgtag_t
39 l4_ipc(l4_cap_idx_t dest, l4_utcb_t *utcb,
40        l4_umword_t flags,
41        l4_umword_t slabel,
42        l4_msgtag_t tag,
43        l4_umword_t *rlabel,
44        l4_timeout_t timeout) L4_NOTHROW
45 {
46   register l4_umword_t _dest     __asm__("r4") = dest | flags;
47   register l4_umword_t _timeout  __asm__("r5") = timeout.raw;
48   register l4_umword_t _tag      __asm__("r3") = tag.raw;
49   register l4_umword_t _lab      __asm__("r6") = slabel;
50   (void)utcb;
51
52   __asm__ __volatile__
53     ("bla %[addr]"
54      :
55      "+r" (_dest),
56      "+r" (_timeout),
57      "+r" (_lab),
58      "+r" (_tag)
59      :
60      [addr] "i" (L4_SYSCALL_INVOKE)
61      :
62      "memory", "lr");
63
64   if (rlabel)
65     *rlabel = _lab;
66   tag.raw = _tag;
67   return tag;
68 }
69
70
71 L4_INLINE l4_msgtag_t
72 l4_ipc_call(l4_cap_idx_t dest, l4_utcb_t *utcb,
73             l4_msgtag_t tag,
74             l4_timeout_t timeout) L4_NOTHROW
75 {
76   return l4_ipc(dest, utcb, L4_SYSF_CALL, 0, tag, 0, timeout);
77 }
78
79 L4_INLINE l4_msgtag_t
80 l4_ipc_reply_and_wait(l4_utcb_t *utcb, l4_msgtag_t tag,
81                       l4_umword_t *label,
82                       l4_timeout_t timeout) L4_NOTHROW
83 {
84   return l4_ipc(L4_INVALID_CAP, utcb, L4_SYSF_REPLY_AND_WAIT, 0, tag, label, timeout);
85 }
86
87 L4_INLINE l4_msgtag_t
88 l4_ipc_send_and_wait(l4_cap_idx_t dest, l4_utcb_t *utcb,
89                      l4_msgtag_t tag,
90                      l4_umword_t *src,
91                      l4_timeout_t timeout) L4_NOTHROW
92 {
93   return l4_ipc(dest, utcb, L4_SYSF_SEND_AND_WAIT, 0, tag, src, timeout);
94 }
95
96 L4_INLINE l4_msgtag_t
97 l4_ipc_send(l4_cap_idx_t dest, l4_utcb_t *utcb,
98             l4_msgtag_t tag,
99             l4_timeout_t timeout) L4_NOTHROW
100 {
101   return l4_ipc(dest, utcb, L4_SYSF_SEND, 0, tag, 0, timeout);
102 }
103
104 L4_INLINE l4_msgtag_t
105 l4_ipc_wait(l4_utcb_t *utcb, l4_umword_t *src,
106             l4_timeout_t timeout) L4_NOTHROW
107 {
108   l4_msgtag_t t;
109   t.raw = 0;
110   return l4_ipc(L4_INVALID_CAP, utcb, L4_SYSF_WAIT, 0, t, src, timeout);
111 }
112
113 L4_INLINE l4_msgtag_t
114 l4_ipc_receive(l4_cap_idx_t src, l4_utcb_t *utcb,
115                l4_timeout_t timeout) L4_NOTHROW
116 {
117   l4_msgtag_t t;
118   t.raw = 0;
119   return l4_ipc(src, utcb, L4_SYSF_RECV, 0, t, 0, timeout);
120 }
121
122 #include <l4/sys/ipc-impl.h>
123
124 #endif //__GNUC__