changeset 26:1a3bbab2ea26

loadagent: jump command implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sat, 04 May 2013 05:38:58 +0000
parents 796da8d60b23
children ae6294b8a015
files target-utils/libcommon/Makefile target-utils/libcommon/cmd_jump.c target-utils/libcommon/serflush.S target-utils/loadagent/cmdtab.c
diffstat 4 files changed, 40 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/target-utils/libcommon/Makefile	Sat May 04 05:02:04 2013 +0000
+++ b/target-utils/libcommon/Makefile	Sat May 04 05:38:58 2013 +0000
@@ -4,8 +4,8 @@
 AR=	arm-elf-ar
 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_w8.o cmd_w16.o cmd_w32.o
+OBJS=	cmdentry.o dispatch.o hexarg.o parseargs.o serio.o serflush.o uartsel.o\
+	cmd_jump.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_jump.c	Sat May 04 05:38:58 2013 +0000
@@ -0,0 +1,24 @@
+/*
+ * jump hexaddr -- transfer control with BX
+ */
+
+#include <sys/types.h>
+#include "types.h"
+
+void
+cmd_jump(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;
+	}
+	serial_flush();
+	asm volatile ("bx %0" : : "r" (addr));
+	__builtin_unreachable();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/target-utils/libcommon/serflush.S	Sat May 04 05:38:58 2013 +0000
@@ -0,0 +1,12 @@
+#include "ns16550.h"
+
+	.text
+	.code	32
+	.global	serial_flush
+serial_flush:
+	ldr	r1, =uart_base
+	ldr	r2, [r1]
+1:	ldrb	r3, [r2, #NS16550_LSR]
+	tst	r3, #NS16550_LSR_TEMP
+	beq	1b
+	bx	lr
--- a/target-utils/loadagent/cmdtab.c	Sat May 04 05:02:04 2013 +0000
+++ b/target-utils/loadagent/cmdtab.c	Sat May 04 05:38:58 2013 +0000
@@ -1,5 +1,6 @@
 #include "cmdtab.h"
 
+extern void cmd_jump();
 extern void cmd_r8();
 extern void cmd_r16();
 extern void cmd_r32();
@@ -13,6 +14,7 @@
 const struct cmdtab cmdtab[] = {
 	{"DUMP", cmd_memdump_machine},
 	{"dump", cmd_memdump_human},
+	{"jump", cmd_jump},
 	{"r8", cmd_r8},
 	{"r16", cmd_r16},
 	{"r32", cmd_r32},