source: mainline/kernel/generic/src/ipc/ipc.c@ 16f9782

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

Track client data by client task ID instead of client task hash.

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