Changeset 06502f7d in mainline


Ignore:
Timestamp:
2006-03-14T09:31:06Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
df50cf6
Parents:
a19bdf8
Message:

Added extended syscalls to ipc to support more arguments.

Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • init/init.c

    ra19bdf8 r06502f7d  
    2929#include "version.h"
    3030#include <ipc.h>
     31#include <ns.h>
    3132
    3233int main(int argc, char *argv[])
    3334{
    34         ipc_data_t ipcdata;
    35 
    3635        version_print();
    3736
    38         ipc_call_sync(0, 1, 2, &ipcdata);
     37        ipc_call_sync_2(PHONE_NS, NS_PING, 2, 0, 0, 0);
    3938       
    4039        return 0;
  • libipc/Makefile

    ra19bdf8 r06502f7d  
    5555
    5656clean:
    57         -rm -f libipcc.a Makefile.depend
     57        -rm -f libipc.a Makefile.depend
    5858        find generic/ -name '*.o' -follow -exec rm \{\} \;
    5959
  • libipc/generic/ipc.c

    ra19bdf8 r06502f7d  
    3030#include <libc.h>
    3131
    32 int ipc_call_sync(int phoneid, int arg1, int arg2, ipc_data_t *resdata)
     32int ipc_call_sync(int phoneid, sysarg_t method, sysarg_t arg1,
     33                  sysarg_t *result)
    3334{
    34         return __SYSCALL4(SYS_IPC_CALL_SYNC, phoneid, arg1, arg2,
    35                           (sysarg_t)resdata);
     35        ipc_data_t resdata;
     36        int callres;
     37       
     38        callres = __SYSCALL4(SYS_IPC_CALL_SYNC, phoneid, method, arg1,
     39                             (sysarg_t)&resdata);
     40        if (callres)
     41                return callres;
     42        if (result)
     43                *result = IPC_GET_ARG1(resdata);
     44        return IPC_GET_RETVAL(resdata);
    3645}
    3746
    38 /*
    39 int ipc_call_async()
     47int ipc_call_sync_3(int phoneid, sysarg_t method, sysarg_t arg1,
     48                    sysarg_t arg2, sysarg_t arg3,
     49                    sysarg_t *result1, sysarg_t *result2, sysarg_t *result3)
    4050{
     51        ipc_data_t data;
     52        int callres;
     53
     54        IPC_SET_METHOD(data, method);
     55        IPC_SET_ARG1(data, arg1);
     56        IPC_SET_ARG2(data, arg2);
     57        IPC_SET_ARG3(data, arg3);
     58
     59        callres = __SYSCALL2(SYS_IPC_CALL_SYNC_MEDIUM, phoneid, (sysarg_t)&data);
     60        if (callres)
     61                return callres;
     62
     63        if (result1)
     64                *result1 = IPC_GET_ARG1(data);
     65        if (result2)
     66                *result2 = IPC_GET_ARG2(data);
     67        if (result3)
     68                *result3 = IPC_GET_ARG3(data);
     69        return IPC_GET_RETVAL(data);
     70}
     71
     72/** Send asynchronous message
     73 *
     74 * - if fatal error, call callback handler with proper error code
     75 * - if message cannot be temporarily sent, add to queue
     76 */
     77void ipc_call_async_2(int phoneid, sysarg_t method, sysarg_t arg1,
     78                      sysarg_t arg2,
     79                      ipc_async_callback_t callback)
     80{
     81        ipc_callid_t callid;
     82        ipc_data_t data; /* Data storage for saving calls */
     83
     84        callid = __SYSCALL4(SYS_IPC_CALL_ASYNC, phoneid, method, arg1, arg2);
     85        if (callid == IPC_CALLRET_FATAL) {
     86                /* Call asynchronous handler with error code */
     87                IPC_SET_RETVAL(data, IPC_CALLRET_FATAL);
     88                callback(&data);
     89                return;
     90        }
     91        if (callid == IPC_CALLRET_TEMPORARY) {
     92                /* Add asynchronous call to queue of non-dispatched async calls */
     93                IPC_SET_METHOD(data, method);
     94                IPC_SET_ARG1(data, arg1);
     95                IPC_SET_ARG2(data, arg2);
     96               
     97                return;
     98        }
     99        /* Add callid to list of dispatched calls */
    41100       
    42101}
    43102
    44 int ipc_answer()
     103
     104/** Send answer to a received call */
     105void ipc_answer(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
     106                sysarg_t arg2)
    45107{
     108        __SYSCALL4(SYS_IPC_ANSWER, callid, retval, arg1, arg2);
    46109}
    47 */
     110
    48111
    49112/** Call syscall function sys_ipc_wait_for_call */
     
    61124        ipc_callid_t callid;
    62125
    63         callid = _ipc_wait_for_call(data, flags);
    64         /* TODO: Handle async replies etc.. */
     126        do {
     127                /* Try to dispatch non-dispatched async calls */
     128                callid = _ipc_wait_for_call(data, flags);
     129                if (callid & IPC_CALLID_ANSWERED) {
     130                        /* TODO: Call async answer handler */
     131                }
     132        } while (callid & IPC_CALLID_ANSWERED);
    65133        return callid;
    66134}
  • libipc/include/ipc.h

    ra19bdf8 r06502f7d  
    3636typedef sysarg_t ipc_callid_t;
    3737
     38typedef void (* ipc_async_callback_t)(ipc_data_t *data);
    3839
    39 extern int ipc_call_sync(int phoneid, int arg1, int arg2, ipc_data_t *resdata);
    40 extern int ipc_wait_for_call(ipc_data_t *data, int flags);
     40#define ipc_call_sync_2(phoneid, method, arg1, arg2, res1, res2) ipc_call_sync_3((phoneid), (method), (arg1), (arg2), 0, (res1), (res2), 0)
     41extern int ipc_call_sync_3(int phoneid, sysarg_t method, sysarg_t arg1,
     42                           sysarg_t arg2, sysarg_t arg3,
     43                           sysarg_t *result1, sysarg_t *result2,
     44                           sysarg_t *result3);
    4145
    4246
     47extern int ipc_call_sync(int phoneid, sysarg_t method, sysarg_t arg1,
     48                         sysarg_t *result);
     49extern int ipc_wait_for_call(ipc_data_t *data, int flags);
     50extern void ipc_answer(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
     51                       sysarg_t arg2);
     52
     53#define ipc_call_async(phoneid,method,arg1,callback) (ipc_call_async_2(phoneid, method, arg1, 0, callback))
     54void ipc_call_async_2(int phoneid, sysarg_t method, sysarg_t arg1,
     55                      sysarg_t arg2,
     56                      ipc_async_callback_t callback);
     57
    4358#endif
Note: See TracChangeset for help on using the changeset viewer.