Tim Wawrzynczak submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Furquan Shaikh: Looks good to me, approved Nick Vaccaro: Looks good to me, approved
fw_config: Use UNDEFINED_FW_CONFIG to mean unprovisioned

A mainboard might want to configure some things differently when a
device is in an unprovisioned state. In the case when fw_config comes
from the Chromium EC, an unprovisioned device will not have a FW_CONFIG
tag in its CBI. This patch will set the fw_config value to
UNDEFINED_FW_CONFIG in the case of an error retrieving the value, as
well as adding a function, `fw_config_is_provisioned()` to indicate the
provisioning status.

BUG=none
TEST=remove fw_config from chromium EC CBI, add code to mainboard to
print return value of fw_config_is_provisioned() (`0`), add
fw_config back to CBI, run same test and see `1`.

Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Change-Id: Ib3046233667e97a5f78961fabacbeb3099b3d442
Reviewed-on: https://review.coreboot.org/c/coreboot/+/47956
Reviewed-by: Furquan Shaikh <furquan@google.com>
Reviewed-by: Nick Vaccaro <nvaccaro@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
---
M src/include/fw_config.h
M src/lib/fw_config.c
2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/include/fw_config.h b/src/include/fw_config.h
index 3c87725..b702871 100644
--- a/src/include/fw_config.h
+++ b/src/include/fw_config.h
@@ -57,6 +57,12 @@
void fw_config_for_each_found(void (*cb)(const struct fw_config *config, void *arg), void *arg);

/**
+ * fw_config_is_provisioned() - Determine if FW_CONFIG has been provisioned.
+ * Return %true if FW_CONFIG has been provisioned, %false otherwise.
+ */
+bool fw_config_is_provisioned(void);
+
+/**
* fw_config_get_found() - Return a pointer to the fw_config struct for a given field.
* @field_mask: A field mask from static.h, e.g., FW_CONFIG_FIELD_FEATURE_MASK
*
diff --git a/src/lib/fw_config.c b/src/lib/fw_config.c
index 2f7186c..2c4c6b2 100644
--- a/src/lib/fw_config.c
+++ b/src/lib/fw_config.c
@@ -28,7 +28,7 @@
sizeof(fw_config_value)) != sizeof(fw_config_value)) {
printk(BIOS_WARNING, "%s: Could not get fw_config from CBFS\n",
__func__);
- fw_config_value = 0;
+ fw_config_value = UNDEFINED_FW_CONFIG;
} else {
printk(BIOS_INFO, "FW_CONFIG value from CBFS is 0x%" PRIx64 "\n",
fw_config_value);
@@ -38,8 +38,10 @@

/* Read the value from EC CBI. */
if (CONFIG(FW_CONFIG_SOURCE_CHROMEEC_CBI)) {
- if (google_chromeec_cbi_get_fw_config(&fw_config_value))
+ if (google_chromeec_cbi_get_fw_config(&fw_config_value)) {
printk(BIOS_WARNING, "%s: Could not get fw_config from EC\n", __func__);
+ fw_config_value = UNDEFINED_FW_CONFIG;
+ }
}

printk(BIOS_INFO, "FW_CONFIG value is 0x%" PRIx64 "\n", fw_config_value);
@@ -63,6 +65,11 @@
return false;
}

+bool fw_config_is_provisioned(void)
+{
+ return fw_config_get() != UNDEFINED_FW_CONFIG;
+}
+
#if ENV_RAMSTAGE

/*

To view, visit change 47956. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ib3046233667e97a5f78961fabacbeb3099b3d442
Gerrit-Change-Number: 47956
Gerrit-PatchSet: 9
Gerrit-Owner: Tim Wawrzynczak <twawrzynczak@chromium.org>
Gerrit-Reviewer: Duncan Laurie <dlaurie@chromium.org>
Gerrit-Reviewer: Furquan Shaikh <furquan@google.com>
Gerrit-Reviewer: Julius Werner <jwerner@chromium.org>
Gerrit-Reviewer: Nick Vaccaro <nvaccaro@google.com>
Gerrit-Reviewer: Tim Wawrzynczak <twawrzynczak@chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-CC: Caveh Jalali <caveh@chromium.org>
Gerrit-CC: Paul Menzel <paulepanter@users.sourceforge.net>
Gerrit-MessageType: merged