OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / sdk / emulator / qtools / tests / macros.h
1 #ifndef _TEST_TRACE_C_H_
2 #define _TEST_TRACE_C_H_
3
4 /* the base address of trace device */
5 #define TRACE_DEV_BASE_ADDR             0x21000000
6
7 /*the register addresses of the trace device */
8 #define TRACE_DEV_REG_SWITCH            0
9 #define TRACE_DEV_REG_FORK              1
10 #define TRACE_DEV_REG_EXECVE_PID        2
11 #define TRACE_DEV_REG_EXECVE_VMSTART    3
12 #define TRACE_DEV_REG_EXECVE_VMEND      4
13 #define TRACE_DEV_REG_EXECVE_OFFSET     5
14 #define TRACE_DEV_REG_EXECVE_EXEPATH    6
15 #define TRACE_DEV_REG_EXIT              7
16 #define TRACE_DEV_REG_CMDLINE           8
17 #define TRACE_DEV_REG_CMDLINE_LEN       9
18 #define TRACE_DEV_REG_MMAP_EXEPATH      10
19 #define TRACE_DEV_REG_INIT_PID          11
20 #define TRACE_DEV_REG_INIT_NAME         12
21 #define TRACE_DEV_REG_CLONE             13
22 #define TRACE_DEV_REG_DYN_SYM           50
23 #define TRACE_DEV_REG_DYN_SYM_ADDR      51
24 #define TRACE_DEV_REG_PRINT_STR         60
25 #define TRACE_DEV_REG_PRINT_NUM_DEC     61
26 #define TRACE_DEV_REG_PRINT_NUM_HEX     62
27 #define TRACE_DEV_REG_STOP_EMU          90
28 #define TRACE_DEV_REG_ENABLE            100
29 #define TRACE_DEV_REG_DISABLE           101
30
31 /* write a word to a trace device register */
32 #define DEV_WRITE_WORD(addr,value)\
33     (*(volatile unsigned long *)(TRACE_DEV_BASE_ADDR + ((addr) << 2)) = (value))
34
35 /*************************************************************/
36 /* generates test events */
37
38 /* context switch */
39 #define TRACE_SWITCH(pid)            DEV_WRITE_WORD(TRACE_DEV_REG_SWITCH, (pid))
40 /* fork */
41 #define TRACE_FORK(pid)              DEV_WRITE_WORD(TRACE_DEV_REG_FORK, (pid))
42 /* clone */
43 #define TRACE_CLONE(pid)             DEV_WRITE_WORD(TRACE_DEV_REG_CLONE, (pid))
44 /* dump name and path of threads executed before trace device created */
45 #define TRACE_INIT_NAME(pid,path)\
46 do {\
47     DEV_WRITE_WORD(TRACE_DEV_REG_INIT_PID, (pid));\
48     DEV_WRITE_WORD(TRACE_DEV_REG_INIT_NAME, (unsigned long)(path));\
49 }while(0)
50 /* dump exec mapping of threads executed before trace device created */
51 #define TRACE_INIT_EXEC(vstart,vend,eoff,path)\
52 do {\
53     DEV_WRITE_WORD(TRACE_DEV_REG_EXECVE_VMSTART, (vstart));\
54     DEV_WRITE_WORD(TRACE_DEV_REG_EXECVE_VMEND, (vend));\
55     DEV_WRITE_WORD(TRACE_DEV_REG_EXECVE_OFFSET, (eoff));\
56     DEV_WRITE_WORD(TRACE_DEV_REG_EXECVE_EXEPATH, (unsigned long)(path));\
57 }while(0)
58 /* mmap */
59 #define TRACE_MMAP(vstart,vend,eoff,path)\
60 do {\
61     DEV_WRITE_WORD(TRACE_DEV_REG_EXECVE_VMSTART, (vstart));\
62     DEV_WRITE_WORD(TRACE_DEV_REG_EXECVE_VMEND, (vend));\
63     DEV_WRITE_WORD(TRACE_DEV_REG_EXECVE_OFFSET, (eoff));\
64     DEV_WRITE_WORD(TRACE_DEV_REG_MMAP_EXEPATH, (unsigned long)(path));\
65 }while(0)
66 /* execve */
67 #define TRACE_EXECVE(cmdlen,cmd)\
68 do {\
69     DEV_WRITE_WORD(TRACE_DEV_REG_CMDLINE_LEN, (cmdlen));\
70     DEV_WRITE_WORD(TRACE_DEV_REG_CMDLINE, (unsigned long)(cmd));\
71 }while(0)
72 /* exit */
73 #define TRACE_EXIT(retv)             DEV_WRITE_WORD(TRACE_DEV_REG_EXIT, (retv))
74
75 /* other commands */
76
77 /* stop emulation */
78 #define TRACE_STOP_EMU()             DEV_WRITE_WORD(TRACE_DEV_REG_STOP_EMU, 1)
79 /* enable/disable tracing */
80 #define TRACE_ENABLE_TRACING()       DEV_WRITE_WORD(TRACE_DEV_REG_ENABLE, 1)
81 #define TRACE_DISABLE_TRACING()      DEV_WRITE_WORD(TRACE_DEV_REG_DISABLE, 1)
82 /* dynamic symbols */
83 #define TRACE_DYN_SYM(addr,sym)\
84 do {\
85     DEV_WRITE_WORD(TRACE_DEV_REG_DYN_SYM_ADDR, (addr));\
86     DEV_WRITE_WORD(TRACE_DEV_REG_DYN_SYM, (unsigned long)(sym));\
87 }while(0)
88 /* prints */
89 #define PRINT_STR(str)         DEV_WRITE_WORD(TRACE_DEV_REG_PRINT_STR, (unsigned long)(str))
90 #define PRINT_NUM_DEC(num)     DEV_WRITE_WORD(TRACE_DEV_REG_PRINT_NUM_DEC, (num))
91 #define PRINT_NUM_HEX(num)     DEV_WRITE_WORD(TRACE_DEV_REG_PRINT_NUM_HEX, (num))
92
93 #endif