When changing playback speed write the current speed to OSD only after
[mplayer.git] / TOOLS / mem2dump.c
blob9a0969480358d8983dd85805ad328cfd6c4ed9e0
1 /*
2 bios2dump.c - Was designed to dump memory block to file.
3 Usage: as argument requires absolute address of memory dump and its lenght
4 (int hexadecimal form).
5 as output - will write file which will named: memADDR_LEN.dump
6 where: ADDR - given address of memory
7 LEN - given length of memory
8 Licence: GNU GPL v2
9 Copyright: Nick Kurshev <nickols_k@mail.ru>
11 #include <stdio.h>
12 #include <stdlib.h>
14 int main( int argc, char *argv[])
16 FILE * fd_mem, *fd_out;
17 unsigned long i,addr,len;
18 int int_no;
19 char outname[80];
20 unsigned char ch;
21 if(argc < 3)
23 printf("Usage: %s address length (in hex)\n",argv[0]);
24 return EXIT_FAILURE;
26 addr = strtol(argv[1],NULL,16);
27 len = strtol(argv[2],NULL,16);
28 if(!(fd_mem = fopen("/dev/mem","rb")))
30 perror("Can't open file - /dev/mem");
31 return EXIT_FAILURE;
33 sprintf(outname,"mem%08X_%08X.dump",addr,len);
34 if(!(fd_out = fopen(outname,"wb")))
36 perror("Can't open output file");
37 fclose(fd_mem);
38 return EXIT_FAILURE;
40 fseek(fd_mem,addr,SEEK_SET);
41 for(i=0;i<len;i++)
43 fread(&ch,1,1,fd_mem);
44 fwrite(&ch,1,1,fd_out);
46 fclose(fd_out);
47 fclose(fd_mem);
48 return EXIT_SUCCESS;