Rev 1027 | Rev 1050 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1027 | Rev 1040 | ||
|---|---|---|---|
| Line 69... | Line 69... | ||
| 69 | #define PHONE_NS 0 |
69 | #define PHONE_NS 0 |
| 70 | 70 | ||
| 71 | /* System-specific methods - only through special syscalls |
71 | /* System-specific methods - only through special syscalls |
| 72 | * These methods have special behaviour |
72 | * These methods have special behaviour |
| 73 | */ |
73 | */ |
| 74 | #define IPC_M_IAMCONNECTING 0 |
- | |
| 75 | /** Protocol for CONNECT - TO - ME |
74 | /** Protocol for CONNECT - TO - ME |
| 76 | * |
75 | * |
| 77 | * Calling process asks the callee to create a callback connection, |
76 | * Calling process asks the callee to create a callback connection, |
| 78 | * so that it can start initiating new messages. |
77 | * so that it can start initiating new messages. |
| 79 | * |
78 | * |
| 80 | * The protocol for negotiating is as follows: |
79 | * The protocol for negotiating is: |
| 81 | * - sys_connecttome - sends a message IPC_M_CONNECTTOME |
80 | * - sys_connecttome - sends a message IPC_M_CONNECTTOME |
| 82 | * - sys_wait_for_call - upon receipt tries to allocate new phone |
81 | * - sys_wait_for_call - upon receipt tries to allocate new phone |
| 83 | * - if it fails, responds with ELIMIT |
82 | * - if it fails, responds with ELIMIT |
| 84 | * - passes call to userspace. If userspace |
83 | * - passes call to userspace. If userspace |
| 85 | * responds with error, phone is deallocated and |
84 | * responds with error, phone is deallocated and |
| 86 | * error is sent back to caller. Otherwise |
85 | * error is sent back to caller. Otherwise |
| 87 | * the call is accepted and the response is sent back. |
86 | * the call is accepted and the response is sent back. |
| 88 | * - the allocated phoneid is passed to userspace as |
87 | * - the allocated phoneid is passed to userspace |
| 89 | * ARG3 of the call. |
88 | * (on the receiving sid) as ARG3 of the call. |
| 90 | * - the caller obtains taskid of the called thread |
89 | * - the caller obtains taskid of the called thread |
| 91 | */ |
90 | */ |
| 92 | #define IPC_M_CONNECTTOME 1 |
91 | #define IPC_M_CONNECTTOME 1 |
| - | 92 | /** Protocol for CONNECT - ME - TO |
|
| - | 93 | * |
|
| - | 94 | * Calling process asks the callee to create for him a new connection. |
|
| - | 95 | * E.g. the caller wants a name server to connect him to print server. |
|
| - | 96 | * |
|
| - | 97 | * The protocol for negotiating is: |
|
| - | 98 | * - sys_connect_me_to - send a synchronous message to name server |
|
| - | 99 | * indicating that it wants to be connected to some |
|
| - | 100 | * service |
|
| - | 101 | * recepient - if ipc_answer == 0, then accept connection |
|
| - | 102 | * - otherwise connection refused |
|
| - | 103 | * - recepient may forward message. Forwarding |
|
| - | 104 | * system message |
|
| - | 105 | * |
|
| - | 106 | */ |
|
| 93 | #define IPC_M_CONNECTMETO 2 |
107 | #define IPC_M_CONNECTMETO 2 |
| - | 108 | /* Control messages that the server sends to the processes |
|
| - | 109 | * about their connections. |
|
| - | 110 | */ |
|
| 94 | 111 | ||
| 95 | 112 | ||
| 96 | /* Well-known methods */ |
113 | /* Well-known methods */ |
| 97 | #define IPC_M_FIRST_USER 512 |
114 | #define IPC_M_LAST_SYSTEM 511 |
| 98 | #define IPC_M_PING 512 |
115 | #define IPC_M_PING 512 |
| 99 | /* User methods */ |
116 | /* User methods */ |
| 100 | #define FIRST_USER_METHOD 1024 |
117 | #define FIRST_USER_METHOD 1024 |
| 101 | 118 | ||
| 102 | #ifdef KERNEL |
119 | #ifdef KERNEL |
| Line 121... | Line 138... | ||
| 121 | struct answerbox { |
138 | struct answerbox { |
| 122 | SPINLOCK_DECLARE(lock); |
139 | SPINLOCK_DECLARE(lock); |
| 123 | 140 | ||
| 124 | task_t *task; |
141 | task_t *task; |
| 125 | 142 | ||
| 126 | mutex_t mutex; |
- | |
| 127 | condvar_t cv; |
143 | waitq_t wq; |
| 128 | 144 | ||
| 129 | link_t connected_phones; /**< Phones connected to this answerbox */ |
145 | link_t connected_phones; /**< Phones connected to this answerbox */ |
| 130 | link_t calls; /**< Received calls */ |
146 | link_t calls; /**< Received calls */ |
| 131 | link_t dispatched_calls; /* Should be hash table in the future */ |
147 | link_t dispatched_calls; /* Should be hash table in the future */ |
| 132 | 148 | ||
| Line 135... | Line 151... | ||
| 135 | 151 | ||
| 136 | typedef struct { |
152 | typedef struct { |
| 137 | SPINLOCK_DECLARE(lock); |
153 | SPINLOCK_DECLARE(lock); |
| 138 | link_t list; |
154 | link_t list; |
| 139 | answerbox_t *callee; |
155 | answerbox_t *callee; |
| - | 156 | int busy; |
|
| 140 | } phone_t; |
157 | } phone_t; |
| 141 | 158 | ||
| 142 | extern void ipc_init(void); |
159 | extern void ipc_init(void); |
| 143 | extern call_t * ipc_wait_for_call(answerbox_t *box, int flags); |
160 | extern call_t * ipc_wait_for_call(answerbox_t *box, int flags); |
| 144 | extern void ipc_answer(answerbox_t *box, call_t *request); |
161 | extern void ipc_answer(answerbox_t *box, call_t *request); |
| 145 | extern void ipc_call(phone_t *phone, call_t *request); |
162 | extern void ipc_call(phone_t *phone, call_t *request); |
| 146 | extern void ipc_call_sync(phone_t *phone, call_t *request); |
163 | extern void ipc_call_sync(phone_t *phone, call_t *request); |
| 147 | extern void ipc_phone_destroy(phone_t *phone); |
164 | extern void ipc_phone_destroy(phone_t *phone); |
| - | 165 | extern void ipc_phone_init(phone_t *phone); |
|
| 148 | extern void ipc_phone_init(phone_t *phone, answerbox_t *box); |
166 | extern void ipc_phone_connect(phone_t *phone, answerbox_t *box); |
| 149 | extern void ipc_call_free(call_t *call); |
167 | extern void ipc_call_free(call_t *call); |
| 150 | extern call_t * ipc_call_alloc(void); |
168 | extern call_t * ipc_call_alloc(void); |
| 151 | extern void ipc_answerbox_init(answerbox_t *box); |
169 | extern void ipc_answerbox_init(answerbox_t *box); |
| 152 | extern void ipc_phone_init(phone_t *phone, answerbox_t *box); |
- | |
| 153 | extern void ipc_call_init(call_t *call); |
170 | extern void ipc_call_init(call_t *call); |
| - | 171 | extern void ipc_forward(call_t *call, answerbox_t *newbox,answerbox_t *oldbox); |
|
| 154 | 172 | ||
| 155 | extern answerbox_t *ipc_phone_0; |
173 | extern answerbox_t *ipc_phone_0; |
| 156 | 174 | ||
| 157 | #endif |
175 | #endif |
| 158 | 176 | ||