2014-01-26 13:41:54 +01:00
|
|
|
#include <smp/node.h>
|
2015-10-09 22:37:58 +02:00
|
|
|
#include <arch/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)
|
|
|
|
{
|
2015-11-30 17:49:21 +01:00
|
|
|
u8 boot_mode;
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-11-30 17:49:21 +01:00
|
|
|
char *normal_candidate = (char *)walkcbfs("coreboot-stages");
|
2012-01-07 19:15:43 +01:00
|
|
|
|
2015-11-30 17:49:21 +01:00
|
|
|
if (!normal_candidate)
|
|
|
|
normal_candidate = default_filenames;
|
2010-02-24 14:58:23 +01:00
|
|
|
|
2015-11-30 17:49:21 +01:00
|
|
|
unsigned long entry;
|
|
|
|
|
|
|
|
if (boot_mode) {
|
|
|
|
entry = findstage(normal_candidate);
|
|
|
|
if (entry)
|
|
|
|
call(entry, bist);
|
|
|
|
}
|
2010-02-24 14:58:23 +01:00
|
|
|
|
2012-01-07 19:15:43 +01:00
|
|
|
entry = findstage(get_fallback(normal_candidate));
|
2015-11-30 17:49:21 +01:00
|
|
|
if (entry)
|
|
|
|
call(entry, bist);
|
2010-02-24 14:58:23 +01:00
|
|
|
|
|
|
|
/* duh. we're stuck */
|
2014-11-29 10:38:17 +01:00
|
|
|
halt();
|
2010-02-24 14:58:23 +01:00
|
|
|
}
|