arch/arm64: Add an alternative entry point for ramstage code
This change prepares an alternative entry point for the ARM64
ramstage. It is written in assembly language, avoids the usage of the
stack, and overrides the program stack pointer (SP register) if the
`preram_stack` and `postram_stack` point to different addresses.
Previous Boot Flow:
- header.ld -> jump into `stage_entry` C code for ROMSTAGE onwards ->
`stage_entry` being called and followed by `main` function
Updated Boot Flow:
- header.ld -> jump into `_start` (assembly entry point) for
ramstage specifically -> Update the existing SP (stack pointer)
register if the `preram_` or `postram_` stack address is not
same -> call into `stage_entry` and follow the `main` function.
BUG=b:456953373
BRANCH=None
TEST=Able to build google/bluey.
Change-Id: I4eec24aff1c9d01180c3452a3631dd344656c771
Signed-off-by: Subrata Banik <subratabanik@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/90403
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Jayvik Desai <jayvik@google.com>
Reviewed-by: Kapil Porwal <kapilporwal@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
641f7ac677
commit
1b599a8844
3 changed files with 36 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
34
src/arch/arm64/armv8/ramstage_entry.S
Normal file
34
src/arch/arm64/armv8/ramstage_entry.S
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Ramstage entrypoint code for aarch64 (a.k.a. armv8)
|
||||
*/
|
||||
|
||||
#include <arch/asm.h>
|
||||
|
||||
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)
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue