changeset 955:d7830aee0d35

c139-lldbg hack concocted
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Wed, 04 Nov 2015 20:34:12 +0000
parents d25d73815817
children 1557e15a012f
files target-utils/c139-lldbg/Makefile target-utils/c139-lldbg/cmdtab.c target-utils/c139-lldbg/entry.S target-utils/c139-lldbg/entryinfo.c target-utils/c139-lldbg/lldbg.lds target-utils/c139-lldbg/main.c target-utils/c139-lldbg/mygetchar.c
diffstat 7 files changed, 157 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/target-utils/c139-lldbg/Makefile	Wed Nov 04 20:34:12 2015 +0000
@@ -0,0 +1,28 @@
+CC=	arm-elf-gcc
+CFLAGS=	-Os -fno-builtin
+CPPFLAGS=-I../include
+LD=	arm-elf-ld
+OBJCOPY=arm-elf-objcopy
+
+PROG=	lldbg
+OBJS=	entry.o cmdtab.o entryinfo.o main.o mygetchar.o
+LIBS=	../libcommon/libcommon.a ../libprintf/libprintf.a
+LDS=	lldbg.lds
+
+TC_LIBS=`${CC} -print-file-name=libc.a` \
+	`${CC} -print-file-name=libgcc.a`
+
+all:	${PROG}.bin
+
+${PROG}.elf:	${OBJS} ${LIBS} ${LDS}
+	${LD} -N -T ${LDS} -o $@ ${OBJS} \
+		--start-group ${LIBS} --end-group \
+		--start-group ${TC_LIBS} --end-group
+
+${PROG}.bin:	${PROG}.elf
+	${OBJCOPY} -O binary $< $@
+
+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/c139-lldbg/cmdtab.c	Wed Nov 04 20:34:12 2015 +0000
@@ -0,0 +1,20 @@
+#include "cmdtab.h"
+
+extern void cmd_entryinfo();
+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[] = {
+	{"entryinfo", cmd_entryinfo},
+	{"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/c139-lldbg/entry.S	Wed Nov 04 20:34:12 2015 +0000
@@ -0,0 +1,20 @@
+	.text
+	.globl	_entry
+_entry:
+	.code	16
+	bx	pc
+	nop
+
+	.code	32
+	stmfd	sp!, {r0-r12,lr}
+	mrs	r0, CPSR
+	mov	r1, sp
+	/* supervisor mode, disable all interrupts */
+	msr	CPSR_c, #0xd3
+	ldr	sp, =stack_bottom
+	/* save entry SP and CPSR */
+	ldr	r2, =lldbg_entry_cpsr
+	str	r0, [r2]
+	ldr	r2, =lldbg_entry_sp
+	str	r1, [r2]
+	b	main
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/target-utils/c139-lldbg/entryinfo.c	Wed Nov 04 20:34:12 2015 +0000
@@ -0,0 +1,11 @@
+#include "types.h"
+
+u32 lldbg_entry_cpsr;
+u32 lldbg_entry_sp;
+
+void
+cmd_entryinfo()
+{
+	printf("CPSR on entry: %08X\n", lldbg_entry_cpsr);
+	printf("SP on entry after register save: %08X\n", lldbg_entry_sp);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/target-utils/c139-lldbg/lldbg.lds	Wed Nov 04 20:34:12 2015 +0000
@@ -0,0 +1,42 @@
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_entry)
+SECTIONS
+{
+    /* code */
+    . = 0x3B0000;
+    .text : {
+        /* regular code */
+        *(.text*)
+        /* gcc voodoo */
+        *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)
+        . = ALIGN(4);
+    }
+
+    /* read-only data */
+    . = ALIGN(4);
+    .rodata : {
+        *(.rodata*)
+    }
+
+    /* initialized data */
+    . = ALIGN(4);
+    .data : {
+        *(.data)
+    }
+    PROVIDE(edata = .);
+
+    /* uninitialized data */
+    .bss 0x83C000 (NOLOAD) : {
+        . = ALIGN(4);
+        __bss_start = .;
+        *(.bss)
+    }
+    . = ALIGN(4);
+    __bss_end = .;
+    /* end of image */
+    _end = .;
+    PROVIDE(end = .);
+}
+
+stack_bottom = 0x83FFFC;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/target-utils/c139-lldbg/main.c	Wed Nov 04 20:34:12 2015 +0000
@@ -0,0 +1,15 @@
+#include "types.h"
+#include "ns16550.h"
+
+struct ns16550_regs *uart_base;
+
+main()
+{
+	uart_base = (struct ns16550_regs *) 0xFFFF5800;
+	printf("\2\2\2*Standalone Low Level Debugger entered\2");
+	for (;;) {
+		putchar('>');
+		if (command_entry())
+			command_dispatch();
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/target-utils/c139-lldbg/mygetchar.c	Wed Nov 04 20:34:12 2015 +0000
@@ -0,0 +1,21 @@
+/*
+ * The interactive command entry (editing) function in libcommon
+ * will call mygetchar() for its character input.  It is supposed
+ * to be a blocking wait for input, but in some programs other
+ * processing can be done while waiting - for example, check for
+ * keypad presses as well.  This is the basic version which waits
+ * for serial input and nothing else.
+ */
+
+extern int serial_in_poll();
+
+int
+mygetchar()
+{
+	register int c;
+
+	do
+		c = serial_in_poll();
+	while (c < 0);
+	return c;
+}