Changeset 2e51969 in mainline


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.

Files:
10 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/ipc/sysipc.h

    re0bc7fc r2e51969  
    4141
    4242unative_t sys_ipc_call_sync_fast(unative_t phoneid, unative_t method,
    43     unative_t arg1, ipc_data_t *data);
    44 unative_t sys_ipc_call_sync(unative_t phoneid, ipc_data_t *question,
     43    unative_t arg1, unative_t arg2, unative_t arg3, ipc_data_t *data);
     44unative_t sys_ipc_call_sync_slow(unative_t phoneid, ipc_data_t *question,
    4545    ipc_data_t *reply);
    4646unative_t sys_ipc_call_async_fast(unative_t phoneid, unative_t method,
  • kernel/generic/include/syscall/syscall.h

    re0bc7fc r2e51969  
    4949        SYS_AS_AREA_DESTROY,
    5050        SYS_IPC_CALL_SYNC_FAST,
    51         SYS_IPC_CALL_SYNC,
     51        SYS_IPC_CALL_SYNC_SLOW,
    5252        SYS_IPC_CALL_ASYNC_FAST,
    5353        SYS_IPC_CALL_ASYNC,
  • kernel/generic/src/ipc/sysipc.c

    re0bc7fc r2e51969  
    349349/** Make a fast call over IPC, wait for reply and return to user.
    350350 *
    351  * This function can handle only one argument of payload, but is faster than
    352  * the generic function (i.e. sys_ipc_call_sync()).
     351 * This function can handle only three arguments of payload, but is faster than
     352 * the generic function (i.e. sys_ipc_call_sync_slow()).
    353353 *
    354354 * @param phoneid       Phone handle for the call.
    355355 * @param method        Method of the call.
    356356 * @param arg1          Service-defined payload argument.
     357 * @param arg2          Service-defined payload argument.
     358 * @param arg3          Service-defined payload argument.
    357359 * @param data          Address of userspace structure where the reply call will
    358360 *                      be stored.
     
    362364 */
    363365unative_t sys_ipc_call_sync_fast(unative_t phoneid, unative_t method,
    364     unative_t arg1, ipc_data_t *data)
     366    unative_t arg1, unative_t arg2, unative_t arg3, ipc_data_t *data)
    365367{
    366368        call_t call;
     
    373375        IPC_SET_METHOD(call.data, method);
    374376        IPC_SET_ARG1(call.data, arg1);
     377        IPC_SET_ARG2(call.data, arg2);
     378        IPC_SET_ARG3(call.data, arg3);
    375379
    376380        if (!(res = request_preprocess(&call))) {
     
    394398 * @return              Zero on success or an error code.
    395399 */
    396 unative_t sys_ipc_call_sync(unative_t phoneid, ipc_data_t *question,
     400unative_t sys_ipc_call_sync_slow(unative_t phoneid, ipc_data_t *question,
    397401    ipc_data_t *reply)
    398402{
  • kernel/generic/src/syscall/syscall.c

    re0bc7fc r2e51969  
    134134        /* IPC related syscalls. */
    135135        (syshandler_t) sys_ipc_call_sync_fast,
    136         (syshandler_t) sys_ipc_call_sync,
     136        (syshandler_t) sys_ipc_call_sync_slow,
    137137        (syshandler_t) sys_ipc_call_async_fast,
    138138        (syshandler_t) sys_ipc_call_async,
  • uspace/app/klog/klog.c

    re0bc7fc r2e51969  
    6464       
    6565        mapping = as_get_mappable_page(PAGE_SIZE);
    66         res = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_RECV,
    67                               (sysarg_t) mapping, PAGE_SIZE, SERVICE_MEM_KLOG,
    68                               NULL, NULL, NULL);
     66        res = ipc_call_sync_3_0(PHONE_NS, IPC_M_AS_AREA_RECV,
     67            (sysarg_t) mapping, PAGE_SIZE, SERVICE_MEM_KLOG);
    6968        if (res) {
    7069                printf("Failed to initialize klog memarea\n");
  • uspace/app/tester/ipc/send_sync.c

    re0bc7fc r2e51969  
    3030#include <unistd.h>
    3131#include "../tester.h"
     32#include <ipc/ipc.h>
    3233
    3334char * test_send_sync(bool quiet)
     
    4546       
    4647        printf("Sending msg...");
    47         res = ipc_call_sync_2(phoneid, 2000, 0, 0, NULL, NULL);
     48        res = ipc_call_sync_0_0(phoneid, 2000);
    4849        printf("done: %d\n", res);
    4950       
  • 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
  • uspace/lib/libc/generic/time.c

    re0bc7fc r2e51969  
    142142                mapping = as_get_mappable_page(PAGE_SIZE);
    143143                /* Get the mapping of kernel clock */
    144                 res = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_RECV,
     144                res = ipc_call_sync_3_2(PHONE_NS, IPC_M_AS_AREA_RECV,
    145145                    (sysarg_t) mapping, PAGE_SIZE, SERVICE_MEM_REALTIME, NULL,
    146                     &rights, NULL);
     146                    &rights);
    147147                if (res) {
    148148                        printf("Failed to initialize timeofday memarea\n");
  • uspace/lib/libc/include/ipc/ipc.h

    re0bc7fc r2e51969  
    5252    ipc_call_t *data);
    5353
    54 #define ipc_call_sync_2(phoneid, method, arg1, arg2, res1, res2) \
    55         ipc_call_sync_3((phoneid), (method), (arg1), (arg2), 0, (res1), \
    56             (res2), 0)
    57 extern int ipc_call_sync_3(int phoneid, ipcarg_t method, ipcarg_t arg1,
     54/*
     55 * User-friendly wrappers for ipc_call_sync_fast() and ipc_call_sync_slow().
     56 * They are in the form ipc_call_sync_m_n(), where m denotes the number of
     57 * arguments of payload and n denotes number of return values. Whenever
     58 * possible, the fast version is used.
     59 */
     60#define ipc_call_sync_0_0(phoneid, method) \
     61    ipc_call_sync_fast((phoneid), (method), 0, 0, 0, 0, 0, 0, 0, 0)
     62#define ipc_call_sync_0_1(phoneid, method, res1) \
     63    ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), 0, 0, 0, 0)
     64#define ipc_call_sync_0_2(phoneid, method, res1, res2) \
     65    ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), (res2), 0, 0, 0)
     66#define ipc_call_sync_0_3(phoneid, method, res1, res2, res3) \
     67    ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), (res2), (res3), \
     68        0, 0)
     69#define ipc_call_sync_0_4(phoneid, method, res1, res2, res3, res4) \
     70    ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), (res2), (res3), \
     71        (res4), 0)
     72#define ipc_call_sync_0_5(phoneid, method, res1, res2, res3, res4, res5) \
     73    ipc_call_sync_fast((phoneid), (method), 0, 0, 0, (res1), (res2), (res3), \
     74        (res4), (res5))
     75#define ipc_call_sync_1_0(phoneid, method, arg1) \
     76    ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, 0, 0, 0, 0, 0)
     77#define ipc_call_sync_1_1(phoneid, method, arg1, res1) \
     78    ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), 0, 0, 0, 0)
     79#define ipc_call_sync_1_2(phoneid, method, arg1, res1, res2) \
     80    ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), (res2), 0, \
     81        0, 0)
     82#define ipc_call_sync_1_3(phoneid, method, arg1, res1, res2, res3) \
     83    ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), (res2), \
     84        (res3), 0, 0)
     85#define ipc_call_sync_1_4(phoneid, method, arg1, res1, res2, res3, res4) \
     86    ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), (res2), \
     87        (res3), (res4), 0)
     88#define ipc_call_sync_1_5(phoneid, method, arg1, res1, res2, res3, res4, \
     89    res5) \
     90        ipc_call_sync_fast((phoneid), (method), (arg1), 0, 0, (res1), (res2), \
     91            (res3), (res4), (res5))
     92#define ipc_call_sync_2_0(phoneid, method, arg1, arg2) \
     93    ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, 0, 0, 0, \
     94        0, 0)
     95#define ipc_call_sync_2_1(phoneid, method, arg1, arg2, res1) \
     96    ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), 0, 0, \
     97        0, 0)
     98#define ipc_call_sync_2_2(phoneid, method, arg1, arg2, res1, res2) \
     99    ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), \
     100        (res2), 0, 0, 0)
     101#define ipc_call_sync_2_3(phoneid, method, arg1, arg2, res1, res2, res3) \
     102    ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), \
     103        (res2), (res3), 0, 0)
     104#define ipc_call_sync_2_4(phoneid, method, arg1, arg2, res1, res2, res3, \
     105    res4) \
     106        ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), \
     107            (res2), (res3), (res4), 0)
     108#define ipc_call_sync_2_5(phoneid, method, arg1, arg2, res1, res2, res3, \
     109    res4, res5)\
     110        ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), 0, (res1), \
     111            (res2), (res3), (res4), (res5))
     112#define ipc_call_sync_3_0(phoneid, method, arg1, arg2, arg3) \
     113    ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), 0, 0, 0, \
     114    0, 0)
     115#define ipc_call_sync_3_1(phoneid, method, arg1, arg2, arg3, res1) \
     116    ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), (res1), \
     117        0, 0, 0, 0)
     118#define ipc_call_sync_3_2(phoneid, method, arg1, arg2, arg3, res1, res2) \
     119    ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), (res1), \
     120        (res2), 0, 0, 0)
     121#define ipc_call_sync_3_3(phoneid, method, arg1, arg2, arg3, res1, res2, \
     122    res3) \
     123        ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), \
     124            (res1), (res2), (res3), 0, 0)
     125#define ipc_call_sync_3_4(phoneid, method, arg1, arg2, arg3, res1, res2, \
     126    res3, res4) \
     127        ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), \
     128            (res1), (res2), (res3), (res4), 0)
     129#define ipc_call_sync_3_5(phoneid, method, arg1, arg2, arg3, res1, res2, \
     130    res3, res4, res5) \
     131        ipc_call_sync_fast((phoneid), (method), (arg1), (arg2), (arg3), \
     132            (res1), (res2), (res3), (res4), (res5))
     133#define ipc_call_sync_4_0(phoneid, method, arg1, arg2, arg3, arg4) \
     134    ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
     135        0, 0, 0, 0, 0)
     136#define ipc_call_sync_4_1(phoneid, method, arg1, arg2, arg3, arg4, res1) \
     137    ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
     138        (res1), 0, 0, 0, 0)
     139#define ipc_call_sync_4_2(phoneid, method, arg1, arg2, arg3, arg4, res1, res2) \
     140    ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
     141        (res1), (res2), 0, 0, 0)
     142#define ipc_call_sync_4_3(phoneid, method, arg1, arg2, arg3, arg4, res1, res2, \
     143    res3) \
     144        ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
     145            (arg4), (res1), (res2), (res3), 0, 0)
     146#define ipc_call_sync_4_4(phoneid, method, arg1, arg2, arg3, arg4, res1, res2, \
     147    res3, res4) \
     148        ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
     149            (arg4), (res1), (res2), (res3), (res4), 0)
     150#define ipc_call_sync_4_5(phoneid, method, arg1, arg2, arg3, arg4, res1, res2, \
     151    res3, res4, res5) \
     152        ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
     153            (arg4), (res1), (res2), (res3), (res4), (res5))
     154#define ipc_call_sync_5_0(phoneid, method, arg1, arg2, arg3, arg4, arg5) \
     155    ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
     156        (arg5), 0, 0, 0, 0, 0)
     157#define ipc_call_sync_5_1(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1) \
     158    ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), (arg4), \
     159        (arg5), (res1), 0, 0, 0, 0)
     160#define ipc_call_sync_5_2(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1, \
     161    res2) \
     162        ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
     163            (arg4), (arg5), (res1), (res2), 0, 0, 0)
     164#define ipc_call_sync_5_3(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1, \
     165    res2, res3) \
     166        ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
     167            (arg4), (arg5), (res1), (res2), (res3), 0, 0)
     168#define ipc_call_sync_5_4(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1, \
     169    res2, res3, res4) \
     170        ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
     171            (arg4), (arg5), (res1), (res2), (res3), (res4), 0)
     172#define ipc_call_sync_5_5(phoneid, method, arg1, arg2, arg3, arg4, arg5, res1, \
     173    res2, res3, res4, res5) \
     174        ipc_call_sync_slow((phoneid), (method), (arg1), (arg2), (arg3), \
     175            (arg4), (arg5), (res1), (res2), (res3), (res4), (res5))
     176
     177extern int ipc_call_sync_fast(int phoneid, ipcarg_t method, ipcarg_t arg1,
    58178    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t *result1, ipcarg_t *result2,
    59     ipcarg_t *result3);
    60 
    61 extern int ipc_call_sync(int phoneid, ipcarg_t method, ipcarg_t arg1,
    62     ipcarg_t *result);
     179    ipcarg_t *result3, ipcarg_t *result4, ipcarg_t *result5);
     180
     181extern int ipc_call_sync_slow(int phoneid, ipcarg_t method, ipcarg_t arg1,
     182    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5,
     183    ipcarg_t *result1, ipcarg_t *result2, ipcarg_t *result3, ipcarg_t *result4,
     184    ipcarg_t *result5);
     185
    63186
    64187extern ipc_callid_t ipc_wait_cycle(ipc_call_t *call, uint32_t usec, int flags);
  • uspace/srv/fs/fat/fat.c

    re0bc7fc r2e51969  
    158158         * Request sharing the Path Lookup Buffer with VFS.
    159159         */
    160         rc = ipc_call_sync_3(vfs_phone, IPC_M_AS_AREA_RECV, (ipcarg_t) plb_ro,
    161             PLB_SIZE, 0, NULL, NULL, NULL);
     160        rc = ipc_call_sync_2_0(vfs_phone, IPC_M_AS_AREA_RECV, (ipcarg_t) plb_ro,
     161            PLB_SIZE);
    162162        if (rc) {
    163163                async_wait_for(req, NULL);
Note: See TracChangeset for help on using the changeset viewer.