blob: 2ed3253ad683e302679d0b03d08800eafd3b535d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
extern unsigned int _sidata; // start of .data section in ROM
extern unsigned int _sdata; // start of .data section in RAM
extern unsigned int _edata; // end of .data section in RAM
extern unsigned int _sbss; // start of .bss section
extern unsigned int _ebss; // end of .bss section
extern unsigned int _estack; // end of .stack section (stack top)
void main(void); // main function declaration
// extern void test_prog(void);
void _start(void) __attribute__((section(".text.startup"), naked)); // entry point, cpu starts executing from here
void _start(void)
{
// test_prog();
unsigned int *src, *dst;
// copy .data section from ROM to RAM
src = &_sidata;
for (dst = &_sdata; dst < &_edata;) {
*dst++ = *src++;
}
// zero initialize .bss section
for (dst = &_sbss; dst < &_ebss;) {
*dst++ = 0;
}
// initialize stack pointer
asm volatile ("la sp, _estack");
// call main function
main();
// halt
while (1);
}
|