Changeset 7048773 in mainline for init/init.c


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.

File:
1 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}
Note: See TracChangeset for help on using the changeset viewer.