Subversion Repositories HelenOS-historic

Rev

Rev 1463 | Rev 1472 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1394 palkovsky 1
#ifndef _libc_ASYNC_H_
2
#define _libc_ASYNC_H_
3
 
4
#include <ipc/ipc.h>
1407 palkovsky 5
#include <psthread.h>
1449 palkovsky 6
#include <sys/time.h>
1463 palkovsky 7
#include <atomic.h>
1394 palkovsky 8
 
1427 palkovsky 9
typedef ipc_callid_t aid_t;
10
 
1394 palkovsky 11
int async_manager(void);
12
ipc_callid_t async_get_call(ipc_call_t *data);
13
 
1464 palkovsky 14
 
1427 palkovsky 15
aid_t async_send_2(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2,
16
           ipc_call_t *dataptr);
17
void async_wait_for(aid_t amsgid, ipcarg_t *result);
1441 palkovsky 18
int async_wait_timeout(aid_t amsgid, ipcarg_t *retval, suseconds_t timeout);
1464 palkovsky 19
 
20
/** Pseudo-synchronous message sending
21
 *
22
 * Send message through IPC, wait in the event loop, until it is received
23
 *
24
 * @return Return code of message
25
 */
26
static inline ipcarg_t sync_send_2(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t *r1, ipcarg_t *r2)
27
{
28
    ipc_call_t result;
29
    ipcarg_t rc;
30
 
31
    aid_t eid = async_send_2(phoneid, method, arg1, arg2, &result);
32
    async_wait_for(eid, &rc);
33
    if (r1)
34
        *r1 = IPC_GET_ARG1(result);
35
    if (r2)
36
        *r2 = IPC_GET_ARG2(result);
37
    return rc;
38
}
39
 
40
 
1452 palkovsky 41
pstid_t async_new_connection(ipcarg_t in_phone_hash,ipc_callid_t callid,
42
                 ipc_call_t *call,
43
                 void (*cthread)(ipc_callid_t,ipc_call_t *));
44
void async_usleep(suseconds_t timeout);
1464 palkovsky 45
void async_create_manager(void);
46
void async_destroy_manager(void);
47
int _async_init(void);
1427 palkovsky 48
 
49
/* Should be defined by application */
1394 palkovsky 50
void client_connection(ipc_callid_t callid, ipc_call_t *call) __attribute__((weak));
1452 palkovsky 51
void interrupt_received(ipc_call_t *call)  __attribute__((weak));
1394 palkovsky 52
 
1463 palkovsky 53
 
54
extern atomic_t async_futex;
55
 
1394 palkovsky 56
#endif