Files
system76-coreboot/src/arch/x86/assembly_entry.S
Raul E Rangel ca0606e04f arch/x86,lib/thread: Enable thread support in romstage
This change does the following:
* Pushes the cpu_info struct into the top of the stack (just like
  c_start.S). This is required so the cpu_info function works correctly.

* Adds the thread.c to the romstage build.

I only enabled this for romstage since I haven't done any tests in other
stages, but in theory it should work for other stages.

BUG=b:179699789
TEST=Boot guybrush with threads enabled in romstage

Signed-off-by: Raul E Rangel <rrangel@chromium.org>
Change-Id: I8e32e1c54dea0d0c85dd6d6753147099aa54b9b5
Reviewed-on: https://review.coreboot.org/c/coreboot/+/56494
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
2021-07-26 07:30:48 +00:00

79 lines
1.4 KiB
ArmAsm

/* SPDX-License-Identifier: GPL-2.0-only */
#include <rules.h>
/*
* 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 CONFIG(COOP_MULTITASKING)
/* Push the thread pointer. */
push $0
#endif
/* Push the CPU index and struct CPU */
push $0
push $0
/* 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
#if ((ENV_SEPARATE_VERSTAGE && CONFIG(VERSTAGE_DEBUG_SPINLOOP)) \
|| (ENV_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