FreeCalypso > hg > freecalypso-sw
annotate target-utils/libload/cmd_blankchk.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 | d67bfcb9e351 |
children |
rev | line source |
---|---|
39
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * Flash blank check command |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 */ |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include <sys/types.h> |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include "types.h" |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 void |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 cmd_blankchk(argbulk) |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 char *argbulk; |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 { |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 char *argv[3]; |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 u_long start, length; |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 u_long addr; |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 int c; |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 if (parse_args(argbulk, 2, 2, argv, 0) < 0) |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 return; |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 if (parse_hexarg(argv[0], 8, &start) < 0) { |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 printf("ERROR: arg1 must be a valid 32-bit hex address\n"); |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 return; |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 } |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 if (parse_hexarg(argv[1], 8, &length) < 0) { |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 printf("ERROR: arg2 must be a valid 32-bit hex value (length)\n"); |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 return; |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 } |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 for (addr = start; addr < start + length; addr++) { |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 c = *(volatile u8 *)addr; |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 if (c != 0xFF) { |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 printf("Not blank: %02X at %08X\n", c, addr); |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 return; |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 } |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 } |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 printf("OK\n"); |
d67bfcb9e351
loadagent: blankchk command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 } |