Changeset bd5a663 in mainline


Ignore:
Timestamp:
2006-05-17T14:03:44Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
59477e3
Parents:
bdb9ea8
Message:

Modify ipc_wait_for_call() to support all of blocking, non-blocking and timeout operation.

Location:
generic
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • generic/include/ipc/ipc.h

    rbdb9ea8 rbd5a663  
    4545#define IPC_CALL_CONN_ME_TO     (1<<4) /* Identify connect_me_to */
    4646#define IPC_CALL_NOTIF          (1<<5) /* Interrupt notification */
    47 
    48 /* Flags for ipc_wait_for_call */
    49 #define IPC_WAIT_NONBLOCKING   1
    5047
    5148/* Flags of callid (the addresses are aligned at least to 4,
     
    201198
    202199extern void ipc_init(void);
    203 extern call_t * ipc_wait_for_call(answerbox_t *box, int flags);
     200extern call_t * ipc_wait_for_call(answerbox_t *box, __u32 usec, int nonblocking);
    204201extern void ipc_answer(answerbox_t *box, call_t *request);
    205202extern int ipc_call(phone_t *phone, call_t *call);
     
    217214extern void ipc_backsend_err(phone_t *phone, call_t *call, __native err);
    218215
    219 
    220216extern answerbox_t *ipc_phone_0;
    221217
  • generic/include/ipc/sysipc.h

    rbdb9ea8 rbd5a663  
    3232#include <ipc/ipc.h>
    3333#include <ipc/irq.h>
     34#include <arch/types.h>
    3435
    3536__native sys_ipc_call_sync_fast(__native phoneid, __native method,
     
    4344                             __native arg1, __native arg2);
    4445__native sys_ipc_answer(__native callid, ipc_data_t *data);
    45 __native sys_ipc_wait_for_call(ipc_data_t *calldata, __native flags);
     46__native sys_ipc_wait_for_call(ipc_data_t *calldata, __u32 usec, int nonblocking);
    4647__native sys_ipc_forward_fast(__native callid, __native phoneid,
    4748                              __native method, __native arg1);
  • generic/src/ipc/ipc.c

    rbdb9ea8 rbd5a663  
    3434#include <synch/spinlock.h>
    3535#include <synch/waitq.h>
     36#include <synch/synch.h>
    3637#include <ipc/ipc.h>
    3738#include <errno.h>
     
    142143
    143144        ipc_call(phone, request);
    144         ipc_wait_for_call(&sync_box, 0);
     145        ipc_wait_for_call(&sync_box, SYNCH_NO_TIMEOUT, SYNCH_BLOCKING);
    145146}
    146147
     
    302303/** Wait for phone call
    303304 *
     305 * @param box Answerbox expecting the call.
     306 * @param usec Timeout in microseconds. See documentation for waitq_sleep_timeout() for
     307 *             decription of its special meaning.
     308 * @param nonblocking Blocking vs. non-blocking operation mode switch. See documentation
     309 *                    for waitq_sleep_timeout() for description of its special meaning.
    304310 * @return Recived message address
    305311 * - to distinguish between call and answer, look at call->flags
    306312 */
    307 call_t * ipc_wait_for_call(answerbox_t *box, int flags)
     313call_t * ipc_wait_for_call(answerbox_t *box, __u32 usec, int nonblocking)
    308314{
    309315        call_t *request;
    310316        ipl_t ipl;
    311 
    312 restart:     
    313         if (flags & IPC_WAIT_NONBLOCKING) {
    314                 if (waitq_sleep_timeout(&box->wq,0,1) == ESYNCH_WOULD_BLOCK)
    315                         return NULL;
    316         } else
    317                 waitq_sleep(&box->wq);
     317        int rc;
     318
     319restart:
     320        rc = waitq_sleep_timeout(&box->wq, usec, nonblocking);
     321        if (SYNCH_FAILED(rc))
     322                return NULL;
    318323       
    319324        spinlock_lock(&box->lock);
     
    408413        /* Wait for all async answers to arrive */
    409414        while (atomic_get(&task->active_calls)) {
    410                 call = ipc_wait_for_call(&task->answerbox, 0);
     415                call = ipc_wait_for_call(&task->answerbox, SYNCH_NO_TIMEOUT, SYNCH_BLOCKING);
    411416                ASSERT((call->flags & IPC_CALL_ANSWERED) || (call->flags & IPC_CALL_NOTIF));
    412417                ASSERT(! (call->flags & IPC_CALL_STATIC_ALLOC));
  • generic/src/ipc/sysipc.c

    rbdb9ea8 rbd5a663  
    469469 *
    470470 * @param calldata Pointer to buffer where the call/answer data is stored
    471  * @param flags
     471 * @param usec Timeout. See waitq_sleep_timeout() for explanation.
     472 * @param nonblocking See waitq_sleep_timeout() for explanation.
     473 *
    472474 * @return Callid, if callid & 1, then the call is answer
    473475 */
    474 __native sys_ipc_wait_for_call(ipc_data_t *calldata, __native flags)
     476__native sys_ipc_wait_for_call(ipc_data_t *calldata, __u32 usec, int nonblocking)
    475477{
    476478        call_t *call;
    477479
    478480restart:       
    479         call = ipc_wait_for_call(&TASK->answerbox, flags);
     481        call = ipc_wait_for_call(&TASK->answerbox, usec, nonblocking);
    480482        if (!call)
    481483                return 0;
Note: See TracChangeset for help on using the changeset viewer.