FreeCalypso > hg > freecalypso-hwlab
annotate lcdtest/memops.c @ 69:1e6f05ede5ca
lunalcd: ppmtoimg utility added
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 07 May 2020 00:12:54 +0000 |
parents | de3d3cfcbb35 |
children |
rev | line source |
---|---|
28
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * Functions for ETM memory read requests |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdlib.h> |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <string.h> |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <strings.h> |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <rvinterf/etm.h> |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <rvinterf/limits.h> |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <rvinterf/localtypes.h> |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include "exitcodes.h" |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #ifndef MAX_MEMREAD_BYTES |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #define MAX_MEMREAD_BYTES 238 |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #endif |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 #ifndef MAX_MEMREAD_16BIT |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 #define MAX_MEMREAD_16BIT 119 |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 #endif |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 #ifndef MAX_MEMREAD_32BIT |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 #define MAX_MEMREAD_32BIT 59 |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 #endif |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 extern u_char rvi_msg[]; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 extern int rvi_msg_len; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 do_memory_read(memaddr, databuf, nbytes) |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 u32 memaddr; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 u_char *databuf; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 { |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 u_char cmdpkt[10]; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 int rc; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 if (nbytes > MAX_MEMREAD_BYTES) { |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 printf("error: # of bytes to read may not exceed %d\n", |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 MAX_MEMREAD_BYTES); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 return(ERROR_USAGE); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 } |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 cmdpkt[1] = ETM_CORE; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 cmdpkt[2] = TMCORE_OPC_MEM; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 cmdpkt[3] = 0x01; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 cmdpkt[4] = nbytes; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 cmdpkt[5] = memaddr; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 cmdpkt[6] = memaddr >> 8; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 cmdpkt[7] = memaddr >> 16; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 cmdpkt[8] = memaddr >> 24; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 rc = etm_pkt_exch(cmdpkt, 8); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 if (rc) |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 return(rc); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 if (rvi_msg[3]) { |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 printf("ETM error response to mem read request: 0x%02X\n", |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 rvi_msg[3]); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 return(ERROR_TARGET); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 } |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 if (rvi_msg_len != nbytes + 7) { |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 printf("error: mem read response has wrong length\n"); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 return(ERROR_TARGET); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 } |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 if (rvi_msg[4] != TMCORE_OPC_MEM || rvi_msg[5] != 0x01) { |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 printf("error: mem read response has wrong opcode\n"); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 return(ERROR_TARGET); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 } |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 bcopy(rvi_msg + 6, databuf, nbytes); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 return(0); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 } |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 do_memory_read_16(memaddr, databuf, nwords) |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 u32 memaddr; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 u_char *databuf; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 { |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 u_char cmdpkt[10]; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 int rc; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 if (nwords > MAX_MEMREAD_16BIT) { |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 printf("error: # of 16-bit words to read may not exceed %d\n", |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 MAX_MEMREAD_16BIT); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 return(ERROR_USAGE); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 } |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 cmdpkt[1] = ETM_CORE; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 cmdpkt[2] = TMCORE_OPC_MEM; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 cmdpkt[3] = 0x02; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 cmdpkt[4] = nwords; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 cmdpkt[5] = memaddr; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 cmdpkt[6] = memaddr >> 8; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 cmdpkt[7] = memaddr >> 16; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 cmdpkt[8] = memaddr >> 24; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 rc = etm_pkt_exch(cmdpkt, 8); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 if (rc) |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 return(rc); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 if (rvi_msg[3]) { |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 printf("ETM error response to mem read 16 request: 0x%02X\n", |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 rvi_msg[3]); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 return(ERROR_TARGET); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 } |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 if (rvi_msg_len != nwords * 2 + 7) { |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 printf("error: mem read 16 response has wrong length\n"); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 return(ERROR_TARGET); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 } |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 if (rvi_msg[4] != TMCORE_OPC_MEM || rvi_msg[5] != 0x02) { |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 printf("error: mem read 16 response has wrong opcode\n"); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 return(ERROR_TARGET); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 } |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 bcopy(rvi_msg + 6, databuf, nwords * 2); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 return(0); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 } |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 do_memory_read_32(memaddr, databuf, nwords) |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 u32 memaddr; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 u_char *databuf; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 { |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 u_char cmdpkt[10]; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 int rc; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 if (nwords > MAX_MEMREAD_32BIT) { |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 printf("error: # of 32-bit words to read may not exceed %d\n", |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 MAX_MEMREAD_32BIT); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 return(ERROR_USAGE); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 } |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 cmdpkt[1] = ETM_CORE; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 cmdpkt[2] = TMCORE_OPC_MEM; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 cmdpkt[3] = 0x04; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 cmdpkt[4] = nwords; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 cmdpkt[5] = memaddr; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 cmdpkt[6] = memaddr >> 8; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 cmdpkt[7] = memaddr >> 16; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 cmdpkt[8] = memaddr >> 24; |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 rc = etm_pkt_exch(cmdpkt, 8); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 if (rc) |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 return(rc); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 if (rvi_msg[3]) { |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 printf("ETM error response to mem read 32 request: 0x%02X\n", |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 rvi_msg[3]); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 return(ERROR_TARGET); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 } |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 if (rvi_msg_len != nwords * 4 + 7) { |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 printf("error: mem read 32 response has wrong length\n"); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 return(ERROR_TARGET); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 } |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 if (rvi_msg[4] != TMCORE_OPC_MEM || rvi_msg[5] != 0x04 && rvi_msg[5]) { |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 printf("error: mem read 32 response has wrong opcode\n"); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 return(ERROR_TARGET); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 } |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 bcopy(rvi_msg + 6, databuf, nwords * 4); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 return(0); |
de3d3cfcbb35
lcdtest: lcdphone program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 } |