Ignore:
File:
1 edited

Legend:

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

    r63f8966 r8e80d3f  
    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
    3539#ifndef LIBC_ASYNC_H_
    3640#define LIBC_ASYNC_H_
    3741
    38 #include <ipc/ipc.h>
     42#include <ipc/common.h>
     43#include <async_sess.h>
    3944#include <fibril.h>
    4045#include <sys/time.h>
    4146#include <atomic.h>
    4247#include <bool.h>
     48#include <task.h>
    4349
    4450typedef ipc_callid_t aid_t;
    45 typedef void (*async_client_conn_t)(ipc_callid_t callid, ipc_call_t *call);
    46 
    47 extern atomic_t async_futex;
     51
     52typedef void *(*async_client_data_ctor_t)(void);
     53typedef void (*async_client_data_dtor_t)(void *);
     54
     55typedef void (*async_client_conn_t)(ipc_callid_t, ipc_call_t *);
    4856
    4957extern atomic_t threads_in_ipc_wait;
    5058
    51 extern int __async_init(void);
    52 extern ipc_callid_t async_get_call_timeout(ipc_call_t *call, suseconds_t usecs);
    53 
    54 static inline ipc_callid_t async_get_call(ipc_call_t *data)
    55 {
    56         return async_get_call_timeout(data, 0);
    57 }
    58 
    59 static inline void async_manager(void)
    60 {
    61         fibril_switch(FIBRIL_TO_MANAGER);
    62 }
     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
     65extern ipc_callid_t async_get_call_timeout(ipc_call_t *, suseconds_t);
    6366
    6467/*
     
    8487            (arg5), (dataptr))
    8588
    86 extern aid_t async_send_fast(int phoneid, ipcarg_t method, ipcarg_t arg1,
    87     ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipc_call_t *dataptr);
    88 extern aid_t async_send_slow(int phoneid, ipcarg_t method, ipcarg_t arg1,
    89     ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5,
    90     ipc_call_t *dataptr);
    91 extern void async_wait_for(aid_t amsgid, ipcarg_t *result);
    92 extern int async_wait_timeout(aid_t amsgid, ipcarg_t *retval,
    93     suseconds_t timeout);
    94 
    95 extern fid_t async_new_connection(ipcarg_t in_phone_hash, ipc_callid_t callid,
    96     ipc_call_t *call, void (*cthread)(ipc_callid_t, ipc_call_t *));
    97 extern void async_usleep(suseconds_t timeout);
     89extern aid_t async_send_fast(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
     90    sysarg_t, ipc_call_t *);
     91extern aid_t async_send_slow(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
     92    sysarg_t, sysarg_t, ipc_call_t *);
     93extern void async_wait_for(aid_t, sysarg_t *);
     94extern int async_wait_timeout(aid_t, sysarg_t *, suseconds_t);
     95
     96extern fid_t async_new_connection(sysarg_t, sysarg_t, ipc_callid_t,
     97    ipc_call_t *, void (*)(ipc_callid_t, ipc_call_t *));
     98extern void async_usleep(suseconds_t);
    9899extern void async_create_manager(void);
    99100extern void async_destroy_manager(void);
    100101
    101 extern void async_set_client_connection(async_client_conn_t conn);
    102 extern void async_set_interrupt_received(async_client_conn_t conn);
    103 
    104 /* Wrappers for simple communication */
    105 #define async_msg_0(phone, method) \
    106         ipc_call_async_0((phone), (method), NULL, NULL, true)
    107 #define async_msg_1(phone, method, arg1) \
    108         ipc_call_async_1((phone), (method), (arg1), NULL, NULL, \
    109             true)
    110 #define async_msg_2(phone, method, arg1, arg2) \
    111         ipc_call_async_2((phone), (method), (arg1), (arg2), NULL, NULL, \
    112             true)
    113 #define async_msg_3(phone, method, arg1, arg2, arg3) \
    114         ipc_call_async_3((phone), (method), (arg1), (arg2), (arg3), NULL, NULL, \
    115             true)
    116 #define async_msg_4(phone, method, arg1, arg2, arg3, arg4) \
    117         ipc_call_async_4((phone), (method), (arg1), (arg2), (arg3), (arg4), NULL, \
    118             NULL, true)
    119 #define async_msg_5(phone, method, arg1, arg2, arg3, arg4, arg5) \
    120         ipc_call_async_5((phone), (method), (arg1), (arg2), (arg3), (arg4), \
    121             (arg5), NULL, NULL, true)
     102extern void async_set_client_data_constructor(async_client_data_ctor_t);
     103extern void async_set_client_data_destructor(async_client_data_dtor_t);
     104
     105extern void *async_client_data_get(void);
     106
     107extern void async_set_client_connection(async_client_conn_t);
     108extern void async_set_interrupt_received(async_client_conn_t);
     109
     110/*
     111 * Wrappers for simple communication.
     112 */
     113
     114extern void async_msg_0(int, sysarg_t);
     115extern void async_msg_1(int, sysarg_t, sysarg_t);
     116extern void async_msg_2(int, sysarg_t, sysarg_t, sysarg_t);
     117extern void async_msg_3(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t);
     118extern void async_msg_4(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t, sysarg_t);
     119extern 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
     126extern sysarg_t async_answer_0(ipc_callid_t, sysarg_t);
     127extern sysarg_t async_answer_1(ipc_callid_t, sysarg_t, sysarg_t);
     128extern sysarg_t async_answer_2(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t);
     129extern sysarg_t async_answer_3(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
     130    sysarg_t);
     131extern sysarg_t async_answer_4(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
     132    sysarg_t, sysarg_t);
     133extern 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
     140extern int async_forward_fast(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,
     141    unsigned int);
     142extern int async_forward_slow(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,
     143    sysarg_t, sysarg_t, sysarg_t, unsigned int);
    122144
    123145/*
     
    127149 * and slow verion based on m.
    128150 */
     151
    129152#define async_req_0_0(phoneid, method) \
    130153        async_req_fast((phoneid), (method), 0, 0, 0, 0, NULL, NULL, NULL, NULL, \
     
    242265            (arg5), (rc1), (rc2), (rc3), (rc4), (rc5))
    243266
    244 extern ipcarg_t async_req_fast(int phoneid, ipcarg_t method, ipcarg_t arg1,
    245     ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t *r1, ipcarg_t *r2,
    246     ipcarg_t *r3, ipcarg_t *r4, ipcarg_t *r5);
    247 extern ipcarg_t async_req_slow(int phoneid, ipcarg_t method, ipcarg_t arg1,
    248     ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5, ipcarg_t *r1,
    249     ipcarg_t *r2, ipcarg_t *r3, ipcarg_t *r4, ipcarg_t *r5);
     267extern 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 *);
     269extern 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 *);
    250272
    251273static inline void async_serialize_start(void)
     
    259281}
    260282
    261 extern int async_connect_me_to(int, ipcarg_t, ipcarg_t, ipcarg_t);
    262 extern int async_connect_me_to_blocking(int, ipcarg_t, ipcarg_t, ipcarg_t);
     283extern int async_connect_to_me(int, sysarg_t, sysarg_t, sysarg_t,
     284    async_client_conn_t);
     285extern int async_connect_me_to(int, sysarg_t, sysarg_t, sysarg_t);
     286extern int async_connect_me_to_blocking(int, sysarg_t, sysarg_t, sysarg_t);
     287extern int async_connect_kbox(task_id_t);
     288extern int async_hangup(int);
     289extern void async_poke(void);
    263290
    264291/*
    265292 * User-friendly wrappers for async_share_in_start().
    266293 */
     294
    267295#define async_share_in_start_0_0(phoneid, dst, size) \
    268296        async_share_in_start((phoneid), (dst), (size), 0, NULL)
     
    274302        async_share_in_start((phoneid), (dst), (size), (arg), (flags))
    275303
    276 extern int async_share_in_start(int, void *, size_t, ipcarg_t, int *);
    277 extern int async_share_in_receive(ipc_callid_t *, size_t *);
    278 extern int async_share_in_finalize(ipc_callid_t, void *, int );
    279 extern int async_share_out_start(int, void *, int);
    280 extern int async_share_out_receive(ipc_callid_t *, size_t *, int *);
     304extern int async_share_in_start(int, void *, size_t, sysarg_t, unsigned int *);
     305extern bool async_share_in_receive(ipc_callid_t *, size_t *);
     306extern int async_share_in_finalize(ipc_callid_t, void *, unsigned int);
     307
     308extern int async_share_out_start(int, void *, unsigned int);
     309extern bool async_share_out_receive(ipc_callid_t *, size_t *, unsigned int *);
    281310extern int async_share_out_finalize(ipc_callid_t, void *);
    282311
     
    284313 * User-friendly wrappers for async_data_read_forward_fast().
    285314 */
     315
    286316#define async_data_read_forward_0_0(phoneid, method, answer) \
    287317        async_data_read_forward_fast((phoneid), (method), 0, 0, 0, 0, NULL)
     
    310340            (arg4), (answer))
    311341
    312 extern int async_data_read_start(int, void *, size_t);
    313 extern int async_data_read_receive(ipc_callid_t *, size_t *);
     342#define async_data_read_start(p, buf, len) \
     343        async_data_read_start_generic((p), (buf), (len), IPC_XF_NONE)
     344
     345extern int async_data_read_start_generic(int, void *, size_t, int);
     346extern bool async_data_read_receive(ipc_callid_t *, size_t *);
    314347extern int async_data_read_finalize(ipc_callid_t, const void *, size_t);
    315348
    316 extern int async_data_read_forward_fast(int, ipcarg_t, ipcarg_t, ipcarg_t,
    317     ipcarg_t, ipcarg_t, ipc_call_t *);
     349extern int async_data_read_forward_fast(int, sysarg_t, sysarg_t, sysarg_t,
     350    sysarg_t, sysarg_t, ipc_call_t *);
    318351
    319352/*
    320353 * User-friendly wrappers for async_data_write_forward_fast().
    321354 */
     355
    322356#define async_data_write_forward_0_0(phoneid, method, answer) \
    323357        async_data_write_forward_fast((phoneid), (method), 0, 0, 0, 0, NULL)
     
    348382            (arg4), (answer))
    349383
    350 extern int async_data_write_start(int, const void *, size_t);
    351 extern int async_data_write_receive(ipc_callid_t *, size_t *);
     384#define async_data_write_start(p, buf, len) \
     385        async_data_write_start_generic((p), (buf), (len), IPC_XF_NONE)
     386
     387extern int async_data_write_start_generic(int, const void *, size_t, int);
     388extern bool async_data_write_receive(ipc_callid_t *, size_t *);
    352389extern int async_data_write_finalize(ipc_callid_t, void *, size_t);
    353390
    354391extern int async_data_write_accept(void **, const bool, const size_t,
    355392    const size_t, const size_t, size_t *);
    356 extern void async_data_write_void(const int);
    357 
    358 extern int async_data_write_forward_fast(int, ipcarg_t, ipcarg_t, ipcarg_t,
    359     ipcarg_t, ipcarg_t, ipc_call_t *);
     393extern void async_data_write_void(sysarg_t);
     394
     395extern int async_data_write_forward_fast(int, sysarg_t, sysarg_t, sysarg_t,
     396    sysarg_t, sysarg_t, ipc_call_t *);
    360397
    361398#endif
Note: See TracChangeset for help on using the changeset viewer.