1/* SPDX-License-Identifier: GPL-2.0-or-later */ 2 3#include <cpu/x86/64bit/entry64.inc> 4#include <cpu/x86/post_code.h> 5 6.section .init, "ax", @progbits 7 8.extern temp_ram_init_params 9 10.code32 11 12.global bootblock_pre_c_entry 13bootblock_pre_c_entry: 14 15.global cache_as_ram 16cache_as_ram: 17 post_code(POSTCODE_BOOTBLOCK_CAR) 18 19 movl $(CONFIG_FSP_T_LOCATION), %ebx 20 add $0x94, %ebx 21 22 /* 23 * save mm2 into ebp, because TempRamInit API doesn't preserve 24 * mm2 register 25 */ 26 movd %mm2, %ebp 27 28 /* 29 * ebx = FSP INFO HEADER 30 * Calculate entry into FSP 31 */ 32 movl 0x30(%ebx), %eax /* Load TempRamInitEntryOffset */ 33 addl 0x1c(%ebx), %eax /* add the FSP ImageBase */ 34 35 /* 36 * Pass early init variables on a fake stack (no memory yet) 37 * as well as the return location 38 */ 39 leal CAR_init_stack, %esp 40 41 /* call FSP binary to setup temporary stack */ 42 jmp *%eax 43 44/* 45 * If the TempRamInit API is successful, then when returning, the ECX and 46 * EDX registers will point to the temporary but writeable memory range 47 * available to the bootloader where ECX is the start and EDX is the end of 48 * the range i.e. [ECX,EDX). See FSP Integration Guide for more information. 49 * 50 * Return Values: 51 * EAX | Return Status 52 * ECX | Temporary Memory Start 53 * EDX | Temporary Memory End 54 * EBX, EDI, ESI, EBP, MM0, MM1 | Preserved Through API Call 55 */ 56 57CAR_init_done: 58 cmp $0, %eax 59 jnz .halt_forever 60 61 /* Setup bootblock stack */ 62 movl $_ecar_stack, %esp 63 /* 64 * temp_memory_start/end reside in the .bss section, which gets cleared 65 * below. Save the FSP return value to the stack before writing those 66 * variables. 67 */ 68 push %ecx 69 push %edx 70 71 /* clear .bss section as it is not shared */ 72 cld 73 xor %eax, %eax 74 movl $(_ebss), %ecx 75 movl $(_bss), %edi 76 sub %edi, %ecx 77 shrl $2, %ecx 78 rep stosl 79 80 pop %edx 81 movl %edx, temp_memory_end 82 pop %ecx 83 movl %ecx, temp_memory_start 84 85#if ENV_X86_64 86 setup_longmode $PM4LE 87 movl %ebp, %edi 88 shlq $32, %rdi 89 movd %mm1, %rsi 90 or %rsi, %rdi 91 andl $0xfffffff0, %esp 92#else 93 /* Restore the timestamp from bootblock_crt0.S (ebp:mm1) */ 94 push %ebp 95 movd %mm1, %eax 96 push %eax 97#endif 98 99 /* Copy .data section content to Cache-As-Ram */ 100#include <cpu/x86/copy_data_section.inc> 101 102 /* We can call into C functions now */ 103 call bootblock_c_entry 104 105 /* Never reached */ 106 107.halt_forever: 108 post_code(POSTCODE_DEAD_CODE) 109 hlt 110 jmp .halt_forever 111 112CAR_init_stack: 113 .long CAR_init_done 114 .long temp_ram_init_params 115 116fsp_name: 117 .string "fspt.bin" 118