blob: a6a877cdc6e7bdb829d05adaeccb7722ecd5522b [file] [log] [blame]
Kyösti Mälkki5a5c8862014-01-26 14:41:54 +02001#include <smp/node.h>
Julius Werner86fc11d2015-10-09 13:37:58 -07002#include <arch/bootblock_common.h>
Edwin Beasanteb50c7d2010-07-06 21:05:04 +00003#include <pc80/mc146818rtc.h>
Patrick Georgi546953c2014-11-29 10:38:17 +01004#include <halt.h>
Patrick Georgic9fa96d2010-02-24 13:58:23 +00005
Patrick Georgi06c04292012-01-07 19:15:43 +01006static const char *get_fallback(const char *stagelist) {
7 while (*stagelist) stagelist++;
8 return ++stagelist;
9}
10
Patrick Georgic9fa96d2010-02-24 13:58:23 +000011static void main(unsigned long bist)
12{
Martin Roth1b304cc2015-11-30 09:49:21 -070013 u8 boot_mode;
14 const char *default_filenames =
15 "normal/romstage\0fallback/romstage";
Kyösti Mälkkif28dbe02011-12-05 20:17:17 +020016
Patrick Georgic9fa96d2010-02-24 13:58:23 +000017 if (boot_cpu()) {
Kyösti Mälkkif9022482012-11-14 08:01:44 +020018 bootblock_mainboard_init();
Patrick Georgic9fa96d2010-02-24 13:58:23 +000019
Patrick Georgifab35e32011-03-08 07:50:43 +000020#if CONFIG_USE_OPTION_TABLE
Kyösti Mälkkif28dbe02011-12-05 20:17:17 +020021 sanitize_cmos();
Patrick Georgifab35e32011-03-08 07:50:43 +000022#endif
Kyösti Mälkkif28dbe02011-12-05 20:17:17 +020023 boot_mode = do_normal_boot();
24 } else {
Patrick Georgifab35e32011-03-08 07:50:43 +000025
Kyösti Mälkkif28dbe02011-12-05 20:17:17 +020026 /* Questionable single byte read from CMOS.
27 * Do not add any other CMOS access in the
28 * bootblock for AP CPUs.
29 */
Timothy Pearson82cb7872015-11-03 16:04:56 -060030 boot_mode = boot_use_normal(cmos_read(RTC_BOOT_BYTE));
Kyösti Mälkkif28dbe02011-12-05 20:17:17 +020031 }
32
Martin Roth1b304cc2015-11-30 09:49:21 -070033 char *normal_candidate = (char *)walkcbfs("coreboot-stages");
Patrick Georgi06c04292012-01-07 19:15:43 +010034
Martin Roth1b304cc2015-11-30 09:49:21 -070035 if (!normal_candidate)
36 normal_candidate = default_filenames;
37
38 unsigned long entry;
39
40 if (boot_mode) {
Patrick Georgi06c04292012-01-07 19:15:43 +010041 entry = findstage(normal_candidate);
Martin Roth1b304cc2015-11-30 09:49:21 -070042 if (entry)
43 call(entry, bist);
44 }
Patrick Georgic9fa96d2010-02-24 13:58:23 +000045
Patrick Georgi06c04292012-01-07 19:15:43 +010046 entry = findstage(get_fallback(normal_candidate));
Martin Roth1b304cc2015-11-30 09:49:21 -070047 if (entry)
48 call(entry, bist);
Patrick Georgic9fa96d2010-02-24 13:58:23 +000049
50 /* duh. we're stuck */
Patrick Georgi546953c2014-11-29 10:38:17 +010051 halt();
Patrick Georgic9fa96d2010-02-24 13:58:23 +000052}