From e80d06284f4155228f5e9e368a2b65770b1c9c21 Mon Sep 17 00:00:00 2001 From: Zheng Bao Date: Sat, 16 Mar 2024 17:12:30 +0800 Subject: amdfwtool: Move linking BHD2 to PSP2 from main to link funcion Move the complexity from main to function, so the main flow is easy to understand. TEST=Identical test on all AMD SOC platform Change-Id: Ia549a0d08c2a60b8858440543ac8d8b5259017dd Signed-off-by: Zheng Bao Reviewed-on: https://review.coreboot.org/c/coreboot/+/81334 Tested-by: build bot (Jenkins) Reviewed-by: Felix Held --- util/amdfwtool/amdfwtool.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'util/amdfwtool/amdfwtool.c') diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c index 72f0c5ff34..00a366c9c3 100644 --- a/util/amdfwtool/amdfwtool.c +++ b/util/amdfwtool/amdfwtool.c @@ -1210,15 +1210,22 @@ static void add_bios_apcb_bk_entry(bios_directory_table *biosdir, unsigned int i biosdir->entries[idx].address_mode = SET_ADDR_MODE_BY_TABLE(biosdir); } -static void integrate_bios_levels(context *ctx) +static void integrate_bios_levels(context *ctx, amd_cb_config *cb_config) { - unsigned int count = ctx->biosdir->header.num_entries; + unsigned int count; uint32_t current_table_save; - current_table_save = ctx->current_table; - ctx->current_table = (char *)ctx->biosdir - ctx->rom; - - if (ctx->biosdir2) { + if (cb_config->recovery_ab) { + add_psp_firmware_entry(ctx, ctx->pspdir2, ctx->biosdir2, + AMD_FW_BIOS_TABLE, TABLE_ALIGNMENT); + if (ctx->pspdir2_b != NULL) + add_psp_firmware_entry(ctx, ctx->pspdir2_b, + ctx->biosdir2_b, AMD_FW_BIOS_TABLE, + TABLE_ALIGNMENT); + } else if (ctx->biosdir2) { + current_table_save = ctx->current_table; + ctx->current_table = (char *)ctx->biosdir - ctx->rom; + count = ctx->biosdir->header.num_entries; assert_fw_entry(count, MAX_BIOS_ENTRIES, ctx); ctx->biosdir->entries[count].type = AMD_BIOS_L2_PTR; ctx->biosdir->entries[count].region_type = 0; @@ -1237,9 +1244,9 @@ static void integrate_bios_levels(context *ctx) ctx->biosdir->entries[count].reset = 0; ctx->biosdir->entries[count].ro = 0; count++; + fill_dir_header(ctx->biosdir, count, ctx); + ctx->current_table = current_table_save; } - fill_dir_header(ctx->biosdir, count, ctx); - ctx->current_table = current_table_save; } static void integrate_bios_firmwares(context *ctx, amd_bios_entry *fw_table, @@ -1763,17 +1770,11 @@ int main(int argc, char **argv) amd_bios_table, BHDL2_COOKIE, &cb_config); } - add_psp_firmware_entry(&ctx, ctx.pspdir2, ctx.biosdir2, - AMD_FW_BIOS_TABLE, TABLE_ALIGNMENT); - if (ctx.pspdir2_b != NULL) - add_psp_firmware_entry(&ctx, ctx.pspdir2_b, - ctx.biosdir2_b, AMD_FW_BIOS_TABLE, - TABLE_ALIGNMENT); } else { integrate_bios_firmwares(&ctx, amd_bios_table, BHD_COOKIE, &cb_config); - integrate_bios_levels(&ctx); } + integrate_bios_levels(&ctx, &cb_config); } else { /* flat: BHD1 cookie and no pointer to 2nd table */ integrate_bios_firmwares(&ctx, -- cgit v1.2.3