Subversion Repositories HelenOS-historic

Rev

Rev 1088 | Rev 1141 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1088 Rev 1090
1
/*
1
/*
2
 * Copyright (C) 2006 Ondrej Palkovsky
2
 * Copyright (C) 2006 Ondrej Palkovsky
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
8
 *
8
 *
9
 * - Redistributions of source code must retain the above copyright
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
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
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.
15
 *   derived from this software without specific prior written permission.
16
 *
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
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
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
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
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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
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.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
/* Lock ordering
29
/* Lock ordering
30
 *
30
 *
31
 * First the answerbox, then the phone
31
 * First the answerbox, then the phone
32
 */
32
 */
33
 
33
 
34
#include <synch/spinlock.h>
34
#include <synch/spinlock.h>
35
#include <synch/waitq.h>
35
#include <synch/waitq.h>
36
#include <ipc/ipc.h>
36
#include <ipc/ipc.h>
37
#include <errno.h>
37
#include <errno.h>
38
#include <mm/slab.h>
38
#include <mm/slab.h>
39
#include <arch.h>
39
#include <arch.h>
40
#include <proc/task.h>
40
#include <proc/task.h>
41
#include <memstr.h>
41
#include <memstr.h>
42
#include <debug.h>
42
#include <debug.h>
43
 
43
 
44
#include <print.h>
44
#include <print.h>
45
#include <proc/thread.h>
45
#include <proc/thread.h>
46
 
46
 
47
/* Open channel that is assigned automatically to new tasks */
47
/* Open channel that is assigned automatically to new tasks */
48
answerbox_t *ipc_phone_0 = NULL;
48
answerbox_t *ipc_phone_0 = NULL;
49
 
49
 
50
static slab_cache_t *ipc_call_slab;
50
static slab_cache_t *ipc_call_slab;
51
 
51
 
52
/* Initialize new call */
52
/* Initialize new call */
53
static void _ipc_call_init(call_t *call)
53
static void _ipc_call_init(call_t *call)
54
{
54
{
55
    memsetb((__address)call, sizeof(*call), 0);
55
    memsetb((__address)call, sizeof(*call), 0);
56
    call->callerbox = &TASK->answerbox;
56
    call->callerbox = &TASK->answerbox;
57
    call->sender = TASK;
57
    call->sender = TASK;
58
}
58
}
59
 
59
 
60
/** Allocate & initialize call structure
60
/** Allocate & initialize call structure
61
 *
61
 *
62
 * The call is initialized, so that the reply will be directed
62
 * The call is initialized, so that the reply will be directed
63
 * to TASK->answerbox
63
 * to TASK->answerbox
64
 */
64
 */
65
call_t * ipc_call_alloc(void)
65
call_t * ipc_call_alloc(void)
66
{
66
{
67
    call_t *call;
67
    call_t *call;
68
 
68
 
69
    call = slab_alloc(ipc_call_slab, 0);
69
    call = slab_alloc(ipc_call_slab, 0);
70
    _ipc_call_init(call);
70
    _ipc_call_init(call);
71
 
71
 
72
    return call;
72
    return call;
73
}
73
}
74
 
74
 
75
/** Initialize allocated call */
75
/** Initialize allocated call */
76
void ipc_call_static_init(call_t *call)
76
void ipc_call_static_init(call_t *call)
77
{
77
{
78
    _ipc_call_init(call);
78
    _ipc_call_init(call);
79
    call->flags |= IPC_CALL_STATIC_ALLOC;
79
    call->flags |= IPC_CALL_STATIC_ALLOC;
80
}
80
}
81
 
81
 
82
/** Deallocate call stracuture */
82
/** Deallocate call stracuture */
83
void ipc_call_free(call_t *call)
83
void ipc_call_free(call_t *call)
84
{
84
{
85
    slab_free(ipc_call_slab, call);
85
    slab_free(ipc_call_slab, call);
86
}
86
}
87
 
87
 
88
/** Initialize answerbox structure
88
/** Initialize answerbox structure
89
 */
89
 */
90
void ipc_answerbox_init(answerbox_t *box)
90
void ipc_answerbox_init(answerbox_t *box)
91
{
91
{
92
    spinlock_initialize(&box->lock, "ipc_box_lock");
92
    spinlock_initialize(&box->lock, "ipc_box_lock");
93
    waitq_initialize(&box->wq);
93
    waitq_initialize(&box->wq);
94
    list_initialize(&box->connected_phones);
94
    list_initialize(&box->connected_phones);
95
    list_initialize(&box->calls);
95
    list_initialize(&box->calls);
96
    list_initialize(&box->dispatched_calls);
96
    list_initialize(&box->dispatched_calls);
97
    list_initialize(&box->answers);
97
    list_initialize(&box->answers);
98
    box->task = TASK;
98
    box->task = TASK;
99
}
99
}
100
 
100
 
101
/** Connect phone to answerbox */
101
/** Connect phone to answerbox */
102
void ipc_phone_connect(phone_t *phone, answerbox_t *box)
102
void ipc_phone_connect(phone_t *phone, answerbox_t *box)
103
{
103
{
104
    spinlock_lock(&phone->lock);
104
    spinlock_lock(&phone->lock);
105
 
105
 
106
    ASSERT(!phone->callee);
106
    ASSERT(!phone->callee);
107
    phone->busy = IPC_BUSY_CONNECTED;
107
    phone->busy = IPC_BUSY_CONNECTED;
108
    phone->callee = box;
108
    phone->callee = box;
109
 
109
 
110
    spinlock_lock(&box->lock);
110
    spinlock_lock(&box->lock);
111
    list_append(&phone->list, &box->connected_phones);
111
    list_append(&phone->list, &box->connected_phones);
112
    spinlock_unlock(&box->lock);
112
    spinlock_unlock(&box->lock);
113
 
113
 
114
    spinlock_unlock(&phone->lock);
114
    spinlock_unlock(&phone->lock);
115
}
115
}
116
 
116
 
117
/** Initialize phone structure and connect phone to naswerbox
117
/** Initialize phone structure and connect phone to naswerbox
118
 */
118
 */
119
void ipc_phone_init(phone_t *phone)
119
void ipc_phone_init(phone_t *phone)
120
{
120
{
121
    spinlock_initialize(&phone->lock, "phone_lock");
121
    spinlock_initialize(&phone->lock, "phone_lock");
122
    phone->callee = NULL;
122
    phone->callee = NULL;
123
    phone->busy = IPC_BUSY_FREE;
123
    phone->busy = IPC_BUSY_FREE;
124
    atomic_set(&phone->active_calls, 0);
124
    atomic_set(&phone->active_calls, 0);
125
}
125
}
126
 
126
 
127
/** Helper function to facilitate synchronous calls */
127
/** Helper function to facilitate synchronous calls */
128
void ipc_call_sync(phone_t *phone, call_t *request)
128
void ipc_call_sync(phone_t *phone, call_t *request)
129
{
129
{
130
    answerbox_t sync_box;
130
    answerbox_t sync_box;
131
 
131
 
132
    ipc_answerbox_init(&sync_box);
132
    ipc_answerbox_init(&sync_box);
133
 
133
 
134
    /* We will receive data on special box */
134
    /* We will receive data on special box */
135
    request->callerbox = &sync_box;
135
    request->callerbox = &sync_box;
136
 
136
 
137
    ipc_call(phone, request);
137
    ipc_call(phone, request);
138
    ipc_wait_for_call(&sync_box, 0);
138
    ipc_wait_for_call(&sync_box, 0);
139
}
139
}
140
 
140
 
141
/** Answer message that was not dispatched and is not entered in
141
/** Answer message that was not dispatched and is not entered in
142
 * any queue
142
 * any queue
143
 */
143
 */
144
static void _ipc_answer_free_call(call_t *call)
144
static void _ipc_answer_free_call(call_t *call)
145
{
145
{
146
    answerbox_t *callerbox = call->callerbox;
146
    answerbox_t *callerbox = call->callerbox;
147
 
147
 
148
    call->flags &= ~IPC_CALL_DISPATCHED;
-
 
149
    call->flags |= IPC_CALL_ANSWERED;
148
    call->flags |= IPC_CALL_ANSWERED;
150
 
149
 
151
    spinlock_lock(&callerbox->lock);
150
    spinlock_lock(&callerbox->lock);
152
    list_append(&call->list, &callerbox->answers);
151
    list_append(&call->list, &callerbox->answers);
153
    spinlock_unlock(&callerbox->lock);
152
    spinlock_unlock(&callerbox->lock);
154
    waitq_wakeup(&callerbox->wq, 0);
153
    waitq_wakeup(&callerbox->wq, 0);
155
}
154
}
156
 
155
 
157
/** Answer message, that is in callee queue
156
/** Answer message, that is in callee queue
158
 *
157
 *
159
 * @param box Answerbox that is answering the message
158
 * @param box Answerbox that is answering the message
160
 * @param call Modified request that is being sent back
159
 * @param call Modified request that is being sent back
161
 */
160
 */
162
void ipc_answer(answerbox_t *box, call_t *call)
161
void ipc_answer(answerbox_t *box, call_t *call)
163
{
162
{
164
    /* Remove from active box */
163
    /* Remove from active box */
165
    spinlock_lock(&box->lock);
164
    spinlock_lock(&box->lock);
166
    list_remove(&call->list);
165
    list_remove(&call->list);
167
    spinlock_unlock(&box->lock);
166
    spinlock_unlock(&box->lock);
168
    /* Send back answer */
167
    /* Send back answer */
169
    _ipc_answer_free_call(call);
168
    _ipc_answer_free_call(call);
170
}
169
}
171
 
170
 
-
 
171
/** Simulate sending back a message
-
 
172
 *
-
 
173
 * Most errors are better handled by forming a normal backward
-
 
174
 * message and sending it as a normal answer.
-
 
175
 */
-
 
176
void ipc_backsend_err(phone_t *phone, call_t *call, __native err)
-
 
177
{
-
 
178
    call->data.phone = phone;
-
 
179
    atomic_inc(&phone->active_calls);
-
 
180
    if (phone->busy == IPC_BUSY_CONNECTED)
-
 
181
        IPC_SET_RETVAL(call->data, EHANGUP);
-
 
182
    else
-
 
183
        IPC_SET_RETVAL(call->data, ENOENT);
-
 
184
 
-
 
185
    _ipc_answer_free_call(call);
-
 
186
}
-
 
187
 
172
/* Unsafe unchecking ipc_call */
188
/* Unsafe unchecking ipc_call */
173
static void _ipc_call(phone_t *phone, answerbox_t *box, call_t *call)
189
static void _ipc_call(phone_t *phone, answerbox_t *box, call_t *call)
174
{
190
{
175
    if (! (call->flags & IPC_CALL_FORWARDED)) {
191
    if (! (call->flags & IPC_CALL_FORWARDED)) {
176
        atomic_inc(&phone->active_calls);
192
        atomic_inc(&phone->active_calls);
177
        call->data.phone = phone;
193
        call->data.phone = phone;
178
    }
194
    }
179
 
195
 
180
    spinlock_lock(&box->lock);
196
    spinlock_lock(&box->lock);
181
    list_append(&call->list, &box->calls);
197
    list_append(&call->list, &box->calls);
182
    spinlock_unlock(&box->lock);
198
    spinlock_unlock(&box->lock);
183
    waitq_wakeup(&box->wq, 0);
199
    waitq_wakeup(&box->wq, 0);
184
}
200
}
185
 
201
 
186
/** Send a asynchronous request using phone to answerbox
202
/** Send a asynchronous request using phone to answerbox
187
 *
203
 *
188
 * @param phone Phone connected to answerbox
204
 * @param phone Phone connected to answerbox
189
 * @param request Request to be sent
205
 * @param request Request to be sent
190
 */
206
 */
191
int ipc_call(phone_t *phone, call_t *call)
207
int ipc_call(phone_t *phone, call_t *call)
192
{
208
{
193
    answerbox_t *box;
209
    answerbox_t *box;
194
 
210
 
195
    spinlock_lock(&phone->lock);
211
    spinlock_lock(&phone->lock);
196
 
212
 
197
    box = phone->callee;
213
    box = phone->callee;
198
    if (!box) {
214
    if (!box) {
199
        /* Trying to send over disconnected phone */
215
        /* Trying to send over disconnected phone */
200
        spinlock_unlock(&phone->lock);
216
        spinlock_unlock(&phone->lock);
201
        if (call->flags & IPC_CALL_FORWARDED) {
217
        if (call->flags & IPC_CALL_FORWARDED) {
202
            IPC_SET_RETVAL(call->data, EFORWARD);
218
            IPC_SET_RETVAL(call->data, EFORWARD);
-
 
219
            _ipc_answer_free_call(call);
203
        } else { /* Simulate sending a message */
220
        } else { /* Simulate sending back a message */
204
            call->data.phone = phone;
-
 
205
            atomic_inc(&phone->active_calls);
-
 
206
            if (phone->busy == IPC_BUSY_CONNECTED)
221
            if (phone->busy == IPC_BUSY_CONNECTED)
207
                IPC_SET_RETVAL(call->data, EHANGUP);
222
                ipc_backsend_err(phone, call, EHANGUP);
208
            else
223
            else
209
                IPC_SET_RETVAL(call->data, ENOENT);
224
                ipc_backsend_err(phone, call, ENOENT);
210
        }
225
        }
211
 
226
 
212
        _ipc_answer_free_call(call);
-
 
213
        return ENOENT;
227
        return ENOENT;
214
    }
228
    }
215
    _ipc_call(phone, box, call);
229
    _ipc_call(phone, box, call);
216
   
230
   
217
    spinlock_unlock(&phone->lock);
231
    spinlock_unlock(&phone->lock);
218
    return 0;
232
    return 0;
219
}
233
}
220
 
234
 
221
/** Disconnect phone from answerbox
235
/** Disconnect phone from answerbox
222
 *
236
 *
223
 * It is allowed to call disconnect on already disconnected phone
237
 * It is allowed to call disconnect on already disconnected phone
224
 *
238
 *
225
 * @return 0 - phone disconnected, -1 - the phone was already disconnected
239
 * @return 0 - phone disconnected, -1 - the phone was already disconnected
226
 */
240
 */
227
int ipc_phone_hangup(phone_t *phone)
241
int ipc_phone_hangup(phone_t *phone)
228
{
242
{
229
    answerbox_t *box;
243
    answerbox_t *box;
230
    call_t *call;
244
    call_t *call;
231
   
245
   
232
    spinlock_lock(&phone->lock);
246
    spinlock_lock(&phone->lock);
233
    box = phone->callee;
247
    box = phone->callee;
234
    if (!box) {
248
    if (!box) {
235
        if (phone->busy == IPC_BUSY_CONNECTING) {
249
        if (phone->busy == IPC_BUSY_CONNECTING) {
236
            spinlock_unlock(&phone->lock);
250
            spinlock_unlock(&phone->lock);
237
            return -1;
251
            return -1;
238
        }
252
        }
239
        /* Already disconnected phone */
253
        /* Already disconnected phone */
240
        phone->busy = IPC_BUSY_FREE;
254
        phone->busy = IPC_BUSY_FREE;
241
        spinlock_unlock(&phone->lock);
255
        spinlock_unlock(&phone->lock);
242
        return 0;
256
        return 0;
243
    }
257
    }
244
 
258
 
245
    spinlock_lock(&box->lock);
259
    spinlock_lock(&box->lock);
246
    list_remove(&phone->list);
260
    list_remove(&phone->list);
247
    phone->callee = NULL;
261
    phone->callee = NULL;
248
    spinlock_unlock(&box->lock);
262
    spinlock_unlock(&box->lock);
249
 
263
 
250
    call = ipc_call_alloc();
264
    call = ipc_call_alloc();
251
    IPC_SET_METHOD(call->data, IPC_M_PHONE_HUNGUP);
265
    IPC_SET_METHOD(call->data, IPC_M_PHONE_HUNGUP);
252
    call->flags |= IPC_CALL_DISCARD_ANSWER;
266
    call->flags |= IPC_CALL_DISCARD_ANSWER;
253
    _ipc_call(phone, box, call);
267
    _ipc_call(phone, box, call);
254
 
268
 
255
    phone->busy = IPC_BUSY_FREE;
269
    phone->busy = IPC_BUSY_FREE;
256
 
270
 
257
    spinlock_unlock(&phone->lock);
271
    spinlock_unlock(&phone->lock);
258
 
272
 
259
    return 0;
273
    return 0;
260
}
274
}
261
 
275
 
262
/** Forwards call from one answerbox to a new one
276
/** Forwards call from one answerbox to a new one
263
 *
277
 *
264
 * @param request Request to be forwarded
278
 * @param request Request to be forwarded
265
 * @param newbox Target answerbox
279
 * @param newbox Target answerbox
266
 * @param oldbox Old answerbox
280
 * @param oldbox Old answerbox
267
 * @return 0 on forward ok, error code, if there was error
281
 * @return 0 on forward ok, error code, if there was error
268
 *
282
 *
269
 * - the return value serves only as an information for the forwarder,
283
 * - the return value serves only as an information for the forwarder,
270
 *   the original caller is notified automatically with EFORWARD
284
 *   the original caller is notified automatically with EFORWARD
271
 */
285
 */
272
int ipc_forward(call_t *call, phone_t *newphone, answerbox_t *oldbox)
286
int ipc_forward(call_t *call, phone_t *newphone, answerbox_t *oldbox)
273
{
287
{
274
    spinlock_lock(&oldbox->lock);
288
    spinlock_lock(&oldbox->lock);
275
    list_remove(&call->list);
289
    list_remove(&call->list);
276
    spinlock_unlock(&oldbox->lock);
290
    spinlock_unlock(&oldbox->lock);
277
 
291
 
278
    return ipc_call(newphone, call);
292
    return ipc_call(newphone, call);
279
}
293
}
280
 
294
 
281
 
295
 
282
/** Wait for phone call
296
/** Wait for phone call
283
 *
297
 *
284
 * @return Recived message address
298
 * @return Recived message address
285
 * - to distinguish between call and answer, look at call->flags
299
 * - to distinguish between call and answer, look at call->flags
286
 */
300
 */
287
call_t * ipc_wait_for_call(answerbox_t *box, int flags)
301
call_t * ipc_wait_for_call(answerbox_t *box, int flags)
288
{
302
{
289
    call_t *request;
303
    call_t *request;
290
 
304
 
291
restart:      
305
restart:      
292
    if (flags & IPC_WAIT_NONBLOCKING) {
306
    if (flags & IPC_WAIT_NONBLOCKING) {
293
        if (waitq_sleep_timeout(&box->wq,0,1) == ESYNCH_WOULD_BLOCK)
307
        if (waitq_sleep_timeout(&box->wq,0,1) == ESYNCH_WOULD_BLOCK)
294
            return NULL;
308
            return NULL;
295
    } else
309
    } else
296
        waitq_sleep(&box->wq);
310
        waitq_sleep(&box->wq);
297
   
311
   
298
    spinlock_lock(&box->lock);
312
    spinlock_lock(&box->lock);
299
    if (!list_empty(&box->answers)) {
313
    if (!list_empty(&box->answers)) {
300
        /* Handle asynchronous answers */
314
        /* Handle asynchronous answers */
301
        request = list_get_instance(box->answers.next, call_t, list);
315
        request = list_get_instance(box->answers.next, call_t, list);
302
        list_remove(&request->list);
316
        list_remove(&request->list);
303
        atomic_dec(&request->data.phone->active_calls);
317
        atomic_dec(&request->data.phone->active_calls);
304
    } else if (!list_empty(&box->calls)) {
318
    } else if (!list_empty(&box->calls)) {
305
        /* Handle requests */
319
        /* Handle requests */
306
        request = list_get_instance(box->calls.next, call_t, list);
320
        request = list_get_instance(box->calls.next, call_t, list);
307
        list_remove(&request->list);
321
        list_remove(&request->list);
308
        /* Append request to dispatch queue */
322
        /* Append request to dispatch queue */
309
        list_append(&request->list, &box->dispatched_calls);
323
        list_append(&request->list, &box->dispatched_calls);
310
        request->flags |= IPC_CALL_DISPATCHED;
-
 
311
    } else {
324
    } else {
312
        printf("WARNING: Spurious IPC wakeup.\n");
325
        printf("WARNING: Spurious IPC wakeup.\n");
313
        spinlock_unlock(&box->lock);
326
        spinlock_unlock(&box->lock);
314
        goto restart;
327
        goto restart;
315
    }
328
    }
316
    spinlock_unlock(&box->lock);
329
    spinlock_unlock(&box->lock);
317
    return request;
330
    return request;
318
}
331
}
319
 
332
 
320
/** Initilize ipc subsystem */
333
/** Initilize ipc subsystem */
321
void ipc_init(void)
334
void ipc_init(void)
322
{
335
{
323
    ipc_call_slab = slab_cache_create("ipc_call",
336
    ipc_call_slab = slab_cache_create("ipc_call",
324
                      sizeof(call_t),
337
                      sizeof(call_t),
325
                      0,
338
                      0,
326
                      NULL, NULL, 0);
339
                      NULL, NULL, 0);
327
}
340
}
328
 
341
 
329
/** Cleans up all IPC communication of the given task
342
/** Cleans up all IPC communication of the given task
330
 *
343
 *
331
 *
344
 *
332
 */
345
 */
333
void ipc_cleanup(task_t *task)
346
void ipc_cleanup(task_t *task)
334
{
347
{
335
    int i;
348
    int i;
336
 
349
 
337
    /* Disconnect all our phones ('ipc_phone_hangup') */
350
    /* Disconnect all our phones ('ipc_phone_hangup') */
338
    for (i=0;i < IPC_MAX_PHONES; i++)
351
    for (i=0;i < IPC_MAX_PHONES; i++)
339
        ipc_phone_hangup(&task->phones[i]);
352
        ipc_phone_hangup(&task->phones[i]);
340
 
353
 
341
    /* Disconnect all phones connected to answerbox */
354
    /* Disconnect all phones connected to answerbox */
342
 
355
 
343
    /* Answer all messages in 'calls' and 'dispatched_calls' queues */
356
    /* Answer all messages in 'calls' and 'dispatched_calls' queues */
344
   
357
   
345
    /* Wait for all async answers to arrive */
358
    /* Wait for all async answers to arrive */
346
}
359
}
347
 
360