blob: 7455d300470097985abc4091984a06c75d775037 [file] [log] [blame]
Angel Pons8a3453f2020-04-02 23:48:19 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Aaron Durbine6af4be2015-09-24 12:26:31 -05002
Kyösti Mälkkia963acd2019-08-16 20:34:25 +03003#include <arch/romstage.h>
Arthur Heymans8a1b94c2019-05-25 09:47:01 +02004#include <arch/symbols.h>
Julius Werner53584672021-01-11 16:44:06 -08005#include <cbfs.h>
Kyösti Mälkki8f23b5d2019-06-30 21:00:07 +03006#include <cbmem.h>
Aaron Durbine6af4be2015-09-24 12:26:31 -05007#include <console/console.h>
Elyes HAOUAS2195f7a2019-06-21 07:20:12 +02008#include <commonlib/helpers.h>
Nico Huberd67edca2018-11-13 19:28:07 +01009#include <cpu/x86/mtrr.h>
Aaron Durbine6af4be2015-09-24 12:26:31 -050010#include <fsp/car.h>
Aaron Durbin909c5122015-09-29 17:41:30 -050011#include <fsp/util.h>
Aaron Durbine6af4be2015-09-24 12:26:31 -050012
Kyösti Mälkki5bc641a2019-08-09 09:37:49 +030013void fill_postcar_frame(struct postcar_frame *pcf)
Aaron Durbin909c5122015-09-29 17:41:30 -050014{
Kyösti Mälkki8f23b5d2019-06-30 21:00:07 +030015 uintptr_t top_of_ram;
Arthur Heymansbe291e82019-01-06 07:35:11 +010016
Kyösti Mälkki8f23b5d2019-06-30 21:00:07 +030017 /* Cache at least 8 MiB below the top of ram, and at most 8 MiB
18 * above top of the ram. This satisfies MTRR alignment requirement
19 * with different TSEG size configurations. */
20 top_of_ram = ALIGN_DOWN((uintptr_t)cbmem_top(), 8*MiB);
Kyösti Mälkki5bc641a2019-08-09 09:37:49 +030021 postcar_frame_add_mtrr(pcf, top_of_ram - 8*MiB, 16*MiB, MTRR_TYPE_WRBACK);
Aaron Durbin909c5122015-09-29 17:41:30 -050022}
23
Arthur Heymans59b65422019-05-23 15:24:30 +020024/* This is the romstage entry called from cpu/intel/car/romstage.c */
Kyösti Mälkki157b1892019-08-16 14:02:25 +030025void mainboard_romstage_entry(void)
Aaron Durbin909c5122015-09-29 17:41:30 -050026{
27 /* Need to locate the current FSP_INFO_HEADER. The cache-as-ram
28 * is still enabled. We can directly access work buffer here. */
Julius Werner53584672021-01-11 16:44:06 -080029 void *fsp = cbfs_map("fsp.bin", NULL);
Aaron Durbin909c5122015-09-29 17:41:30 -050030
Julius Werner53584672021-01-11 16:44:06 -080031 if (!fsp)
lilacious40cb3fe2023-06-21 23:24:14 +020032 die_with_post_code(POSTCODE_INVALID_CBFS, "Unable to locate fsp.bin");
Jacob Garberf7f90f72019-05-28 15:37:37 -060033
34 /* This leaks a mapping which this code assumes is benign as
35 * the flash is memory mapped CPU's address space. */
Julius Werner53584672021-01-11 16:44:06 -080036 FSP_INFO_HEADER *fih = find_fsp((uintptr_t)fsp);
Aaron Durbin909c5122015-09-29 17:41:30 -050037
John Zhaod3a73282019-05-31 09:58:49 -070038 if (!fih)
39 die("Invalid FSP header\n");
40
Arthur Heymansbe291e82019-01-06 07:35:11 +010041 cache_as_ram_stage_main(fih);
Aaron Durbine6af4be2015-09-24 12:26:31 -050042}