1/* SPDX-License-Identifier: GPL-2.0-only */ 2 3/* 4 * This path is for stages that are post bootblock. The gdt is reloaded 5 * to accommodate platforms that are executing out of CAR. In order to 6 * continue with C code execution one needs to set stack pointer and 7 * clear .bss variables that are stage specific. 8 */ 9 10#if CONFIG(RESET_VECTOR_IN_RAM) 11 #define _STACK_TOP _eearlyram_stack 12#else 13 #define _STACK_TOP _ecar_stack 14#endif 15 16#if ENV_X86_64 17.code64 18#else 19.code32 20#endif 21 22.section ".text._start", "ax", @progbits 23.global _start 24_start: 25 26 /* Migrate GDT to this text segment */ 27#if ENV_X86_64 28 call gdt_init64 29#else 30 call gdt_init 31#endif 32 33 /* reset stack pointer to CAR/EARLYRAM stack */ 34 mov $_STACK_TOP, %esp 35 36#if ENV_SEPARATE_DATA_AND_BSS 37 /* clear .bss section as it is not shared */ 38 cld 39 xor %eax, %eax 40 movl $(_ebss), %ecx 41 movl $(_bss), %edi 42 sub %edi, %ecx 43 shrl $2, %ecx 44 rep stosl 45 46 /* Copy .data section content to Cache-As-Ram */ 47 movl $(_edata), %ecx 48 movl $(_data), %edi 49 sub %edi, %ecx 50 shrl $2, %ecx 51 movl $(_data_load),%esi 52 rep movsl 53#endif 54 55#if ((ENV_SEPARATE_VERSTAGE && CONFIG(VERSTAGE_DEBUG_SPINLOOP)) \ 56 || (ENV_SEPARATE_ROMSTAGE && CONFIG(ROMSTAGE_DEBUG_SPINLOOP))) 57 58 /* Wait for a JTAG debugger to break in and set EBX non-zero */ 59 xor %ebx, %ebx 60 61debug_spinloop: 62 cmp $0, %ebx 63 jz debug_spinloop 64#endif 65 66 andl $0xfffffff0, %esp 67#if CONFIG(IDT_IN_EVERY_STAGE) 68 call exception_init 69#endif 70 71#if CONFIG(ASAN_IN_ROMSTAGE) 72 call asan_init 73#endif 74 call car_stage_entry 75 76 /* Expect to never return. */ 771: 78 jmp 1b 79