From b5392f930d601c12db52d1f6428e1866fcfdcf86 Mon Sep 17 00:00:00 2001 From: Jonathan Zhang Date: Tue, 16 Jul 2019 14:37:23 -0700 Subject: drivers/vpd: add framework to search VPD in romstage Summary: Added a framework to search VPD in romstage before memory is avilable. vpd_cbmem.c and vpd_premem.c are added for code specific for premem environment and for environment that cbmem can be used. Since global variable is forbidden in romstage. A CAR_GLOBAL variable is defined in vpd.c. This variable holds VPD binary blobs' base address and size from memory mapped flash. The overall flow is: * The CAR variable g_vpd_blob is initialized if it was not, either at romstage (before FSP-M execution in case of FSP UPD customization), or at ramstage. * At ramstage, during CBMEM_INIT, the VPD binary blob contents are copied into CBMEM. * At vpd_find() which may be called at romstage or at ramstage, it sets storage for a local struct vpd_blob variable. * The variable gets contents duplicated from g_vpd_blob, if vpd_find() is called at romstage. * The variable gets contents obtained from CBMEM, if vpd_find() is called at ramstage. Added a call vpd_get_bool(). Given a key/value pair in VPD binary blob, and name of a bool type variable, set the variable value if there is a match. Several checks are in place: * The key/value length needs to be correct. * The key name needs to match. * THe value is either '1' or '0'. Test Plan: * Build an OCP MonoLake coreboot image, flash and run. Tags: Signed-off-by: Jonathan Zhang Change-Id: Iebdba59419a555147fc40391cf17cc6879d9e1b2 Reviewed-on: https://review.coreboot.org/c/coreboot/+/34634 Tested-by: build bot (Jenkins) Reviewed-by: Hung-Te Lin --- src/drivers/vpd/vpd.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/drivers/vpd/vpd.h') diff --git a/src/drivers/vpd/vpd.h b/src/drivers/vpd/vpd.h index 6009b8bc0d..14b002c8f6 100644 --- a/src/drivers/vpd/vpd.h +++ b/src/drivers/vpd/vpd.h @@ -7,11 +7,37 @@ #ifndef __VPD_H__ #define __VPD_H__ +#define GOOGLE_VPD_2_0_OFFSET 0x600 + enum vpd_region { VPD_ANY = 0, VPD_RO = 1, VPD_RW = 2 }; + +/* VPD 2.0 data blob structure */ +struct vpd_blob { + bool initialized; + uint8_t *ro_base; + uint32_t ro_size; + uint8_t *rw_base; + uint32_t rw_size; +}; +extern struct vpd_blob g_vpd_blob; + +/* + * This function loads g_vpd_blob CAR_GLOBAL variable. + * The variable is initialized if it was not. + */ +const struct vpd_blob *vpd_load_blob(void); + +/* + * This function gets the base address and size of + * buffers for RO_VPD/RW_VPD binary blobs, and sets + * the struct. + */ +void vpd_get_buffers(struct vpd_blob *blob); + /* * Reads VPD string value by key. * @@ -39,4 +65,13 @@ char *vpd_gets(const char *key, char *buffer, int size, enum vpd_region region); const void *vpd_find(const char *key, int *size, enum vpd_region region); +/* + * Find value of boolean type vpd key. + * + * During the process, necessary checking is done, such as making + * sure the value length is 1, and value is either '1' or '0'. + */ +bool vpd_get_bool(const char *key, enum vpd_region region, + uint8_t *val); + #endif /* __VPD_H__ */ -- cgit v1.2.3