From ea807de65b0485ac58b6eae576209c64d4d5c4e9 Mon Sep 17 00:00:00 2001 From: Oxore Date: Sun, 5 Mar 2023 20:20:45 +0300 Subject: Split app code and third party libraries --- .../src/platform/stm32f0-gcc/startup/startup.cpp | 96 ---------------------- 1 file changed, 96 deletions(-) delete mode 100644 Project/src/platform/stm32f0-gcc/startup/startup.cpp (limited to 'Project/src/platform/stm32f0-gcc/startup/startup.cpp') 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); -} -- cgit v1.2.3