blob: d04b6e120c718cb34053e9af9b5111186589b05f [file] [log] [blame]
Kyösti Mälkkia4ffe9d2016-06-27 13:24:11 +03001/*
2 * This file is part of the coreboot project.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#include <arch/cpu.h>
15#include <console/console.h>
Kyösti Mälkkie325b222016-06-17 11:04:37 +030016#include <cpu/intel/romstage.h>
Kyösti Mälkkia4ffe9d2016-06-27 13:24:11 +030017#include <program_loading.h>
18
19#define DCACHE_RAM_ROMSTAGE_STACK_SIZE 0x800
Kyösti Mälkkie325b222016-06-17 11:04:37 +030020
21void * asmlinkage romstage_main(unsigned long bist)
22{
Kyösti Mälkkia4ffe9d2016-06-27 13:24:11 +030023 int i;
24 void *romstage_stack_after_car;
25 const int num_guards = 4;
26 const u32 stack_guard = 0xdeadbeef;
27 u32 *stack_base = (void *)(CONFIG_DCACHE_RAM_BASE +
28 CONFIG_DCACHE_RAM_SIZE -
29 DCACHE_RAM_ROMSTAGE_STACK_SIZE);
30
31 for (i = 0; i < num_guards; i++)
32 stack_base[i] = stack_guard;
33
Kyösti Mälkkie325b222016-06-17 11:04:37 +030034 mainboard_romstage_entry(bist);
Kyösti Mälkkia4ffe9d2016-06-27 13:24:11 +030035
36 /* Check the stack. */
37 for (i = 0; i < num_guards; i++) {
38 if (stack_base[i] == stack_guard)
39 continue;
40 printk(BIOS_DEBUG, "Smashed stack detected in romstage!\n");
41 }
42
43 /* Get the stack to use after cache-as-ram is torn down. */
44 if (IS_ENABLED(CONFIG_LATE_CBMEM_INIT))
45 romstage_stack_after_car = (void*)CONFIG_RAMTOP;
46 else
47 romstage_stack_after_car = setup_stack_and_mtrrs();
48
49 return romstage_stack_after_car;
50}
51
52void asmlinkage romstage_after_car(void)
53{
54 /* Load the ramstage. */
55 run_ramstage();
Kyösti Mälkkie325b222016-06-17 11:04:37 +030056}