Subversion Repositories HelenOS

Rev

Rev 2808 | Rev 2812 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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