Kyösti Mälkki has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/37760 )
Change subject: bootblock: Support normal/fallback mechanism again ......................................................................
bootblock: Support normal/fallback mechanism again
Change-Id: I7395e62f6682f4ef123da10ac125127a57711ec6 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- M src/arch/x86/Kconfig M src/lib/prog_loaders.c 2 files changed, 35 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/60/37760/1
diff --git a/src/arch/x86/Kconfig b/src/arch/x86/Kconfig index e27aec2..e3816a7 100644 --- a/src/arch/x86/Kconfig +++ b/src/arch/x86/Kconfig @@ -248,7 +248,6 @@ choice prompt "Bootblock behaviour" default BOOTBLOCK_SIMPLE - depends on ROMCC_BOOTBLOCK
config BOOTBLOCK_SIMPLE bool "Always load fallback" @@ -261,6 +260,7 @@
config BOOTBLOCK_SOURCE string + depends on ROMCC_BOOTBLOCK default "bootblock_simple.c" if BOOTBLOCK_SIMPLE default "bootblock_normal.c" if BOOTBLOCK_NORMAL
diff --git a/src/lib/prog_loaders.c b/src/lib/prog_loaders.c index 5787496..36fe1ce 100644 --- a/src/lib/prog_loaders.c +++ b/src/lib/prog_loaders.c @@ -53,6 +53,39 @@ return 0; }
+#include <pc80/mc146818rtc.h> +#include <string.h> + +static const char *get_fallback(const char *stagelist) +{ + while (*stagelist) + stagelist++; + return ++stagelist; +} + +static int legacy_romstage_selector(struct prog *romstage) +{ + static const char *default_filenames = "normal/romstage\0fallback/romstage"; + const char *boot_candidate; + size_t stages_len; + + if (!(CONFIG(BOOTBLOCK_NORMAL))) + return prog_locate(romstage); + + boot_candidate = cbfs_boot_map_with_leak("coreboot-stages", CBFS_TYPE_RAW, &stages_len); + if (!boot_candidate) + boot_candidate = default_filenames; + + if (do_normal_boot()) { + romstage->name = boot_candidate; + if (!prog_locate(romstage)) + return 0; + } + + romstage->name = get_fallback(boot_candidate); + return prog_locate(romstage); +} + void run_romstage(void) { struct prog romstage = @@ -60,7 +93,7 @@
vboot_run_logic();
- if (prog_locate(&romstage)) + if (legacy_romstage_selector(&romstage)) goto fail;
timestamp_add_now(TS_START_COPYROM);