blob: 173ebf7699d297a43d78999ef084cc078c94a225 [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>
6
Arthur Heymans0eb9c572019-01-05 18:21:47 +01007#define CBFS_FILE_MAGIC 0
8#define CBFS_FILE_LEN (CBFS_FILE_MAGIC + 8)
9#define CBFS_FILE_TYPE (CBFS_FILE_LEN + 4)
10#define CBFS_FILE_CHECKSUM (CBFS_FILE_TYPE + 4)
11#define CBFS_FILE_OFFSET (CBFS_FILE_CHECKSUM + 4)
Mariusz Szafranskia4041332017-08-02 17:28:17 +020012
Kyösti Mälkki7522a8f2020-11-20 16:47:38 +020013.section .init, "ax", @progbits
14
Mariusz Szafranskia4041332017-08-02 17:28:17 +020015.extern temp_ram_init_params
16
17.global bootblock_pre_c_entry
18bootblock_pre_c_entry:
19
20.global cache_as_ram
21cache_as_ram:
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +080022 post_code(0x21)
Mariusz Szafranskia4041332017-08-02 17:28:17 +020023
Arthur Heymans0f068a62021-05-03 10:59:45 +020024 movl $(CONFIG_FSP_T_LOCATION), %ebx
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +080025 add $0x94, %ebx
Mariusz Szafranskia4041332017-08-02 17:28:17 +020026
27 /*
28 * save mm2 into ebp, because TempRamInit API doesn't preserve
29 * mm2 register
30 */
31 movd %mm2, %ebp
32
33 /*
34 * ebx = FSP INFO HEADER
35 * Calculate entry into FSP
36 */
37 movl 0x30(%ebx), %eax /* Load TempRamInitEntryOffset */
38 addl 0x1c(%ebx), %eax /* add the FSP ImageBase */
39
40 /*
41 * Pass early init variables on a fake stack (no memory yet)
42 * as well as the return location
43 */
44 leal CAR_init_stack, %esp
45
46 /* call FSP binary to setup temporary stack */
47 jmp *%eax
48
49/*
50 * If the TempRamInit API is successful, then when returning, the ECX and
51 * EDX registers will point to the temporary but writeable memory range
52 * available to the bootloader where ECX is the start and EDX is the end of
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +080053 * the range i.e. [ECX,EDX). See FSP Integration Guide for more information.
Mariusz Szafranskia4041332017-08-02 17:28:17 +020054 *
55 * Return Values:
56 * EAX | Return Status
57 * ECX | Temporary Memory Start
58 * EDX | Temporary Memory End
59 * EBX, EDI, ESI, EBP, MM0, MM1 | Preserved Through API Call
60 */
61
62CAR_init_done:
63 cmp $0, %eax
64 jnz .halt_forever
65
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +080066 /* Setup bootblock stack */
Arthur Heymansfe9d2112019-11-27 11:20:57 +010067 movl $_ecar_stack, %esp
Arthur Heymans5a663342020-10-28 14:03:14 +010068 /*
69 * temp_memory_start/end reside in the .bss section, which gets cleared
70 * below. Save the FSP return value to the stack before writing those
71 * variables.
72 */
73 push %ecx
74 push %edx
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +080075
Kyösti Mälkki910490f2019-08-22 12:56:22 +030076 /* clear .bss section as it is not shared */
Mariusz Szafranskia4041332017-08-02 17:28:17 +020077 cld
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +080078 xor %eax, %eax
Kyösti Mälkki910490f2019-08-22 12:56:22 +030079 movl $(_ebss), %ecx
80 movl $(_bss), %edi
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +080081 sub %edi, %ecx
Mariusz Szafranskia4041332017-08-02 17:28:17 +020082 shrl $2, %ecx
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +080083 rep stosl
Mariusz Szafranskia4041332017-08-02 17:28:17 +020084
Arthur Heymans5a663342020-10-28 14:03:14 +010085 pop %edx
86 movl %edx, temp_memory_end
87 pop %ecx
88 movl %ecx, temp_memory_start
89
Mariusz Szafranskia4041332017-08-02 17:28:17 +020090 /* Restore the timestamp from bootblock_crt0.S (ebp:mm1) */
91 push %ebp
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +080092 movd %mm1, %eax
93 push %eax
Mariusz Szafranskia4041332017-08-02 17:28:17 +020094
95 /* We can call into C functions now */
96 call bootblock_c_entry
97
98 /* Never reached */
99
100.halt_forever:
101 post_code(POST_DEAD_CODE)
102 hlt
103 jmp .halt_forever
104
Mariusz Szafranskia4041332017-08-02 17:28:17 +0200105CAR_init_stack:
106 .long CAR_init_done
107 .long temp_ram_init_params
108
109fsp_name:
Praveen hodagatta praneshb66757f2018-10-23 02:43:05 +0800110 .string "fspt.bin"