-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathboot.s
More file actions
50 lines (42 loc) · 1.28 KB
/
Copy pathboot.s
File metadata and controls
50 lines (42 loc) · 1.28 KB
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
40
41
42
43
44
45
46
47
48
49
50
/* ToubkalOS boot entry — AArch64
* This is the REAL first code that runs. The CPU jumps here with an
* undefined stack pointer, so we must set SP before ANY Rust code runs.
* (The Rust compiler emits a function prologue that saves LR to the stack,
* so if SP is bad we get an immediate data-abort crash.) */
.section .text.boot
.globl _start
.type _start, %function
_start:
/* Setup Exception Vector Table */
adrp x0, vector_table_el1
add x0, x0, :lo12:vector_table_el1
msr vbar_el1, x0
isb
/* Initialize stack pointer. _stack_top is defined in linker.ld. */
adrp x0, _stack_top
add x0, x0, :lo12:_stack_top
mov sp, x0
/* Enable FP/SIMD coprocessors to prevent exception on SIMD instructions */
mrs x1, cpacr_el1
mov x2, #(3 << 20)
orr x1, x1, x2
msr cpacr_el1, x1
isb
/* Zero-initialise the BSS section. */
adrp x1, __bss_start
add x1, x1, :lo12:__bss_start
adrp x2, __bss_end
add x2, x2, :lo12:__bss_end
bss_loop:
cmp x1, x2
b.ge bss_done
str xzr, [x1], #8
b bss_loop
bss_done:
/* Jump into Rust — kernel_main never returns. */
bl kernel_main
/* Safety halt if kernel_main somehow returns. */
halt:
wfi
b halt
.size _start, . - _start