When rewriting some bits of the boot-wrapper in C, we will need tiny
per-CPU stacks. This patch reserves 256 bytes of stack for each CPU
defined in the CPU_IDS macro.
Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
DEFINES += -DNR_CPUS=$(NR_CPUS)
DEFINES += -DSYSREGS_BASE=$(SYSREGS_BASE)
DEFINES += -DUART_BASE=$(UART_BASE)
+DEFINES += -DSTACK_SIZE=256
OFILES =
ARCH_SRC := arch/aarch64/
CPPFLAGS += $(INITRD_FLAGS)
-OFILES += $(addprefix $(ARCH_SRC),boot.o cache.o $(GIC) mmu.o ns.o $(BOOTMETHOD) utils.o)
+OFILES += $(addprefix $(ARCH_SRC),boot.o stack.o cache.o $(GIC) mmu.o ns.o $(BOOTMETHOD) utils.o)
all: $(IMAGE)
.globl _start
_start:
+ mrs x0, mpidr_el1
+ ldr x1, =MPIDR_ID_BITS
+ and x0, x0, x1
+ bl find_logical_id
+ cmp x0, #MPIDR_INVALID
+ beq err_invalid_id
+ bl setup_stack
+
/*
* EL3 initialisation
*/
b start_el3
+err_invalid_id:
+ b .
.ltorg
--- /dev/null
+/*
+ * arch/aarch64/stack.S - stack handling
+ *
+ * Copyright (C) 2015 ARM Limited. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE.txt file.
+ */
+
+ .globl setup_stack
+ .globl stack_top
+ .globl stack_bottom
+
+ .text
+ /*
+ * Setup initial stack pointer
+ * x0: logical CPU ID
+ * Clobbers x1 and x2
+ */
+setup_stack:
+ mov w1, #STACK_SIZE
+ ldr x2, =stack_top
+ umsubl x0, w0, w1, x2 // sp = st_base - cpu * st_size
+ mov sp, x0
+ ret
+
+ .section .stack
+ .align 4
+stack_bottom:
+ .irp cpu, CPU_IDS
+ .space STACK_SIZE
+ .endr
+stack_top:
*(.init)
*(.text .data .rodata* .bss COMMON)
*(.vectors)
+ *(.stack)
*(.pgtables)
}