annotate rvinterf/tmsh/omr.c @ 1034:405b5469abc4 default tip

top README: repository change notice
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 12 Jun 2016 19:06:34 +0000
parents a0879ce32d2c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
978
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
2 * Old-style memory read command
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
3 */
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
4
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <sys/types.h>
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <stdio.h>
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <string.h>
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <strings.h>
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <stdlib.h>
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
10 #include "pktmux.h"
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "limits.h"
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "localtypes.h"
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "tm3.h"
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
14
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
15 extern u_char rvi_msg[];
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
16 extern int rvi_msg_len;
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
17
979
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
18 static void
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
19 memdump_line(off, inbuf, len)
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
20 u_char *inbuf;
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
21 {
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
22 char outbuf[80], *dp;
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
23 int i, c;
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
24
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
25 sprintf(outbuf, "omr %02X: ", off);
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
26 dp = index(outbuf, '\0');
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
27 for (i = 0; i < 16; i++) {
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
28 if (i < len)
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
29 sprintf(dp, "%02X ", inbuf[i]);
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
30 else
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
31 strcpy(dp, " ");
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
32 dp += 3;
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
33 if (i == 7 || i == 15)
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
34 *dp++ = ' ';
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
35 }
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
36 for (i = 0; i < len; i++) {
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
37 c = inbuf[i];
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
38 if (c < ' ' || c > '~')
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
39 c = '.';
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
40 *dp++ = c;
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
41 }
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
42 *dp = '\0';
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
43 async_msg_output(outbuf);
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
44 }
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
45
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
46 void
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
47 handle_omr_response()
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
48 {
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
49 int off, len;
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
50
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
51 if (rvi_msg[3]) {
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
52 print_etm_pkt_raw("TM3 memread error");
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
53 return;
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
54 }
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
55 if (rvi_msg_len < 10) {
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
56 bad: print_etm_pkt_raw("omr bad resp");
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
57 return;
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
58 }
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
59 if (rvi_msg[5] || rvi_msg[6] || rvi_msg[7])
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
60 goto bad;
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
61 if (rvi_msg_len != rvi_msg[4] + 9)
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
62 goto bad;
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
63 for (off = 0; off < rvi_msg[4]; off += len) {
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
64 len = rvi_msg[4] - off;
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
65 if (len > 16)
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
66 len = 16;
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
67 memdump_line(off, rvi_msg + 8 + off, len);
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
68 }
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
69 }
ebdf5afa9fb5 fc-tmsh: omr responses parsed and formatted in a readable manner
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 978
diff changeset
70
978
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
71 void
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
72 cmd_omr(argc, argv)
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
73 char **argv;
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
74 {
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
75 u32 addr, size;
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
76 u_char cmdpkt[11];
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
77
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
78 addr = strtoul(argv[1], 0, 16);
980
a0879ce32d2c fc-tmsh omr command: always interpret both arguments as hex
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 979
diff changeset
79 size = strtoul(argv[2], 0, 16);
978
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
80 if (size < 1 || size > TM3_MEMREAD_MAX) {
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
81 printf("error: count argument outside valid range\n");
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
82 return;
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
83 }
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
84 cmdpkt[1] = MEM_READ;
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
85 cmdpkt[2] = addr;
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
86 cmdpkt[3] = addr >> 8;
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
87 cmdpkt[4] = addr >> 16;
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
88 cmdpkt[5] = addr >> 24;
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
89 cmdpkt[6] = size;
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
90 cmdpkt[7] = 0;
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
91 cmdpkt[8] = 0;
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
92 cmdpkt[9] = 0;
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
93 send_etm_cmd(cmdpkt, 9);
1ee80bcb0fd0 fc-tmsh: omr (old-style memory read) command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
94 }