diff target-utils/libcommon/abbcmd.c @ 0:e7502631a0f9

initial import from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 11 Jun 2016 00:13:35 +0000
parents
children 4be951811791
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/target-utils/libcommon/abbcmd.c	Sat Jun 11 00:13:35 2016 +0000
@@ -0,0 +1,51 @@
+/*
+ * abbr pg reg		-- read ABB register
+ * abbw pg reg val	-- write ABB register
+ */
+
+#include <sys/types.h>
+#include "types.h"
+#include "abbdefs.h"
+
+extern u16 abb_reg_read();
+extern void abb_reg_write();
+
+void
+cmd_abbr(argbulk)
+	char *argbulk;
+{
+	char *argv[3];
+	u32 pg, reg, val;
+
+	if (parse_args(argbulk, 2, 2, argv, 0) < 0)
+		return;
+	pg = strtoul(argv[0], 0, 0);
+	reg = strtoul(argv[1], 0, 0);
+	if (pg > 1 || reg > 31) {
+		printf("ERROR: argument(s) out of range\n");
+		return;
+	}
+	abb_init();
+	val = abb_reg_read(PAGE(pg) | reg);
+	printf("%03X\n", val);
+}
+
+void
+cmd_abbw(argbulk)
+	char *argbulk;
+{
+	char *argv[4];
+	u32 pg, reg, val;
+
+	if (parse_args(argbulk, 3, 3, argv, 0) < 0)
+		return;
+	pg = strtoul(argv[0], 0, 0);
+	reg = strtoul(argv[1], 0, 0);
+	val = strtoul(argv[2], 0, 16);
+	if (pg > 1 || reg > 31 || val > 0x3FF) {
+		printf("ERROR: argument(s) out of range\n");
+		return;
+	}
+	abb_init();
+	abb_reg_write(PAGE(pg) | reg, val);
+}