2014-01-26 13:41:54 +01:00
|
|
|
#include <smp/node.h>
|
2010-02-24 14:58:23 +01:00
|
|
|
#include <bootblock_common.h>
|
2010-07-06 23:05:04 +02:00
|
|
|
#include <pc80/mc146818rtc.h>
|
2014-11-29 10:38:17 +01:00
|
|
|
#include <halt.h>
|
2010-02-24 14:58:23 +01:00
|
|
|
|
2012-01-07 19:15:43 +01:00
|
|
|
static const char *get_fallback(const char *stagelist) {
|
|
|
|
while (*stagelist) stagelist++;
|
|
|
|
return ++stagelist;
|
|
|
|
}
|
|
|
|
|
2010-02-24 14:58:23 +01:00
|
|
|
static void main(unsigned long bist)
|
|
|
|
{
|
2011-12-05 19:17:17 +01:00
|
|
|
unsigned long entry;
|
|
|
|
int boot_mode;
|
2012-01-07 19:15:43 +01:00
|
|
|
const char *default_filenames = "normal/romstage\0fallback/romstage";
|
2011-12-05 19:17:17 +01:00
|
|
|
|
2010-02-24 14:58:23 +01:00
|
|
|
if (boot_cpu()) {
|
2012-11-14 07:01:44 +01:00
|
|
|
bootblock_mainboard_init();
|
2010-02-24 14:58:23 +01:00
|
|
|
|
2011-03-08 08:50:43 +01:00
|
|
|
#if CONFIG_USE_OPTION_TABLE
|
2011-12-05 19:17:17 +01:00
|
|
|
sanitize_cmos();
|
2011-03-08 08:50:43 +01:00
|
|
|
#endif
|
2011-12-05 19:17:17 +01:00
|
|
|
boot_mode = do_normal_boot();
|
|
|
|
} else {
|
2011-03-08 08:50:43 +01:00
|
|
|
|
2011-12-05 19:17:17 +01:00
|
|
|
/* Questionable single byte read from CMOS.
|
|
|
|
* Do not add any other CMOS access in the
|
|
|
|
* bootblock for AP CPUs.
|
|
|
|
*/
|
2015-11-03 23:04:56 +01:00
|
|
|
boot_mode = boot_use_normal(cmos_read(RTC_BOOT_BYTE));
|
2011-12-05 19:17:17 +01:00
|
|
|
}
|
|
|
|
|
2012-01-07 19:15:43 +01:00
|
|
|
char *filenames = (char *)walkcbfs("coreboot-stages");
|
|
|
|
if (!filenames) {
|
|
|
|
filenames = default_filenames;
|
|
|
|
}
|
|
|
|
char *normal_candidate = filenames;
|
|
|
|
|
2011-12-05 19:17:17 +01:00
|
|
|
if (boot_mode)
|
2012-01-07 19:15:43 +01:00
|
|
|
entry = findstage(normal_candidate);
|
2010-02-24 14:58:23 +01:00
|
|
|
else
|
2012-01-07 19:15:43 +01:00
|
|
|
entry = findstage(get_fallback(normal_candidate));
|
2010-02-24 14:58:23 +01:00
|
|
|
|
|
|
|
if (entry) call(entry, bist);
|
|
|
|
|
|
|
|
/* run fallback if normal can't be found */
|
2012-01-07 19:15:43 +01:00
|
|
|
entry = findstage(get_fallback(normal_candidate));
|
2010-02-24 14:58:23 +01:00
|
|
|
if (entry) call(entry, bist);
|
|
|
|
|
|
|
|
/* duh. we're stuck */
|
2014-11-29 10:38:17 +01:00
|
|
|
halt();
|
2010-02-24 14:58:23 +01:00
|
|
|
}
|