source: mainline/uspace/lib/c/include/ipc/ipc.h@ 3c22f70

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 3c22f70 was 3c22f70, checked in by Jakub Jermar <jakub@…>, 14 years ago

Pass client task hash into async_new_connection().

  • Property mode set to 100644
File size: 13.4 KB
RevLine 
[b419162]1/*
[df4ed85]2 * Copyright (c) 2006 Ondrej Palkovsky
[b419162]3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
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.
16 *
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.
[b2951e2]27 */
28
[fadd381]29/** @addtogroup libcipc
[b2951e2]30 * @{
31 */
32/** @file
[ca3ba3a]33 */
[b419162]34
[fadd381]35#ifndef LIBIPC_IPC_H_
36#define LIBIPC_IPC_H_
[b419162]37
[ca3ba3a]38#include <task.h>
[b419162]39#include <kernel/ipc/ipc.h>
[b3f8fb7]40#include <kernel/ddi/irq.h>
[5d4e90f0]41#include <sys/types.h>
[80649a91]42#include <kernel/synch/synch.h>
[b419162]43
[ca3ba3a]44#define IPC_FLAG_BLOCKING 0x01
45
[7048773]46typedef struct {
[96b02eb9]47 sysarg_t args[IPC_CALL_LEN];
[fdb9982c]48 sysarg_t in_task_hash;
[3c22f70]49 sysarg_t in_phone_hash;
[b3f8fb7]50} ipc_call_t;
[ca3ba3a]51
[b419162]52typedef sysarg_t ipc_callid_t;
53
[161ae09]54typedef void (* ipc_async_callback_t)(void *, int, ipc_call_t *);
[b419162]55
[2e51969]56/*
57 * User-friendly wrappers for ipc_call_sync_fast() and ipc_call_sync_slow().
58 * They are in the form ipc_call_sync_m_n(), where m denotes the number of
59 * arguments of payload and n denotes number of return values. Whenever
60 * possible, the fast version is used.
61 */
62#define ipc_call_sync_0_0(phoneid, method) \
[ca3ba3a]63 ipc_call_sync_fast((phoneid), (method), 0, 0, 0, 0, 0, 0, 0, 0)
[2e51969]64#define ipc_call_sync_0_1(phoneid, method, res1) \
[ca3ba3a]65 ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), 0, 0, 0, 0)
[2e51969]66#define ipc_call_sync_0_2(phoneid, method, res1, res2) \
[ca3ba3a]67 ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), (res2), 0, 0, 0)
[2e51969]68#define ipc_call_sync_0_3(phoneid, method, res1, res2, res3) \
[ca3ba3a]69 ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), (res2), (res3), \
70 0, 0)
[2e51969]71#define ipc_call_sync_0_4(phoneid, method, res1, res2, res3, res4) \
[ca3ba3a]72 ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), (res2), (res3), \
73 (res4), 0)
[2e51969]74#define ipc_call_sync_0_5(phoneid, method, res1, res2, res3, res4, res5) \
[ca3ba3a]75 ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), (res2), (res3), \
76 (res4), (res5))
77
[2e51969]78#define ipc_call_sync_1_0(phoneid, method, arg1) \
[ca3ba3a]79 ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, 0, 0, 0, 0, 0)
[2e51969]80#define ipc_call_sync_1_1(phoneid, method, arg1, res1) \
[ca3ba3a]81 ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), 0, 0, 0, 0)
[2e51969]82#define ipc_call_sync_1_2(phoneid, method, arg1, res1, res2) \
[ca3ba3a]83 ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), (res2), 0, \
84 0, 0)
[2e51969]85#define ipc_call_sync_1_3(phoneid, method, arg1, res1, res2, res3) \
[ca3ba3a]86 ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), (res2), \
87 (res3), 0, 0)
[2e51969]88#define ipc_call_sync_1_4(phoneid, method, arg1, res1, res2, res3, res4) \
[ca3ba3a]89 ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), (res2), \
90 (res3), (res4), 0)
[2e51969]91#define ipc_call_sync_1_5(phoneid, method, arg1, res1, res2, res3, res4, \
92 res5) \
93 ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), (res2), \
94 (res3), (res4), (res5))
[ca3ba3a]95
[2e51969]96#define ipc_call_sync_2_0(phoneid, method, arg1, arg2) \
[ca3ba3a]97 ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, 0, 0, 0, \
98 0, 0)
[2e51969]99#define ipc_call_sync_2_1(phoneid, method, arg1, arg2, res1) \
[ca3ba3a]100 ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), 0, 0, \
101 0, 0)
[2e51969]102#define ipc_call_sync_2_2(phoneid, method, arg1, arg2, res1, res2) \
[ca3ba3a]103 ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), \
104 (res2), 0, 0, 0)
[2e51969]105#define ipc_call_sync_2_3(phoneid, method, arg1, arg2, res1, res2, res3) \
[ca3ba3a]106 ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), \
107 (res2), (res3), 0, 0)
[2e51969]108#define ipc_call_sync_2_4(phoneid, method, arg1, arg2, res1, res2, res3, \
109 res4) \
110 ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), \
111 (res2), (res3), (res4), 0)
112#define ipc_call_sync_2_5(phoneid, method, arg1, arg2, res1, res2, res3, \
113 res4, res5)\
114 ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), \
115 (res2), (res3), (res4), (res5))
[ca3ba3a]116
[2e51969]117#define ipc_call_sync_3_0(phoneid, method, arg1, arg2, arg3) \
[ca3ba3a]118 ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), 0, 0, 0, \
119 0, 0)
[2e51969]120#define ipc_call_sync_3_1(phoneid, method, arg1, arg2, arg3, res1) \
[ca3ba3a]121 ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), (res1), \
122 0, 0, 0, 0)
[2e51969]123#define ipc_call_sync_3_2(phoneid, method, arg1, arg2, arg3, res1, res2) \
[ca3ba3a]124 ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), (res1), \
125 (res2), 0, 0, 0)
[2e51969]126#define ipc_call_sync_3_3(phoneid, method, arg1, arg2, arg3, res1, res2, \
127 res3) \
128 ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), \
129 (res1), (res2), (res3), 0, 0)
130#define ipc_call_sync_3_4(phoneid, method, arg1, arg2, arg3, res1, res2, \
131 res3, res4) \
132 ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), \
133 (res1), (res2), (res3), (res4), 0)
134#define ipc_call_sync_3_5(phoneid, method, arg1, arg2, arg3, res1, res2, \
135 res3, res4, res5) \
136 ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), \
137 (res1), (res2), (res3), (res4), (res5))
[ca3ba3a]138
[2e51969]139#define ipc_call_sync_4_0(phoneid, method, arg1, arg2, arg3, arg4) \
[ca3ba3a]140 ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), 0, \
141 0, 0, 0, 0, 0)
[2e51969]142#define ipc_call_sync_4_1(phoneid, method, arg1, arg2, arg3, arg4, res1) \
[ca3ba3a]143 ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), 0, \
144 (res1), 0, 0, 0, 0)
[2e51969]145#define ipc_call_sync_4_2(phoneid, method, arg1, arg2, arg3, arg4, res1, res2) \
[ca3ba3a]146 ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), 0, \
147 (res1), (res2), 0, 0, 0)
[2e51969]148#define ipc_call_sync_4_3(phoneid, method, arg1, arg2, arg3, arg4, res1, res2, \
149 res3) \
150 ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
[1383356]151 (arg4), 0, (res1), (res2), (res3), 0, 0)
[2e51969]152#define ipc_call_sync_4_4(phoneid, method, arg1, arg2, arg3, arg4, res1, res2, \
153 res3, res4) \
154 ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
[1383356]155 (arg4), 0, (res1), (res2), (res3), (res4), 0)
[2e51969]156#define ipc_call_sync_4_5(phoneid, method, arg1, arg2, arg3, arg4, res1, res2, \
157 res3, res4, res5) \
158 ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
[1383356]159 (arg4), 0, (res1), (res2), (res3), (res4), (res5))
[ca3ba3a]160
[2e51969]161#define ipc_call_sync_5_0(phoneid, method, arg1, arg2, arg3, arg4, arg5) \
[ca3ba3a]162 ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
163 (arg5), 0, 0, 0, 0, 0)
[2e51969]164#define ipc_call_sync_5_1(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1) \
[ca3ba3a]165 ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
166 (arg5), (res1), 0, 0, 0, 0)
[2e51969]167#define ipc_call_sync_5_2(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1, \
168 res2) \
169 ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
170 (arg4), (arg5), (res1), (res2), 0, 0, 0)
171#define ipc_call_sync_5_3(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1, \
172 res2, res3) \
173 ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
174 (arg4), (arg5), (res1), (res2), (res3), 0, 0)
175#define ipc_call_sync_5_4(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1, \
176 res2, res3, res4) \
177 ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
178 (arg4), (arg5), (res1), (res2), (res3), (res4), 0)
179#define ipc_call_sync_5_5(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1, \
180 res2, res3, res4, res5) \
181 ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
182 (arg4), (arg5), (res1), (res2), (res3), (res4), (res5))
183
[96b02eb9]184extern int ipc_call_sync_fast(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
185 sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *);
[2e51969]186
[96b02eb9]187extern int ipc_call_sync_slow(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
188 sysarg_t, sysarg_t, sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *,
189 sysarg_t *);
[06502f7d]190
[161ae09]191extern ipc_callid_t ipc_wait_cycle(ipc_call_t *, uint32_t, int);
192extern ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *, uint32_t);
[057d21a]193extern void ipc_poke(void);
[ca3ba3a]194
[80649a91]195static inline ipc_callid_t ipc_wait_for_call(ipc_call_t *data)
196{
197 return ipc_wait_for_call_timeout(data, SYNCH_NO_TIMEOUT);
198}
[ca3ba3a]199
[161ae09]200extern ipc_callid_t ipc_trywait_for_call(ipc_call_t *);
[04a73cdf]201
[b74959bd]202/*
203 * User-friendly wrappers for ipc_answer_fast() and ipc_answer_slow().
204 * They are in the form of ipc_answer_m(), where m is the number of return
205 * arguments. The macros decide between the fast and the slow version according
206 * to m.
207 */
208#define ipc_answer_0(callid, retval) \
[ca3ba3a]209 ipc_answer_fast((callid), (retval), 0, 0, 0, 0)
[b74959bd]210#define ipc_answer_1(callid, retval, arg1) \
[ca3ba3a]211 ipc_answer_fast((callid), (retval), (arg1), 0, 0, 0)
[b74959bd]212#define ipc_answer_2(callid, retval, arg1, arg2) \
[ca3ba3a]213 ipc_answer_fast((callid), (retval), (arg1), (arg2), 0, 0)
[b74959bd]214#define ipc_answer_3(callid, retval, arg1, arg2, arg3) \
[ca3ba3a]215 ipc_answer_fast((callid), (retval), (arg1), (arg2), (arg3), 0)
[b74959bd]216#define ipc_answer_4(callid, retval, arg1, arg2, arg3, arg4) \
[ca3ba3a]217 ipc_answer_fast((callid), (retval), (arg1), (arg2), (arg3), (arg4))
[b74959bd]218#define ipc_answer_5(callid, retval, arg1, arg2, arg3, arg4, arg5) \
[ca3ba3a]219 ipc_answer_slow((callid), (retval), (arg1), (arg2), (arg3), (arg4), (arg5))
[b74959bd]220
[96b02eb9]221extern sysarg_t ipc_answer_fast(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
222 sysarg_t, sysarg_t);
223extern sysarg_t ipc_answer_slow(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
224 sysarg_t, sysarg_t, sysarg_t);
[b419162]225
[3209923]226/*
227 * User-friendly wrappers for ipc_call_async_fast() and ipc_call_async_slow().
228 * They are in the form of ipc_call_async_m(), where m is the number of payload
229 * arguments. The macros decide between the fast and the slow version according
230 * to m.
231 */
[161ae09]232#define ipc_call_async_0(phoneid, method, private, callback, can_preempt) \
[3209923]233 ipc_call_async_fast((phoneid), (method), 0, 0, 0, 0, (private), \
234 (callback), (can_preempt))
235#define ipc_call_async_1(phoneid, method, arg1, private, callback, \
236 can_preempt) \
237 ipc_call_async_fast((phoneid), (method), (arg1), 0, 0, 0, (private), \
238 (callback), (can_preempt))
239#define ipc_call_async_2(phoneid, method, arg1, arg2, private, callback, \
240 can_preempt) \
241 ipc_call_async_fast((phoneid), (method), (arg1), (arg2), 0, 0, \
242 (private), (callback), (can_preempt))
243#define ipc_call_async_3(phoneid, method, arg1, arg2, arg3, private, callback, \
244 can_preempt) \
245 ipc_call_async_fast((phoneid), (method), (arg1), (arg2), (arg3), 0, \
246 (private), (callback), (can_preempt))
247#define ipc_call_async_4(phoneid, method, arg1, arg2, arg3, arg4, private, \
248 callback, can_preempt) \
249 ipc_call_async_fast((phoneid), (method), (arg1), (arg2), (arg3), \
250 (arg4), (private), (callback), (can_preempt))
251#define ipc_call_async_5(phoneid, method, arg1, arg2, arg3, arg4, arg5, \
252 private, callback, can_preempt) \
253 ipc_call_async_slow((phoneid), (method), (arg1), (arg2), (arg3), \
254 (arg4), (arg5), (private), (callback), (can_preempt))
255
[96b02eb9]256extern void ipc_call_async_fast(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
257 sysarg_t, void *, ipc_async_callback_t, int);
258extern void ipc_call_async_slow(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
259 sysarg_t, sysarg_t, void *, ipc_async_callback_t, int);
[b1f51f0]260
[124c061]261extern int ipc_connect_to_me(int, int, int, int, sysarg_t *, sysarg_t *);
[161ae09]262extern int ipc_connect_me_to(int, int, int, int);
[19b28b0]263extern int ipc_connect_me_to_blocking(int, int, int, int);
[161ae09]264extern int ipc_hangup(int);
265extern int ipc_register_irq(int, int, int, irq_code_t *);
266extern int ipc_unregister_irq(int, int);
[96b02eb9]267extern int ipc_forward_fast(ipc_callid_t, int, int, sysarg_t, sysarg_t, int);
268extern int ipc_forward_slow(ipc_callid_t, int, int, sysarg_t, sysarg_t,
269 sysarg_t, sysarg_t, sysarg_t, int);
[a55d5f9f]270
[27d293a]271/*
[215e375]272 * User-friendly wrappers for ipc_share_in_start().
[27d293a]273 */
[215e375]274#define ipc_share_in_start_0_0(phoneid, dst, size) \
[ca3ba3a]275 ipc_share_in_start((phoneid), (dst), (size), 0, NULL)
[215e375]276#define ipc_share_in_start_0_1(phoneid, dst, size, flags) \
[ca3ba3a]277 ipc_share_in_start((phoneid), (dst), (size), 0, (flags))
[215e375]278#define ipc_share_in_start_1_0(phoneid, dst, size, arg) \
[ca3ba3a]279 ipc_share_in_start((phoneid), (dst), (size), (arg), NULL)
[215e375]280#define ipc_share_in_start_1_1(phoneid, dst, size, arg, flags) \
[ca3ba3a]281 ipc_share_in_start((phoneid), (dst), (size), (arg), (flags))
[27d293a]282
[96b02eb9]283extern int ipc_share_in_start(int, void *, size_t, sysarg_t, int *);
[161ae09]284extern int ipc_share_in_finalize(ipc_callid_t, void *, int );
285extern int ipc_share_out_start(int, void *, int);
286extern int ipc_share_out_finalize(ipc_callid_t, void *);
287extern int ipc_data_read_start(int, void *, size_t);
288extern int ipc_data_read_finalize(ipc_callid_t, const void *, size_t);
289extern int ipc_data_write_start(int, const void *, size_t);
290extern int ipc_data_write_finalize(ipc_callid_t, void *, size_t);
[183b4a0]291
[161ae09]292extern int ipc_connect_kbox(task_id_t);
[9a1b20c]293
[b419162]294#endif
[b2951e2]295
[fadd381]296/** @}
[b2951e2]297 */
Note: See TracBrowser for help on using the repository browser.