| 1 | /*
|
|---|
| 2 | * Copyright (c) 2006 Ondrej Palkovsky
|
|---|
| 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.
|
|---|
| 27 | */
|
|---|
| 28 |
|
|---|
| 29 | /** @addtogroup libc
|
|---|
| 30 | * @{
|
|---|
| 31 | */
|
|---|
| 32 | /** @file
|
|---|
| 33 | */
|
|---|
| 34 |
|
|---|
| 35 | #if ((defined(LIBC_IPC_H_)) && (!defined(LIBC_ASYNC_C_)))
|
|---|
| 36 | #error Do not intermix low-level IPC interface and async framework
|
|---|
| 37 | #endif
|
|---|
| 38 |
|
|---|
| 39 | #ifndef LIBC_ASYNC_H_
|
|---|
| 40 | #define LIBC_ASYNC_H_
|
|---|
| 41 |
|
|---|
| 42 | #include <ipc/common.h>
|
|---|
| 43 | #include <fibril.h>
|
|---|
| 44 | #include <sys/time.h>
|
|---|
| 45 | #include <atomic.h>
|
|---|
| 46 | #include <stdbool.h>
|
|---|
| 47 | #include <task.h>
|
|---|
| 48 |
|
|---|
| 49 | typedef ipc_callid_t aid_t;
|
|---|
| 50 |
|
|---|
| 51 | typedef void *(*async_client_data_ctor_t)(void);
|
|---|
| 52 | typedef void (*async_client_data_dtor_t)(void *);
|
|---|
| 53 |
|
|---|
| 54 | /** Client connection handler
|
|---|
| 55 | *
|
|---|
| 56 | * @param callid ID of incoming call or 0 if connection initiated from
|
|---|
| 57 | * inside using async_connect_to_me()
|
|---|
| 58 | * @param call Incoming call or 0 if connection initiated from inside
|
|---|
| 59 | * @param arg Local argument passed from async_new_connection() or
|
|---|
| 60 | * async_connect_to_me()
|
|---|
| 61 | */
|
|---|
| 62 | typedef void (*async_client_conn_t)(ipc_callid_t, ipc_call_t *, void *);
|
|---|
| 63 |
|
|---|
| 64 | /** Interrupt handler */
|
|---|
| 65 | typedef void (*async_interrupt_handler_t)(ipc_callid_t, ipc_call_t *);
|
|---|
| 66 |
|
|---|
| 67 | /** Exchange management style
|
|---|
| 68 | *
|
|---|
| 69 | */
|
|---|
| 70 | typedef enum {
|
|---|
| 71 | /** No explicit exchange management
|
|---|
| 72 | *
|
|---|
| 73 | * Suitable for protocols which use a single
|
|---|
| 74 | * IPC message per exchange only.
|
|---|
| 75 | *
|
|---|
| 76 | */
|
|---|
| 77 | EXCHANGE_ATOMIC = 0,
|
|---|
| 78 |
|
|---|
| 79 | /** Exchange management via phone cloning
|
|---|
| 80 | *
|
|---|
| 81 | * Suitable for servers which support client
|
|---|
| 82 | * data tracking by task hashes and do not
|
|---|
| 83 | * mind cloned phones.
|
|---|
| 84 | *
|
|---|
| 85 | */
|
|---|
| 86 | EXCHANGE_PARALLEL,
|
|---|
| 87 |
|
|---|
| 88 | /** Exchange management via mutual exclusion
|
|---|
| 89 | *
|
|---|
| 90 | * Suitable for any kind of client/server communication,
|
|---|
| 91 | * but can limit parallelism.
|
|---|
| 92 | *
|
|---|
| 93 | */
|
|---|
| 94 | EXCHANGE_SERIALIZE
|
|---|
| 95 | } exch_mgmt_t;
|
|---|
| 96 |
|
|---|
| 97 | /** Forward declarations */
|
|---|
| 98 | struct async_exch;
|
|---|
| 99 | struct async_sess;
|
|---|
| 100 |
|
|---|
| 101 | typedef struct async_sess async_sess_t;
|
|---|
| 102 | typedef struct async_exch async_exch_t;
|
|---|
| 103 |
|
|---|
| 104 | extern atomic_t threads_in_ipc_wait;
|
|---|
| 105 |
|
|---|
| 106 | #define async_manager() \
|
|---|
| 107 | fibril_switch(FIBRIL_TO_MANAGER)
|
|---|
| 108 |
|
|---|
| 109 | #define async_get_call(data) \
|
|---|
| 110 | async_get_call_timeout(data, 0)
|
|---|
| 111 |
|
|---|
| 112 | extern ipc_callid_t async_get_call_timeout(ipc_call_t *, suseconds_t);
|
|---|
| 113 |
|
|---|
| 114 | /*
|
|---|
| 115 | * User-friendly wrappers for async_send_fast() and async_send_slow(). The
|
|---|
| 116 | * macros are in the form async_send_m(), where m denotes the number of payload
|
|---|
| 117 | * arguments. Each macros chooses between the fast and the slow version based
|
|---|
| 118 | * on m.
|
|---|
| 119 | */
|
|---|
| 120 |
|
|---|
| 121 | #define async_send_0(exch, method, dataptr) \
|
|---|
| 122 | async_send_fast(exch, method, 0, 0, 0, 0, dataptr)
|
|---|
| 123 | #define async_send_1(exch, method, arg1, dataptr) \
|
|---|
| 124 | async_send_fast(exch, method, arg1, 0, 0, 0, dataptr)
|
|---|
| 125 | #define async_send_2(exch, method, arg1, arg2, dataptr) \
|
|---|
| 126 | async_send_fast(exch, method, arg1, arg2, 0, 0, dataptr)
|
|---|
| 127 | #define async_send_3(exch, method, arg1, arg2, arg3, dataptr) \
|
|---|
| 128 | async_send_fast(exch, method, arg1, arg2, arg3, 0, dataptr)
|
|---|
| 129 | #define async_send_4(exch, method, arg1, arg2, arg3, arg4, dataptr) \
|
|---|
| 130 | async_send_fast(exch, method, arg1, arg2, arg3, arg4, dataptr)
|
|---|
| 131 | #define async_send_5(exch, method, arg1, arg2, arg3, arg4, arg5, dataptr) \
|
|---|
| 132 | async_send_slow(exch, method, arg1, arg2, arg3, arg4, arg5, dataptr)
|
|---|
| 133 |
|
|---|
| 134 | extern aid_t async_send_fast(async_exch_t *, sysarg_t, sysarg_t, sysarg_t,
|
|---|
| 135 | sysarg_t, sysarg_t, ipc_call_t *);
|
|---|
| 136 | extern aid_t async_send_slow(async_exch_t *, sysarg_t, sysarg_t, sysarg_t,
|
|---|
| 137 | sysarg_t, sysarg_t, sysarg_t, ipc_call_t *);
|
|---|
| 138 |
|
|---|
| 139 | extern void async_wait_for(aid_t, sysarg_t *);
|
|---|
| 140 | extern int async_wait_timeout(aid_t, sysarg_t *, suseconds_t);
|
|---|
| 141 | extern void async_forget(aid_t);
|
|---|
| 142 |
|
|---|
| 143 | extern fid_t async_new_connection(task_id_t, sysarg_t, ipc_callid_t,
|
|---|
| 144 | ipc_call_t *, async_client_conn_t, void *);
|
|---|
| 145 |
|
|---|
| 146 | extern void async_usleep(suseconds_t);
|
|---|
| 147 | extern void async_create_manager(void);
|
|---|
| 148 | extern void async_destroy_manager(void);
|
|---|
| 149 |
|
|---|
| 150 | extern void async_set_client_data_constructor(async_client_data_ctor_t);
|
|---|
| 151 | extern void async_set_client_data_destructor(async_client_data_dtor_t);
|
|---|
| 152 | extern void *async_get_client_data(void);
|
|---|
| 153 | extern void *async_get_client_data_by_id(task_id_t);
|
|---|
| 154 | extern void async_put_client_data_by_id(task_id_t);
|
|---|
| 155 |
|
|---|
| 156 | extern void async_set_client_connection(async_client_conn_t);
|
|---|
| 157 | extern void async_set_interrupt_received(async_interrupt_handler_t);
|
|---|
| 158 |
|
|---|
| 159 | /*
|
|---|
| 160 | * Wrappers for simple communication.
|
|---|
| 161 | */
|
|---|
| 162 |
|
|---|
| 163 | extern void async_msg_0(async_exch_t *, sysarg_t);
|
|---|
| 164 | extern void async_msg_1(async_exch_t *, sysarg_t, sysarg_t);
|
|---|
| 165 | extern void async_msg_2(async_exch_t *, sysarg_t, sysarg_t, sysarg_t);
|
|---|
| 166 | extern void async_msg_3(async_exch_t *, sysarg_t, sysarg_t, sysarg_t, sysarg_t);
|
|---|
| 167 | extern void async_msg_4(async_exch_t *, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
|
|---|
| 168 | sysarg_t);
|
|---|
| 169 | extern void async_msg_5(async_exch_t *, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
|
|---|
| 170 | sysarg_t, sysarg_t);
|
|---|
| 171 |
|
|---|
| 172 | /*
|
|---|
| 173 | * Wrappers for answer routines.
|
|---|
| 174 | */
|
|---|
| 175 |
|
|---|
| 176 | extern sysarg_t async_answer_0(ipc_callid_t, sysarg_t);
|
|---|
| 177 | extern sysarg_t async_answer_1(ipc_callid_t, sysarg_t, sysarg_t);
|
|---|
| 178 | extern sysarg_t async_answer_2(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t);
|
|---|
| 179 | extern sysarg_t async_answer_3(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
|
|---|
| 180 | sysarg_t);
|
|---|
| 181 | extern sysarg_t async_answer_4(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
|
|---|
| 182 | sysarg_t, sysarg_t);
|
|---|
| 183 | extern sysarg_t async_answer_5(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
|
|---|
| 184 | sysarg_t, sysarg_t, sysarg_t);
|
|---|
| 185 |
|
|---|
| 186 | /*
|
|---|
| 187 | * Wrappers for forwarding routines.
|
|---|
| 188 | */
|
|---|
| 189 |
|
|---|
| 190 | extern int async_forward_fast(ipc_callid_t, async_exch_t *, sysarg_t, sysarg_t,
|
|---|
| 191 | sysarg_t, unsigned int);
|
|---|
| 192 | extern int async_forward_slow(ipc_callid_t, async_exch_t *, sysarg_t, sysarg_t,
|
|---|
| 193 | sysarg_t, sysarg_t, sysarg_t, sysarg_t, unsigned int);
|
|---|
| 194 |
|
|---|
| 195 | /*
|
|---|
| 196 | * User-friendly wrappers for async_req_fast() and async_req_slow(). The macros
|
|---|
| 197 | * are in the form async_req_m_n(), where m is the number of payload arguments
|
|---|
| 198 | * and n is the number of return arguments. The macros decide between the fast
|
|---|
| 199 | * and slow verion based on m.
|
|---|
| 200 | */
|
|---|
| 201 |
|
|---|
| 202 | #define async_req_0_0(exch, method) \
|
|---|
| 203 | async_req_fast(exch, method, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL)
|
|---|
| 204 | #define async_req_0_1(exch, method, r1) \
|
|---|
| 205 | async_req_fast(exch, method, 0, 0, 0, 0, r1, NULL, NULL, NULL, NULL)
|
|---|
| 206 | #define async_req_0_2(exch, method, r1, r2) \
|
|---|
| 207 | async_req_fast(exch, method, 0, 0, 0, 0, r1, r2, NULL, NULL, NULL)
|
|---|
| 208 | #define async_req_0_3(exch, method, r1, r2, r3) \
|
|---|
| 209 | async_req_fast(exch, method, 0, 0, 0, 0, r1, r2, r3, NULL, NULL)
|
|---|
| 210 | #define async_req_0_4(exch, method, r1, r2, r3, r4) \
|
|---|
| 211 | async_req_fast(exch, method, 0, 0, 0, 0, r1, r2, r3, r4, NULL)
|
|---|
| 212 | #define async_req_0_5(exch, method, r1, r2, r3, r4, r5) \
|
|---|
| 213 | async_req_fast(exch, method, 0, 0, 0, 0, r1, r2, r3, r4, r5)
|
|---|
| 214 |
|
|---|
| 215 | #define async_req_1_0(exch, method, arg1) \
|
|---|
| 216 | async_req_fast(exch, method, arg1, 0, 0, 0, NULL, NULL, NULL, NULL, \
|
|---|
| 217 | NULL)
|
|---|
| 218 | #define async_req_1_1(exch, method, arg1, rc1) \
|
|---|
| 219 | async_req_fast(exch, method, arg1, 0, 0, 0, rc1, NULL, NULL, NULL, \
|
|---|
| 220 | NULL)
|
|---|
| 221 | #define async_req_1_2(exch, method, arg1, rc1, rc2) \
|
|---|
| 222 | async_req_fast(exch, method, arg1, 0, 0, 0, rc1, rc2, NULL, NULL, \
|
|---|
| 223 | NULL)
|
|---|
| 224 | #define async_req_1_3(exch, method, arg1, rc1, rc2, rc3) \
|
|---|
| 225 | async_req_fast(exch, method, arg1, 0, 0, 0, rc1, rc2, rc3, NULL, \
|
|---|
| 226 | NULL)
|
|---|
| 227 | #define async_req_1_4(exch, method, arg1, rc1, rc2, rc3, rc4) \
|
|---|
| 228 | async_req_fast(exch, method, arg1, 0, 0, 0, rc1, rc2, rc3, rc4, \
|
|---|
| 229 | NULL)
|
|---|
| 230 | #define async_req_1_5(exch, method, arg1, rc1, rc2, rc3, rc4, rc5) \
|
|---|
| 231 | async_req_fast(exch, method, arg1, 0, 0, 0, rc1, rc2, rc3, rc4, \
|
|---|
| 232 | rc5)
|
|---|
| 233 |
|
|---|
| 234 | #define async_req_2_0(exch, method, arg1, arg2) \
|
|---|
| 235 | async_req_fast(exch, method, arg1, arg2, 0, 0, NULL, NULL, NULL, \
|
|---|
| 236 | NULL, NULL)
|
|---|
| 237 | #define async_req_2_1(exch, method, arg1, arg2, rc1) \
|
|---|
| 238 | async_req_fast(exch, method, arg1, arg2, 0, 0, rc1, NULL, NULL, \
|
|---|
| 239 | NULL, NULL)
|
|---|
| 240 | #define async_req_2_2(exch, method, arg1, arg2, rc1, rc2) \
|
|---|
| 241 | async_req_fast(exch, method, arg1, arg2, 0, 0, rc1, rc2, NULL, NULL, \
|
|---|
| 242 | NULL)
|
|---|
| 243 | #define async_req_2_3(exch, method, arg1, arg2, rc1, rc2, rc3) \
|
|---|
| 244 | async_req_fast(exch, method, arg1, arg2, 0, 0, rc1, rc2, rc3, NULL, \
|
|---|
| 245 | NULL)
|
|---|
| 246 | #define async_req_2_4(exch, method, arg1, arg2, rc1, rc2, rc3, rc4) \
|
|---|
| 247 | async_req_fast(exch, method, arg1, arg2, 0, 0, rc1, rc2, rc3, rc4, \
|
|---|
| 248 | NULL)
|
|---|
| 249 | #define async_req_2_5(exch, method, arg1, arg2, rc1, rc2, rc3, rc4, rc5) \
|
|---|
| 250 | async_req_fast(exch, method, arg1, arg2, 0, 0, rc1, rc2, rc3, rc4, \
|
|---|
| 251 | rc5)
|
|---|
| 252 |
|
|---|
| 253 | #define async_req_3_0(exch, method, arg1, arg2, arg3) \
|
|---|
| 254 | async_req_fast(exch, method, arg1, arg2, arg3, 0, NULL, NULL, NULL, \
|
|---|
| 255 | NULL, NULL)
|
|---|
| 256 | #define async_req_3_1(exch, method, arg1, arg2, arg3, rc1) \
|
|---|
| 257 | async_req_fast(exch, method, arg1, arg2, arg3, 0, rc1, NULL, NULL, \
|
|---|
| 258 | NULL, NULL)
|
|---|
| 259 | #define async_req_3_2(exch, method, arg1, arg2, arg3, rc1, rc2) \
|
|---|
| 260 | async_req_fast(exch, method, arg1, arg2, arg3, 0, rc1, rc2, NULL, \
|
|---|
| 261 | NULL, NULL)
|
|---|
| 262 | #define async_req_3_3(exch, method, arg1, arg2, arg3, rc1, rc2, rc3) \
|
|---|
| 263 | async_req_fast(exch, method, arg1, arg2, arg3, 0, rc1, rc2, rc3, \
|
|---|
| 264 | NULL, NULL)
|
|---|
| 265 | #define async_req_3_4(exch, method, arg1, arg2, arg3, rc1, rc2, rc3, rc4) \
|
|---|
| 266 | async_req_fast(exch, method, arg1, arg2, arg3, 0, rc1, rc2, rc3, \
|
|---|
| 267 | rc4, NULL)
|
|---|
| 268 | #define async_req_3_5(exch, method, arg1, arg2, arg3, rc1, rc2, rc3, rc4, \
|
|---|
| 269 | rc5) \
|
|---|
| 270 | async_req_fast(exch, method, arg1, arg2, arg3, 0, rc1, rc2, rc3, \
|
|---|
| 271 | rc4, rc5)
|
|---|
| 272 |
|
|---|
| 273 | #define async_req_4_0(exch, method, arg1, arg2, arg3, arg4) \
|
|---|
| 274 | async_req_fast(exch, method, arg1, arg2, arg3, arg4, NULL, NULL, \
|
|---|
| 275 | NULL, NULL, NULL)
|
|---|
| 276 | #define async_req_4_1(exch, method, arg1, arg2, arg3, arg4, rc1) \
|
|---|
| 277 | async_req_fast(exch, method, arg1, arg2, arg3, arg4, rc1, NULL, \
|
|---|
| 278 | NULL, NULL, NULL)
|
|---|
| 279 | #define async_req_4_2(exch, method, arg1, arg2, arg3, arg4, rc1, rc2) \
|
|---|
| 280 | async_req_fast(exch, method, arg1, arg2, arg3, arg4, rc1, rc2, NULL, \
|
|---|
| 281 | NULL, NULL)
|
|---|
| 282 | #define async_req_4_3(exch, method, arg1, arg2, arg3, arg4, rc1, rc2, rc3) \
|
|---|
| 283 | async_req_fast(exch, method, arg1, arg2, arg3, arg4, rc1, rc2, rc3, \
|
|---|
| 284 | NULL, NULL)
|
|---|
| 285 | #define async_req_4_4(exch, method, arg1, arg2, arg3, arg4, rc1, rc2, rc3, \
|
|---|
| 286 | rc4) \
|
|---|
| 287 | async_req_fast(exch, method, arg1, arg2, arg3, arg4, rc1, rc2, rc3, \
|
|---|
| 288 | rc4, NULL)
|
|---|
| 289 | #define async_req_4_5(exch, method, arg1, arg2, arg3, arg4, rc1, rc2, rc3, \
|
|---|
| 290 | rc4, rc5) \
|
|---|
| 291 | async_req_fast(exch, method, arg1, arg2, arg3, arg4, rc1, rc2, rc3, \
|
|---|
| 292 | rc4, rc5)
|
|---|
| 293 |
|
|---|
| 294 | #define async_req_5_0(exch, method, arg1, arg2, arg3, arg4, arg5) \
|
|---|
| 295 | async_req_slow(exch, method, arg1, arg2, arg3, arg4, arg5, NULL, \
|
|---|
| 296 | NULL, NULL, NULL, NULL)
|
|---|
| 297 | #define async_req_5_1(exch, method, arg1, arg2, arg3, arg4, arg5, rc1) \
|
|---|
| 298 | async_req_slow(exch, method, arg1, arg2, arg3, arg4, arg5, rc1, \
|
|---|
| 299 | NULL, NULL, NULL, NULL)
|
|---|
| 300 | #define async_req_5_2(exch, method, arg1, arg2, arg3, arg4, arg5, rc1, rc2) \
|
|---|
| 301 | async_req_slow(exch, method, arg1, arg2, arg3, arg4, arg5, rc1, rc2, \
|
|---|
| 302 | NULL, NULL, NULL)
|
|---|
| 303 | #define async_req_5_3(exch, method, arg1, arg2, arg3, arg4, arg5, rc1, rc2, \
|
|---|
| 304 | rc3) \
|
|---|
| 305 | async_req_slow(exch, method, arg1, arg2, arg3, arg4, arg5, rc1, rc2, \
|
|---|
| 306 | rc3, NULL, NULL)
|
|---|
| 307 | #define async_req_5_4(exch, method, arg1, arg2, arg3, arg4, arg5, rc1, rc2, \
|
|---|
| 308 | rc3, rc4) \
|
|---|
| 309 | async_req_slow(exch, method, arg1, arg2, arg3, arg4, arg5, rc1, rc2, \
|
|---|
| 310 | rc3, rc4, NULL)
|
|---|
| 311 | #define async_req_5_5(exch, method, arg1, arg2, arg3, arg4, arg5, rc1, rc2, \
|
|---|
| 312 | rc3, rc4, rc5) \
|
|---|
| 313 | async_req_slow(exch, method, arg1, arg2, arg3, arg4, arg5, rc1, rc2, \
|
|---|
| 314 | rc3, rc4, rc5)
|
|---|
| 315 |
|
|---|
| 316 | extern sysarg_t async_req_fast(async_exch_t *, sysarg_t, sysarg_t, sysarg_t,
|
|---|
| 317 | sysarg_t, sysarg_t, sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *,
|
|---|
| 318 | sysarg_t *);
|
|---|
| 319 | extern sysarg_t async_req_slow(async_exch_t *, sysarg_t, sysarg_t, sysarg_t,
|
|---|
| 320 | sysarg_t, sysarg_t, sysarg_t, sysarg_t *, sysarg_t *, sysarg_t *,
|
|---|
| 321 | sysarg_t *, sysarg_t *);
|
|---|
| 322 |
|
|---|
| 323 | extern async_sess_t *async_clone_establish(exch_mgmt_t, async_exch_t *);
|
|---|
| 324 | extern async_sess_t *async_connect_me_to(exch_mgmt_t, async_exch_t *, sysarg_t,
|
|---|
| 325 | sysarg_t, sysarg_t);
|
|---|
| 326 | extern async_sess_t *async_connect_me_to_blocking(exch_mgmt_t, async_exch_t *,
|
|---|
| 327 | sysarg_t, sysarg_t, sysarg_t);
|
|---|
| 328 | extern async_sess_t *async_connect_kbox(task_id_t);
|
|---|
| 329 |
|
|---|
| 330 | extern int async_connect_to_me(async_exch_t *, sysarg_t, sysarg_t, sysarg_t,
|
|---|
| 331 | async_client_conn_t, void *);
|
|---|
| 332 |
|
|---|
| 333 | extern int async_hangup(async_sess_t *);
|
|---|
| 334 | extern void async_poke(void);
|
|---|
| 335 |
|
|---|
| 336 | extern async_exch_t *async_exchange_begin(async_sess_t *);
|
|---|
| 337 | extern void async_exchange_end(async_exch_t *);
|
|---|
| 338 |
|
|---|
| 339 | /*
|
|---|
| 340 | * FIXME These functions just work around problems with parallel exchange
|
|---|
| 341 | * management. Proper solution needs to be implemented.
|
|---|
| 342 | */
|
|---|
| 343 | void async_sess_args_set(async_sess_t *sess, sysarg_t, sysarg_t, sysarg_t);
|
|---|
| 344 |
|
|---|
| 345 | /*
|
|---|
| 346 | * User-friendly wrappers for async_share_in_start().
|
|---|
| 347 | */
|
|---|
| 348 |
|
|---|
| 349 | #define async_share_in_start_0_0(exch, size, dst) \
|
|---|
| 350 | async_share_in_start(exch, size, 0, NULL, dst)
|
|---|
| 351 | #define async_share_in_start_0_1(exch, size, flags, dst) \
|
|---|
| 352 | async_share_in_start(exch, size, 0, flags, dst)
|
|---|
| 353 | #define async_share_in_start_1_0(exch, size, arg, dst) \
|
|---|
| 354 | async_share_in_start(exch, size, arg, NULL, dst)
|
|---|
| 355 | #define async_share_in_start_1_1(exch, size, arg, flags, dst) \
|
|---|
| 356 | async_share_in_start(exch, size, arg, flags, dst)
|
|---|
| 357 |
|
|---|
| 358 | extern int async_share_in_start(async_exch_t *, size_t, sysarg_t,
|
|---|
| 359 | unsigned int *, void **);
|
|---|
| 360 | extern bool async_share_in_receive(ipc_callid_t *, size_t *);
|
|---|
| 361 | extern int async_share_in_finalize(ipc_callid_t, void *, unsigned int);
|
|---|
| 362 |
|
|---|
| 363 | extern int async_share_out_start(async_exch_t *, void *, unsigned int);
|
|---|
| 364 | extern bool async_share_out_receive(ipc_callid_t *, size_t *, unsigned int *);
|
|---|
| 365 | extern int async_share_out_finalize(ipc_callid_t, void **);
|
|---|
| 366 |
|
|---|
| 367 | /*
|
|---|
| 368 | * User-friendly wrappers for async_data_read_forward_fast().
|
|---|
| 369 | */
|
|---|
| 370 |
|
|---|
| 371 | #define async_data_read_forward_0_0(exch, method, answer) \
|
|---|
| 372 | async_data_read_forward_fast(exch, method, 0, 0, 0, 0, NULL)
|
|---|
| 373 | #define async_data_read_forward_0_1(exch, method, answer) \
|
|---|
| 374 | async_data_read_forward_fast(exch, method, 0, 0, 0, 0, answer)
|
|---|
| 375 | #define async_data_read_forward_1_0(exch, method, arg1, answer) \
|
|---|
| 376 | async_data_read_forward_fast(exch, method, arg1, 0, 0, 0, NULL)
|
|---|
| 377 | #define async_data_read_forward_1_1(exch, method, arg1, answer) \
|
|---|
| 378 | async_data_read_forward_fast(exch, method, arg1, 0, 0, 0, answer)
|
|---|
| 379 | #define async_data_read_forward_2_0(exch, method, arg1, arg2, answer) \
|
|---|
| 380 | async_data_read_forward_fast(exch, method, arg1, arg2, 0, 0, NULL)
|
|---|
| 381 | #define async_data_read_forward_2_1(exch, method, arg1, arg2, answer) \
|
|---|
| 382 | async_data_read_forward_fast(exch, method, arg1, arg2, 0, 0, answer)
|
|---|
| 383 | #define async_data_read_forward_3_0(exch, method, arg1, arg2, arg3, answer) \
|
|---|
| 384 | async_data_read_forward_fast(exch, method, arg1, arg2, arg3, 0, NULL)
|
|---|
| 385 | #define async_data_read_forward_3_1(exch, method, arg1, arg2, arg3, answer) \
|
|---|
| 386 | async_data_read_forward_fast(exch, method, arg1, arg2, arg3, 0, \
|
|---|
| 387 | answer)
|
|---|
| 388 | #define async_data_read_forward_4_0(exch, method, arg1, arg2, arg3, arg4, \
|
|---|
| 389 | answer) \
|
|---|
| 390 | async_data_read_forward_fast(exch, method, arg1, arg2, arg3, arg4, \
|
|---|
| 391 | NULL)
|
|---|
| 392 | #define async_data_read_forward_4_1(exch, method, arg1, arg2, arg3, arg4, \
|
|---|
| 393 | answer) \
|
|---|
| 394 | async_data_read_forward_fast(exch, method, arg1, arg2, arg3, arg4, \
|
|---|
| 395 | answer)
|
|---|
| 396 |
|
|---|
| 397 | extern aid_t async_data_read(async_exch_t *, void *, size_t, ipc_call_t *);
|
|---|
| 398 | extern int async_data_read_start(async_exch_t *, void *, size_t);
|
|---|
| 399 | extern bool async_data_read_receive(ipc_callid_t *, size_t *);
|
|---|
| 400 | extern int async_data_read_finalize(ipc_callid_t, const void *, size_t);
|
|---|
| 401 |
|
|---|
| 402 | extern int async_data_read_forward_fast(async_exch_t *, sysarg_t, sysarg_t,
|
|---|
| 403 | sysarg_t, sysarg_t, sysarg_t, ipc_call_t *);
|
|---|
| 404 |
|
|---|
| 405 | /*
|
|---|
| 406 | * User-friendly wrappers for async_data_write_forward_fast().
|
|---|
| 407 | */
|
|---|
| 408 |
|
|---|
| 409 | #define async_data_write_forward_0_0(exch, method, answer) \
|
|---|
| 410 | async_data_write_forward_fast(exch, method, 0, 0, 0, 0, NULL)
|
|---|
| 411 | #define async_data_write_forward_0_1(exch, method, answer) \
|
|---|
| 412 | async_data_write_forward_fast(exch, method, 0, 0, 0, 0, answer)
|
|---|
| 413 | #define async_data_write_forward_1_0(exch, method, arg1, answer) \
|
|---|
| 414 | async_data_write_forward_fast(exch, method, arg1, 0, 0, 0, NULL)
|
|---|
| 415 | #define async_data_write_forward_1_1(exch, method, arg1, answer) \
|
|---|
| 416 | async_data_write_forward_fast(exch, method, arg1, 0, 0, 0, answer)
|
|---|
| 417 | #define async_data_write_forward_2_0(exch, method, arg1, arg2, answer) \
|
|---|
| 418 | async_data_write_forward_fast(exch, method, arg1, arg2, 0, 0, NULL)
|
|---|
| 419 | #define async_data_write_forward_2_1(exch, method, arg1, arg2, answer) \
|
|---|
| 420 | async_data_write_forward_fast(exch, method, arg1, arg2, 0, 0, answer)
|
|---|
| 421 | #define async_data_write_forward_3_0(exch, method, arg1, arg2, arg3, answer) \
|
|---|
| 422 | async_data_write_forward_fast(exch, method, arg1, arg2, arg3, 0, \
|
|---|
| 423 | NULL)
|
|---|
| 424 | #define async_data_write_forward_3_1(exch, method, arg1, arg2, arg3, answer) \
|
|---|
| 425 | async_data_write_forward_fast(exch, method, arg1, arg2, arg3, 0, \
|
|---|
| 426 | answer)
|
|---|
| 427 | #define async_data_write_forward_4_0(exch, method, arg1, arg2, arg3, arg4, \
|
|---|
| 428 | answer) \
|
|---|
| 429 | async_data_write_forward_fast(exch, method, arg1, arg2, arg3, arg4, \
|
|---|
| 430 | NULL)
|
|---|
| 431 | #define async_data_write_forward_4_1(exch, method, arg1, arg2, arg3, arg4, \
|
|---|
| 432 | answer) \
|
|---|
| 433 | async_data_write_forward_fast(exch, method, arg1, arg2, arg3, arg4, \
|
|---|
| 434 | answer)
|
|---|
| 435 |
|
|---|
| 436 | extern int async_data_write_start(async_exch_t *, const void *, size_t);
|
|---|
| 437 | extern bool async_data_write_receive(ipc_callid_t *, size_t *);
|
|---|
| 438 | extern int async_data_write_finalize(ipc_callid_t, void *, size_t);
|
|---|
| 439 |
|
|---|
| 440 | extern int async_data_write_accept(void **, const bool, const size_t,
|
|---|
| 441 | const size_t, const size_t, size_t *);
|
|---|
| 442 | extern void async_data_write_void(sysarg_t);
|
|---|
| 443 |
|
|---|
| 444 | extern int async_data_write_forward_fast(async_exch_t *, sysarg_t, sysarg_t,
|
|---|
| 445 | sysarg_t, sysarg_t, sysarg_t, ipc_call_t *);
|
|---|
| 446 |
|
|---|
| 447 | extern int async_exchange_clone(async_exch_t *, async_exch_t *);
|
|---|
| 448 | extern async_sess_t *async_clone_receive(exch_mgmt_t);
|
|---|
| 449 | extern async_sess_t *async_callback_receive(exch_mgmt_t);
|
|---|
| 450 | extern async_sess_t *async_callback_receive_start(exch_mgmt_t, ipc_call_t *);
|
|---|
| 451 |
|
|---|
| 452 | extern int async_state_change_start(async_exch_t *, sysarg_t, sysarg_t,
|
|---|
| 453 | sysarg_t, async_exch_t *);
|
|---|
| 454 | extern bool async_state_change_receive(ipc_callid_t *, sysarg_t *, sysarg_t *,
|
|---|
| 455 | sysarg_t *);
|
|---|
| 456 | extern int async_state_change_finalize(ipc_callid_t, async_exch_t *);
|
|---|
| 457 |
|
|---|
| 458 | extern void *async_remote_state_acquire(async_sess_t *);
|
|---|
| 459 | extern void async_remote_state_update(async_sess_t *, void *);
|
|---|
| 460 | extern void async_remote_state_release(async_sess_t *);
|
|---|
| 461 | extern void async_remote_state_release_exchange(async_exch_t *);
|
|---|
| 462 |
|
|---|
| 463 | #endif
|
|---|
| 464 |
|
|---|
| 465 | /** @}
|
|---|
| 466 | */
|
|---|