#include <stdio.h>
#include <unistd.h>
#include <syscall.h>
#include <ipc/ipc.h>
#include "../tester.h"
const char *syscall_name[] = {
"sys_io",
"sys_tls_set",
"sys_thread_create",
"sys_thread_exit",
"sys_thread_get_id",
"sys_task_get_id",
"sys_futex_sleep_timeout",
"sys_futex_wakeup",
"sys_as_area_create",
"sys_as_area_resize",
"sys_as_area_destroy",
"sys_ipc_call_sync_fast",
"sys_ipc_call_sync_slow",
"sys_ipc_call_async_fast",
"sys_ipc_call_async_slow",
"sys_ipc_answer_fast",
"sys_ipc_answer_slow",
"sys_ipc_forward_fast",
"sys_ipc_wait_for_call",
"sys_ipc_hangup",
"sys_ipc_register_irq",
"sys_ipc_unregister_irq",
"sys_cap_grant",
"sys_cap_revoke",
"sys_physmem_map",
"sys_iospace_enable",
"sys_preempt_control",
"sys_sysinfo_valid",
"sys_sysinfo_value",
"sys_debug_enable_console",
"sys_ipc_connect_task"
};
#define TIDBUF_SIZE 64
char * test_debug1(bool quiet)
{
int taskid;
int rc;
int phoneid;
int i;
unsigned sc_args[6];
unsigned ipc_args[6];
unsigned copied;
unsigned ev_type;
unsigned sc_id;
int sc_rc;
unsigned threadid_buf[TIDBUF_SIZE];
int tb_copied, tb_needed;
printf("running debug1 test\n");
taskid = 12;
printf("ipc_connect_task(%d)...\n", taskid
);
rc = ipc_connect_kbox(taskid);
phoneid = rc;
printf("send IPC_M_DEBUG_BEGIN message\n");
rc = ipc_call_sync_0_0(phoneid, IPC_M_DEBUG_BEGIN);
printf("send IPC_M_DEBUG_THREAD_READ message\n");
rc = ipc_call_sync_2_2(phoneid, IPC_M_DEBUG_THREAD_READ,
&threadid_buf, TIDBUF_SIZE*sizeof(unsigned),
&tb_copied, &tb_needed);
for (i=0; i<tb_copied / sizeof(unsigned); i++) {
printf(" %u", threadid_buf
[i
]);
}
printf("\ntotal of %u threads\n", tb_needed
/sizeof(unsigned));
while (1) {
rc = ipc_call_sync_1_3(phoneid, IPC_M_DEBUG_GO, threadid_buf[0],
&ev_type, &sc_id, &sc_rc);
if (rc >= 0) {
rc = ipc_call_sync_3_1(phoneid, IPC_M_DEBUG_ARGS_READ,
threadid_buf[0], sc_args, 6 * sizeof(unsigned), &copied);
}
if (rc >= 0) {
printf("%s[%d](%u, %u, %u, %u, %u, %u) -> %d\n",
syscall_name[sc_id], sc_id,
sc_args[0], sc_args[1], sc_args[2],
sc_args[3], sc_args[4], sc_args[5],
sc_rc);
}
if (sc_id == SYS_IPC_CALL_ASYNC_SLOW) {
memset(ipc_args
, 0, sizeof(ipc_args
));
printf("read async call args..\n");
printf("dest=%u, ptr=%u, len=%u\n",
(sysarg_t)ipc_args, sc_args[1], sizeof(ipc_args));
rc = ipc_call_sync_3_0(phoneid, IPC_M_DEBUG_MEM_READ,
(sysarg_t)ipc_args, sc_args[1], sizeof(ipc_args));
printf("args: (%u, %u, %u, %u, %u, %u)\n",
ipc_args[0], ipc_args[1], ipc_args[2],
ipc_args[3], ipc_args[4], ipc_args[5]);
}
}
return NULL;
}