summaryrefslogtreecommitdiff
path: root/entry.cpp
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2011-05-28 16:15:15 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2011-05-28 16:15:15 +0200
commitd2e75eee1d017a7632faf017f40780a5255897f5 (patch)
tree0bca544eb7ec4a8da4da6c3ed6faaf0d02411bca /entry.cpp
parent422a7785c423d64b97f9ae06baf19921a859e380 (diff)
Started rewrite from scratch.
Diffstat (limited to 'entry.cpp')
-rw-r--r--entry.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/entry.cpp b/entry.cpp
new file mode 100644
index 0000000..4faca0e
--- /dev/null
+++ b/entry.cpp
@@ -0,0 +1,41 @@
+#include <stdint.h>
+#include "rcc.h"
+
+int main();
+
+// Symbols from linker script.
+extern uint32_t _data_rom;
+extern uint32_t _data_start;
+extern uint32_t _data_end;
+extern uint32_t _bss_start;
+extern uint32_t _bss_end;
+
+void __attribute__((naked)) entry() {
+ // Initialize clock.
+ rcc_init();
+
+ // Load .data from rom image.
+ uint32_t* rp = &_data_rom;
+ uint32_t* wp = &_data_start;
+
+ while(wp < &_data_end) {
+ *wp++ = *rp++;
+ }
+
+ // Clear .bss.
+ wp = &_bss_start;
+
+ while(wp < &_bss_end) {
+ *wp++ = 0;
+ }
+
+ // Call constructors.
+
+ // Call main().
+ main();
+
+ // Call destructors.
+
+ // Halt.
+ while(1);
+}