synth/arm/app_init.cc
2022-05-16 20:59:17 -07:00

20 lines
407 B
C++

#include <cstdint>
extern "C" int main();
extern uint32_t _bss_begin, _bss_end, _initial_stack_pointer;
__attribute__((section(".app_init"), used)) void AppInit() {
*(uint32_t*)(0x40000000) = 0;
asm("mov sp, %0" : : "r"(&_initial_stack_pointer) :);
// clear .bss
for (uint32_t* ptr = &_bss_begin; ptr < &_bss_end; ptr++) {
*ptr = 0;
}
main();
while (true) {
}
}