Subversion Repositories HelenOS-historic

Rev

Rev 1365 | Rev 1443 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1365 Rev 1392
Line 55... Line 55...
55
} async_call_t;
55
} async_call_t;
56
 
56
 
57
LIST_INITIALIZE(dispatched_calls);
57
LIST_INITIALIZE(dispatched_calls);
58
LIST_INITIALIZE(queued_calls);
58
LIST_INITIALIZE(queued_calls);
59
 
59
 
60
static atomic_t ipc_futex;
60
static atomic_t ipc_futex = FUTEX_INITIALIZER;
61
 
-
 
62
void _ipc_init(void)
-
 
63
{
-
 
64
    futex_initialize(&ipc_futex, 1);
-
 
65
}
-
 
66
 
61
 
67
int ipc_call_sync(int phoneid, ipcarg_t method, ipcarg_t arg1,
62
int ipc_call_sync(int phoneid, ipcarg_t method, ipcarg_t arg1,
68
          ipcarg_t *result)
63
          ipcarg_t *result)
69
{
64
{
70
    ipc_call_t resdata;
65
    ipc_call_t resdata;
Line 250... Line 245...
250
    futex_up(&ipc_futex);
245
    futex_up(&ipc_futex);
251
    printf("Received unidentified answer: %P!!!\n", callid);
246
    printf("Received unidentified answer: %P!!!\n", callid);
252
}
247
}
253
 
248
 
254
 
249
 
255
/** Unconditionally wait for an IPC call.
250
/** One cycle of ipc wait for call call
256
 *
251
 *
257
 * - dispatch ASYNC reoutines in the background
252
 * - dispatch ASYNC reoutines in the background
258
 * @param call Space where the message is stored
253
 * @param call Space where the message is stored
-
 
254
 * @param usec Timeout in microseconds
-
 
255
 * @param flags Flags passed to SYS_IPC_WAIT (blocking, nonblocking)
259
 * @return Callid of the answer.
256
 * @return Callid of the answer.
260
 */
257
 */
261
ipc_callid_t ipc_wait_for_call(ipc_call_t *call)
258
ipc_callid_t ipc_wait_cycle(ipc_call_t *call, uint32_t usec, int flags)
262
{
259
{
263
    ipc_callid_t callid;
260
    ipc_callid_t callid;
264
 
261
 
265
    do {
-
 
266
        try_dispatch_queued_calls();
262
    try_dispatch_queued_calls();
267
 
263
   
268
        callid = __SYSCALL3(SYS_IPC_WAIT, (sysarg_t) call, SYNCH_NO_TIMEOUT, SYNCH_BLOCKING);
264
    callid = __SYSCALL3(SYS_IPC_WAIT, (sysarg_t) call, usec, flags);
269
        /* Handle received answers */
265
    /* Handle received answers */
270
        if (callid & IPC_CALLID_ANSWERED)
266
    if (callid & IPC_CALLID_ANSWERED)
271
            handle_answer(callid, call);
267
        handle_answer(callid, call);
272
    } while (callid & IPC_CALLID_ANSWERED);
-
 
273
 
268
 
274
    return callid;
269
    return callid;
275
}
270
}
276
 
271
 
277
/** Wait some time for an IPC call.
272
/** Wait some time for an IPC call.
Line 284... Line 279...
284
ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *call, uint32_t usec)
279
ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *call, uint32_t usec)
285
{
280
{
286
    ipc_callid_t callid;
281
    ipc_callid_t callid;
287
 
282
 
288
    do {
283
    do {
289
        try_dispatch_queued_calls();
-
 
290
 
-
 
291
        callid = __SYSCALL3(SYS_IPC_WAIT, (sysarg_t) call, usec, SYNCH_BLOCKING);
284
        callid = ipc_wait_cycle(call, usec, SYNCH_BLOCKING);
292
        /* Handle received answers */
-
 
293
        if (callid & IPC_CALLID_ANSWERED)
-
 
294
            handle_answer(callid, call);
-
 
295
    } while (callid & IPC_CALLID_ANSWERED);
285
    } while (callid & IPC_CALLID_ANSWERED);
296
 
286
 
297
    return callid;
287
    return callid;
298
}
288
}
299
 
289
 
Line 306... Line 296...
306
ipc_callid_t ipc_trywait_for_call(ipc_call_t *call)
296
ipc_callid_t ipc_trywait_for_call(ipc_call_t *call)
307
{
297
{
308
    ipc_callid_t callid;
298
    ipc_callid_t callid;
309
 
299
 
310
    do {
300
    do {
311
        try_dispatch_queued_calls();
-
 
312
 
-
 
313
        callid = __SYSCALL3(SYS_IPC_WAIT, (sysarg_t)call, SYNCH_NO_TIMEOUT, SYNCH_NON_BLOCKING);
301
        callid = ipc_wait_cycle(call, SYNCH_NO_TIMEOUT, SYNCH_NON_BLOCKING);
314
        /* Handle received answers */
-
 
315
        if (callid & IPC_CALLID_ANSWERED)
-
 
316
            handle_answer(callid, call);
-
 
317
    } while (callid & IPC_CALLID_ANSWERED);
302
    } while (callid & IPC_CALLID_ANSWERED);
318
 
303
 
319
    return callid;
304
    return callid;
320
}
305
}
321
 
306