Rev 3438 | Rev 3445 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3438 | Rev 3441 | ||
---|---|---|---|
Line 37... | Line 37... | ||
37 | #include <synch/mutex.h> |
37 | #include <synch/mutex.h> |
38 | #include <ipc/ipc.h> |
38 | #include <ipc/ipc.h> |
39 | #include <ipc/ipcrsc.h> |
39 | #include <ipc/ipcrsc.h> |
40 | #include <arch.h> |
40 | #include <arch.h> |
41 | #include <errno.h> |
41 | #include <errno.h> |
42 | #include <print.h> |
42 | #include <debug.h> |
43 | #include <udebug/udebug_ipc.h> |
43 | #include <udebug/udebug_ipc.h> |
44 | #include <ipc/ipc_kbox.h> |
44 | #include <ipc/ipc_kbox.h> |
45 | 45 | ||
46 | void ipc_kbox_cleanup(void) |
46 | void ipc_kbox_cleanup(void) |
47 | { |
47 | { |
Line 63... | Line 63... | ||
63 | * wake up and terminate. |
63 | * wake up and terminate. |
64 | */ |
64 | */ |
65 | ipc_answerbox_slam_phones(&TASK->kernel_box, have_kb_thread); |
65 | ipc_answerbox_slam_phones(&TASK->kernel_box, have_kb_thread); |
66 | 66 | ||
67 | if (have_kb_thread) { |
67 | if (have_kb_thread) { |
68 | printf("join kb_thread..\n"); |
68 | LOG("join kb_thread..\n"); |
69 | thread_join(TASK->kb_thread); |
69 | thread_join(TASK->kb_thread); |
70 | thread_detach(TASK->kb_thread); |
70 | thread_detach(TASK->kb_thread); |
71 | printf("join done\n"); |
71 | LOG("join done\n"); |
72 | TASK->kb_thread = NULL; |
72 | TASK->kb_thread = NULL; |
73 | } |
73 | } |
74 | 74 | ||
75 | /* Answer all messages in 'calls' and 'dispatched_calls' queues */ |
75 | /* Answer all messages in 'calls' and 'dispatched_calls' queues */ |
76 | spinlock_lock(&TASK->kernel_box.lock); |
76 | spinlock_lock(&TASK->kernel_box.lock); |
Line 86... | Line 86... | ||
86 | int method; |
86 | int method; |
87 | bool done; |
87 | bool done; |
88 | ipl_t ipl; |
88 | ipl_t ipl; |
89 | 89 | ||
90 | (void)arg; |
90 | (void)arg; |
91 | printf("kbox_thread_proc()\n"); |
91 | LOG("kbox_thread_proc()\n"); |
92 | done = false; |
92 | done = false; |
93 | 93 | ||
94 | while (!done) { |
94 | while (!done) { |
95 | //printf("kbox: wait for call\n"); |
- | |
96 | call = ipc_wait_for_call(&TASK->kernel_box, SYNCH_NO_TIMEOUT, |
95 | call = ipc_wait_for_call(&TASK->kernel_box, SYNCH_NO_TIMEOUT, |
97 | SYNCH_FLAGS_NONE); |
96 | SYNCH_FLAGS_NONE); |
98 | 97 | ||
99 | if (call != NULL) { |
98 | if (call != NULL) { |
100 | method = IPC_GET_METHOD(call->data); |
99 | method = IPC_GET_METHOD(call->data); |
Line 102... | Line 101... | ||
102 | if (method == IPC_M_DEBUG_ALL) { |
101 | if (method == IPC_M_DEBUG_ALL) { |
103 | udebug_call_receive(call); |
102 | udebug_call_receive(call); |
104 | } |
103 | } |
105 | 104 | ||
106 | if (method == IPC_M_PHONE_HUNGUP) { |
105 | if (method == IPC_M_PHONE_HUNGUP) { |
107 | printf("kbox: handle hangup message\n"); |
106 | LOG("kbox: handle hangup message\n"); |
108 | 107 | ||
109 | /* Was it our debugger, who hung up? */ |
108 | /* Was it our debugger, who hung up? */ |
110 | if (call->sender == TASK->udebug.debugger) { |
109 | if (call->sender == TASK->udebug.debugger) { |
111 | /* Terminate debugging session (if any) */ |
110 | /* Terminate debugging session (if any) */ |
112 | printf("kbox: terminate debug session\n"); |
111 | LOG("kbox: terminate debug session\n"); |
113 | ipl = interrupts_disable(); |
112 | ipl = interrupts_disable(); |
114 | spinlock_lock(&TASK->lock); |
113 | spinlock_lock(&TASK->lock); |
115 | udebug_task_cleanup(TASK); |
114 | udebug_task_cleanup(TASK); |
116 | spinlock_unlock(&TASK->lock); |
115 | spinlock_unlock(&TASK->lock); |
117 | interrupts_restore(ipl); |
116 | interrupts_restore(ipl); |
118 | } else { |
117 | } else { |
119 | printf("kbox: was not debugger\n"); |
118 | LOG("kbox: was not debugger\n"); |
120 | } |
119 | } |
121 | 120 | ||
122 | printf("kbox: continue with hangup message\n"); |
121 | LOG("kbox: continue with hangup message\n"); |
123 | IPC_SET_RETVAL(call->data, 0); |
122 | IPC_SET_RETVAL(call->data, 0); |
124 | ipc_answer(&TASK->kernel_box, call); |
123 | ipc_answer(&TASK->kernel_box, call); |
125 | 124 | ||
126 | ipl = interrupts_disable(); |
125 | ipl = interrupts_disable(); |
127 | spinlock_lock(&TASK->lock); |
126 | spinlock_lock(&TASK->lock); |
128 | spinlock_lock(&TASK->answerbox.lock); |
127 | spinlock_lock(&TASK->answerbox.lock); |
129 | if (list_empty(&TASK->answerbox.connected_phones)) { |
128 | if (list_empty(&TASK->answerbox.connected_phones)) { |
130 | /* Last phone has been disconnected */ |
129 | /* Last phone has been disconnected */ |
131 | TASK->kb_thread = NULL; |
130 | TASK->kb_thread = NULL; |
132 | done = true; |
131 | done = true; |
133 | printf("phone list is empty\n"); |
132 | LOG("phone list is empty\n"); |
134 | } |
133 | } |
135 | spinlock_unlock(&TASK->answerbox.lock); |
134 | spinlock_unlock(&TASK->answerbox.lock); |
136 | spinlock_unlock(&TASK->lock); |
135 | spinlock_unlock(&TASK->lock); |
137 | interrupts_restore(ipl); |
136 | interrupts_restore(ipl); |
138 | } |
137 | } |
139 | } |
138 | } |
140 | } |
139 | } |
141 | 140 | ||
142 | printf("kbox: finished\n"); |
141 | LOG("kbox: finished\n"); |
143 | } |
142 | } |
144 | 143 | ||
145 | 144 | ||
146 | /** |
145 | /** |
147 | * Connect phone to a task kernel-box specified by id. |
146 | * Connect phone to a task kernel-box specified by id. |