Subversion Repositories HelenOS-historic

Rev

Rev 1282 | Rev 1335 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  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. /*
  8. irq_cmd_t msim_cmds[1] = {
  9.     { CMD_MEM_READ_1, (void *)0xB0000000, 0 }
  10. };
  11.  
  12. irq_code_t msim_kbd = {
  13.     1,
  14.     msim_cmds
  15. };
  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.  
  28. static int service;
  29.  
  30. int main(int argc, char **argv)
  31. {
  32.     ipc_call_t call;
  33.     ipc_callid_t callid;
  34.    
  35.     ipcarg_t retval, arg1, arg2;
  36.  
  37.     printf("NS:Name service started.\n");
  38. //  ipc_register_irq(2, &msim_kbd);
  39. //  ipc_register_irq(1, &i8042_kbd);
  40.     while (1) {
  41.         callid = ipc_wait_for_call(&call, 0);
  42.         printf("NS:Call phone=%lX..", call.phoneid);
  43.         switch (IPC_GET_METHOD(call)) {
  44.         case IPC_M_INTERRUPT:
  45.             printf("GOT INTERRUPT: %c\n", IPC_GET_ARG2(call));
  46.             break;
  47.         case IPC_M_PHONE_HUNGUP:
  48.             printf("Phone hung up.\n");
  49.             retval = 0;
  50.             break;
  51.         case IPC_M_CONNECT_TO_ME:
  52.             printf("Somebody connecting phid=%zd.\n", IPC_GET_ARG3(call));
  53.             service = IPC_GET_ARG3(call);
  54.             retval = 0;
  55.             break;
  56.         case IPC_M_CONNECT_ME_TO:
  57.             printf("Connectme(%P)to: %zd\n",
  58.                    IPC_GET_ARG3(call), IPC_GET_ARG1(call));
  59.             retval = 0;
  60.             break;
  61.         case NS_PING:
  62.             printf("Ping...%P %P\n", IPC_GET_ARG1(call),
  63.                    IPC_GET_ARG2(call));
  64.             retval = 0;
  65.             arg1 = 0xdead;
  66.             arg2 = 0xbeef;
  67.             break;
  68.         case NS_HANGUP:
  69.             printf("Closing connection.\n");
  70.             retval = EHANGUP;
  71.             break;
  72.         case NS_PING_SVC:
  73.             printf("NS:Pinging service %d\n", service);
  74.             ipc_call_sync(service, NS_PING, 0xbeef, 0);
  75.             printf("NS:Got pong\n");
  76.             break;
  77.         default:
  78.             printf("Unknown method: %zd\n", IPC_GET_METHOD(call));
  79.             retval = ENOENT;
  80.             break;
  81.         }
  82.         if (! (callid & IPC_CALLID_NOTIFICATION)) {
  83.             printf("Answerinh\n");
  84.             ipc_answer(callid, retval, arg1, arg2);
  85.         }
  86.     }
  87. }
  88.