Changeset 7048773 in mainline


Ignore:
Timestamp:
2006-03-19T12:43:37Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4c61e60
Parents:
0a862b65
Message:

More IPC added syscall for hangup and some tests.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • init/init.c

    r0a862b65 r7048773  
    3535#include <thread.h>
    3636
     37int a;
     38
    3739extern void utest(void *arg);
    3840void utest(void *arg)
     
    170172                ipc_answer(callid, 0, 0, 0);
    171173        }
    172         callid = ipc_wait_for_call(&data, NULL);
     174//      callid = ipc_wait_for_call(&data, NULL);
    173175}
    174176
     
    183185        printf("pinging.\n");
    184186        res = ipc_call_sync(res, NS_PING, 0xbeef,&result);
    185         printf("Retval: %d - received: %zd\n", res, result);
     187        printf("Retval: %d - received: %X\n", res, result);
    186188       
     189}
     190
     191static void test_hangup(void)
     192{
     193        int phoneid;
     194        ipc_call_t data;
     195        ipc_callid_t callid;
     196        int i;
     197
     198        printf("Starting connect...\n");
     199        phoneid = ipc_connect_me_to(PHONE_NS, 10, 20);
     200        printf("Phoneid: %d, pinging\n", phoneid);
     201        ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2,
     202                         "Pong1", got_answer);
     203        printf("Hangin up\n");
     204        ipc_hangup(phoneid);
     205        printf("Connecting\n");
     206        phoneid = ipc_connect_me_to(PHONE_NS, 10, 20);
     207        printf("Newphid: %d\n", phoneid);
     208        for (i=0; i < 1000; i++) {
     209                if ((callid=ipc_wait_for_call(&data, IPC_WAIT_NONBLOCKING)))
     210                        printf("callid: %d\n");
     211        }
     212        printf("New new phoneid: %d\n", ipc_connect_me_to(PHONE_NS, 10, 20));
     213}
     214
     215static void test_slam(void)
     216{
     217        int i;
     218        ipc_call_t data;
     219        ipc_callid_t callid;
     220
     221        printf("ping");
     222        ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2,
     223                         "Pong1", got_answer);
     224        printf("slam");
     225        ipc_call_async_2(PHONE_NS, NS_HANGUP, 1, 0xbeefbee2,
     226                         "Hang", got_answer);
     227        printf("ping2\n");
     228        ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2,
     229                         "Ping2", got_answer);
     230       
     231        for (i=0; i < 1000; i++) {
     232                if ((callid=ipc_wait_for_call(&data, IPC_WAIT_NONBLOCKING)))
     233                        printf("callid: %d\n");
     234        }
     235        ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2,
     236                         "Pong1", got_answer);
     237        printf("Closing file\n");
     238        ipc_hangup(PHONE_NS);
     239        ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2,
     240                         "Pong1", got_answer);
     241        ipc_wait_for_call(&data, 0);
    187242}
    188243
     
    196251//      test_async_ipc();
    197252//      test_advanced_ipc();
    198         test_connection_ipc();
    199        
    200         if ((tid = thread_create(utest, NULL, "utest") != -1)) {
    201                 printf("Created thread tid=%d\n", tid);
    202         }
    203        
     253//      test_connection_ipc();
     254//      test_hangup();
     255        test_slam();
     256
     257//      if ((tid = thread_create(utest, NULL, "utest") != -1)) {
     258//              printf("Created thread tid=%d\n", tid);
     259//      }
    204260        return 0;
    205261}
  • libipc/generic/ipc.c

    r0a862b65 r7048773  
    253253}
    254254
     255/* Hang up specified phone */
     256int ipc_hangup(int phoneid)
     257{
     258        return __SYSCALL1(SYS_IPC_HANGUP, phoneid);
     259}
  • libipc/include/ipc.h

    r0a862b65 r7048773  
    3535
    3636typedef sysarg_t ipcarg_t;
    37 typedef sysarg_t ipc_data_t[IPC_CALL_LEN];
     37typedef struct {
     38        sysarg_t args[IPC_CALL_LEN];
     39        sysarg_t phoneid;
     40} ipc_data_t ;
    3841typedef struct {
    3942        unsigned long long taskid;
     
    6669                      unsigned long long *taskid);
    6770int ipc_connect_me_to(int phoneid, int arg1, int arg2);
     71int ipc_hangup(int phoneid);
    6872
    6973#endif
  • libipc/include/ns.h

    r0a862b65 r7048773  
    3232#define NS_PING      1024
    3333#define NS_PING_SVC  1025
     34#define NS_HANGUP    1026
    3435
    3536#endif
  • ns/ns.c

    r0a862b65 r7048773  
    1515        ipcarg_t retval, arg1, arg2;
    1616
    17         printf("Name service started.\n");
     17        printf("NS:Name service started.\n");
    1818        while (1) {
     19                call.taskid = -1;
    1920                callid = ipc_wait_for_call(&call, 0);
    20                 printf("Received call from: %P..%llX\n", &call.taskid,call.taskid);
     21                printf("NS:Call task=%llX,phone=%lX..",
     22                       call.taskid,call.data.phoneid);
    2123                switch (IPC_GET_METHOD(call.data)) {
    22                 case IPC_M_CONNECTTOME:
    23                         printf("Somebody wants to connect with phoneid %zd...accepting\n", IPC_GET_ARG3(call.data));
     24                case IPC_M_PHONE_HUNGUP:
     25                        printf("Phone hung up.\n");
     26                        retval = 0;
     27                        break;
     28                case IPC_M_CONNECT_TO_ME:
     29                        printf("Somebody connecting phid=%zd.\n", IPC_GET_ARG3(call.data));
    2430                        service = IPC_GET_ARG3(call.data);
    2531                        retval = 0;
    2632                        break;
    27                 case IPC_M_CONNECTMETO:
    28                         printf("Somebody wants to connect to: %zd\n",
     33                case IPC_M_CONNECT_ME_TO:
     34                        printf("Connectmeto: %zd\n",
    2935                               IPC_GET_ARG1(call.data));
    3036                        retval = 0;
     
    3743                        arg2 = 0xbeef;
    3844                        break;
     45                case NS_HANGUP:
     46                        printf("Closing connection.\n");
     47                        retval = EHANGUP;
     48                        break;
    3949                case NS_PING_SVC:
    40                         printf("Pinging service %d\n", service);
     50                        printf("NS:Pinging service %d\n", service);
    4151                        ipc_call_sync(service, NS_PING, 0xbeef, 0);
    42                         printf("Got pong\n");
     52                        printf("NS:Got pong\n");
    4353                        break;
    4454                default:
Note: See TracChangeset for help on using the changeset viewer.