Rev 1282 | Rev 1330 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1282 | Rev 1285 | ||
---|---|---|---|
1 | #include <ipc.h> |
1 | #include <ipc.h> |
2 | #include <stdio.h> |
2 | #include <stdio.h> |
3 | #include <unistd.h> |
3 | #include <unistd.h> |
4 | #include <stdlib.h> |
4 | #include <stdlib.h> |
5 | #include <ns.h> |
5 | #include <ns.h> |
6 | #include <errno.h> |
6 | #include <errno.h> |
7 | /* |
7 | /* |
8 | irq_cmd_t msim_cmds[1] = { |
8 | irq_cmd_t msim_cmds[1] = { |
9 | { CMD_MEM_READ_1, (void *)0xB0000000, 0 } |
9 | { CMD_MEM_READ_1, (void *)0xB0000000, 0 } |
10 | }; |
10 | }; |
11 | 11 | ||
12 | irq_code_t msim_kbd = { |
12 | irq_code_t msim_kbd = { |
13 | 1, |
13 | 1, |
14 | msim_cmds |
14 | msim_cmds |
15 | }; |
15 | }; |
16 | */ |
16 | */ |
- | 17 | /* |
|
- | 18 | irq_cmd_t i8042_cmds[1] = { |
|
- | 19 | { CMD_PORT_READ_1, (void *)0x60, 0 } |
|
- | 20 | }; |
|
- | 21 | ||
- | 22 | irq_code_t i8042_kbd = { |
|
- | 23 | 1, |
|
- | 24 | i8042_cmds |
|
- | 25 | }; |
|
- | 26 | */ |
|
- | 27 | ||
17 | static int service; |
28 | static int service; |
18 | 29 | ||
19 | int main(int argc, char **argv) |
30 | int main(int argc, char **argv) |
20 | { |
31 | { |
21 | ipc_call_t call; |
32 | ipc_call_t call; |
22 | ipc_callid_t callid; |
33 | ipc_callid_t callid; |
23 | 34 | ||
24 | ipcarg_t retval, arg1, arg2; |
35 | ipcarg_t retval, arg1, arg2; |
25 | 36 | ||
26 | printf("NS:Name service started.\n"); |
37 | printf("NS:Name service started.\n"); |
27 | // ipc_register_irq(2, &msim_kbd); |
38 | // ipc_register_irq(2, &msim_kbd); |
- | 39 | // ipc_register_irq(1, &i8042_kbd); |
|
28 | while (1) { |
40 | while (1) { |
29 | callid = ipc_wait_for_call(&call, 0); |
41 | callid = ipc_wait_for_call(&call, 0); |
30 | printf("NS:Call phone=%lX..", call.phoneid); |
42 | printf("NS:Call phone=%lX..", call.phoneid); |
31 | switch (IPC_GET_METHOD(call)) { |
43 | switch (IPC_GET_METHOD(call)) { |
32 | case IPC_M_INTERRUPT: |
44 | case IPC_M_INTERRUPT: |
33 | printf("GOT INTERRUPT: %c\n", IPC_GET_ARG2(call)); |
45 | printf("GOT INTERRUPT: %c\n", IPC_GET_ARG2(call)); |
34 | break; |
46 | break; |
35 | case IPC_M_PHONE_HUNGUP: |
47 | case IPC_M_PHONE_HUNGUP: |
36 | printf("Phone hung up.\n"); |
48 | printf("Phone hung up.\n"); |
37 | retval = 0; |
49 | retval = 0; |
38 | break; |
50 | break; |
39 | case IPC_M_CONNECT_TO_ME: |
51 | case IPC_M_CONNECT_TO_ME: |
40 | printf("Somebody connecting phid=%zd.\n", IPC_GET_ARG3(call)); |
52 | printf("Somebody connecting phid=%zd.\n", IPC_GET_ARG3(call)); |
41 | service = IPC_GET_ARG3(call); |
53 | service = IPC_GET_ARG3(call); |
42 | retval = 0; |
54 | retval = 0; |
43 | break; |
55 | break; |
44 | case IPC_M_CONNECT_ME_TO: |
56 | case IPC_M_CONNECT_ME_TO: |
45 | printf("Connectme(%P)to: %zd\n", |
57 | printf("Connectme(%P)to: %zd\n", |
46 | IPC_GET_ARG3(call), IPC_GET_ARG1(call)); |
58 | IPC_GET_ARG3(call), IPC_GET_ARG1(call)); |
47 | retval = 0; |
59 | retval = 0; |
48 | break; |
60 | break; |
49 | case NS_PING: |
61 | case NS_PING: |
50 | printf("Ping...%P %P\n", IPC_GET_ARG1(call), |
62 | printf("Ping...%P %P\n", IPC_GET_ARG1(call), |
51 | IPC_GET_ARG2(call)); |
63 | IPC_GET_ARG2(call)); |
52 | retval = 0; |
64 | retval = 0; |
53 | arg1 = 0xdead; |
65 | arg1 = 0xdead; |
54 | arg2 = 0xbeef; |
66 | arg2 = 0xbeef; |
55 | break; |
67 | break; |
56 | case NS_HANGUP: |
68 | case NS_HANGUP: |
57 | printf("Closing connection.\n"); |
69 | printf("Closing connection.\n"); |
58 | retval = EHANGUP; |
70 | retval = EHANGUP; |
59 | break; |
71 | break; |
60 | case NS_PING_SVC: |
72 | case NS_PING_SVC: |
61 | printf("NS:Pinging service %d\n", service); |
73 | printf("NS:Pinging service %d\n", service); |
62 | ipc_call_sync(service, NS_PING, 0xbeef, 0); |
74 | ipc_call_sync(service, NS_PING, 0xbeef, 0); |
63 | printf("NS:Got pong\n"); |
75 | printf("NS:Got pong\n"); |
64 | break; |
76 | break; |
65 | default: |
77 | default: |
66 | printf("Unknown method: %zd\n", IPC_GET_METHOD(call)); |
78 | printf("Unknown method: %zd\n", IPC_GET_METHOD(call)); |
67 | retval = ENOENT; |
79 | retval = ENOENT; |
68 | break; |
80 | break; |
69 | } |
81 | } |
70 | if (! (callid & IPC_CALLID_NOTIFICATION)) { |
82 | if (! (callid & IPC_CALLID_NOTIFICATION)) { |
71 | printf("Answerinh\n"); |
83 | printf("Answerinh\n"); |
72 | ipc_answer(callid, retval, arg1, arg2); |
84 | ipc_answer(callid, retval, arg1, arg2); |
73 | } |
85 | } |
74 | } |
86 | } |
75 | } |
87 | } |
76 | 88 |