changeset 921:38c7078712ab

fc-dspapidump utility written, compiles
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Sun, 18 Oct 2015 21:41:01 +0000
parents 7cb0b32f1997
children fb3f04a62f71
files .hgignore rvinterf/etmsync/Makefile rvinterf/etmsync/dspapidump.c rvinterf/etmsync/memops.c rvinterf/include/etm.h
diffstat 5 files changed, 88 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Tue Sep 08 23:33:38 2015 +0000
+++ b/.hgignore	Sun Oct 18 21:41:01 2015 +0000
@@ -28,6 +28,7 @@
 
 ^rvinterf/asyncshell/fc-shell$
 ^rvinterf/ctracedec/ctracedec$
+^rvinterf/etmsync/fc-dspapidump$
 ^rvinterf/etmsync/fc-fsio$
 ^rvinterf/etmsync/fc-getpirimei$
 ^rvinterf/etmsync/fc-pirhackinit$
--- a/rvinterf/etmsync/Makefile	Tue Sep 08 23:33:38 2015 +0000
+++ b/rvinterf/etmsync/Makefile	Sun Oct 18 21:41:01 2015 +0000
@@ -1,8 +1,11 @@
 CC=	gcc
 CFLAGS=	-O2 -I../include
-PROGS=	fc-fsio fc-getpirimei fc-pirhackinit
+PROGS=	fc-dspapidump fc-fsio fc-getpirimei fc-pirhackinit
 INSTBIN=/usr/local/bin
 
+DSPDUMP_OBJS=	connect.o dspapidump.o interf.o launchrvif.o memops.o \
+		simplemain.o
+
 FSIO_OBJS=	connect.o dispatch.o fdcmd.o fileio.o fsbasics.o fscmdtab.o \
 		fserr.o fsiomain.o fsmisc.o fspath.o fsread.o fsupload.o \
 		fswrite.o interf.o launchrvif.o memcmd.o memops.o rfcap.o \
@@ -16,6 +19,9 @@
 
 all:	${PROGS}
 
+fc-dspapidump:	${DSPDUMP_OBJS}
+	${CC} ${CFLAGS} -o $@ ${DSPDUMP_OBJS}
+
 fc-fsio:	${FSIO_OBJS}
 	${CC} ${CFLAGS} -o $@ ${FSIO_OBJS}
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/etmsync/dspapidump.c	Sun Oct 18 21:41:01 2015 +0000
@@ -0,0 +1,39 @@
+/*
+ * This utility uses ETM in synchronous mode to read and dump the contents
+ * of the DSP API RAM in a target Calypso GSM device while the firmware is
+ * running.
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <endian.h>
+#include "localtypes.h"
+#include "exitcodes.h"
+
+#define	APIF_ADDR		0xFFD00000
+#define	API_SIZE_IN_WORDS	0x2000
+
+single_op_main()
+{
+	u16 buf[64], *linebase;
+	unsigned off;
+	int rc, i, j;
+
+	for (off = 0; off < API_SIZE_IN_WORDS; ) {
+		rc = do_memory_read_16(APIF_ADDR + off * 2, buf, 0x40);
+		if (rc)
+			return(rc);
+		for (i = 0; i < 8; i++) {
+			printf("%04X:", off);
+			linebase = buf + i * 8;
+			for (j = 0; j < 8; j++)
+				printf(" %04X", linebase[j]);
+			putchar('\n');
+			off += 8;
+		}
+	}
+	return(0);
+}
--- a/rvinterf/etmsync/memops.c	Tue Sep 08 23:33:38 2015 +0000
+++ b/rvinterf/etmsync/memops.c	Sun Oct 18 21:41:01 2015 +0000
@@ -55,6 +55,46 @@
 	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;
 {
--- a/rvinterf/include/etm.h	Tue Sep 08 23:33:38 2015 +0000
+++ b/rvinterf/include/etm.h	Sun Oct 18 21:41:01 2015 +0000
@@ -50,3 +50,4 @@
 #define	TMCORE_OPC_DIEID	0x68
 
 #define	MAX_MEMREAD_BYTES	238
+#define	MAX_MEMREAD_16BIT	119