1 | /* |
---|
2 | * From Newlib 1.16.0 |
---|
3 | * |
---|
4 | * $Id$ |
---|
5 | */ |
---|
6 | |
---|
7 | #warning Call to boot_card has changed and needs checking. |
---|
8 | #warning The call is "void boot_card(const char* cmdline);" |
---|
9 | #warning You need to pass a NULL. |
---|
10 | #warning Please check and remove these warnings. |
---|
11 | |
---|
12 | .text |
---|
13 | .balign 4 |
---|
14 | .global _start |
---|
15 | _start: |
---|
16 | |
---|
17 | seth sp, #shigh(_stack) |
---|
18 | add3 sp, sp, #low(_stack) |
---|
19 | ldi fp, #0 |
---|
20 | |
---|
21 | # Clear the BSS. Do it in two parts for efficiency: longwords first |
---|
22 | # for most of it, then the remaining 0 to 3 bytes. |
---|
23 | |
---|
24 | seth r2, #shigh(__bss_start) |
---|
25 | add3 r2, r2, #low(__bss_start); R2 = start of BSS |
---|
26 | seth r3, #shigh(_end) |
---|
27 | add3 r3, r3, #low(_end) ; R3 = end of BSS + 1 |
---|
28 | |
---|
29 | sub r3, r2 ; R3 = BSS size in bytes |
---|
30 | mv r4, r3 |
---|
31 | srli r4, #2 ; R4 = BSS size in longwords (rounded down) |
---|
32 | ldi r1, #0 ; clear R1 for longword store |
---|
33 | addi r2, #-4 ; account for pre-inc store |
---|
34 | beqz r4, .Lendloop1 ; any more to go? |
---|
35 | .Lloop1: |
---|
36 | st r1, @+r2 ; yep, zero out another longword |
---|
37 | addi r4, #-1 ; decrement count |
---|
38 | bnez r4, .Lloop1 ; go do some more |
---|
39 | .Lendloop1: |
---|
40 | and3 r4, r3, #3 ; get no. of remaining BSS bytes to clear |
---|
41 | addi r2, #4 ; account for pre-inc store |
---|
42 | beqz r4, .Lendloop2 ; any more to go? |
---|
43 | .Lloop2: |
---|
44 | stb r1, @r2 ; yep, zero out another byte |
---|
45 | addi r2, #1 ; bump address |
---|
46 | addi r4, #-1 ; decrement count |
---|
47 | bnez r4, .Lloop2 ; go do some more |
---|
48 | .Lendloop2: |
---|
49 | |
---|
50 | # Run code in the .init section. |
---|
51 | # This will queue the .fini section to be run with atexit. |
---|
52 | |
---|
53 | # bl __init |
---|
54 | |
---|
55 | # Call main, then exit. |
---|
56 | |
---|
57 | bl boot_card |
---|
58 | bl sys_exit |
---|
59 | |
---|
60 | # If that fails just loop. |
---|
61 | |
---|
62 | .Lexit: |
---|
63 | bra .Lexit |
---|