Changeset 2e51969 in mainline for uspace/lib/libc/generic/ipc.c


Ignore:
Timestamp:
2007-11-19T12:20:10Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0c09f2b
Parents:
e0bc7fc
Message:

Modify synchronous IPC to make use of all six syscall arguments. The preferred
means of synchronous communication is now via the set of ipc_call_sync_m_n()
macros, where m is the number of payload arguments passed to the kernel and n is
the number of return values. These macros will automatically decide between the
fast and the universal slow version of ipc_call_sync.

File:
1 edited

Legend:

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

    re0bc7fc r2e51969  
    8585/** Make a fast synchronous call.
    8686 *
    87  * Only one payload argument can be passed using this function. However, this
    88  * function is faster than the generic ipc_call_sync_3().
    89  *
    90  * @param phoneid       Phone handle for the call.
    91  * @param method        Requested method.
    92  * @param arg1          Service-defined payload argument.
    93  * @param result        If non-NULL, the return ARG1 will be stored there.
    94  *
    95  * @return              Negative values represent errors returned by IPC.
    96  *                      Otherwise the RETVAL of the answer is returned.
    97  */
    98 int ipc_call_sync(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t *result)
    99 {
    100         ipc_call_t resdata;
    101         int callres;
    102        
    103         callres = __SYSCALL4(SYS_IPC_CALL_SYNC_FAST, phoneid, method, arg1,
    104             (sysarg_t) &resdata);
    105         if (callres)
    106                 return callres;
    107         if (result)
    108                 *result = IPC_GET_ARG1(resdata);
    109         return IPC_GET_RETVAL(resdata);
    110 }
    111 
    112 /** Make a synchronous call transmitting 3 arguments of payload.
     87 * Only three payload arguments can be passed using this function. However, this
     88 * function is faster than the generic ipc_call_sync_slow() because the payload
     89 * is passed directly in registers.
    11390 *
    11491 * @param phoneid       Phone handle for the call.
     
    11794 * @param arg2          Service-defined payload argument.
    11895 * @param arg3          Service-defined payload argument.
     96 * @param result1       If non-NULL, the return ARG1 will be stored there.
     97 * @param result2       If non-NULL, the return ARG2 will be stored there.
     98 * @param result3       If non-NULL, the return ARG3 will be stored there.
     99 * @param result4       If non-NULL, the return ARG4 will be stored there.
     100 * @param result5       If non-NULL, the return ARG5 will be stored there.
     101 *
     102 * @return              Negative values represent errors returned by IPC.
     103 *                      Otherwise the RETVAL of the answer is returned.
     104 */
     105int
     106ipc_call_sync_fast(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2,
     107    ipcarg_t arg3, ipcarg_t *result1, ipcarg_t *result2, ipcarg_t *result3,
     108    ipcarg_t *result4, ipcarg_t *result5)
     109{
     110        ipc_call_t resdata;
     111        int callres;
     112       
     113        callres = __SYSCALL6(SYS_IPC_CALL_SYNC_FAST, phoneid, method, arg1,
     114            arg2, arg3, (sysarg_t) &resdata);
     115        if (callres)
     116                return callres;
     117        if (result1)
     118                *result1 = IPC_GET_ARG1(resdata);
     119        if (result2)
     120                *result2 = IPC_GET_ARG2(resdata);
     121        if (result3)
     122                *result3 = IPC_GET_ARG3(resdata);
     123        if (result4)
     124                *result4 = IPC_GET_ARG4(resdata);
     125        if (result5)
     126                *result5 = IPC_GET_ARG5(resdata);
     127
     128        return IPC_GET_RETVAL(resdata);
     129}
     130
     131/** Make a synchronous call transmitting 5 arguments of payload.
     132 *
     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.
    119140 * @param result1       If non-NULL, storage for the first return argument.
    120141 * @param result2       If non-NULL, storage for the second return argument.
    121142 * @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.
    122145 *
    123146 * @return              Negative value means IPC error.
    124147 *                      Otherwise the RETVAL of the answer.
    125148 */
    126 int ipc_call_sync_3(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2,
    127     ipcarg_t arg3, ipcarg_t *result1, ipcarg_t *result2, ipcarg_t *result3)
     149int
     150ipc_call_sync_slow(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2,
     151    ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5, ipcarg_t *result1,
     152    ipcarg_t *result2, ipcarg_t *result3, ipcarg_t *result4, ipcarg_t *result5)
    128153{
    129154        ipc_call_t data;
     
    134159        IPC_SET_ARG2(data, arg2);
    135160        IPC_SET_ARG3(data, arg3);
    136 
    137         callres = __SYSCALL3(SYS_IPC_CALL_SYNC, phoneid, (sysarg_t) &data,
     161        IPC_SET_ARG4(data, arg4);
     162        IPC_SET_ARG5(data, arg5);
     163
     164        callres = __SYSCALL3(SYS_IPC_CALL_SYNC_SLOW, phoneid, (sysarg_t) &data,
    138165            (sysarg_t) &data);
    139166        if (callres)
     
    146173        if (result3)
    147174                *result3 = IPC_GET_ARG3(data);
     175        if (result4)
     176                *result4 = IPC_GET_ARG4(data);
     177        if (result5)
     178                *result5 = IPC_GET_ARG5(data);
     179
    148180        return IPC_GET_RETVAL(data);
    149181}
     
    516548int ipc_connect_to_me(int phoneid, int arg1, int arg2, ipcarg_t *phonehash)
    517549{
    518         return ipc_call_sync_3(phoneid, IPC_M_CONNECT_TO_ME, arg1, arg2, 0, 0,
    519             0, phonehash);
     550        return ipc_call_sync_2_3(phoneid, IPC_M_CONNECT_TO_ME, arg1, arg2,
     551            NULL, NULL, phonehash);
    520552}
    521553
     
    533565        int res;
    534566
    535         res = ipc_call_sync_3(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, 0, 0, 0,
    536             &newphid);
     567        res = ipc_call_sync_2_3(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, NULL,
     568            NULL, &newphid);
    537569        if (res)
    538570                return res;
     
    606638int ipc_data_send(int phoneid, void *src, size_t size)
    607639{
    608         return ipc_call_sync_3(phoneid, IPC_M_DATA_SEND, 0, (ipcarg_t) src,
    609             (ipcarg_t) size, NULL, NULL, NULL);
     640        return ipc_call_sync_3_0(phoneid, IPC_M_DATA_SEND, 0, (ipcarg_t) src,
     641            (ipcarg_t) size);
    610642}
    611643
Note: See TracChangeset for help on using the changeset viewer.