blob: fe2f6be3973a04cbe4c57f8b2f55c39883b242b1 [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) {
Brian Silvermanaa9183a2013-12-08 10:33:47 -08008 __asm__ __volatile__(
Brian Silverman44311d62013-12-06 22:03:29 -08009 "mov sp, %[stack]\n\t"
10 "bx %[reset]" : :
11 [stack]"r"(RAM_START + RAM_SIZE), [reset]"r"(MAIN_FLASH_START | 1)
12 : "memory");
13 __builtin_unreachable();
14}
15
Brian Silverman5020be62013-12-06 19:09:07 -080016void _start(void) {
Brian Silverman44311d62013-12-06 22:03:29 -080017 jump_to_main();
Brian Silverman5020be62013-12-06 19:09:07 -080018}