blob: dd4522103089b9650675675c4734f2dac1f63cfa [file] [log] [blame]
Lee Leahy3dad4892015-05-05 11:14:02 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2000,2007 Ronald G. Minnich <rminnich@gmail.com>
5 * Copyright (C) 2007-2008 coresystems GmbH
6 * Copyright (C) 2013-2014 Sage Electronic Engineering, LLC.
Lee Leahyb5ad8272015-04-20 15:29:16 -07007 * Copyright (C) 2015 Intel Corp.
Lee Leahy3dad4892015-05-05 11:14:02 -07008 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 2 of the License.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
Patrick Georgib890a122015-03-26 15:17:45 +010020 * Foundation, Inc.
Lee Leahy3dad4892015-05-05 11:14:02 -070021 */
22
Lee Leahyb5ad8272015-04-20 15:29:16 -070023/*
24 * Replacement for cache_as_ram.inc when using the FSP binary. This code
25 * locates the FSP binary, initializes the cache as RAM and performs the
26 * first stage of initialization. Next this code switches the stack from
27 * the cache to RAM and then disables the cache as RAM. Finally this code
28 * performs the final stage of initialization.
29 */
30
Lee Leahy3dad4892015-05-05 11:14:02 -070031
Lee Leahy3dad4892015-05-05 11:14:02 -070032#define LHLT_DELAY 0x50000 /* I/O delay between post codes on failure */
33
Lee Leahyb5ad8272015-04-20 15:29:16 -070034 /*
35 * eax: BIST value
36 * mm0: low 32-bits of TSC value
37 * mm1: high 32-bits of TSC value
38 */
39
40 mov %eax, %edi
Lee Leahy3dad4892015-05-05 11:14:02 -070041
42cache_as_ram:
43 post_code(0x20)
44
45 /*
Lee Leahyb5ad8272015-04-20 15:29:16 -070046 * edi: BIST value
47 * mm0: low 32-bits of TSC value
48 * mm1: high 32-bits of TSC value
49 */
50
51 /*
Lee Leahy3dad4892015-05-05 11:14:02 -070052 * Find the FSP binary in cbfs.
53 * Make a fake stack that has the return value back to this code.
54 */
Lee Leahyb5ad8272015-04-20 15:29:16 -070055 lea fake_fsp_stack, %esp
56 jmp find_fsp
Lee Leahy3dad4892015-05-05 11:14:02 -070057find_fsp_ret:
58 /* Save the FSP location */
Lee Leahyb5ad8272015-04-20 15:29:16 -070059 mov %eax, %ebp
60
61 /*
62 * Only when a valid FSP binary is found at CONFIG_FSP_LOC is
63 * the returned FSP_INFO_HEADER structure address above the base
64 * address of FSP binary specified by the CONFIG_FSP_LOC value.
65 * All of the error values are in the 0x8xxxxxxx range which are
66 * below the CONFIG_FSP_LOC value.
67 */
68 cmp $CONFIG_FSP_LOC, %eax
69 jbe halt1
Lee Leahy3dad4892015-05-05 11:14:02 -070070
71 post_code(0x22)
72
73 /* Calculate entry into FSP */
Lee Leahyb5ad8272015-04-20 15:29:16 -070074 mov 0x30(%ebp), %eax /* Load TempRamInitEntry */
75 add 0x1c(%ebp), %eax /* add in the offset for FSP */
Lee Leahy3dad4892015-05-05 11:14:02 -070076
77 /*
78 * Pass early init variables on a fake stack (no memory yet)
79 * as well as the return location
80 */
Lee Leahyb5ad8272015-04-20 15:29:16 -070081 lea CAR_init_stack, %esp
Lee Leahy3dad4892015-05-05 11:14:02 -070082
83 /*
Lee Leahyb5ad8272015-04-20 15:29:16 -070084 * BIST value is zero
85 * eax: TempRamInitApi address
86 * ebp: FSP_INFO_HEADER address
87 * edi: BIST value
88 * esi: Not used
89 * mm0: low 32-bits of TSC value
90 * mm1: high 32-bits of TSC value
Lee Leahy3dad4892015-05-05 11:14:02 -070091 */
Lee Leahy3dad4892015-05-05 11:14:02 -070092
Lee Leahyb5ad8272015-04-20 15:29:16 -070093 /* call FSP binary to setup temporary stack */
94 jmp *%eax
95
96CAR_init_done:
97 addl $4, %esp
98
99 /*
100 * ebp: FSP_INFO_HEADER address
101 * ecx: Temp RAM base
102 * edx: Temp RAM top
103 * edi: BIST value
104 * mm0: low 32-bits of TSC value
105 * mm1: high 32-bits of TSC value
106 */
107
108 cmp $0, %eax
109 jne halt2
110
111 /* Setup bootloader stack */
112 movl %edx, %esp
113
Lee Leahyb5ad8272015-04-20 15:29:16 -0700114 /*
115 * ebp: FSP_INFO_HEADER address
116 * ecx: Temp RAM base
117 * edx: Temp RAM top
Aaron Durbine1ecfc92015-09-16 15:18:04 -0500118 * edi: BIST value
Lee Leahyb5ad8272015-04-20 15:29:16 -0700119 * esp: Top of stack in temp RAM
120 * mm0: low 32-bits of TSC value
121 * mm1: high 32-bits of TSC value
Lee Leahyb5ad8272015-04-20 15:29:16 -0700122 */
123
Aaron Durbine6af4be2015-09-24 12:26:31 -0500124 /* Create cache_as_ram_params on stack */
Aaron Durbine1ecfc92015-09-16 15:18:04 -0500125 pushl %edx /* bootloader CAR end */
126 pushl %ecx /* bootloader CAR begin */
127 pushl %ebp /* FSP_INFO_HEADER */
Aaron Durbine1ecfc92015-09-16 15:18:04 -0500128 pushl %edi /* bist */
129 movd %mm1, %eax
130 pushl %eax /* tsc[63:32] */
131 movd %mm0, %eax
132 pushl %eax /* tsc[31:0] */
133 pushl %esp /* pointer to cache_as_ram_params */
134
135 /* Save FSP_INFO_HEADER location in ebx */
136 mov %ebp, %ebx
137
Lee Leahyb5ad8272015-04-20 15:29:16 -0700138 /* Coreboot assumes stack/heap region will be zero */
139 cld
140 movl %ecx, %edi
141 neg %ecx
Aaron Durbine1ecfc92015-09-16 15:18:04 -0500142 /* Only clear up to current stack value. */
143 add %esp, %ecx
Lee Leahyb5ad8272015-04-20 15:29:16 -0700144 shrl $2, %ecx
145 xorl %eax, %eax
146 rep stosl
147
Lee Leahy3dad4892015-05-05 11:14:02 -0700148before_romstage:
149 post_code(0x23)
150
Aaron Durbine6af4be2015-09-24 12:26:31 -0500151 /* Call cache_as_ram_main(struct cache_as_ram_params *) */
152 call cache_as_ram_main
Lee Leahy3dad4892015-05-05 11:14:02 -0700153
Aaron Durbine6af4be2015-09-24 12:26:31 -0500154#include "after_raminit.S"
Lee Leahyb5ad8272015-04-20 15:29:16 -0700155
156 movb $0x69, %ah
157 jmp .Lhlt
Lee Leahy3dad4892015-05-05 11:14:02 -0700158
159halt1:
160 /*
Lee Leahyb5ad8272015-04-20 15:29:16 -0700161 * Failures for postcode 0xBA - failed in fsp_fih_early_find()
Lee Leahy3dad4892015-05-05 11:14:02 -0700162 *
163 * Values are:
164 * 0x01 - FV signature, "_FVH" not present
165 * 0x02 - FFS GUID not present
166 * 0x03 - FSP INFO Header not found
167 * 0x04 - ImageBase does not equal CONFIG_FSP_LOC - Is the FSP rebased to
168 * a different location, or does it need to be?
169 * 0x05 - FSP INFO Header signature "FSPH" not found
170 * 0x06 - FSP Image ID is not the expected ID.
171 */
Lee Leahyb5ad8272015-04-20 15:29:16 -0700172 movb $0xBA, %ah
173 jmp .Lhlt
Lee Leahy3dad4892015-05-05 11:14:02 -0700174
175halt2:
176 /*
177 * Failures for postcode 0xBB - failed in the FSP:
178 *
179 * 0x00 - FSP_SUCCESS: Temp RAM was initialized successfully.
180 * 0x02 - FSP_INVALID_PARAMETER: Input parameters are invalid.
Lee Leahy3dad4892015-05-05 11:14:02 -0700181 * 0x03 - FSP_UNSUPPORTED: The FSP calling conditions were not met.
182 * 0x07 - FSP_DEVICE_ERROR: Temp RAM initialization failed
Lee Leahyb5ad8272015-04-20 15:29:16 -0700183 * 0x0E - FSP_NOT_FOUND: No valid microcode was found in the microcode region.
Lee Leahy3dad4892015-05-05 11:14:02 -0700184 * 0x14 - FSP_ALREADY_STARTED: Temp RAM initialization has been invoked
185 */
Lee Leahyb5ad8272015-04-20 15:29:16 -0700186 movb $0xBB, %ah
187 jmp .Lhlt
188
Lee Leahy3dad4892015-05-05 11:14:02 -0700189.Lhlt:
Lee Leahyb5ad8272015-04-20 15:29:16 -0700190 xchg %al, %ah
191#if IS_ENABLED(CONFIG_POST_IO)
192 outb %al, $CONFIG_POST_IO_PORT
Lee Leahy3dad4892015-05-05 11:14:02 -0700193#else
194 post_code(POST_DEAD_CODE)
195#endif
Lee Leahyb5ad8272015-04-20 15:29:16 -0700196 movl $LHLT_DELAY, %ecx
Lee Leahy3dad4892015-05-05 11:14:02 -0700197.Lhlt_Delay:
Lee Leahyb5ad8272015-04-20 15:29:16 -0700198 outb %al, $0xED
199 loop .Lhlt_Delay
200 jmp .Lhlt
Lee Leahy3dad4892015-05-05 11:14:02 -0700201
202/*
203 * esp is set to this location so that the call into and return from the FSP
204 * in find_fsp will work.
205 */
206 .align 4
207fake_fsp_stack:
Lee Leahyb5ad8272015-04-20 15:29:16 -0700208 .long find_fsp_ret
Lee Leahya8874922015-08-26 14:58:29 -0700209 .long CONFIG_FSP_LOC /* FSP base address */
Lee Leahy3dad4892015-05-05 11:14:02 -0700210
211CAR_init_params:
Lee Leahyb5ad8272015-04-20 15:29:16 -0700212 .long CONFIG_CPU_MICROCODE_CBFS_LOC /* Microcode Location */
213 .long CONFIG_CPU_MICROCODE_CBFS_LEN /* Microcode Length */
214 .long 0xFFFFFFFF - CONFIG_CBFS_SIZE + 1 /* Firmware Location */
215 .long CONFIG_CBFS_SIZE /* Total Firmware Length */
Lee Leahy3dad4892015-05-05 11:14:02 -0700216
217CAR_init_stack:
Lee Leahyb5ad8272015-04-20 15:29:16 -0700218 .long CAR_init_done
219 .long CAR_init_params