Rev 1338 | Rev 1353 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1338 | Rev 1343 | ||
|---|---|---|---|
| Line 69... | Line 69... | ||
| 69 | ipcarg_t service; /**< Number of the service. */ |
69 | ipcarg_t service; /**< Number of the service. */ |
| 70 | ipcarg_t phone; /**< Phone registered with the service. */ |
70 | ipcarg_t phone; /**< Phone registered with the service. */ |
| 71 | ipcarg_t in_phone_hash; /**< Incoming phone hash. */ |
71 | ipcarg_t in_phone_hash; /**< Incoming phone hash. */ |
| 72 | } hashed_service_t; |
72 | } hashed_service_t; |
| 73 | 73 | ||
| 74 | /* |
- | |
| 75 | irq_cmd_t msim_cmds[1] = { |
- | |
| 76 | { CMD_MEM_READ_1, (void *)0xB0000000, 0 } |
- | |
| 77 | }; |
- | |
| 78 | - | ||
| 79 | irq_code_t msim_kbd = { |
- | |
| 80 | 1, |
- | |
| 81 | msim_cmds |
- | |
| 82 | }; |
- | |
| 83 | */ |
- | |
| 84 | /* |
- | |
| 85 | irq_cmd_t i8042_cmds[1] = { |
- | |
| 86 | { CMD_PORT_READ_1, (void *)0x60, 0 } |
- | |
| 87 | }; |
- | |
| 88 | - | ||
| 89 | irq_code_t i8042_kbd = { |
- | |
| 90 | 1, |
- | |
| 91 | i8042_cmds |
- | |
| 92 | }; |
- | |
| 93 | */ |
- | |
| 94 | - | ||
| 95 | - | ||
| 96 | int static ping_phone; |
74 | int static ping_phone; |
| 97 | 75 | ||
| 98 | int main(int argc, char **argv) |
76 | int main(int argc, char **argv) |
| 99 | { |
77 | { |
| 100 | ipc_call_t call; |
78 | ipc_call_t call; |
| Line 107... | Line 85... | ||
| 107 | 85 | ||
| 108 | if (!hash_table_create(&ns_hash_table, NS_HASH_TABLE_CHAINS, 3, &ns_hash_table_ops)) { |
86 | if (!hash_table_create(&ns_hash_table, NS_HASH_TABLE_CHAINS, 3, &ns_hash_table_ops)) { |
| 109 | printf("%s: cannot create hash table\n", NAME); |
87 | printf("%s: cannot create hash table\n", NAME); |
| 110 | return ENOMEM; |
88 | return ENOMEM; |
| 111 | } |
89 | } |
| 112 | - | ||
| 113 | 90 | ||
| 114 | // ipc_register_irq(2, &msim_kbd); |
- | |
| 115 | // ipc_register_irq(1, &i8042_kbd); |
- | |
| 116 | while (1) { |
91 | while (1) { |
| 117 | callid = ipc_wait_for_call(&call, 0); |
92 | callid = ipc_wait_for_call(&call, 0); |
| 118 | printf("NS: Call in_phone_hash=%lX...", call.in_phone_hash); |
93 | // printf("NS: Call in_phone_hash=%lX...", call.in_phone_hash); |
| 119 | switch (IPC_GET_METHOD(call)) { |
94 | switch (IPC_GET_METHOD(call)) { |
| 120 | case IPC_M_AS_SEND: |
95 | case IPC_M_AS_SEND: |
| 121 | as = (char *)IPC_GET_ARG2(call); |
96 | as = (char *)IPC_GET_ARG2(call); |
| 122 | printf("Received as: %P, size:%d\n", as, IPC_GET_ARG3(call)); |
97 | printf("Received as: %P, size:%d\n", as, IPC_GET_ARG3(call)); |
| 123 | retval = ipc_answer(callid, 0,(sysarg_t)(1024*1024), 0); |
98 | retval = ipc_answer_fast(callid, 0,(sysarg_t)(1024*1024), 0); |
| 124 | if (!retval) { |
99 | if (!retval) { |
| 125 | printf("Reading shared memory..."); |
100 | printf("Reading shared memory..."); |
| 126 | printf("Text: %s", as); |
101 | printf("Text: %s", as); |
| 127 | } else |
102 | } else |
| 128 | printf("Failed answer: %d\n", retval); |
103 | printf("Failed answer: %d\n", retval); |
| Line 168... | Line 143... | ||
| 168 | printf("Unknown method: %zd\n", IPC_GET_METHOD(call)); |
143 | printf("Unknown method: %zd\n", IPC_GET_METHOD(call)); |
| 169 | retval = ENOENT; |
144 | retval = ENOENT; |
| 170 | break; |
145 | break; |
| 171 | } |
146 | } |
| 172 | if (! (callid & IPC_CALLID_NOTIFICATION)) { |
147 | if (! (callid & IPC_CALLID_NOTIFICATION)) { |
| 173 | printf("Answering.\n"); |
148 | // printf("Answering.\n"); |
| 174 | ipc_answer(callid, retval, arg1, arg2); |
149 | ipc_answer_fast(callid, retval, arg1, arg2); |
| 175 | } |
150 | } |
| 176 | } |
151 | } |
| 177 | } |
152 | } |
| 178 | 153 | ||
| 179 | /** Register service. |
154 | /** Register service. |
| Line 225... | Line 200... | ||
| 225 | link_t *hlp; |
200 | link_t *hlp; |
| 226 | hashed_service_t *hs; |
201 | hashed_service_t *hs; |
| 227 | 202 | ||
| 228 | hlp = hash_table_find(&ns_hash_table, keys); |
203 | hlp = hash_table_find(&ns_hash_table, keys); |
| 229 | if (!hlp) { |
204 | if (!hlp) { |
| 230 | printf("Service %d not registered.\n", service); |
205 | // printf("Service %d not registered.\n", service); |
| 231 | return ENOENT; |
206 | return ENOENT; |
| 232 | } |
207 | } |
| 233 | hs = hash_table_get_instance(hlp, hashed_service_t, link); |
208 | hs = hash_table_get_instance(hlp, hashed_service_t, link); |
| 234 | printf("Connecting in_phone_hash=%lX to service at phone %d...", call->in_phone_hash, hs->phone); |
209 | printf("Connecting in_phone_hash=%lX to service at phone %d...", call->in_phone_hash, hs->phone); |
| 235 | return ipc_forward_fast(callid, hs->phone, 0, 0); |
210 | return ipc_forward_fast(callid, hs->phone, 0, 0); |