Aaron Durbin | 3d0071b | 2013-01-18 14:32:50 -0600 | [diff] [blame^] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2012 ChromeOS Authors |
| 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. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <cbmem.h> |
| 22 | #include <console/console.h> |
| 23 | |
| 24 | /* Mainboard needs to supply this symbol. */ |
| 25 | extern void romstage_main(unsigned long bist); |
| 26 | |
| 27 | void main(unsigned long bist) |
| 28 | { |
| 29 | int i; |
| 30 | const int num_guards = 4; |
| 31 | const u32 stack_guard = 0xdeadbeef; |
| 32 | u32 *stack_base = (void *)(CONFIG_DCACHE_RAM_BASE + |
| 33 | CONFIG_DCACHE_RAM_SIZE - |
| 34 | CONFIG_DCACHE_RAM_ROMSTAGE_STACK_SIZE); |
| 35 | |
| 36 | printk(BIOS_DEBUG, "Setting up stack guards.\n"); |
| 37 | for (i = 0; i < num_guards; i++) |
| 38 | stack_base[i] = stack_guard; |
| 39 | |
| 40 | romstage_main(bist); |
| 41 | |
| 42 | /* Check the stack. */ |
| 43 | for (i = 0; i < num_guards; i++) { |
| 44 | if (stack_base[i] == stack_guard) |
| 45 | continue; |
| 46 | printk(BIOS_DEBUG, "Smashed stack detected in romstage!\n"); |
| 47 | } |
| 48 | |
| 49 | #if CONFIG_CONSOLE_CBMEM |
| 50 | /* Keep this the last thing this function does. */ |
| 51 | cbmemc_reinit(); |
| 52 | #endif |
| 53 | } |