Rev 1582 | Rev 1595 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1582 | Rev 1591 | ||
---|---|---|---|
Line 235... | Line 235... | ||
235 | * |
235 | * |
236 | * This call leaves the phone in HUNGUP state. The change to 'free' is done |
236 | * This call leaves the phone in HUNGUP state. The change to 'free' is done |
237 | * lazily later. |
237 | * lazily later. |
238 | * |
238 | * |
239 | * @param phone Phone to be hung up |
239 | * @param phone Phone to be hung up |
240 | * @param aggressive If false, the phone is only marked hungup, and all |
- | |
241 | * messages are allowed to complete. |
- | |
242 | * If true, all messages in all queues are discarded. There |
- | |
243 | * may still be some messages that will be 'in-transit' on |
- | |
244 | * other CPU. |
- | |
245 | * |
240 | * |
246 | * @return 0 - phone disconnected, -1 - the phone was already disconnected |
241 | * @return 0 - phone disconnected, -1 - the phone was already disconnected |
247 | */ |
242 | */ |
248 | int ipc_phone_hangup(phone_t *phone, int aggressive) |
243 | int ipc_phone_hangup(phone_t *phone) |
249 | { |
244 | { |
250 | answerbox_t *box; |
245 | answerbox_t *box; |
251 | call_t *call; |
246 | call_t *call; |
252 | 247 | ||
253 | spinlock_lock(&phone->lock); |
248 | spinlock_lock(&phone->lock); |
Line 269... | Line 264... | ||
269 | call->flags |= IPC_CALL_DISCARD_ANSWER; |
264 | call->flags |= IPC_CALL_DISCARD_ANSWER; |
270 | _ipc_call(phone, box, call); |
265 | _ipc_call(phone, box, call); |
271 | } |
266 | } |
272 | } |
267 | } |
273 | 268 | ||
274 | if (aggressive && atomic_get(&phone->active_calls) > 0) { |
- | |
275 | /* TODO: Do some stuff be VERY aggressive */ |
- | |
276 | } |
- | |
277 | - | ||
278 | phone->state = IPC_PHONE_HUNGUP; |
269 | phone->state = IPC_PHONE_HUNGUP; |
279 | spinlock_unlock(&phone->lock); |
270 | spinlock_unlock(&phone->lock); |
280 | 271 | ||
281 | return 0; |
272 | return 0; |
282 | } |
273 | } |
Line 380... | Line 371... | ||
380 | call_t *call; |
371 | call_t *call; |
381 | phone_t *phone; |
372 | phone_t *phone; |
382 | 373 | ||
383 | /* Disconnect all our phones ('ipc_phone_hangup') */ |
374 | /* Disconnect all our phones ('ipc_phone_hangup') */ |
384 | for (i=0;i < IPC_MAX_PHONES; i++) |
375 | for (i=0;i < IPC_MAX_PHONES; i++) |
385 | ipc_phone_hangup(&TASK->phones[i], 1); |
376 | ipc_phone_hangup(&TASK->phones[i]); |
386 | 377 | ||
387 | /* Disconnect all connected irqs */ |
378 | /* Disconnect all connected irqs */ |
388 | ipc_irq_cleanup(&TASK->answerbox); |
379 | ipc_irq_cleanup(&TASK->answerbox); |
389 | 380 | ||
390 | /* Disconnect all phones connected to our answerbox */ |
381 | /* Disconnect all phones connected to our answerbox */ |
Line 419... | Line 410... | ||
419 | for (i=0;i < IPC_MAX_PHONES; i++) { |
410 | for (i=0;i < IPC_MAX_PHONES; i++) { |
420 | if (TASK->phones[i].state == IPC_PHONE_HUNGUP && \ |
411 | if (TASK->phones[i].state == IPC_PHONE_HUNGUP && \ |
421 | atomic_get(&TASK->phones[i].active_calls) == 0) |
412 | atomic_get(&TASK->phones[i].active_calls) == 0) |
422 | TASK->phones[i].state = IPC_PHONE_FREE; |
413 | TASK->phones[i].state = IPC_PHONE_FREE; |
423 | 414 | ||
- | 415 | /* Just for sure, we might have had some |
|
- | 416 | * IPC_PHONE_CONNECTING phones */ |
|
424 | if (TASK->phones[i].state == IPC_PHONE_CONNECTED) |
417 | if (TASK->phones[i].state == IPC_PHONE_CONNECTED) |
425 | ipc_phone_hangup(&TASK->phones[i], 1); |
418 | ipc_phone_hangup(&TASK->phones[i]); |
- | 419 | /* If the hangup succeeded, it has sent a HANGUP |
|
- | 420 | * message, the IPC is now in HUNGUP state, we |
|
- | 421 | * wait for the reply to come */ |
|
426 | 422 | ||
427 | if (TASK->phones[i].state != IPC_PHONE_FREE) |
423 | if (TASK->phones[i].state != IPC_PHONE_FREE) |
428 | break; |
424 | break; |
429 | } |
425 | } |
430 | /* Voila, got into cleanup */ |
426 | /* Voila, got into cleanup */ |