Jonathan Zhang has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/41586 )
Change subject: drivers/vpd: add function to find default boolean key value ......................................................................
drivers/vpd: add function to find default boolean key value
This change is based on the concept that system user's overwrite settings are held in VPD_RW region, while system owner's (default) settings are held in VPD_RO region.
Add vpd_get_bool_ex() to find value of boolean type vpd key. VPD_RW is searched first; If not found in VPD_RW, then search VPD_RO.
Signed-off-by: Jonathan Zhang jonzhang@fb.com Change-Id: I960688d1f6ab199768107ab73b8a7400a3fdf473 --- M src/drivers/vpd/vpd.c M src/drivers/vpd/vpd.h 2 files changed, 29 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/86/41586/1
diff --git a/src/drivers/vpd/vpd.c b/src/drivers/vpd/vpd.c index 7ed1255..74ac700 100644 --- a/src/drivers/vpd/vpd.c +++ b/src/drivers/vpd/vpd.c @@ -227,3 +227,22 @@ } else return false; } + +/* + * This function finds value of boolean type vpd key with the + * concept of default value being held in VPD_RO, and overwrite + * value being held in VPD_RW. + * + * True is returned if key found in VPD_RW, otherwise VPD_RO + * is searched. The value is held in *val if true is returned. + */ +bool vpd_get_bool_ex(const char *key, uint8_t *val) +{ + if (vpd_get_bool(key, VPD_RW, val)) + return true; + + if (vpd_get_bool(key, VPD_RO, val)) + return true; + + return false; +} diff --git a/src/drivers/vpd/vpd.h b/src/drivers/vpd/vpd.h index 05b7db8..cfc339d 100644 --- a/src/drivers/vpd/vpd.h +++ b/src/drivers/vpd/vpd.h @@ -76,4 +76,14 @@ bool vpd_get_bool(const char *key, enum vpd_region region, uint8_t *val);
+/* + * This function finds value of boolean type vpd key with the + * concept of default value being held in VPD_RO, and overwrite + * value being held in VPD_RW. + * + * True is returned if key found in VPD_RW, otherwise VPD_RO + * is searched. The value is held in *val if true is returned. + */ +bool vpd_get_bool_ex(const char *key, uint8_t *val) + #endif /* __VPD_H__ */