summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorJoel Kitching <kitching@google.com>2019-04-12 11:45:32 +0800
committerchrome-bot <chrome-bot@chromium.org>2019-05-03 07:02:32 -0700
commite7edff6653e16ed915c3ad12234d133d1ef4dcc9 (patch)
treec8e8d39ed37ebe1ef339bb0e46b74124293f6238 /firmware
parent6a72e23120a99fab124395d83ba2d511a1a6664e (diff)
downloadvboot-e7edff6653e16ed915c3ad12234d133d1ef4dcc9.tar.gz
vboot: implement DISPLAY_INIT context and SD flag
As part of go/vboot2-cleanup-oprom, introduce new context flag DISPLAY_INIT. The equivalent shared data flag DISPLAY_AVAILABLE is also introduced for downstream vboot to read. The context flag serves the dual purpose of: (1) the vboot caller (coreboot) telling vboot that "display will be initialized regardless", for cases when a mainboard/SoC cannot disable its display initialization code (see coreboot Kconfig VBOOT_MUST_REQUEST_DISPLAY, previously VBOOT_OPROM_MATTERS). (2) vboot telling the vboot caller (coreboot) that "display initialization should occur" for cases when vboot needs display enabled on this boot. BUG=b:124141368, chromium:948529 TEST=make clean && make runtests BRANCH=none Change-Id: If18bedf99c0f6e366c12d043377edb7bcdb35fdf Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/1564232 Commit-Ready: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'firmware')
-rw-r--r--firmware/2lib/2api.c17
-rw-r--r--firmware/2lib/include/2api.h13
-rw-r--r--firmware/2lib/include/2struct.h3
3 files changed, 33 insertions, 0 deletions
diff --git a/firmware/2lib/2api.c b/firmware/2lib/2api.c
index 707f2027..1556c997 100644
--- a/firmware/2lib/2api.c
+++ b/firmware/2lib/2api.c
@@ -37,9 +37,11 @@ void vb2api_fail(struct vb2_context *ctx, uint8_t reason, uint8_t subcode)
int vb2api_fw_phase1(struct vb2_context *ctx)
{
int rv;
+ struct vb2_shared_data *sd;
/* Initialize the vboot context if it hasn't been yet */
vb2_init_context(ctx);
+ sd = vb2_get_sd(ctx);
/* Initialize NV context */
vb2_nv_init(ctx);
@@ -97,6 +99,21 @@ int vb2api_fw_phase1(struct vb2_context *ctx)
return rv;
}
+ /*
+ * Check for possible reasons to ask the firmware to make display
+ * available. sd->recovery_reason may have been set above by
+ * vb2_check_recovery. VB2_SD_FLAG_DEV_MODE_ENABLED may have been set
+ * above by vb2_check_dev_switch.
+ */
+ if (!(ctx->flags & VB2_CONTEXT_DISPLAY_INIT) &&
+ (vb2_nv_get(ctx, VB2_NV_OPROM_NEEDED) ||
+ sd->flags & VB2_SD_FLAG_DEV_MODE_ENABLED ||
+ sd->recovery_reason))
+ ctx->flags |= VB2_CONTEXT_DISPLAY_INIT;
+ /* Mark display as available for downstream vboot and vboot callers. */
+ if (ctx->flags & VB2_CONTEXT_DISPLAY_INIT)
+ sd->flags |= VB2_SD_FLAG_DISPLAY_AVAILABLE;
+
/* Return error if recovery is needed */
if (ctx->flags & VB2_CONTEXT_RECOVERY_MODE) {
/* Always clear RAM when entering recovery mode */
diff --git a/firmware/2lib/include/2api.h b/firmware/2lib/include/2api.h
index 5edbc506..68fb12bd 100644
--- a/firmware/2lib/include/2api.h
+++ b/firmware/2lib/include/2api.h
@@ -161,6 +161,19 @@ enum vb2_context_flags {
/* Allow vendor data to be set via the vendor data ui. */
VB2_CONTEXT_VENDOR_DATA_SETTABLE = (1 << 19),
+
+ /*
+ * Caller may set this before running vb2api_fw_phase1. In this case,
+ * it means: "Display is available on this boot. Please advertise
+ * as such to downstream vboot code and users."
+ *
+ * vboot may also set this before returning from vb2api_fw_phase1.
+ * In this case, it means: "Please initialize display so that it is
+ * available to downstream vboot code and users." This is used when
+ * vboot encounters some internally-generated request for display
+ * support.
+ */
+ VB2_CONTEXT_DISPLAY_INIT = (1 << 20),
};
/*
diff --git a/firmware/2lib/include/2struct.h b/firmware/2lib/include/2struct.h
index a67518c8..adff0d7b 100644
--- a/firmware/2lib/include/2struct.h
+++ b/firmware/2lib/include/2struct.h
@@ -49,6 +49,9 @@ enum vb2_shared_data_flags {
/* Software sync says EC / PD running RW */
VB2_SD_FLAG_ECSYNC_EC_IN_RW = (1 << 6),
VB2_SD_FLAG_ECSYNC_PD_IN_RW = (1 << 7),
+
+ /* Display is available on this boot */
+ VB2_SD_FLAG_DISPLAY_AVAILABLE = (1 << 8),
};
/* Flags for vb2_shared_data.status */