blob: b65d0a53ea5ed1b9280a8d1ca56fe5aa893c70bc [file] [log] [blame]
Angel Pons8a3453f2020-04-02 23:48:19 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Aaron Durbine6af4be2015-09-24 12:26:31 -05003
Kyösti Mälkkia963acd2019-08-16 20:34:25 +03004#include <arch/romstage.h>
Arthur Heymans8a1b94c2019-05-25 09:47:01 +02005#include <arch/symbols.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>
Kyösti Mälkkib2a5f0b2019-08-04 19:54:32 +030010#include <cpu/x86/smm.h>
Aaron Durbine6af4be2015-09-24 12:26:31 -050011#include <fsp/car.h>
Aaron Durbin909c5122015-09-29 17:41:30 -050012#include <fsp/util.h>
Aaron Durbin6d720f32015-12-08 17:00:23 -060013#include <program_loading.h>
Aaron Durbine6af4be2015-09-24 12:26:31 -050014
Kyösti Mälkki5bc641a2019-08-09 09:37:49 +030015void fill_postcar_frame(struct postcar_frame *pcf)
Aaron Durbin909c5122015-09-29 17:41:30 -050016{
Kyösti Mälkki8f23b5d2019-06-30 21:00:07 +030017 uintptr_t top_of_ram;
Arthur Heymansbe291e82019-01-06 07:35:11 +010018
Kyösti Mälkki8f23b5d2019-06-30 21:00:07 +030019 /* Cache at least 8 MiB below the top of ram, and at most 8 MiB
20 * above top of the ram. This satisfies MTRR alignment requirement
21 * with different TSEG size configurations. */
22 top_of_ram = ALIGN_DOWN((uintptr_t)cbmem_top(), 8*MiB);
Kyösti Mälkki5bc641a2019-08-09 09:37:49 +030023 postcar_frame_add_mtrr(pcf, top_of_ram - 8*MiB, 16*MiB, MTRR_TYPE_WRBACK);
Arthur Heymansbe291e82019-01-06 07:35:11 +010024
Aaron Durbin909c5122015-09-29 17:41:30 -050025}
26
Arthur Heymans59b65422019-05-23 15:24:30 +020027/* This is the romstage entry called from cpu/intel/car/romstage.c */
Kyösti Mälkki157b1892019-08-16 14:02:25 +030028void mainboard_romstage_entry(void)
Aaron Durbin909c5122015-09-29 17:41:30 -050029{
30 /* Need to locate the current FSP_INFO_HEADER. The cache-as-ram
31 * is still enabled. We can directly access work buffer here. */
Aaron Durbin7e7a4df2015-12-08 14:34:35 -060032 struct prog fsp = PROG_INIT(PROG_REFCODE, "fsp.bin");
Aaron Durbin909c5122015-09-29 17:41:30 -050033
Jacob Garberf7f90f72019-05-28 15:37:37 -060034 if (prog_locate(&fsp))
35 die_with_post_code(POST_INVALID_CBFS, "Unable to locate fsp.bin");
36
37 /* This leaks a mapping which this code assumes is benign as
38 * the flash is memory mapped CPU's address space. */
39 FSP_INFO_HEADER *fih = find_fsp((uintptr_t)rdev_mmap_full(prog_rdev(&fsp)));
Aaron Durbin909c5122015-09-29 17:41:30 -050040
John Zhaod3a73282019-05-31 09:58:49 -070041 if (!fih)
42 die("Invalid FSP header\n");
43
Arthur Heymansbe291e82019-01-06 07:35:11 +010044 cache_as_ram_stage_main(fih);
Aaron Durbine6af4be2015-09-24 12:26:31 -050045}