Changeset e74cb73 in mainline for generic/src/syscall/syscall.c


Ignore:
Timestamp:
2006-03-14T09:30:07Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d1f8a87
Parents:
27810c5
Message:

Added skeleton name service.
Cleanup for IPC to use mutexes instead of spinlocks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • generic/src/syscall/syscall.c

    r27810c5 re74cb73  
    6161           -2 on 'Too many async request, handle answers first
    6262 */
    63 static __native sys_ipc_call_sync(__native phoneid, __native arg1,
    64                                    __native arg2, __native *respdata)
     63static __native sys_ipc_call_sync(__native phoneid, __native method,
     64                                   __native arg1, __native *data)
    6565{
    66         call_t *call;
     66        call_t call;
    6767        phone_t *phone;
    6868        /* Special answerbox for synchronous messages */
    6969
    7070        if (phoneid >= IPC_MAX_PHONES)
    71                 return -ENOENT;
     71                return IPC_CALLRET_FATAL;
    7272
    7373        phone = &TASK->phones[phoneid];
    7474        if (!phone->callee)
    75                 return -ENOENT;
     75                return IPC_CALLRET_FATAL;
    7676
    77         call = ipc_call_alloc();
    78         call->data[0] = arg1;
    79         call->data[1] = arg2;
     77        ipc_call_init(&call);
     78        IPC_SET_METHOD(call.data, method);
     79        IPC_SET_ARG1(call.data, arg1);
    8080       
    81         ipc_call_sync(phone, call);
     81        ipc_call_sync(phone, &call);
    8282
    83         copy_to_uspace(respdata, &call->data, sizeof(__native) * IPC_CALL_LEN);
     83        copy_to_uspace(data, &call.data, sizeof(call.data));
    8484
    8585        return 0;
    8686}
     87
     88static __native sys_ipc_call_sync_medium(__native phoneid, __native *data)
     89{
     90        call_t call;
     91        phone_t *phone;
     92        /* Special answerbox for synchronous messages */
     93
     94        if (phoneid >= IPC_MAX_PHONES)
     95                return IPC_CALLRET_FATAL;
     96
     97        phone = &TASK->phones[phoneid];
     98        if (!phone->callee)
     99                return IPC_CALLRET_FATAL;
     100
     101        ipc_call_init(&call);
     102        copy_from_uspace(&call.data, data, sizeof(call.data));
     103       
     104        ipc_call_sync(phone, &call);
     105
     106        copy_to_uspace(data, &call.data, sizeof(call.data));
     107
     108        return 0;
     109}
     110
    87111
    88112/** Send an asynchronous call over ipc
     
    91115           -2 on 'Too many async request, handle answers first
    92116 */
    93 static __native sys_ipc_call_async(__native phoneid, __native arg1,
    94                                    __native arg2)
     117static __native sys_ipc_call_async(__native phoneid, __native method,
     118                                   __native arg1, __native arg2)
    95119{
    96120        call_t *call;
     
    98122
    99123        if (phoneid >= IPC_MAX_PHONES)
    100                 return -ENOENT;
     124                return IPC_CALLRET_FATAL;
    101125
    102126        phone = &TASK->phones[phoneid];
    103127        if (!phone->callee)
    104                 return -ENOENT;
    105 
     128                return IPC_CALLRET_FATAL;
    106129
    107130        /* TODO: Check that we did not exceed system imposed maximum
     
    110133         */
    111134        call = ipc_call_alloc();
    112         call->data[0] = arg1;
    113         call->data[1] = arg2;
     135        IPC_SET_METHOD(call->data, method);
     136        IPC_SET_ARG1(call->data, arg1);
     137        IPC_SET_ARG2(call->data, arg2);
     138
    114139        ipc_call(phone, call);
    115140
     
    118143
    119144/** Send IPC answer */
    120 static __native sys_ipc_answer(__native callid, __native arg1, __native arg2)
     145static __native sys_ipc_answer(__native callid, __native retval, __native arg1,
     146                               __native arg2)
    121147{
    122148        call_t *call;
     
    127153        call = (call_t *) callid;
    128154
    129         call->data[0] = arg1;
    130         call->data[1] = arg2;
     155        IPC_SET_RETVAL(call->data, retval);
     156        IPC_SET_ARG1(call->data, arg1);
     157        IPC_SET_ARG2(call->data, arg2);
    131158
    132159        ipc_answer(&TASK->answerbox, call);
     
    145172       
    146173        call = ipc_wait_for_call(&TASK->answerbox, flags);
    147         copy_to_uspace(calldata, &call->data, sizeof(__native) * IPC_CALL_LEN);
    148174
    149         if (call->flags & IPC_CALL_ANSWERED)
    150                 return ((__native)call) | 1;
     175        copy_to_uspace(calldata, &call->data, sizeof(call->data));
     176        if (call->flags & IPC_CALL_ANSWERED) {
     177                ASSERT(! (call->flags & IPC_CALL_STATIC_ALLOC));
     178                ipc_call_free(call);
     179                return ((__native)call) | IPC_CALLID_ANSWERED;
     180        }
    151181        return (__native)call;
    152182}
     
    157187        sys_io,
    158188        sys_ipc_call_sync,
     189        sys_ipc_call_sync_medium,
    159190        sys_ipc_call_async,
    160191        sys_ipc_answer,
Note: See TracChangeset for help on using the changeset viewer.