source: mainline/uspace/lib/libc/include/ipc/ipc.h@ 057d21a

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

Add SYS_IPC_POKE syscall.

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