changeset 16:4c78fc688127

w8/w16/w32 implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Fri, 03 May 2013 07:27:53 +0000
parents d60806c703aa
children 24b88c119465
files target-utils/helloapp/cmdtab.c target-utils/libcommon/Makefile target-utils/libcommon/cmd_w16.c target-utils/libcommon/cmd_w32.c target-utils/libcommon/cmd_w8.c
diffstat 5 files changed, 93 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/target-utils/helloapp/cmdtab.c	Fri May 03 07:00:12 2013 +0000
+++ b/target-utils/helloapp/cmdtab.c	Fri May 03 07:27:53 2013 +0000
@@ -3,10 +3,16 @@
 extern void cmd_r8();
 extern void cmd_r16();
 extern void cmd_r32();
+extern void cmd_w8();
+extern void cmd_w16();
+extern void cmd_w32();
 
 const struct cmdtab cmdtab[] = {
 	{"r8", cmd_r8},
 	{"r16", cmd_r16},
 	{"r32", cmd_r32},
+	{"w8", cmd_w8},
+	{"w16", cmd_w16},
+	{"w32", cmd_w32},
 	{0, 0}
 };
--- a/target-utils/libcommon/Makefile	Fri May 03 07:00:12 2013 +0000
+++ b/target-utils/libcommon/Makefile	Fri May 03 07:27:53 2013 +0000
@@ -5,7 +5,7 @@
 RANLIB=	arm-elf-ranlib
 
 OBJS=	cmdentry.o dispatch.o hexarg.o parseargs.o serio.o uartsel.o \
-	cmd_r8.o cmd_r16.o cmd_r32.o
+	cmd_r8.o cmd_r16.o cmd_r32.o cmd_w8.o cmd_w16.o cmd_w32.o
 
 all:	libcommon.a
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/target-utils/libcommon/cmd_w16.c	Fri May 03 07:27:53 2013 +0000
@@ -0,0 +1,30 @@
+/*
+ * w16 hexaddr xxxx -- write a 16-bit register or memory location
+ */
+
+#include <sys/types.h>
+#include "types.h"
+
+void
+cmd_w16(argbulk)
+	char *argbulk;
+{
+	char *argv[3];
+	u_long addr, data;
+
+	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 & 1) {
+		printf("ERROR: unaligned address\n");
+		return;
+	}
+	if (parse_hexarg(argv[1], 4, &data) < 0) {
+		printf("ERROR: arg2 must be a valid 16-bit hex value\n");
+		return;
+	}
+	*(volatile u16 *)addr = data;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/target-utils/libcommon/cmd_w32.c	Fri May 03 07:27:53 2013 +0000
@@ -0,0 +1,30 @@
+/*
+ * w32 hexaddr xxxxxxxx -- write a 32-bit register or memory location
+ */
+
+#include <sys/types.h>
+#include "types.h"
+
+void
+cmd_w32(argbulk)
+	char *argbulk;
+{
+	char *argv[3];
+	u_long addr, data;
+
+	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 & 3) {
+		printf("ERROR: unaligned address\n");
+		return;
+	}
+	if (parse_hexarg(argv[1], 8, &data) < 0) {
+		printf("ERROR: arg2 must be a valid 32-bit hex value\n");
+		return;
+	}
+	*(volatile u32 *)addr = data;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/target-utils/libcommon/cmd_w8.c	Fri May 03 07:27:53 2013 +0000
@@ -0,0 +1,26 @@
+/*
+ * w8 hexaddr xx -- write an 8-bit register or memory location
+ */
+
+#include <sys/types.h>
+#include "types.h"
+
+void
+cmd_w8(argbulk)
+	char *argbulk;
+{
+	char *argv[3];
+	u_long addr, data;
+
+	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 (parse_hexarg(argv[1], 2, &data) < 0) {
+		printf("ERROR: arg2 must be a valid 8-bit hex value\n");
+		return;
+	}
+	*(volatile u8 *)addr = data;
+}