Tim Wawrzynczak has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/47956 )
Change subject: fw_config: Default to undefined fw_config value ......................................................................
fw_config: Default to undefined fw_config value
If for some reason a value for fw_config cannot be located, set its value to a magic undefined value. The current `fw_config_probe` function is modified to return true if fw_config is undefined, and a new function `fw_config_probe_nodefault` is added which will return false if the fw_config value is undefined. A new Kconfig option is added, FW_CONFIG_IGNORE_UNDEFINED (defaults to n), which controls the behavior of fw_config probing the devicetree.
Signed-off-by: Tim Wawrzynczak twawrzynczak@chromium.org Change-Id: Ib3046233667e97a5f78961fabacbeb3099b3d442 --- M src/Kconfig M src/include/fw_config.h M src/lib/fw_config.c 3 files changed, 43 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/56/47956/1
diff --git a/src/Kconfig b/src/Kconfig index dc98ca2..a0f692c 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -398,6 +398,16 @@ is not tried if FW_CONFIG_SOURCE_CBFS is enabled and the value was found in CBFS.
+config FW_CONFIG_IGNORE_UNDEFINED + bool "Undefined Firmware Configuration value will not probe devices" + depends on FW_CONFIG + default n + help + When probing devices with fw_config, when the value is undefined or + unable to be located, all devices will be successfully probed, and + fw_config_probe will always return true. Set this to 'y' if you do + not want this behavior. + config HAVE_RAMPAYLOAD bool
diff --git a/src/include/fw_config.h b/src/include/fw_config.h index 3c87725..e02a38e 100644 --- a/src/include/fw_config.h +++ b/src/include/fw_config.h @@ -45,11 +45,21 @@ * fw_config_probe() - Check if field and option matches. * @match: Structure containing field and option to probe. * - * Return %true if match is found, %false if match is not found. + * Return %true if match is found or fw_config value is undefined. + * %false if match is not found. */ bool fw_config_probe(const struct fw_config *match);
/** + * fw_config_probe_nodefault() - Check if field and option matches. + * @match: Structure containing field and option to probe. + * + * Return %true if match is found. + * %false if match is not found or fw_config value is undefined + */ +bool fw_config_probe_nodefault(const struct fw_config *match); + +/** * fw_config_for_each_found() - Call a callback for each fw_config field found * @cb: The callback function * @arg: A context argument that is passed to the callback diff --git a/src/lib/fw_config.c b/src/lib/fw_config.c index e17d40e..efbee01 100644 --- a/src/lib/fw_config.c +++ b/src/lib/fw_config.c @@ -29,7 +29,7 @@ CBFS_TYPE_RAW) != 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); @@ -39,16 +39,24 @@
/* 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); return fw_config_value; }
-bool fw_config_probe(const struct fw_config *match) +static bool fw_config_match(const struct fw_config *match, bool undefined_match) { + uint64_t fw_config; + + fw_config = fw_config_get(); + if (fw_config == UNDEFINED_FW_CONFIG) + return undefined_match; + /* Compare to system value. */ if ((fw_config_get() & match->mask) == match->value) { if (match->field_name && match->option_name) @@ -64,6 +72,16 @@ return false; }
+bool fw_config_probe(const struct fw_config *match) +{ + return fw_config_match(match, true); +} + +bool fw_config_probe_nodefault(const struct fw_config *match) +{ + return fw_config_match(match, false); +} + #if ENV_RAMSTAGE
/* @@ -111,7 +129,7 @@ continue;
for (probe = dev->probe_list; probe && probe->mask != 0; probe++) { - if (fw_config_probe(probe)) { + if (fw_config_match(probe, (bool)!CONFIG(FW_CONFIG_IGNORE_UNDEFINED))) { match = true; cached_configs[probe_index(probe->mask)] = probe; break;