FreeCalypso > hg > freecalypso-sw
view 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 |
line wrap: on
line source
/* * Functions for reading memory regions and Calypso die ID via ETM */ #include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include "etm.h" #include "limits.h" #include "localtypes.h" #include "exitcodes.h" extern u_char rvi_msg[]; extern int rvi_msg_len; do_memory_read(memaddr, databuf, nbytes) u32 memaddr; u_char *databuf; { u_char cmdpkt[10]; int rc; if (nbytes > MAX_MEMREAD_BYTES) { printf("error: # of bytes to read may not exceed %d\n", MAX_MEMREAD_BYTES); return(ERROR_USAGE); } cmdpkt[1] = ETM_CORE; cmdpkt[2] = TMCORE_OPC_MEM; cmdpkt[3] = 0x01; cmdpkt[4] = nbytes; cmdpkt[5] = memaddr; cmdpkt[6] = memaddr >> 8; cmdpkt[7] = memaddr >> 16; cmdpkt[8] = memaddr >> 24; rc = etm_pkt_exch(cmdpkt, 8); if (rc) return(rc); if (rvi_msg[3]) { printf("ETM error response to mem read request: 0x%02X\n", rvi_msg[3]); return(ERROR_TARGET); } if (rvi_msg_len != nbytes + 7) { printf("error: mem read response has wrong length\n"); return(ERROR_TARGET); } if (rvi_msg[4] != TMCORE_OPC_MEM || rvi_msg[5] != 0x01) { printf("error: mem read response has wrong opcode\n"); return(ERROR_TARGET); } bcopy(rvi_msg + 6, databuf, nbytes); return(0); } do_memory_read_16(memaddr, databuf, nwords) u32 memaddr; u_char *databuf; { u_char cmdpkt[10]; int rc; if (nwords > MAX_MEMREAD_16BIT) { printf("error: # of 16-bit words to read may not exceed %d\n", MAX_MEMREAD_16BIT); return(ERROR_USAGE); } cmdpkt[1] = ETM_CORE; cmdpkt[2] = TMCORE_OPC_MEM; cmdpkt[3] = 0x02; cmdpkt[4] = nwords; cmdpkt[5] = memaddr; cmdpkt[6] = memaddr >> 8; cmdpkt[7] = memaddr >> 16; cmdpkt[8] = memaddr >> 24; rc = etm_pkt_exch(cmdpkt, 8); if (rc) return(rc); if (rvi_msg[3]) { printf("ETM error response to mem read 16 request: 0x%02X\n", rvi_msg[3]); return(ERROR_TARGET); } if (rvi_msg_len != nwords * 2 + 7) { printf("error: mem read 16 response has wrong length\n"); return(ERROR_TARGET); } if (rvi_msg[4] != TMCORE_OPC_MEM || rvi_msg[5] != 0x02) { printf("error: mem read 16 response has wrong opcode\n"); return(ERROR_TARGET); } bcopy(rvi_msg + 6, databuf, nwords * 2); return(0); } do_dieid_read(databuf) u_char *databuf; { u_char cmdpkt[4]; int rc; cmdpkt[1] = ETM_CORE; cmdpkt[2] = TMCORE_OPC_DIEID; rc = etm_pkt_exch(cmdpkt, 2); if (rc) return(rc); if (rvi_msg[3]) { printf("ETM error response to die ID read request: 0x%02X\n", rvi_msg[3]); return(ERROR_TARGET); } if (rvi_msg_len != 14) { printf("error: die ID read response has wrong length\n"); return(ERROR_TARGET); } if (rvi_msg[4] != TMCORE_OPC_DIEID) { printf("error: die ID read response has wrong opcode\n"); return(ERROR_TARGET); } bcopy(rvi_msg + 5, databuf, 8); return(0); }