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 #ifndef _libc_ASYNC_H_
00036 #define _libc_ASYNC_H_
00037
00038 #include <ipc/ipc.h>
00039 #include <psthread.h>
00040 #include <sys/time.h>
00041 #include <atomic.h>
00042
00043 typedef ipc_callid_t aid_t;
00044 typedef void (*async_client_conn_t)(ipc_callid_t callid, ipc_call_t *call);
00045
00046 static inline void async_manager(void)
00047 {
00048 psthread_schedule_next_adv(PS_TO_MANAGER);
00049 }
00050
00051 ipc_callid_t async_get_call_timeout(ipc_call_t *call, suseconds_t usecs);
00052 static inline ipc_callid_t async_get_call(ipc_call_t *data)
00053 {
00054 return async_get_call_timeout(data, 0);
00055 }
00056
00057 aid_t async_send_2(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2,
00058 ipc_call_t *dataptr);
00059 aid_t async_send_3(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2,
00060 ipcarg_t arg3, ipc_call_t *dataptr);
00061 void async_wait_for(aid_t amsgid, ipcarg_t *result);
00062 int async_wait_timeout(aid_t amsgid, ipcarg_t *retval, suseconds_t timeout);
00063
00070 static inline ipcarg_t async_req_2(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t *r1, ipcarg_t *r2)
00071 {
00072 ipc_call_t result;
00073 ipcarg_t rc;
00074
00075 aid_t eid = async_send_2(phoneid, method, arg1, arg2, &result);
00076 async_wait_for(eid, &rc);
00077 if (r1)
00078 *r1 = IPC_GET_ARG1(result);
00079 if (r2)
00080 *r2 = IPC_GET_ARG2(result);
00081 return rc;
00082 }
00083 #define async_req(phoneid, method, arg1, r1) async_req_2(phoneid, method, arg1, 0, r1, 0)
00084
00085 static inline ipcarg_t async_req_3(int phoneid, ipcarg_t method, ipcarg_t arg1,
00086 ipcarg_t arg2, ipcarg_t arg3, ipcarg_t *r1,
00087 ipcarg_t *r2, ipcarg_t *r3)
00088 {
00089 ipc_call_t result;
00090 ipcarg_t rc;
00091
00092 aid_t eid = async_send_3(phoneid, method, arg1, arg2, arg3, &result);
00093 async_wait_for(eid, &rc);
00094 if (r1)
00095 *r1 = IPC_GET_ARG1(result);
00096 if (r2)
00097 *r2 = IPC_GET_ARG2(result);
00098 if (r3)
00099 *r3 = IPC_GET_ARG3(result);
00100 return rc;
00101 }
00102
00103
00104 pstid_t async_new_connection(ipcarg_t in_phone_hash,ipc_callid_t callid,
00105 ipc_call_t *call,
00106 void (*cthread)(ipc_callid_t,ipc_call_t *));
00107 void async_usleep(suseconds_t timeout);
00108 void async_create_manager(void);
00109 void async_destroy_manager(void);
00110 void async_set_client_connection(async_client_conn_t conn);
00111 void async_set_interrupt_received(async_client_conn_t conn);
00112 int _async_init(void);
00113
00114
00115
00116 void async_msg_3(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2,
00117 ipcarg_t arg3);
00118 void async_msg_2(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2);
00119 #define async_msg(ph,m,a1) async_msg_2(ph,m,a1,0)
00120
00121 static inline void async_serialize_start(void)
00122 {
00123 psthread_inc_sercount();
00124 }
00125 static inline void async_serialize_end(void)
00126 {
00127 psthread_dec_sercount();
00128 }
00129
00130 extern atomic_t async_futex;
00131 #endif
00132
00133