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 <matt.devillier@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/90741
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Matt DeVillier 2025-12-14 18:10:03 -06:00
commit db3e23d505
2 changed files with 25 additions and 0 deletions

View file

@ -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.

View file

@ -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;