blob: 686a4c8c7e027fdf77b0ed8ca0a657eaf0707470 [file] [log] [blame]
Aaron Durbine6af4be2015-09-24 12:26:31 -05001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright 2015 Google Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Aaron Durbine6af4be2015-09-24 12:26:31 -050014 */
15
Aaron Durbin909c5122015-09-29 17:41:30 -050016#include <arch/early_variables.h>
Aaron Durbin64031672018-04-21 14:45:32 -060017#include <compiler.h>
Aaron Durbine6af4be2015-09-24 12:26:31 -050018#include <console/console.h>
Aaron Durbine6af4be2015-09-24 12:26:31 -050019#include <fsp/car.h>
Aaron Durbin909c5122015-09-29 17:41:30 -050020#include <fsp/util.h>
Aaron Durbin6d720f32015-12-08 17:00:23 -060021#include <program_loading.h>
Aaron Durbine6af4be2015-09-24 12:26:31 -050022#include <soc/intel/common/util.h>
23#include <timestamp.h>
24
Aaron Durbin909c5122015-09-29 17:41:30 -050025FSP_INFO_HEADER *fih_car CAR_GLOBAL;
26
27/* Save FSP_INFO_HEADER for TempRamExit() call in assembly. */
28static inline void set_fih_car(FSP_INFO_HEADER *fih)
29{
30 /* This variable is written in the raw form because it's only
31 * ever accessed in code that that has the cache-as-ram enabled. The
32 * assembly routine which tears down cache-as-ram utilizes this
33 * variable for determining where to find FSP. */
34 fih_car = fih;
35}
36
Aaron Durbine6af4be2015-09-24 12:26:31 -050037asmlinkage void *cache_as_ram_main(struct cache_as_ram_params *car_params)
38{
39 /* Initialize timestamp book keeping only once. */
40 timestamp_init(car_params->tsc);
41
42 /* Call into pre-console init code then initialize console. */
43 car_soc_pre_console_init();
44 car_mainboard_pre_console_init();
45 console_init();
46
47 printk(BIOS_DEBUG, "FSP TempRamInit successful\n");
48
49 printk(BIOS_SPEW, "bist: 0x%08x\n", car_params->bist);
50 printk(BIOS_SPEW, "tsc: 0x%016llx\n", car_params->tsc);
51
52 if (car_params->bootloader_car_start != CONFIG_DCACHE_RAM_BASE ||
53 car_params->bootloader_car_end !=
54 (CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE)) {
55 printk(BIOS_INFO, "CAR mismatch: %08x--%08x vs %08lx--%08lx\n",
56 CONFIG_DCACHE_RAM_BASE,
57 CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE,
58 (long)car_params->bootloader_car_start,
59 (long)car_params->bootloader_car_end);
60 }
61
62 car_soc_post_console_init();
63 car_mainboard_post_console_init();
64
Aaron Durbin909c5122015-09-29 17:41:30 -050065 set_fih_car(car_params->fih);
66
Elyes HAOUAS77537312016-07-30 15:37:26 +020067 /* Return new stack value in RAM back to assembly stub. */
Aaron Durbine6af4be2015-09-24 12:26:31 -050068 return cache_as_ram_stage_main(car_params->fih);
69}
70
Aaron Durbin909c5122015-09-29 17:41:30 -050071/* Entry point taken when romstage is called after a separate verstage. */
Teo Boon Tiongd8e34b22016-12-28 18:56:26 +080072asmlinkage void *romstage_c_entry(void)
Aaron Durbin909c5122015-09-29 17:41:30 -050073{
74 /* Need to locate the current FSP_INFO_HEADER. The cache-as-ram
75 * is still enabled. We can directly access work buffer here. */
76 FSP_INFO_HEADER *fih;
Aaron Durbin7e7a4df2015-12-08 14:34:35 -060077 struct prog fsp = PROG_INIT(PROG_REFCODE, "fsp.bin");
Aaron Durbin909c5122015-09-29 17:41:30 -050078
79 console_init();
80
Aaron Durbin6d720f32015-12-08 17:00:23 -060081 if (prog_locate(&fsp)) {
Aaron Durbin909c5122015-09-29 17:41:30 -050082 fih = NULL;
Aaron Durbin6d720f32015-12-08 17:00:23 -060083 printk(BIOS_ERR, "Unable to locate %s\n", prog_name(&fsp));
Aaron Durbin909c5122015-09-29 17:41:30 -050084 } else
Aaron Durbin6d720f32015-12-08 17:00:23 -060085 /* This leaks a mapping which this code assumes is benign as
86 * the flash is memory mapped CPU's address space. */
87 fih = find_fsp((uintptr_t)rdev_mmap_full(prog_rdev(&fsp)));
Aaron Durbin909c5122015-09-29 17:41:30 -050088
89 set_fih_car(fih);
90
Elyes HAOUAS77537312016-07-30 15:37:26 +020091 /* Return new stack value in RAM back to assembly stub. */
Aaron Durbin909c5122015-09-29 17:41:30 -050092 return cache_as_ram_stage_main(fih);
93}
94
Aaron Durbine6af4be2015-09-24 12:26:31 -050095asmlinkage void after_cache_as_ram(void *chipset_context)
96{
97 timestamp_add_now(TS_FSP_TEMP_RAM_EXIT_END);
98 printk(BIOS_DEBUG, "FspTempRamExit returned successfully\n");
99 soc_display_mtrrs();
100
101 after_cache_as_ram_stage();
102}
103
Aaron Durbin64031672018-04-21 14:45:32 -0600104void __weak car_mainboard_pre_console_init(void)
Aaron Durbine6af4be2015-09-24 12:26:31 -0500105{
106}
107
Aaron Durbin64031672018-04-21 14:45:32 -0600108void __weak car_soc_pre_console_init(void)
Aaron Durbine6af4be2015-09-24 12:26:31 -0500109{
110}
111
Aaron Durbin64031672018-04-21 14:45:32 -0600112void __weak car_mainboard_post_console_init(void)
Aaron Durbine6af4be2015-09-24 12:26:31 -0500113{
114}
115
Aaron Durbin64031672018-04-21 14:45:32 -0600116void __weak car_soc_post_console_init(void)
Aaron Durbine6af4be2015-09-24 12:26:31 -0500117{
118}