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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 8983273 was 96b02eb9, checked in by Martin Decky <martin@…>, 15 years ago

more unification of basic types

  • use sysarg_t and native_t (unsigned and signed variant) in both kernel and uspace
  • remove ipcarg_t in favour of sysarg_t

(no change in functionality)

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