aboutsummaryrefslogtreecommitdiffstats
path: root/wirish
diff options
context:
space:
mode:
Diffstat (limited to 'wirish')
-rw-r--r--wirish/rules.mk7
-rw-r--r--wirish/start.S27
-rw-r--r--wirish/start_c.c65
3 files changed, 97 insertions, 2 deletions
diff --git a/wirish/rules.mk b/wirish/rules.mk
index 6aa0904..1bf6245 100644
--- a/wirish/rules.mk
+++ b/wirish/rules.mk
@@ -12,8 +12,9 @@ WIRISH_INCLUDES := -I$(d) -I$(d)/comm -I$(d)/boards
CFLAGS_$(d) := $(WIRISH_INCLUDES) $(LIBMAPLE_INCLUDES)
# Local rules and targets
-cSRCS_$(d) :=
+sSRCS_$(d) := start.S
+cSRCS_$(d) := start_c.c
cppSRCS_$(d) := wirish_math.cpp \
Print.cpp \
boards.cpp \
@@ -34,10 +35,12 @@ cppSRCS_$(d) := wirish_math.cpp \
ext_interrupts.cpp \
wirish_digital.cpp
+sFILES_$(d) := $(sSRCS_$(d):%=$(d)/%)
cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%)
cppFILES_$(d) := $(cppSRCS_$(d):%=$(d)/%)
-OBJS_$(d) := $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) \
+OBJS_$(d) := $(sFILES_$(d):%.S=$(BUILD_PATH)/%.o) \
+ $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) \
$(cppFILES_$(d):%.cpp=$(BUILD_PATH)/%.o)
DEPS_$(d) := $(OBJS_$(d):%.o=%.d)
diff --git a/wirish/start.S b/wirish/start.S
new file mode 100644
index 0000000..4d1d405
--- /dev/null
+++ b/wirish/start.S
@@ -0,0 +1,27 @@
+/*
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+ .text
+ .code 16
+ .thumb_func
+
+ .globl _start
+ .type _start, %function
+_start:
+ .fnstart
+ ldr r1,=__cs3_stack
+ mov sp,r1
+ ldr r1,=__cs3_start_c
+ bx r1
+ .pool
+ .cantunwind
+ .fnend
diff --git a/wirish/start_c.c b/wirish/start_c.c
new file mode 100644
index 0000000..cb96fc5
--- /dev/null
+++ b/wirish/start_c.c
@@ -0,0 +1,65 @@
+/* CS3 start_c routine.
+ *
+ * Copyright (c) 2006, 2007 CodeSourcery Inc
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include <stddef.h>
+
+extern void __libc_init_array (void);
+
+extern int main (int, char **, char **);
+
+extern void exit (int) __attribute__ ((noreturn, weak));
+
+extern char _data, _edata;
+extern char _bss, _ebss;
+
+struct rom_img_cfg {
+ long long *img_start;
+};
+
+extern char _lm_rom_img_cfgp;
+
+void __attribute__ ((noreturn))
+__cs3_start_c (void)
+{
+ struct rom_img_cfg *img_cfg = (struct rom_img_cfg*)&_lm_rom_img_cfgp;
+ long long *src;
+ long long *dst;
+ int exit_code;
+
+ /* Initialize .data, if necessary. */
+ src = img_cfg->img_start;
+ dst = (long long*)&_data;
+ if (src != dst) {
+ while (dst < (long long*)&_edata) {
+ *dst++ = *src++;
+ }
+ }
+
+ /* Zero .bss. */
+ dst = (long long*)&_bss;
+ while (dst < (long long*)&_ebss) {
+ *dst++ = 0;
+ }
+
+ /* Run initializers. */
+ __libc_init_array ();
+
+ exit_code = main (0, NULL, NULL);
+ if (exit)
+ exit (exit_code);
+ /* If exit is NULL, make sure we don't return. */
+ for (;;)
+ continue;
+}