Subversion Repositories HelenOS-historic

Rev

Rev 1259 | Rev 1285 | 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. static int service;
  18.  
  19. int main(int argc, char **argv)
  20. {
  21.     ipc_call_t call;
  22.     ipc_callid_t callid;
  23.    
  24.     ipcarg_t retval, arg1, arg2;
  25.  
  26.     printf("NS:Name service started.\n");
  27. //  ipc_register_irq(2, &msim_kbd);
  28.     while (1) {
  29.         callid = ipc_wait_for_call(&call, 0);
  30.         printf("NS:Call phone=%lX..", call.phoneid);
  31.         switch (IPC_GET_METHOD(call)) {
  32.         case IPC_M_INTERRUPT:
  33.             printf("GOT INTERRUPT: %c\n", IPC_GET_ARG2(call));
  34.             break;
  35.         case IPC_M_PHONE_HUNGUP:
  36.             printf("Phone hung up.\n");
  37.             retval = 0;
  38.             break;
  39.         case IPC_M_CONNECT_TO_ME:
  40.             printf("Somebody connecting phid=%zd.\n", IPC_GET_ARG3(call));
  41.             service = IPC_GET_ARG3(call);
  42.             retval = 0;
  43.             break;
  44.         case IPC_M_CONNECT_ME_TO:
  45.             printf("Connectme(%P)to: %zd\n",
  46.                    IPC_GET_ARG3(call), IPC_GET_ARG1(call));
  47.             retval = 0;
  48.             break;
  49.         case NS_PING:
  50.             printf("Ping...%P %P\n", IPC_GET_ARG1(call),
  51.                    IPC_GET_ARG2(call));
  52.             retval = 0;
  53.             arg1 = 0xdead;
  54.             arg2 = 0xbeef;
  55.             break;
  56.         case NS_HANGUP:
  57.             printf("Closing connection.\n");
  58.             retval = EHANGUP;
  59.             break;
  60.         case NS_PING_SVC:
  61.             printf("NS:Pinging service %d\n", service);
  62.             ipc_call_sync(service, NS_PING, 0xbeef, 0);
  63.             printf("NS:Got pong\n");
  64.             break;
  65.         default:
  66.             printf("Unknown method: %zd\n", IPC_GET_METHOD(call));
  67.             retval = ENOENT;
  68.             break;
  69.         }
  70.         if (! (callid & IPC_CALLID_NOTIFICATION)) {
  71.             printf("Answerinh\n");
  72.             ipc_answer(callid, retval, arg1, arg2);
  73.         }
  74.     }
  75. }
  76.