blob: bde2535ba6b137a1e1af57b4007b4e519286feb4 [file] [log] [blame]
Kyösti Mälkki5a5c8862014-01-26 14:41:54 +02001#include <smp/node.h>
Patrick Georgic9fa96d2010-02-24 13:58:23 +00002#include <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{
Kyösti Mälkkif28dbe02011-12-05 20:17:17 +020013 unsigned long entry;
14 int boot_mode;
Patrick Georgi06c04292012-01-07 19:15:43 +010015 const char *default_filenames = "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 */
30 boot_mode = last_boot_normal();
31 }
32
Patrick Georgi06c04292012-01-07 19:15:43 +010033 char *filenames = (char *)walkcbfs("coreboot-stages");
34 if (!filenames) {
35 filenames = default_filenames;
36 }
37 char *normal_candidate = filenames;
38
Kyösti Mälkkif28dbe02011-12-05 20:17:17 +020039 if (boot_mode)
Patrick Georgi06c04292012-01-07 19:15:43 +010040 entry = findstage(normal_candidate);
Patrick Georgic9fa96d2010-02-24 13:58:23 +000041 else
Patrick Georgi06c04292012-01-07 19:15:43 +010042 entry = findstage(get_fallback(normal_candidate));
Patrick Georgic9fa96d2010-02-24 13:58:23 +000043
44 if (entry) call(entry, bist);
45
46 /* run fallback if normal can't be found */
Patrick Georgi06c04292012-01-07 19:15:43 +010047 entry = findstage(get_fallback(normal_candidate));
Patrick Georgic9fa96d2010-02-24 13:58:23 +000048 if (entry) call(entry, bist);
49
50 /* duh. we're stuck */
Patrick Georgi546953c2014-11-29 10:38:17 +010051 halt();
Patrick Georgic9fa96d2010-02-24 13:58:23 +000052}