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
51
52
53
54
55
56
57
58
59
60
61
62
63
| ...
// disable MMU
ldr x1, =SCTLR_VALUE_MMU_DISABLED
msr sctlr_el1, x1
... // skip for simplicity
adr x1, el1_start
msr elr_el2, x1
eret
el1_start:
... // skip for simplicity
// set stack pointer
ldr x1, =0x60000
mov sp, x1
// setup tcr
ldr x0, =TCR_EL1_VALUE
msr tcr_el1, x0
// setup mair
ldr x0, =MAIR_VALUE
msr mair_el1, x0
// identity paging
ldr x0, =PGD_ADDR
ldr x1, =PUD_ADDR
ldr x2, =PGD_VALUE
str x2, [x0]
ldr x2, =PUD1_VALUE // 1st 1GB mapped by the 1st entry of PUD
str x2, [x1]
ldr x2, =PUD2_VALUE // 2nd 1GB mapped by the 2nd entry of PUD
str x2, [x1, #8]
msr ttbr0_el1, x0 // load PGD to the buttom translation based register.
msr ttbr1_el1, x0 // load PGD to the upper translation based register.
// enable MMU
ldr x1, =SCTLR_VALUE_MMU_ENABLE
mrs x2, sctlr_el1
orr x2, x2, x1
msr sctlr_el1, x2
... // skip for simplicity
// mov sp to virtual address
ldr x1, =KERNEL_VIRT_BASE
add sp, sp, x1
// indirect branch
ldr x0, =boot_init
br x0
1:
b 1b
... // skip for simplicity
|