aboutsummaryrefslogtreecommitdiff
path: root/boot.S
blob: 0cd0339e30e46a36f2979b3bbe4c2d17bea2f0e2 (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
// armv7 mode
 
// Entry point for the kernel.
// r15 -> should begin execution at 0x8000.
// r0 -> 0x00000000
// r1 -> 0x00000C42
// r2 -> 0x00000100 - start of ATAGS
// preserve these registers as argument for kernel_main
	
.global _boot // make entry point label global
_boot:
        // Only let the first core execute
        mrc p15, 0, r3, c0, c0, 5
        and r3, r3, #3
        cmp r3, #0
        beq proceed
	// this is a kind of blef - races can theoretically still occur
	// when the main core overwrites this part of memory
	wfe

proceed:
	// go to system mode (we had problems doing this later)
	cps #0b11111
	isb
	
        // Initialize the stack (_stack_top is defined in linker.ld)
        ldr sp, =_stack_top
 
        // Call kernel_main
        ldr r3, =kernel_main
        bx r3