From d2e75eee1d017a7632faf017f40780a5255897f5 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Sat, 28 May 2011 16:15:15 +0200 Subject: Started rewrite from scratch. --- entry.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 entry.cpp (limited to 'entry.cpp') 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 +#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); +} -- cgit v1.2.3