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