Subversion Repositories HelenOS-historic

Rev

Rev 1464 | Rev 1490 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1464 Rev 1472
-
 
1
/*
-
 
2
 * Copyright (C) 2006 Ondrej Palkovsky
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions
-
 
7
 * are met:
-
 
8
 *
-
 
9
 * - Redistributions of source code must retain the above copyright
-
 
10
 *   notice, this list of conditions and the following disclaimer.
-
 
11
 * - Redistributions in binary form must reproduce the above copyright
-
 
12
 *   notice, this list of conditions and the following disclaimer in the
-
 
13
 *   documentation and/or other materials provided with the distribution.
-
 
14
 * - The name of the author may not be used to endorse or promote products
-
 
15
 *   derived from this software without specific prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-
 
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-
 
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-
 
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-
 
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-
 
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-
 
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-
 
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
 
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
 
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
27
 */
-
 
28
 
1
#ifndef _libc_ASYNC_H_
29
#ifndef _libc_ASYNC_H_
2
#define _libc_ASYNC_H_
30
#define _libc_ASYNC_H_
3
 
31
 
4
#include <ipc/ipc.h>
32
#include <ipc/ipc.h>
5
#include <psthread.h>
33
#include <psthread.h>
6
#include <sys/time.h>
34
#include <sys/time.h>
7
#include <atomic.h>
35
#include <atomic.h>
8
 
36
 
9
typedef ipc_callid_t aid_t;
37
typedef ipc_callid_t aid_t;
10
 
38
 
11
int async_manager(void);
39
int async_manager(void);
12
ipc_callid_t async_get_call(ipc_call_t *data);
40
ipc_callid_t async_get_call(ipc_call_t *data);
13
 
41
 
14
 
42
 
15
aid_t async_send_2(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2,
43
aid_t async_send_2(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2,
16
           ipc_call_t *dataptr);
44
           ipc_call_t *dataptr);
17
void async_wait_for(aid_t amsgid, ipcarg_t *result);
45
void async_wait_for(aid_t amsgid, ipcarg_t *result);
18
int async_wait_timeout(aid_t amsgid, ipcarg_t *retval, suseconds_t timeout);
46
int async_wait_timeout(aid_t amsgid, ipcarg_t *retval, suseconds_t timeout);
19
 
47
 
20
/** Pseudo-synchronous message sending
48
/** Pseudo-synchronous message sending
21
 *
49
 *
22
 * Send message through IPC, wait in the event loop, until it is received
50
 * Send message through IPC, wait in the event loop, until it is received
23
 *
51
 *
24
 * @return Return code of message
52
 * @return Return code of message
25
 */
53
 */
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)
54
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
{
55
{
28
    ipc_call_t result;
56
    ipc_call_t result;
29
    ipcarg_t rc;
57
    ipcarg_t rc;
30
 
58
 
31
    aid_t eid = async_send_2(phoneid, method, arg1, arg2, &result);
59
    aid_t eid = async_send_2(phoneid, method, arg1, arg2, &result);
32
    async_wait_for(eid, &rc);
60
    async_wait_for(eid, &rc);
33
    if (r1)
61
    if (r1)
34
        *r1 = IPC_GET_ARG1(result);
62
        *r1 = IPC_GET_ARG1(result);
35
    if (r2)
63
    if (r2)
36
        *r2 = IPC_GET_ARG2(result);
64
        *r2 = IPC_GET_ARG2(result);
37
    return rc;
65
    return rc;
38
}
66
}
39
 
67
 
40
 
68
 
41
pstid_t async_new_connection(ipcarg_t in_phone_hash,ipc_callid_t callid,
69
pstid_t async_new_connection(ipcarg_t in_phone_hash,ipc_callid_t callid,
42
                 ipc_call_t *call,
70
                 ipc_call_t *call,
43
                 void (*cthread)(ipc_callid_t,ipc_call_t *));
71
                 void (*cthread)(ipc_callid_t,ipc_call_t *));
44
void async_usleep(suseconds_t timeout);
72
void async_usleep(suseconds_t timeout);
45
void async_create_manager(void);
73
void async_create_manager(void);
46
void async_destroy_manager(void);
74
void async_destroy_manager(void);
47
int _async_init(void);
75
int _async_init(void);
48
 
76
 
49
/* Should be defined by application */
77
/* Should be defined by application */
50
void client_connection(ipc_callid_t callid, ipc_call_t *call) __attribute__((weak));
78
void client_connection(ipc_callid_t callid, ipc_call_t *call) __attribute__((weak));
51
void interrupt_received(ipc_call_t *call)  __attribute__((weak));
79
void interrupt_received(ipc_call_t *call)  __attribute__((weak));
52
 
80
 
53
 
81
 
54
extern atomic_t async_futex;
82
extern atomic_t async_futex;
55
 
83
 
56
#endif
84
#endif
57
 
85