Changeset 228e490 in mainline for uspace/lib/c/generic/ipc.c


Ignore:
Timestamp:
2010-12-14T17:00:02Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a9b6bec, eb221e5
Parents:
dd8d5a7
Message:

initial modifications for supporting declarative IPC interfaces

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/ipc.c

    rdd8d5a7 r228e490  
    131131/** Make a synchronous call transmitting 5 arguments of payload.
    132132 *
    133  * @param phoneid       Phone handle for the call.
    134  * @param method        Requested method.
    135  * @param arg1          Service-defined payload argument.
    136  * @param arg2          Service-defined payload argument.
    137  * @param arg3          Service-defined payload argument.
    138  * @param arg4          Service-defined payload argument.
    139  * @param arg5          Service-defined payload argument.
    140  * @param result1       If non-NULL, storage for the first return argument.
    141  * @param result2       If non-NULL, storage for the second return argument.
    142  * @param result3       If non-NULL, storage for the third return argument.
    143  * @param result4       If non-NULL, storage for the fourth return argument.
    144  * @param result5       If non-NULL, storage for the fifth return argument.
    145  *
    146  * @return              Negative value means IPC error.
    147  *                      Otherwise the RETVAL of the answer.
     133 * @param phoneid Phone handle for the call.
     134 * @param imethod Requested interface and method.
     135 * @param arg1    Service-defined payload argument.
     136 * @param arg2    Service-defined payload argument.
     137 * @param arg3    Service-defined payload argument.
     138 * @param arg4    Service-defined payload argument.
     139 * @param arg5    Service-defined payload argument.
     140 * @param result1 If non-NULL, storage for the first return argument.
     141 * @param result2 If non-NULL, storage for the second return argument.
     142 * @param result3 If non-NULL, storage for the third return argument.
     143 * @param result4 If non-NULL, storage for the fourth return argument.
     144 * @param result5 If non-NULL, storage for the fifth return argument.
     145 *
     146 * @return Negative value means IPC error.
     147 *         Otherwise the RETVAL of the answer.
     148 *
    148149 */
    149150int
    150 ipc_call_sync_slow(int phoneid, sysarg_t method, sysarg_t arg1, sysarg_t arg2,
     151ipc_call_sync_slow(int phoneid, sysarg_t imethod, sysarg_t arg1, sysarg_t arg2,
    151152    sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, sysarg_t *result1,
    152153    sysarg_t *result2, sysarg_t *result3, sysarg_t *result4, sysarg_t *result5)
    153154{
    154155        ipc_call_t data;
    155         int callres;
    156 
    157         IPC_SET_METHOD(data, method);
     156       
     157        IPC_SET_IMETHOD(data, imethod);
    158158        IPC_SET_ARG1(data, arg1);
    159159        IPC_SET_ARG2(data, arg2);
     
    161161        IPC_SET_ARG4(data, arg4);
    162162        IPC_SET_ARG5(data, arg5);
    163 
    164         callres = __SYSCALL3(SYS_IPC_CALL_SYNC_SLOW, phoneid, (sysarg_t) &data,
    165             (sysarg_t) &data);
     163       
     164        int callres = __SYSCALL3(SYS_IPC_CALL_SYNC_SLOW, phoneid,
     165            (sysarg_t) &data, (sysarg_t) &data);
    166166        if (callres)
    167167                return callres;
    168 
     168       
    169169        if (result1)
    170170                *result1 = IPC_GET_ARG1(data);
     
    177177        if (result5)
    178178                *result5 = IPC_GET_ARG5(data);
    179 
     179       
    180180        return IPC_GET_RETVAL(data);
    181181}
     
    183183/** Syscall to send asynchronous message.
    184184 *
    185  * @param phoneid       Phone handle for the call.
    186  * @param data          Call data with the request.
    187  *
    188  * @return              Hash of the call or an error code.
     185 * @param phoneid Phone handle for the call.
     186 * @param data    Call data with the request.
     187 *
     188 * @return Hash of the call or an error code.
     189 *
    189190 */
    190191static ipc_callid_t _ipc_call_async(int phoneid, ipc_call_t *data)
     
    277278 * If the call cannot be temporarily made, queue it.
    278279 *
    279  * @param phoneid       Phone handle for the call.
    280  * @param method        Requested method.
    281  * @param arg1          Service-defined payload argument.
    282  * @param arg2          Service-defined payload argument.
    283  * @param arg3          Service-defined payload argument.
    284  * @param arg4          Service-defined payload argument.
    285  * @param private       Argument to be passed to the answer/error callback.
    286  * @param callback      Answer or error callback.
    287  * @param can_preempt   If non-zero, the current fibril will be preempted in
    288  *                      case the kernel temporarily refuses to accept more
    289  *                      asynchronous calls.
    290  */
    291 void ipc_call_async_fast(int phoneid, sysarg_t method, sysarg_t arg1,
     280 * @param phoneid     Phone handle for the call.
     281 * @param imethod     Requested interface and method.
     282 * @param arg1        Service-defined payload argument.
     283 * @param arg2        Service-defined payload argument.
     284 * @param arg3        Service-defined payload argument.
     285 * @param arg4        Service-defined payload argument.
     286 * @param private     Argument to be passed to the answer/error callback.
     287 * @param callback    Answer or error callback.
     288 * @param can_preempt If non-zero, the current fibril will be preempted in
     289 *                    case the kernel temporarily refuses to accept more
     290 *                    asynchronous calls.
     291 *
     292 */
     293void ipc_call_async_fast(int phoneid, sysarg_t imethod, sysarg_t arg1,
    292294    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, void *private,
    293295    ipc_async_callback_t callback, int can_preempt)
    294296{
    295297        async_call_t *call = NULL;
    296         ipc_callid_t callid;
    297 
     298       
    298299        if (callback) {
    299300                call = ipc_prepare_async(private, callback);
     
    301302                        return;
    302303        }
    303 
     304       
    304305        /*
    305306         * We need to make sure that we get callid before another thread
     
    307308         */
    308309        futex_down(&ipc_futex);
    309         callid = __SYSCALL6(SYS_IPC_CALL_ASYNC_FAST, phoneid, method, arg1,
    310             arg2, arg3, arg4);
    311 
     310        ipc_callid_t callid = __SYSCALL6(SYS_IPC_CALL_ASYNC_FAST, phoneid,
     311            imethod, arg1, arg2, arg3, arg4);
     312       
    312313        if (callid == (ipc_callid_t) IPC_CALLRET_TEMPORARY) {
    313314                if (!call) {
     
    316317                                return;
    317318                }
    318                 IPC_SET_METHOD(call->u.msg.data, method);
     319                IPC_SET_IMETHOD(call->u.msg.data, imethod);
    319320                IPC_SET_ARG1(call->u.msg.data, arg1);
    320321                IPC_SET_ARG2(call->u.msg.data, arg2);
     
    337338 * If the call cannot be temporarily made, queue it.
    338339 *
    339  * @param phoneid       Phone handle for the call.
    340  * @param method        Requested method.
    341  * @param arg1          Service-defined payload argument.
    342  * @param arg2          Service-defined payload argument.
    343  * @param arg3          Service-defined payload argument.
    344  * @param arg4          Service-defined payload argument.
    345  * @param arg5          Service-defined payload argument.
    346  * @param private       Argument to be passed to the answer/error callback.
    347  * @param callback      Answer or error callback.
    348  * @param can_preempt   If non-zero, the current fibril will be preempted in
    349  *                      case the kernel temporarily refuses to accept more
    350  *                      asynchronous calls.
    351  *
    352  */
    353 void ipc_call_async_slow(int phoneid, sysarg_t method, sysarg_t arg1,
     340 * @param phoneid     Phone handle for the call.
     341 * @param imethod     Requested interface and method.
     342 * @param arg1        Service-defined payload argument.
     343 * @param arg2        Service-defined payload argument.
     344 * @param arg3        Service-defined payload argument.
     345 * @param arg4        Service-defined payload argument.
     346 * @param arg5        Service-defined payload argument.
     347 * @param private     Argument to be passed to the answer/error callback.
     348 * @param callback    Answer or error callback.
     349 * @param can_preempt If non-zero, the current fibril will be preempted in
     350 *                    case the kernel temporarily refuses to accept more
     351 *                    asynchronous calls.
     352 *
     353 */
     354void ipc_call_async_slow(int phoneid, sysarg_t imethod, sysarg_t arg1,
    354355    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, void *private,
    355356    ipc_async_callback_t callback, int can_preempt)
     
    362363                return;
    363364
    364         IPC_SET_METHOD(call->u.msg.data, method);
     365        IPC_SET_IMETHOD(call->u.msg.data, imethod);
    365366        IPC_SET_ARG1(call->u.msg.data, arg1);
    366367        IPC_SET_ARG2(call->u.msg.data, arg2);
     
    676677/** Forward a received call to another destination.
    677678 *
    678  * @param callid        Hash of the call to forward.
    679  * @param phoneid       Phone handle to use for forwarding.
    680  * @param method        New method for the forwarded call.
    681  * @param arg1          New value of the first argument for the forwarded call.
    682  * @param arg2          New value of the second argument for the forwarded call.
    683  * @param mode          Flags specifying mode of the forward operation.
    684  *
    685  * @return              Zero on success or an error code.
     679 * @param callid  Hash of the call to forward.
     680 * @param phoneid Phone handle to use for forwarding.
     681 * @param imethod New interface and method for the forwarded call.
     682 * @param arg1    New value of the first argument for the forwarded call.
     683 * @param arg2    New value of the second argument for the forwarded call.
     684 * @param mode    Flags specifying mode of the forward operation.
     685 *
     686 * @return Zero on success or an error code.
    686687 *
    687688 * For non-system methods, the old method, arg1 and arg2 are rewritten by the
     
    690691 * methods are forwarded verbatim.
    691692 */
    692 int ipc_forward_fast(ipc_callid_t callid, int phoneid, int method,
     693int ipc_forward_fast(ipc_callid_t callid, int phoneid, int imethod,
    693694    sysarg_t arg1, sysarg_t arg2, int mode)
    694695{
    695         return __SYSCALL6(SYS_IPC_FORWARD_FAST, callid, phoneid, method, arg1,
     696        return __SYSCALL6(SYS_IPC_FORWARD_FAST, callid, phoneid, imethod, arg1,
    696697            arg2, mode);
    697698}
    698699
    699700
    700 int ipc_forward_slow(ipc_callid_t callid, int phoneid, int method,
     701int ipc_forward_slow(ipc_callid_t callid, int phoneid, int imethod,
    701702    sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5,
    702703    int mode)
    703704{
    704705        ipc_call_t data;
    705 
    706         IPC_SET_METHOD(data, method);
     706       
     707        IPC_SET_IMETHOD(data, imethod);
    707708        IPC_SET_ARG1(data, arg1);
    708709        IPC_SET_ARG2(data, arg2);
     
    710711        IPC_SET_ARG4(data, arg4);
    711712        IPC_SET_ARG5(data, arg5);
    712 
     713       
    713714        return __SYSCALL4(SYS_IPC_FORWARD_SLOW, callid, phoneid, (sysarg_t) &data, mode);
    714715}
Note: See TracChangeset for help on using the changeset viewer.