Jonathan Zhang has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/41732 )
Change subject: drivers/vpd: add VPD region VPD_RW_OR_RO ......................................................................
drivers/vpd: add VPD region VPD_RW_OR_RO
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_RW_OR_RO, so that VPD_RW region is searched first to get overwrite setting, otherwise VPD_RO region is searched to get default setting.
Signed-off-by: Jonathan Zhang jonzhang@fb.com Change-Id: Icd7cbd9c3fb2a6b02fc417ad45d7d22ca6795457 --- M src/drivers/vpd/vpd.c M src/drivers/vpd/vpd.h 2 files changed, 30 insertions(+), 9 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/32/41732/1
diff --git a/src/drivers/vpd/vpd.c b/src/drivers/vpd/vpd.c index f1dcf8c..9264140 100644 --- a/src/drivers/vpd/vpd.c +++ b/src/drivers/vpd/vpd.c @@ -193,17 +193,33 @@ } }
- assert(region == VPD_RO_OR_RW); /* - * As the region is set to VPD_RO_OR_RW, use the search result from VPD_RO + * If the region is set to VPD_RO_OR_RW, use the search result from VPD_RO * as the preference, otherwise use the search result from VPD_RW. */ - if (arg_ro.matched) { - *size = arg_ro.value_len; - return arg_ro.value; - } else if (arg_rw.matched) { + if (region == VPD_RO_OR_RW) { + if (arg_ro.matched) { + *size = arg_ro.value_len; + return arg_ro.value; + } else if (arg_rw.matched) { + *size = arg_rw.value_len; + return arg_rw.value; + } else { + return NULL; + } + } + + /* + * As the region is set to VPD_RW_OR_RO, use the search result from VPD_RW + * as the preference, otherwise use the search result from VPD_RO. + */ + assert(region == VPD_RW_OR_RO); + if (arg_rw.matched) { *size = arg_rw.value_len; return arg_rw.value; + } else if (arg_ro.matched) { + *size = arg_ro.value_len; + return arg_ro.value; } else { return NULL; } diff --git a/src/drivers/vpd/vpd.h b/src/drivers/vpd/vpd.h index 5fa3b4e..549b7a4 100644 --- a/src/drivers/vpd/vpd.h +++ b/src/drivers/vpd/vpd.h @@ -13,11 +13,16 @@
/* * VPD_RO_OR_RW indicates VPD_RO search result is preferred over VPD_RW search result. + * + * VPD_RW_OR_RO indicates VPD_RW search result is preferred over VPD_RO search result. + * This 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. */ enum vpd_region { - VPD_RO_OR_RW = 0, - VPD_RO = 1, - VPD_RW = 2 + VPD_RO = 0, + VPD_RW = 1, + VPD_RO_OR_RW = 2, + VPD_RW_OR_RO = 3 };
/* VPD 2.0 data blob structure */