Patrick Georgi (pgeorgi@google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10022
-gerrit
commit d38a72fba740f3aaed455088564d3a245efe00f5 Author: Aaron Durbin adurbin@chromium.org Date: Tue Apr 28 15:59:12 2015 -0500
program loading: add optional is_loader_active() callback
Add a way for a loader to indicate if it is active. Such users of this callback would be vboot which can indicate to the rest of the system that it isn't active. is_loader_active() also gives vboot a chance to perform the necessary work to make said decision.
Change-Id: I6679ac75b19bb1bfff9c2b709da5591986f752ff Signed-off-by: Aaron Durbin adurbin@chromium.org --- src/include/program_loading.h | 3 +++ src/lib/loaders/load_and_run_payload.c | 17 +++++++++++++++++ src/lib/loaders/load_and_run_ramstage.c | 19 ++++++++++++++++++- src/lib/loaders/load_and_run_romstage.c | 17 ++++++++++++++++- 4 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/src/include/program_loading.h b/src/include/program_loading.h index 02e6f5f..ca80b0e 100644 --- a/src/include/program_loading.h +++ b/src/include/program_loading.h @@ -103,6 +103,9 @@ void platform_prog_run(struct prog *prog);
struct prog_loader_ops { const char *name; + /* Determine if the loader is the active one. If so returns 1 else 0 + * or < 0 on error. */ + int (*is_loader_active)(struct prog *prog); /* Returns < 0 on error or 0 on success. This function needs to do * different things depending on the prog type. See definition * of struct prog above. */ diff --git a/src/lib/loaders/load_and_run_payload.c b/src/lib/loaders/load_and_run_payload.c index 0e08d88..7a08097 100644 --- a/src/lib/loaders/load_and_run_payload.c +++ b/src/lib/loaders/load_and_run_payload.c @@ -54,7 +54,24 @@ void payload_load(void) struct prog *payload = &global_payload;
for (i = 0; i < ARRAY_SIZE(payload_ops); i++) { + /* Default loader state is active. */ + int ret = 1; + ops = payload_ops[i]; + + if (ops->is_loader_active != NULL) + ret = ops->is_loader_active(payload); + + if (ret == 0) { + printk(BIOS_DEBUG, "%s payload loader inactive.\n", + ops->name); + continue; + } else if (ret < 0) { + printk(BIOS_DEBUG, "%s payload loader failure.\n", + ops->name); + continue; + } + if (ops->prepare(payload) < 0) { printk(BIOS_DEBUG, "%s: could not locate payload.\n", ops->name); diff --git a/src/lib/loaders/load_and_run_ramstage.c b/src/lib/loaders/load_and_run_ramstage.c index 153e38e..fddea4d 100644 --- a/src/lib/loaders/load_and_run_ramstage.c +++ b/src/lib/loaders/load_and_run_ramstage.c @@ -83,8 +83,25 @@ void run_ramstage(void) run_ramstage_from_resume(romstage_handoff_find_or_add(), &ramstage);
for (i = 0; i < ARRAY_SIZE(loaders); i++) { + /* Default loader state is active. */ + int ret = 1; + ops = loaders[i]; - printk(BIOS_DEBUG, "Trying %s ramstage loader.\n", ops->name); + + if (ops->is_loader_active != NULL) + ret = ops->is_loader_active(&ramstage); + + if (ret == 0) { + printk(BIOS_DEBUG, "%s ramstage loader inactive.\n", + ops->name); + continue; + } else if (ret < 0) { + printk(BIOS_DEBUG, "%s ramstage loader failure.\n", + ops->name); + continue; + } + + printk(BIOS_DEBUG, "%s ramstage loader active.\n", ops->name); load_ramstage(ops, &ramstage); }
diff --git a/src/lib/loaders/load_and_run_romstage.c b/src/lib/loaders/load_and_run_romstage.c index 1c2ed77..b54bfc7 100644 --- a/src/lib/loaders/load_and_run_romstage.c +++ b/src/lib/loaders/load_and_run_romstage.c @@ -41,11 +41,26 @@ void run_romstage(void) };
for (i = 0; i < ARRAY_SIZE(loaders); i++) { + /* Default loader state is active. */ + int ret = 1; const struct prog_loader_ops *ops;
ops = loaders[i];
- printk(BIOS_DEBUG, "Trying %s romstage loader.\n", ops->name); + if (ops->is_loader_active != NULL) + ret = ops->is_loader_active(&romstage); + + if (ret == 0) { + printk(BIOS_DEBUG, "%s romstage loader inactive.\n", + ops->name); + continue; + } else if (ret < 0) { + printk(BIOS_DEBUG, "%s romstage loader failure.\n", + ops->name); + continue; + } + + printk(BIOS_DEBUG, "%s romstage loader active.\n", ops->name);
timestamp_add_now(TS_START_COPYROM);