source: mainline/kernel/generic/src/ipc/ipc.c@ 9c779e9

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

Incoming vs. outgoing answers.

  • Property mode set to 100644
File size: 21.5 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 call->data.task = TASK;
298 }
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 call->data.task = TASK;
410 }
411
412 return ipc_call(newphone, call);
413}
414
415
416/** Wait for a phone call.
417 *
418 * @param box Answerbox expecting the call.
419 * @param usec Timeout in microseconds. See documentation for
420 * waitq_sleep_timeout() for decription of its special
421 * meaning.
422 * @param flags Select mode of sleep operation. See documentation for
423 * waitq_sleep_timeout() for description of its special
424 * meaning.
425 *
426 * @return Recived call structure or NULL.
427 *
428 * To distinguish between a call and an answer, have a look at call->flags.
429 *
430 */
431call_t *ipc_wait_for_call(answerbox_t *box, uint32_t usec, unsigned int flags)
432{
433 call_t *request;
434 uint64_t irq_cnt = 0;
435 uint64_t answer_cnt = 0;
436 uint64_t call_cnt = 0;
437 int rc;
438
439restart:
440 rc = waitq_sleep_timeout(&box->wq, usec, flags);
441 if (SYNCH_FAILED(rc))
442 return NULL;
443
444 irq_spinlock_lock(&box->lock, true);
445 if (!list_empty(&box->irq_notifs)) {
446 /* Count received IRQ notification */
447 irq_cnt++;
448
449 irq_spinlock_lock(&box->irq_lock, false);
450
451 request = list_get_instance(box->irq_notifs.next, 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(box->answers.next, call_t, link);
461 list_remove(&request->link);
462 atomic_dec(&request->data.phone->active_calls);
463 } else if (!list_empty(&box->calls)) {
464 /* Count received call */
465 call_cnt++;
466
467 /* Handle requests */
468 request = list_get_instance(box->calls.next, call_t, link);
469 list_remove(&request->link);
470
471 /* Append request to dispatch queue */
472 list_append(&request->link, &box->dispatched_calls);
473 } else {
474 /* This can happen regularly after ipc_cleanup */
475 irq_spinlock_unlock(&box->lock, true);
476 goto restart;
477 }
478
479 irq_spinlock_pass(&box->lock, &TASK->lock);
480
481 TASK->ipc_info.irq_notif_received += irq_cnt;
482 TASK->ipc_info.answer_received += answer_cnt;
483 TASK->ipc_info.call_received += call_cnt;
484
485 irq_spinlock_unlock(&TASK->lock, true);
486
487 return request;
488}
489
490/** Answer all calls from list with EHANGUP answer.
491 *
492 * @param lst Head of the list to be cleaned up.
493 *
494 */
495void ipc_cleanup_call_list(link_t *lst)
496{
497 while (!list_empty(lst)) {
498 call_t *call = list_get_instance(lst->next, call_t, link);
499 if (call->buffer)
500 free(call->buffer);
501
502 list_remove(&call->link);
503
504 IPC_SET_RETVAL(call->data, EHANGUP);
505 _ipc_answer_free_call(call, true);
506 }
507}
508
509/** Disconnects all phones connected to an answerbox.
510 *
511 * @param box Answerbox to disconnect phones from.
512 * @param notify_box If true, the answerbox will get a hangup message for
513 * each disconnected phone.
514 *
515 */
516void ipc_answerbox_slam_phones(answerbox_t *box, bool notify_box)
517{
518 phone_t *phone;
519 DEADLOCK_PROBE_INIT(p_phonelck);
520
521 call_t *call = notify_box ? ipc_call_alloc(0) : NULL;
522
523 /* Disconnect all phones connected to our answerbox */
524restart_phones:
525 irq_spinlock_lock(&box->lock, true);
526 while (!list_empty(&box->connected_phones)) {
527 phone = list_get_instance(box->connected_phones.next,
528 phone_t, link);
529 if (SYNCH_FAILED(mutex_trylock(&phone->lock))) {
530 irq_spinlock_unlock(&box->lock, true);
531 DEADLOCK_PROBE(p_phonelck, DEADLOCK_THRESHOLD);
532 goto restart_phones;
533 }
534
535 /* Disconnect phone */
536 ASSERT(phone->state == IPC_PHONE_CONNECTED);
537
538 list_remove(&phone->link);
539 phone->state = IPC_PHONE_SLAMMED;
540
541 if (notify_box) {
542 mutex_unlock(&phone->lock);
543 irq_spinlock_unlock(&box->lock, true);
544
545 /*
546 * Send one message to the answerbox for each
547 * phone. Used to make sure the kbox thread
548 * wakes up after the last phone has been
549 * disconnected.
550 */
551 IPC_SET_IMETHOD(call->data, IPC_M_PHONE_HUNGUP);
552 call->flags |= IPC_CALL_DISCARD_ANSWER;
553 _ipc_call(phone, box, call);
554
555 /* Allocate another call in advance */
556 call = ipc_call_alloc(0);
557
558 /* Must start again */
559 goto restart_phones;
560 }
561
562 mutex_unlock(&phone->lock);
563 }
564
565 irq_spinlock_unlock(&box->lock, true);
566
567 /* Free unused call */
568 if (call)
569 ipc_call_free(call);
570}
571
572/** Clean up all IPC communication of the current task.
573 *
574 * Note: ipc_hangup sets returning answerbox to TASK->answerbox, you
575 * have to change it as well if you want to cleanup other tasks than TASK.
576 *
577 */
578void ipc_cleanup(void)
579{
580 /* Disconnect all our phones ('ipc_phone_hangup') */
581 size_t i;
582 for (i = 0; i < IPC_MAX_PHONES; i++)
583 ipc_phone_hangup(&TASK->phones[i]);
584
585 /* Unsubscribe from any event notifications. */
586 event_cleanup_answerbox(&TASK->answerbox);
587
588 /* Disconnect all connected irqs */
589 ipc_irq_cleanup(&TASK->answerbox);
590
591 /* Disconnect all phones connected to our regular answerbox */
592 ipc_answerbox_slam_phones(&TASK->answerbox, false);
593
594#ifdef CONFIG_UDEBUG
595 /* Clean up kbox thread and communications */
596 ipc_kbox_cleanup();
597#endif
598
599 /* Answer all messages in 'calls' and 'dispatched_calls' queues */
600 irq_spinlock_lock(&TASK->answerbox.lock, true);
601 ipc_cleanup_call_list(&TASK->answerbox.dispatched_calls);
602 ipc_cleanup_call_list(&TASK->answerbox.calls);
603 irq_spinlock_unlock(&TASK->answerbox.lock, true);
604
605 /* Wait for all answers to interrupted synchronous calls to arrive */
606 ipl_t ipl = interrupts_disable();
607 while (!list_empty(&TASK->sync_box_head)) {
608 answerbox_t *box = list_get_instance(TASK->sync_box_head.next,
609 answerbox_t, sync_box_link);
610
611 list_remove(&box->sync_box_link);
612 call_t *call = ipc_wait_for_call(box, SYNCH_NO_TIMEOUT,
613 SYNCH_FLAGS_NONE);
614 ipc_call_free(call);
615 slab_free(ipc_answerbox_slab, box);
616 }
617 interrupts_restore(ipl);
618
619 /* Wait for all answers to asynchronous calls to arrive */
620 while (true) {
621 /*
622 * Go through all phones, until they are all FREE
623 * Locking is not needed, no one else should modify
624 * it when we are in cleanup
625 */
626 for (i = 0; i < IPC_MAX_PHONES; i++) {
627 if (TASK->phones[i].state == IPC_PHONE_HUNGUP &&
628 atomic_get(&TASK->phones[i].active_calls) == 0) {
629 TASK->phones[i].state = IPC_PHONE_FREE;
630 TASK->phones[i].callee = NULL;
631 }
632
633 /*
634 * Just for sure, we might have had some
635 * IPC_PHONE_CONNECTING phones
636 */
637 if (TASK->phones[i].state == IPC_PHONE_CONNECTED)
638 ipc_phone_hangup(&TASK->phones[i]);
639
640 /*
641 * If the hangup succeeded, it has sent a HANGUP
642 * message, the IPC is now in HUNGUP state, we
643 * wait for the reply to come
644 */
645
646 if (TASK->phones[i].state != IPC_PHONE_FREE)
647 break;
648 }
649
650 /* Got into cleanup */
651 if (i == IPC_MAX_PHONES)
652 break;
653
654 call_t *call = ipc_wait_for_call(&TASK->answerbox, SYNCH_NO_TIMEOUT,
655 SYNCH_FLAGS_NONE);
656 ASSERT((call->flags & IPC_CALL_ANSWERED) ||
657 (call->flags & IPC_CALL_NOTIF));
658
659 ipc_call_free(call);
660 }
661}
662
663/** Initilize IPC subsystem
664 *
665 */
666void ipc_init(void)
667{
668 ipc_call_slab = slab_cache_create("ipc_call", sizeof(call_t), 0, NULL,
669 NULL, 0);
670 ipc_answerbox_slab = slab_cache_create("ipc_answerbox",
671 sizeof(answerbox_t), 0, NULL, NULL, 0);
672}
673
674/** List answerbox contents.
675 *
676 * @param taskid Task ID.
677 *
678 */
679void ipc_print_task(task_id_t taskid)
680{
681 irq_spinlock_lock(&tasks_lock, true);
682 task_t *task = task_find_by_id(taskid);
683
684 if (!task) {
685 irq_spinlock_unlock(&tasks_lock, true);
686 return;
687 }
688
689 /* Hand-over-hand locking */
690 irq_spinlock_exchange(&tasks_lock, &task->lock);
691
692 printf("[phone id] [calls] [state\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("%-10zu (mutex busy)\n", i);
698 continue;
699 }
700
701 if (task->phones[i].state != IPC_PHONE_FREE) {
702 printf("%-10zu %7" PRIun " ", i,
703 atomic_get(&task->phones[i].active_calls));
704
705 switch (task->phones[i].state) {
706 case IPC_PHONE_CONNECTING:
707 printf("connecting");
708 break;
709 case IPC_PHONE_CONNECTED:
710 printf("connected to %" PRIu64 " (%s)",
711 task->phones[i].callee->task->taskid,
712 task->phones[i].callee->task->name);
713 break;
714 case IPC_PHONE_SLAMMED:
715 printf("slammed by %p",
716 task->phones[i].callee);
717 break;
718 case IPC_PHONE_HUNGUP:
719 printf("hung up by %p",
720 task->phones[i].callee);
721 break;
722 default:
723 break;
724 }
725
726 printf("\n");
727 }
728
729 mutex_unlock(&task->phones[i].lock);
730 }
731
732 irq_spinlock_lock(&task->answerbox.lock, false);
733
734#ifdef __32_BITS__
735 printf("[call id ] [method] [arg1] [arg2] [arg3] [arg4] [arg5]"
736 " [flags] [sender\n");
737#endif
738
739#ifdef __64_BITS__
740 printf("[call id ] [method] [arg1] [arg2] [arg3] [arg4]"
741 " [arg5] [flags] [sender\n");
742#endif
743
744 link_t *cur;
745
746 printf(" --- incomming calls ---\n");
747 for (cur = task->answerbox.calls.next; cur != &task->answerbox.calls;
748 cur = cur->next) {
749 call_t *call = list_get_instance(cur, call_t, link);
750
751#ifdef __32_BITS__
752 printf("%10p ", call);
753#endif
754
755#ifdef __64_BITS__
756 printf("%18p ", call);
757#endif
758
759 printf("%-8" PRIun " %-6" PRIun " %-6" PRIun " %-6" PRIun
760 " %-6" PRIun " %-6" PRIun " %-7x %" PRIu64 " (%s)\n",
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, call->sender->taskid, call->sender->name);
765 }
766
767 printf(" --- dispatched calls ---\n");
768 for (cur = task->answerbox.dispatched_calls.next;
769 cur != &task->answerbox.dispatched_calls;
770 cur = cur->next) {
771 call_t *call = list_get_instance(cur, call_t, link);
772
773#ifdef __32_BITS__
774 printf("%10p ", call);
775#endif
776
777#ifdef __64_BITS__
778 printf("%18p ", call);
779#endif
780
781 printf("%-8" PRIun " %-6" PRIun " %-6" PRIun " %-6" PRIun
782 " %-6" PRIun " %-6" PRIun " %-7x %" PRIu64 " (%s)\n",
783 IPC_GET_IMETHOD(call->data), IPC_GET_ARG1(call->data),
784 IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data),
785 IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data),
786 call->flags, call->sender->taskid, call->sender->name);
787 }
788
789 printf(" --- incoming answers ---\n");
790 for (cur = task->answerbox.answers.next;
791 cur != &task->answerbox.answers;
792 cur = cur->next) {
793 call_t *call = list_get_instance(cur, call_t, link);
794
795#ifdef __32_BITS__
796 printf("%10p ", call);
797#endif
798
799#ifdef __64_BITS__
800 printf("%18p ", call);
801#endif
802
803 printf("%-8" PRIun " %-6" PRIun " %-6" PRIun " %-6" PRIun
804 " %-6" PRIun " %-6" PRIun " %-7x %" PRIu64 " (%s)\n",
805 IPC_GET_IMETHOD(call->data), IPC_GET_ARG1(call->data),
806 IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data),
807 IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data),
808 call->flags, call->sender->taskid, call->sender->name);
809 }
810
811 irq_spinlock_unlock(&task->answerbox.lock, false);
812 irq_spinlock_unlock(&task->lock, true);
813}
814
815/** @}
816 */
Note: See TracBrowser for help on using the repository browser.