FreeCalypso > hg > freecalypso-sw
comparison ffstools/tiffs-rd/main.c @ 229:24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
| author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
|---|---|
| date | Sat, 25 Jan 2014 23:56:47 +0000 |
| parents | c04aa85559ed |
| children | ffaa033e7643 |
comparison
equal
deleted
inserted
replaced
| 228:3275c8881cb7 | 229:24ed817dd25d |
|---|---|
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| 11 #include <strings.h> | 11 #include <strings.h> |
| 12 #include "types.h" | 12 #include "types.h" |
| 13 | 13 |
| 14 u8 tiffs_header[6] = {'F', 'f', 's', '#', 0x10, 0x02}; | |
| 15 u8 blank_flash_line[16] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | |
| 16 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; | |
| 17 | |
| 18 char *imgfile; | 14 char *imgfile; |
| 19 u32 eraseblk_size; | 15 u32 eraseblk_size; |
| 20 int total_blocks; | 16 int total_blocks; |
| 21 u32 total_ffs_size; | 17 u32 total_ffs_size; |
| 22 int index_blk_num = -1, root_node_no; | 18 int index_blk_num = -1, root_node_no; |
| 23 int offset_blocks; | |
| 24 int verbose; | 19 int verbose; |
| 25 | 20 |
| 26 parse_org_arg(arg) | 21 parse_org_arg(arg) |
| 27 char *arg; | 22 char *arg; |
| 28 { | 23 { |
| 33 fprintf(stderr, | 28 fprintf(stderr, |
| 34 "error: TIFFS organization argument \"%s\" is invalid\n", arg); | 29 "error: TIFFS organization argument \"%s\" is invalid\n", arg); |
| 35 exit(1); | 30 exit(1); |
| 36 } | 31 } |
| 37 *cp++ = '\0'; | 32 *cp++ = '\0'; |
| 38 if (!strcmp(arg, "16")) | 33 if (!strcmp(arg, "8")) |
| 34 eraseblk_size = 0x2000; | |
| 35 else if (!strcmp(arg, "16")) | |
| 39 eraseblk_size = 0x4000; | 36 eraseblk_size = 0x4000; |
| 40 else if (!strcmp(arg, "32")) | 37 else if (!strcmp(arg, "32")) |
| 41 eraseblk_size = 0x8000; | 38 eraseblk_size = 0x8000; |
| 42 else if (!strcmp(arg, "64")) | 39 else if (!strcmp(arg, "64")) |
| 43 eraseblk_size = 0x10000; | 40 eraseblk_size = 0x10000; |
| 59 exit(1); | 56 exit(1); |
| 60 } | 57 } |
| 61 total_ffs_size = eraseblk_size * total_blocks; | 58 total_ffs_size = eraseblk_size * total_blocks; |
| 62 } | 59 } |
| 63 | 60 |
| 61 extern int cmd_blkhdr(); | |
| 62 | |
| 64 static struct cmdtab { | 63 static struct cmdtab { |
| 65 char *cmd; | 64 char *cmd; |
| 66 int (*func)(); | 65 int (*func)(); |
| 67 } cmdtab[] = { | 66 } cmdtab[] = { |
| 67 {"blkhdr", cmd_blkhdr}, | |
| 68 {"cat", NULL}, | 68 {"cat", NULL}, |
| 69 {"fsck", NULL}, | 69 {"fsck", NULL}, |
| 70 {"ls", NULL}, | 70 {"ls", NULL}, |
| 71 {"xtr", NULL}, | 71 {"xtr", NULL}, |
| 72 {NULL, NULL} | 72 {NULL, NULL} |
| 79 extern char *optarg; | 79 extern char *optarg; |
| 80 int c; | 80 int c; |
| 81 char *cmd; | 81 char *cmd; |
| 82 struct cmdtab *tp; | 82 struct cmdtab *tp; |
| 83 | 83 |
| 84 while ((c = getopt(argc, argv, "+a:o:r:v")) != EOF) | 84 while ((c = getopt(argc, argv, "+a:r:v")) != EOF) |
| 85 switch (c) { | 85 switch (c) { |
| 86 case 'a': | 86 case 'a': |
| 87 index_blk_num = atoi(optarg); | 87 index_blk_num = atoi(optarg); |
| 88 continue; | |
| 89 case 'o': | |
| 90 offset_blocks = atoi(optarg); | |
| 91 continue; | 88 continue; |
| 92 case 'r': | 89 case 'r': |
| 93 root_node_no = atoi(optarg); | 90 root_node_no = atoi(optarg); |
| 94 continue; | 91 continue; |
| 95 case 'v': | 92 case 'v': |
