Changeset 7048773 in mainline
- Timestamp:
- 2006-03-19T12:43:37Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4c61e60
- Parents:
- 0a862b65
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
init/init.c
r0a862b65 r7048773 35 35 #include <thread.h> 36 36 37 int a; 38 37 39 extern void utest(void *arg); 38 40 void utest(void *arg) … … 170 172 ipc_answer(callid, 0, 0, 0); 171 173 } 172 callid = ipc_wait_for_call(&data, NULL);174 // callid = ipc_wait_for_call(&data, NULL); 173 175 } 174 176 … … 183 185 printf("pinging.\n"); 184 186 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); 186 188 189 } 190 191 static 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 215 static 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); 187 242 } 188 243 … … 196 251 // test_async_ipc(); 197 252 // 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 // } 204 260 return 0; 205 261 } -
libipc/generic/ipc.c
r0a862b65 r7048773 253 253 } 254 254 255 /* Hang up specified phone */ 256 int ipc_hangup(int phoneid) 257 { 258 return __SYSCALL1(SYS_IPC_HANGUP, phoneid); 259 } -
libipc/include/ipc.h
r0a862b65 r7048773 35 35 36 36 typedef sysarg_t ipcarg_t; 37 typedef sysarg_t ipc_data_t[IPC_CALL_LEN]; 37 typedef struct { 38 sysarg_t args[IPC_CALL_LEN]; 39 sysarg_t phoneid; 40 } ipc_data_t ; 38 41 typedef struct { 39 42 unsigned long long taskid; … … 66 69 unsigned long long *taskid); 67 70 int ipc_connect_me_to(int phoneid, int arg1, int arg2); 71 int ipc_hangup(int phoneid); 68 72 69 73 #endif -
libipc/include/ns.h
r0a862b65 r7048773 32 32 #define NS_PING 1024 33 33 #define NS_PING_SVC 1025 34 #define NS_HANGUP 1026 34 35 35 36 #endif -
ns/ns.c
r0a862b65 r7048773 15 15 ipcarg_t retval, arg1, arg2; 16 16 17 printf("N ame service started.\n");17 printf("NS:Name service started.\n"); 18 18 while (1) { 19 call.taskid = -1; 19 20 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); 21 23 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)); 24 30 service = IPC_GET_ARG3(call.data); 25 31 retval = 0; 26 32 break; 27 case IPC_M_CONNECT METO:28 printf(" Somebody wants to connectto: %zd\n",33 case IPC_M_CONNECT_ME_TO: 34 printf("Connectmeto: %zd\n", 29 35 IPC_GET_ARG1(call.data)); 30 36 retval = 0; … … 37 43 arg2 = 0xbeef; 38 44 break; 45 case NS_HANGUP: 46 printf("Closing connection.\n"); 47 retval = EHANGUP; 48 break; 39 49 case NS_PING_SVC: 40 printf(" Pinging service %d\n", service);50 printf("NS:Pinging service %d\n", service); 41 51 ipc_call_sync(service, NS_PING, 0xbeef, 0); 42 printf(" Got pong\n");52 printf("NS:Got pong\n"); 43 53 break; 44 54 default:
Note:
See TracChangeset
for help on using the changeset viewer.