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


Ignore:
Timestamp:
2007-11-20T21:33:32Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8498915
Parents:
3209923
Message:

Modify ipc_answer_*() to make use of all six syscall arguments. The recommended
means of answering calls is via the ipc_answer_m() macros (where m denotes the
number of return arguments) that automatically decide between the fast register
version or the slow universal version of ipc_answer().

File:
1 edited

Legend:

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

    r3209923 rb74959bd  
    376376/** Answer a received call - fast version.
    377377 *
    378  * The fast answer makes use of passing retval and first two arguments in
    379  * registers. If you need to return more, use the ipc_answer() instead.
     378 * The fast answer makes use of passing retval and first four arguments in
     379 * registers. If you need to return more, use the ipc_answer_slow() instead.
    380380 *
    381381 * @param callid        Hash of the call being answered.
     
    383383 * @param arg1          First return argument.
    384384 * @param arg2          Second return argument.
     385 * @param arg3          Third return argument.
     386 * @param arg4          Fourth return argument.
    385387 *
    386388 * @return              Zero on success or a value from @ref errno.h on failure.
    387389 */
    388390ipcarg_t ipc_answer_fast(ipc_callid_t callid, ipcarg_t retval, ipcarg_t arg1,
    389     ipcarg_t arg2)
    390 {
    391         return __SYSCALL4(SYS_IPC_ANSWER_FAST, callid, retval, arg1, arg2);
    392 }
    393 
    394 /** Answer a received call - full version.
     391    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4)
     392{
     393        return __SYSCALL6(SYS_IPC_ANSWER_FAST, callid, retval, arg1, arg2, arg3,
     394            arg4);
     395}
     396
     397/** Answer a received call - slow full version.
    395398 *
    396399 * @param callid        Hash of the call being answered.
    397  * @param call          Call structure with the answer.
    398  *                      Must be already initialized by the responder.
     400 * @param retval        Return value.
     401 * @param arg1          First return argument.
     402 * @param arg2          Second return argument.
     403 * @param arg3          Third return argument.
     404 * @param arg4          Fourth return argument.
     405 * @param arg5          Fifth return argument.
    399406 *
    400407 * @return              Zero on success or a value from @ref errno.h on failure.
    401408 */
    402 ipcarg_t ipc_answer(ipc_callid_t callid, ipc_call_t *call)
    403 {
    404         return __SYSCALL2(SYS_IPC_ANSWER, callid, (sysarg_t) call);
     409ipcarg_t ipc_answer_slow(ipc_callid_t callid, ipcarg_t retval, ipcarg_t arg1,
     410    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5)
     411{
     412        ipc_call_t data;
     413
     414        IPC_SET_RETVAL(data, retval);
     415        IPC_SET_ARG1(data, arg1);
     416        IPC_SET_ARG2(data, arg2);
     417        IPC_SET_ARG3(data, arg3);
     418        IPC_SET_ARG4(data, arg4);
     419        IPC_SET_ARG5(data, arg5);
     420
     421        return __SYSCALL2(SYS_IPC_ANSWER_SLOW, callid, (sysarg_t) &data);
    405422}
    406423
     
    659676 * @param callid        Storage where the hash of the IPC_M_DATA_SEND call will
    660677 *                      be stored.
    661  * @param call          Storage where the incoming call will be stored.
    662678 * @param dst           Storage where the suggested destination address will
    663679 *                      be stored. May be NULL.
     
    667683 * @return              Non-zero on success, zero on failure.
    668684 */
    669 int ipc_data_receive(ipc_callid_t *callid, ipc_call_t *call, void **dst,
    670     size_t *size)
    671 {
     685int ipc_data_receive(ipc_callid_t *callid, void **dst, size_t *size)
     686{
     687        ipc_call_t data;
     688       
    672689        assert(callid);
    673         assert(call);
    674 
    675         *callid = async_get_call(call);
    676         if (IPC_GET_METHOD(*call) != IPC_M_DATA_SEND)
     690
     691        *callid = async_get_call(&data);
     692        if (IPC_GET_METHOD(data) != IPC_M_DATA_SEND)
    677693                return 0;
    678694        if (dst)
    679                 *dst = (void *) IPC_GET_ARG1(*call);
     695                *dst = (void *) IPC_GET_ARG1(data);
    680696        if (size)
    681                 *size = (size_t) IPC_GET_ARG3(*call);
     697                *size = (size_t) IPC_GET_ARG3(data);
    682698        return 1;
    683699}
     
    689705 *
    690706 * @param callid        Hash of the IPC_M_DATA_SEND call to answer.
    691  * @param call          Call structure with the request.
    692707 * @param dst           Final destination address for the IPC_M_DATA_SEND call.
    693708 * @param size          Final size for the IPC_M_DATA_SEND call.
     
    695710 * @return              Zero on success or a value from @ref errno.h on failure.
    696711 */
    697 ipcarg_t ipc_data_deliver(ipc_callid_t callid, ipc_call_t *call, void *dst,
    698     size_t size)
    699 {
    700         IPC_SET_RETVAL(*call, EOK);
    701         IPC_SET_ARG1(*call, (ipcarg_t) dst);
    702         IPC_SET_ARG3(*call, (ipcarg_t) size);
    703         return ipc_answer(callid, call);
     712ipcarg_t ipc_data_deliver(ipc_callid_t callid, void *dst, size_t size)
     713{
     714        return ipc_answer_3(callid, EOK, (ipcarg_t) dst, 0, (ipcarg_t) size);
    704715}
    705716 
Note: See TracChangeset for help on using the changeset viewer.