Subversion Repositories shark

Rev

Rev 1606 | 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
 
1606 tullio 18
/*
19
 * This program is free software; you can redistribute it and/or modify
20
 * it under the terms of the GNU General Public License as published by
21
 * the Free Software Foundation; either version 2 of the License, or
22
 * (at your option) any later version.
23
 *
24
 * This program is distributed in the hope that it will be useful,
25
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27
 * GNU General Public License for more details.
28
 *
29
 * You should have received a copy of the GNU General Public License
30
 * along with this program; if not, write to the Free Software
31
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
32
 *
33
 */
34
 
1491 giacomo 35
#include <stdio.h>
36
#include <unistd.h>
37
#include <stdlib.h>
38
#include <string.h>
39
 
40
#include <FTrace.h>
41
 
42
#define READ_BUFFER 2000
43
#define DELTA_BUFFER 100
44
 
45
int main(int argc, char *argv[])
46
{
47
 
48
  char buffer[READ_BUFFER+DELTA_BUFFER];
49
  void *p, *last;
1492 giacomo 50
  int n,delta,size,tsc;
1491 giacomo 51
 
52
  unsigned long long ev = 0, tsc_value;
53
 
54
  FILE *input_file;
55
 
56
  if (argc < 2) {
57
    printf("%s: Enter the input file name [%s filename]\n",argv[0],argv[0]);
58
    exit(1);
59
  }
60
 
61
  input_file = fopen(argv[1],"rb");
62
 
63
  last = buffer + READ_BUFFER;
64
 
65
  while(!feof(input_file)) {
66
 
67
    //move remaining byte
68
    delta = (unsigned int)(buffer) + READ_BUFFER - (unsigned int)(last);
69
    if (delta > 0) memcpy(buffer,last,delta);    
70
 
71
    n = fread(buffer+delta,1,READ_BUFFER+10,input_file);
72
    fseek(input_file,-(delta+10),SEEK_CUR);
73
 
74
    p = buffer;
1558 trimarchi 75
    /*
76
    // specific server events
77
    #define FTrace_EVT_server_create      0x08 // Par1 [empty] Par2 [server]
78
    #define FTrace_EVT_server_replenish   0x18 // Par1 [empty] Par2 [server]
79
    #define FTrace_EVT_server_exhaust     0x28 // Par1 [empty] Par2 [server]
80
    #define FTrace_EVT_server_reclaiming  0x38 // Par1 [empty] Par2 [server]
81
    #define FTrace_EVT_server_remove      0x48 // Par1 [empty] Par2 [server]
82
    #define FTrace_EVT_server_active      0x58 // Par1 [empty] Par2 [server]
83
    #define FTrace_EVT_server_using_rec   0x68 // Par1 [reclaiming] Par2 [server]
84
    */
1491 giacomo 85
 
86
    while ((unsigned int)(p) + 16 <= (unsigned int)(buffer + READ_BUFFER) &&
87
           (unsigned int)(p) + 16 <= (unsigned int)(buffer + n + delta)) {
88
 
1492 giacomo 89
        tsc = 0;
90
 
1510 giacomo 91
        switch (*(unsigned short int *)(p) & 0x00FF) {
1491 giacomo 92
 
93
          case FTrace_EVT_ipoint:
94
                printf("%d ",*(unsigned short int *)(p+2));
1492 giacomo 95
                tsc = 1;
1491 giacomo 96
                break;
97
 
1494 giacomo 98
          /* Tracer start */
1491 giacomo 99
          case FTrace_EVT_trace_start:
100
                printf("0 ");
1492 giacomo 101
                tsc = 1;
1491 giacomo 102
                break;
103
 
1494 giacomo 104
          /* Tracer stop */
1491 giacomo 105
          case FTrace_EVT_trace_stop:
106
                printf("1 ");
1492 giacomo 107
                tsc = 1;
1491 giacomo 108
                break;
109
 
1494 giacomo 110
          /* Interrupt start (int num) */
1491 giacomo 111
          case FTrace_EVT_timer_wakeup_start:
112
          case FTrace_EVT_interrupt_start:
113
                printf("2 ");
1492 giacomo 114
                tsc = 1;
1491 giacomo 115
                break;
116
 
1494 giacomo 117
          /* Interrupt Stop (int num, or context num is int 3) */
118
          case FTrace_EVT_timer_wakeup_end:
1491 giacomo 119
          case FTrace_EVT_interrupt_end:
120
                printf("3 ");
1492 giacomo 121
                tsc = 1;
1491 giacomo 122
                break;
123
 
1494 giacomo 124
          /* Context to (context num) */
1491 giacomo 125
          case FTrace_EVT_context_switch:
126
                printf("4 ");
1492 giacomo 127
                tsc = 1;
1491 giacomo 128
                break;
129
 
1494 giacomo 130
          /* Task Create (context num, pid num) */
131
          case FTrace_EVT_task_create:
132
                printf("5 ");
133
                tsc = 1;
134
                break;
135
 
136
          /* Task Activate (context num) */
137
          case FTrace_EVT_task_activate:
138
                printf("6 ");
139
                tsc = 1;
140
                break;
141
 
142
          /* Task End (context num) */
143
          case FTrace_EVT_task_end:
144
                printf("7 ");
145
                tsc = 1;
146
                break;
147
 
148
          /* Task End-Cycle (context num) */
149
          case FTrace_EVT_task_end_cycle:
150
                printf("8 ");
151
                tsc = 1;
152
                break;
153
 
1508 giacomo 154
          /* Task Context - PID declaration */
155
          case FTrace_EVT_id:
156
                printf("9 ");
157
                tsc = 1;
158
                break;
159
 
1517 giacomo 160
          case FTrace_EVT_cycles_per_msec:
161
                printf("10 ");
162
                tsc = 1;
163
                break;
1558 trimarchi 164
                // specific server events
1517 giacomo 165
 
1558 trimarchi 166
          case FTrace_EVT_server_active:
167
                printf("16 ");
168
                tsc=1;
169
                break;
170
 
1523 giacomo 171
          case FTrace_EVT_task_deadline_miss:
172
                printf("20 ");
173
                tsc = 1;
174
                break;
175
 
176
          case FTrace_EVT_task_wcet_violation:
177
                printf("21 ");
178
                tsc = 1;
179
                break;
180
 
1491 giacomo 181
        }
182
 
183
        tsc_value = (unsigned long long)(*(unsigned int *)(p+4)) << 32;
184
        tsc_value += (unsigned long long)(*(unsigned int *)(p+8));
185
 
1492 giacomo 186
        if (tsc == 1) {
1491 giacomo 187
 
1492 giacomo 188
          printf("%llu ",tsc_value);
189
 
1510 giacomo 190
          switch (*(unsigned short int *)(p) & 0x00FF) {
1492 giacomo 191
 
1520 giacomo 192
            case FTrace_EVT_trace_start:
193
                printf("%d %d ",*(unsigned short int *)(p+2),*(unsigned int *)(p+12));
194
                break;
195
 
1492 giacomo 196
            case FTrace_EVT_interrupt_start:
197
                printf("%d ",*(unsigned short int *)(p+2));
198
                break;
199
 
200
            case FTrace_EVT_timer_wakeup_start:
201
                printf("%d ",0);
202
                break;
203
 
204
            case FTrace_EVT_timer_wakeup_end:
205
            case FTrace_EVT_interrupt_end:
206
                printf("%d ",*(unsigned short int *)(p+2));
207
                break;
208
 
209
            case FTrace_EVT_context_switch:
210
                printf("%d ",*(unsigned short int *)(p+2));
211
                break;
212
 
1494 giacomo 213
            case FTrace_EVT_task_create:
214
                printf("%d %d",*(unsigned short int *)(p+2),*(unsigned int *)(p+12));
215
                break;
216
 
1523 giacomo 217
            case FTrace_EVT_task_deadline_miss:
218
                printf("%d %d",*(unsigned short int *)(p+2),*(unsigned int *)(p+12));
219
                break;
220
 
221
            case FTrace_EVT_task_wcet_violation:
222
                printf("%d %d",*(unsigned short int *)(p+2),*(unsigned int *)(p+12));
223
                break;
224
 
1494 giacomo 225
            case FTrace_EVT_task_activate:
226
                printf("%d ",*(unsigned short int *)(p+2));
227
                break;
228
 
229
            case FTrace_EVT_task_end_cycle:
230
                printf("%d ",*(unsigned short int *)(p+2));
231
                break;
232
 
233
            case FTrace_EVT_task_end:
234
                printf("%d ",*(unsigned short int *)(p+2));
235
                break;
236
 
1508 giacomo 237
            case FTrace_EVT_id:
238
                printf("%d %d",*(unsigned short int *)(p+2),*(unsigned int *)(p+12));
239
                break;
240
 
1517 giacomo 241
            case FTrace_EVT_cycles_per_msec:
242
                printf("%d ",*(unsigned int *)(p+12));
243
                break;
1558 trimarchi 244
 
1560 trimarchi 245
            case FTrace_EVT_server_active:
1558 trimarchi 246
                printf("%d %d",*(unsigned short int *)(p+2),*(unsigned int *)(p+12));
247
                break;
1492 giacomo 248
          }
249
 
250
          printf("\n");
251
 
252
        }
253
 
1491 giacomo 254
        size = 16;
255
 
256
      ev++;
257
 
258
      p += 16;
259
 
260
      if ((unsigned int)(p) + 10 > (unsigned int)(buffer + n + delta)) break;
261
 
262
      last = p;
263
 
264
    }
265
 
266
    if ((unsigned int)(p) + 10 > (unsigned int)(buffer + n + delta)) break;
267
 
268
  }
269
 
270
  fclose(input_file);
271
 
272
  return 0;
273
 
274
}
275