Martin Roth | 9df9e939 | 2016-01-12 15:55:28 -0700 | [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 | |
Kyösti Mälkki | 5a5c886 | 2014-01-26 14:41:54 +0200 | [diff] [blame] | 14 | #include <smp/node.h> |
Alexandru Gagniuc | cc96624 | 2016-01-07 19:10:24 -0800 | [diff] [blame] | 15 | #include <arch/bootblock_romcc.h> |
Edwin Beasant | eb50c7d | 2010-07-06 21:05:04 +0000 | [diff] [blame] | 16 | #include <pc80/mc146818rtc.h> |
Patrick Georgi | 546953c | 2014-11-29 10:38:17 +0100 | [diff] [blame] | 17 | #include <halt.h> |
Patrick Georgi | c9fa96d | 2010-02-24 13:58:23 +0000 | [diff] [blame] | 18 | |
Lee Leahy | 9c7c6f7 | 2017-03-16 11:24:09 -0700 | [diff] [blame] | 19 | static const char *get_fallback(const char *stagelist) |
| 20 | { |
Lee Leahy | 0b5678f | 2017-03-16 16:01:40 -0700 | [diff] [blame] | 21 | while (*stagelist) |
| 22 | stagelist++; |
Patrick Georgi | 06c0429 | 2012-01-07 19:15:43 +0100 | [diff] [blame] | 23 | return ++stagelist; |
| 24 | } |
| 25 | |
Patrick Georgi | c9fa96d | 2010-02-24 13:58:23 +0000 | [diff] [blame] | 26 | static void main(unsigned long bist) |
| 27 | { |
Martin Roth | 1b304cc | 2015-11-30 09:49:21 -0700 | [diff] [blame] | 28 | u8 boot_mode; |
| 29 | const char *default_filenames = |
| 30 | "normal/romstage\0fallback/romstage"; |
Kyösti Mälkki | f28dbe0 | 2011-12-05 20:17:17 +0200 | [diff] [blame] | 31 | |
Patrick Georgi | c9fa96d | 2010-02-24 13:58:23 +0000 | [diff] [blame] | 32 | if (boot_cpu()) { |
Kyösti Mälkki | f902248 | 2012-11-14 08:01:44 +0200 | [diff] [blame] | 33 | bootblock_mainboard_init(); |
Patrick Georgi | c9fa96d | 2010-02-24 13:58:23 +0000 | [diff] [blame] | 34 | |
Kyösti Mälkki | f28dbe0 | 2011-12-05 20:17:17 +0200 | [diff] [blame] | 35 | sanitize_cmos(); |
Nico Huber | 5ce0fe1 | 2017-07-25 16:11:36 +0200 | [diff] [blame] | 36 | |
Kyösti Mälkki | f28dbe0 | 2011-12-05 20:17:17 +0200 | [diff] [blame] | 37 | boot_mode = do_normal_boot(); |
| 38 | } else { |
Patrick Georgi | fab35e3 | 2011-03-08 07:50:43 +0000 | [diff] [blame] | 39 | |
Kyösti Mälkki | f28dbe0 | 2011-12-05 20:17:17 +0200 | [diff] [blame] | 40 | /* Questionable single byte read from CMOS. |
| 41 | * Do not add any other CMOS access in the |
| 42 | * bootblock for AP CPUs. |
| 43 | */ |
Timothy Pearson | 82cb787 | 2015-11-03 16:04:56 -0600 | [diff] [blame] | 44 | boot_mode = boot_use_normal(cmos_read(RTC_BOOT_BYTE)); |
Kyösti Mälkki | f28dbe0 | 2011-12-05 20:17:17 +0200 | [diff] [blame] | 45 | } |
| 46 | |
Martin Roth | 1b304cc | 2015-11-30 09:49:21 -0700 | [diff] [blame] | 47 | char *normal_candidate = (char *)walkcbfs("coreboot-stages"); |
Patrick Georgi | 06c0429 | 2012-01-07 19:15:43 +0100 | [diff] [blame] | 48 | |
Martin Roth | 1b304cc | 2015-11-30 09:49:21 -0700 | [diff] [blame] | 49 | if (!normal_candidate) |
| 50 | normal_candidate = default_filenames; |
| 51 | |
| 52 | unsigned long entry; |
| 53 | |
| 54 | if (boot_mode) { |
Patrick Georgi | 06c0429 | 2012-01-07 19:15:43 +0100 | [diff] [blame] | 55 | entry = findstage(normal_candidate); |
Martin Roth | 1b304cc | 2015-11-30 09:49:21 -0700 | [diff] [blame] | 56 | if (entry) |
| 57 | call(entry, bist); |
| 58 | } |
Patrick Georgi | c9fa96d | 2010-02-24 13:58:23 +0000 | [diff] [blame] | 59 | |
Patrick Georgi | 06c0429 | 2012-01-07 19:15:43 +0100 | [diff] [blame] | 60 | entry = findstage(get_fallback(normal_candidate)); |
Martin Roth | 1b304cc | 2015-11-30 09:49:21 -0700 | [diff] [blame] | 61 | if (entry) |
| 62 | call(entry, bist); |
Patrick Georgi | c9fa96d | 2010-02-24 13:58:23 +0000 | [diff] [blame] | 63 | |
| 64 | /* duh. we're stuck */ |
Patrick Georgi | 546953c | 2014-11-29 10:38:17 +0100 | [diff] [blame] | 65 | halt(); |
Patrick Georgi | c9fa96d | 2010-02-24 13:58:23 +0000 | [diff] [blame] | 66 | } |