1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License 2.  See the file "COPYING-GPL-2" in the main directory of this
4  * archive for more details.
5  *
6  * Copyright (C) 2013 Imagination Technologies Ltd.
7  * Author: Yann Le Du <ledu@kymasys.com>
8  *
9  * This file incorporates work covered by the following copyright notice:
10  */
11 
12 /**
13  * \file
14  * \brief   L4 IPC System Calls, MIPS
15  * \ingroup api_calls
16  */
17 /*
18  * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
19  *               Alexander Warg <warg@os.inf.tu-dresden.de>
20  *     economic rights: Technische Universität Dresden (Germany)
21  *
22  * This file is part of TUD:OS and distributed under the terms of the
23  * GNU General Public License 2.
24  * Please see the COPYING-GPL-2 file for details.
25  *
26  * As a special exception, you may use this file as part of a free software
27  * library without restriction.  Specifically, if other files instantiate
28  * templates or use macros or inline functions from this file, or you compile
29  * this file and link it with other files to produce an executable, this
30  * file does not by itself cause the resulting executable to be covered by
31  * the GNU General Public License.  This exception does not however
32  * invalidate any other reasons why the executable file might be covered by
33  * the GNU General Public License.
34  */
35 #pragma once
36 
37 #include_next <l4/sys/ipc.h>
38 
39 #ifdef __GNUC__
40 
41 #include <l4/sys/compiler.h>
42 
43 L4_INLINE 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)44 l4_ipc(l4_cap_idx_t dest, l4_utcb_t *utcb,
45        l4_umword_t flags,
46        l4_umword_t slabel,
47        l4_msgtag_t tag,
48        l4_umword_t *rlabel,
49        l4_timeout_t timeout) L4_NOTHROW
50 {
51   register void       *_utcb     __asm__("s0") = utcb;
52   register l4_umword_t _dest     __asm__("s1") = dest | flags;
53   register l4_umword_t _timeout  __asm__("s2") = timeout.raw;
54   register l4_mword_t  _tag      __asm__("s3") = tag.raw;
55   register l4_umword_t _label    __asm__("s4") = slabel;
56 
57   /* the kernl preserves sp(29), fp(30), and gp(28) */
58   /* s0 - s4 are in/out arguments */
59   __asm__ __volatile__
60     ("syscall"
61      :
62      "+r" (_dest),
63      "+r" (_timeout),
64      "+r" (_label),
65      "+r" (_tag),
66      "+r" (_utcb)
67      :
68      : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11",
69        "$12", "$13", "$14", "$15", "$22", "$23", "$24", "$25",
70        "$31", "memory");
71 
72   if (rlabel)
73     *rlabel = _label;
74   tag.raw = _tag;
75 
76   return tag;
77 }
78 
79 #endif //__GNUC__
80