Rev 2310 | Rev 2472 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2310 | Rev 2471 | ||
---|---|---|---|
Line 32... | Line 32... | ||
32 | /** @file |
32 | /** @file |
33 | */ |
33 | */ |
34 | 34 | ||
35 | /* Lock ordering |
35 | /* Lock ordering |
36 | * |
36 | * |
37 | * First the answerbox, then the phone |
37 | * First the answerbox, then the phone. |
38 | */ |
38 | */ |
39 | 39 | ||
40 | #include <synch/spinlock.h> |
40 | #include <synch/spinlock.h> |
41 | #include <synch/waitq.h> |
41 | #include <synch/waitq.h> |
42 | #include <synch/synch.h> |
42 | #include <synch/synch.h> |
Line 51... | Line 51... | ||
51 | #include <print.h> |
51 | #include <print.h> |
52 | #include <proc/thread.h> |
52 | #include <proc/thread.h> |
53 | #include <arch/interrupt.h> |
53 | #include <arch/interrupt.h> |
54 | #include <ipc/irq.h> |
54 | #include <ipc/irq.h> |
55 | 55 | ||
56 | /* Open channel that is assigned automatically to new tasks */ |
56 | /** Open channel that is assigned automatically to new tasks */ |
57 | answerbox_t *ipc_phone_0 = NULL; |
57 | answerbox_t *ipc_phone_0 = NULL; |
58 | 58 | ||
59 | static slab_cache_t *ipc_call_slab; |
59 | static slab_cache_t *ipc_call_slab; |
60 | 60 | ||
61 | /* Initialize new call */ |
61 | /** Initialize a call structure. |
- | 62 | * |
|
- | 63 | * @param call Call structure to be initialized. |
|
- | 64 | */ |
|
62 | static void _ipc_call_init(call_t *call) |
65 | static void _ipc_call_init(call_t *call) |
63 | { |
66 | { |
64 | memsetb((uintptr_t)call, sizeof(*call), 0); |
67 | memsetb((uintptr_t) call, sizeof(*call), 0); |
65 | call->callerbox = &TASK->answerbox; |
68 | call->callerbox = &TASK->answerbox; |
66 | call->sender = TASK; |
69 | call->sender = TASK; |
67 | } |
70 | } |
68 | 71 | ||
69 | /** Allocate & initialize call structure |
72 | /** Allocate and initialize a call structure. |
70 | * |
73 | * |
71 | * The call is initialized, so that the reply will be directed |
74 | * The call is initialized, so that the reply will be directed to |
72 | * to TASK->answerbox |
75 | * TASK->answerbox. |
- | 76 | * |
|
- | 77 | * @param flags Parameters for slab_alloc (e.g FRAME_ATOMIC). |
|
73 | * |
78 | * |
74 | * @param flags Parameters for slab_alloc (ATOMIC, etc.) |
79 | * @return If flags permit it, return NULL, or initialized kernel |
- | 80 | * call structure. |
|
75 | */ |
81 | */ |
76 | call_t * ipc_call_alloc(int flags) |
82 | call_t *ipc_call_alloc(int flags) |
77 | { |
83 | { |
78 | call_t *call; |
84 | call_t *call; |
79 | 85 | ||
80 | call = slab_alloc(ipc_call_slab, flags); |
86 | call = slab_alloc(ipc_call_slab, flags); |
81 | _ipc_call_init(call); |
87 | _ipc_call_init(call); |
82 | 88 | ||
83 | return call; |
89 | return call; |
84 | } |
90 | } |
85 | 91 | ||
86 | /** Initialize allocated call */ |
92 | /** Initialize a statically allocated call structure. |
- | 93 | * |
|
- | 94 | * @param call Statically allocated kernel call structure to be |
|
- | 95 | * initialized. |
|
- | 96 | */ |
|
87 | void ipc_call_static_init(call_t *call) |
97 | void ipc_call_static_init(call_t *call) |
88 | { |
98 | { |
89 | _ipc_call_init(call); |
99 | _ipc_call_init(call); |
90 | call->flags |= IPC_CALL_STATIC_ALLOC; |
100 | call->flags |= IPC_CALL_STATIC_ALLOC; |
91 | } |
101 | } |
92 | 102 | ||
93 | /** Deallocate call stracuture */ |
103 | /** Deallocate a call stracuture. |
- | 104 | * |
|
- | 105 | * @param call Call structure to be freed. |
|
- | 106 | */ |
|
94 | void ipc_call_free(call_t *call) |
107 | void ipc_call_free(call_t *call) |
95 | { |
108 | { |
- | 109 | ASSERT(!(call->flags & IPC_CALL_STATIC_ALLOC)); |
|
96 | slab_free(ipc_call_slab, call); |
110 | slab_free(ipc_call_slab, call); |
97 | } |
111 | } |
98 | 112 | ||
99 | /** Initialize answerbox structure |
113 | /** Initialize an answerbox structure. |
- | 114 | * |
|
- | 115 | * @param box Answerbox structure to be initialized. |
|
100 | */ |
116 | */ |
101 | void ipc_answerbox_init(answerbox_t *box) |
117 | void ipc_answerbox_init(answerbox_t *box) |
102 | { |
118 | { |
103 | spinlock_initialize(&box->lock, "ipc_box_lock"); |
119 | spinlock_initialize(&box->lock, "ipc_box_lock"); |
104 | spinlock_initialize(&box->irq_lock, "ipc_box_irqlock"); |
120 | spinlock_initialize(&box->irq_lock, "ipc_box_irqlock"); |
Line 110... | Line 126... | ||
110 | list_initialize(&box->irq_notifs); |
126 | list_initialize(&box->irq_notifs); |
111 | list_initialize(&box->irq_head); |
127 | list_initialize(&box->irq_head); |
112 | box->task = TASK; |
128 | box->task = TASK; |
113 | } |
129 | } |
114 | 130 | ||
115 | /** Connect phone to answerbox */ |
131 | /** Connect a phone to an answerbox. |
- | 132 | * |
|
- | 133 | * @param phone Initialized phone structure. |
|
- | 134 | * @param box Initialized answerbox structure. |
|
- | 135 | */ |
|
116 | void ipc_phone_connect(phone_t *phone, answerbox_t *box) |
136 | void ipc_phone_connect(phone_t *phone, answerbox_t *box) |
117 | { |
137 | { |
118 | spinlock_lock(&phone->lock); |
138 | spinlock_lock(&phone->lock); |
119 | 139 | ||
120 | phone->state = IPC_PHONE_CONNECTED; |
140 | phone->state = IPC_PHONE_CONNECTED; |
Line 125... | Line 145... | ||
125 | spinlock_unlock(&box->lock); |
145 | spinlock_unlock(&box->lock); |
126 | 146 | ||
127 | spinlock_unlock(&phone->lock); |
147 | spinlock_unlock(&phone->lock); |
128 | } |
148 | } |
129 | 149 | ||
- | 150 | /** Initialize a phone structure. |
|
- | 151 | * |
|
130 | /** Initialize phone structure and connect phone to answerbox |
152 | * @param phone Phone structure to be initialized. |
131 | */ |
153 | */ |
132 | void ipc_phone_init(phone_t *phone) |
154 | void ipc_phone_init(phone_t *phone) |
133 | { |
155 | { |
134 | spinlock_initialize(&phone->lock, "phone_lock"); |
156 | spinlock_initialize(&phone->lock, "phone_lock"); |
135 | phone->callee = NULL; |
157 | phone->callee = NULL; |
136 | phone->state = IPC_PHONE_FREE; |
158 | phone->state = IPC_PHONE_FREE; |
137 | atomic_set(&phone->active_calls, 0); |
159 | atomic_set(&phone->active_calls, 0); |
138 | } |
160 | } |
139 | 161 | ||
140 | /** Helper function to facilitate synchronous calls */ |
162 | /** Helper function to facilitate synchronous calls. |
- | 163 | * |
|
- | 164 | * @param phone Destination kernel phone structure. |
|
- | 165 | * @param request Call structure with request. |
|
- | 166 | */ |
|
141 | void ipc_call_sync(phone_t *phone, call_t *request) |
167 | void ipc_call_sync(phone_t *phone, call_t *request) |
142 | { |
168 | { |
143 | answerbox_t sync_box; |
169 | answerbox_t sync_box; |
144 | 170 | ||
145 | ipc_answerbox_init(&sync_box); |
171 | ipc_answerbox_init(&sync_box); |
146 | 172 | ||
147 | /* We will receive data on special box */ |
173 | /* We will receive data in a special box. */ |
148 | request->callerbox = &sync_box; |
174 | request->callerbox = &sync_box; |
149 | 175 | ||
150 | ipc_call(phone, request); |
176 | ipc_call(phone, request); |
151 | ipc_wait_for_call(&sync_box, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE); |
177 | ipc_wait_for_call(&sync_box, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE); |
152 | } |
178 | } |
153 | 179 | ||
154 | /** Answer message that was not dispatched and is not entered in |
180 | /** Answer a message which was not dispatched and is not listed in any queue. |
155 | * any queue |
181 | * |
- | 182 | * @param call Call structure to be answered. |
|
156 | */ |
183 | */ |
157 | static void _ipc_answer_free_call(call_t *call) |
184 | static void _ipc_answer_free_call(call_t *call) |
158 | { |
185 | { |
159 | answerbox_t *callerbox = call->callerbox; |
186 | answerbox_t *callerbox = call->callerbox; |
160 | 187 | ||
Line 164... | Line 191... | ||
164 | list_append(&call->link, &callerbox->answers); |
191 | list_append(&call->link, &callerbox->answers); |
165 | spinlock_unlock(&callerbox->lock); |
192 | spinlock_unlock(&callerbox->lock); |
166 | waitq_wakeup(&callerbox->wq, WAKEUP_FIRST); |
193 | waitq_wakeup(&callerbox->wq, WAKEUP_FIRST); |
167 | } |
194 | } |
168 | 195 | ||
169 | /** Answer message, that is in callee queue |
196 | /** Answer a message which is in a callee queue. |
170 | * |
197 | * |
171 | * @param box Answerbox that is answering the message |
198 | * @param box Answerbox that is answering the message. |
172 | * @param call Modified request that is being sent back |
199 | * @param call Modified request that is being sent back. |
173 | */ |
200 | */ |
174 | void ipc_answer(answerbox_t *box, call_t *call) |
201 | void ipc_answer(answerbox_t *box, call_t *call) |
175 | { |
202 | { |
176 | /* Remove from active box */ |
203 | /* Remove from active box */ |
177 | spinlock_lock(&box->lock); |
204 | spinlock_lock(&box->lock); |
Line 179... | Line 206... | ||
179 | spinlock_unlock(&box->lock); |
206 | spinlock_unlock(&box->lock); |
180 | /* Send back answer */ |
207 | /* Send back answer */ |
181 | _ipc_answer_free_call(call); |
208 | _ipc_answer_free_call(call); |
182 | } |
209 | } |
183 | 210 | ||
184 | /** Simulate sending back a message |
211 | /** Simulate sending back a message. |
185 | * |
212 | * |
186 | * Most errors are better handled by forming a normal backward |
213 | * Most errors are better handled by forming a normal backward |
187 | * message and sending it as a normal answer. |
214 | * message and sending it as a normal answer. |
- | 215 | * |
|
- | 216 | * @param phone Phone structure the call should appear to come from. |
|
- | 217 | * @param call Call structure to be answered. |
|
- | 218 | * @param err Return value to be used for the answer. |
|
188 | */ |
219 | */ |
189 | void ipc_backsend_err(phone_t *phone, call_t *call, unative_t err) |
220 | void ipc_backsend_err(phone_t *phone, call_t *call, unative_t err) |
190 | { |
221 | { |
191 | call->data.phone = phone; |
222 | call->data.phone = phone; |
192 | atomic_inc(&phone->active_calls); |
223 | atomic_inc(&phone->active_calls); |
193 | IPC_SET_RETVAL(call->data, err); |
224 | IPC_SET_RETVAL(call->data, err); |
194 | _ipc_answer_free_call(call); |
225 | _ipc_answer_free_call(call); |
195 | } |
226 | } |
196 | 227 | ||
197 | /* Unsafe unchecking ipc_call */ |
228 | /** Unsafe unchecking version of ipc_call. |
- | 229 | * |
|
- | 230 | * @param phone Phone structure the call comes from. |
|
- | 231 | * @param box Destination answerbox structure. |
|
- | 232 | */ |
|
198 | static void _ipc_call(phone_t *phone, answerbox_t *box, call_t *call) |
233 | static void _ipc_call(phone_t *phone, answerbox_t *box, call_t *call) |
199 | { |
234 | { |
200 | if (! (call->flags & IPC_CALL_FORWARDED)) { |
235 | if (!(call->flags & IPC_CALL_FORWARDED)) { |
201 | atomic_inc(&phone->active_calls); |
236 | atomic_inc(&phone->active_calls); |
202 | call->data.phone = phone; |
237 | call->data.phone = phone; |
203 | } |
238 | } |
204 | 239 | ||
205 | spinlock_lock(&box->lock); |
240 | spinlock_lock(&box->lock); |
206 | list_append(&call->link, &box->calls); |
241 | list_append(&call->link, &box->calls); |
207 | spinlock_unlock(&box->lock); |
242 | spinlock_unlock(&box->lock); |
208 | waitq_wakeup(&box->wq, WAKEUP_FIRST); |
243 | waitq_wakeup(&box->wq, WAKEUP_FIRST); |
209 | } |
244 | } |
210 | 245 | ||
211 | /** Send a asynchronous request using phone to answerbox |
246 | /** Send an asynchronous request using a phone to an answerbox. |
- | 247 | * |
|
- | 248 | * @param phone Phone structure the call comes from and which is |
|
- | 249 | * connected to the destination answerbox. |
|
- | 250 | * @param call Call structure with request. |
|
212 | * |
251 | * |
213 | * @param phone Phone connected to answerbox. |
252 | * @return Return 0 on success, ENOENT on error. |
214 | * @param call Structure representing the call. |
- | |
215 | */ |
253 | */ |
216 | int ipc_call(phone_t *phone, call_t *call) |
254 | int ipc_call(phone_t *phone, call_t *call) |
217 | { |
255 | { |
218 | answerbox_t *box; |
256 | answerbox_t *box; |
219 | 257 | ||
Line 236... | Line 274... | ||
236 | 274 | ||
237 | spinlock_unlock(&phone->lock); |
275 | spinlock_unlock(&phone->lock); |
238 | return 0; |
276 | return 0; |
239 | } |
277 | } |
240 | 278 | ||
241 | /** Disconnect phone from answerbox |
279 | /** Disconnect phone from answerbox. |
242 | * |
280 | * |
243 | * This call leaves the phone in HUNGUP state. The change to 'free' is done |
281 | * This call leaves the phone in the HUNGUP state. The change to 'free' is done |
244 | * lazily later. |
282 | * lazily later. |
245 | * |
283 | * |
246 | * @param phone Phone to be hung up |
284 | * @param phone Phone structure to be hung up. |
247 | * |
285 | * |
- | 286 | * @return Return 0 if the phone is disconnected. |
|
248 | * @return 0 - phone disconnected, -1 - the phone was already disconnected |
287 | * Return -1 if the phone was already disconnected. |
249 | */ |
288 | */ |
250 | int ipc_phone_hangup(phone_t *phone) |
289 | int ipc_phone_hangup(phone_t *phone) |
251 | { |
290 | { |
252 | answerbox_t *box; |
291 | answerbox_t *box; |
253 | call_t *call; |
292 | call_t *call; |
254 | 293 | ||
255 | spinlock_lock(&phone->lock); |
294 | spinlock_lock(&phone->lock); |
256 | if (phone->state == IPC_PHONE_FREE || phone->state ==IPC_PHONE_HUNGUP \ |
295 | if (phone->state == IPC_PHONE_FREE || phone->state == IPC_PHONE_HUNGUP || |
257 | || phone->state == IPC_PHONE_CONNECTING) { |
296 | phone->state == IPC_PHONE_CONNECTING) { |
258 | spinlock_unlock(&phone->lock); |
297 | spinlock_unlock(&phone->lock); |
259 | return -1; |
298 | return -1; |
260 | } |
299 | } |
261 | box = phone->callee; |
300 | box = phone->callee; |
262 | if (phone->state != IPC_PHONE_SLAMMED) { |
301 | if (phone->state != IPC_PHONE_SLAMMED) { |
Line 277... | Line 316... | ||
277 | spinlock_unlock(&phone->lock); |
316 | spinlock_unlock(&phone->lock); |
278 | 317 | ||
279 | return 0; |
318 | return 0; |
280 | } |
319 | } |
281 | 320 | ||
282 | /** Forwards call from one answerbox to a new one |
321 | /** Forwards call from one answerbox to another one. |
283 | * |
322 | * |
284 | * @param call Call to be redirected. |
323 | * @param call Call structure to be redirected. |
285 | * @param newphone Phone to target answerbox. |
324 | * @param newphone Phone structure to target answerbox. |
286 | * @param oldbox Old answerbox |
325 | * @param oldbox Old answerbox structure. |
- | 326 | * |
|
287 | * @return 0 on forward ok, error code, if there was error |
327 | * @return Return 0 if forwarding succeeded or an error code if |
- | 328 | * there was error. |
|
288 | * |
329 | * |
289 | * - the return value serves only as an information for the forwarder, |
330 | * The return value serves only as an information for the forwarder, |
290 | * the original caller is notified automatically with EFORWARD |
331 | * the original caller is notified automatically with EFORWARD. |
291 | */ |
332 | */ |
292 | int ipc_forward(call_t *call, phone_t *newphone, answerbox_t *oldbox) |
333 | int ipc_forward(call_t *call, phone_t *newphone, answerbox_t *oldbox) |
293 | { |
334 | { |
294 | spinlock_lock(&oldbox->lock); |
335 | spinlock_lock(&oldbox->lock); |
295 | list_remove(&call->link); |
336 | list_remove(&call->link); |
Line 297... | Line 338... | ||
297 | 338 | ||
298 | return ipc_call(newphone, call); |
339 | return ipc_call(newphone, call); |
299 | } |
340 | } |
300 | 341 | ||
301 | 342 | ||
302 | /** Wait for phone call |
343 | /** Wait for a phone call. |
303 | * |
344 | * |
304 | * @param box Answerbox expecting the call. |
345 | * @param box Answerbox expecting the call. |
305 | * @param usec Timeout in microseconds. See documentation for waitq_sleep_timeout() for |
346 | * @param usec Timeout in microseconds. See documentation for |
306 | * decription of its special meaning. |
347 | * waitq_sleep_timeout() for decription of its special |
- | 348 | * meaning. |
|
307 | * @param flags Select mode of sleep operation. See documentation for waitq_sleep_timeout()i |
349 | * @param flags Select mode of sleep operation. See documentation for |
308 | * for description of its special meaning. |
350 | * waitq_sleep_timeout() for description of its special |
- | 351 | * meaning. |
|
309 | * @return Recived message address |
352 | * @return Recived call structure or NULL. |
- | 353 | * |
|
310 | * - to distinguish between call and answer, look at call->flags |
354 | * To distinguish between a call and an answer, have a look at call->flags. |
311 | */ |
355 | */ |
312 | call_t * ipc_wait_for_call(answerbox_t *box, uint32_t usec, int flags) |
356 | call_t *ipc_wait_for_call(answerbox_t *box, uint32_t usec, int flags) |
313 | { |
357 | { |
314 | call_t *request; |
358 | call_t *request; |
315 | ipl_t ipl; |
359 | ipl_t ipl; |
316 | int rc; |
360 | int rc; |
317 | 361 | ||
Line 348... | Line 392... | ||
348 | } |
392 | } |
349 | spinlock_unlock(&box->lock); |
393 | spinlock_unlock(&box->lock); |
350 | return request; |
394 | return request; |
351 | } |
395 | } |
352 | 396 | ||
353 | /** Answer all calls from list with EHANGUP msg */ |
397 | /** Answer all calls from list with EHANGUP answer. |
- | 398 | * |
|
- | 399 | * @param lst Head of the list to be cleaned up. |
|
- | 400 | */ |
|
354 | static void ipc_cleanup_call_list(link_t *lst) |
401 | static void ipc_cleanup_call_list(link_t *lst) |
355 | { |
402 | { |
356 | call_t *call; |
403 | call_t *call; |
357 | 404 | ||
358 | while (!list_empty(lst)) { |
405 | while (!list_empty(lst)) { |
Line 362... | Line 409... | ||
362 | IPC_SET_RETVAL(call->data, EHANGUP); |
409 | IPC_SET_RETVAL(call->data, EHANGUP); |
363 | _ipc_answer_free_call(call); |
410 | _ipc_answer_free_call(call); |
364 | } |
411 | } |
365 | } |
412 | } |
366 | 413 | ||
367 | /** Cleans up all IPC communication of the current task |
414 | /** Cleans up all IPC communication of the current task. |
368 | * |
415 | * |
369 | * Note: ipc_hangup sets returning answerbox to TASK->answerbox, you |
416 | * Note: ipc_hangup sets returning answerbox to TASK->answerbox, you |
370 | * have to change it as well if you want to cleanup other current then current. |
417 | * have to change it as well if you want to cleanup other tasks than TASK. |
371 | */ |
418 | */ |
372 | void ipc_cleanup(void) |
419 | void ipc_cleanup(void) |
373 | { |
420 | { |
374 | int i; |
421 | int i; |
375 | call_t *call; |
422 | call_t *call; |
376 | phone_t *phone; |
423 | phone_t *phone; |
377 | DEADLOCK_PROBE_INIT(p_phonelck); |
424 | DEADLOCK_PROBE_INIT(p_phonelck); |
378 | 425 | ||
379 | /* Disconnect all our phones ('ipc_phone_hangup') */ |
426 | /* Disconnect all our phones ('ipc_phone_hangup') */ |
380 | for (i=0;i < IPC_MAX_PHONES; i++) |
427 | for (i = 0; i < IPC_MAX_PHONES; i++) |
381 | ipc_phone_hangup(&TASK->phones[i]); |
428 | ipc_phone_hangup(&TASK->phones[i]); |
382 | 429 | ||
383 | /* Disconnect all connected irqs */ |
430 | /* Disconnect all connected irqs */ |
384 | ipc_irq_cleanup(&TASK->answerbox); |
431 | ipc_irq_cleanup(&TASK->answerbox); |
385 | 432 | ||
Line 411... | Line 458... | ||
411 | /* Wait for all async answers to arrive */ |
458 | /* Wait for all async answers to arrive */ |
412 | while (1) { |
459 | while (1) { |
413 | /* Go through all phones, until all are FREE... */ |
460 | /* Go through all phones, until all are FREE... */ |
414 | /* Locking not needed, no one else should modify |
461 | /* Locking not needed, no one else should modify |
415 | * it, when we are in cleanup */ |
462 | * it, when we are in cleanup */ |
416 | for (i=0;i < IPC_MAX_PHONES; i++) { |
463 | for (i = 0; i < IPC_MAX_PHONES; i++) { |
417 | if (TASK->phones[i].state == IPC_PHONE_HUNGUP && \ |
464 | if (TASK->phones[i].state == IPC_PHONE_HUNGUP && |
418 | atomic_get(&TASK->phones[i].active_calls) == 0) |
465 | atomic_get(&TASK->phones[i].active_calls) == 0) |
419 | TASK->phones[i].state = IPC_PHONE_FREE; |
466 | TASK->phones[i].state = IPC_PHONE_FREE; |
420 | 467 | ||
421 | /* Just for sure, we might have had some |
468 | /* Just for sure, we might have had some |
422 | * IPC_PHONE_CONNECTING phones */ |
469 | * IPC_PHONE_CONNECTING phones */ |
Line 431... | Line 478... | ||
431 | } |
478 | } |
432 | /* Voila, got into cleanup */ |
479 | /* Voila, got into cleanup */ |
433 | if (i == IPC_MAX_PHONES) |
480 | if (i == IPC_MAX_PHONES) |
434 | break; |
481 | break; |
435 | 482 | ||
436 | call = ipc_wait_for_call(&TASK->answerbox, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE); |
483 | call = ipc_wait_for_call(&TASK->answerbox, SYNCH_NO_TIMEOUT, |
- | 484 | SYNCH_FLAGS_NONE); |
|
437 | ASSERT((call->flags & IPC_CALL_ANSWERED) || (call->flags & IPC_CALL_NOTIF)); |
485 | ASSERT((call->flags & IPC_CALL_ANSWERED) || |
- | 486 | (call->flags & IPC_CALL_NOTIF)); |
|
438 | ASSERT(! (call->flags & IPC_CALL_STATIC_ALLOC)); |
487 | ASSERT(!(call->flags & IPC_CALL_STATIC_ALLOC)); |
439 | 488 | ||
440 | atomic_dec(&TASK->active_calls); |
489 | atomic_dec(&TASK->active_calls); |
441 | ipc_call_free(call); |
490 | ipc_call_free(call); |
442 | } |
491 | } |
443 | } |
492 | } |
444 | 493 | ||
445 | 494 | ||
446 | /** Initilize IPC subsystem */ |
495 | /** Initilize IPC subsystem */ |
447 | void ipc_init(void) |
496 | void ipc_init(void) |
448 | { |
497 | { |
449 | ipc_call_slab = slab_cache_create("ipc_call", sizeof(call_t), 0, NULL, NULL, 0); |
498 | ipc_call_slab = slab_cache_create("ipc_call", sizeof(call_t), 0, NULL, |
- | 499 | NULL, 0); |
|
450 | } |
500 | } |
451 | 501 | ||
452 | 502 | ||
453 | /** Kconsole - list answerbox contents */ |
503 | /** List answerbox contents. |
- | 504 | * |
|
- | 505 | * @param taskid Task ID. |
|
- | 506 | */ |
|
454 | void ipc_print_task(task_id_t taskid) |
507 | void ipc_print_task(task_id_t taskid) |
455 | { |
508 | { |
456 | task_t *task; |
509 | task_t *task; |
457 | int i; |
510 | int i; |
458 | call_t *call; |
511 | call_t *call; |
Line 466... | Line 519... | ||
466 | if (!task) |
519 | if (!task) |
467 | return; |
520 | return; |
468 | 521 | ||
469 | /* Print opened phones & details */ |
522 | /* Print opened phones & details */ |
470 | printf("PHONE:\n"); |
523 | printf("PHONE:\n"); |
471 | for (i=0; i < IPC_MAX_PHONES;i++) { |
524 | for (i = 0; i < IPC_MAX_PHONES; i++) { |
472 | spinlock_lock(&task->phones[i].lock); |
525 | spinlock_lock(&task->phones[i].lock); |
473 | if (task->phones[i].state != IPC_PHONE_FREE) { |
526 | if (task->phones[i].state != IPC_PHONE_FREE) { |
474 | printf("%d: ",i); |
527 | printf("%d: ", i); |
475 | switch (task->phones[i].state) { |
528 | switch (task->phones[i].state) { |
476 | case IPC_PHONE_CONNECTING: |
529 | case IPC_PHONE_CONNECTING: |
477 | printf("connecting "); |
530 | printf("connecting "); |
478 | break; |
531 | break; |
479 | case IPC_PHONE_CONNECTED: |
532 | case IPC_PHONE_CONNECTED: |