From 20795899999bab47ba875b0d2a2c7e0a6ff4effa Mon Sep 17 00:00:00 2001 From: Zheng Bao Date: Fri, 20 Aug 2021 14:58:22 +0800 Subject: [PATCH] amdfwtool: Detect the flag multilevel to decide the actual value To save the space for FW, some of the FWs are going to be defined as LVL2 entries. To be compatible to "flattened" layout, we still drop the LVL2 entry to level1 if there is only one level. Change-Id: Ibe8cdd5c14225899352b02bb19aae6059d56d428 Signed-off-by: Zheng Bao Reviewed-on: https://review.coreboot.org/c/coreboot/+/57063 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth --- util/amdfwtool/amdfwtool.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c index 57c67f0760..d051582498 100644 --- a/util/amdfwtool/amdfwtool.c +++ b/util/amdfwtool/amdfwtool.c @@ -585,7 +585,8 @@ static void integrate_psp_firmwares(context *ctx, psp_directory_table *pspdir, psp_directory_table *pspdir2, amd_fw_entry *fw_table, - uint32_t cookie) + uint32_t cookie, + amd_cb_config *cb_config) { ssize_t bytes; unsigned int i, count; @@ -598,7 +599,9 @@ static void integrate_psp_firmwares(context *ctx, * 1st-level cookie may indicate level 1 or flattened. If the caller * passes a pointer to a 2nd-level table, then assume not flat. */ - if (cookie == PSPL2_COOKIE) + if (cb_config->multi_level == 0) + level = PSP_BOTH; + else if (cookie == PSPL2_COOKIE) level = PSP_LVL2; else if (pspdir2) level = PSP_LVL1; @@ -763,7 +766,8 @@ static void integrate_bios_firmwares(context *ctx, bios_directory_table *biosdir, bios_directory_table *biosdir2, amd_bios_entry *fw_table, - uint32_t cookie) + uint32_t cookie, + amd_cb_config *cb_config) { ssize_t bytes; unsigned int i, count; @@ -779,7 +783,9 @@ static void integrate_bios_firmwares(context *ctx, * 1st-level cookie may indicate level 1 or flattened. If the caller * passes a pointer to a 2nd-level table, then assume not flat. */ - if (cookie == BDT2_COOKIE) + if (cb_config->multi_level == 0) + level = BDT_BOTH; + else if (cookie == BDT2_COOKIE) level = BDT_LVL2; else if (biosdir2) level = BDT_LVL1; @@ -1568,16 +1574,16 @@ int main(int argc, char **argv) /* Do 2nd PSP directory followed by 1st */ psp_directory_table *pspdir2 = new_psp_dir(&ctx, cb_config.multi_level); integrate_psp_firmwares(&ctx, pspdir2, 0, - amd_psp_fw_table, PSPL2_COOKIE); + amd_psp_fw_table, PSPL2_COOKIE, &cb_config); pspdir = new_psp_dir(&ctx, cb_config.multi_level); integrate_psp_firmwares(&ctx, pspdir, pspdir2, - amd_psp_fw_table, PSP_COOKIE); + amd_psp_fw_table, PSP_COOKIE, &cb_config); } else { /* flat: PSP 1 cookie and no pointer to 2nd table */ pspdir = new_psp_dir(&ctx, cb_config.multi_level); integrate_psp_firmwares(&ctx, pspdir, 0, - amd_psp_fw_table, PSP_COOKIE); + amd_psp_fw_table, PSP_COOKIE, &cb_config); } if (comboable) @@ -1605,16 +1611,16 @@ int main(int argc, char **argv) bios_directory_table *biosdir2 = new_bios_dir(&ctx, cb_config.multi_level); integrate_bios_firmwares(&ctx, biosdir2, 0, - amd_bios_table, BDT2_COOKIE); + amd_bios_table, BDT2_COOKIE, &cb_config); biosdir = new_bios_dir(&ctx, cb_config.multi_level); integrate_bios_firmwares(&ctx, biosdir, biosdir2, - amd_bios_table, BDT1_COOKIE); + amd_bios_table, BDT1_COOKIE, &cb_config); } else { /* flat: BDT1 cookie and no pointer to 2nd table */ biosdir = new_bios_dir(&ctx, cb_config.multi_level); integrate_bios_firmwares(&ctx, biosdir, 0, - amd_bios_table, BDT1_COOKIE); + amd_bios_table, BDT1_COOKIE, &cb_config); } switch (soc_id) { case PLATFORM_RENOIR: