changeset 2:ddda170fa6f4

loadagent.elf compiled and linked, no printf yet
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Mon, 29 Apr 2013 05:21:05 +0000
parents da98dc08f575
children 45bf8af5f061
files .hgignore loadagent/Makefile loadagent/crt0.S loadagent/loadagent.lds loadagent/main.c
diffstat 5 files changed, 96 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Mon Apr 29 03:21:00 2013 +0000
+++ b/.hgignore	Mon Apr 29 05:21:05 2013 +0000
@@ -1,6 +1,7 @@
 syntax: regexp
 
 \.[oa]$
+\.elf$
 
 ^toolchain/binutils-2.21.1/
 ^toolchain/binutils-build/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadagent/Makefile	Mon Apr 29 05:21:05 2013 +0000
@@ -0,0 +1,17 @@
+CC=	arm-elf-gcc
+CFLAGS=	-Os -fno-builtin
+LD=	arm-elf-ld
+
+OBJS=	crt0.o main.o serio.o serwait.o
+
+TC_LIBS=`${CC} -print-file-name=libc.a` \
+	`${CC} -print-file-name=libgcc.a`
+
+all:	loadagent.elf
+
+loadagent.elf:	${OBJS} loadagent.lds
+	${LD} -N -T loadagent.lds -o $@ ${OBJS} \
+		--start-group ${TC_LIBS} --end-group
+
+clean:
+	rm -f *.o *errs *core *.elf *.bin *.srec
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadagent/crt0.S	Mon Apr 29 05:21:05 2013 +0000
@@ -0,0 +1,19 @@
+#include "halt.h"
+
+	.text
+	.code	32
+	.global	_entry
+_entry:
+	ldr	sp, =stack_bottom
+@ zero bss
+	ldr	r0, =__bss_start
+	ldr	r2, =__bss_end
+	sub	r1, r2, r0
+	bl	bzero
+@ C code entry
+	bl	main
+	mov	r0, #HALTCODE_MAINEXITED
+	.global	_exit
+_exit:	nop
+1:	nop
+	b	1b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadagent/loadagent.lds	Mon Apr 29 05:21:05 2013 +0000
@@ -0,0 +1,44 @@
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_entry)
+SECTIONS
+{
+    /* code */
+    . = 0x800750;
+    .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 (NOLOAD) : {
+        . = ALIGN(4);
+        __bss_start = .;
+        *(.bss)
+    }
+    . = ALIGN(4);
+    __bss_end = .;
+    /* end of image */
+    _end = .;
+    PROVIDE(end = .);
+}
+
+/* a few absolute definitions */
+rom_vars = 0x800518;
+stack_bottom = 0x83FFFC;
--- a/loadagent/main.c	Mon Apr 29 03:21:00 2013 +0000
+++ b/loadagent/main.c	Mon Apr 29 05:21:05 2013 +0000
@@ -29,3 +29,18 @@
 		_exit(HALTCODE_INVALIDUART);
 	}
 }
+
+main()
+{
+	uart_select_init();
+#if 0
+	printf("FreeCalypso loadagent running\n");
+	printf("Loaded via UART %d (%s) at baud rate #%d\n", rom_vars.uart_id,
+		uart_name, rom_vars.baud_rate_code);
+	printf("TCXO clock input autodetected to be %d MHz\n",
+		rom_vars.clktcxo_13mhz ? 13 : 26);
+#endif
+	/* interactive command mode to be implemented */
+	while (1)
+		;
+}