FreeCalypso > hg > freecalypso-sw
comparison rvinterf/etmsync/memops.c @ 911:42719fa3e6af
etmsync: memory read implemented
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Tue, 08 Sep 2015 07:52:29 +0000 |
parents | |
children | f50c71442d50 |
comparison
equal
deleted
inserted
replaced
910:d1333db6385f | 911:42719fa3e6af |
---|---|
1 /* | |
2 * Functions for reading memory regions and Calypso die ID via ETM | |
3 */ | |
4 | |
5 #include <sys/types.h> | |
6 #include <stdio.h> | |
7 #include <stdlib.h> | |
8 #include <string.h> | |
9 #include <strings.h> | |
10 #include "etm.h" | |
11 #include "limits.h" | |
12 #include "localtypes.h" | |
13 #include "exitcodes.h" | |
14 | |
15 extern u_char rvi_msg[]; | |
16 extern int rvi_msg_len; | |
17 | |
18 do_memory_read(memaddr, databuf, nbytes) | |
19 u32 memaddr; | |
20 u_char *databuf; | |
21 { | |
22 u_char cmdpkt[10]; | |
23 int rc; | |
24 | |
25 if (nbytes > MAX_MEMREAD_BYTES) { | |
26 printf("error: # of bytes to read may not exceed %d\n", | |
27 MAX_MEMREAD_BYTES); | |
28 return(ERROR_USAGE); | |
29 } | |
30 cmdpkt[1] = ETM_CORE; | |
31 cmdpkt[2] = TMCORE_OPC_MEM; | |
32 cmdpkt[3] = 0x01; | |
33 cmdpkt[4] = nbytes; | |
34 cmdpkt[5] = memaddr; | |
35 cmdpkt[6] = memaddr >> 8; | |
36 cmdpkt[7] = memaddr >> 16; | |
37 cmdpkt[8] = memaddr >> 24; | |
38 rc = etm_pkt_exch(cmdpkt, 8); | |
39 if (rc) | |
40 return(rc); | |
41 if (rvi_msg[3]) { | |
42 printf("ETM error response to mem read request: 0x%02X\n", | |
43 rvi_msg[3]); | |
44 return(ERROR_TARGET); | |
45 } | |
46 if (rvi_msg_len != nbytes + 7) { | |
47 printf("error: mem read response has wrong length\n"); | |
48 return(ERROR_TARGET); | |
49 } | |
50 if (rvi_msg[4] != TMCORE_OPC_MEM || rvi_msg[5] != 0x01) { | |
51 printf("error: mem read response has wrong opcode\n"); | |
52 return(ERROR_TARGET); | |
53 } | |
54 bcopy(rvi_msg + 6, databuf, nbytes); | |
55 return(0); | |
56 } |