From 6095cd1501143025c51a6505fd37c4e2614f0347 Mon Sep 17 00:00:00 2001 From: Zheng Bao Date: Tue, 21 Feb 2023 10:52:47 +0800 Subject: [PATCH] amdfwtool: Clean up the logic sequence of pointer growing When the EFS data is being packed, the pointer should be at EFS header. After that, it should be at body location. TEST=binary identical test on amd/birman amd/chausie amd/majolica amd/gardenia pcengines/apu2 amd/mandolin Change-Id: Ia81e2bdf9feb02971723f39e7f223b5055807cd8 Signed-off-by: Zheng Bao Reviewed-on: https://review.coreboot.org/c/coreboot/+/73180 Tested-by: build bot (Jenkins) Reviewed-by: Fred Reitberger --- util/amdfwtool/amdfwtool.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c index cd2922359d..b946a1bf54 100644 --- a/util/amdfwtool/amdfwtool.c +++ b/util/amdfwtool/amdfwtool.c @@ -2496,18 +2496,8 @@ int main(int argc, char **argv) } memset(ctx.rom, 0xFF, ctx.rom_size); - if (efs_location) { - if (efs_location != body_location) { - romsig_offset = efs_location; - set_current_pointer(&ctx, body_location); - } else { - romsig_offset = efs_location; - set_current_pointer(&ctx, romsig_offset + sizeof(embedded_firmware)); - } - } else { - romsig_offset = AMD_ROMSIG_OFFSET; - set_current_pointer(&ctx, romsig_offset + sizeof(embedded_firmware)); - } + romsig_offset = efs_location ? efs_location : AMD_ROMSIG_OFFSET; + set_current_pointer(&ctx, romsig_offset); amd_romsig = BUFF_OFFSET(ctx, romsig_offset); amd_romsig->signature = EMBEDDED_FW_SIGNATURE; @@ -2539,6 +2529,11 @@ int main(int argc, char **argv) else printf("\n"); + if (efs_location != body_location) + set_current_pointer(&ctx, body_location); + else + set_current_pointer(&ctx, romsig_offset + sizeof(embedded_firmware)); + integrate_firmwares(&ctx, amd_romsig, amd_fw_table); adjust_current_pointer(&ctx, 0, 0x10000U); /* TODO: is it necessary? */