Rev 1297 |
Rev 1365 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
/*
* Project: S.Ha.R.K.
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* Giacomo Guidi <giacomo@gandalf.sssup.it>
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://shark.sssup.it
*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#define READ_BUFFER 2000
#define DELTA_BUFFER 100
int main
(int argc
, char *argv
[])
{
char buffer
[READ_BUFFER
+DELTA_BUFFER
];
void *p
, *last
;
int n
,i
,delta
,size
;
unsigned long long ev
= 0;
FILE
*input_file
;
if (argc
< 2) {
printf("%s: Enter the input file name [%s filename]\n",argv
[0],argv
[0]);
exit(1);
}
input_file
= fopen(argv
[1],"rb");
last
= buffer
+ READ_BUFFER
;
while(!feof(input_file
)) {
//move remaining byte
delta
= (unsigned int)(buffer
) + READ_BUFFER
- (unsigned int)(last
);
if (delta
> 0) memcpy(buffer
,last
,delta
);
n
= fread(buffer
+delta
,1,READ_BUFFER
+10,input_file
);
fseek(input_file
,-(delta
+10),SEEK_CUR
);
p
= buffer
;
while ((unsigned int)(p
) + *(unsigned char *)(p
+9) <= (unsigned int)(buffer
+ READ_BUFFER
) &&
(unsigned int)(p
) + *(unsigned char *)(p
+9) <= (unsigned int)(buffer
+ n
+ delta
)) {
printf("%08d Type = %02x ",(unsigned int)ev
,*(unsigned char *)(p
));
printf("TSC = %08x:%08x",*(unsigned int *)(p
+1),*(unsigned int *)(p
+5));
size
= *(unsigned char *)(p
+9);
if (*(unsigned char *)(p
) == 0x6e) {
exit(2);
}
size
-= 10;
i
= 0;
while (size
> 0) {
printf("Par%d = %d ",i
,*(unsigned int *)(p
+10+i
*4));
i
++;
size
-= 4;
}
printf("\n");
ev
++;
p
+= *(unsigned char *)(p
+9);
if ((unsigned int)(p
) + 10 > (unsigned int)(buffer
+ n
+ delta
)) break;
last
= p
;
}
if ((unsigned int)(p
) + 10 > (unsigned int)(buffer
+ n
+ delta
)) break;
}
fclose(input_file
);
return 0;
}