Files
system76-coreboot/src/arch/x86/assembly_entry.S
Arthur Heymans a2bc2540c2 Allow to build romstage sources inside the bootblock
Having a separate romstage is only desirable:
 - with advanced setups like vboot or normal/fallback
 - boot medium is slow at startup (some ARM SOCs)
 - bootblock is limited in size (Intel APL 32K)

When this is not the case there is no need for the extra complexity
that romstage brings. Including the romstage sources inside the
bootblock substantially reduces the total code footprint. Often the
resulting code is 10-20k smaller.

This is controlled via a Kconfig option.

TESTED: works on qemu x86, arm and aarch64 with and without VBOOT.

Change-Id: Id68390edc1ba228b121cca89b80c64a92553e284
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/55068
Reviewed-by: Julius Werner <jwerner@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
2023-11-09 13:20:18 +00:00

79 lines
1.5 KiB
ArmAsm

/* SPDX-License-Identifier: GPL-2.0-only */
/*
* This path is for stages that are post bootblock. The gdt is reloaded
* to accommodate platforms that are executing out of CAR. In order to
* continue with C code execution one needs to set stack pointer and
* clear .bss variables that are stage specific.
*/
#if CONFIG(RESET_VECTOR_IN_RAM)
#define _STACK_TOP _eearlyram_stack
#else
#define _STACK_TOP _ecar_stack
#endif
#if ENV_X86_64
.code64
#else
.code32
#endif
.section ".text._start", "ax", @progbits
.global _start
_start:
/* Migrate GDT to this text segment */
#if ENV_X86_64
call gdt_init64
#else
call gdt_init
#endif
/* reset stack pointer to CAR/EARLYRAM stack */
mov $_STACK_TOP, %esp
#if ENV_SEPARATE_DATA_AND_BSS
/* clear .bss section as it is not shared */
cld
xor %eax, %eax
movl $(_ebss), %ecx
movl $(_bss), %edi
sub %edi, %ecx
shrl $2, %ecx
rep stosl
/* Copy .data section content to Cache-As-Ram */
movl $(_edata), %ecx
movl $(_data), %edi
sub %edi, %ecx
shrl $2, %ecx
movl $(_data_load),%esi
rep movsl
#endif
#if ((ENV_SEPARATE_VERSTAGE && CONFIG(VERSTAGE_DEBUG_SPINLOOP)) \
|| (ENV_SEPARATE_ROMSTAGE && CONFIG(ROMSTAGE_DEBUG_SPINLOOP)))
/* Wait for a JTAG debugger to break in and set EBX non-zero */
xor %ebx, %ebx
debug_spinloop:
cmp $0, %ebx
jz debug_spinloop
#endif
andl $0xfffffff0, %esp
#if CONFIG(IDT_IN_EVERY_STAGE)
call exception_init
#endif
#if CONFIG(ASAN_IN_ROMSTAGE)
call asan_init
#endif
call car_stage_entry
/* Expect to never return. */
1:
jmp 1b