intel/mtl: Add get_cse_ver_from_cbfs function
This patch implements helper function get_cse_ver_from_cbfs() to retrieve the CSE Lite version from CBFE RW's metadata and calls the helper function from cse_check_update_status() TEST=Verified CSE Lite version in coreboot boot log Signed-off-by: Ashish Kumar Mishra <ashish.k.mishra@intel.com> Change-Id: Ie1bf186adfc3f87826a7ce9b0167a6bbe6767299 Reviewed-on: https://review.coreboot.org/c/coreboot/+/74755 Reviewed-by: Sridhar Siricilla <sridhar.siricilla@intel.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Himanshu Sahdev <himanshu.sahdev@intel.com>
This commit is contained in:
parent
627f4c5deb
commit
2ee716227e
|
@ -630,31 +630,45 @@ static bool read_ver_field(const char *start, char **curr, size_t size, uint16_t
|
|||
return true;
|
||||
}
|
||||
|
||||
static enum cb_err get_cse_ver_from_cbfs(struct fw_version *cbfs_rw_version)
|
||||
{
|
||||
char *version_str, *cbfs_ptr;
|
||||
size_t size;
|
||||
|
||||
if (cbfs_rw_version == NULL)
|
||||
return CB_ERR;
|
||||
|
||||
cbfs_ptr = cbfs_map(CONFIG_SOC_INTEL_CSE_RW_VERSION_CBFS_NAME, &size);
|
||||
version_str = cbfs_ptr;
|
||||
if (!version_str) {
|
||||
printk(BIOS_ERR, "cse_lite: Failed to get %s\n",
|
||||
CONFIG_SOC_INTEL_CSE_RW_VERSION_CBFS_NAME);
|
||||
return CB_ERR;
|
||||
}
|
||||
|
||||
if (!read_ver_field(version_str, &cbfs_ptr, size, &cbfs_rw_version->major) ||
|
||||
!read_ver_field(version_str, &cbfs_ptr, size, &cbfs_rw_version->minor) ||
|
||||
!read_ver_field(version_str, &cbfs_ptr, size, &cbfs_rw_version->hotfix) ||
|
||||
!read_ver_field(version_str, &cbfs_ptr, size, &cbfs_rw_version->build)) {
|
||||
cbfs_unmap(version_str);
|
||||
return CB_ERR;
|
||||
}
|
||||
|
||||
cbfs_unmap(version_str);
|
||||
return CB_SUCCESS;
|
||||
}
|
||||
|
||||
static enum cse_update_status cse_check_update_status(const struct cse_bp_info *cse_bp_info,
|
||||
struct region_device *target_rdev)
|
||||
struct region_device *target_rdev)
|
||||
{
|
||||
int ret;
|
||||
struct fw_version cbfs_rw_version;
|
||||
char *version_str, *ptr;
|
||||
size_t size;
|
||||
|
||||
if (!cse_is_rw_bp_sign_valid(target_rdev))
|
||||
return CSE_UPDATE_CORRUPTED;
|
||||
|
||||
ptr = version_str = cbfs_map(CONFIG_SOC_INTEL_CSE_RW_VERSION_CBFS_NAME, &size);
|
||||
if (!version_str) {
|
||||
printk(BIOS_ERR, "cse_lite: Failed to get %s\n",
|
||||
CONFIG_SOC_INTEL_CSE_RW_VERSION_CBFS_NAME);
|
||||
if (get_cse_ver_from_cbfs(&cbfs_rw_version) == CB_ERR)
|
||||
return CSE_UPDATE_METADATA_ERROR;
|
||||
}
|
||||
|
||||
if (!read_ver_field(version_str, &ptr, size, &cbfs_rw_version.major) ||
|
||||
!read_ver_field(version_str, &ptr, size, &cbfs_rw_version.minor) ||
|
||||
!read_ver_field(version_str, &ptr, size, &cbfs_rw_version.hotfix) ||
|
||||
!read_ver_field(version_str, &ptr, size, &cbfs_rw_version.build)) {
|
||||
cbfs_unmap(version_str);
|
||||
return CSE_UPDATE_METADATA_ERROR;
|
||||
}
|
||||
|
||||
printk(BIOS_DEBUG, "cse_lite: CSE CBFS RW version : %d.%d.%d.%d\n",
|
||||
cbfs_rw_version.major,
|
||||
|
@ -662,8 +676,6 @@ static enum cse_update_status cse_check_update_status(const struct cse_bp_info *
|
|||
cbfs_rw_version.hotfix,
|
||||
cbfs_rw_version.build);
|
||||
|
||||
cbfs_unmap(version_str);
|
||||
|
||||
ret = cse_compare_sub_part_version(&cbfs_rw_version, cse_get_rw_version(cse_bp_info));
|
||||
if (ret == 0)
|
||||
return CSE_UPDATE_NOT_REQUIRED;
|
||||
|
|
Loading…
Reference in New Issue