[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 |
|
---|
[64d2b10] | 42 | #include <ipc/common.h>
|
---|
[c0699467] | 43 | #include <abi/ipc/methods.h>
|
---|
| 44 | #include <abi/synch.h>
|
---|
[1c635d6] | 45 | #include <abi/proc/task.h>
|
---|
[b419162] | 46 |
|
---|
[64d2b10] | 47 | typedef void (*ipc_async_callback_t)(void *, int, ipc_call_t *);
|
---|
[b419162] | 48 |
|
---|
[10477601] | 49 | extern ipc_callid_t ipc_wait_cycle(ipc_call_t *, sysarg_t, unsigned int);
|
---|
[057d21a] | 50 | extern void ipc_poke(void);
|
---|
[ca3ba3a] | 51 |
|
---|
[10477601] | 52 | #define ipc_wait_for_call(data) \
|
---|
| 53 | ipc_wait_for_call_timeout(data, SYNCH_NO_TIMEOUT);
|
---|
[ca3ba3a] | 54 |
|
---|
[10477601] | 55 | extern ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *, sysarg_t);
|
---|
[161ae09] | 56 | extern ipc_callid_t ipc_trywait_for_call(ipc_call_t *);
|
---|
[04a73cdf] | 57 |
|
---|
[b74959bd] | 58 | /*
|
---|
| 59 | * User-friendly wrappers for ipc_answer_fast() and ipc_answer_slow().
|
---|
| 60 | * They are in the form of ipc_answer_m(), where m is the number of return
|
---|
| 61 | * arguments. The macros decide between the fast and the slow version according
|
---|
| 62 | * to m.
|
---|
| 63 | */
|
---|
[10477601] | 64 |
|
---|
[b74959bd] | 65 | #define ipc_answer_0(callid, retval) \
|
---|
[ca3ba3a] | 66 | ipc_answer_fast((callid), (retval), 0, 0, 0, 0)
|
---|
[b74959bd] | 67 | #define ipc_answer_1(callid, retval, arg1) \
|
---|
[ca3ba3a] | 68 | ipc_answer_fast((callid), (retval), (arg1), 0, 0, 0)
|
---|
[b74959bd] | 69 | #define ipc_answer_2(callid, retval, arg1, arg2) \
|
---|
[ca3ba3a] | 70 | ipc_answer_fast((callid), (retval), (arg1), (arg2), 0, 0)
|
---|
[b74959bd] | 71 | #define ipc_answer_3(callid, retval, arg1, arg2, arg3) \
|
---|
[ca3ba3a] | 72 | ipc_answer_fast((callid), (retval), (arg1), (arg2), (arg3), 0)
|
---|
[b74959bd] | 73 | #define ipc_answer_4(callid, retval, arg1, arg2, arg3, arg4) \
|
---|
[ca3ba3a] | 74 | ipc_answer_fast((callid), (retval), (arg1), (arg2), (arg3), (arg4))
|
---|
[b74959bd] | 75 | #define ipc_answer_5(callid, retval, arg1, arg2, arg3, arg4, arg5) \
|
---|
[ca3ba3a] | 76 | ipc_answer_slow((callid), (retval), (arg1), (arg2), (arg3), (arg4), (arg5))
|
---|
[b74959bd] | 77 |
|
---|
[96b02eb9] | 78 | extern sysarg_t ipc_answer_fast(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
|
---|
| 79 | sysarg_t, sysarg_t);
|
---|
| 80 | extern sysarg_t ipc_answer_slow(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
|
---|
| 81 | sysarg_t, sysarg_t, sysarg_t);
|
---|
[b419162] | 82 |
|
---|
[3209923] | 83 | /*
|
---|
| 84 | * User-friendly wrappers for ipc_call_async_fast() and ipc_call_async_slow().
|
---|
| 85 | * They are in the form of ipc_call_async_m(), where m is the number of payload
|
---|
| 86 | * arguments. The macros decide between the fast and the slow version according
|
---|
| 87 | * to m.
|
---|
| 88 | */
|
---|
[10477601] | 89 |
|
---|
[dcc150cb] | 90 | #define ipc_call_async_0(phoneid, method, private, callback) \
|
---|
[7c0e1f5] | 91 | ipc_call_async_fast((phoneid), (method), 0, 0, 0, (private), (callback))
|
---|
[dcc150cb] | 92 | #define ipc_call_async_1(phoneid, method, arg1, private, callback) \
|
---|
[7c0e1f5] | 93 | ipc_call_async_fast((phoneid), (method), (arg1), 0, 0, (private), \
|
---|
[dcc150cb] | 94 | (callback))
|
---|
| 95 | #define ipc_call_async_2(phoneid, method, arg1, arg2, private, callback) \
|
---|
[7c0e1f5] | 96 | ipc_call_async_fast((phoneid), (method), (arg1), (arg2), 0, \
|
---|
[dcc150cb] | 97 | (private), (callback))
|
---|
| 98 | #define ipc_call_async_3(phoneid, method, arg1, arg2, arg3, private, callback) \
|
---|
[7c0e1f5] | 99 | ipc_call_async_fast((phoneid), (method), (arg1), (arg2), (arg3), \
|
---|
[dcc150cb] | 100 | (private), (callback))
|
---|
[3209923] | 101 | #define ipc_call_async_4(phoneid, method, arg1, arg2, arg3, arg4, private, \
|
---|
[dcc150cb] | 102 | callback) \
|
---|
[7c0e1f5] | 103 | ipc_call_async_slow((phoneid), (method), (arg1), (arg2), (arg3), \
|
---|
| 104 | (arg4), 0, (private), (callback))
|
---|
[3209923] | 105 | #define ipc_call_async_5(phoneid, method, arg1, arg2, arg3, arg4, arg5, \
|
---|
[dcc150cb] | 106 | private, callback) \
|
---|
[3209923] | 107 | ipc_call_async_slow((phoneid), (method), (arg1), (arg2), (arg3), \
|
---|
[dcc150cb] | 108 | (arg4), (arg5), (private), (callback))
|
---|
[3209923] | 109 |
|
---|
[96b02eb9] | 110 | extern void ipc_call_async_fast(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
|
---|
[7c0e1f5] | 111 | void *, ipc_async_callback_t);
|
---|
[96b02eb9] | 112 | extern void ipc_call_async_slow(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
|
---|
[dcc150cb] | 113 | sysarg_t, sysarg_t, void *, ipc_async_callback_t);
|
---|
[10477601] | 114 |
|
---|
[161ae09] | 115 | extern int ipc_hangup(int);
|
---|
[10477601] | 116 |
|
---|
| 117 | extern int ipc_forward_fast(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,
|
---|
| 118 | unsigned int);
|
---|
| 119 | extern int ipc_forward_slow(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,
|
---|
| 120 | sysarg_t, sysarg_t, sysarg_t, unsigned int);
|
---|
[a55d5f9f] | 121 |
|
---|
[161ae09] | 122 | extern int ipc_connect_kbox(task_id_t);
|
---|
[9a1b20c] | 123 |
|
---|
[b419162] | 124 | #endif
|
---|
[b2951e2] | 125 |
|
---|
[fadd381] | 126 | /** @}
|
---|
[b2951e2] | 127 | */
|
---|