Changeset 4c61e60 in mainline


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

Adapt userspace API to conform to kernel api.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • init/init.c

    r7048773 r4c61e60  
    113113        int retval;
    114114
     115        printf("Pinging\n");
    115116        retval = ipc_call_sync(PHONE_NS, NS_PING, 0xbeef,&result);
    116117        printf("Retval: %d - received: %P\n", retval, result);
    117118}
    118119
    119 static void got_answer(void *private, int retval, ipc_data_t *data)
     120static void got_answer(void *private, int retval, ipc_call_t *data)
    120121{
    121122        printf("Retval: %d...%s...%zX, %zX\n", retval, private,
     
    149150
    150151
    151 static void got_answer_2(void *private, int retval, ipc_data_t *data)
     152static void got_answer_2(void *private, int retval, ipc_call_t *data)
    152153{
    153154        printf("Pong\n");
     
    156157{
    157158        int res;
    158         unsigned long long taskid;
     159        ipcarg_t phonead;
    159160        ipc_callid_t callid;
    160161        ipc_call_t data;
     
    162163
    163164        printf("Asking 0 to connect to me...\n");
    164         res = ipc_connect_to_me(0, 1, 2, &taskid);
    165         printf("Result: %d - taskid: %llu\n", res, taskid);
     165        res = ipc_connect_to_me(0, 1, 2, &phonead);
     166        printf("Result: %d - phonead: %llu\n", res, phonead);
    166167        for (i=0; i < 100; i++) {
    167168                printf("----------------\n");
     
    179180        int res;
    180181        ipcarg_t result;
     182        int phoneid;
    181183
    182184        printf("Starting connect...\n");
     
    253255//      test_connection_ipc();
    254256//      test_hangup();
    255         test_slam();
    256 
    257 //      if ((tid = thread_create(utest, NULL, "utest") != -1)) {
    258 //              printf("Created thread tid=%d\n", tid);
    259 //      }
     257//      test_slam();
     258
     259        if ((tid = thread_create(utest, NULL, "utest") != -1)) {
     260                printf("Created thread tid=%d\n", tid);
     261        }
    260262        return 0;
    261263}
  • libipc/generic/ipc.c

    r7048773 r4c61e60  
    4747                ipc_callid_t callid;
    4848                struct {
     49                        ipc_call_t data;
    4950                        int phoneid;
    50                         ipc_data_t data;
    5151                } msg;
    5252        }u;
     
    5959                  ipcarg_t *result)
    6060{
    61         ipc_data_t resdata;
     61        ipc_call_t resdata;
    6262        int callres;
    6363       
     
    7575                    ipcarg_t *result1, ipcarg_t *result2, ipcarg_t *result3)
    7676{
    77         ipc_data_t data;
     77        ipc_call_t data;
    7878        int callres;
    7979
     
    9898
    9999/** Syscall to send asynchronous message */
    100 static  ipc_callid_t _ipc_call_async(int phoneid, ipc_data_t *data)
     100static  ipc_callid_t _ipc_call_async(int phoneid, ipc_call_t *data)
    101101{
    102102        return __SYSCALL2(SYS_IPC_CALL_ASYNC, phoneid, (sysarg_t)data);
     
    153153{
    154154        __SYSCALL4(SYS_IPC_ANSWER_FAST, callid, retval, arg1, arg2);
    155 }
    156 
    157 
    158 /** Call syscall function sys_ipc_wait_for_call */
    159 static inline ipc_callid_t _ipc_wait_for_call(ipc_call_t *call, int flags)
    160 {
    161         return __SYSCALL3(SYS_IPC_WAIT, (sysarg_t)&call->data,
    162                           (sysarg_t)&call->taskid, flags);
    163155}
    164156
     
    194186 * @param callid Callid (with first bit set) of the answered call
    195187 */
    196 static void handle_answer(ipc_callid_t callid, ipc_data_t *data)
     188static void handle_answer(ipc_callid_t callid, ipc_call_t *data)
    197189{
    198190        link_t *item;
     
    230222                try_dispatch_queued_calls();
    231223
    232                 callid = _ipc_wait_for_call(call, flags);
     224                callid = __SYSCALL2(SYS_IPC_WAIT, (sysarg_t)call, flags);
    233225                /* Handle received answers */
    234226                if (callid & IPC_CALLID_ANSWERED)
    235                         handle_answer(callid, &call->data);
     227                        handle_answer(callid, call);
    236228        } while (callid & IPC_CALLID_ANSWERED);
    237229
     
    239231}
    240232
    241 /** Ask destination to do a callback connection */
    242 int ipc_connect_to_me(int phoneid, int arg1, int arg2,
    243                       unsigned long long *taskid)
    244 {
    245         return __SYSCALL4(SYS_IPC_CONNECT_TO_ME, phoneid, arg1, arg2,
    246                           (sysarg_t) taskid);
    247 }
    248 
    249 /** Ask through phone for a new connection to some service */
     233/** Ask destination to do a callback connection
     234 *
     235 * @return 0 - OK, error code
     236 */
     237int ipc_connect_to_me(int phoneid, int arg1, int arg2, ipcarg_t *phone)
     238{
     239        return ipc_call_sync_3(phoneid, IPC_M_CONNECT_TO_ME, arg1,
     240                               arg2, 0, 0, 0, phone);
     241}
     242
     243/** Ask through phone for a new connection to some service
     244 *
     245 * @return new phoneid - OK, error code
     246 */
    250247int ipc_connect_me_to(int phoneid, int arg1, int arg2)
    251248{
    252         return __SYSCALL3(SYS_IPC_CONNECT_ME_TO, phoneid, arg1, arg2);
     249        int newphid;
     250        int res;
     251
     252        res =  ipc_call_sync_3(phoneid, IPC_M_CONNECT_ME_TO, arg1,
     253                               arg2, 0, 0, 0, &newphid);
     254        if (res)
     255                return res;
     256        return newphid;
    253257}
    254258
  • libipc/include/ipc.h

    r7048773 r4c61e60  
    3636typedef sysarg_t ipcarg_t;
    3737typedef struct {
    38         sysarg_t args[IPC_CALL_LEN];
    39         sysarg_t phoneid;
    40 } ipc_data_t ;
    41 typedef struct {
    42         unsigned long long taskid;
    43         ipc_data_t data;
    44 }ipc_call_t;
     38        ipcarg_t args[IPC_CALL_LEN];
     39        ipcarg_t phoneid;
     40} ipc_call_t ;
    4541typedef sysarg_t ipc_callid_t;
    4642
    47 typedef void (* ipc_async_callback_t)(void *private,
    48                                       int retval,
    49                                       ipc_data_t *data);
     43typedef void (* ipc_async_callback_t)(void *private, int retval,
     44                                      ipc_call_t *data);
    5045
    5146#define ipc_call_sync_2(phoneid, method, arg1, arg2, res1, res2) ipc_call_sync_3((phoneid), (method), (arg1), (arg2), 0, (res1), (res2), 0)
     
    6661                      ipcarg_t arg2, void *private,
    6762                      ipc_async_callback_t callback);
    68 int ipc_connect_to_me(int phoneid, int arg1, int arg2,
    69                       unsigned long long *taskid);
     63int ipc_connect_to_me(int phoneid, int arg1, int arg2, ipcarg_t *phone);
    7064int ipc_connect_me_to(int phoneid, int arg1, int arg2);
    7165int ipc_hangup(int phoneid);
  • ns/ns.c

    r7048773 r4c61e60  
    1717        printf("NS:Name service started.\n");
    1818        while (1) {
    19                 call.taskid = -1;
    2019                callid = ipc_wait_for_call(&call, 0);
    21                 printf("NS:Call task=%llX,phone=%lX..",
    22                        call.taskid,call.data.phoneid);
    23                 switch (IPC_GET_METHOD(call.data)) {
     20                printf("NS:Call phone=%lX..", call.phoneid);
     21                switch (IPC_GET_METHOD(call)) {
    2422                case IPC_M_PHONE_HUNGUP:
    2523                        printf("Phone hung up.\n");
     
    2725                        break;
    2826                case IPC_M_CONNECT_TO_ME:
    29                         printf("Somebody connecting phid=%zd.\n", IPC_GET_ARG3(call.data));
    30                         service = IPC_GET_ARG3(call.data);
     27                        printf("Somebody connecting phid=%zd.\n", IPC_GET_ARG3(call));
     28                        service = IPC_GET_ARG3(call);
    3129                        retval = 0;
    3230                        break;
    3331                case IPC_M_CONNECT_ME_TO:
    34                         printf("Connectmeto: %zd\n",
    35                                IPC_GET_ARG1(call.data));
     32                        printf("Connectme(%P)to: %zd\n",
     33                               IPC_GET_ARG3(call), IPC_GET_ARG1(call));
    3634                        retval = 0;
    3735                        break;
    3836                case NS_PING:
    39                         printf("Ping...%P %P\n", IPC_GET_ARG1(call.data),
    40                                IPC_GET_ARG2(call.data));
     37                        printf("Ping...%P %P\n", IPC_GET_ARG1(call),
     38                               IPC_GET_ARG2(call));
    4139                        retval = 0;
    4240                        arg1 = 0xdead;
     
    5351                        break;
    5452                default:
    55                         printf("Unknown method: %zd\n", IPC_GET_METHOD(call.data));
     53                        printf("Unknown method: %zd\n", IPC_GET_METHOD(call));
    5654                        retval = ENOENT;
    5755                        break;
Note: See TracChangeset for help on using the changeset viewer.