Subversion Repositories HelenOS

Rev

Rev 1005 | Rev 1040 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1005 Rev 1027
Line 66... Line 66...
66
#define IPC_GET_ARG3(data)              ((data)[3])
66
#define IPC_GET_ARG3(data)              ((data)[3])
67
 
67
 
68
/* Well known phone descriptors */
68
/* Well known phone descriptors */
69
#define PHONE_NS              0
69
#define PHONE_NS              0
70
 
70
 
-
 
71
/* System-specific methods - only through special syscalls
-
 
72
 * These methods have special behaviour
-
 
73
 */
-
 
74
#define IPC_M_IAMCONNECTING   0
-
 
75
/** Protocol for CONNECT - TO - ME
-
 
76
 *
-
 
77
 * Calling process asks the callee to create a callback connection,
-
 
78
 * so that it can start initiating new messages.
-
 
79
 *
-
 
80
 * The protocol for negotiating is as follows:
-
 
81
 * - sys_connecttome - sends a message IPC_M_CONNECTTOME
-
 
82
 * - sys_wait_for_call - upon receipt tries to allocate new phone
-
 
83
 *                       - if it fails, responds with ELIMIT
-
 
84
 *                     - passes call to userspace. If userspace
-
 
85
 *                       responds with error, phone is deallocated and
-
 
86
 *                       error is sent back to caller. Otherwise
-
 
87
 *                       the call is accepted and the response is sent back.
-
 
88
 *                     - the allocated phoneid is passed to userspace as
-
 
89
 *                       ARG3 of the call.
-
 
90
 *                     - the caller obtains taskid of the called thread
-
 
91
 */
-
 
92
#define IPC_M_CONNECTTOME     1
-
 
93
#define IPC_M_CONNECTMETO     2
-
 
94
 
-
 
95
 
-
 
96
/* Well-known methods */
-
 
97
#define IPC_M_FIRST_USER      512
-
 
98
#define IPC_M_PING            512
-
 
99
/* User methods */
-
 
100
#define FIRST_USER_METHOD     1024
-
 
101
 
71
#ifdef KERNEL
102
#ifdef KERNEL
72
 
103
 
73
#include <synch/mutex.h>
104
#include <synch/mutex.h>
74
#include <synch/condvar.h>
105
#include <synch/condvar.h>
75
#include <adt/list.h>
106
#include <adt/list.h>
76
 
107
 
77
#define IPC_MAX_PHONES  16
108
#define IPC_MAX_PHONES  16
78
 
109
 
79
 
-
 
80
typedef struct answerbox answerbox_t;
110
typedef struct answerbox answerbox_t;
-
 
111
typedef __native ipc_data_t[IPC_CALL_LEN];
81
 
112
 
82
typedef struct {
113
typedef struct {
83
    link_t list;
114
    link_t list;
84
    answerbox_t *callerbox;
115
    answerbox_t *callerbox;
85
    int flags;
116
    int flags;
86
    task_t *sender;
117
    task_t *sender;
87
    __native data[IPC_CALL_LEN];
118
    ipc_data_t data;
88
} call_t;
119
} call_t;
89
 
120
 
90
struct answerbox {
121
struct answerbox {
91
    SPINLOCK_DECLARE(lock);
122
    SPINLOCK_DECLARE(lock);
92
 
123
 
-
 
124
    task_t *task;
-
 
125
 
93
    mutex_t mutex;
126
    mutex_t mutex;
94
    condvar_t cv;
127
    condvar_t cv;
95
 
128
 
96
    link_t connected_phones; /**< Phones connected to this answerbox */
129
    link_t connected_phones; /**< Phones connected to this answerbox */
97
    link_t calls;            /**< Received calls */
130
    link_t calls;            /**< Received calls */