diff target-utils/dspdump/dumpops.c @ 542:b95b251b33eb

dspdump: bigdump command implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 28 Oct 2019 20:42:06 +0000
parents target-utils/dspdump/mandump.c@27b5526ba1a8
children 947c6a443a9c
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/target-utils/dspdump/dumpops.c	Mon Oct 28 20:42:06 2019 +0000
@@ -0,0 +1,97 @@
+#include <sys/types.h>
+#include "types.h"
+#include "leadapi.h"
+
+void
+cmd_dump(argbulk)
+	char *argbulk;
+{
+	char *argv[4];
+	u_long mode, addr, len;
+	int rc;
+	volatile u16 *api;
+	unsigned n;
+
+	if (parse_args(argbulk, 3, 3, argv, 0) < 0)
+		return;
+	if (parse_hexarg(argv[0], 4, &mode) < 0) {
+		printf("ERROR: mode must be a valid 16-bit hex value\n");
+		return;
+	}
+	if (parse_hexarg(argv[1], 8, &addr) < 0) {
+		printf("ERROR: addr must be a valid 32-bit hex value\n");
+		return;
+	}
+	if (parse_hexarg(argv[2], 4, &len) < 0) {
+		printf("ERROR: len must be a valid 16-bit hex value\n");
+		return;
+	}
+	rc = boot_dsp_dump_agent();
+	if (rc < 0)
+		return;		/* error msg already printed */
+	rc = dsp_read_op((u16)mode, (u32)addr, (u16)len);
+	if (rc < 0) {
+		printf("ERROR: DSP timeout on read operation\n");
+		return;
+	}
+	api = (volatile u16 *) APIF_ADDR;
+	for (n = 0; n < len; n++)
+		printf("%04X\n", *api++);
+}
+
+dump_large_section(mode, addr, len)
+	u16 mode;
+	u32 addr, len;
+{
+	u32 chunk, remain;
+	volatile u16 *api;
+	int rc;
+
+	for (remain = len; remain; remain -= chunk) {
+		chunk = remain;
+		if (chunk > MAX_BLOCK_SIZE)
+			chunk = MAX_BLOCK_SIZE;
+		rc = dsp_read_op(mode, addr, chunk);
+		if (rc < 0) {
+			printf("ERROR: DSP timeout on read operation\n");
+			return(rc);
+		}
+		api = (volatile u16 *) APIF_ADDR;
+		for (; chunk; chunk--) {
+			if (!(addr & 0xF))
+				printf("%05x : ", addr);
+			printf("%04x%c", *api++, ((addr&15)==15)?'\n':' ');
+			addr++;
+		}
+	}
+	putchar('\n');
+	return(0);
+}
+
+void
+cmd_bigdump(argbulk)
+	char *argbulk;
+{
+	char *argv[4];
+	u_long mode, addr, len;
+	int rc;
+
+	if (parse_args(argbulk, 3, 3, argv, 0) < 0)
+		return;
+	if (parse_hexarg(argv[0], 4, &mode) < 0) {
+		printf("ERROR: mode must be a valid 16-bit hex value\n");
+		return;
+	}
+	if (parse_hexarg(argv[1], 8, &addr) < 0) {
+		printf("ERROR: addr must be a valid 32-bit hex value\n");
+		return;
+	}
+	if (parse_hexarg(argv[2], 8, &len) < 0) {
+		printf("ERROR: len must be a valid 32-bit hex value\n");
+		return;
+	}
+	rc = boot_dsp_dump_agent();
+	if (rc < 0)
+		return;		/* error msg already printed */
+	dump_large_section((u16)mode, (u32)addr, (u32)len);
+}