source: mainline/kernel/generic/src/ipc/ipc.c@ fdb9982c

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since fdb9982c was fdb9982c, checked in by Jakub Jermar <jakub@…>, 15 years ago

Sign each outgoing call by the task hash.

  • Property mode set to 100644
File size: 21.0 KB
Line 
1/*
2 * Copyright (c) 2006 Ondrej Palkovsky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup genericipc
30 * @{
31 */
32/** @file
33 */
34
35/* Lock ordering
36 *
37 * First the answerbox, then the phone.
38 */
39
40#include <synch/synch.h>
41#include <synch/spinlock.h>
42#include <synch/mutex.h>
43#include <synch/waitq.h>
44#include <synch/synch.h>
45#include <ipc/ipc.h>
46#include <ipc/kbox.h>
47#include <ipc/event.h>
48#include <errno.h>
49#include <mm/slab.h>
50#include <arch.h>
51#include <proc/task.h>
52#include <memstr.h>
53#include <debug.h>
54#include <print.h>
55#include <console/console.h>
56#include <proc/thread.h>
57#include <arch/interrupt.h>
58#include <ipc/irq.h>
59
60/** Open channel that is assigned automatically to new tasks */
61answerbox_t *ipc_phone_0 = NULL;
62
63static slab_cache_t *ipc_call_slab;
64static slab_cache_t *ipc_answerbox_slab;
65
66/** Initialize a call structure.
67 *
68 * @param call Call structure to be initialized.
69 *
70 */
71static void _ipc_call_init(call_t *call)
72{
73 memsetb(call, sizeof(*call), 0);
74 call->callerbox = &TASK->answerbox;
75 call->sender = TASK;
76 call->buffer = NULL;
77}
78
79/** Allocate and initialize a call structure.
80 *
81 * The call is initialized, so that the reply will be directed to
82 * TASK->answerbox.
83 *
84 * @param flags Parameters for slab_alloc (e.g FRAME_ATOMIC).
85 *
86 * @return If flags permit it, return NULL, or initialized kernel
87 * call structure.
88 *
89 */
90call_t *ipc_call_alloc(unsigned int flags)
91{
92 call_t *call = slab_alloc(ipc_call_slab, flags);
93 if (call)
94 _ipc_call_init(call);
95
96 return call;
97}
98
99/** Deallocate a call structure.
100 *
101 * @param call Call structure to be freed.
102 *
103 */
104void ipc_call_free(call_t *call)
105{
106 /* Check to see if we have data in the IPC_M_DATA_SEND buffer. */
107 if (call->buffer)
108 free(call->buffer);
109 slab_free(ipc_call_slab, call);
110}
111
112/** Initialize an answerbox structure.
113 *
114 * @param box Answerbox structure to be initialized.
115 * @param task Task to which the answerbox belongs.
116 *
117 */
118void ipc_answerbox_init(answerbox_t *box, task_t *task)
119{
120 irq_spinlock_initialize(&box->lock, "ipc.box.lock");
121 irq_spinlock_initialize(&box->irq_lock, "ipc.box.irqlock");
122 waitq_initialize(&box->wq);
123 link_initialize(&box->sync_box_link);
124 list_initialize(&box->connected_phones);
125 list_initialize(&box->calls);
126 list_initialize(&box->dispatched_calls);
127 list_initialize(&box->answers);
128 list_initialize(&box->irq_notifs);
129 list_initialize(&box->irq_head);
130 box->task = task;
131}
132
133/** Connect a phone to an answerbox.
134 *
135 * @param phone Initialized phone structure.
136 * @param box Initialized answerbox structure.
137 *
138 */
139void ipc_phone_connect(phone_t *phone, answerbox_t *box)
140{
141 mutex_lock(&phone->lock);
142
143 phone->state = IPC_PHONE_CONNECTED;
144 phone->callee = box;
145
146 irq_spinlock_lock(&box->lock, true);
147 list_append(&phone->link, &box->connected_phones);
148 irq_spinlock_unlock(&box->lock, true);
149
150 mutex_unlock(&phone->lock);
151}
152
153/** Initialize a phone structure.
154 *
155 * @param phone Phone structure to be initialized.
156 *
157 */
158void ipc_phone_init(phone_t *phone)
159{
160 mutex_initialize(&phone->lock, MUTEX_PASSIVE);
161 phone->callee = NULL;
162 phone->state = IPC_PHONE_FREE;
163 atomic_set(&phone->active_calls, 0);
164}
165
166/** Helper function to facilitate synchronous calls.
167 *
168 * @param phone Destination kernel phone structure.
169 * @param request Call structure with request.
170 *
171 * @return EOK on success or EINTR if the sleep was interrupted.
172 *
173 */
174int ipc_call_sync(phone_t *phone, call_t *request)
175{
176 answerbox_t *sync_box = slab_alloc(ipc_answerbox_slab, 0);
177 ipc_answerbox_init(sync_box, TASK);
178
179 /*
180 * Put the answerbox on the TASK's list of synchronous answerboxes so
181 * that it can be cleaned up if the call is interrupted.
182 */
183 irq_spinlock_lock(&TASK->lock, true);
184 list_append(&sync_box->sync_box_link, &TASK->sync_box_head);
185 irq_spinlock_unlock(&TASK->lock, true);
186
187 /* We will receive data in a special box. */
188 request->callerbox = sync_box;
189
190 ipc_call(phone, request);
191 if (!ipc_wait_for_call(sync_box, SYNCH_NO_TIMEOUT,
192 SYNCH_FLAGS_INTERRUPTIBLE)) {
193 /* The answerbox and the call will be freed by ipc_cleanup(). */
194 return EINTR;
195 }
196
197 /*
198 * The answer arrived without interruption so we can remove the
199 * answerbox from the TASK's list of synchronous answerboxes.
200 */
201 irq_spinlock_lock(&TASK->lock, true);
202 list_remove(&sync_box->sync_box_link);
203 irq_spinlock_unlock(&TASK->lock, true);
204
205 slab_free(ipc_answerbox_slab, sync_box);
206 return EOK;
207}
208
209/** Answer a message which was not dispatched and is not listed in any queue.
210 *
211 * @param call Call structure to be answered.
212 * @param selflocked If true, then TASK->answebox is locked.
213 *
214 */
215static void _ipc_answer_free_call(call_t *call, bool selflocked)
216{
217 answerbox_t *callerbox = call->callerbox;
218 bool do_lock = ((!selflocked) || callerbox != (&TASK->answerbox));
219
220 /* Count sent answer */
221 irq_spinlock_lock(&TASK->lock, true);
222 TASK->ipc_info.answer_sent++;
223 irq_spinlock_unlock(&TASK->lock, true);
224
225 call->flags |= IPC_CALL_ANSWERED;
226
227 if (call->flags & IPC_CALL_FORWARDED) {
228 if (call->caller_phone) {
229 /* Demasquerade the caller phone. */
230 call->data.phone = call->caller_phone;
231 }
232 }
233
234 if (do_lock)
235 irq_spinlock_lock(&callerbox->lock, true);
236
237 list_append(&call->link, &callerbox->answers);
238
239 if (do_lock)
240 irq_spinlock_unlock(&callerbox->lock, true);
241
242 waitq_wakeup(&callerbox->wq, WAKEUP_FIRST);
243}
244
245/** Answer a message which is in a callee queue.
246 *
247 * @param box Answerbox that is answering the message.
248 * @param call Modified request that is being sent back.
249 *
250 */
251void ipc_answer(answerbox_t *box, call_t *call)
252{
253 /* Remove from active box */
254 irq_spinlock_lock(&box->lock, true);
255 list_remove(&call->link);
256 irq_spinlock_unlock(&box->lock, true);
257
258 /* Send back answer */
259 _ipc_answer_free_call(call, false);
260}
261
262/** Simulate sending back a message.
263 *
264 * Most errors are better handled by forming a normal backward
265 * message and sending it as a normal answer.
266 *
267 * @param phone Phone structure the call should appear to come from.
268 * @param call Call structure to be answered.
269 * @param err Return value to be used for the answer.
270 *
271 */
272void ipc_backsend_err(phone_t *phone, call_t *call, sysarg_t err)
273{
274 call->data.phone = phone;
275 atomic_inc(&phone->active_calls);
276 IPC_SET_RETVAL(call->data, err);
277 _ipc_answer_free_call(call, false);
278}
279
280/** Unsafe unchecking version of ipc_call.
281 *
282 * @param phone Phone structure the call comes from.
283 * @param box Destination answerbox structure.
284 * @param call Call structure with request.
285 *
286 */
287static void _ipc_call(phone_t *phone, answerbox_t *box, call_t *call)
288{
289 /* Count sent ipc call */
290 irq_spinlock_lock(&TASK->lock, true);
291 TASK->ipc_info.call_sent++;
292 irq_spinlock_unlock(&TASK->lock, true);
293
294 if (!(call->flags & IPC_CALL_FORWARDED)) {
295 atomic_inc(&phone->active_calls);
296 call->data.phone = phone;
297 }
298 call->data.task = TASK;
299
300 irq_spinlock_lock(&box->lock, true);
301 list_append(&call->link, &box->calls);
302 irq_spinlock_unlock(&box->lock, true);
303
304 waitq_wakeup(&box->wq, WAKEUP_FIRST);
305}
306
307/** Send an asynchronous request using a phone to an answerbox.
308 *
309 * @param phone Phone structure the call comes from and which is
310 * connected to the destination answerbox.
311 * @param call Call structure with request.
312 *
313 * @return Return 0 on success, ENOENT on error.
314 *
315 */
316int ipc_call(phone_t *phone, call_t *call)
317{
318 mutex_lock(&phone->lock);
319 if (phone->state != IPC_PHONE_CONNECTED) {
320 mutex_unlock(&phone->lock);
321 if (call->flags & IPC_CALL_FORWARDED) {
322 IPC_SET_RETVAL(call->data, EFORWARD);
323 _ipc_answer_free_call(call, false);
324 } else {
325 if (phone->state == IPC_PHONE_HUNGUP)
326 ipc_backsend_err(phone, call, EHANGUP);
327 else
328 ipc_backsend_err(phone, call, ENOENT);
329 }
330
331 return ENOENT;
332 }
333
334 answerbox_t *box = phone->callee;
335 _ipc_call(phone, box, call);
336
337 mutex_unlock(&phone->lock);
338 return 0;
339}
340
341/** Disconnect phone from answerbox.
342 *
343 * This call leaves the phone in the HUNGUP state. The change to 'free' is done
344 * lazily later.
345 *
346 * @param phone Phone structure to be hung up.
347 *
348 * @return 0 if the phone is disconnected.
349 * @return -1 if the phone was already disconnected.
350 *
351 */
352int ipc_phone_hangup(phone_t *phone)
353{
354 mutex_lock(&phone->lock);
355 if (phone->state == IPC_PHONE_FREE ||
356 phone->state == IPC_PHONE_HUNGUP ||
357 phone->state == IPC_PHONE_CONNECTING) {
358 mutex_unlock(&phone->lock);
359 return -1;
360 }
361
362 answerbox_t *box = phone->callee;
363 if (phone->state != IPC_PHONE_SLAMMED) {
364 /* Remove myself from answerbox */
365 irq_spinlock_lock(&box->lock, true);
366 list_remove(&phone->link);
367 irq_spinlock_unlock(&box->lock, true);
368
369 call_t *call = ipc_call_alloc(0);
370 IPC_SET_IMETHOD(call->data, IPC_M_PHONE_HUNGUP);
371 call->flags |= IPC_CALL_DISCARD_ANSWER;
372 _ipc_call(phone, box, call);
373 }
374
375 phone->state = IPC_PHONE_HUNGUP;
376 mutex_unlock(&phone->lock);
377
378 return 0;
379}
380
381/** Forwards call from one answerbox to another one.
382 *
383 * @param call Call structure to be redirected.
384 * @param newphone Phone structure to target answerbox.
385 * @param oldbox Old answerbox structure.
386 * @param mode Flags that specify mode of the forward operation.
387 *
388 * @return 0 if forwarding succeeded or an error code if
389 * there was an error.
390 *
391 * The return value serves only as an information for the forwarder,
392 * the original caller is notified automatically with EFORWARD.
393 *
394 */
395int ipc_forward(call_t *call, phone_t *newphone, answerbox_t *oldbox,
396 unsigned int mode)
397{
398 /* Count forwarded calls */
399 irq_spinlock_lock(&TASK->lock, true);
400 TASK->ipc_info.forwarded++;
401 irq_spinlock_pass(&TASK->lock, &oldbox->lock);
402 list_remove(&call->link);
403 irq_spinlock_unlock(&oldbox->lock, true);
404
405 if (mode & IPC_FF_ROUTE_FROM_ME) {
406 if (!call->caller_phone)
407 call->caller_phone = call->data.phone;
408 call->data.phone = newphone;
409 }
410
411 return ipc_call(newphone, call);
412}
413
414
415/** Wait for a phone call.
416 *
417 * @param box Answerbox expecting the call.
418 * @param usec Timeout in microseconds. See documentation for
419 * waitq_sleep_timeout() for decription of its special
420 * meaning.
421 * @param flags Select mode of sleep operation. See documentation for
422 * waitq_sleep_timeout() for description of its special
423 * meaning.
424 *
425 * @return Recived call structure or NULL.
426 *
427 * To distinguish between a call and an answer, have a look at call->flags.
428 *
429 */
430call_t *ipc_wait_for_call(answerbox_t *box, uint32_t usec, unsigned int flags)
431{
432 call_t *request;
433 uint64_t irq_cnt = 0;
434 uint64_t answer_cnt = 0;
435 uint64_t call_cnt = 0;
436 int rc;
437
438restart:
439 rc = waitq_sleep_timeout(&box->wq, usec, flags);
440 if (SYNCH_FAILED(rc))
441 return NULL;
442
443 irq_spinlock_lock(&box->lock, true);
444 if (!list_empty(&box->irq_notifs)) {
445 /* Count received IRQ notification */
446 irq_cnt++;
447
448 irq_spinlock_lock(&box->irq_lock, false);
449
450 request = list_get_instance(box->irq_notifs.next, call_t, link);
451 list_remove(&request->link);
452
453 irq_spinlock_unlock(&box->irq_lock, false);
454 } else if (!list_empty(&box->answers)) {
455 /* Count received answer */
456 answer_cnt++;
457
458 /* Handle asynchronous answers */
459 request = list_get_instance(box->answers.next, call_t, link);
460 list_remove(&request->link);
461 atomic_dec(&request->data.phone->active_calls);
462 } else if (!list_empty(&box->calls)) {
463 /* Count received call */
464 call_cnt++;
465
466 /* Handle requests */
467 request = list_get_instance(box->calls.next, call_t, link);
468 list_remove(&request->link);
469
470 /* Append request to dispatch queue */
471 list_append(&request->link, &box->dispatched_calls);
472 } else {
473 /* This can happen regularly after ipc_cleanup */
474 irq_spinlock_unlock(&box->lock, true);
475 goto restart;
476 }
477
478 irq_spinlock_pass(&box->lock, &TASK->lock);
479
480 TASK->ipc_info.irq_notif_received += irq_cnt;
481 TASK->ipc_info.answer_received += answer_cnt;
482 TASK->ipc_info.call_received += call_cnt;
483
484 irq_spinlock_unlock(&TASK->lock, true);
485
486 return request;
487}
488
489/** Answer all calls from list with EHANGUP answer.
490 *
491 * @param lst Head of the list to be cleaned up.
492 *
493 */
494void ipc_cleanup_call_list(link_t *lst)
495{
496 while (!list_empty(lst)) {
497 call_t *call = list_get_instance(lst->next, call_t, link);
498 if (call->buffer)
499 free(call->buffer);
500
501 list_remove(&call->link);
502
503 IPC_SET_RETVAL(call->data, EHANGUP);
504 _ipc_answer_free_call(call, true);
505 }
506}
507
508/** Disconnects all phones connected to an answerbox.
509 *
510 * @param box Answerbox to disconnect phones from.
511 * @param notify_box If true, the answerbox will get a hangup message for
512 * each disconnected phone.
513 *
514 */
515void ipc_answerbox_slam_phones(answerbox_t *box, bool notify_box)
516{
517 phone_t *phone;
518 DEADLOCK_PROBE_INIT(p_phonelck);
519
520 call_t *call = notify_box ? ipc_call_alloc(0) : NULL;
521
522 /* Disconnect all phones connected to our answerbox */
523restart_phones:
524 irq_spinlock_lock(&box->lock, true);
525 while (!list_empty(&box->connected_phones)) {
526 phone = list_get_instance(box->connected_phones.next,
527 phone_t, link);
528 if (SYNCH_FAILED(mutex_trylock(&phone->lock))) {
529 irq_spinlock_unlock(&box->lock, true);
530 DEADLOCK_PROBE(p_phonelck, DEADLOCK_THRESHOLD);
531 goto restart_phones;
532 }
533
534 /* Disconnect phone */
535 ASSERT(phone->state == IPC_PHONE_CONNECTED);
536
537 list_remove(&phone->link);
538 phone->state = IPC_PHONE_SLAMMED;
539
540 if (notify_box) {
541 mutex_unlock(&phone->lock);
542 irq_spinlock_unlock(&box->lock, true);
543
544 /*
545 * Send one message to the answerbox for each
546 * phone. Used to make sure the kbox thread
547 * wakes up after the last phone has been
548 * disconnected.
549 */
550 IPC_SET_IMETHOD(call->data, IPC_M_PHONE_HUNGUP);
551 call->flags |= IPC_CALL_DISCARD_ANSWER;
552 _ipc_call(phone, box, call);
553
554 /* Allocate another call in advance */
555 call = ipc_call_alloc(0);
556
557 /* Must start again */
558 goto restart_phones;
559 }
560
561 mutex_unlock(&phone->lock);
562 }
563
564 irq_spinlock_unlock(&box->lock, true);
565
566 /* Free unused call */
567 if (call)
568 ipc_call_free(call);
569}
570
571/** Clean up all IPC communication of the current task.
572 *
573 * Note: ipc_hangup sets returning answerbox to TASK->answerbox, you
574 * have to change it as well if you want to cleanup other tasks than TASK.
575 *
576 */
577void ipc_cleanup(void)
578{
579 /* Disconnect all our phones ('ipc_phone_hangup') */
580 size_t i;
581 for (i = 0; i < IPC_MAX_PHONES; i++)
582 ipc_phone_hangup(&TASK->phones[i]);
583
584 /* Unsubscribe from any event notifications. */
585 event_cleanup_answerbox(&TASK->answerbox);
586
587 /* Disconnect all connected irqs */
588 ipc_irq_cleanup(&TASK->answerbox);
589
590 /* Disconnect all phones connected to our regular answerbox */
591 ipc_answerbox_slam_phones(&TASK->answerbox, false);
592
593#ifdef CONFIG_UDEBUG
594 /* Clean up kbox thread and communications */
595 ipc_kbox_cleanup();
596#endif
597
598 /* Answer all messages in 'calls' and 'dispatched_calls' queues */
599 irq_spinlock_lock(&TASK->answerbox.lock, true);
600 ipc_cleanup_call_list(&TASK->answerbox.dispatched_calls);
601 ipc_cleanup_call_list(&TASK->answerbox.calls);
602 irq_spinlock_unlock(&TASK->answerbox.lock, true);
603
604 /* Wait for all answers to interrupted synchronous calls to arrive */
605 ipl_t ipl = interrupts_disable();
606 while (!list_empty(&TASK->sync_box_head)) {
607 answerbox_t *box = list_get_instance(TASK->sync_box_head.next,
608 answerbox_t, sync_box_link);
609
610 list_remove(&box->sync_box_link);
611 call_t *call = ipc_wait_for_call(box, SYNCH_NO_TIMEOUT,
612 SYNCH_FLAGS_NONE);
613 ipc_call_free(call);
614 slab_free(ipc_answerbox_slab, box);
615 }
616 interrupts_restore(ipl);
617
618 /* Wait for all answers to asynchronous calls to arrive */
619 while (true) {
620 /*
621 * Go through all phones, until they are all FREE
622 * Locking is not needed, no one else should modify
623 * it when we are in cleanup
624 */
625 for (i = 0; i < IPC_MAX_PHONES; i++) {
626 if (TASK->phones[i].state == IPC_PHONE_HUNGUP &&
627 atomic_get(&TASK->phones[i].active_calls) == 0) {
628 TASK->phones[i].state = IPC_PHONE_FREE;
629 TASK->phones[i].callee = NULL;
630 }
631
632 /*
633 * Just for sure, we might have had some
634 * IPC_PHONE_CONNECTING phones
635 */
636 if (TASK->phones[i].state == IPC_PHONE_CONNECTED)
637 ipc_phone_hangup(&TASK->phones[i]);
638
639 /*
640 * If the hangup succeeded, it has sent a HANGUP
641 * message, the IPC is now in HUNGUP state, we
642 * wait for the reply to come
643 */
644
645 if (TASK->phones[i].state != IPC_PHONE_FREE)
646 break;
647 }
648
649 /* Got into cleanup */
650 if (i == IPC_MAX_PHONES)
651 break;
652
653 call_t *call = ipc_wait_for_call(&TASK->answerbox, SYNCH_NO_TIMEOUT,
654 SYNCH_FLAGS_NONE);
655 ASSERT((call->flags & IPC_CALL_ANSWERED) ||
656 (call->flags & IPC_CALL_NOTIF));
657
658 ipc_call_free(call);
659 }
660}
661
662/** Initilize IPC subsystem
663 *
664 */
665void ipc_init(void)
666{
667 ipc_call_slab = slab_cache_create("ipc_call", sizeof(call_t), 0, NULL,
668 NULL, 0);
669 ipc_answerbox_slab = slab_cache_create("ipc_answerbox",
670 sizeof(answerbox_t), 0, NULL, NULL, 0);
671}
672
673/** List answerbox contents.
674 *
675 * @param taskid Task ID.
676 *
677 */
678void ipc_print_task(task_id_t taskid)
679{
680 irq_spinlock_lock(&tasks_lock, true);
681 task_t *task = task_find_by_id(taskid);
682
683 if (!task) {
684 irq_spinlock_unlock(&tasks_lock, true);
685 return;
686 }
687
688 /* Hand-over-hand locking */
689 irq_spinlock_exchange(&tasks_lock, &task->lock);
690
691 /* Print opened phones & details */
692 printf("PHONE:\n");
693
694 size_t i;
695 for (i = 0; i < IPC_MAX_PHONES; i++) {
696 if (SYNCH_FAILED(mutex_trylock(&task->phones[i].lock))) {
697 printf("%zu: mutex busy\n", i);
698 continue;
699 }
700
701 if (task->phones[i].state != IPC_PHONE_FREE) {
702 printf("%zu: ", i);
703
704 switch (task->phones[i].state) {
705 case IPC_PHONE_CONNECTING:
706 printf("connecting ");
707 break;
708 case IPC_PHONE_CONNECTED:
709 printf("connected to: %p (%" PRIu64 ") ",
710 task->phones[i].callee,
711 task->phones[i].callee->task->taskid);
712 break;
713 case IPC_PHONE_SLAMMED:
714 printf("slammed by: %p ",
715 task->phones[i].callee);
716 break;
717 case IPC_PHONE_HUNGUP:
718 printf("hung up - was: %p ",
719 task->phones[i].callee);
720 break;
721 default:
722 break;
723 }
724
725 printf("active: %" PRIun "\n",
726 atomic_get(&task->phones[i].active_calls));
727 }
728
729 mutex_unlock(&task->phones[i].lock);
730 }
731
732 irq_spinlock_lock(&task->answerbox.lock, false);
733
734 link_t *cur;
735
736 /* Print answerbox - calls */
737 printf("ABOX - CALLS:\n");
738 for (cur = task->answerbox.calls.next; cur != &task->answerbox.calls;
739 cur = cur->next) {
740 call_t *call = list_get_instance(cur, call_t, link);
741 printf("Callid: %p Srctask:%" PRIu64 " M:%" PRIun
742 " A1:%" PRIun " A2:%" PRIun " A3:%" PRIun
743 " A4:%" PRIun " A5:%" PRIun " Flags:%x\n", call,
744 call->sender->taskid,
745 IPC_GET_IMETHOD(call->data), IPC_GET_ARG1(call->data),
746 IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data),
747 IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data),
748 call->flags);
749 }
750
751 /* Print answerbox - dispatched calls */
752 printf("ABOX - DISPATCHED CALLS:\n");
753 for (cur = task->answerbox.dispatched_calls.next;
754 cur != &task->answerbox.dispatched_calls;
755 cur = cur->next) {
756 call_t *call = list_get_instance(cur, call_t, link);
757 printf("Callid: %p Srctask:%" PRIu64 " M:%" PRIun
758 " A1:%" PRIun " A2:%" PRIun " A3:%" PRIun
759 " A4:%" PRIun " A5:%" PRIun " Flags:%x\n", call,
760 call->sender->taskid,
761 IPC_GET_IMETHOD(call->data), IPC_GET_ARG1(call->data),
762 IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data),
763 IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data),
764 call->flags);
765 }
766
767 /* Print answerbox - answers */
768 printf("ABOX - ANSWERS:\n");
769 for (cur = task->answerbox.answers.next;
770 cur != &task->answerbox.answers;
771 cur = cur->next) {
772 call_t *call = list_get_instance(cur, call_t, link);
773 printf("Callid:%p M:%" PRIun " A1:%" PRIun " A2:%" PRIun
774 " A3:%" PRIun " A4:%" PRIun " A5:%" PRIun " Flags:%x\n",
775 call, IPC_GET_IMETHOD(call->data), IPC_GET_ARG1(call->data),
776 IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data),
777 IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data),
778 call->flags);
779 }
780
781 irq_spinlock_unlock(&task->answerbox.lock, false);
782 irq_spinlock_unlock(&task->lock, true);
783}
784
785/** @}
786 */
Note: See TracBrowser for help on using the repository browser.