Rev 2836 | Rev 2839 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2836 | Rev 2837 | ||
---|---|---|---|
Line 612... | Line 612... | ||
612 | 612 | ||
613 | static void kbox_thread_proc(void *arg) |
613 | static void kbox_thread_proc(void *arg) |
614 | { |
614 | { |
615 | call_t *call; |
615 | call_t *call; |
616 | int method; |
616 | int method; |
- | 617 | bool done; |
|
- | 618 | ipl_t ipl; |
|
617 | 619 | ||
618 | (void)arg; |
620 | (void)arg; |
619 | klog_printf("kbox_thread_proc()"); |
621 | klog_printf("kbox_thread_proc()"); |
- | 622 | done = false; |
|
- | 623 | ||
620 | while (1) { |
624 | while (!done) { |
621 | klog_printf("kbox: wait for call"); |
625 | klog_printf("kbox: wait for call"); |
622 | call = ipc_wait_for_call(&TASK->kernel_box, SYNCH_NO_TIMEOUT, |
626 | call = ipc_wait_for_call(&TASK->kernel_box, SYNCH_NO_TIMEOUT, |
623 | SYNCH_FLAGS_NONE); |
627 | SYNCH_FLAGS_NONE); |
- | 628 | ||
624 | if (call != NULL) { |
629 | if (call != NULL) { |
625 | method = IPC_GET_METHOD(call->data); |
630 | method = IPC_GET_METHOD(call->data); |
626 | 631 | ||
627 | if (method == IPC_M_DEBUG_ALL) { |
632 | if (method == IPC_M_DEBUG_ALL) { |
628 | udebug_call_receive(call); |
633 | udebug_call_receive(call); |
629 | } |
634 | } |
- | 635 | ||
- | 636 | if (method == IPC_M_PHONE_HUNGUP) { |
|
- | 637 | klog_printf("kbox: handle hangup message\n"); |
|
- | 638 | IPC_SET_RETVAL(call->data, 0); |
|
- | 639 | ipc_answer(&TASK->kernel_box, call); |
|
- | 640 | ||
- | 641 | ipl = interrupts_disable(); |
|
- | 642 | spinlock_lock(&TASK->lock); |
|
- | 643 | spinlock_lock(&TASK->answerbox.lock); |
|
- | 644 | if (list_empty(&TASK->answerbox.connected_phones)) { |
|
- | 645 | /* Last phone has been disconnected */ |
|
- | 646 | TASK->kb_thread = NULL; |
|
- | 647 | done = true; |
|
- | 648 | printf("phone list is empty\n"); |
|
- | 649 | } |
|
- | 650 | spinlock_unlock(&TASK->answerbox.lock); |
|
- | 651 | spinlock_unlock(&TASK->lock); |
|
- | 652 | interrupts_restore(ipl); |
|
- | 653 | } |
|
630 | } |
654 | } |
631 | } |
655 | } |
- | 656 | ||
- | 657 | klog_printf("kbox: finished"); |
|
632 | } |
658 | } |
633 | 659 | ||
634 | /** |
660 | /** |
635 | * Connect phone to a task kernel-box specified by id. |
661 | * Connect phone to a task kernel-box specified by id. |
636 | * |
662 | * |
Line 663... | Line 689... | ||
663 | ta->kb_thread = thread_create(kbox_thread_proc, |
689 | ta->kb_thread = thread_create(kbox_thread_proc, |
664 | NULL, ta, 0, "kbox", false); |
690 | NULL, ta, 0, "kbox", false); |
665 | if (!ta->kb_thread) |
691 | if (!ta->kb_thread) |
666 | return ENOMEM; |
692 | return ENOMEM; |
667 | 693 | ||
- | 694 | thread_detach(ta->kb_thread); |
|
668 | thread_ready(ta->kb_thread); |
695 | thread_ready(ta->kb_thread); |
669 | } |
696 | } |
670 | 697 | ||
671 | return newphid; |
698 | return newphid; |
672 | } |
699 | } |