blob: ef816f3e773efd8f7f5e3bc4ad2beb32f734da4f [file] [log] [blame]
Brian Silverman44311d62013-12-06 22:03:29 -08001#include <stdint.h>
2
3#include "cape/bootloader_handoff.h"
4
5// Sets everything up and then jumps to the main code.
6static void jump_to_main(void) __attribute__((noreturn));
7static void jump_to_main(void) {
8 // 0x20008000
Brian Silvermanaa9183a2013-12-08 10:33:47 -08009 __asm__ __volatile__(
Brian Silverman44311d62013-12-06 22:03:29 -080010 "mov sp, %[stack]\n\t"
11 "bx %[reset]" : :
12 [stack]"r"(RAM_START + RAM_SIZE), [reset]"r"(MAIN_FLASH_START | 1)
13 : "memory");
14 __builtin_unreachable();
15}
16
Brian Silverman5020be62013-12-06 19:09:07 -080017void _start(void) {
Brian Silverman44311d62013-12-06 22:03:29 -080018 jump_to_main();
Brian Silverman5020be62013-12-06 19:09:07 -080019}