00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00035 #if ((defined(LIBC_IPC_H_)) && (!defined(LIBC_ASYNC_C_)))
00036 #error Do not intermix low-level IPC interface and async framework
00037 #endif
00038
00039 #ifndef LIBC_ASYNC_H_
00040 #define LIBC_ASYNC_H_
00041
00042 #include <ipc/common.h>
00043 #include <async_sess.h>
00044 #include <fibril.h>
00045 #include <sys/time.h>
00046 #include <atomic.h>
00047 #include <bool.h>
00048 #include <task.h>
00049
00050 typedef ipc_callid_t aid_t;
00051
00052 typedef void *(*async_client_data_ctor_t)(void);
00053 typedef void (*async_client_data_dtor_t)(void *);
00054
00055 typedef void (*async_client_conn_t)(ipc_callid_t, ipc_call_t *);
00056
00057 extern atomic_t threads_in_ipc_wait;
00058
00059 #define async_manager() \
00060 fibril_switch(FIBRIL_TO_MANAGER)
00061
00062 #define async_get_call(data) \
00063 async_get_call_timeout(data, 0)
00064
00065 extern ipc_callid_t async_get_call_timeout(ipc_call_t *, suseconds_t);
00066
00067
00068
00069
00070
00071
00072
00073
00074 #define async_send_0(phoneid, method, dataptr) \
00075 async_send_fast((phoneid), (method), 0, 0, 0, 0, (dataptr))
00076 #define async_send_1(phoneid, method, arg1, dataptr) \
00077 async_send_fast((phoneid), (method), (arg1), 0, 0, 0, (dataptr))
00078 #define async_send_2(phoneid, method, arg1, arg2, dataptr) \
00079 async_send_fast((phoneid), (method), (arg1), (arg2), 0, 0, (dataptr))
00080 #define async_send_3(phoneid, method, arg1, arg2, arg3, dataptr) \
00081 async_send_fast((phoneid), (method), (arg1), (arg2), (arg3), 0, (dataptr))
00082 #define async_send_4(phoneid, method, arg1, arg2, arg3, arg4, dataptr) \
00083 async_send_fast((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
00084 (dataptr))
00085 #define async_send_5(phoneid, method, arg1, arg2, arg3, arg4, arg5, dataptr) \
00086 async_send_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
00087 (arg5), (dataptr))
00088
00089 extern aid_t async_send_fast(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
00090 sysarg_t, ipc_call_t *);
00091 extern aid_t async_send_slow(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
00092 sysarg_t, sysarg_t, ipc_call_t *);
00093 extern void async_wait_for(aid_t, sysarg_t *);
00094 extern int async_wait_timeout(aid_t, sysarg_t *, suseconds_t);
00095
00096 extern fid_t async_new_connection(sysarg_t, sysarg_t, ipc_callid_t,
00097 ipc_call_t *, void (*)(ipc_callid_t, ipc_call_t *));
00098 extern void async_usleep(suseconds_t);
00099 extern void async_create_manager(void);
00100 extern void async_destroy_manager(void);
00101
00102 extern void async_set_client_data_constructor(async_client_data_ctor_t);
00103 extern void async_set_client_data_destructor(async_client_data_dtor_t);
00104
00105 extern void *async_client_data_get(void);
00106
00107 extern void async_set_client_connection(async_client_conn_t);
00108 extern void async_set_interrupt_received(async_client_conn_t);
00109
00110
00111
00112
00113
00114 extern void async_msg_0(int, sysarg_t);
00115 extern void async_msg_1(int, sysarg_t, sysarg_t);
00116 extern void async_msg_2(int, sysarg_t, sysarg_t, sysarg_t);
00117 extern void async_msg_3(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t);
00118 extern void async_msg_4(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t, sysarg_t);
00119 extern void async_msg_5(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
00120 sysarg_t);
00121
00122
00123
00124
00125
00126 extern sysarg_t async_answer_0(ipc_callid_t, sysarg_t);
00127 extern sysarg_t async_answer_1(ipc_callid_t, sysarg_t, sysarg_t);
00128 extern sysarg_t async_answer_2(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t);
00129 extern sysarg_t async_answer_3(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
00130 sysarg_t);
00131 extern sysarg_t async_answer_4(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
00132 sysarg_t, sysarg_t);
00133 extern sysarg_t async_answer_5(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
00134 sysarg_t, sysarg_t, sysarg_t);
00135
00136
00137
00138
00139
00140 extern int async_forward_fast(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,
00141 unsigned int);
00142 extern int async_forward_slow(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,
00143 sysarg_t, sysarg_t, sysarg_t, unsigned int);
00144
00145
00146
00147
00148
00149
00150
00151
00152 #define async_req_0_0(phoneid, method) \
00153 async_req_fast((phoneid), (method), 0, 0, 0, 0, NULL, NULL, NULL, NULL, \
00154 NULL)
00155 #define async_req_0_1(phoneid, method, r1) \
00156 async_req_fast((phoneid), (method), 0, 0, 0, 0, (r1), NULL, NULL, NULL, \
00157 NULL)
00158 #define async_req_0_2(phoneid, method, r1, r2) \
00159 async_req_fast((phoneid), (method), 0, 0, 0, 0, (r1), (r2), NULL, NULL, \
00160 NULL)
00161 #define async_req_0_3(phoneid, method, r1, r2, r3) \
00162 async_req_fast((phoneid), (method), 0, 0, 0, 0, (r1), (r2), (r3), NULL, \
00163 NULL)
00164 #define async_req_0_4(phoneid, method, r1, r2, r3, r4) \
00165 async_req_fast((phoneid), (method), 0, 0, 0, 0, (r1), (r2), (r3), (r4), \
00166 NULL)
00167 #define async_req_0_5(phoneid, method, r1, r2, r3, r4, r5) \
00168 async_req_fast((phoneid), (method), 0, 0, 0, 0, (r1), (r2), (r3), (r4), \
00169 (r5))
00170 #define async_req_1_0(phoneid, method, arg1) \
00171 async_req_fast((phoneid), (method), (arg1), 0, 0, 0, NULL, NULL, NULL, \
00172 NULL, NULL)
00173 #define async_req_1_1(phoneid, method, arg1, rc1) \
00174 async_req_fast((phoneid), (method), (arg1), 0, 0, 0, (rc1), NULL, NULL, \
00175 NULL, NULL)
00176 #define async_req_1_2(phoneid, method, arg1, rc1, rc2) \
00177 async_req_fast((phoneid), (method), (arg1), 0, 0, 0, (rc1), (rc2), NULL, \
00178 NULL, NULL)
00179 #define async_req_1_3(phoneid, method, arg1, rc1, rc2, rc3) \
00180 async_req_fast((phoneid), (method), (arg1), 0, 0, 0, (rc1), (rc2), (rc3), \
00181 NULL, NULL)
00182 #define async_req_1_4(phoneid, method, arg1, rc1, rc2, rc3, rc4) \
00183 async_req_fast((phoneid), (method), (arg1), 0, 0, 0, (rc1), (rc2), (rc3), \
00184 (rc4), NULL)
00185 #define async_req_1_5(phoneid, method, arg1, rc1, rc2, rc3, rc4, rc5) \
00186 async_req_fast((phoneid), (method), (arg1), 0, 0, 0, (rc1), (rc2), (rc3), \
00187 (rc4), (rc5))
00188 #define async_req_2_0(phoneid, method, arg1, arg2) \
00189 async_req_fast((phoneid), (method), (arg1), (arg2), 0, 0, NULL, NULL, \
00190 NULL, NULL, NULL)
00191 #define async_req_2_1(phoneid, method, arg1, arg2, rc1) \
00192 async_req_fast((phoneid), (method), (arg1), (arg2), 0, 0, (rc1), NULL, \
00193 NULL, NULL, NULL)
00194 #define async_req_2_2(phoneid, method, arg1, arg2, rc1, rc2) \
00195 async_req_fast((phoneid), (method), (arg1), (arg2), 0, 0, (rc1), (rc2), \
00196 NULL, NULL, NULL)
00197 #define async_req_2_3(phoneid, method, arg1, arg2, rc1, rc2, rc3) \
00198 async_req_fast((phoneid), (method), (arg1), (arg2), 0, 0, (rc1), (rc2), \
00199 (rc3), NULL, NULL)
00200 #define async_req_2_4(phoneid, method, arg1, arg2, rc1, rc2, rc3, rc4) \
00201 async_req_fast((phoneid), (method), (arg1), (arg2), 0, 0, (rc1), (rc2), \
00202 (rc3), (rc4), NULL)
00203 #define async_req_2_5(phoneid, method, arg1, arg2, rc1, rc2, rc3, rc4, rc5) \
00204 async_req_fast((phoneid), (method), (arg1), (arg2), 0, 0, (rc1), (rc2), \
00205 (rc3), (rc4), (rc5))
00206 #define async_req_3_0(phoneid, method, arg1, arg2, arg3) \
00207 async_req_fast((phoneid), (method), (arg1), (arg2), (arg3), 0, NULL, NULL, \
00208 NULL, NULL, NULL)
00209 #define async_req_3_1(phoneid, method, arg1, arg2, arg3, rc1) \
00210 async_req_fast((phoneid), (method), (arg1), (arg2), (arg3), 0, (rc1), \
00211 NULL, NULL, NULL, NULL)
00212 #define async_req_3_2(phoneid, method, arg1, arg2, arg3, rc1, rc2) \
00213 async_req_fast((phoneid), (method), (arg1), (arg2), (arg3), 0, (rc1), \
00214 (rc2), NULL, NULL, NULL)
00215 #define async_req_3_3(phoneid, method, arg1, arg2, arg3, rc1, rc2, rc3) \
00216 async_req_fast((phoneid), (method), (arg1), (arg2), (arg3), 0, (rc1), \
00217 (rc2), (rc3), NULL, NULL)
00218 #define async_req_3_4(phoneid, method, arg1, arg2, arg3, rc1, rc2, rc3, rc4) \
00219 async_req_fast((phoneid), (method), (arg1), (arg2), (arg3), 0, (rc1), \
00220 (rc2), (rc3), (rc4), NULL)
00221 #define async_req_3_5(phoneid, method, arg1, arg2, arg3, rc1, rc2, rc3, rc4, \
00222 rc5) \
00223 async_req_fast((phoneid), (method), (arg1), (arg2), (arg3), 0, (rc1), \
00224 (rc2), (rc3), (rc4), (rc5))
00225 #define async_req_4_0(phoneid, method, arg1, arg2, arg3, arg4) \
00226 async_req_fast((phoneid), (method), (arg1), (arg2), (arg3), (arg4), NULL, \
00227 NULL, NULL, NULL, NULL)
00228 #define async_req_4_1(phoneid, method, arg1, arg2, arg3, arg4, rc1) \
00229 async_req_fast((phoneid), (method), (arg1), (arg2), (arg3), (arg4), (rc1), \
00230 NULL, NULL, NULL, NULL)
00231 #define async_req_4_2(phoneid, method, arg1, arg2, arg3, arg4, rc1, rc2) \
00232 async_req_fast((phoneid), (method), (arg1), (arg2), (arg3), (arg4), (rc1), \
00233 (rc2), NULL, NULL, NULL)
00234 #define async_req_4_3(phoneid, method, arg1, arg2, arg3, arg4, rc1, rc2, rc3) \
00235 async_req_fast((phoneid), (method), (arg1), (arg2), (arg3), (arg4), (rc1), \
00236 (rc2), (rc3), NULL, NULL)
00237 #define async_req_4_4(phoneid, method, arg1, arg2, arg3, arg4, rc1, rc2, rc3, \
00238 rc4) \
00239 async_req_fast((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
00240 (rc1), (rc2), (rc3), (rc4), NULL)
00241 #define async_req_4_5(phoneid, method, arg1, arg2, arg3, arg4, rc1, rc2, rc3, \
00242 rc4, rc5) \
00243 async_req_fast((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
00244 (rc1), (rc2), (rc3), (rc4), (rc5))
00245 #define async_req_5_0(phoneid, method, arg1, arg2, arg3, arg4, arg5) \
00246 async_req_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
00247 (arg5), NULL, NULL, NULL, NULL, NULL)
00248 #define async_req_5_1(phoneid, method, arg1, arg2, arg3, arg4, arg5, rc1) \
00249 async_req_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
00250 (arg5), (rc1), NULL, NULL, NULL, NULL)
00251 #define async_req_5_2(phoneid, method, arg1, arg2, arg3, arg4, arg5, rc1, rc2) \
00252 async_req_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
00253 (arg5), (rc1), (rc2), NULL, NULL, NULL)
00254 #define async_req_5_3(phoneid, method, arg1, arg2, arg3, arg4, arg5, rc1, rc2, \
00255 rc3) \
00256 async_req_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
00257 (arg5), (rc1), (rc2), (rc3), NULL, NULL)
00258 #define async_req_5_4(phoneid, method, arg1, arg2, arg3, arg4, arg5, rc1, rc2, \
00259 rc3, rc4) \
00260 async_req_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
00261 (arg5), (rc1), (rc2), (rc3), (rc4), NULL)
00262 #define async_req_5_5(phoneid, method, arg1, arg2, arg3, arg4, arg5, rc1, rc2, \
00263 rc3, rc4, rc5) \
00264 async_req_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
00265 (arg5), (rc1), (rc2), (rc3), (rc4), (rc5))
00266
00267 extern sysarg_t async_req_fast(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
00268 sysarg_t, sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *);
00269 extern sysarg_t async_req_slow(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
00270 sysarg_t, sysarg_t, sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *,
00271 sysarg_t *);
00272
00273 static inline void async_serialize_start(void)
00274 {
00275 fibril_inc_sercount();
00276 }
00277
00278 static inline void async_serialize_end(void)
00279 {
00280 fibril_dec_sercount();
00281 }
00282
00283 extern int async_connect_to_me(int, sysarg_t, sysarg_t, sysarg_t,
00284 async_client_conn_t);
00285 extern int async_connect_me_to(int, sysarg_t, sysarg_t, sysarg_t);
00286 extern int async_connect_me_to_blocking(int, sysarg_t, sysarg_t, sysarg_t);
00287 extern int async_connect_kbox(task_id_t);
00288 extern int async_hangup(int);
00289 extern void async_poke(void);
00290
00291
00292
00293
00294
00295 #define async_share_in_start_0_0(phoneid, dst, size) \
00296 async_share_in_start((phoneid), (dst), (size), 0, NULL)
00297 #define async_share_in_start_0_1(phoneid, dst, size, flags) \
00298 async_share_in_start((phoneid), (dst), (size), 0, (flags))
00299 #define async_share_in_start_1_0(phoneid, dst, size, arg) \
00300 async_share_in_start((phoneid), (dst), (size), (arg), NULL)
00301 #define async_share_in_start_1_1(phoneid, dst, size, arg, flags) \
00302 async_share_in_start((phoneid), (dst), (size), (arg), (flags))
00303
00304 extern int async_share_in_start(int, void *, size_t, sysarg_t, unsigned int *);
00305 extern bool async_share_in_receive(ipc_callid_t *, size_t *);
00306 extern int async_share_in_finalize(ipc_callid_t, void *, unsigned int);
00307
00308 extern int async_share_out_start(int, void *, unsigned int);
00309 extern bool async_share_out_receive(ipc_callid_t *, size_t *, unsigned int *);
00310 extern int async_share_out_finalize(ipc_callid_t, void *);
00311
00312
00313
00314
00315
00316 #define async_data_read_forward_0_0(phoneid, method, answer) \
00317 async_data_read_forward_fast((phoneid), (method), 0, 0, 0, 0, NULL)
00318 #define async_data_read_forward_0_1(phoneid, method, answer) \
00319 async_data_read_forward_fast((phoneid), (method), 0, 0, 0, 0, (answer))
00320 #define async_data_read_forward_1_0(phoneid, method, arg1, answer) \
00321 async_data_read_forward_fast((phoneid), (method), (arg1), 0, 0, 0, NULL)
00322 #define async_data_read_forward_1_1(phoneid, method, arg1, answer) \
00323 async_data_read_forward_fast((phoneid), (method), (arg1), 0, 0, 0, (answer))
00324 #define async_data_read_forward_2_0(phoneid, method, arg1, arg2, answer) \
00325 async_data_read_forward_fast((phoneid), (method), (arg1), (arg2), 0, 0, NULL)
00326 #define async_data_read_forward_2_1(phoneid, method, arg1, arg2, answer) \
00327 async_data_read_forward_fast((phoneid), (method), (arg1), (arg2), 0, 0, \
00328 (answer))
00329 #define async_data_read_forward_3_0(phoneid, method, arg1, arg2, arg3, answer) \
00330 async_data_read_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), 0, \
00331 NULL)
00332 #define async_data_read_forward_3_1(phoneid, method, arg1, arg2, arg3, answer) \
00333 async_data_read_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), 0, \
00334 (answer))
00335 #define async_data_read_forward_4_0(phoneid, method, arg1, arg2, arg3, arg4, answer) \
00336 async_data_read_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), \
00337 (arg4), NULL)
00338 #define async_data_read_forward_4_1(phoneid, method, arg1, arg2, arg3, arg4, answer) \
00339 async_data_read_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), \
00340 (arg4), (answer))
00341
00342 extern aid_t async_data_read(int, void *, size_t, ipc_call_t *);
00343 #define async_data_read_start(p, buf, len) \
00344 async_data_read_start_generic((p), (buf), (len), IPC_XF_NONE)
00345
00346 extern int async_data_read_start_generic(int, void *, size_t, int);
00347 extern bool async_data_read_receive(ipc_callid_t *, size_t *);
00348 extern int async_data_read_finalize(ipc_callid_t, const void *, size_t);
00349
00350 extern int async_data_read_forward_fast(int, sysarg_t, sysarg_t, sysarg_t,
00351 sysarg_t, sysarg_t, ipc_call_t *);
00352
00353
00354
00355
00356
00357 #define async_data_write_forward_0_0(phoneid, method, answer) \
00358 async_data_write_forward_fast((phoneid), (method), 0, 0, 0, 0, NULL)
00359 #define async_data_write_forward_0_1(phoneid, method, answer) \
00360 async_data_write_forward_fast((phoneid), (method), 0, 0, 0, 0, (answer))
00361 #define async_data_write_forward_1_0(phoneid, method, arg1, answer) \
00362 async_data_write_forward_fast((phoneid), (method), (arg1), 0, 0, 0, NULL)
00363 #define async_data_write_forward_1_1(phoneid, method, arg1, answer) \
00364 async_data_write_forward_fast((phoneid), (method), (arg1), 0, 0, 0, \
00365 (answer))
00366 #define async_data_write_forward_2_0(phoneid, method, arg1, arg2, answer) \
00367 async_data_write_forward_fast((phoneid), (method), (arg1), (arg2), 0, 0, \
00368 NULL)
00369 #define async_data_write_forward_2_1(phoneid, method, arg1, arg2, answer) \
00370 async_data_write_forward_fast((phoneid), (method), (arg1), (arg2), 0, 0, \
00371 (answer))
00372 #define async_data_write_forward_3_0(phoneid, method, arg1, arg2, arg3, answer) \
00373 async_data_write_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), \
00374 0, NULL)
00375 #define async_data_write_forward_3_1(phoneid, method, arg1, arg2, arg3, answer) \
00376 async_data_write_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), \
00377 0, (answer))
00378 #define async_data_write_forward_4_0(phoneid, method, arg1, arg2, arg3, arg4, answer) \
00379 async_data_write_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), \
00380 (arg4), NULL)
00381 #define async_data_write_forward_4_1(phoneid, method, arg1, arg2, arg3, arg4, answer) \
00382 async_data_write_forward_fast((phoneid), (method), (arg1), (arg2), (arg3), \
00383 (arg4), (answer))
00384
00385 #define async_data_write_start(p, buf, len) \
00386 async_data_write_start_generic((p), (buf), (len), IPC_XF_NONE)
00387
00388 extern int async_data_write_start_generic(int, const void *, size_t, int);
00389 extern bool async_data_write_receive(ipc_callid_t *, size_t *);
00390 extern int async_data_write_finalize(ipc_callid_t, void *, size_t);
00391
00392 extern int async_data_write_accept(void **, const bool, const size_t,
00393 const size_t, const size_t, size_t *);
00394 extern void async_data_write_void(sysarg_t);
00395
00396 extern int async_data_write_forward_fast(int, sysarg_t, sysarg_t, sysarg_t,
00397 sysarg_t, sysarg_t, ipc_call_t *);
00398
00399 #endif
00400