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 __IPC_H__
00036 #define __IPC_H__
00037
00038
00039
00040 #define IPC_CALL_LEN 4
00041
00043 #ifdef CONFIG_DEBUG
00044 # define IPC_MAX_ASYNC_CALLS 4
00045 #else
00046 # define IPC_MAX_ASYNC_CALLS 4000
00047 #endif
00048
00049
00050 #define IPC_CALL_ANSWERED (1<<0)
00051 #define IPC_CALL_STATIC_ALLOC (1<<1)
00052 #define IPC_CALL_DISCARD_ANSWER (1<<2)
00054 #define IPC_CALL_FORWARDED (1<<3)
00055 #define IPC_CALL_CONN_ME_TO (1<<4)
00056 #define IPC_CALL_NOTIF (1<<5)
00057
00058
00059
00060
00061 #define IPC_CALLID_ANSWERED 1
00062 #define IPC_CALLID_NOTIFICATION 2
00064
00065 #define IPC_CALLRET_FATAL -1
00066 #define IPC_CALLRET_TEMPORARY -2
00067
00068
00069
00070 #define IPC_SET_RETVAL(data, retval) ((data).args[0] = (retval))
00071 #define IPC_SET_METHOD(data, val) ((data).args[0] = (val))
00072 #define IPC_SET_ARG1(data, val) ((data).args[1] = (val))
00073 #define IPC_SET_ARG2(data, val) ((data).args[2] = (val))
00074 #define IPC_SET_ARG3(data, val) ((data).args[3] = (val))
00075
00076 #define IPC_GET_METHOD(data) ((data).args[0])
00077 #define IPC_GET_RETVAL(data) ((data).args[0])
00078
00079 #define IPC_GET_ARG1(data) ((data).args[1])
00080 #define IPC_GET_ARG2(data) ((data).args[2])
00081 #define IPC_GET_ARG3(data) ((data).args[3])
00082
00083
00084 #define PHONE_NS 0
00085
00086
00087
00088
00106 #define IPC_M_CONNECT_TO_ME 1
00107
00125 #define IPC_M_CONNECT_ME_TO 2
00126
00129 #define IPC_M_PHONE_HUNGUP 3
00130
00137 #define IPC_M_AS_AREA_SEND 5
00138
00147 #define IPC_M_AS_AREA_RECV 6
00148
00149
00150
00151 #define IPC_M_LAST_SYSTEM 511
00152 #define IPC_M_PING 512
00153
00154 #define FIRST_USER_METHOD 1024
00155
00156 #ifdef KERNEL
00157
00158 #include <synch/mutex.h>
00159 #include <synch/condvar.h>
00160 #include <adt/list.h>
00161
00162 #define IPC_MAX_PHONES 16
00163
00164 typedef struct answerbox_s answerbox_t;
00165 typedef struct phone_s phone_t;
00166 typedef struct {
00167 __native args[IPC_CALL_LEN];
00168 phone_t *phone;
00169 }ipc_data_t;
00170
00171 struct answerbox_s {
00172 SPINLOCK_DECLARE(lock);
00173
00174 task_t *task;
00175
00176 waitq_t wq;
00177
00178 link_t connected_phones;
00179 link_t calls;
00180 link_t dispatched_calls;
00181
00182 link_t answers;
00184 SPINLOCK_DECLARE(irq_lock);
00185 link_t irq_notifs;
00186 };
00187
00188 typedef enum {
00189 IPC_PHONE_FREE = 0,
00190 IPC_PHONE_CONNECTING,
00191 IPC_PHONE_CONNECTED,
00192 IPC_PHONE_HUNGUP,
00193 IPC_PHONE_SLAMMED
00194 } ipc_phone_state_t;
00195
00197 struct phone_s {
00198 SPINLOCK_DECLARE(lock);
00199 link_t link;
00200 answerbox_t *callee;
00201 ipc_phone_state_t state;
00202 atomic_t active_calls;
00203 };
00204
00205 typedef struct {
00206 link_t link;
00207
00208 int flags;
00209
00210
00211 task_t *sender;
00212
00213
00214
00215 answerbox_t *callerbox;
00216
00217 __native private;
00219 ipc_data_t data;
00220 }call_t;
00221
00222 extern void ipc_init(void);
00223 extern call_t * ipc_wait_for_call(answerbox_t *box, __u32 usec, int flags);
00224 extern void ipc_answer(answerbox_t *box, call_t *request);
00225 extern int ipc_call(phone_t *phone, call_t *call);
00226 extern void ipc_call_sync(phone_t *phone, call_t *request);
00227 extern void ipc_phone_init(phone_t *phone);
00228 extern void ipc_phone_connect(phone_t *phone, answerbox_t *box);
00229 extern void ipc_call_free(call_t *call);
00230 extern call_t * ipc_call_alloc(int flags);
00231 extern void ipc_answerbox_init(answerbox_t *box);
00232 extern void ipc_call_static_init(call_t *call);
00233 extern void task_print_list(void);
00234 extern int ipc_forward(call_t *call, phone_t *newphone, answerbox_t *oldbox);
00235 void ipc_cleanup(void);
00236 int ipc_phone_hangup(phone_t *phone);
00237 extern void ipc_backsend_err(phone_t *phone, call_t *call, __native err);
00238 extern void ipc_print_task(task_id_t taskid);
00239
00240 extern answerbox_t *ipc_phone_0;
00241
00242 #endif
00243
00244 #endif
00245