source: mainline/kernel/generic/src/ipc/ipc.c@ 95319bd

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 95319bd was 95319bd, checked in by Stanislav Kozina <stanislav.kozina@…>, 15 years ago

Added dummy_load utility.
It just does some dummy load - either in uspace or in system.

  • Property mode set to 100644
File size: 20.9 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 */
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 */
88call_t *ipc_call_alloc(int flags)
89{
90 call_t *call;
91
92 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 */
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 */
116void ipc_answerbox_init(answerbox_t *box, task_t *task)
117{
118 spinlock_initialize(&box->lock, "ipc_box_lock");
119 spinlock_initialize(&box->irq_lock, "ipc_box_irqlock");
120 waitq_initialize(&box->wq);
121 link_initialize(&box->sync_box_link);
122 list_initialize(&box->connected_phones);
123 list_initialize(&box->calls);
124 list_initialize(&box->dispatched_calls);
125 list_initialize(&box->answers);
126 list_initialize(&box->irq_notifs);
127 list_initialize(&box->irq_head);
128 box->task = task;
129}
130
131/** Connect a phone to an answerbox.
132 *
133 * @param phone Initialized phone structure.
134 * @param box Initialized answerbox structure.
135 */
136void ipc_phone_connect(phone_t *phone, answerbox_t *box)
137{
138 mutex_lock(&phone->lock);
139
140 phone->state = IPC_PHONE_CONNECTED;
141 phone->callee = box;
142
143 spinlock_lock(&box->lock);
144 list_append(&phone->link, &box->connected_phones);
145 spinlock_unlock(&box->lock);
146
147 mutex_unlock(&phone->lock);
148}
149
150/** Initialize a phone structure.
151 *
152 * @param phone Phone structure to be initialized.
153 */
154void ipc_phone_init(phone_t *phone)
155{
156 mutex_initialize(&phone->lock, MUTEX_PASSIVE);
157 phone->callee = NULL;
158 phone->state = IPC_PHONE_FREE;
159 atomic_set(&phone->active_calls, 0);
160}
161
162/** Helper function to facilitate synchronous calls.
163 *
164 * @param phone Destination kernel phone structure.
165 * @param request Call structure with request.
166 *
167 * @return EOK on success or EINTR if the sleep was interrupted.
168 */
169int ipc_call_sync(phone_t *phone, call_t *request)
170{
171 answerbox_t *sync_box;
172 ipl_t ipl;
173
174 sync_box = slab_alloc(ipc_answerbox_slab, 0);
175 ipc_answerbox_init(sync_box, TASK);
176
177 /*
178 * Put the answerbox on the TASK's list of synchronous answerboxes so
179 * that it can be cleaned up if the call is interrupted.
180 */
181 ipl = interrupts_disable();
182 spinlock_lock(&TASK->lock);
183 list_append(&sync_box->sync_box_link, &TASK->sync_box_head);
184 spinlock_unlock(&TASK->lock);
185 interrupts_restore(ipl);
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 (void) interrupts_disable();
202 spinlock_lock(&TASK->lock);
203 list_remove(&sync_box->sync_box_link);
204 spinlock_unlock(&TASK->lock);
205 interrupts_restore(ipl);
206
207 slab_free(ipc_answerbox_slab, sync_box);
208 return EOK;
209}
210
211/** Answer a message which was not dispatched and is not listed in any queue.
212 *
213 * @param call Call structure to be answered.
214 * @param selflocked If true, then TASK->answebox is locked.
215 */
216static void _ipc_answer_free_call(call_t *call, bool selflocked)
217{
218 answerbox_t *callerbox = call->callerbox;
219 bool do_lock = ((!selflocked) || callerbox != (&TASK->answerbox));
220
221 /* Count sent answer */
222 spinlock_lock(&TASK->lock);
223 TASK->ipc_info.answer_sent++;
224 spinlock_unlock(&TASK->lock);
225
226 call->flags |= IPC_CALL_ANSWERED;
227
228 if (call->flags & IPC_CALL_FORWARDED) {
229 if (call->caller_phone) {
230 /* Demasquerade the caller phone. */
231 call->data.phone = call->caller_phone;
232 }
233 }
234
235 if (do_lock)
236 spinlock_lock(&callerbox->lock);
237 list_append(&call->link, &callerbox->answers);
238 if (do_lock)
239 spinlock_unlock(&callerbox->lock);
240 waitq_wakeup(&callerbox->wq, WAKEUP_FIRST);
241}
242
243/** Answer a message which is in a callee queue.
244 *
245 * @param box Answerbox that is answering the message.
246 * @param call Modified request that is being sent back.
247 */
248void ipc_answer(answerbox_t *box, call_t *call)
249{
250 /* Remove from active box */
251 spinlock_lock(&box->lock);
252 list_remove(&call->link);
253 spinlock_unlock(&box->lock);
254 /* Send back answer */
255 _ipc_answer_free_call(call, false);
256}
257
258/** Simulate sending back a message.
259 *
260 * Most errors are better handled by forming a normal backward
261 * message and sending it as a normal answer.
262 *
263 * @param phone Phone structure the call should appear to come from.
264 * @param call Call structure to be answered.
265 * @param err Return value to be used for the answer.
266 */
267void ipc_backsend_err(phone_t *phone, call_t *call, unative_t err)
268{
269 call->data.phone = phone;
270 atomic_inc(&phone->active_calls);
271 IPC_SET_RETVAL(call->data, err);
272 _ipc_answer_free_call(call, false);
273}
274
275/** Unsafe unchecking version of ipc_call.
276 *
277 * @param phone Phone structure the call comes from.
278 * @param box Destination answerbox structure.
279 * @param call Call structure with request.
280 */
281static void _ipc_call(phone_t *phone, answerbox_t *box, call_t *call)
282{
283 /* Count sent ipc call */
284 spinlock_lock(&TASK->lock);
285 TASK->ipc_info.call_sent++;
286 spinlock_unlock(&TASK->lock);
287
288 if (!(call->flags & IPC_CALL_FORWARDED)) {
289 atomic_inc(&phone->active_calls);
290 call->data.phone = phone;
291 }
292
293 spinlock_lock(&box->lock);
294 list_append(&call->link, &box->calls);
295 spinlock_unlock(&box->lock);
296 waitq_wakeup(&box->wq, WAKEUP_FIRST);
297}
298
299/** Send an asynchronous request using a phone to an answerbox.
300 *
301 * @param phone Phone structure the call comes from and which is
302 * connected to the destination answerbox.
303 * @param call Call structure with request.
304 *
305 * @return Return 0 on success, ENOENT on error.
306 */
307int ipc_call(phone_t *phone, call_t *call)
308{
309 answerbox_t *box;
310
311 mutex_lock(&phone->lock);
312 if (phone->state != IPC_PHONE_CONNECTED) {
313 mutex_unlock(&phone->lock);
314 if (call->flags & IPC_CALL_FORWARDED) {
315 IPC_SET_RETVAL(call->data, EFORWARD);
316 _ipc_answer_free_call(call, false);
317 } else {
318 if (phone->state == IPC_PHONE_HUNGUP)
319 ipc_backsend_err(phone, call, EHANGUP);
320 else
321 ipc_backsend_err(phone, call, ENOENT);
322 }
323 return ENOENT;
324 }
325 box = phone->callee;
326 _ipc_call(phone, box, call);
327
328 mutex_unlock(&phone->lock);
329 return 0;
330}
331
332/** Disconnect phone from answerbox.
333 *
334 * This call leaves the phone in the HUNGUP state. The change to 'free' is done
335 * lazily later.
336 *
337 * @param phone Phone structure to be hung up.
338 *
339 * @return Return 0 if the phone is disconnected.
340 * Return -1 if the phone was already disconnected.
341 */
342int ipc_phone_hangup(phone_t *phone)
343{
344 answerbox_t *box;
345 call_t *call;
346
347 mutex_lock(&phone->lock);
348 if (phone->state == IPC_PHONE_FREE ||
349 phone->state == IPC_PHONE_HUNGUP ||
350 phone->state == IPC_PHONE_CONNECTING) {
351 mutex_unlock(&phone->lock);
352 return -1;
353 }
354 box = phone->callee;
355 if (phone->state != IPC_PHONE_SLAMMED) {
356 /* Remove myself from answerbox */
357 spinlock_lock(&box->lock);
358 list_remove(&phone->link);
359 spinlock_unlock(&box->lock);
360
361 call = ipc_call_alloc(0);
362 IPC_SET_METHOD(call->data, IPC_M_PHONE_HUNGUP);
363 call->flags |= IPC_CALL_DISCARD_ANSWER;
364 _ipc_call(phone, box, call);
365 }
366
367 phone->state = IPC_PHONE_HUNGUP;
368 mutex_unlock(&phone->lock);
369
370 return 0;
371}
372
373/** Forwards call from one answerbox to another one.
374 *
375 * @param call Call structure to be redirected.
376 * @param newphone Phone structure to target answerbox.
377 * @param oldbox Old answerbox structure.
378 * @param mode Flags that specify mode of the forward operation.
379 *
380 * @return Return 0 if forwarding succeeded or an error code if
381 * there was error.
382 *
383 * The return value serves only as an information for the forwarder,
384 * the original caller is notified automatically with EFORWARD.
385 */
386int ipc_forward(call_t *call, phone_t *newphone, answerbox_t *oldbox, int mode)
387{
388 /* Count forwarded calls */
389 spinlock_lock(&TASK->lock);
390 TASK->ipc_info.forwarded++;
391 spinlock_unlock(&TASK->lock);
392
393 spinlock_lock(&oldbox->lock);
394 list_remove(&call->link);
395 spinlock_unlock(&oldbox->lock);
396
397 if (mode & IPC_FF_ROUTE_FROM_ME) {
398 if (!call->caller_phone)
399 call->caller_phone = call->data.phone;
400 call->data.phone = newphone;
401 }
402
403 return ipc_call(newphone, call);
404}
405
406
407/** Wait for a phone call.
408 *
409 * @param box Answerbox expecting the call.
410 * @param usec Timeout in microseconds. See documentation for
411 * waitq_sleep_timeout() for decription of its special
412 * meaning.
413 * @param flags Select mode of sleep operation. See documentation for
414 * waitq_sleep_timeout() for description of its special
415 * meaning.
416 * @return Recived call structure or NULL.
417 *
418 * To distinguish between a call and an answer, have a look at call->flags.
419 */
420call_t *ipc_wait_for_call(answerbox_t *box, uint32_t usec, int flags)
421{
422 call_t *request;
423 ipl_t ipl;
424 int rc;
425
426restart:
427 rc = waitq_sleep_timeout(&box->wq, usec, flags);
428 if (SYNCH_FAILED(rc))
429 return NULL;
430
431 spinlock_lock(&box->lock);
432 if (!list_empty(&box->irq_notifs)) {
433
434 /* Count recieved IRQ notification */
435 spinlock_lock(&TASK->lock);
436 TASK->ipc_info.irq_notif_recieved++;
437 spinlock_unlock(&TASK->lock);
438
439 ipl = interrupts_disable();
440 spinlock_lock(&box->irq_lock);
441
442 request = list_get_instance(box->irq_notifs.next, call_t, link);
443 list_remove(&request->link);
444
445 spinlock_unlock(&box->irq_lock);
446 interrupts_restore(ipl);
447 } else if (!list_empty(&box->answers)) {
448 /* Count recieved answer */
449 spinlock_lock(&TASK->lock);
450 TASK->ipc_info.answer_recieved++;
451 spinlock_unlock(&TASK->lock);
452
453 /* Handle asynchronous answers */
454 request = list_get_instance(box->answers.next, call_t, link);
455 list_remove(&request->link);
456 atomic_dec(&request->data.phone->active_calls);
457 } else if (!list_empty(&box->calls)) {
458 /* Count recieved call */
459 spinlock_lock(&TASK->lock);
460 TASK->ipc_info.call_recieved++;
461 spinlock_unlock(&TASK->lock);
462
463 /* Handle requests */
464 request = list_get_instance(box->calls.next, call_t, link);
465 list_remove(&request->link);
466 /* Append request to dispatch queue */
467 list_append(&request->link, &box->dispatched_calls);
468 } else {
469 /* This can happen regularly after ipc_cleanup */
470 spinlock_unlock(&box->lock);
471 goto restart;
472 }
473 spinlock_unlock(&box->lock);
474 return request;
475}
476
477/** Answer all calls from list with EHANGUP answer.
478 *
479 * @param lst Head of the list to be cleaned up.
480 */
481void ipc_cleanup_call_list(link_t *lst)
482{
483 call_t *call;
484
485 while (!list_empty(lst)) {
486 call = list_get_instance(lst->next, call_t, link);
487 if (call->buffer)
488 free(call->buffer);
489 list_remove(&call->link);
490
491 IPC_SET_RETVAL(call->data, EHANGUP);
492 _ipc_answer_free_call(call, true);
493 }
494}
495
496/** Disconnects all phones connected to an answerbox.
497 *
498 * @param box Answerbox to disconnect phones from.
499 * @param notify_box If true, the answerbox will get a hangup message for
500 * each disconnected phone.
501 */
502void ipc_answerbox_slam_phones(answerbox_t *box, bool notify_box)
503{
504 phone_t *phone;
505 DEADLOCK_PROBE_INIT(p_phonelck);
506 ipl_t ipl;
507 call_t *call;
508
509 call = notify_box ? ipc_call_alloc(0) : NULL;
510
511 /* Disconnect all phones connected to our answerbox */
512restart_phones:
513 ipl = interrupts_disable();
514 spinlock_lock(&box->lock);
515 while (!list_empty(&box->connected_phones)) {
516 phone = list_get_instance(box->connected_phones.next,
517 phone_t, link);
518 if (SYNCH_FAILED(mutex_trylock(&phone->lock))) {
519 spinlock_unlock(&box->lock);
520 interrupts_restore(ipl);
521 DEADLOCK_PROBE(p_phonelck, DEADLOCK_THRESHOLD);
522 goto restart_phones;
523 }
524
525 /* Disconnect phone */
526 ASSERT(phone->state == IPC_PHONE_CONNECTED);
527
528 list_remove(&phone->link);
529 phone->state = IPC_PHONE_SLAMMED;
530
531 if (notify_box) {
532 mutex_unlock(&phone->lock);
533 spinlock_unlock(&box->lock);
534 interrupts_restore(ipl);
535
536 /*
537 * Send one message to the answerbox for each
538 * phone. Used to make sure the kbox thread
539 * wakes up after the last phone has been
540 * disconnected.
541 */
542 IPC_SET_METHOD(call->data, IPC_M_PHONE_HUNGUP);
543 call->flags |= IPC_CALL_DISCARD_ANSWER;
544 _ipc_call(phone, box, call);
545
546 /* Allocate another call in advance */
547 call = ipc_call_alloc(0);
548
549 /* Must start again */
550 goto restart_phones;
551 }
552
553 mutex_unlock(&phone->lock);
554 }
555
556 spinlock_unlock(&box->lock);
557 interrupts_restore(ipl);
558
559 /* Free unused call */
560 if (call)
561 ipc_call_free(call);
562}
563
564/** Cleans up all IPC communication of the current task.
565 *
566 * Note: ipc_hangup sets returning answerbox to TASK->answerbox, you
567 * have to change it as well if you want to cleanup other tasks than TASK.
568 */
569void ipc_cleanup(void)
570{
571 int i;
572 call_t *call;
573 ipl_t ipl;
574
575 /* Disconnect all our phones ('ipc_phone_hangup') */
576 for (i = 0; i < IPC_MAX_PHONES; i++)
577 ipc_phone_hangup(&TASK->phones[i]);
578
579 /* Unsubscribe from any event notifications. */
580 event_cleanup_answerbox(&TASK->answerbox);
581
582 /* Disconnect all connected irqs */
583 ipc_irq_cleanup(&TASK->answerbox);
584
585 /* Disconnect all phones connected to our regular answerbox */
586 ipc_answerbox_slam_phones(&TASK->answerbox, false);
587
588#ifdef CONFIG_UDEBUG
589 /* Clean up kbox thread and communications */
590 ipc_kbox_cleanup();
591#endif
592
593 /* Answer all messages in 'calls' and 'dispatched_calls' queues */
594 spinlock_lock(&TASK->answerbox.lock);
595 ipc_cleanup_call_list(&TASK->answerbox.dispatched_calls);
596 ipc_cleanup_call_list(&TASK->answerbox.calls);
597 spinlock_unlock(&TASK->answerbox.lock);
598
599 /* Wait for all answers to interrupted synchronous calls to arrive */
600 ipl = interrupts_disable();
601 while (!list_empty(&TASK->sync_box_head)) {
602 answerbox_t *box = list_get_instance(TASK->sync_box_head.next,
603 answerbox_t, sync_box_link);
604
605 list_remove(&box->sync_box_link);
606 call = ipc_wait_for_call(box, SYNCH_NO_TIMEOUT,
607 SYNCH_FLAGS_NONE);
608 ipc_call_free(call);
609 slab_free(ipc_answerbox_slab, box);
610 }
611 interrupts_restore(ipl);
612
613 /* Wait for all answers to asynchronous calls to arrive */
614 while (1) {
615 /* Go through all phones, until all are FREE... */
616 /* Locking not needed, no one else should modify
617 * it, when we are in cleanup */
618 for (i = 0; i < IPC_MAX_PHONES; i++) {
619 if (TASK->phones[i].state == IPC_PHONE_HUNGUP &&
620 atomic_get(&TASK->phones[i].active_calls) == 0) {
621 TASK->phones[i].state = IPC_PHONE_FREE;
622 TASK->phones[i].callee = NULL;
623 }
624
625 /* Just for sure, we might have had some
626 * IPC_PHONE_CONNECTING phones */
627 if (TASK->phones[i].state == IPC_PHONE_CONNECTED)
628 ipc_phone_hangup(&TASK->phones[i]);
629 /* If the hangup succeeded, it has sent a HANGUP
630 * message, the IPC is now in HUNGUP state, we
631 * wait for the reply to come */
632
633 if (TASK->phones[i].state != IPC_PHONE_FREE)
634 break;
635 }
636 /* Voila, got into cleanup */
637 if (i == IPC_MAX_PHONES)
638 break;
639
640 call = ipc_wait_for_call(&TASK->answerbox, SYNCH_NO_TIMEOUT,
641 SYNCH_FLAGS_NONE);
642 ASSERT((call->flags & IPC_CALL_ANSWERED) ||
643 (call->flags & IPC_CALL_NOTIF));
644
645 /*
646 * Record the receipt of this call in the current task's counter
647 * of active calls. IPC_M_PHONE_HUNGUP calls do not contribute
648 * to this counter so do not record answers to them either.
649 */
650 if (!(call->flags & IPC_CALL_DISCARD_ANSWER))
651 atomic_dec(&TASK->active_calls);
652 ipc_call_free(call);
653 }
654}
655
656
657/** Initilize IPC subsystem */
658void ipc_init(void)
659{
660 ipc_call_slab = slab_cache_create("ipc_call", sizeof(call_t), 0, NULL,
661 NULL, 0);
662 ipc_answerbox_slab = slab_cache_create("ipc_answerbox",
663 sizeof(answerbox_t), 0, NULL, NULL, 0);
664}
665
666
667/** List answerbox contents.
668 *
669 * @param taskid Task ID.
670 */
671void ipc_print_task(task_id_t taskid)
672{
673 task_t *task;
674 int i;
675 call_t *call;
676 link_t *tmp;
677
678 spinlock_lock(&tasks_lock);
679 task = task_find_by_id(taskid);
680 if (task)
681 spinlock_lock(&task->lock);
682 spinlock_unlock(&tasks_lock);
683 if (!task)
684 return;
685
686 /* Print opened phones & details */
687 printf("PHONE:\n");
688 for (i = 0; i < IPC_MAX_PHONES; i++) {
689 if (SYNCH_FAILED(mutex_trylock(&task->phones[i].lock))) {
690 printf("%d: mutex busy\n", i);
691 continue;
692 }
693 if (task->phones[i].state != IPC_PHONE_FREE) {
694 printf("%d: ", i);
695 switch (task->phones[i].state) {
696 case IPC_PHONE_CONNECTING:
697 printf("connecting ");
698 break;
699 case IPC_PHONE_CONNECTED:
700 printf("connected to: %p ",
701 task->phones[i].callee);
702 break;
703 case IPC_PHONE_SLAMMED:
704 printf("slammed by: %p ",
705 task->phones[i].callee);
706 break;
707 case IPC_PHONE_HUNGUP:
708 printf("hung up - was: %p ",
709 task->phones[i].callee);
710 break;
711 default:
712 break;
713 }
714 printf("active: %ld\n",
715 atomic_get(&task->phones[i].active_calls));
716 }
717 mutex_unlock(&task->phones[i].lock);
718 }
719
720
721 /* Print answerbox - calls */
722 spinlock_lock(&task->answerbox.lock);
723 printf("ABOX - CALLS:\n");
724 for (tmp = task->answerbox.calls.next; tmp != &task->answerbox.calls;
725 tmp = tmp->next) {
726 call = list_get_instance(tmp, call_t, link);
727 printf("Callid: %p Srctask:%" PRIu64 " M:%" PRIun
728 " A1:%" PRIun " A2:%" PRIun " A3:%" PRIun
729 " A4:%" PRIun " A5:%" PRIun " Flags:%x\n", call,
730 call->sender->taskid,
731 IPC_GET_METHOD(call->data), IPC_GET_ARG1(call->data),
732 IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data),
733 IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data),
734 call->flags);
735 }
736 /* Print answerbox - calls */
737 printf("ABOX - DISPATCHED CALLS:\n");
738 for (tmp = task->answerbox.dispatched_calls.next;
739 tmp != &task->answerbox.dispatched_calls;
740 tmp = tmp->next) {
741 call = list_get_instance(tmp, call_t, link);
742 printf("Callid: %p Srctask:%" PRIu64 " M:%" PRIun
743 " A1:%" PRIun " A2:%" PRIun " A3:%" PRIun
744 " A4:%" PRIun " A5:%" PRIun " Flags:%x\n", call,
745 call->sender->taskid,
746 IPC_GET_METHOD(call->data), IPC_GET_ARG1(call->data),
747 IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data),
748 IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data),
749 call->flags);
750 }
751 /* Print answerbox - calls */
752 printf("ABOX - ANSWERS:\n");
753 for (tmp = task->answerbox.answers.next;
754 tmp != &task->answerbox.answers;
755 tmp = tmp->next) {
756 call = list_get_instance(tmp, call_t, link);
757 printf("Callid:%p M:%" PRIun " A1:%" PRIun " A2:%" PRIun
758 " A3:%" PRIun " A4:%" PRIun " A5:%" PRIun " Flags:%x\n",
759 call, IPC_GET_METHOD(call->data), IPC_GET_ARG1(call->data),
760 IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data),
761 IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data),
762 call->flags);
763 }
764
765 spinlock_unlock(&task->answerbox.lock);
766 spinlock_unlock(&task->lock);
767}
768
769/** @}
770 */
Note: See TracBrowser for help on using the repository browser.