amdfwtool: Add combo new layout for new family

The new layout definition has a new way to support combo.
It packs multiple ISH entries into PSP L1 directory.

TEST=Identical test on all AMD platform

Change-Id: If573cdeaeb56e95d2fed235c9337fab82d622757
Signed-off-by: Zheng Bao <fishbaozi@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/84233
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
This commit is contained in:
Zheng Bao 2024-08-29 15:54:59 +08:00 committed by Felix Held
commit 138dc601f7
3 changed files with 21 additions and 6 deletions

View file

@ -1582,6 +1582,11 @@ static bool is_initial_alignment_required(enum platform soc_id)
}
}
static bool needs_new_combo_layout(enum platform soc_id)
{
return needs_ish(soc_id);
}
int main(int argc, char **argv)
{
int retval = 0;
@ -1610,6 +1615,9 @@ int main(int argc, char **argv)
open_process_config(cb_config.config, &cb_config);
if (cb_config.use_combo && needs_new_combo_layout(cb_config.soc_id))
cb_config.combo_new_rab = true;
ctx.rom = malloc(ctx.rom_size);
if (!ctx.rom) {
fprintf(stderr, "Error: Failed to allocate memory\n");
@ -1664,7 +1672,7 @@ int main(int argc, char **argv)
cb_config.signed_start_addr,
cb_config.soc_id);
if (cb_config.use_combo) {
if (cb_config.use_combo && !cb_config.combo_new_rab) {
ctx.psp_combo_dir = new_combo_dir(&ctx, PSP2_COOKIE);
adjust_current_pointer(&ctx, 0, 0x1000U);
@ -1681,7 +1689,10 @@ int main(int argc, char **argv)
if (cb_config.use_combo && cb_config.debug)
printf("Processing %dth combo entry\n", combo_index);
ctx.pspdir = NULL;
/* The pspdir level 1 is special. For new combo layout, all the combo entries
share one pspdir L1. It should not be cleared at each iteration. */
if (!cb_config.combo_new_rab || combo_index == 0)
ctx.pspdir = NULL;
ctx.pspdir2 = NULL;
ctx.pspdir2_b = NULL;
ctx.biosdir = NULL;
@ -1735,7 +1746,8 @@ int main(int argc, char **argv)
*/
ctx.pspdir2_b = NULL; /* More explicitly */
}
integrate_psp_firmwares(&ctx,
if (!cb_config.combo_new_rab || combo_index == 0)
integrate_psp_firmwares(&ctx,
amd_psp_fw_table, PSP_COOKIE, &cb_config);
integrate_psp_levels(&ctx, &cb_config);
} else {
@ -1744,9 +1756,10 @@ int main(int argc, char **argv)
amd_psp_fw_table, PSP_COOKIE, &cb_config);
}
if (!cb_config.use_combo) {
if (!cb_config.use_combo || (cb_config.combo_new_rab && combo_index == 0)) {
/* For new combo layout, there is only 1 PSP level 1 directory. */
fill_psp_directory_to_efs(ctx.amd_romsig_ptr, ctx.pspdir, &ctx, &cb_config);
} else {
} else if (cb_config.use_combo && !cb_config.combo_new_rab) {
fill_psp_directory_to_efs(ctx.amd_romsig_ptr, ctx.psp_combo_dir, &ctx, &cb_config);
/* 0 -Compare PSP ID, 1 -Compare chip family ID */
assert_fw_entry(combo_index, MAX_COMBO_ENTRIES, &ctx);

View file

@ -426,6 +426,7 @@ typedef struct _amd_cb_config {
bool recovery_ab_single_copy;
bool need_ish;
bool use_combo;
bool combo_new_rab; /* new combo layout for recovery A/B */
bool have_apcb_bk;
enum platform soc_id;
@ -466,6 +467,7 @@ void process_signed_psp_firmwares(const char *signed_rom,
uint64_t signed_start_addr,
enum platform soc_id);
int find_bios_entry(amd_bios_type type);
bool needs_ish(enum platform platform_type);
#define EFS_FILE_SUFFIX ".efs"
#define TMP_FILE_SUFFIX ".tmp"

View file

@ -723,7 +723,7 @@ static uint8_t process_one_line(char *oneline, regmatch_t *match, char *dir,
return 1;
}
static bool needs_ish(enum platform platform_type)
bool needs_ish(enum platform platform_type)
{
if (platform_type == PLATFORM_MENDOCINO || platform_type == PLATFORM_PHOENIX || platform_type == PLATFORM_GLINDA)
return true;