annotate target-utils/libload/cmd_memdump_machine.c @ 19:c0e063494194

loadagent built with memory dump commands
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sat, 04 May 2013 00:25:30 +0000
parents
children 9ee91bc6057c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This is a machine-oriented memory dump command. The output is in the
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * form of S3 records.
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 */
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <sys/types.h>
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include "types.h"
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 void
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 cmd_memdump_machine(argbulk)
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 char *argbulk;
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 {
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 char *argv[3];
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 u_long start, length;
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 u_long addr;
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 u_char srbuf[0x86], cksum;
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 int i;
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 if (parse_args(argbulk, 2, 2, argv, 0) < 0)
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 return;
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 if (parse_hexarg(argv[0], 8, &start) < 0) {
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 printf("ERROR: arg1 must be a valid 32-bit hex address\n");
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 return;
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 }
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 if (parse_hexarg(argv[1], 2, &length) < 0) {
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 printf("ERROR: arg2 must be a valid 32-bit hex value (length)\n");
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 return;
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 }
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 if (start & 0x7F || length & 0x7F) {
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 printf("ERROR: implementation limit: 128-byte alignment required\n");
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 return;
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 }
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 srbuf[0] = 0x85;
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 for (addr = start; addr < start + length; addr += 0x80) {
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 srbuf[1] = addr >> 24;
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 srbuf[2] = addr >> 16;
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 srbuf[3] = addr >> 8;
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 srbuf[4] = addr;
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 bcopy(addr, srbuf + 5, 0x80);
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 cksum = 0;
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 for (i = 0; i < 0x85; i++)
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 cksum += srbuf[i];
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 srbuf[i] = ~cksum;
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 putchar('S');
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 putchar('3');
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 for (i = 0; i < 0x86; i++)
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 printf("%02X", srbuf[i]);
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 putchar('\n');
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 }
c0e063494194 loadagent built with memory dump commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 }