changeset 988:5a6019ed7e72

pln-ppb-test: implement read-id
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 03 Dec 2023 00:04:18 +0000
parents 6b87de9e385b
children a5bff8104b45
files target-utils/pln-ppb-test/Makefile target-utils/pln-ppb-test/cmdtab.c target-utils/pln-ppb-test/read_id.c
diffstat 3 files changed, 31 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/target-utils/pln-ppb-test/Makefile	Sun Dec 03 00:01:03 2023 +0000
+++ b/target-utils/pln-ppb-test/Makefile	Sun Dec 03 00:04:18 2023 +0000
@@ -5,7 +5,7 @@
 OBJCOPY=arm-elf-objcopy
 
 PROG=	pln-ppb-test
-OBJS=	crt0.o cmdtab.o main.o mode_entry.o
+OBJS=	crt0.o cmdtab.o main.o mode_entry.o read_id.o
 LIBS=	../libcommon/libcommon.a ../libprintf/libprintf.a \
 	../libbase/libbase.a ../libc/libc.a
 LIBGCC=	`${CC} -print-file-name=libgcc.a`
--- a/target-utils/pln-ppb-test/cmdtab.c	Sun Dec 03 00:01:03 2023 +0000
+++ b/target-utils/pln-ppb-test/cmdtab.c	Sun Dec 03 00:04:18 2023 +0000
@@ -8,6 +8,7 @@
 extern void cmd_r8();
 extern void cmd_r16();
 extern void cmd_r32();
+extern void cmd_read_id();
 extern void cmd_w8();
 extern void cmd_w16();
 extern void cmd_w32();
@@ -33,6 +34,7 @@
 	{"r8", cmd_r8},
 	{"r16", cmd_r16},
 	{"r32", cmd_r32},
+	{"read-id", cmd_read_id},
 	{"w8", cmd_w8},
 	{"w16", cmd_w16},
 	{"w32", cmd_w32},
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/target-utils/pln-ppb-test/read_id.c	Sun Dec 03 00:04:18 2023 +0000
@@ -0,0 +1,28 @@
+/*
+ * read-id (Autoselect) command
+ */
+
+#include <sys/types.h>
+#include "types.h"
+
+void
+cmd_read_id(argbulk)
+	char *argbulk;
+{
+	char *argv[2];
+	u_long addr;
+
+	if (parse_args(argbulk, 1, 1, argv, 0) < 0)
+		return;
+	if (parse_hexarg(argv[0], 8, &addr) < 0) {
+		printf("ERROR: argument must be a valid 32-bit hex address\n");
+		return;
+	}
+	if (addr & 0xFFFF) {
+		printf("ERROR: address is not on 64 KiB boundary\n");
+		return;
+	}
+	*(volatile u16 *)(addr + 0xAAA) = 0xAA;
+	*(volatile u16 *)(addr + 0x554) = 0x55;
+	*(volatile u16 *)(addr + 0xAAA) = 0x90;
+}