Changeset 9f22213 in mainline for generic/src/ipc/ipc.c
- Timestamp:
- 2006-03-19T12:43:12Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7c7aae16
- Parents:
- b4b45210
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
generic/src/ipc/ipc.c
rb4b45210 r9f22213 105 105 106 106 ASSERT(!phone->callee); 107 phone->busy = 1;107 phone->busy = IPC_BUSY_CONNECTED; 108 108 phone->callee = box; 109 109 … … 121 121 spinlock_initialize(&phone->lock, "phone_lock"); 122 122 phone->callee = NULL; 123 phone->busy = 0; 123 phone->busy = IPC_BUSY_FREE; 124 atomic_set(&phone->active_calls, 0); 124 125 } 125 126 … … 172 173 static void _ipc_call(phone_t *phone, answerbox_t *box, call_t *call) 173 174 { 174 atomic_inc(&phone->active_calls); 175 call->data.phone = phone; 175 if (! (call->flags & IPC_CALL_FORWARDED)) { 176 atomic_inc(&phone->active_calls); 177 call->data.phone = phone; 178 } 176 179 177 180 spinlock_lock(&box->lock); … … 186 189 * @param request Request to be sent 187 190 */ 188 voidipc_call(phone_t *phone, call_t *call)191 int ipc_call(phone_t *phone, call_t *call) 189 192 { 190 193 answerbox_t *box; … … 196 199 /* Trying to send over disconnected phone */ 197 200 spinlock_unlock(&phone->lock); 198 199 call->data.phone = phone; 200 IPC_SET_RETVAL(call->data, ENOENT); 201 if (call->flags & IPC_CALL_FORWARDED) { 202 IPC_SET_RETVAL(call->data, EFORWARD); 203 } else { /* Simulate sending a message */ 204 call->data.phone = phone; 205 atomic_inc(&phone->active_calls); 206 if (phone->busy == IPC_BUSY_CONNECTED) 207 IPC_SET_RETVAL(call->data, EHANGUP); 208 else 209 IPC_SET_RETVAL(call->data, ENOENT); 210 } 211 201 212 _ipc_answer_free_call(call); 202 return ;213 return ENOENT; 203 214 } 204 215 _ipc_call(phone, box, call); 205 216 206 217 spinlock_unlock(&phone->lock); 218 return 0; 207 219 } 208 220 … … 221 233 box = phone->callee; 222 234 if (!box) { 235 if (phone->busy == IPC_BUSY_CONNECTING) { 236 spinlock_unlock(&phone->lock); 237 return -1; 238 } 239 /* Already disconnected phone */ 240 phone->busy = IPC_BUSY_FREE; 223 241 spinlock_unlock(&phone->lock); 224 return -1;242 return 0; 225 243 } 226 244 … … 235 253 _ipc_call(phone, box, call); 236 254 237 phone->busy = 0;255 phone->busy = IPC_BUSY_FREE; 238 256 239 257 spinlock_unlock(&phone->lock); … … 247 265 * @param newbox Target answerbox 248 266 * @param oldbox Old answerbox 249 */ 250 void ipc_forward(call_t *call, phone_t *newphone, answerbox_t *oldbox) 267 * @return 0 on forward ok, error code, if there was error 268 * 269 * - the return value serves only as an information for the forwarder, 270 * the original caller is notified automatically with EFORWARD 271 */ 272 int ipc_forward(call_t *call, phone_t *newphone, answerbox_t *oldbox) 251 273 { 252 274 spinlock_lock(&oldbox->lock); 253 atomic_dec(&call->data.phone->active_calls);254 275 list_remove(&call->list); 255 276 spinlock_unlock(&oldbox->lock); 256 277 257 ipc_call(newphone, call);278 return ipc_call(newphone, call); 258 279 } 259 280 … … 280 301 request = list_get_instance(box->answers.next, call_t, list); 281 302 list_remove(&request->list); 282 printf("%d %P\n", IPC_GET_METHOD(request->data),283 request->data.phone);284 303 atomic_dec(&request->data.phone->active_calls); 285 304 } else if (!list_empty(&box->calls)) { … … 314 333 void ipc_cleanup(task_t *task) 315 334 { 316 /* Cancel all calls in my dispatch queue */ 335 int i; 336 337 /* Disconnect all our phones ('ipc_phone_hangup') */ 338 for (i=0;i < IPC_MAX_PHONES; i++) 339 ipc_phone_hangup(&task->phones[i]); 340 341 /* Disconnect all phones connected to answerbox */ 342 343 /* Answer all messages in 'calls' and 'dispatched_calls' queues */ 317 344 318 } 345 /* Wait for all async answers to arrive */ 346 }
Note:
See TracChangeset
for help on using the changeset viewer.