Subversion Repositories shark

Rev

Rev 1523 | Rev 1560 | 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
148
          case FTrace_EVT_server_create:
149
                printf("11 ");
150
                tsc=1;
151
                break;
1517 giacomo 152
 
1558 trimarchi 153
          case FTrace_EVT_server_replenish:
154
                printf("12 ");
155
                tsc=1;
156
                break;
157
          case FTrace_EVT_server_exhaust:  
158
                printf("13 ");
159
                tsc=1;
160
                break;
161
          case FTrace_EVT_server_reclaiming:
162
                printf("14 ");
163
                tsc=1;
164
                break;
165
          case FTrace_EVT_server_remove:
166
                printf("15 ");      
167
                tsc=1;
168
                break;
169
          case FTrace_EVT_server_active:
170
                printf("16 ");
171
                tsc=1;
172
                break;
173
          case FTrace_EVT_server_using_rec:
174
                printf("17 ");
175
                tsc=1;
176
                break;
177
 
1523 giacomo 178
          case FTrace_EVT_task_deadline_miss:
179
                printf("20 ");
180
                tsc = 1;
181
                break;
182
 
183
          case FTrace_EVT_task_wcet_violation:
184
                printf("21 ");
185
                tsc = 1;
186
                break;
187
 
1491 giacomo 188
        }
189
 
190
        tsc_value = (unsigned long long)(*(unsigned int *)(p+4)) << 32;
191
        tsc_value += (unsigned long long)(*(unsigned int *)(p+8));
192
 
1492 giacomo 193
        if (tsc == 1) {
1491 giacomo 194
 
1492 giacomo 195
          printf("%llu ",tsc_value);
196
 
1510 giacomo 197
          switch (*(unsigned short int *)(p) & 0x00FF) {
1492 giacomo 198
 
1520 giacomo 199
            case FTrace_EVT_trace_start:
200
                printf("%d %d ",*(unsigned short int *)(p+2),*(unsigned int *)(p+12));
201
                break;
202
 
1492 giacomo 203
            case FTrace_EVT_interrupt_start:
204
                printf("%d ",*(unsigned short int *)(p+2));
205
                break;
206
 
207
            case FTrace_EVT_timer_wakeup_start:
208
                printf("%d ",0);
209
                break;
210
 
211
            case FTrace_EVT_timer_wakeup_end:
212
            case FTrace_EVT_interrupt_end:
213
                printf("%d ",*(unsigned short int *)(p+2));
214
                break;
215
 
216
            case FTrace_EVT_context_switch:
217
                printf("%d ",*(unsigned short int *)(p+2));
218
                break;
219
 
1494 giacomo 220
            case FTrace_EVT_task_create:
221
                printf("%d %d",*(unsigned short int *)(p+2),*(unsigned int *)(p+12));
222
                break;
223
 
1523 giacomo 224
            case FTrace_EVT_task_deadline_miss:
225
                printf("%d %d",*(unsigned short int *)(p+2),*(unsigned int *)(p+12));
226
                break;
227
 
228
            case FTrace_EVT_task_wcet_violation:
229
                printf("%d %d",*(unsigned short int *)(p+2),*(unsigned int *)(p+12));
230
                break;
231
 
1494 giacomo 232
            case FTrace_EVT_task_activate:
233
                printf("%d ",*(unsigned short int *)(p+2));
234
                break;
235
 
236
            case FTrace_EVT_task_end_cycle:
237
                printf("%d ",*(unsigned short int *)(p+2));
238
                break;
239
 
240
            case FTrace_EVT_task_end:
241
                printf("%d ",*(unsigned short int *)(p+2));
242
                break;
243
 
1508 giacomo 244
            case FTrace_EVT_id:
245
                printf("%d %d",*(unsigned short int *)(p+2),*(unsigned int *)(p+12));
246
                break;
247
 
1517 giacomo 248
            case FTrace_EVT_cycles_per_msec:
249
                printf("%d ",*(unsigned int *)(p+12));
250
                break;
1558 trimarchi 251
 
252
            case FTrace_EVT_server_replenish:
253
            case FTrace_EVT_server_exhaust:
254
            case FTrace_EVT_server_reclaiming:
255
            case FTrace_EVT_server_remove:
256
            case FTrace_EVT_server_active:
257
                printf("%d ", *(unsigned int *)(p+12));
258
                break;
259
            case FTrace_EVT_server_create:
260
            case FTrace_EVT_server_using_rec:
261
                printf("%d %d",*(unsigned short int *)(p+2),*(unsigned int *)(p+12));
262
                break;
1492 giacomo 263
          }
264
 
265
          printf("\n");
266
 
267
        }
268
 
1491 giacomo 269
        size = 16;
270
 
271
      ev++;
272
 
273
      p += 16;
274
 
275
      if ((unsigned int)(p) + 10 > (unsigned int)(buffer + n + delta)) break;
276
 
277
      last = p;
278
 
279
    }
280
 
281
    if ((unsigned int)(p) + 10 > (unsigned int)(buffer + n + delta)) break;
282
 
283
  }
284
 
285
  fclose(input_file);
286
 
287
  return 0;
288
 
289
}
290