From db3e23d505bf9f62757f7ade5c2e2f90e2d04acc Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Sun, 14 Dec 2025 18:10:03 -0600 Subject: [PATCH] lib/fw_config: Add mainboard hook for selective probe override Add fw_config_probe_mainboard_override() hook that allows mainboards to selectively override specific fw_config probes. The hook returns whether the function handed the probe or not. If set to true, the hook's 'result' parameter is returned; otherwise, standard fw_config logic is used automatically. This enables mainboards to override probes based on runtime conditions (e.g., CFR options) without reimplementing standard fw_config logic. The change is backward compatible as the default hook doesn't handle any probes. TEST=tested with subsequent patch Change-Id: I6b9207eb9097ef5296fb5c41d8d1acbfde68b445 Signed-off-by: Matt DeVillier Reviewed-on: https://review.coreboot.org/c/coreboot/+/90741 Tested-by: build bot (Jenkins) Reviewed-by: Angel Pons --- src/include/fw_config.h | 14 ++++++++++++++ src/lib/fw_config.c | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/include/fw_config.h b/src/include/fw_config.h index 1e1652efb6..266490bc7e 100644 --- a/src/include/fw_config.h +++ b/src/include/fw_config.h @@ -71,6 +71,20 @@ static inline bool fw_config_is_provisioned(void) */ uint64_t fw_config_get_field(const struct fw_config_field *field); +/** + * fw_config_probe_mainboard_override() - Mainboard hook to override specific probes + * @match: Structure containing field and option to probe + * @result: Output parameter - set to the probe result if this probe was handled + * + * Return: %true if this probe was handled, %false otherwise + * + * Mainboards can override this function to handle specific fw_config probes + * (e.g., based on CFR/CMOS options). If a probe is handled, return %true and + * set *result to the desired probe result. If not handled, return %false and + * the standard fw_config logic will be used. + */ +bool fw_config_probe_mainboard_override(const struct fw_config *match, bool *result); + /** * fw_config_probe() - Check if field and option matches. * @match: Structure containing field and option to probe. diff --git a/src/lib/fw_config.c b/src/lib/fw_config.c index 74f3f8bc41..b2c1cd491d 100644 --- a/src/lib/fw_config.c +++ b/src/lib/fw_config.c @@ -72,8 +72,19 @@ uint64_t fw_config_get_field(const struct fw_config_field *field) return value; } +bool __weak fw_config_probe_mainboard_override(const struct fw_config *match, bool *result) +{ + return false; +} + bool fw_config_probe(const struct fw_config *match) { + bool result; + + /* Give mainboard a chance to override this probe */ + if (fw_config_probe_mainboard_override(match, &result)) + return result; + /* If fw_config is not provisioned, then there is nothing to match. */ if (!fw_config_is_provisioned()) return false;