/* CRT initialization code called from Reset_Handler after it calls SystemInit() */ extern "C" __attribute__ ((section(".mbed_init"))) void __main(void) { unsigned long* pulDest; unsigned long* pulSrc; int ExitCode; /* Copy the data segment initializers from flash to SRAM in ROM mode if needed */ if (&_sidata != &_sdata) // only if needed { pulSrc = &_sidata; for(pulDest = &_sdata; pulDest < &_edata; ) { *(pulDest++) = *(pulSrc++); } } /* Copy the .fastcode code from ROM to SRAM if needed */ if (&_sifastcode != &_sfastcode) { pulSrc = &_sifastcode; for(pulDest = &_sfastcode; pulDest < &_efastcode; ) { *(pulDest++) = *(pulSrc++); } } /* Zero fill the bss segment. */ for(pulDest = &_sbss; pulDest < &_ebss; ) { *(pulDest++) = 0; } /* Initialize stdin/stdout/stderr file handles. */ if (!MRI_SEMIHOST_STDIO && !GCC4MBED_DELAYED_STDIO_INIT) { __GCC4MBEDOpenStandardHandles(); } if (MRI_ENABLE) { __mriInit(MRI_INIT_PARAMETERS); if (MRI_BREAK_ON_INIT) { __debugbreak(); } } /* Initialize static constructors. */ __libc_init_array(); /* Call the application's entry point. */ ExitCode = main(); /* Call exit */ exit(ExitCode); }
// extern "C" void exit(int ErrorCode); extern "C" void _start(void) { int bssSize = (int)&__bss_end__ - (int)&__bss_start__; int mainReturnValue; memset(&__bss_start__, 0, bssSize); fillUnusedRAM(); if (STACK_SIZE) { configureStackSizeLimit(STACK_SIZE); } if (WRITE_BUFFER_DISABLE) { disableMPU(); configureMpuRegionToAccessAllMemoryWithNoCaching(); enableMPU(); } if (MRI_ENABLE) { __mriInit(MRI_INIT_PARAMETERS); if (MRI_BREAK_ON_INIT) __debugbreak(); } // MemoryPool stuff - needs to be initialised before __libc_init_array // so static ctors can use them extern uint8_t __AHB0_dyn_start; extern uint8_t __AHB0_end; extern uint8_t __AHB1_dyn_start; extern uint8_t __AHB1_end; MemoryPool _AHB0_stack(&__AHB0_dyn_start, &__AHB0_end - &__AHB0_dyn_start); MemoryPool _AHB1_stack(&__AHB1_dyn_start, &__AHB1_end - &__AHB1_dyn_start); _AHB0 = &_AHB0_stack; _AHB1 = &_AHB1_stack; // MemoryPool init done __libc_init_array(); mainReturnValue = main(); exit(mainReturnValue); }
void _start(void) { int bssSize = (int)&__bss_end__ - (int)&__bss_start__; int mainReturnValue; memset(&__bss_start__, 0, bssSize); if (MRI_ENABLE) { __mriInit(MRI_INIT_PARAMETERS); if (MRI_BREAK_ON_INIT) __debugbreak(); } software_init_hook(); __libc_init_array(); mainReturnValue = main(); exit(mainReturnValue); }