Attention is currently required from: Zheng Bao.
Hello Zheng Bao,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/73496
to review the following change.
Change subject: amdfwtool: Add combo index and combo config table ......................................................................
amdfwtool: Add combo index and combo config table
For now, combo index is 0, and only first entry in config table is used. Next the index will grow.
Change-Id: I00609d91defc08e17f937ac8339575f84b1bd37c Signed-off-by: Zheng Bao fishbaozi@gmail.com --- M util/amdfwtool/amdfwtool.c M util/amdfwtool/amdfwtool.h 2 files changed, 37 insertions(+), 13 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/96/73496/1
diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c index 1fcf8a0..554c91a 100644 --- a/util/amdfwtool/amdfwtool.c +++ b/util/amdfwtool/amdfwtool.c @@ -2161,6 +2161,8 @@ psp_directory_table *pspdir2 = NULL; psp_directory_table *pspdir2_b = NULL; psp_combo_directory *psp_combo_dir = NULL, *bhd_combo_dir = NULL; + char *combo_config[4] = { 0 }; + int combo_index = 0; int fuse_defined = 0; int targetfd; char *output = NULL, *config = NULL; @@ -2551,15 +2553,22 @@ bhd_combo_dir = new_combo_dir(&ctx); }
- if (config) { - config_handle = fopen(config, "r"); + if (config) + combo_config[0] = config; + + combo_index = 0; + + /* for non-combo image, combo_config[0] == config */ + if (combo_config[combo_index]) { + config_handle = fopen(combo_config[combo_index], "r"); if (config_handle == NULL) { fprintf(stderr, "Can not open file %s for reading: %s\n", - config, strerror(errno)); + combo_config[combo_index], strerror(errno)); exit(1); } if (process_config(config_handle, &cb_config, list_deps) == 0) { - fprintf(stderr, "Configuration file %s parsing error\n", config); + fprintf(stderr, "Configuration file %s parsing error\n", + combo_config[combo_index]); fclose(config_handle); exit(1); } @@ -2619,12 +2628,13 @@ } else { fill_psp_directory_to_efs(amd_romsig, psp_combo_dir, &ctx, &cb_config); /* 0 -Compare PSP ID, 1 -Compare chip family ID */ - psp_combo_dir->entries[0].id_sel = 0; - psp_combo_dir->entries[0].id = get_psp_id(cb_config.soc_id); - psp_combo_dir->entries[0].lvl2_addr = + assert_fw_entry(combo_index, MAX_COMBO_ENTRIES, &ctx); + psp_combo_dir->entries[combo_index].id_sel = 0; + psp_combo_dir->entries[combo_index].id = get_psp_id(cb_config.soc_id); + psp_combo_dir->entries[combo_index].lvl2_addr = BUFF_TO_RUN_MODE(ctx, pspdir, AMD_ADDR_REL_BIOS);
- fill_dir_header(psp_combo_dir, 1, PSP2_COOKIE, &ctx); + fill_dir_header(psp_combo_dir, combo_index + 1, PSP2_COOKIE, &ctx); }
if (have_bios_tables(amd_bios_table)) { @@ -2664,12 +2674,13 @@ fill_bios_directory_to_efs(amd_romsig, biosdir, &ctx, &cb_config); } else { fill_bios_directory_to_efs(amd_romsig, bhd_combo_dir, &ctx, &cb_config); - bhd_combo_dir->entries[0].id_sel = 0; - bhd_combo_dir->entries[0].id = get_psp_id(cb_config.soc_id); - bhd_combo_dir->entries[0].lvl2_addr = + assert_fw_entry(combo_index, MAX_COMBO_ENTRIES, &ctx); + bhd_combo_dir->entries[combo_index].id_sel = 0; + bhd_combo_dir->entries[combo_index].id = get_psp_id(cb_config.soc_id); + bhd_combo_dir->entries[combo_index].lvl2_addr = BUFF_TO_RUN_MODE(ctx, biosdir, AMD_ADDR_REL_BIOS);
- fill_dir_header(bhd_combo_dir, 1, BHD2_COOKIE, &ctx); + fill_dir_header(bhd_combo_dir, combo_index + 1, BHD2_COOKIE, &ctx); } }
diff --git a/util/amdfwtool/amdfwtool.h b/util/amdfwtool/amdfwtool.h index 2ccb3e9..42a2c1d 100644 --- a/util/amdfwtool/amdfwtool.h +++ b/util/amdfwtool/amdfwtool.h @@ -237,7 +237,7 @@ psp_combo_entry entries[]; } __attribute__((packed, aligned(16))) psp_combo_directory;
-#define MAX_COMBO_ENTRIES 1 +#define MAX_COMBO_ENTRIES 2
typedef struct _bios_directory_hdr { uint32_t cookie;