1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-06-09 15:29:29 +00:00
8bitworkshop/src/worker/lib/arm32/crt0.c

28 lines
653 B
C
Raw Normal View History

2023-12-30 04:46:57 +00:00
2024-01-05 17:23:54 +00:00
extern void _end;
void malloc_addblock(void* addr, int size);
2023-12-30 04:46:57 +00:00
int entry();
__attribute__((weak, naked, noinline, noreturn)) void _start() {
2024-01-01 22:35:13 +00:00
// set bss segment symbols
2023-12-30 04:46:57 +00:00
asm(".global __bss_start__, __bss_end__");
asm("__bss_start__ = _edata");
asm("__bss_end__ = _end");
2024-01-01 22:35:13 +00:00
// set stack pointer
asm("mov sp, #0x100000");
2024-01-05 17:23:54 +00:00
// allocate heap block
malloc_addblock(&_end, (void*)0xf0000 - &_end);
2024-01-01 22:35:13 +00:00
// run main()
2023-12-30 04:46:57 +00:00
entry();
2024-01-01 22:35:13 +00:00
// wait for next video frame
while (*(volatile int*)0x4000020 != 0) { }
// halt cpu
2023-12-30 04:46:57 +00:00
asm(".long 0xe7f000f0"); // udf #0
}
void _Exit(int ec) {
asm(".long 0xe7f000f0"); // udf #0
}