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

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

Turn phone→lock into mutex.

  • Property mode set to 100644
File size: 16.7 KB
RevLine 
[6d9c49a]1/*
[df4ed85]2 * Copyright (c) 2006 Ondrej Palkovsky
[6d9c49a]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
[cc73a8a1]29/** @addtogroup genericipc
[b45c443]30 * @{
31 */
32/** @file
33 */
34
[6d9c49a]35/* Lock ordering
36 *
[8b243f2]37 * First the answerbox, then the phone.
[6d9c49a]38 */
39
[ff48a15]40#include <synch/synch.h>
[2ba7810]41#include <synch/spinlock.h>
[ff48a15]42#include <synch/mutex.h>
[2ba7810]43#include <synch/waitq.h>
[bd5a663]44#include <synch/synch.h>
[6d9c49a]45#include <ipc/ipc.h>
46#include <errno.h>
47#include <mm/slab.h>
48#include <arch.h>
49#include <proc/task.h>
50#include <memstr.h>
51#include <debug.h>
52
53#include <print.h>
54#include <proc/thread.h>
[5626277]55#include <arch/interrupt.h>
[162f919]56#include <ipc/irq.h>
[6d9c49a]57
[8b243f2]58/** Open channel that is assigned automatically to new tasks */
[e74cb73]59answerbox_t *ipc_phone_0 = NULL;
[6d9c49a]60
61static slab_cache_t *ipc_call_slab;
62
[8b243f2]63/** Initialize a call structure.
64 *
65 * @param call Call structure to be initialized.
66 */
[ba81cab]67static void _ipc_call_init(call_t *call)
68{
[8b243f2]69 memsetb((uintptr_t) call, sizeof(*call), 0);
[ba81cab]70 call->callerbox = &TASK->answerbox;
71 call->sender = TASK;
[7918fce]72 call->buffer = NULL;
[ba81cab]73}
74
[8b243f2]75/** Allocate and initialize a call structure.
[6d9c49a]76 *
[8b243f2]77 * The call is initialized, so that the reply will be directed to
78 * TASK->answerbox.
79 *
80 * @param flags Parameters for slab_alloc (e.g FRAME_ATOMIC).
[5626277]81 *
[8b243f2]82 * @return If flags permit it, return NULL, or initialized kernel
83 * call structure.
[6d9c49a]84 */
[8b243f2]85call_t *ipc_call_alloc(int flags)
[6d9c49a]86{
87 call_t *call;
88
[5626277]89 call = slab_alloc(ipc_call_slab, flags);
[ba81cab]90 _ipc_call_init(call);
[6d9c49a]91
92 return call;
93}
94
[8b243f2]95/** Initialize a statically allocated call structure.
96 *
97 * @param call Statically allocated kernel call structure to be
98 * initialized.
99 */
[ba81cab]100void ipc_call_static_init(call_t *call)
[e74cb73]101{
[ba81cab]102 _ipc_call_init(call);
103 call->flags |= IPC_CALL_STATIC_ALLOC;
[e74cb73]104}
105
[bd72c3e9]106/** Deallocate a call structure.
[8b243f2]107 *
108 * @param call Call structure to be freed.
109 */
[6d9c49a]110void ipc_call_free(call_t *call)
111{
[8b243f2]112 ASSERT(!(call->flags & IPC_CALL_STATIC_ALLOC));
[7918fce]113 /* Check to see if we have data in the IPC_M_DATA_SEND buffer. */
114 if (call->buffer)
115 free(call->buffer);
[6d9c49a]116 slab_free(ipc_call_slab, call);
117}
118
[8b243f2]119/** Initialize an answerbox structure.
120 *
121 * @param box Answerbox structure to be initialized.
[12ab886]122 * @param task Task to which the answerbox belongs.
[6d9c49a]123 */
[12ab886]124void ipc_answerbox_init(answerbox_t *box, task_t *task)
[6d9c49a]125{
[2ba7810]126 spinlock_initialize(&box->lock, "ipc_box_lock");
[5626277]127 spinlock_initialize(&box->irq_lock, "ipc_box_irqlock");
[2ba7810]128 waitq_initialize(&box->wq);
[6d9c49a]129 list_initialize(&box->connected_phones);
130 list_initialize(&box->calls);
131 list_initialize(&box->dispatched_calls);
132 list_initialize(&box->answers);
[5626277]133 list_initialize(&box->irq_notifs);
[b14e35f2]134 list_initialize(&box->irq_head);
[12ab886]135 box->task = task;
[6d9c49a]136}
137
[8b243f2]138/** Connect a phone to an answerbox.
139 *
140 * @param phone Initialized phone structure.
141 * @param box Initialized answerbox structure.
142 */
[2ba7810]143void ipc_phone_connect(phone_t *phone, answerbox_t *box)
[6d9c49a]144{
[ff48a15]145 mutex_lock(&phone->lock);
[ba81cab]146
[eb3d379]147 phone->state = IPC_PHONE_CONNECTED;
[6d9c49a]148 phone->callee = box;
[e74cb73]149
[2ba7810]150 spinlock_lock(&box->lock);
[c4e4507]151 list_append(&phone->link, &box->connected_phones);
[2ba7810]152 spinlock_unlock(&box->lock);
[ba81cab]153
[ff48a15]154 mutex_unlock(&phone->lock);
[2ba7810]155}
156
[8b243f2]157/** Initialize a phone structure.
158 *
159 * @param phone Phone structure to be initialized.
[2ba7810]160 */
161void ipc_phone_init(phone_t *phone)
162{
[ff48a15]163 mutex_initialize(&phone->lock);
[2ba7810]164 phone->callee = NULL;
[eb3d379]165 phone->state = IPC_PHONE_FREE;
[9f22213]166 atomic_set(&phone->active_calls, 0);
[6d9c49a]167}
168
[8b243f2]169/** Helper function to facilitate synchronous calls.
170 *
171 * @param phone Destination kernel phone structure.
172 * @param request Call structure with request.
173 */
[631ca4d]174void ipc_call_sync(phone_t *phone, call_t *request)
175{
176 answerbox_t sync_box;
177
[12ab886]178 ipc_answerbox_init(&sync_box, TASK);
[631ca4d]179
[8b243f2]180 /* We will receive data in a special box. */
[631ca4d]181 request->callerbox = &sync_box;
182
183 ipc_call(phone, request);
[116d1ef4]184 ipc_wait_for_call(&sync_box, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE);
[631ca4d]185}
[6d9c49a]186
[8b243f2]187/** Answer a message which was not dispatched and is not listed in any queue.
188 *
189 * @param call Call structure to be answered.
[ba81cab]190 */
191static void _ipc_answer_free_call(call_t *call)
192{
193 answerbox_t *callerbox = call->callerbox;
194
195 call->flags |= IPC_CALL_ANSWERED;
196
197 spinlock_lock(&callerbox->lock);
[c4e4507]198 list_append(&call->link, &callerbox->answers);
[ba81cab]199 spinlock_unlock(&callerbox->lock);
[5c8ba05]200 waitq_wakeup(&callerbox->wq, WAKEUP_FIRST);
[ba81cab]201}
202
[8b243f2]203/** Answer a message which is in a callee queue.
[ba81cab]204 *
[8b243f2]205 * @param box Answerbox that is answering the message.
206 * @param call Modified request that is being sent back.
[ba81cab]207 */
208void ipc_answer(answerbox_t *box, call_t *call)
209{
210 /* Remove from active box */
211 spinlock_lock(&box->lock);
[c4e4507]212 list_remove(&call->link);
[ba81cab]213 spinlock_unlock(&box->lock);
214 /* Send back answer */
215 _ipc_answer_free_call(call);
216}
217
[8b243f2]218/** Simulate sending back a message.
[7c7aae16]219 *
220 * Most errors are better handled by forming a normal backward
221 * message and sending it as a normal answer.
[8b243f2]222 *
223 * @param phone Phone structure the call should appear to come from.
224 * @param call Call structure to be answered.
225 * @param err Return value to be used for the answer.
[7c7aae16]226 */
[7f1c620]227void ipc_backsend_err(phone_t *phone, call_t *call, unative_t err)
[7c7aae16]228{
229 call->data.phone = phone;
230 atomic_inc(&phone->active_calls);
[eb3d379]231 IPC_SET_RETVAL(call->data, err);
[7c7aae16]232 _ipc_answer_free_call(call);
233}
234
[8b243f2]235/** Unsafe unchecking version of ipc_call.
236 *
237 * @param phone Phone structure the call comes from.
238 * @param box Destination answerbox structure.
[7c5bcc0]239 * @param call Call structure with request.
[8b243f2]240 */
[fbcfd458]241static void _ipc_call(phone_t *phone, answerbox_t *box, call_t *call)
242{
[8b243f2]243 if (!(call->flags & IPC_CALL_FORWARDED)) {
[9f22213]244 atomic_inc(&phone->active_calls);
245 call->data.phone = phone;
246 }
[fbcfd458]247
248 spinlock_lock(&box->lock);
[c4e4507]249 list_append(&call->link, &box->calls);
[fbcfd458]250 spinlock_unlock(&box->lock);
[5c8ba05]251 waitq_wakeup(&box->wq, WAKEUP_FIRST);
[fbcfd458]252}
253
[8b243f2]254/** Send an asynchronous request using a phone to an answerbox.
255 *
256 * @param phone Phone structure the call comes from and which is
257 * connected to the destination answerbox.
258 * @param call Call structure with request.
[6d9c49a]259 *
[8b243f2]260 * @return Return 0 on success, ENOENT on error.
[6d9c49a]261 */
[9f22213]262int ipc_call(phone_t *phone, call_t *call)
[6d9c49a]263{
[ba81cab]264 answerbox_t *box;
[6d9c49a]265
[ff48a15]266 mutex_lock(&phone->lock);
[eb3d379]267 if (phone->state != IPC_PHONE_CONNECTED) {
[ff48a15]268 mutex_unlock(&phone->lock);
[9f22213]269 if (call->flags & IPC_CALL_FORWARDED) {
270 IPC_SET_RETVAL(call->data, EFORWARD);
[7c7aae16]271 _ipc_answer_free_call(call);
[eb3d379]272 } else {
273 if (phone->state == IPC_PHONE_HUNGUP)
[7c7aae16]274 ipc_backsend_err(phone, call, EHANGUP);
[9f22213]275 else
[7c7aae16]276 ipc_backsend_err(phone, call, ENOENT);
[9f22213]277 }
278 return ENOENT;
[ba81cab]279 }
[eb3d379]280 box = phone->callee;
[fbcfd458]281 _ipc_call(phone, box, call);
282
[ff48a15]283 mutex_unlock(&phone->lock);
[9f22213]284 return 0;
[fbcfd458]285}
286
[8b243f2]287/** Disconnect phone from answerbox.
[fbcfd458]288 *
[8b243f2]289 * This call leaves the phone in the HUNGUP state. The change to 'free' is done
[eb3d379]290 * lazily later.
[fbcfd458]291 *
[8b243f2]292 * @param phone Phone structure to be hung up.
[eb3d379]293 *
[8b243f2]294 * @return Return 0 if the phone is disconnected.
295 * Return -1 if the phone was already disconnected.
[fbcfd458]296 */
[d8f7362]297int ipc_phone_hangup(phone_t *phone)
[fbcfd458]298{
299 answerbox_t *box;
300 call_t *call;
301
[ff48a15]302 mutex_lock(&phone->lock);
[7918fce]303 if (phone->state == IPC_PHONE_FREE ||
304 phone->state == IPC_PHONE_HUNGUP ||
[8b243f2]305 phone->state == IPC_PHONE_CONNECTING) {
[ff48a15]306 mutex_unlock(&phone->lock);
[eb3d379]307 return -1;
[fbcfd458]308 }
[eb3d379]309 box = phone->callee;
310 if (phone->state != IPC_PHONE_SLAMMED) {
311 /* Remove myself from answerbox */
312 spinlock_lock(&box->lock);
[c4e4507]313 list_remove(&phone->link);
[eb3d379]314 spinlock_unlock(&box->lock);
[6d9c49a]315
[eb3d379]316 if (phone->state != IPC_PHONE_SLAMMED) {
317 call = ipc_call_alloc(0);
318 IPC_SET_METHOD(call->data, IPC_M_PHONE_HUNGUP);
319 call->flags |= IPC_CALL_DISCARD_ANSWER;
320 _ipc_call(phone, box, call);
321 }
322 }
[fbcfd458]323
[eb3d379]324 phone->state = IPC_PHONE_HUNGUP;
[ff48a15]325 mutex_unlock(&phone->lock);
[fbcfd458]326
327 return 0;
[2ba7810]328}
329
[8b243f2]330/** Forwards call from one answerbox to another one.
[2ba7810]331 *
[8b243f2]332 * @param call Call structure to be redirected.
333 * @param newphone Phone structure to target answerbox.
334 * @param oldbox Old answerbox structure.
[d40a8ff]335 * @param mode Flags that specify mode of the forward operation.
[8b243f2]336 *
337 * @return Return 0 if forwarding succeeded or an error code if
338 * there was error.
[9f22213]339 *
[8b243f2]340 * The return value serves only as an information for the forwarder,
341 * the original caller is notified automatically with EFORWARD.
[2ba7810]342 */
[d40a8ff]343int ipc_forward(call_t *call, phone_t *newphone, answerbox_t *oldbox, int mode)
[2ba7810]344{
345 spinlock_lock(&oldbox->lock);
[c4e4507]346 list_remove(&call->link);
[2ba7810]347 spinlock_unlock(&oldbox->lock);
348
[9201f47]349 if (mode & IPC_FF_ROUTE_FROM_ME)
350 call->data.phone = newphone;
351
[9f22213]352 return ipc_call(newphone, call);
[6d9c49a]353}
354
355
[8b243f2]356/** Wait for a phone call.
[6d9c49a]357 *
[8b243f2]358 * @param box Answerbox expecting the call.
359 * @param usec Timeout in microseconds. See documentation for
360 * waitq_sleep_timeout() for decription of its special
361 * meaning.
362 * @param flags Select mode of sleep operation. See documentation for
363 * waitq_sleep_timeout() for description of its special
364 * meaning.
365 * @return Recived call structure or NULL.
366 *
367 * To distinguish between a call and an answer, have a look at call->flags.
[6d9c49a]368 */
[8b243f2]369call_t *ipc_wait_for_call(answerbox_t *box, uint32_t usec, int flags)
[6d9c49a]370{
371 call_t *request;
[5626277]372 ipl_t ipl;
[bd5a663]373 int rc;
[6d9c49a]374
[bd5a663]375restart:
[116d1ef4]376 rc = waitq_sleep_timeout(&box->wq, usec, flags);
[bd5a663]377 if (SYNCH_FAILED(rc))
378 return NULL;
[fbcfd458]379
[2ba7810]380 spinlock_lock(&box->lock);
[5626277]381 if (!list_empty(&box->irq_notifs)) {
382 ipl = interrupts_disable();
383 spinlock_lock(&box->irq_lock);
384
[c4e4507]385 request = list_get_instance(box->irq_notifs.next, call_t, link);
386 list_remove(&request->link);
[5626277]387
388 spinlock_unlock(&box->irq_lock);
389 interrupts_restore(ipl);
390 } else if (!list_empty(&box->answers)) {
[fbcfd458]391 /* Handle asynchronous answers */
[c4e4507]392 request = list_get_instance(box->answers.next, call_t, link);
393 list_remove(&request->link);
[fbcfd458]394 atomic_dec(&request->data.phone->active_calls);
395 } else if (!list_empty(&box->calls)) {
396 /* Handle requests */
[c4e4507]397 request = list_get_instance(box->calls.next, call_t, link);
398 list_remove(&request->link);
[fbcfd458]399 /* Append request to dispatch queue */
[c4e4507]400 list_append(&request->link, &box->dispatched_calls);
[fbcfd458]401 } else {
[874621f]402 /* This can happen regularly after ipc_cleanup */
[fbcfd458]403 spinlock_unlock(&box->lock);
404 goto restart;
[6d9c49a]405 }
[2ba7810]406 spinlock_unlock(&box->lock);
[6d9c49a]407 return request;
408}
409
[8b243f2]410/** Answer all calls from list with EHANGUP answer.
411 *
412 * @param lst Head of the list to be cleaned up.
413 */
[ca687ad]414static void ipc_cleanup_call_list(link_t *lst)
415{
416 call_t *call;
417
418 while (!list_empty(lst)) {
[c4e4507]419 call = list_get_instance(lst->next, call_t, link);
[a55d5f9f]420 if (call->buffer)
421 free(call->buffer);
[c4e4507]422 list_remove(&call->link);
[ca687ad]423
424 IPC_SET_RETVAL(call->data, EHANGUP);
425 _ipc_answer_free_call(call);
426 }
427}
428
[8b243f2]429/** Cleans up all IPC communication of the current task.
[4e49572]430 *
[214c5a0]431 * Note: ipc_hangup sets returning answerbox to TASK->answerbox, you
[8b243f2]432 * have to change it as well if you want to cleanup other tasks than TASK.
[4e49572]433 */
[214c5a0]434void ipc_cleanup(void)
[4e49572]435{
[9f22213]436 int i;
[ca687ad]437 call_t *call;
438 phone_t *phone;
[31d8e10]439 DEADLOCK_PROBE_INIT(p_phonelck);
[214c5a0]440
[9f22213]441 /* Disconnect all our phones ('ipc_phone_hangup') */
[8b243f2]442 for (i = 0; i < IPC_MAX_PHONES; i++)
[d8f7362]443 ipc_phone_hangup(&TASK->phones[i]);
[9f22213]444
[5626277]445 /* Disconnect all connected irqs */
[214c5a0]446 ipc_irq_cleanup(&TASK->answerbox);
[5626277]447
[ca687ad]448 /* Disconnect all phones connected to our answerbox */
449restart_phones:
[214c5a0]450 spinlock_lock(&TASK->answerbox.lock);
451 while (!list_empty(&TASK->answerbox.connected_phones)) {
452 phone = list_get_instance(TASK->answerbox.connected_phones.next,
[31d8e10]453 phone_t, link);
[ff48a15]454 if (SYNCH_FAILED(mutex_trylock(&phone->lock))) {
[214c5a0]455 spinlock_unlock(&TASK->answerbox.lock);
[31d8e10]456 DEADLOCK_PROBE(p_phonelck, DEADLOCK_THRESHOLD);
[ca687ad]457 goto restart_phones;
458 }
459
460 /* Disconnect phone */
[eb3d379]461 ASSERT(phone->state == IPC_PHONE_CONNECTED);
462 phone->state = IPC_PHONE_SLAMMED;
[c4e4507]463 list_remove(&phone->link);
[ca687ad]464
[ff48a15]465 mutex_unlock(&phone->lock);
[ca687ad]466 }
[9f22213]467
468 /* Answer all messages in 'calls' and 'dispatched_calls' queues */
[214c5a0]469 ipc_cleanup_call_list(&TASK->answerbox.dispatched_calls);
470 ipc_cleanup_call_list(&TASK->answerbox.calls);
471 spinlock_unlock(&TASK->answerbox.lock);
[4e49572]472
[9f22213]473 /* Wait for all async answers to arrive */
[eb3d379]474 while (1) {
475 /* Go through all phones, until all are FREE... */
476 /* Locking not needed, no one else should modify
477 * it, when we are in cleanup */
[8b243f2]478 for (i = 0; i < IPC_MAX_PHONES; i++) {
479 if (TASK->phones[i].state == IPC_PHONE_HUNGUP &&
[214c5a0]480 atomic_get(&TASK->phones[i].active_calls) == 0)
481 TASK->phones[i].state = IPC_PHONE_FREE;
482
[d8f7362]483 /* Just for sure, we might have had some
484 * IPC_PHONE_CONNECTING phones */
[214c5a0]485 if (TASK->phones[i].state == IPC_PHONE_CONNECTED)
[d8f7362]486 ipc_phone_hangup(&TASK->phones[i]);
487 /* If the hangup succeeded, it has sent a HANGUP
488 * message, the IPC is now in HUNGUP state, we
489 * wait for the reply to come */
[214c5a0]490
491 if (TASK->phones[i].state != IPC_PHONE_FREE)
[eb3d379]492 break;
493 }
494 /* Voila, got into cleanup */
495 if (i == IPC_MAX_PHONES)
496 break;
497
[8b243f2]498 call = ipc_wait_for_call(&TASK->answerbox, SYNCH_NO_TIMEOUT,
499 SYNCH_FLAGS_NONE);
500 ASSERT((call->flags & IPC_CALL_ANSWERED) ||
501 (call->flags & IPC_CALL_NOTIF));
502 ASSERT(!(call->flags & IPC_CALL_STATIC_ALLOC));
[ca687ad]503
[214c5a0]504 atomic_dec(&TASK->active_calls);
[ca687ad]505 ipc_call_free(call);
506 }
[4e49572]507}
[5626277]508
509
[2b017ba]510/** Initilize IPC subsystem */
[5626277]511void ipc_init(void)
512{
[8b243f2]513 ipc_call_slab = slab_cache_create("ipc_call", sizeof(call_t), 0, NULL,
514 NULL, 0);
[5626277]515}
516
[c4e4507]517
[8b243f2]518/** List answerbox contents.
519 *
520 * @param taskid Task ID.
521 */
[c4e4507]522void ipc_print_task(task_id_t taskid)
523{
524 task_t *task;
525 int i;
526 call_t *call;
527 link_t *tmp;
528
529 spinlock_lock(&tasks_lock);
530 task = task_find_by_id(taskid);
531 if (task)
532 spinlock_lock(&task->lock);
533 spinlock_unlock(&tasks_lock);
534 if (!task)
535 return;
536
537 /* Print opened phones & details */
538 printf("PHONE:\n");
[8b243f2]539 for (i = 0; i < IPC_MAX_PHONES; i++) {
[ff48a15]540 if (SYNCH_FAILED(mutex_trylock(&task->phones[i].lock))) {
541 printf("%d: mutex busy\n", i);
542 continue;
543 }
[c4e4507]544 if (task->phones[i].state != IPC_PHONE_FREE) {
[8b243f2]545 printf("%d: ", i);
[c4e4507]546 switch (task->phones[i].state) {
547 case IPC_PHONE_CONNECTING:
548 printf("connecting ");
549 break;
550 case IPC_PHONE_CONNECTED:
[fbf7b4c]551 printf("connected to: %p ",
[c4e4507]552 task->phones[i].callee);
553 break;
554 case IPC_PHONE_SLAMMED:
[fbf7b4c]555 printf("slammed by: %p ",
[c4e4507]556 task->phones[i].callee);
557 break;
558 case IPC_PHONE_HUNGUP:
[fbf7b4c]559 printf("hung up - was: %p ",
[c4e4507]560 task->phones[i].callee);
561 break;
562 default:
563 break;
564 }
[bd72c3e9]565 printf("active: %d\n",
566 atomic_get(&task->phones[i].active_calls));
[c4e4507]567 }
[ff48a15]568 mutex_unlock(&task->phones[i].lock);
[c4e4507]569 }
570
571
572 /* Print answerbox - calls */
573 spinlock_lock(&task->answerbox.lock);
574 printf("ABOX - CALLS:\n");
[bd72c3e9]575 for (tmp = task->answerbox.calls.next; tmp != &task->answerbox.calls;
576 tmp = tmp->next) {
[c4e4507]577 call = list_get_instance(tmp, call_t, link);
[bd72c3e9]578 printf("Callid: %p Srctask:%llu M:%d A1:%d A2:%d A3:%d "
[38c706cc]579 "A4:%d A5:%d Flags:%x\n", call, call->sender->taskid,
[bd72c3e9]580 IPC_GET_METHOD(call->data), IPC_GET_ARG1(call->data),
581 IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data),
[38c706cc]582 IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data),
[bd72c3e9]583 call->flags);
[c4e4507]584 }
585 /* Print answerbox - calls */
586 printf("ABOX - DISPATCHED CALLS:\n");
[ff48a15]587 for (tmp = task->answerbox.dispatched_calls.next;
[c4e4507]588 tmp != &task->answerbox.dispatched_calls;
589 tmp = tmp->next) {
590 call = list_get_instance(tmp, call_t, link);
[bd72c3e9]591 printf("Callid: %p Srctask:%llu M:%d A1:%d A2:%d A3:%d "
[38c706cc]592 "A4:%d A5:%d Flags:%x\n", call, call->sender->taskid,
[bd72c3e9]593 IPC_GET_METHOD(call->data), IPC_GET_ARG1(call->data),
594 IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data),
[38c706cc]595 IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data),
[bd72c3e9]596 call->flags);
[c4e4507]597 }
598 /* Print answerbox - calls */
599 printf("ABOX - ANSWERS:\n");
[bd72c3e9]600 for (tmp = task->answerbox.answers.next; tmp != &task->answerbox.answers;
601 tmp = tmp->next) {
[c4e4507]602 call = list_get_instance(tmp, call_t, link);
[38c706cc]603 printf("Callid:%p M:%d A1:%d A2:%d A3:%d A4:%d A5:%d Flags:%x\n",
604 call, IPC_GET_METHOD(call->data), IPC_GET_ARG1(call->data),
[bd72c3e9]605 IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data),
[38c706cc]606 IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data),
[bd72c3e9]607 call->flags);
[c4e4507]608 }
609
610 spinlock_unlock(&task->answerbox.lock);
611 spinlock_unlock(&task->lock);
612}
[b45c443]613
[cc73a8a1]614/** @}
[b45c443]615 */
Note: See TracBrowser for help on using the repository browser.