Rev 1301 | 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> |
||
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 | #define READ_BUFFER 2000 |
||
24 | #define DELTA_BUFFER 100 |
||
25 | |||
26 | int main(int argc, char *argv[]) |
||
27 | { |
||
28 | |||
29 | char buffer[READ_BUFFER+DELTA_BUFFER]; |
||
30 | void *p, *last; |
||
31 | int n,i,delta,size; |
||
32 | |||
1297 | giacomo | 33 | unsigned long long ev = 0; |
34 | |||
1296 | giacomo | 35 | FILE *input_file; |
36 | |||
37 | if (argc < 2) { |
||
38 | printf("%s: Enter the input file name [%s filename]\n",argv[0],argv[0]); |
||
39 | exit(1); |
||
40 | } |
||
41 | |||
42 | input_file = fopen(argv[1],"rb"); |
||
43 | |||
44 | last = buffer + READ_BUFFER; |
||
45 | |||
46 | while(!feof(input_file)) { |
||
47 | |||
48 | //move remaining byte |
||
49 | delta = (unsigned int)(buffer) + READ_BUFFER - (unsigned int)(last); |
||
50 | if (delta > 0) memcpy(buffer,last,delta); |
||
51 | |||
1301 | giacomo | 52 | n = fread(buffer+delta,1,READ_BUFFER+10,input_file); |
53 | fseek(input_file,-(delta+10),SEEK_CUR); |
||
1296 | giacomo | 54 | |
55 | p = buffer; |
||
56 | |||
1297 | giacomo | 57 | while ((unsigned int)(p) + *(unsigned char *)(p+9) <= (unsigned int)(buffer + READ_BUFFER) && |
58 | (unsigned int)(p) + *(unsigned char *)(p+9) <= (unsigned int)(buffer + n + delta)) { |
||
1296 | giacomo | 59 | |
1297 | giacomo | 60 | printf("%08d Type = %02x ",(unsigned int)ev,*(unsigned char *)(p)); |
1296 | giacomo | 61 | |
1301 | giacomo | 62 | printf("TSC = %08x:%08x",*(unsigned int *)(p+1),*(unsigned int *)(p+5)); |
1296 | giacomo | 63 | |
64 | size = *(unsigned char *)(p+9); |
||
65 | |||
1301 | giacomo | 66 | if (*(unsigned char *)(p) == 0x6e) { |
67 | exit(2); |
||
68 | } |
||
69 | |||
1296 | giacomo | 70 | size -= 10; |
71 | i = 0; |
||
72 | while (size > 0) { |
||
1322 | giacomo | 73 | printf(" Par%d = %d",i,*(unsigned int *)(p+10+i*4)); |
1296 | giacomo | 74 | i++; |
75 | size -= 4; |
||
76 | } |
||
77 | |||
78 | printf("\n"); |
||
79 | |||
1297 | giacomo | 80 | ev++; |
81 | |||
82 | p += *(unsigned char *)(p+9); |
||
1301 | giacomo | 83 | |
84 | if ((unsigned int)(p) + 10 > (unsigned int)(buffer + n + delta)) break; |
||
85 | |||
1296 | giacomo | 86 | last = p; |
1297 | giacomo | 87 | |
1296 | giacomo | 88 | } |
1301 | giacomo | 89 | |
90 | if ((unsigned int)(p) + 10 > (unsigned int)(buffer + n + delta)) break; |
||
1296 | giacomo | 91 | |
92 | } |
||
93 | |||
94 | fclose(input_file); |
||
95 | |||
96 | return 0; |
||
97 | |||
98 | } |
||
99 |