2 * Copyright (c) 2006 Ondrej Palkovsky
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 /** @addtogroup libcipc
35 #if ((defined(LIBC_ASYNC_H_)) && (!defined(LIBC_ASYNC_C_)))
36 #error Do not intermix low-level IPC interface and async framework
42 #include <ipc/common.h>
43 #include <abi/ipc/methods.h>
44 #include <abi/synch.h>
45 #include <abi/proc/task.h>
48 typedef void (*ipc_async_callback_t
)(void *, int, ipc_call_t
*);
50 extern int ipc_wait_cycle(ipc_call_t
*, sysarg_t
, unsigned int);
51 extern void ipc_poke(void);
53 #define ipc_wait_for_call(data) \
54 ipc_wait_for_call_timeout(data, SYNCH_NO_TIMEOUT);
56 extern int ipc_wait_for_call_timeout(ipc_call_t
*, sysarg_t
);
57 extern int ipc_trywait_for_call(ipc_call_t
*);
60 * User-friendly wrappers for ipc_answer_fast() and ipc_answer_slow().
61 * They are in the form of ipc_answer_m(), where m is the number of return
62 * arguments. The macros decide between the fast and the slow version according
66 #define ipc_answer_0(chandle, retval) \
67 ipc_answer_fast((chandle), (retval), 0, 0, 0, 0)
68 #define ipc_answer_1(chandle, retval, arg1) \
69 ipc_answer_fast((chandle), (retval), (arg1), 0, 0, 0)
70 #define ipc_answer_2(chandle, retval, arg1, arg2) \
71 ipc_answer_fast((chandle), (retval), (arg1), (arg2), 0, 0)
72 #define ipc_answer_3(chandle, retval, arg1, arg2, arg3) \
73 ipc_answer_fast((chandle), (retval), (arg1), (arg2), (arg3), 0)
74 #define ipc_answer_4(chandle, retval, arg1, arg2, arg3, arg4) \
75 ipc_answer_fast((chandle), (retval), (arg1), (arg2), (arg3), (arg4))
76 #define ipc_answer_5(chandle, retval, arg1, arg2, arg3, arg4, arg5) \
77 ipc_answer_slow((chandle), (retval), (arg1), (arg2), (arg3), (arg4), \
80 extern sysarg_t
ipc_answer_fast(cap_handle_t
, sysarg_t
, sysarg_t
, sysarg_t
,
82 extern sysarg_t
ipc_answer_slow(cap_handle_t
, sysarg_t
, sysarg_t
, sysarg_t
,
83 sysarg_t
, sysarg_t
, sysarg_t
);
86 * User-friendly wrappers for ipc_call_async_fast() and ipc_call_async_slow().
87 * They are in the form of ipc_call_async_m(), where m is the number of payload
88 * arguments. The macros decide between the fast and the slow version according
92 #define ipc_call_async_0(phandle, method, private, callback) \
93 ipc_call_async_fast((phandle), (method), 0, 0, 0, (private), (callback))
94 #define ipc_call_async_1(phandle, method, arg1, private, callback) \
95 ipc_call_async_fast((phandle), (method), (arg1), 0, 0, (private), \
97 #define ipc_call_async_2(phandle, method, arg1, arg2, private, callback) \
98 ipc_call_async_fast((phandle), (method), (arg1), (arg2), 0, \
99 (private), (callback))
100 #define ipc_call_async_3(phandle, method, arg1, arg2, arg3, private, callback) \
101 ipc_call_async_fast((phandle), (method), (arg1), (arg2), (arg3), \
102 (private), (callback))
103 #define ipc_call_async_4(phandle, method, arg1, arg2, arg3, arg4, private, \
105 ipc_call_async_slow((phandle), (method), (arg1), (arg2), (arg3), \
106 (arg4), 0, (private), (callback))
107 #define ipc_call_async_5(phandle, method, arg1, arg2, arg3, arg4, arg5, \
109 ipc_call_async_slow((phandle), (method), (arg1), (arg2), (arg3), \
110 (arg4), (arg5), (private), (callback))
112 extern void ipc_call_async_fast(cap_handle_t
, sysarg_t
, sysarg_t
, sysarg_t
,
113 sysarg_t
, void *, ipc_async_callback_t
);
114 extern void ipc_call_async_slow(cap_handle_t
, sysarg_t
, sysarg_t
, sysarg_t
,
115 sysarg_t
, sysarg_t
, sysarg_t
, void *, ipc_async_callback_t
);
117 extern int ipc_hangup(cap_handle_t
);
119 extern int ipc_forward_fast(cap_handle_t
, cap_handle_t
, sysarg_t
, sysarg_t
,
120 sysarg_t
, unsigned int);
121 extern int ipc_forward_slow(cap_handle_t
, cap_handle_t
, sysarg_t
, sysarg_t
,
122 sysarg_t
, sysarg_t
, sysarg_t
, sysarg_t
, unsigned int);
124 extern int ipc_connect_kbox(task_id_t
, cap_handle_t
*);