Rev 1412 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1296 | 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> |
||
1568 | tullio | 10 | * Tullio Facchinetti <tullio.facchinetti@unipv.it> |
1296 | giacomo | 11 | * |
12 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
13 | * |
||
14 | * http://www.sssup.it |
||
15 | * http://retis.sssup.it |
||
16 | * http://shark.sssup.it |
||
1568 | tullio | 17 | * http://robot.unipv.it |
1296 | giacomo | 18 | */ |
19 | |||
20 | #include <stdio.h> |
||
21 | #include <unistd.h> |
||
22 | #include <stdlib.h> |
||
23 | #include <string.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; |
||
1365 | giacomo | 33 | int n,delta,size; |
1568 | tullio | 34 | |
35 | unsigned long long tsc_value; |
||
1296 | giacomo | 36 | |
1297 | giacomo | 37 | unsigned long long ev = 0; |
38 | |||
1296 | giacomo | 39 | FILE *input_file; |
40 | |||
41 | if (argc < 2) { |
||
42 | printf("%s: Enter the input file name [%s filename]\n",argv[0],argv[0]); |
||
43 | exit(1); |
||
44 | } |
||
45 | |||
46 | input_file = fopen(argv[1],"rb"); |
||
47 | |||
48 | last = buffer + READ_BUFFER; |
||
49 | |||
50 | while(!feof(input_file)) { |
||
51 | |||
52 | //move remaining byte |
||
53 | delta = (unsigned int)(buffer) + READ_BUFFER - (unsigned int)(last); |
||
54 | if (delta > 0) memcpy(buffer,last,delta); |
||
55 | |||
1301 | giacomo | 56 | n = fread(buffer+delta,1,READ_BUFFER+10,input_file); |
57 | fseek(input_file,-(delta+10),SEEK_CUR); |
||
1296 | giacomo | 58 | |
59 | p = buffer; |
||
60 | |||
1365 | giacomo | 61 | while ((unsigned int)(p) + 16 <= (unsigned int)(buffer + READ_BUFFER) && |
62 | (unsigned int)(p) + 16 <= (unsigned int)(buffer + n + delta)) { |
||
1296 | giacomo | 63 | |
1365 | giacomo | 64 | printf("%08d Type = %02x ",(unsigned int)ev,*(unsigned short int *)(p)); |
1296 | giacomo | 65 | |
1568 | tullio | 66 | tsc_value = (unsigned long long)(*(unsigned int *)(p+4)) << 32; |
67 | tsc_value += (unsigned long long)(*(unsigned int *)(p+8)); |
||
68 | |||
69 | printf("TSC = %llu (%08x:%08x)",tsc_value, *(unsigned int *)(p+4),*(unsigned int *)(p+8)); |
||
1296 | giacomo | 70 | |
1365 | giacomo | 71 | size = 16; |
1296 | giacomo | 72 | |
1568 | tullio | 73 | printf(" Par1 = %11d",*(unsigned short int *)(p+2)); |
74 | printf(" Par2 = %11d\n",*(unsigned int *)(p+12)); |
||
1301 | giacomo | 75 | |
1297 | giacomo | 76 | ev++; |
77 | |||
1365 | giacomo | 78 | p += 16; |
1301 | giacomo | 79 | |
80 | if ((unsigned int)(p) + 10 > (unsigned int)(buffer + n + delta)) break; |
||
81 | |||
1296 | giacomo | 82 | last = p; |
1297 | giacomo | 83 | |
1296 | giacomo | 84 | } |
1301 | giacomo | 85 | |
86 | if ((unsigned int)(p) + 10 > (unsigned int)(buffer + n + delta)) break; |
||
1296 | giacomo | 87 | |
88 | } |
||
89 | |||
90 | fclose(input_file); |
||
91 | |||
92 | return 0; |
||
93 | |||
94 | } |
||
95 |