annotate target-utils/libload/cmd_memload.c @ 675:029f631b22ff

starting to compile ALR
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Mon, 29 Sep 2014 01:41:48 +0000
parents eee03b6ac615
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
40
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This module implements the ML (memory load) command, which will be
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * used by fc-chainload.
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 *
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 * The sole argument to the ML command is the body of an S3 record
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 * with the initial "S3" characters stripped, i.e., starting with the
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 * "count" byte, followed by the address, data and checksum bytes
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 * exactly as in the original S3 record.
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 */
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "types.h"
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 void
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 cmd_memload(argbulk)
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 char *argbulk;
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 {
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 char *argv[2], *s;
43
eee03b6ac615 loadagent: buglet in the ML command was breaking fc-xram; fixed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 40
diff changeset
18 u8 srecbin[256], cksum;
40
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 int len, i, c;
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 u32 addr;
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 if (parse_args(argbulk, 1, 1, argv, 0) < 0)
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 return;
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 s = argv[0];
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 if (decode_hex_digits(s, 2, &len) < 0) {
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 inv: printf("ERROR: ML argument is invalid\n");
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 return;
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 }
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 s += 2;
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 if (len < 6)
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 goto inv;
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 srecbin[0] = len;
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 for (i = 1; i <= len; i++) {
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 if (decode_hex_digits(s, 2, &c) < 0)
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 goto inv;
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 s += 2;
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 srecbin[i] = c;
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 }
43
eee03b6ac615 loadagent: buglet in the ML command was breaking fc-xram; fixed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 40
diff changeset
39 cksum = 0;
40
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 for (i = 0; i <= len; i++)
43
eee03b6ac615 loadagent: buglet in the ML command was breaking fc-xram; fixed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 40
diff changeset
41 cksum += srecbin[i];
eee03b6ac615 loadagent: buglet in the ML command was breaking fc-xram; fixed
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 40
diff changeset
42 if (cksum != 0xFF) {
40
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 printf("ERROR: bad ML S-record checksum\n");
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 return;
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 }
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 len -= 5;
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 addr = ((u32)srecbin[1] << 24) |
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 ((u32)srecbin[2] << 16) |
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 ((u32)srecbin[3] << 8) |
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 (u32)srecbin[4];
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 bcopy(srecbin + 5, addr, len);
9b4c5ce3db8b loadagent: ML command (support for fc-chainload) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 }