Changeset b74959bd in mainline for uspace/lib/libc


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().

Location:
uspace/lib/libc
Files:
3 edited

Legend:

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

    r3209923 rb74959bd  
    7676 * {
    7777 *      if (want_refuse) {
    78  *              ipc_answer_fast(icallid, ELIMIT, 0, 0);
     78 *              ipc_answer_0(icallid, ELIMIT);
    7979 *              return;
    8080 *      }
    81  *      ipc_answer_fast(icallid, EOK, 0, 0);
     81 *      ipc_answer_0(icallid, EOK);
    8282 *
    8383 *      callid = async_get_call(&call);
    8484 *      handle_call(callid, call);
    85  *      ipc_answer_fast(callid, 1, 2, 3);
     85 *      ipc_answer_2(callid, 1, 2, 3);
    8686 *
    8787 *      callid = async_get_call(&call);
     
    396396static void default_client_connection(ipc_callid_t callid, ipc_call_t *call)
    397397{
    398         ipc_answer_fast(callid, ENOENT, 0, 0);
     398        ipc_answer_0(callid, ENOENT);
    399399}
    400400
     
    441441                if (msg->callid == FIBRIL_connection->close_callid)
    442442                        close_answered = 1;
    443                 ipc_answer_fast(msg->callid, EHANGUP, 0, 0);
     443                ipc_answer_0(msg->callid, EHANGUP);
    444444                free(msg);
    445445        }
    446446        if (FIBRIL_connection->close_callid)
    447                 ipc_answer_fast(FIBRIL_connection->close_callid, 0, 0, 0);
     447                ipc_answer_0(FIBRIL_connection->close_callid, EOK);
    448448       
    449449        return 0;
     
    476476        if (!conn) {
    477477                if (callid)
    478                         ipc_answer_fast(callid, ENOMEM, 0, 0);
     478                        ipc_answer_0(callid, ENOMEM);
    479479                return NULL;
    480480        }
     
    492492                free(conn);
    493493                if (callid)
    494                         ipc_answer_fast(callid, ENOMEM, 0, 0);
     494                        ipc_answer_0(callid, ENOMEM);
    495495                return NULL;
    496496        }
     
    537537
    538538        /* Unknown call from unknown phone - hang it up */
    539         ipc_answer_fast(callid, EHANGUP, 0, 0);
     539        ipc_answer_0(callid, EHANGUP);
    540540}
    541541
  • 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 
  • uspace/lib/libc/include/ipc/ipc.h

    r3209923 rb74959bd  
    191191extern ipc_callid_t ipc_trywait_for_call(ipc_call_t *data);
    192192
    193 #define ipc_answer_fast_0(callid, retval) \
    194     ipc_answer_fast((callid), (retval), 0, 0)
    195 #define ipc_answer_fast_1(callid, retval, arg1) \
    196     ipc_answer_fast((callid), (retval), (arg1), 0)
     193/*
     194 * User-friendly wrappers for ipc_answer_fast() and ipc_answer_slow().
     195 * They are in the form of ipc_answer_m(), where m is the number of return
     196 * arguments. The macros decide between the fast and the slow version according
     197 * to m.
     198 */
     199#define ipc_answer_0(callid, retval) \
     200    ipc_answer_fast((callid), (retval), 0, 0, 0, 0)
     201#define ipc_answer_1(callid, retval, arg1) \
     202    ipc_answer_fast((callid), (retval), (arg1), 0, 0, 0)
     203#define ipc_answer_2(callid, retval, arg1, arg2) \
     204    ipc_answer_fast((callid), (retval), (arg1), (arg2), 0, 0)
     205#define ipc_answer_3(callid, retval, arg1, arg2, arg3) \
     206    ipc_answer_fast((callid), (retval), (arg1), (arg2), (arg3), 0)
     207#define ipc_answer_4(callid, retval, arg1, arg2, arg3, arg4) \
     208    ipc_answer_fast((callid), (retval), (arg1), (arg2), (arg3), (arg4))
     209#define ipc_answer_5(callid, retval, arg1, arg2, arg3, arg4, arg5) \
     210    ipc_answer_slow((callid), (retval), (arg1), (arg2), (arg3), (arg4), (arg5))
     211
    197212extern ipcarg_t ipc_answer_fast(ipc_callid_t callid, ipcarg_t retval,
    198     ipcarg_t arg1, ipcarg_t arg2);
    199 extern ipcarg_t ipc_answer(ipc_callid_t callid, ipc_call_t *call);
     213    ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4);
     214extern ipcarg_t ipc_answer_slow(ipc_callid_t callid, ipcarg_t retval,
     215    ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5);
    200216
    201217/*
     
    245261    ipcarg_t arg1);
    246262extern int ipc_data_send(int phoneid, void *src, size_t size);
    247 extern int ipc_data_receive(ipc_callid_t *callid, ipc_call_t *call, void **dst,
    248     size_t *size);
    249 extern ipcarg_t ipc_data_deliver(ipc_callid_t callid, ipc_call_t *call,
    250     void *dst, size_t size);
     263extern int ipc_data_receive(ipc_callid_t *callid, void **dst, size_t *size);
     264extern ipcarg_t ipc_data_deliver(ipc_callid_t callid, void *dst, size_t size);
    251265
    252266#endif
Note: See TracChangeset for help on using the changeset viewer.