Kyösti Mälkki | 5a5c886 | 2014-01-26 14:41:54 +0200 | [diff] [blame] | 1 | #include <smp/node.h> |
Patrick Georgi | c9fa96d | 2010-02-24 13:58:23 +0000 | [diff] [blame] | 2 | #include <bootblock_common.h> |
Edwin Beasant | eb50c7d | 2010-07-06 21:05:04 +0000 | [diff] [blame] | 3 | #include <pc80/mc146818rtc.h> |
Patrick Georgi | 546953c | 2014-11-29 10:38:17 +0100 | [diff] [blame] | 4 | #include <halt.h> |
Patrick Georgi | c9fa96d | 2010-02-24 13:58:23 +0000 | [diff] [blame] | 5 | |
Patrick Georgi | 06c0429 | 2012-01-07 19:15:43 +0100 | [diff] [blame] | 6 | static const char *get_fallback(const char *stagelist) { |
| 7 | while (*stagelist) stagelist++; |
| 8 | return ++stagelist; |
| 9 | } |
| 10 | |
Patrick Georgi | c9fa96d | 2010-02-24 13:58:23 +0000 | [diff] [blame] | 11 | static void main(unsigned long bist) |
| 12 | { |
Kyösti Mälkki | f28dbe0 | 2011-12-05 20:17:17 +0200 | [diff] [blame] | 13 | unsigned long entry; |
| 14 | int boot_mode; |
Patrick Georgi | 06c0429 | 2012-01-07 19:15:43 +0100 | [diff] [blame] | 15 | const char *default_filenames = "normal/romstage\0fallback/romstage"; |
Kyösti Mälkki | f28dbe0 | 2011-12-05 20:17:17 +0200 | [diff] [blame] | 16 | |
Patrick Georgi | c9fa96d | 2010-02-24 13:58:23 +0000 | [diff] [blame] | 17 | if (boot_cpu()) { |
Kyösti Mälkki | f902248 | 2012-11-14 08:01:44 +0200 | [diff] [blame] | 18 | bootblock_mainboard_init(); |
Patrick Georgi | c9fa96d | 2010-02-24 13:58:23 +0000 | [diff] [blame] | 19 | |
Patrick Georgi | fab35e3 | 2011-03-08 07:50:43 +0000 | [diff] [blame] | 20 | #if CONFIG_USE_OPTION_TABLE |
Kyösti Mälkki | f28dbe0 | 2011-12-05 20:17:17 +0200 | [diff] [blame] | 21 | sanitize_cmos(); |
Patrick Georgi | fab35e3 | 2011-03-08 07:50:43 +0000 | [diff] [blame] | 22 | #endif |
Kyösti Mälkki | f28dbe0 | 2011-12-05 20:17:17 +0200 | [diff] [blame] | 23 | boot_mode = do_normal_boot(); |
| 24 | } else { |
Patrick Georgi | fab35e3 | 2011-03-08 07:50:43 +0000 | [diff] [blame] | 25 | |
Kyösti Mälkki | f28dbe0 | 2011-12-05 20:17:17 +0200 | [diff] [blame] | 26 | /* Questionable single byte read from CMOS. |
| 27 | * Do not add any other CMOS access in the |
| 28 | * bootblock for AP CPUs. |
| 29 | */ |
| 30 | boot_mode = last_boot_normal(); |
| 31 | } |
| 32 | |
Patrick Georgi | 06c0429 | 2012-01-07 19:15:43 +0100 | [diff] [blame] | 33 | char *filenames = (char *)walkcbfs("coreboot-stages"); |
| 34 | if (!filenames) { |
| 35 | filenames = default_filenames; |
| 36 | } |
| 37 | char *normal_candidate = filenames; |
| 38 | |
Kyösti Mälkki | f28dbe0 | 2011-12-05 20:17:17 +0200 | [diff] [blame] | 39 | if (boot_mode) |
Patrick Georgi | 06c0429 | 2012-01-07 19:15:43 +0100 | [diff] [blame] | 40 | entry = findstage(normal_candidate); |
Patrick Georgi | c9fa96d | 2010-02-24 13:58:23 +0000 | [diff] [blame] | 41 | else |
Patrick Georgi | 06c0429 | 2012-01-07 19:15:43 +0100 | [diff] [blame] | 42 | entry = findstage(get_fallback(normal_candidate)); |
Patrick Georgi | c9fa96d | 2010-02-24 13:58:23 +0000 | [diff] [blame] | 43 | |
| 44 | if (entry) call(entry, bist); |
| 45 | |
| 46 | /* run fallback if normal can't be found */ |
Patrick Georgi | 06c0429 | 2012-01-07 19:15:43 +0100 | [diff] [blame] | 47 | entry = findstage(get_fallback(normal_candidate)); |
Patrick Georgi | c9fa96d | 2010-02-24 13:58:23 +0000 | [diff] [blame] | 48 | if (entry) call(entry, bist); |
| 49 | |
| 50 | /* duh. we're stuck */ |
Patrick Georgi | 546953c | 2014-11-29 10:38:17 +0100 | [diff] [blame] | 51 | halt(); |
Patrick Georgi | c9fa96d | 2010-02-24 13:58:23 +0000 | [diff] [blame] | 52 | } |