changeset 986:676203b4bf33

pln-ppb-test: implement mode-entry
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 02 Dec 2023 23:50:07 +0000
parents d50df222c274
children 6b87de9e385b
files target-utils/pln-ppb-test/Makefile target-utils/pln-ppb-test/cmdtab.c target-utils/pln-ppb-test/mode_entry.c
diffstat 3 files changed, 35 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/target-utils/pln-ppb-test/Makefile	Sat Dec 02 23:39:33 2023 +0000
+++ b/target-utils/pln-ppb-test/Makefile	Sat Dec 02 23:50:07 2023 +0000
@@ -5,7 +5,7 @@
 OBJCOPY=arm-elf-objcopy
 
 PROG=	pln-ppb-test
-OBJS=	crt0.o cmdtab.o main.o
+OBJS=	crt0.o cmdtab.o main.o mode_entry.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	Sat Dec 02 23:39:33 2023 +0000
+++ b/target-utils/pln-ppb-test/cmdtab.c	Sat Dec 02 23:50:07 2023 +0000
@@ -3,6 +3,7 @@
 extern void cmd_abbr();
 extern void cmd_abbw();
 extern void cmd_jump();
+extern void cmd_mode_entry();
 extern void cmd_r8();
 extern void cmd_r16();
 extern void cmd_r32();
@@ -25,6 +26,7 @@
 	{"baud", cmd_baud_switch},
 	{"dump", cmd_memdump_human},
 	{"jump", cmd_jump},
+	{"mode-entry", cmd_mode_entry},
 	{"poweroff", abb_power_off},
 	{"r8", cmd_r8},
 	{"r16", cmd_r16},
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/target-utils/pln-ppb-test/mode_entry.c	Sat Dec 02 23:50:07 2023 +0000
@@ -0,0 +1,32 @@
+/*
+ * mode-entry and mode-exit commands
+ */
+
+#include <sys/types.h>
+#include "types.h"
+
+void
+cmd_mode_entry(argbulk)
+	char *argbulk;
+{
+	char *argv[3];
+	u_long addr, mode;
+
+	if (parse_args(argbulk, 2, 2, argv, 0) < 0)
+		return;
+	if (parse_hexarg(argv[0], 8, &addr) < 0) {
+		printf("ERROR: arg1 must be a valid 32-bit hex address\n");
+		return;
+	}
+	if (addr & 0xFFFF) {
+		printf("ERROR: address is not on 64 KiB boundary\n");
+		return;
+	}
+	if (parse_hexarg(argv[1], 4, &mode) < 0) {
+		printf("ERROR: arg2 must be a valid 16-bit hex value\n");
+		return;
+	}
+	*(volatile u16 *)(addr + 0xAAA) = 0xAA;
+	*(volatile u16 *)(addr + 0x554) = 0x55;
+	*(volatile u16 *)(addr + 0xAAA) = mode;
+}