diff options
author | Oxore <oxore@protonmail.com> | 2023-03-05 20:20:45 +0300 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2023-03-05 20:20:45 +0300 |
commit | ea807de65b0485ac58b6eae576209c64d4d5c4e9 (patch) | |
tree | b4264d20e1d700cfd9e0ece9d847a825dd1dfc03 /Project/src/platform/stm32f0-gcc/startup/startup.cpp | |
parent | dd01e7ed22cea652061f0d12cecf929e04b285e9 (diff) |
Split app code and third party libraries
Diffstat (limited to 'Project/src/platform/stm32f0-gcc/startup/startup.cpp')
-rw-r--r-- | Project/src/platform/stm32f0-gcc/startup/startup.cpp | 96 |
1 files changed, 0 insertions, 96 deletions
diff --git a/Project/src/platform/stm32f0-gcc/startup/startup.cpp b/Project/src/platform/stm32f0-gcc/startup/startup.cpp deleted file mode 100644 index 95276ae..0000000 --- a/Project/src/platform/stm32f0-gcc/startup/startup.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// very simple startup code with definition of handlers for all cortex-m cores - -typedef void (*ptr_func_t)(); - -// main application -extern "C" int main(); - -// location of these variables is defined in linker script -extern unsigned __data_start; -extern unsigned __data_end; -extern unsigned __data_load; - -extern unsigned __bss_start; -extern unsigned __bss_end; - -extern unsigned __heap_start; - -extern ptr_func_t __preinit_array_start[]; -extern ptr_func_t __preinit_array_end[]; - -extern ptr_func_t __init_array_start[]; -extern ptr_func_t __init_array_end[]; - -extern ptr_func_t __fini_array_start[]; -extern ptr_func_t __fini_array_end[]; - - -/** Copy default data to DATA section - */ -void copy_data() { - unsigned *src = &__data_load; - unsigned *dst = &__data_start; - while (dst < &__data_end) { - *dst++ = *src++; - } -} - -/** Erase BSS section - */ -void zero_bss() { - unsigned *dst = &__bss_start; - while (dst < &__bss_end) { - *dst++ = 0; - } -} - -/** Fill heap memory - */ -void fill_heap(unsigned fill=0x45455246) { - unsigned *dst = &__heap_start; - unsigned *msp_reg; - __asm__("mrs %0, msp\n" : "=r" (msp_reg) ); - while (dst < msp_reg) { - *dst++ = fill; - } -} - -/** Call constructors for static objects - */ -void call_init_array() { - auto array = __preinit_array_start; - while (array < __preinit_array_end) { - (*array)(); - array++; - } - - array = __init_array_start; - while (array < __init_array_end) { - (*array)(); - array++; - } -} - -/** Call destructors for static objects - */ -void call_fini_array() { - auto array = __fini_array_start; - while (array < __fini_array_end) { - (*array)(); - array++; - } -} - -// reset handler -extern "C" void RESET_handler() { - copy_data(); - zero_bss(); - fill_heap(); - call_init_array(); - // run application - main(); - // call destructors for static instances - call_fini_array(); - // stop - while (true); -} |