Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/async.h

    r8bf1eeb rc1c0184  
    3333 */
    3434
    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 
    3935#ifndef LIBC_ASYNC_H_
    4036#define LIBC_ASYNC_H_
    4137
    42 #include <ipc/common.h>
     38#include <ipc/ipc.h>
    4339#include <async_sess.h>
    4440#include <fibril.h>
     
    4642#include <atomic.h>
    4743#include <bool.h>
    48 #include <task.h>
    4944
    5045typedef ipc_callid_t aid_t;
    51 
    52 typedef void *(*async_client_data_ctor_t)(void);
    53 typedef void (*async_client_data_dtor_t)(void *);
    54 
    55 typedef void (*async_client_conn_t)(ipc_callid_t, ipc_call_t *);
     46typedef void (*async_client_conn_t)(ipc_callid_t callid, ipc_call_t *call);
     47
     48extern atomic_t async_futex;
    5649
    5750extern atomic_t threads_in_ipc_wait;
    5851
    59 #define async_manager() \
    60         fibril_switch(FIBRIL_TO_MANAGER)
    61 
    62 #define async_get_call(data) \
    63         async_get_call_timeout(data, 0)
    64 
    65 extern ipc_callid_t async_get_call_timeout(ipc_call_t *, suseconds_t);
     52extern int __async_init(void);
     53extern ipc_callid_t async_get_call_timeout(ipc_call_t *call, suseconds_t usecs);
     54
     55static inline ipc_callid_t async_get_call(ipc_call_t *data)
     56{
     57        return async_get_call_timeout(data, 0);
     58}
     59
     60static inline void async_manager(void)
     61{
     62        fibril_switch(FIBRIL_TO_MANAGER);
     63}
    6664
    6765/*
     
    8785            (arg5), (dataptr))
    8886
    89 extern aid_t async_send_fast(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
    90     sysarg_t, ipc_call_t *);
    91 extern aid_t async_send_slow(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
    92     sysarg_t, sysarg_t, ipc_call_t *);
    93 extern void async_wait_for(aid_t, sysarg_t *);
    94 extern int async_wait_timeout(aid_t, sysarg_t *, suseconds_t);
    95 
    96 extern fid_t async_new_connection(sysarg_t, sysarg_t, ipc_callid_t,
    97     ipc_call_t *, void (*)(ipc_callid_t, ipc_call_t *));
    98 extern void async_usleep(suseconds_t);
     87extern aid_t async_send_fast(int phoneid, sysarg_t method, sysarg_t arg1,
     88    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, ipc_call_t *dataptr);
     89extern aid_t async_send_slow(int phoneid, sysarg_t method, sysarg_t arg1,
     90    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5,
     91    ipc_call_t *dataptr);
     92extern void async_wait_for(aid_t amsgid, sysarg_t *result);
     93extern int async_wait_timeout(aid_t amsgid, sysarg_t *retval,
     94    suseconds_t timeout);
     95
     96extern fid_t async_new_connection(sysarg_t in_phone_hash, ipc_callid_t callid,
     97    ipc_call_t *call, void (*cthread)(ipc_callid_t, ipc_call_t *));
     98extern void async_usleep(suseconds_t timeout);
    9999extern void async_create_manager(void);
    100100extern void async_destroy_manager(void);
    101101
    102 extern void async_set_client_data_constructor(async_client_data_ctor_t);
    103 extern void async_set_client_data_destructor(async_client_data_dtor_t);
    104 
    105 extern void *async_client_data_get(void);
    106 
    107 extern void async_set_client_connection(async_client_conn_t);
    108 extern void async_set_interrupt_received(async_client_conn_t);
    109 
    110 /*
    111  * Wrappers for simple communication.
    112  */
    113 
    114 extern void async_msg_0(int, sysarg_t);
    115 extern void async_msg_1(int, sysarg_t, sysarg_t);
    116 extern void async_msg_2(int, sysarg_t, sysarg_t, sysarg_t);
    117 extern void async_msg_3(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t);
    118 extern void async_msg_4(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t, sysarg_t);
    119 extern void async_msg_5(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
    120     sysarg_t);
    121 
    122 /*
    123  * Wrappers for answer routines.
    124  */
    125 
    126 extern sysarg_t async_answer_0(ipc_callid_t, sysarg_t);
    127 extern sysarg_t async_answer_1(ipc_callid_t, sysarg_t, sysarg_t);
    128 extern sysarg_t async_answer_2(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t);
    129 extern sysarg_t async_answer_3(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
    130     sysarg_t);
    131 extern sysarg_t async_answer_4(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
    132     sysarg_t, sysarg_t);
    133 extern sysarg_t async_answer_5(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
    134     sysarg_t, sysarg_t, sysarg_t);
    135 
    136 /*
    137  * Wrappers for forwarding routines.
    138  */
    139 
    140 extern int async_forward_fast(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,
    141     unsigned int);
    142 extern int async_forward_slow(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,
    143     sysarg_t, sysarg_t, sysarg_t, unsigned int);
     102extern void async_set_client_connection(async_client_conn_t conn);
     103extern void async_set_interrupt_received(async_client_conn_t conn);
     104
     105/* Wrappers for simple communication */
     106#define async_msg_0(phone, method) \
     107        ipc_call_async_0((phone), (method), NULL, NULL, true)
     108#define async_msg_1(phone, method, arg1) \
     109        ipc_call_async_1((phone), (method), (arg1), NULL, NULL, \
     110            true)
     111#define async_msg_2(phone, method, arg1, arg2) \
     112        ipc_call_async_2((phone), (method), (arg1), (arg2), NULL, NULL, \
     113            true)
     114#define async_msg_3(phone, method, arg1, arg2, arg3) \
     115        ipc_call_async_3((phone), (method), (arg1), (arg2), (arg3), NULL, NULL, \
     116            true)
     117#define async_msg_4(phone, method, arg1, arg2, arg3, arg4) \
     118        ipc_call_async_4((phone), (method), (arg1), (arg2), (arg3), (arg4), NULL, \
     119            NULL, true)
     120#define async_msg_5(phone, method, arg1, arg2, arg3, arg4, arg5) \
     121        ipc_call_async_5((phone), (method), (arg1), (arg2), (arg3), (arg4), \
     122            (arg5), NULL, NULL, true)
    144123
    145124/*
     
    149128 * and slow verion based on m.
    150129 */
    151 
    152130#define async_req_0_0(phoneid, method) \
    153131        async_req_fast((phoneid), (method), 0, 0, 0, 0, NULL, NULL, NULL, NULL, \
     
    265243            (arg5), (rc1), (rc2), (rc3), (rc4), (rc5))
    266244
    267 extern sysarg_t async_req_fast(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
    268     sysarg_t, sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *);
    269 extern sysarg_t async_req_slow(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
    270     sysarg_t, sysarg_t, sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *,
    271     sysarg_t *);
     245extern sysarg_t async_req_fast(int phoneid, sysarg_t method, sysarg_t arg1,
     246    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t *r1, sysarg_t *r2,
     247    sysarg_t *r3, sysarg_t *r4, sysarg_t *r5);
     248extern sysarg_t async_req_slow(int phoneid, sysarg_t method, sysarg_t arg1,
     249    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, sysarg_t *r1,
     250    sysarg_t *r2, sysarg_t *r3, sysarg_t *r4, sysarg_t *r5);
    272251
    273252static inline void async_serialize_start(void)
     
    281260}
    282261
    283 extern int async_connect_to_me(int, sysarg_t, sysarg_t, sysarg_t,
    284     async_client_conn_t);
    285262extern int async_connect_me_to(int, sysarg_t, sysarg_t, sysarg_t);
    286263extern int async_connect_me_to_blocking(int, sysarg_t, sysarg_t, sysarg_t);
    287 extern int async_connect_kbox(task_id_t);
    288 extern int async_hangup(int);
    289 extern void async_poke(void);
    290264
    291265/*
    292266 * User-friendly wrappers for async_share_in_start().
    293267 */
    294 
    295268#define async_share_in_start_0_0(phoneid, dst, size) \
    296269        async_share_in_start((phoneid), (dst), (size), 0, NULL)
     
    302275        async_share_in_start((phoneid), (dst), (size), (arg), (flags))
    303276
    304 extern int async_share_in_start(int, void *, size_t, sysarg_t, unsigned int *);
    305 extern bool async_share_in_receive(ipc_callid_t *, size_t *);
    306 extern int async_share_in_finalize(ipc_callid_t, void *, unsigned int);
    307 
    308 extern int async_share_out_start(int, void *, unsigned int);
    309 extern bool async_share_out_receive(ipc_callid_t *, size_t *, unsigned int *);
     277extern int async_share_in_start(int, void *, size_t, sysarg_t, int *);
     278extern int async_share_in_receive(ipc_callid_t *, size_t *);
     279extern int async_share_in_finalize(ipc_callid_t, void *, int );
     280extern int async_share_out_start(int, void *, int);
     281extern int async_share_out_receive(ipc_callid_t *, size_t *, int *);
    310282extern int async_share_out_finalize(ipc_callid_t, void *);
    311283
     
    313285 * User-friendly wrappers for async_data_read_forward_fast().
    314286 */
    315 
    316287#define async_data_read_forward_0_0(phoneid, method, answer) \
    317288        async_data_read_forward_fast((phoneid), (method), 0, 0, 0, 0, NULL)
     
    340311            (arg4), (answer))
    341312
    342 extern aid_t async_data_read(int, void *, size_t, ipc_call_t *);
    343313extern int async_data_read_start(int, void *, size_t);
    344 extern bool async_data_read_receive(ipc_callid_t *, size_t *);
     314extern int async_data_read_receive(ipc_callid_t *, size_t *);
    345315extern int async_data_read_finalize(ipc_callid_t, const void *, size_t);
    346316
     
    351321 * User-friendly wrappers for async_data_write_forward_fast().
    352322 */
    353 
    354323#define async_data_write_forward_0_0(phoneid, method, answer) \
    355324        async_data_write_forward_fast((phoneid), (method), 0, 0, 0, 0, NULL)
     
    381350
    382351extern int async_data_write_start(int, const void *, size_t);
    383 extern bool async_data_write_receive(ipc_callid_t *, size_t *);
     352extern int async_data_write_receive(ipc_callid_t *, size_t *);
    384353extern int async_data_write_finalize(ipc_callid_t, void *, size_t);
    385354
    386355extern int async_data_write_accept(void **, const bool, const size_t,
    387356    const size_t, const size_t, size_t *);
    388 extern void async_data_write_void(sysarg_t);
     357extern void async_data_write_void(const int);
    389358
    390359extern int async_data_write_forward_fast(int, sysarg_t, sysarg_t, sysarg_t,
Note: See TracChangeset for help on using the changeset viewer.