FreeCalypso > hg > freecalypso-tools
comparison target-utils/loadagent/bindump.c @ 638:6562364b2033
loadagent: BINDUMP command implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 01 Mar 2020 18:14:56 +0000 |
parents | |
children | 963d15a808eb |
comparison
equal
deleted
inserted
replaced
637:fa8e197a1d9b | 638:6562364b2033 |
---|---|
1 /* | |
2 * Here we are going to implement a new memory dump command for use by | |
3 * fc-loadtool, sending the dump stream to the host in binary instead of hex | |
4 * S-records. | |
5 * | |
6 * We could send the entire stream continuously without any structure or | |
7 * breaks, but if we did that, fc-loadtool would not be able to detect a slip | |
8 * (byte loss error) in the serial stream until the end of the dump, | |
9 * potentially minutes long. For this reason we are taking a different | |
10 * approach: we are going to send the dump stream in blocks of 8192 bytes, | |
11 * with each block preceded by an 8-byte binary header. Loadtool will know | |
12 * and expect the same block structure, and seeing our block headers in the | |
13 * right positions in the stream will provide assurance of synchronization. | |
14 */ | |
15 | |
16 #include <sys/types.h> | |
17 #include "types.h" | |
18 | |
19 void | |
20 cmd_memdump_binary(argbulk) | |
21 char *argbulk; | |
22 { | |
23 char *argv[3]; | |
24 u_long start, length; | |
25 u_long addr, remlen, blklen; | |
26 int i; | |
27 | |
28 if (parse_args(argbulk, 2, 2, argv, 0) < 0) | |
29 return; | |
30 if (parse_hexarg(argv[0], 8, &start) < 0) { | |
31 printf("ERROR: arg1 must be a valid 32-bit hex address\n"); | |
32 return; | |
33 } | |
34 if (parse_hexarg(argv[1], 8, &length) < 0) { | |
35 printf("ERROR: arg2 must be a valid 32-bit hex value (length)\n"); | |
36 return; | |
37 } | |
38 addr = start; | |
39 for (remlen = length; remlen; remlen -= blklen) { | |
40 blklen = 8192; | |
41 if (remlen < blklen) | |
42 blklen = remlen; | |
43 serial_out(0x55); | |
44 serial_out(0xAA); | |
45 serial_out(addr >> 24); | |
46 serial_out(addr >> 16); | |
47 serial_out(addr >> 8); | |
48 serial_out(addr); | |
49 serial_out(blklen >> 8); | |
50 serial_out(blklen); | |
51 for (; blklen; blklen--) { | |
52 serial_out(*(volatile u8 *)addr); | |
53 addr++; | |
54 } | |
55 } | |
56 } |