Kyösti Mälkki | a4ffe9d | 2016-06-27 13:24:11 +0300 | [diff] [blame^] | 1 | /* |
| 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älkki | e325b22 | 2016-06-17 11:04:37 +0300 | [diff] [blame] | 16 | #include <cpu/intel/romstage.h> |
Kyösti Mälkki | a4ffe9d | 2016-06-27 13:24:11 +0300 | [diff] [blame^] | 17 | #include <program_loading.h> |
| 18 | |
| 19 | #define DCACHE_RAM_ROMSTAGE_STACK_SIZE 0x800 |
Kyösti Mälkki | e325b22 | 2016-06-17 11:04:37 +0300 | [diff] [blame] | 20 | |
| 21 | void * asmlinkage romstage_main(unsigned long bist) |
| 22 | { |
Kyösti Mälkki | a4ffe9d | 2016-06-27 13:24:11 +0300 | [diff] [blame^] | 23 | 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älkki | e325b22 | 2016-06-17 11:04:37 +0300 | [diff] [blame] | 34 | mainboard_romstage_entry(bist); |
Kyösti Mälkki | a4ffe9d | 2016-06-27 13:24:11 +0300 | [diff] [blame^] | 35 | |
| 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 | |
| 52 | void asmlinkage romstage_after_car(void) |
| 53 | { |
| 54 | /* Load the ramstage. */ |
| 55 | run_ramstage(); |
Kyösti Mälkki | e325b22 | 2016-06-17 11:04:37 +0300 | [diff] [blame] | 56 | } |