1 /*
2  * Copyright (c) 2012 Travis Geiselbrecht
3  *
4  * Use of this source code is governed by a MIT-style
5  * license that can be found in the LICENSE file or at
6  * https://opensource.org/licenses/MIT
7  */
8 #include <lk/debug.h>
9 #include <lk/compiler.h>
10 #include <lk/main.h>
11 #include <stdint.h>
12 
13 /* externals */
14 extern unsigned int __data_start_rom, __data_start, __data_end;
15 extern unsigned int __bss_start, __bss_end;
16 
17 /* entry point of the binary */
_start(void)18 void _start(void) {
19     /* copy data from rom */
20     if (&__data_start != &__data_start_rom) {
21         unsigned int *src = &__data_start_rom;
22         unsigned int *dest = &__data_start;
23 
24         while (dest != &__data_end)
25             *dest++ = *src++;
26     }
27 
28     /* zero out bss */
29     unsigned int *bss = &__bss_start;
30     while (bss != &__bss_end)
31         *bss++ = 0;
32 
33     lk_main(0, 0, 0, 0);
34 }
35