blob: 7532c7d70753549b47a5b9b20493b3377cfd9f1d [file] [log] [blame]
Patrick Georgiac959032020-05-05 22:49:26 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Mariusz Szafranskia4041332017-08-02 17:28:17 +02002
3#include <device/pci_def.h>
Mariusz Szafranskia4041332017-08-02 17:28:17 +02004#include <cpu/x86/cr.h>
5#include <cpu/x86/post_code.h>
Martin Roth8c974502022-11-20 17:56:44 -07006#include <intelblocks/post_codes.h>
Mariusz Szafranskia4041332017-08-02 17:28:17 +02007
Arthur Heymans0eb9c572019-01-05 18:21:47 +01008#define CBFS_FILE_MAGIC 0
9#define CBFS_FILE_LEN (CBFS_FILE_MAGIC + 8)
10#define CBFS_FILE_TYPE (CBFS_FILE_LEN + 4)
11#define CBFS_FILE_CHECKSUM (CBFS_FILE_TYPE + 4)
12#define CBFS_FILE_OFFSET (CBFS_FILE_CHECKSUM + 4)
Mariusz Szafranskia4041332017-08-02 17:28:17 +020013
Kyösti Mälkki7522a8f2020-11-20 16:47:38 +020014.section .init, "ax", @progbits
15
Mariusz Szafranskia4041332017-08-02 17:28:17 +020016.extern temp_ram_init_params
17
18.global bootblock_pre_c_entry
19bootblock_pre_c_entry:
20
21.global cache_as_ram
22cache_as_ram:
lilacious40cb3fe2023-06-21 23:24:14 +020023 post_code(POSTCODE_BOOTBLOCK_CAR)
Mariusz Szafranskia4041332017-08-02 17:28:17 +020024
Arthur Heymans0f068a62021-05-03 10:59:45 +020025 movl $(CONFIG_FSP_T_LOCATION), %ebx
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +080026 add $0x94, %ebx
Mariusz Szafranskia4041332017-08-02 17:28:17 +020027
28 /*
29 * save mm2 into ebp, because TempRamInit API doesn't preserve
30 * mm2 register
31 */
32 movd %mm2, %ebp
33
34 /*
35 * ebx = FSP INFO HEADER
36 * Calculate entry into FSP
37 */
38 movl 0x30(%ebx), %eax /* Load TempRamInitEntryOffset */
39 addl 0x1c(%ebx), %eax /* add the FSP ImageBase */
40
41 /*
42 * Pass early init variables on a fake stack (no memory yet)
43 * as well as the return location
44 */
45 leal CAR_init_stack, %esp
46
47 /* call FSP binary to setup temporary stack */
48 jmp *%eax
49
50/*
51 * If the TempRamInit API is successful, then when returning, the ECX and
52 * EDX registers will point to the temporary but writeable memory range
53 * available to the bootloader where ECX is the start and EDX is the end of
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +080054 * the range i.e. [ECX,EDX). See FSP Integration Guide for more information.
Mariusz Szafranskia4041332017-08-02 17:28:17 +020055 *
56 * Return Values:
57 * EAX | Return Status
58 * ECX | Temporary Memory Start
59 * EDX | Temporary Memory End
60 * EBX, EDI, ESI, EBP, MM0, MM1 | Preserved Through API Call
61 */
62
63CAR_init_done:
64 cmp $0, %eax
65 jnz .halt_forever
66
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +080067 /* Setup bootblock stack */
Arthur Heymansfe9d2112019-11-27 11:20:57 +010068 movl $_ecar_stack, %esp
Arthur Heymans5a663342020-10-28 14:03:14 +010069 /*
70 * temp_memory_start/end reside in the .bss section, which gets cleared
71 * below. Save the FSP return value to the stack before writing those
72 * variables.
73 */
74 push %ecx
75 push %edx
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +080076
Kyösti Mälkki910490f2019-08-22 12:56:22 +030077 /* clear .bss section as it is not shared */
Mariusz Szafranskia4041332017-08-02 17:28:17 +020078 cld
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +080079 xor %eax, %eax
Kyösti Mälkki910490f2019-08-22 12:56:22 +030080 movl $(_ebss), %ecx
81 movl $(_bss), %edi
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +080082 sub %edi, %ecx
Mariusz Szafranskia4041332017-08-02 17:28:17 +020083 shrl $2, %ecx
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +080084 rep stosl
Mariusz Szafranskia4041332017-08-02 17:28:17 +020085
Arthur Heymans5a663342020-10-28 14:03:14 +010086 pop %edx
87 movl %edx, temp_memory_end
88 pop %ecx
89 movl %ecx, temp_memory_start
90
Mariusz Szafranskia4041332017-08-02 17:28:17 +020091 /* Restore the timestamp from bootblock_crt0.S (ebp:mm1) */
92 push %ebp
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +080093 movd %mm1, %eax
94 push %eax
Mariusz Szafranskia4041332017-08-02 17:28:17 +020095
96 /* We can call into C functions now */
97 call bootblock_c_entry
98
99 /* Never reached */
100
101.halt_forever:
lilacious40cb3fe2023-06-21 23:24:14 +0200102 post_code(POSTCODE_DEAD_CODE)
Mariusz Szafranskia4041332017-08-02 17:28:17 +0200103 hlt
104 jmp .halt_forever
105
Mariusz Szafranskia4041332017-08-02 17:28:17 +0200106CAR_init_stack:
107 .long CAR_init_done
108 .long temp_ram_init_params
109
110fsp_name:
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +0800111 .string "fspt.bin"