aa64: finalise context switch, page fault handler and syscall
[lunaix-os.git] / lunaix-os / arch / aarch64 / boot / start.S
1 #include <asm/aa64_msrs.h>
2
3 .section .boot.data
4     .align 4
5     stack_end:
6         .skip 512
7     stack_top:
8
9 .section .boot.text
10     .global start_
11
12     /*
13         We follow Linux-arm64 boot protocol
14             ldr x0, dtb
15             mov x1, xzr
16             mov x2, xzr
17             mov x3, xzr
18      */
19     start_:
20         adr x4, stack_top
21         mov sp, x4
22         mov fp, xzr
23
24         mov x19, x0
25         bl aarch64_pre_el1_init
26
27         bl aarch64_prepare_el1_transfer
28         cbz x0, 1f
29
30         /* transfer to EL1 if we are currently not in */
31         adr x0, stack_top
32         msr SP_EL1, x0      /* EL1 stack */
33
34         adr x0, 1f
35         msr elr, x0         /* PC to resume at EL1, elr aliased to ELR_ELx */
36
37         eret
38     1:
39         mov x0, x19
40         adr x4, aarch64_init
41         blr x4
42          
43         // x0: ptr to boot_handoff
44         adr x4, kernel_bootstrap
45         blr x4