Subversion Repositories HelenOS

Rev

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

  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <syscall.h>
  4. #include <ipc/ipc.h>
  5. #include <udebug.h>
  6. #include "../tester.h"
  7.  
  8. const char *syscall_name[] = {
  9.     "sys_io",
  10.     "sys_tls_set",
  11.     "sys_thread_create",
  12.     "sys_thread_exit",
  13.     "sys_thread_get_id",
  14.     "sys_task_get_id",
  15.     "sys_futex_sleep_timeout",
  16.     "sys_futex_wakeup",
  17.     "sys_as_area_create",
  18.     "sys_as_area_resize",
  19.     "sys_as_area_destroy",
  20.     "sys_ipc_call_sync_fast",
  21.     "sys_ipc_call_sync_slow",
  22.     "sys_ipc_call_async_fast",
  23.     "sys_ipc_call_async_slow",
  24.     "sys_ipc_answer_fast",
  25.     "sys_ipc_answer_slow",
  26.     "sys_ipc_forward_fast",
  27.     "sys_ipc_wait_for_call",
  28.     "sys_ipc_hangup",
  29.     "sys_ipc_register_irq",
  30.     "sys_ipc_unregister_irq",
  31.     "sys_cap_grant",
  32.     "sys_cap_revoke",
  33.     "sys_physmem_map",
  34.     "sys_iospace_enable",
  35.     "sys_preempt_control",
  36.     "sys_sysinfo_valid",
  37.     "sys_sysinfo_value",
  38.     "sys_debug_enable_console",
  39.     "sys_ipc_connect_task"
  40. };
  41.  
  42. #define TIDBUF_SIZE 64
  43.  
  44. char * test_debug1(bool quiet)
  45. {
  46.     int taskid;
  47.     int rc;
  48.     int phoneid;
  49.     int i;
  50.     unsigned sc_args[6];
  51.     unsigned ipc_args[6];
  52.     unsigned copied;
  53.     unsigned ev_type;
  54.     unsigned sc_id;
  55.     int sc_rc;
  56.     unsigned threadid_buf[TIDBUF_SIZE];
  57.     int tb_copied, tb_needed;
  58.  
  59.     printf("running debug1 test\n");
  60.     taskid = 12;
  61.     printf("ipc_connect_task(%d)...\n", taskid);
  62.     rc = ipc_connect_kbox(taskid);
  63.     printf("-> %d\n", rc);
  64.     phoneid = rc;
  65.  
  66.     printf("send IPC_M_DEBUG_BEGIN message\n");
  67.     rc = ipc_call_sync_1_0(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_BEGIN);
  68.     printf("-> %d\n", rc);
  69.  
  70.     printf("send IPC_M_DEBUG_THREAD_READ message\n");
  71.     rc = ipc_call_sync_3_2(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_THREAD_READ,
  72.         (sysarg_t)threadid_buf, TIDBUF_SIZE*sizeof(unsigned),
  73.         &tb_copied, &tb_needed);
  74.     printf("-> %d\n", rc);
  75.  
  76.     printf("thread IDs:");
  77.     for (i=0; i<tb_copied / sizeof(unsigned); i++) {
  78.         printf(" %u", threadid_buf[i]);
  79.     }
  80.     printf("\ntotal of %u threads\n", tb_needed/sizeof(unsigned));
  81.  
  82.     while (1) {
  83.         rc = ipc_call_sync_2_3(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_GO,
  84.             threadid_buf[0], &ev_type, &sc_id, &sc_rc);
  85.         if (rc >= 0) {
  86.             rc = ipc_call_sync_4_1(phoneid, IPC_M_DEBUG_ALL,
  87.                 UDEBUG_M_ARGS_READ, threadid_buf[0], sc_args,
  88.                 6 * sizeof(unsigned), &copied);
  89.         }
  90.         if (rc >= 0) {
  91.             printf("%s[%d](%u, %u, %u, %u, %u, %u) -> %d\n",
  92.                 syscall_name[sc_id], sc_id,
  93.                 sc_args[0], sc_args[1], sc_args[2],
  94.                 sc_args[3], sc_args[4], sc_args[5],
  95.                 sc_rc);
  96.         }
  97.         if (sc_id == SYS_IPC_CALL_ASYNC_SLOW) {
  98.             memset(ipc_args, 0, sizeof(ipc_args));
  99.             printf("read async call args..\n");
  100.             printf("dest=%u, ptr=%u, len=%u\n",
  101.                 (sysarg_t)ipc_args, sc_args[1], sizeof(ipc_args));
  102.             rc = ipc_call_sync_4_0(phoneid, IPC_M_DEBUG_ALL,
  103.                 UDEBUG_M_MEM_READ, (sysarg_t)ipc_args,
  104.                 sc_args[1], sizeof(ipc_args));
  105.             printf("-> %d\n", rc);
  106.             printf("args: (%u, %u, %u, %u, %u, %u)\n",
  107.                 ipc_args[0], ipc_args[1], ipc_args[2],
  108.                 ipc_args[3], ipc_args[4], ipc_args[5]);
  109.         }
  110.     }
  111.  
  112.     printf("done\n");
  113.     return NULL;
  114. }
  115.