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 <fishbaozi@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/73180
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Fred Reitberger <reitbergerfred@gmail.com>
This commit is contained in:
Zheng Bao 2023-02-21 10:52:47 +08:00 committed by Fred Reitberger
parent 0a466040e0
commit 6095cd1501
1 changed files with 7 additions and 12 deletions

View File

@ -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? */