66 * Date Author Notes
77 * 2020 - 01 - 15 bigmagic the first version
88 * 2020 - 08 - 10 SummerGift support clang compiler
9+ * 2021 - 11 - 04 GuEe - GUI set sp with SP_ELx
910 * /
1011
1112. section ".text.entrypoint" , "ax"
@@ -32,14 +33,15 @@ cpu_setup:
3233 bne cpu_not_in_el3
3334
3435 / * Should never be executed , just for completeness. (EL3) * /
35- mov x0 , #( 1 << 0 ) / * EL0 and EL1 are in Non - Secure state * /
36- orr x0 , x0 , #( 1 << 4 ) / * RES1 * /
37- orr x0 , x0 , #( 1 << 5 ) / * RES1 * /
38- orr x0 , x0 , #( 1 << 7 ) / * SMC instructions are undefined at EL1 and above * /
39- orr x0 , x0 , #( 1 << 8 ) / * HVC instructions are enabled at EL1 and above * /
40- orr x0 , x0 , #( 1 << 10 ) / * The next lower level is AArch64 * /
36+ mov x2 , #( 1 << 0 ) / * EL0 and EL1 are in Non - Secure state * /
37+ orr x2 , x2 , #( 1 << 4 ) / * RES1 * /
38+ orr x2 , x2 , #( 1 << 5 ) / * RES1 * /
39+ orr x2 , x2 , #( 1 << 7 ) / * SMC instructions are undefined at EL1 and above * /
40+ orr x2 , x2 , #( 1 << 8 ) / * HVC instructions are enabled at EL1 and above * /
41+ orr x2 , x2 , #( 1 << 10 ) / * The next lower level is AArch64 * /
4142 msr scr_el3 , x2
4243
44+ / * Change execution level to EL2 * /
4345 mov x2 , # 0x3c9
4446 msr spsr_el3 , x2 / * 0b1111001001 * /
4547 adr x2 , cpu_not_in_el3
@@ -51,8 +53,6 @@ cpu_not_in_el3: /* Running at EL2 or EL1 */
5153 beq cpu_in_el1 / * Halt this core if running in El1 * /
5254
5355cpu_in_el2:
54- msr sp_el1 , x1
55-
5656 / * Enable CNTP for EL1 * /
5757 mrs x0 , cnthctl_el2 / * Counter - timer Hypervisor Control register * /
5858 orr x0 , x0 , # 3
@@ -71,6 +71,7 @@ cpu_in_el2:
7171 eret
7272
7373cpu_in_el1:
74+ msr spsel , # 1
7475 mov sp , x1 / * Set sp in el1 * /
7576
7677 / * Avoid trap from SIMD or float point instruction * /
@@ -89,7 +90,7 @@ cpu_in_el1:
8990clean_bss_loop:
9091 cbz w2 , jump_to_entry
9192 str xzr , [ x1 ], # 8
92- sub w2 , w2 , # 1
93+ sub w2 , w2 , # 8
9394 cbnz w2 , clean_bss_loop
9495
9596jump_to_entry:
0 commit comments