use the -newos toolchain even if -elf is present.
[newos.git] / boot / arm / stage1.S
blob414d8f9da0c9962ac9c87abc9237b08a28780fea
1 /*
2 ** Copyright 2001-2004, Travis Geiselbrecht. All rights reserved.
3 ** Distributed under the terms of the NewOS License.
4 */
6 #define SRAM_START 0x20000000
7 #define TEMPSTACK (SRAM_START + 0x1000)
8 #define RELOCATION_TARGET (TEMPSTACK+0x74) // relocate us to just above the stack in sram
9 #define RELOCATION_SIZE 0x10000 // should be big enough to get the important data
11 #define LED_DISPLAY(pos, char) \
12         ldr             r11,=(0x08000100 + (3-pos) * 2); \
13         ldr             r12,=char; \
14         strh    r12,[r11];
16 #define LED_DISPLAY_REG(pos, reg, byte) \
17         ldr             r12,=(0x08000100 + (pos) * 2); \
18         ldr             r10,=0xf; \
19         and             r11,r10,reg, lsr #(byte * 4); \
20         ldr             r10,='0'; \
21         add             r11,r11,r10; \
22         strh    r11,[r12];
24 .text
25 .globl _start
26 _start:
27         nop
28         nop
29         nop
30         nop
31         nop
32         nop
33         nop
35         LED_DISPLAY(0, ' ')
36         LED_DISPLAY(1, ' ')
37         LED_DISPLAY(2, ' ')
38         LED_DISPLAY(3, ' ')
40         LED_DISPLAY(0, '0')
41         
42         /* load our new stack */
43         ldr             sp,=TEMPSTACK
45         /* copy ourself to sram and jump */
46         ldr             r1,=0
47         ldr             r2,=RELOCATION_TARGET
48         ldr             r3,=RELOCATION_SIZE
49 _loop:
50 //      LED_DISPLAY_REG(0, r3, 0)
51 //      LED_DISPLAY_REG(1, r3, 1)
52 //      LED_DISPLAY_REG(2, r3, 2)
53 //      LED_DISPLAY_REG(3, r3, 3)
54         ldr             r4,[r1], #4
55         str             r4,[r2], #4
56         sub             r3,r3,#4
57         cmp             r3,#0
58         bpl             _loop
60         LED_DISPLAY(0, '1')
62         /* branch */
63         ldr             r5,=_decompress_start
64         mov             lr,pc
65         bx              r5
67 __spin:
68         b               __spin