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