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

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

Remove the two-phase way of creating virtual memory areas (first asking for a mappable address and then mapping it) which was prone to race conditions when two or more calls to as_get_mappable_page() and as_area_create() were interleaved. This for example caused the e1k driver to randomly fail.

The memory area related syscalls and IPC calls have all been altered to accept a special value (void *) -1, representing a demand to atomically search for a mappable address space "hole" and map to it.

Individual changes:

  • IPC_M_SHARE_OUT: the destination address space area is supplied by the kernel, the callee only specifies the lower bound

(the address is returned to the callee via a pointer in an IPC reply argument)

  • IPC_M_SHARE_IN: the destination address space ares is supplied by the kernel, the callee only specifies the lower bound

(the address is returned to the caller as usual via an IPC argument)

  • SYS_AS_GET_UNMAPPED_AREA was removed
  • dummy implementations of SYS_PHYSMEM_UNMAP and SYS_IOSPACE_DISABLE were added for the sake of symmetry (they do nothing yet)
  • SYS_PHYSMEM_MAP and SYS_DMAMEM_MAP were altered to accept (void *) -1 as address space area base and a lower bound
  • kernel as_area_create() and as_area_share() were altered to accept (void *) -1 as address space area base and a lower bound
  • uspace libraries and programs were altered to reflect the new API
  • 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
[64d2b10]35#if ((defined(LIBC_ASYNC_H_)) && (!defined(LIBC_ASYNC_C_)))
36 #error Do not intermix low-level IPC interface and async framework
37#endif
38
[68a2be19]39#ifndef LIBC_IPC_H_
40#define LIBC_IPC_H_
[b419162]41
[5d4e90f0]42#include <sys/types.h>
[64d2b10]43#include <ipc/common.h>
[c0699467]44#include <abi/ipc/methods.h>
45#include <abi/synch.h>
[64d2b10]46#include <task.h>
[b419162]47
[64d2b10]48typedef void (*ipc_async_callback_t)(void *, int, ipc_call_t *);
[b419162]49
[2e51969]50/*
51 * User-friendly wrappers for ipc_call_sync_fast() and ipc_call_sync_slow().
52 * They are in the form ipc_call_sync_m_n(), where m denotes the number of
53 * arguments of payload and n denotes number of return values. Whenever
54 * possible, the fast version is used.
55 */
[10477601]56
[2e51969]57#define ipc_call_sync_0_0(phoneid, method) \
[ca3ba3a]58 ipc_call_sync_fast((phoneid), (method), 0, 0, 0, 0, 0, 0, 0, 0)
[2e51969]59#define ipc_call_sync_0_1(phoneid, method, res1) \
[ca3ba3a]60 ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), 0, 0, 0, 0)
[2e51969]61#define ipc_call_sync_0_2(phoneid, method, res1, res2) \
[ca3ba3a]62 ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), (res2), 0, 0, 0)
[2e51969]63#define ipc_call_sync_0_3(phoneid, method, res1, res2, res3) \
[ca3ba3a]64 ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), (res2), (res3), \
65 0, 0)
[2e51969]66#define ipc_call_sync_0_4(phoneid, method, res1, res2, res3, res4) \
[ca3ba3a]67 ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), (res2), (res3), \
68 (res4), 0)
[2e51969]69#define ipc_call_sync_0_5(phoneid, method, res1, res2, res3, res4, res5) \
[ca3ba3a]70 ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), (res2), (res3), \
71 (res4), (res5))
72
[2e51969]73#define ipc_call_sync_1_0(phoneid, method, arg1) \
[ca3ba3a]74 ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, 0, 0, 0, 0, 0)
[2e51969]75#define ipc_call_sync_1_1(phoneid, method, arg1, res1) \
[ca3ba3a]76 ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), 0, 0, 0, 0)
[2e51969]77#define ipc_call_sync_1_2(phoneid, method, arg1, res1, res2) \
[ca3ba3a]78 ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), (res2), 0, \
79 0, 0)
[2e51969]80#define ipc_call_sync_1_3(phoneid, method, arg1, res1, res2, res3) \
[ca3ba3a]81 ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), (res2), \
82 (res3), 0, 0)
[2e51969]83#define ipc_call_sync_1_4(phoneid, method, arg1, res1, res2, res3, res4) \
[ca3ba3a]84 ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), (res2), \
85 (res3), (res4), 0)
[2e51969]86#define ipc_call_sync_1_5(phoneid, method, arg1, res1, res2, res3, res4, \
87 res5) \
88 ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), (res2), \
89 (res3), (res4), (res5))
[ca3ba3a]90
[2e51969]91#define ipc_call_sync_2_0(phoneid, method, arg1, arg2) \
[ca3ba3a]92 ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, 0, 0, 0, \
93 0, 0)
[2e51969]94#define ipc_call_sync_2_1(phoneid, method, arg1, arg2, res1) \
[ca3ba3a]95 ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), 0, 0, \
96 0, 0)
[2e51969]97#define ipc_call_sync_2_2(phoneid, method, arg1, arg2, res1, res2) \
[ca3ba3a]98 ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), \
99 (res2), 0, 0, 0)
[2e51969]100#define ipc_call_sync_2_3(phoneid, method, arg1, arg2, res1, res2, res3) \
[ca3ba3a]101 ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), \
102 (res2), (res3), 0, 0)
[2e51969]103#define ipc_call_sync_2_4(phoneid, method, arg1, arg2, res1, res2, res3, \
104 res4) \
105 ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), \
106 (res2), (res3), (res4), 0)
107#define ipc_call_sync_2_5(phoneid, method, arg1, arg2, res1, res2, res3, \
108 res4, res5)\
109 ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), \
110 (res2), (res3), (res4), (res5))
[ca3ba3a]111
[2e51969]112#define ipc_call_sync_3_0(phoneid, method, arg1, arg2, arg3) \
[ca3ba3a]113 ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), 0, 0, 0, \
114 0, 0)
[2e51969]115#define ipc_call_sync_3_1(phoneid, method, arg1, arg2, arg3, res1) \
[ca3ba3a]116 ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), (res1), \
117 0, 0, 0, 0)
[2e51969]118#define ipc_call_sync_3_2(phoneid, method, arg1, arg2, arg3, res1, res2) \
[ca3ba3a]119 ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), (res1), \
120 (res2), 0, 0, 0)
[2e51969]121#define ipc_call_sync_3_3(phoneid, method, arg1, arg2, arg3, res1, res2, \
122 res3) \
123 ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), \
124 (res1), (res2), (res3), 0, 0)
125#define ipc_call_sync_3_4(phoneid, method, arg1, arg2, arg3, res1, res2, \
126 res3, res4) \
127 ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), \
128 (res1), (res2), (res3), (res4), 0)
129#define ipc_call_sync_3_5(phoneid, method, arg1, arg2, arg3, res1, res2, \
130 res3, res4, res5) \
131 ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), \
132 (res1), (res2), (res3), (res4), (res5))
[ca3ba3a]133
[2e51969]134#define ipc_call_sync_4_0(phoneid, method, arg1, arg2, arg3, arg4) \
[ca3ba3a]135 ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), 0, \
136 0, 0, 0, 0, 0)
[2e51969]137#define ipc_call_sync_4_1(phoneid, method, arg1, arg2, arg3, arg4, res1) \
[ca3ba3a]138 ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), 0, \
139 (res1), 0, 0, 0, 0)
[2e51969]140#define ipc_call_sync_4_2(phoneid, method, arg1, arg2, arg3, arg4, res1, res2) \
[ca3ba3a]141 ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), 0, \
142 (res1), (res2), 0, 0, 0)
[2e51969]143#define ipc_call_sync_4_3(phoneid, method, arg1, arg2, arg3, arg4, res1, res2, \
144 res3) \
145 ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
[1383356]146 (arg4), 0, (res1), (res2), (res3), 0, 0)
[2e51969]147#define ipc_call_sync_4_4(phoneid, method, arg1, arg2, arg3, arg4, res1, res2, \
148 res3, res4) \
149 ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
[1383356]150 (arg4), 0, (res1), (res2), (res3), (res4), 0)
[2e51969]151#define ipc_call_sync_4_5(phoneid, method, arg1, arg2, arg3, arg4, res1, res2, \
152 res3, res4, res5) \
153 ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
[1383356]154 (arg4), 0, (res1), (res2), (res3), (res4), (res5))
[ca3ba3a]155
[2e51969]156#define ipc_call_sync_5_0(phoneid, method, arg1, arg2, arg3, arg4, arg5) \
[ca3ba3a]157 ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
158 (arg5), 0, 0, 0, 0, 0)
[2e51969]159#define ipc_call_sync_5_1(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1) \
[ca3ba3a]160 ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
161 (arg5), (res1), 0, 0, 0, 0)
[2e51969]162#define ipc_call_sync_5_2(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1, \
163 res2) \
164 ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
165 (arg4), (arg5), (res1), (res2), 0, 0, 0)
166#define ipc_call_sync_5_3(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1, \
167 res2, res3) \
168 ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
169 (arg4), (arg5), (res1), (res2), (res3), 0, 0)
170#define ipc_call_sync_5_4(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1, \
171 res2, res3, res4) \
172 ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
173 (arg4), (arg5), (res1), (res2), (res3), (res4), 0)
174#define ipc_call_sync_5_5(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1, \
175 res2, res3, res4, res5) \
176 ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
177 (arg4), (arg5), (res1), (res2), (res3), (res4), (res5))
178
[96b02eb9]179extern int ipc_call_sync_fast(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
180 sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *);
[2e51969]181
[96b02eb9]182extern int ipc_call_sync_slow(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
183 sysarg_t, sysarg_t, sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *,
184 sysarg_t *);
[06502f7d]185
[10477601]186extern ipc_callid_t ipc_wait_cycle(ipc_call_t *, sysarg_t, unsigned int);
[057d21a]187extern void ipc_poke(void);
[ca3ba3a]188
[10477601]189#define ipc_wait_for_call(data) \
190 ipc_wait_for_call_timeout(data, SYNCH_NO_TIMEOUT);
[ca3ba3a]191
[10477601]192extern ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *, sysarg_t);
[161ae09]193extern ipc_callid_t ipc_trywait_for_call(ipc_call_t *);
[04a73cdf]194
[b74959bd]195/*
196 * User-friendly wrappers for ipc_answer_fast() and ipc_answer_slow().
197 * They are in the form of ipc_answer_m(), where m is the number of return
198 * arguments. The macros decide between the fast and the slow version according
199 * to m.
200 */
[10477601]201
[b74959bd]202#define ipc_answer_0(callid, retval) \
[ca3ba3a]203 ipc_answer_fast((callid), (retval), 0, 0, 0, 0)
[b74959bd]204#define ipc_answer_1(callid, retval, arg1) \
[ca3ba3a]205 ipc_answer_fast((callid), (retval), (arg1), 0, 0, 0)
[b74959bd]206#define ipc_answer_2(callid, retval, arg1, arg2) \
[ca3ba3a]207 ipc_answer_fast((callid), (retval), (arg1), (arg2), 0, 0)
[b74959bd]208#define ipc_answer_3(callid, retval, arg1, arg2, arg3) \
[ca3ba3a]209 ipc_answer_fast((callid), (retval), (arg1), (arg2), (arg3), 0)
[b74959bd]210#define ipc_answer_4(callid, retval, arg1, arg2, arg3, arg4) \
[ca3ba3a]211 ipc_answer_fast((callid), (retval), (arg1), (arg2), (arg3), (arg4))
[b74959bd]212#define ipc_answer_5(callid, retval, arg1, arg2, arg3, arg4, arg5) \
[ca3ba3a]213 ipc_answer_slow((callid), (retval), (arg1), (arg2), (arg3), (arg4), (arg5))
[b74959bd]214
[96b02eb9]215extern sysarg_t ipc_answer_fast(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
216 sysarg_t, sysarg_t);
217extern sysarg_t ipc_answer_slow(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
218 sysarg_t, sysarg_t, sysarg_t);
[b419162]219
[3209923]220/*
221 * User-friendly wrappers for ipc_call_async_fast() and ipc_call_async_slow().
222 * They are in the form of ipc_call_async_m(), where m is the number of payload
223 * arguments. The macros decide between the fast and the slow version according
224 * to m.
225 */
[10477601]226
[161ae09]227#define ipc_call_async_0(phoneid, method, private, callback, can_preempt) \
[3209923]228 ipc_call_async_fast((phoneid), (method), 0, 0, 0, 0, (private), \
229 (callback), (can_preempt))
230#define ipc_call_async_1(phoneid, method, arg1, private, callback, \
231 can_preempt) \
232 ipc_call_async_fast((phoneid), (method), (arg1), 0, 0, 0, (private), \
233 (callback), (can_preempt))
234#define ipc_call_async_2(phoneid, method, arg1, arg2, private, callback, \
235 can_preempt) \
236 ipc_call_async_fast((phoneid), (method), (arg1), (arg2), 0, 0, \
237 (private), (callback), (can_preempt))
238#define ipc_call_async_3(phoneid, method, arg1, arg2, arg3, private, callback, \
239 can_preempt) \
240 ipc_call_async_fast((phoneid), (method), (arg1), (arg2), (arg3), 0, \
241 (private), (callback), (can_preempt))
242#define ipc_call_async_4(phoneid, method, arg1, arg2, arg3, arg4, private, \
243 callback, can_preempt) \
244 ipc_call_async_fast((phoneid), (method), (arg1), (arg2), (arg3), \
245 (arg4), (private), (callback), (can_preempt))
246#define ipc_call_async_5(phoneid, method, arg1, arg2, arg3, arg4, arg5, \
247 private, callback, can_preempt) \
248 ipc_call_async_slow((phoneid), (method), (arg1), (arg2), (arg3), \
249 (arg4), (arg5), (private), (callback), (can_preempt))
250
[96b02eb9]251extern void ipc_call_async_fast(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
[10477601]252 sysarg_t, void *, ipc_async_callback_t, bool);
[96b02eb9]253extern void ipc_call_async_slow(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
[10477601]254 sysarg_t, sysarg_t, void *, ipc_async_callback_t, bool);
255
[633bcc6]256extern int ipc_connect_to_me(int, sysarg_t, sysarg_t, sysarg_t, task_id_t *,
[10477601]257 sysarg_t *);
[79ae36dd]258extern int ipc_connect_me(int);
[10477601]259extern int ipc_connect_me_to(int, sysarg_t, sysarg_t, sysarg_t);
260extern int ipc_connect_me_to_blocking(int, sysarg_t, sysarg_t, sysarg_t);
[b1f51f0]261
[161ae09]262extern int ipc_hangup(int);
[10477601]263
264extern int ipc_forward_fast(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,
265 unsigned int);
266extern int ipc_forward_slow(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,
267 sysarg_t, sysarg_t, sysarg_t, unsigned int);
[a55d5f9f]268
[27d293a]269/*
[215e375]270 * User-friendly wrappers for ipc_share_in_start().
[27d293a]271 */
[10477601]272
[fbcdeb8]273#define ipc_share_in_start_0_0(phoneid, size, dst) \
274 ipc_share_in_start((phoneid), (size), 0, NULL, (dst))
275#define ipc_share_in_start_0_1(phoneid, size, flags, dst) \
276 ipc_share_in_start((phoneid), (size), 0, (flags), (dst))
277#define ipc_share_in_start_1_0(phoneid, size, arg, dst) \
278 ipc_share_in_start((phoneid), (size), (arg), NULL, (dst))
279#define ipc_share_in_start_1_1(phoneid, size, arg, flags, dst) \
280 ipc_share_in_start((phoneid), (size), (arg), (flags), (dst))
281
282extern int ipc_share_in_start(int, size_t, sysarg_t, unsigned int *, void **);
[10477601]283extern int ipc_share_in_finalize(ipc_callid_t, void *, unsigned int);
284extern int ipc_share_out_start(int, void *, unsigned int);
[fbcdeb8]285extern int ipc_share_out_finalize(ipc_callid_t, void **);
[161ae09]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.