changeset 454:daaab2701761

target-utils: simtest program started
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 09 Feb 2019 07:55:50 +0000
parents 6228d27738d1
children bd465e30fc05
files target-utils/simtest/Makefile target-utils/simtest/cmdtab.c target-utils/simtest/main.c target-utils/simtest/poll.c target-utils/simtest/simregs.h
diffstat 5 files changed, 140 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/target-utils/simtest/Makefile	Sat Feb 09 07:55:50 2019 +0000
@@ -0,0 +1,29 @@
+CC=	arm-elf-gcc
+CFLAGS=	-Os -fno-builtin
+CPPFLAGS=-I../include
+LD=	arm-elf-ld
+OBJCOPY=arm-elf-objcopy
+
+PROG=	simtest
+OBJS=	crt0.o cmdtab.o main.o poll.o
+LIBS=	../libcommon/libcommon.a ../libprintf/libprintf.a ../libbase/libbase.a \
+	../libc/libc.a
+LIBGCC=	`${CC} -print-file-name=libgcc.a`
+LDS=	../env/iram.lds
+
+all:	${PROG}.srec
+
+crt0.S:	../env/crt0.S
+	ln -s $< .
+
+${PROG}.elf:	${OBJS} ${LIBS} ${LDS}
+	${LD} -N --defsym Base_addr=0x800750 --defsym stack_bottom=0x83FFFC \
+		-T ${LDS} -o $@ ${OBJS} ${LIBS} ${LIBGCC}
+
+${PROG}.srec:	${PROG}.elf
+	${OBJCOPY} -O srec --srec-forceS3 --srec-len=30 $< $@
+
+clean:
+	rm -f *.o *errs *core *.elf *.bin *.srec crt0.S
+
+FRC:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/target-utils/simtest/cmdtab.c	Sat Feb 09 07:55:50 2019 +0000
@@ -0,0 +1,34 @@
+#include "cmdtab.h"
+
+extern void cmd_abbr();
+extern void cmd_abbw();
+extern void cmd_jump();
+extern void cmd_poll();
+extern void cmd_r8();
+extern void cmd_r16();
+extern void cmd_r32();
+extern void cmd_w8();
+extern void cmd_w16();
+extern void cmd_w32();
+
+extern void cmd_memdump_human();
+
+extern void abb_init();
+extern void abb_power_off();
+
+const struct cmdtab cmdtab[] = {
+	{"abbinit", abb_init},
+	{"abbr", cmd_abbr},
+	{"abbw", cmd_abbw},
+	{"dump", cmd_memdump_human},
+	{"jump", cmd_jump},
+	{"poll", cmd_poll},
+	{"poweroff", abb_power_off},
+	{"r8", cmd_r8},
+	{"r16", cmd_r16},
+	{"r32", cmd_r32},
+	{"w8", cmd_w8},
+	{"w16", cmd_w16},
+	{"w32", cmd_w32},
+	{0, 0}
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/target-utils/simtest/main.c	Sat Feb 09 07:55:50 2019 +0000
@@ -0,0 +1,11 @@
+main()
+{
+	uart_select_init();
+	printf("SIM interface debug program running\n");
+	print_boot_rom_info();
+	for (;;) {
+		putchar('=');
+		if (command_entry())
+			command_dispatch();
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/target-utils/simtest/poll.c	Sat Feb 09 07:55:50 2019 +0000
@@ -0,0 +1,49 @@
+#include <sys/types.h>
+#include <strings.h>
+#include "types.h"
+#include "simregs.h"
+
+extern int serial_in_poll();
+
+int enable_poll;
+
+void
+poll_sim_rx()
+{
+	u32 drx;
+
+	if (SIMREGS.stat & 3)
+		return;
+	drx = SIMREGS.drx & 0xFF;
+	printf("%02X ", drx);
+}
+
+int
+mygetchar()
+{
+	register int c;
+
+	do {
+		if (enable_poll)
+			poll_sim_rx();
+		c = serial_in_poll();
+	}
+	while (c < 0);
+	return c;
+}
+
+void
+cmd_poll(argbulk)
+	char *argbulk;
+{
+	char *argv[2];
+
+	if (parse_args(argbulk, 1, 1, argv, 0) < 0)
+		return;
+	if (!strcmp(argv[0], "on"))
+		enable_poll = 1;
+	else if (!strcmp(argv[0], "off"))
+		enable_poll = 0;
+	else
+		printf("ERROR: \"on\" or \"off\" argument expected\n");
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/target-utils/simtest/simregs.h	Sat Feb 09 07:55:50 2019 +0000
@@ -0,0 +1,17 @@
+/* Calypso SIM registers definition */
+
+#define	SIM_BASE_ADDR	0xFFFE0000
+
+struct sim_registers {
+	u16	cmd;
+	u16	stat;
+	u16	conf1;
+	u16	conf2;
+	u16	it;
+	u16	drx;
+	u16	dtx;
+	u16	maskit;
+	u16	it_cd;
+};
+
+#define	SIMREGS	(*(volatile struct sim_registers *) SIM_BASE_ADDR)