Kyösti Mälkki | 5a5c886 | 2014-01-26 14:41:54 +0200 | [diff] [blame] | 1 | #include <smp/node.h> |
Julius Werner | 86fc11d | 2015-10-09 13:37:58 -0700 | [diff] [blame] | 2 | #include <arch/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 | { | ||||
Martin Roth | 1b304cc | 2015-11-30 09:49:21 -0700 | [diff] [blame] | 13 | u8 boot_mode; |
14 | const char *default_filenames = | ||||
15 | "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 | */ | ||||
Timothy Pearson | 82cb787 | 2015-11-03 16:04:56 -0600 | [diff] [blame] | 30 | boot_mode = boot_use_normal(cmos_read(RTC_BOOT_BYTE)); |
Kyösti Mälkki | f28dbe0 | 2011-12-05 20:17:17 +0200 | [diff] [blame] | 31 | } |
32 | |||||
Martin Roth | 1b304cc | 2015-11-30 09:49:21 -0700 | [diff] [blame] | 33 | char *normal_candidate = (char *)walkcbfs("coreboot-stages"); |
Patrick Georgi | 06c0429 | 2012-01-07 19:15:43 +0100 | [diff] [blame] | 34 | |
Martin Roth | 1b304cc | 2015-11-30 09:49:21 -0700 | [diff] [blame] | 35 | if (!normal_candidate) |
36 | normal_candidate = default_filenames; | ||||
37 | |||||
38 | unsigned long entry; | ||||
39 | |||||
40 | if (boot_mode) { | ||||
Patrick Georgi | 06c0429 | 2012-01-07 19:15:43 +0100 | [diff] [blame] | 41 | entry = findstage(normal_candidate); |
Martin Roth | 1b304cc | 2015-11-30 09:49:21 -0700 | [diff] [blame] | 42 | if (entry) |
43 | call(entry, bist); | ||||
44 | } | ||||
Patrick Georgi | c9fa96d | 2010-02-24 13:58:23 +0000 | [diff] [blame] | 45 | |
Patrick Georgi | 06c0429 | 2012-01-07 19:15:43 +0100 | [diff] [blame] | 46 | entry = findstage(get_fallback(normal_candidate)); |
Martin Roth | 1b304cc | 2015-11-30 09:49:21 -0700 | [diff] [blame] | 47 | if (entry) |
48 | call(entry, bist); | ||||
Patrick Georgi | c9fa96d | 2010-02-24 13:58:23 +0000 | [diff] [blame] | 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 | } |