Ignore:
File:
1 edited

Legend:

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

    r228e490 r63f8966  
    3838 */
    3939/** @file
    40  */
     40 */ 
    4141
    4242#include <ipc/ipc.h>
     
    104104 */
    105105int
    106 ipc_call_sync_fast(int phoneid, sysarg_t method, sysarg_t arg1, sysarg_t arg2,
    107     sysarg_t arg3, sysarg_t *result1, sysarg_t *result2, sysarg_t *result3,
    108     sysarg_t *result4, sysarg_t *result5)
     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)
    109109{
    110110        ipc_call_t resdata;
     
    131131/** Make a synchronous call transmitting 5 arguments of payload.
    132132 *
    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  *
     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.
    149148 */
    150149int
    151 ipc_call_sync_slow(int phoneid, sysarg_t imethod, sysarg_t arg1, sysarg_t arg2,
    152     sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, sysarg_t *result1,
    153     sysarg_t *result2, sysarg_t *result3, sysarg_t *result4, sysarg_t *result5)
     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)
    154153{
    155154        ipc_call_t data;
    156        
    157         IPC_SET_IMETHOD(data, imethod);
     155        int callres;
     156
     157        IPC_SET_METHOD(data, method);
    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         int callres = __SYSCALL3(SYS_IPC_CALL_SYNC_SLOW, phoneid,
    165             (sysarg_t) &data, (sysarg_t) &data);
     163
     164        callres = __SYSCALL3(SYS_IPC_CALL_SYNC_SLOW, phoneid, (sysarg_t) &data,
     165            (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.
    189  *
     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.
    190189 */
    191190static ipc_callid_t _ipc_call_async(int phoneid, ipc_call_t *data)
     
    278277 * If the call cannot be temporarily made, queue it.
    279278 *
    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  */
    293 void ipc_call_async_fast(int phoneid, sysarg_t imethod, sysarg_t arg1,
    294     sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, void *private,
     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 */
     291void ipc_call_async_fast(int phoneid, ipcarg_t method, ipcarg_t arg1,
     292    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, void *private,
    295293    ipc_async_callback_t callback, int can_preempt)
    296294{
    297295        async_call_t *call = NULL;
    298        
     296        ipc_callid_t callid;
     297
    299298        if (callback) {
    300299                call = ipc_prepare_async(private, callback);
     
    302301                        return;
    303302        }
    304        
     303
    305304        /*
    306305         * We need to make sure that we get callid before another thread
     
    308307         */
    309308        futex_down(&ipc_futex);
    310         ipc_callid_t callid = __SYSCALL6(SYS_IPC_CALL_ASYNC_FAST, phoneid,
    311             imethod, arg1, arg2, arg3, arg4);
    312        
     309        callid = __SYSCALL6(SYS_IPC_CALL_ASYNC_FAST, phoneid, method, arg1,
     310            arg2, arg3, arg4);
     311
    313312        if (callid == (ipc_callid_t) IPC_CALLRET_TEMPORARY) {
    314313                if (!call) {
     
    317316                                return;
    318317                }
    319                 IPC_SET_IMETHOD(call->u.msg.data, imethod);
     318                IPC_SET_METHOD(call->u.msg.data, method);
    320319                IPC_SET_ARG1(call->u.msg.data, arg1);
    321320                IPC_SET_ARG2(call->u.msg.data, arg2);
     
    338337 * If the call cannot be temporarily made, queue it.
    339338 *
    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  */
    354 void ipc_call_async_slow(int phoneid, sysarg_t imethod, sysarg_t arg1,
    355     sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, void *private,
     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 */
     353void ipc_call_async_slow(int phoneid, ipcarg_t method, ipcarg_t arg1,
     354    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5, void *private,
    356355    ipc_async_callback_t callback, int can_preempt)
    357356{
     
    363362                return;
    364363
    365         IPC_SET_IMETHOD(call->u.msg.data, imethod);
     364        IPC_SET_METHOD(call->u.msg.data, method);
    366365        IPC_SET_ARG1(call->u.msg.data, arg1);
    367366        IPC_SET_ARG2(call->u.msg.data, arg2);
     
    394393 * @return              Zero on success or a value from @ref errno.h on failure.
    395394 */
    396 sysarg_t ipc_answer_fast(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
    397     sysarg_t arg2, sysarg_t arg3, sysarg_t arg4)
     395ipcarg_t ipc_answer_fast(ipc_callid_t callid, ipcarg_t retval, ipcarg_t arg1,
     396    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4)
    398397{
    399398        return __SYSCALL6(SYS_IPC_ANSWER_FAST, callid, retval, arg1, arg2, arg3,
     
    413412 * @return              Zero on success or a value from @ref errno.h on failure.
    414413 */
    415 sysarg_t ipc_answer_slow(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
    416     sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5)
     414ipcarg_t ipc_answer_slow(ipc_callid_t callid, ipcarg_t retval, ipcarg_t arg1,
     415    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5)
    417416{
    418417        ipc_call_t data;
     
    586585 */
    587586int ipc_connect_to_me(int phoneid, int arg1, int arg2, int arg3,
    588     sysarg_t *phonehash)
     587    ipcarg_t *phonehash)
    589588{
    590589        return ipc_call_sync_3_5(phoneid, IPC_M_CONNECT_TO_ME, arg1, arg2,
     
    603602int ipc_connect_me_to(int phoneid, int arg1, int arg2, int arg3)
    604603{
    605         sysarg_t newphid;
     604        ipcarg_t newphid;
    606605        int res;
    607606
     
    627626int ipc_connect_me_to_blocking(int phoneid, int arg1, int arg2, int arg3)
    628627{
    629         sysarg_t newphid;
     628        ipcarg_t newphid;
    630629        int res;
    631630
     
    677676/** Forward a received call to another destination.
    678677 *
    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.
     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.
    687686 *
    688687 * For non-system methods, the old method, arg1 and arg2 are rewritten by the
     
    691690 * methods are forwarded verbatim.
    692691 */
    693 int ipc_forward_fast(ipc_callid_t callid, int phoneid, int imethod,
    694     sysarg_t arg1, sysarg_t arg2, int mode)
    695 {
    696         return __SYSCALL6(SYS_IPC_FORWARD_FAST, callid, phoneid, imethod, arg1,
     692int ipc_forward_fast(ipc_callid_t callid, int phoneid, int method,
     693    ipcarg_t arg1, ipcarg_t arg2, int mode)
     694{
     695        return __SYSCALL6(SYS_IPC_FORWARD_FAST, callid, phoneid, method, arg1,
    697696            arg2, mode);
    698697}
    699698
    700699
    701 int ipc_forward_slow(ipc_callid_t callid, int phoneid, int imethod,
    702     sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5,
     700int ipc_forward_slow(ipc_callid_t callid, int phoneid, int method,
     701    ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5,
    703702    int mode)
    704703{
    705704        ipc_call_t data;
    706        
    707         IPC_SET_IMETHOD(data, imethod);
     705
     706        IPC_SET_METHOD(data, method);
    708707        IPC_SET_ARG1(data, arg1);
    709708        IPC_SET_ARG2(data, arg2);
     
    711710        IPC_SET_ARG4(data, arg4);
    712711        IPC_SET_ARG5(data, arg5);
    713        
     712
    714713        return __SYSCALL4(SYS_IPC_FORWARD_SLOW, callid, phoneid, (sysarg_t) &data, mode);
    715714}
     
    726725 * @return              Zero on success or a negative error code from errno.h.
    727726 */
    728 int ipc_share_in_start(int phoneid, void *dst, size_t size, sysarg_t arg,
     727int ipc_share_in_start(int phoneid, void *dst, size_t size, ipcarg_t arg,
    729728    int *flags)
    730729{
    731730        sysarg_t tmp_flags = 0;
    732         int res = ipc_call_sync_3_2(phoneid, IPC_M_SHARE_IN, (sysarg_t) dst,
    733             (sysarg_t) size, arg, NULL, &tmp_flags);
     731        int res = ipc_call_sync_3_2(phoneid, IPC_M_SHARE_IN, (ipcarg_t) dst,
     732            (ipcarg_t) size, arg, NULL, &tmp_flags);
    734733       
    735734        if (flags)
     
    752751int ipc_share_in_finalize(ipc_callid_t callid, void *src, int flags)
    753752{
    754         return ipc_answer_2(callid, EOK, (sysarg_t) src, (sysarg_t) flags);
     753        return ipc_answer_2(callid, EOK, (ipcarg_t) src, (ipcarg_t) flags);
    755754}
    756755
     
    765764int ipc_share_out_start(int phoneid, void *src, int flags)
    766765{
    767         return ipc_call_sync_3_0(phoneid, IPC_M_SHARE_OUT, (sysarg_t) src, 0,
    768             (sysarg_t) flags);
     766        return ipc_call_sync_3_0(phoneid, IPC_M_SHARE_OUT, (ipcarg_t) src, 0,
     767            (ipcarg_t) flags);
    769768}
    770769
     
    781780int ipc_share_out_finalize(ipc_callid_t callid, void *dst)
    782781{
    783         return ipc_answer_1(callid, EOK, (sysarg_t) dst);
     782        return ipc_answer_1(callid, EOK, (ipcarg_t) dst);
    784783}
    785784
     
    795794int ipc_data_read_start(int phoneid, void *dst, size_t size)
    796795{
    797         return ipc_call_sync_2_0(phoneid, IPC_M_DATA_READ, (sysarg_t) dst,
    798             (sysarg_t) size);
     796        return ipc_call_sync_2_0(phoneid, IPC_M_DATA_READ, (ipcarg_t) dst,
     797            (ipcarg_t) size);
    799798}
    800799
     
    813812int ipc_data_read_finalize(ipc_callid_t callid, const void *src, size_t size)
    814813{
    815         return ipc_answer_2(callid, EOK, (sysarg_t) src, (sysarg_t) size);
     814        return ipc_answer_2(callid, EOK, (ipcarg_t) src, (ipcarg_t) size);
    816815}
    817816
     
    826825int ipc_data_write_start(int phoneid, const void *src, size_t size)
    827826{
    828         return ipc_call_sync_2_0(phoneid, IPC_M_DATA_WRITE, (sysarg_t) src,
    829             (sysarg_t) size);
     827        return ipc_call_sync_2_0(phoneid, IPC_M_DATA_WRITE, (ipcarg_t) src,
     828            (ipcarg_t) size);
    830829}
    831830
     
    843842int ipc_data_write_finalize(ipc_callid_t callid, void *dst, size_t size)
    844843{
    845         return ipc_answer_2(callid, EOK, (sysarg_t) dst, (sysarg_t) size);
    846 }
    847 
     844        return ipc_answer_2(callid, EOK, (ipcarg_t) dst, (ipcarg_t) size);
     845}
     846
     847#include <kernel/syscall/sysarg64.h>
    848848/** Connect to a task specified by id.
    849  *
    850849 */
    851850int ipc_connect_kbox(task_id_t id)
    852851{
    853 #ifdef __32_BITS__
    854         sysarg64_t arg = (sysarg64_t) id;
     852        sysarg64_t arg;
     853
     854        arg.value = (unsigned long long) id;
     855
    855856        return __SYSCALL1(SYS_IPC_CONNECT_KBOX, (sysarg_t) &arg);
    856 #endif
    857        
    858 #ifdef __64_BITS__
    859         return __SYSCALL1(SYS_IPC_CONNECT_KBOX, (sysarg_t) id);
    860 #endif
    861 }
    862 
     857}
     858 
    863859/** @}
    864860 */
Note: See TracChangeset for help on using the changeset viewer.