source: mainline/ns/ns.c@ 81e55099

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 81e55099 was 11a4fbf, checked in by Josef Cejka <malyzelenyhnus@…>, 19 years ago

Userspace printf was rewritten to support standard format. Not all needed features implemented yet.

  • Property mode set to 100644
File size: 1.2 KB
Line 
1#include <ipc.h>
2#include <stdio.h>
3#include <unistd.h>
4#include <stdlib.h>
5#include <ns.h>
6#include <errno.h>
7
8static int service;
9
10int main(int argc, char **argv)
11{
12 ipc_call_t call;
13 ipc_callid_t callid;
14
15 ipcarg_t retval, arg1, arg2;
16
17 printf("Name service started.\n");
18 while (1) {
19 callid = ipc_wait_for_call(&call, 0);
20 printf("Received call from: %P..%llX\n", &call.taskid,call.taskid);
21 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 service = IPC_GET_ARG3(call.data);
25 retval = 0;
26 break;
27 case IPC_M_CONNECTMETO:
28 printf("Somebody wants to connect to: %zd\n",
29 IPC_GET_ARG1(call.data));
30 retval = 0;
31 break;
32 case NS_PING:
33 printf("Ping...%P %P\n", IPC_GET_ARG1(call.data),
34 IPC_GET_ARG2(call.data));
35 retval = 0;
36 arg1 = 0xdead;
37 arg2 = 0xbeef;
38 break;
39 case NS_PING_SVC:
40 printf("Pinging service %d\n", service);
41 ipc_call_sync(service, NS_PING, 0xbeef, 0);
42 printf("Got pong\n");
43 break;
44 default:
45 printf("Unknown method: %zd\n", IPC_GET_METHOD(call.data));
46 retval = ENOENT;
47 break;
48 }
49 ipc_answer(callid, retval, arg1, arg2);
50 }
51}
Note: See TracBrowser for help on using the repository browser.