diff --git a/src/arch/arm64/armv8/Makefile.mk b/src/arch/arm64/armv8/Makefile.mk index 15d80e64e8..85c83d74da 100644 --- a/src/arch/arm64/armv8/Makefile.mk +++ b/src/arch/arm64/armv8/Makefile.mk @@ -73,6 +73,7 @@ endif ################################################################################ ifeq ($(CONFIG_ARCH_RAMSTAGE_ARMV8_64),y) +ramstage-y += ramstage_entry.S ramstage-y += cache.c ramstage-y += cpu.S ramstage-y += exception.c diff --git a/src/arch/arm64/armv8/ramstage_entry.S b/src/arch/arm64/armv8/ramstage_entry.S new file mode 100644 index 0000000000..823b12d13a --- /dev/null +++ b/src/arch/arm64/armv8/ramstage_entry.S @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Ramstage entrypoint code for aarch64 (a.k.a. armv8) + */ + +#include + +ENTRY(_start) + /* + * Note: x0 must be preserved as it contains the CBMEM top pointer + * for the next stage entry. + */ + ldr x10, =_preram_stack + ldr x11, =_postram_stack + + cmp x10, x11 + beq stack_init_done + + /* Initialize stack with sentinel value to later check overflow. */ + ldr x9, =0xdeadbeefdeadbeef + ldr x10, =_epostram_stack +1: + stp x9, x9, [x11], #16 + cmp x11, x10 + bne 1b + + /* Update stack pointer with DRAM mapped stack base */ + /* Leave a line of beef dead for easier visibility in stack dumps. */ + sub sp, x11, #16 + +stack_init_done: + /* Call the C function. */ + bl stage_entry +ENDPROC(_start) diff --git a/src/arch/arm64/include/arch/header.ld b/src/arch/arm64/include/arch/header.ld index c6d48e704f..4590be1f8b 100644 --- a/src/arch/arm64/include/arch/header.ld +++ b/src/arch/arm64/include/arch/header.ld @@ -9,7 +9,7 @@ PHDRS to_load PT_LOAD; } -#if ENV_DECOMPRESSOR || ENV_BOOTBLOCK || ENV_RMODULE +#if ENV_DECOMPRESSOR || ENV_BOOTBLOCK || ENV_RMODULE || ENV_RAMSTAGE ENTRY(_start) #else ENTRY(stage_entry)