1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Early initialization code for aarch64 (a.k.a. armv8) */
5 #include <soc/addressmap.h>
7 // based on arm64_init_cpu
9 /* Initialize PSTATE (unmask all exceptions, select SP_EL0). */
13 /* TODO: This is where we'd put non-boot CPUs into WFI if needed. */
15 /* x22: SCTLR, return address: x23 (callee-saved by subroutine) */
17 /* TODO: Assert that we always start running at EL3 */
20 /* Activate ICache (12) already for speed during cache flush below. */
21 orr x22, x22, #(1 << 12)
25 /* Invalidate dcache */
26 bl dcache_invalidate_all
28 /* Deactivate MMU (0), Alignment Check (1) and DCache (2) */
29 and x22, x22, # ~(1 << 0) & ~(1 << 1) & ~(1 << 2)
30 /* Activate Stack Alignment (3) because why not */
31 orr x22, x22, #(1 << 3)
32 /* Set to little-endian (25) */
33 and x22, x22, # ~(1 << 25)
34 /* Deactivate write-xor-execute enforcement (19) */
35 and x22, x22, # ~(1 << 19)
38 /* Invalidate icache and TLB for good measure */
44 /* Load core ID to x0 */
51 /* Each core gets CONFIG_STACK_SIZE bytes of stack */
52 mov x2, # CONFIG_STACK_SIZE
57 add x0, x1, x0 // x0 = CONFIG_STACK_SIZE * coreid + _stack_sec
58 add x1, x0, # CONFIG_STACK_SIZE // x1 = x0 + CONFIG_STACK_SIZE
60 /* Initialize stack with sentinel value to later check overflow. */
61 ldr x2, =0xdeadbeefdeadbeef
68 /* Leave a line of beef dead for easier visibility in stack dumps. */
71 /* Set arg0 to core id */
77 ENDPROC(secondary_init)