Rev 1558 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1491 | giacomo | 1 | /* |
2 | * Project: S.Ha.R.K. |
||
3 | * |
||
4 | * Coordinators: |
||
5 | * Giorgio Buttazzo <giorgio@sssup.it> |
||
6 | * Paolo Gai <pj@gandalf.sssup.it> |
||
7 | * |
||
8 | * Authors : |
||
9 | * Giacomo Guidi <giacomo@gandalf.sssup.it> |
||
10 | * |
||
11 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
12 | * |
||
13 | * http://www.sssup.it |
||
14 | * http://retis.sssup.it |
||
15 | * http://shark.sssup.it |
||
16 | */ |
||
17 | |||
18 | #include <stdio.h> |
||
19 | #include <unistd.h> |
||
20 | #include <stdlib.h> |
||
21 | #include <string.h> |
||
22 | |||
23 | #include <FTrace.h> |
||
24 | |||
25 | #define READ_BUFFER 2000 |
||
26 | #define DELTA_BUFFER 100 |
||
27 | |||
28 | int main(int argc, char *argv[]) |
||
29 | { |
||
30 | |||
31 | char buffer[READ_BUFFER+DELTA_BUFFER]; |
||
32 | void *p, *last; |
||
1492 | giacomo | 33 | int n,delta,size,tsc; |
1491 | giacomo | 34 | |
35 | unsigned long long ev = 0, tsc_value; |
||
36 | |||
37 | FILE *input_file; |
||
38 | |||
39 | if (argc < 2) { |
||
40 | printf("%s: Enter the input file name [%s filename]\n",argv[0],argv[0]); |
||
41 | exit(1); |
||
42 | } |
||
43 | |||
44 | input_file = fopen(argv[1],"rb"); |
||
45 | |||
46 | last = buffer + READ_BUFFER; |
||
47 | |||
48 | while(!feof(input_file)) { |
||
49 | |||
50 | //move remaining byte |
||
51 | delta = (unsigned int)(buffer) + READ_BUFFER - (unsigned int)(last); |
||
52 | if (delta > 0) memcpy(buffer,last,delta); |
||
53 | |||
54 | n = fread(buffer+delta,1,READ_BUFFER+10,input_file); |
||
55 | fseek(input_file,-(delta+10),SEEK_CUR); |
||
56 | |||
57 | p = buffer; |
||
1558 | trimarchi | 58 | /* |
59 | // specific server events |
||
60 | #define FTrace_EVT_server_create 0x08 // Par1 [empty] Par2 [server] |
||
61 | #define FTrace_EVT_server_replenish 0x18 // Par1 [empty] Par2 [server] |
||
62 | #define FTrace_EVT_server_exhaust 0x28 // Par1 [empty] Par2 [server] |
||
63 | #define FTrace_EVT_server_reclaiming 0x38 // Par1 [empty] Par2 [server] |
||
64 | #define FTrace_EVT_server_remove 0x48 // Par1 [empty] Par2 [server] |
||
65 | #define FTrace_EVT_server_active 0x58 // Par1 [empty] Par2 [server] |
||
66 | #define FTrace_EVT_server_using_rec 0x68 // Par1 [reclaiming] Par2 [server] |
||
67 | */ |
||
1491 | giacomo | 68 | |
69 | while ((unsigned int)(p) + 16 <= (unsigned int)(buffer + READ_BUFFER) && |
||
70 | (unsigned int)(p) + 16 <= (unsigned int)(buffer + n + delta)) { |
||
71 | |||
1492 | giacomo | 72 | tsc = 0; |
73 | |||
1510 | giacomo | 74 | switch (*(unsigned short int *)(p) & 0x00FF) { |
1491 | giacomo | 75 | |
76 | case FTrace_EVT_ipoint: |
||
77 | printf("%d ",*(unsigned short int *)(p+2)); |
||
1492 | giacomo | 78 | tsc = 1; |
1491 | giacomo | 79 | break; |
80 | |||
1494 | giacomo | 81 | /* Tracer start */ |
1491 | giacomo | 82 | case FTrace_EVT_trace_start: |
83 | printf("0 "); |
||
1492 | giacomo | 84 | tsc = 1; |
1491 | giacomo | 85 | break; |
86 | |||
1494 | giacomo | 87 | /* Tracer stop */ |
1491 | giacomo | 88 | case FTrace_EVT_trace_stop: |
89 | printf("1 "); |
||
1492 | giacomo | 90 | tsc = 1; |
1491 | giacomo | 91 | break; |
92 | |||
1494 | giacomo | 93 | /* Interrupt start (int num) */ |
1491 | giacomo | 94 | case FTrace_EVT_timer_wakeup_start: |
95 | case FTrace_EVT_interrupt_start: |
||
96 | printf("2 "); |
||
1492 | giacomo | 97 | tsc = 1; |
1491 | giacomo | 98 | break; |
99 | |||
1494 | giacomo | 100 | /* Interrupt Stop (int num, or context num is int 3) */ |
101 | case FTrace_EVT_timer_wakeup_end: |
||
1491 | giacomo | 102 | case FTrace_EVT_interrupt_end: |
103 | printf("3 "); |
||
1492 | giacomo | 104 | tsc = 1; |
1491 | giacomo | 105 | break; |
106 | |||
1494 | giacomo | 107 | /* Context to (context num) */ |
1491 | giacomo | 108 | case FTrace_EVT_context_switch: |
109 | printf("4 "); |
||
1492 | giacomo | 110 | tsc = 1; |
1491 | giacomo | 111 | break; |
112 | |||
1494 | giacomo | 113 | /* Task Create (context num, pid num) */ |
114 | case FTrace_EVT_task_create: |
||
115 | printf("5 "); |
||
116 | tsc = 1; |
||
117 | break; |
||
118 | |||
119 | /* Task Activate (context num) */ |
||
120 | case FTrace_EVT_task_activate: |
||
121 | printf("6 "); |
||
122 | tsc = 1; |
||
123 | break; |
||
124 | |||
125 | /* Task End (context num) */ |
||
126 | case FTrace_EVT_task_end: |
||
127 | printf("7 "); |
||
128 | tsc = 1; |
||
129 | break; |
||
130 | |||
131 | /* Task End-Cycle (context num) */ |
||
132 | case FTrace_EVT_task_end_cycle: |
||
133 | printf("8 "); |
||
134 | tsc = 1; |
||
135 | break; |
||
136 | |||
1508 | giacomo | 137 | /* Task Context - PID declaration */ |
138 | case FTrace_EVT_id: |
||
139 | printf("9 "); |
||
140 | tsc = 1; |
||
141 | break; |
||
142 | |||
1517 | giacomo | 143 | case FTrace_EVT_cycles_per_msec: |
144 | printf("10 "); |
||
145 | tsc = 1; |
||
146 | break; |
||
1558 | trimarchi | 147 | // specific server events |
1517 | giacomo | 148 | |
1558 | trimarchi | 149 | case FTrace_EVT_server_active: |
150 | printf("16 "); |
||
151 | tsc=1; |
||
152 | break; |
||
153 | |||
1523 | giacomo | 154 | case FTrace_EVT_task_deadline_miss: |
155 | printf("20 "); |
||
156 | tsc = 1; |
||
157 | break; |
||
158 | |||
159 | case FTrace_EVT_task_wcet_violation: |
||
160 | printf("21 "); |
||
161 | tsc = 1; |
||
162 | break; |
||
163 | |||
1491 | giacomo | 164 | } |
165 | |||
166 | tsc_value = (unsigned long long)(*(unsigned int *)(p+4)) << 32; |
||
167 | tsc_value += (unsigned long long)(*(unsigned int *)(p+8)); |
||
168 | |||
1492 | giacomo | 169 | if (tsc == 1) { |
1491 | giacomo | 170 | |
1492 | giacomo | 171 | printf("%llu ",tsc_value); |
172 | |||
1510 | giacomo | 173 | switch (*(unsigned short int *)(p) & 0x00FF) { |
1492 | giacomo | 174 | |
1520 | giacomo | 175 | case FTrace_EVT_trace_start: |
176 | printf("%d %d ",*(unsigned short int *)(p+2),*(unsigned int *)(p+12)); |
||
177 | break; |
||
178 | |||
1492 | giacomo | 179 | case FTrace_EVT_interrupt_start: |
180 | printf("%d ",*(unsigned short int *)(p+2)); |
||
181 | break; |
||
182 | |||
183 | case FTrace_EVT_timer_wakeup_start: |
||
184 | printf("%d ",0); |
||
185 | break; |
||
186 | |||
187 | case FTrace_EVT_timer_wakeup_end: |
||
188 | case FTrace_EVT_interrupt_end: |
||
189 | printf("%d ",*(unsigned short int *)(p+2)); |
||
190 | break; |
||
191 | |||
192 | case FTrace_EVT_context_switch: |
||
193 | printf("%d ",*(unsigned short int *)(p+2)); |
||
194 | break; |
||
195 | |||
1494 | giacomo | 196 | case FTrace_EVT_task_create: |
197 | printf("%d %d",*(unsigned short int *)(p+2),*(unsigned int *)(p+12)); |
||
198 | break; |
||
199 | |||
1523 | giacomo | 200 | case FTrace_EVT_task_deadline_miss: |
201 | printf("%d %d",*(unsigned short int *)(p+2),*(unsigned int *)(p+12)); |
||
202 | break; |
||
203 | |||
204 | case FTrace_EVT_task_wcet_violation: |
||
205 | printf("%d %d",*(unsigned short int *)(p+2),*(unsigned int *)(p+12)); |
||
206 | break; |
||
207 | |||
1494 | giacomo | 208 | case FTrace_EVT_task_activate: |
209 | printf("%d ",*(unsigned short int *)(p+2)); |
||
210 | break; |
||
211 | |||
212 | case FTrace_EVT_task_end_cycle: |
||
213 | printf("%d ",*(unsigned short int *)(p+2)); |
||
214 | break; |
||
215 | |||
216 | case FTrace_EVT_task_end: |
||
217 | printf("%d ",*(unsigned short int *)(p+2)); |
||
218 | break; |
||
219 | |||
1508 | giacomo | 220 | case FTrace_EVT_id: |
221 | printf("%d %d",*(unsigned short int *)(p+2),*(unsigned int *)(p+12)); |
||
222 | break; |
||
223 | |||
1517 | giacomo | 224 | case FTrace_EVT_cycles_per_msec: |
225 | printf("%d ",*(unsigned int *)(p+12)); |
||
226 | break; |
||
1558 | trimarchi | 227 | |
1560 | trimarchi | 228 | case FTrace_EVT_server_active: |
1558 | trimarchi | 229 | printf("%d %d",*(unsigned short int *)(p+2),*(unsigned int *)(p+12)); |
230 | break; |
||
1492 | giacomo | 231 | } |
232 | |||
233 | printf("\n"); |
||
234 | |||
235 | } |
||
236 | |||
1491 | giacomo | 237 | size = 16; |
238 | |||
239 | ev++; |
||
240 | |||
241 | p += 16; |
||
242 | |||
243 | if ((unsigned int)(p) + 10 > (unsigned int)(buffer + n + delta)) break; |
||
244 | |||
245 | last = p; |
||
246 | |||
247 | } |
||
248 | |||
249 | if ((unsigned int)(p) + 10 > (unsigned int)(buffer + n + delta)) break; |
||
250 | |||
251 | } |
||
252 | |||
253 | fclose(input_file); |
||
254 | |||
255 | return 0; |
||
256 | |||
257 | } |
||
258 |