FreeCalypso > hg > freecalypso-sw
annotate rvinterf/etmsync/memops.c @ 940:0fb9b7f2ef87
gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Sat, 31 Oct 2015 23:39:41 +0000 |
parents | 38c7078712ab |
children | ce0ded19a769 |
rev | line source |
---|---|
911
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * Functions for reading memory regions and Calypso die ID via ETM |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 */ |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include <sys/types.h> |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <stdio.h> |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <stdlib.h> |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <string.h> |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <strings.h> |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include "etm.h" |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include "limits.h" |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 #include "localtypes.h" |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 #include "exitcodes.h" |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 extern u_char rvi_msg[]; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 extern int rvi_msg_len; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 do_memory_read(memaddr, databuf, nbytes) |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 u32 memaddr; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 u_char *databuf; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 { |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 u_char cmdpkt[10]; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 int rc; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 if (nbytes > MAX_MEMREAD_BYTES) { |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 printf("error: # of bytes to read may not exceed %d\n", |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 MAX_MEMREAD_BYTES); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 return(ERROR_USAGE); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 } |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 cmdpkt[1] = ETM_CORE; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 cmdpkt[2] = TMCORE_OPC_MEM; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 cmdpkt[3] = 0x01; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 cmdpkt[4] = nbytes; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 cmdpkt[5] = memaddr; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 cmdpkt[6] = memaddr >> 8; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 cmdpkt[7] = memaddr >> 16; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 cmdpkt[8] = memaddr >> 24; |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 rc = etm_pkt_exch(cmdpkt, 8); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 if (rc) |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 return(rc); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 if (rvi_msg[3]) { |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 printf("ETM error response to mem read request: 0x%02X\n", |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 rvi_msg[3]); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 return(ERROR_TARGET); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 } |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 if (rvi_msg_len != nbytes + 7) { |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 printf("error: mem read response has wrong length\n"); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 return(ERROR_TARGET); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 } |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 if (rvi_msg[4] != TMCORE_OPC_MEM || rvi_msg[5] != 0x01) { |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 printf("error: mem read response has wrong opcode\n"); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 return(ERROR_TARGET); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 } |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 bcopy(rvi_msg + 6, databuf, nbytes); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 return(0); |
42719fa3e6af
etmsync: memory read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 } |
912
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
57 |
921
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
58 do_memory_read_16(memaddr, databuf, nwords) |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
59 u32 memaddr; |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
60 u_char *databuf; |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
61 { |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
62 u_char cmdpkt[10]; |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
63 int rc; |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
64 |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
65 if (nwords > MAX_MEMREAD_16BIT) { |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
66 printf("error: # of 16-bit words to read may not exceed %d\n", |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
67 MAX_MEMREAD_16BIT); |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
68 return(ERROR_USAGE); |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
69 } |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
70 cmdpkt[1] = ETM_CORE; |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
71 cmdpkt[2] = TMCORE_OPC_MEM; |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
72 cmdpkt[3] = 0x02; |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
73 cmdpkt[4] = nwords; |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
74 cmdpkt[5] = memaddr; |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
75 cmdpkt[6] = memaddr >> 8; |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
76 cmdpkt[7] = memaddr >> 16; |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
77 cmdpkt[8] = memaddr >> 24; |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
78 rc = etm_pkt_exch(cmdpkt, 8); |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
79 if (rc) |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
80 return(rc); |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
81 if (rvi_msg[3]) { |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
82 printf("ETM error response to mem read 16 request: 0x%02X\n", |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
83 rvi_msg[3]); |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
84 return(ERROR_TARGET); |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
85 } |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
86 if (rvi_msg_len != nwords * 2 + 7) { |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
87 printf("error: mem read 16 response has wrong length\n"); |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
88 return(ERROR_TARGET); |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
89 } |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
90 if (rvi_msg[4] != TMCORE_OPC_MEM || rvi_msg[5] != 0x02) { |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
91 printf("error: mem read 16 response has wrong opcode\n"); |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
92 return(ERROR_TARGET); |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
93 } |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
94 bcopy(rvi_msg + 6, databuf, nwords * 2); |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
95 return(0); |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
96 } |
38c7078712ab
fc-dspapidump utility written, compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
912
diff
changeset
|
97 |
912
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
98 do_dieid_read(databuf) |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
99 u_char *databuf; |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
100 { |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
101 u_char cmdpkt[4]; |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
102 int rc; |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
103 |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
104 cmdpkt[1] = ETM_CORE; |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
105 cmdpkt[2] = TMCORE_OPC_DIEID; |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
106 rc = etm_pkt_exch(cmdpkt, 2); |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
107 if (rc) |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
108 return(rc); |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
109 if (rvi_msg[3]) { |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
110 printf("ETM error response to die ID read request: 0x%02X\n", |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
111 rvi_msg[3]); |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
112 return(ERROR_TARGET); |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
113 } |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
114 if (rvi_msg_len != 14) { |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
115 printf("error: die ID read response has wrong length\n"); |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
116 return(ERROR_TARGET); |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
117 } |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
118 if (rvi_msg[4] != TMCORE_OPC_DIEID) { |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
119 printf("error: die ID read response has wrong opcode\n"); |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
120 return(ERROR_TARGET); |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
121 } |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
122 bcopy(rvi_msg + 5, databuf, 8); |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
123 return(0); |
f50c71442d50
etmsync: die ID read implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
911
diff
changeset
|
124 } |