summaryrefslogtreecommitdiff
path: root/util/amdfwtool/amdfwtool.c
diff options
context:
space:
mode:
authorZheng Bao <fishbaozi@gmail.com>2023-02-11 22:27:49 +0800
committerFred Reitberger <reitbergerfred@gmail.com>2023-03-08 12:49:07 +0000
commit2f6b7d557d9792efabefb8965f52b1537c2655ca (patch)
tree430c5555ec334e8226fad5a0198ddc46717a1deb /util/amdfwtool/amdfwtool.c
parent1a591d0c4460c896487ee429036754f315b92130 (diff)
amdfwtool: Move the filling of table headers into functions
It is easier to understand what these statements are about. Change-Id: Ib02c68c9f2ea84020b12682c41fb1a6f8f93d725 Signed-off-by: Zheng Bao <fishbaozi@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/66852 Reviewed-by: Fred Reitberger <reitbergerfred@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'util/amdfwtool/amdfwtool.c')
-rw-r--r--util/amdfwtool/amdfwtool.c98
1 files changed, 55 insertions, 43 deletions
diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c
index edac06aba8..8c780801db 100644
--- a/util/amdfwtool/amdfwtool.c
+++ b/util/amdfwtool/amdfwtool.c
@@ -688,6 +688,58 @@ static void fill_dir_header(void *directory, uint32_t count, uint32_t cookie, co
}
+static void fill_psp_directory_to_efs(embedded_firmware *amd_romsig, void *pspdir,
+ context *ctx, amd_cb_config *cb_config)
+{
+ switch (cb_config->soc_id) {
+ case PLATFORM_UNKNOWN:
+ amd_romsig->psp_directory =
+ BUFF_TO_RUN_MODE(*ctx, pspdir, AMD_ADDR_REL_BIOS);
+ break;
+ case PLATFORM_CEZANNE:
+ case PLATFORM_MENDOCINO:
+ case PLATFORM_PHOENIX:
+ case PLATFORM_GLINDA:
+ case PLATFORM_CARRIZO:
+ case PLATFORM_STONEYRIDGE:
+ case PLATFORM_RAVEN:
+ case PLATFORM_PICASSO:
+ case PLATFORM_LUCIENNE:
+ case PLATFORM_RENOIR:
+ default:
+ /* for combo, it is also combo_psp_directory */
+ amd_romsig->new_psp_directory =
+ BUFF_TO_RUN_MODE(*ctx, pspdir, AMD_ADDR_REL_BIOS);
+ break;
+ }
+}
+
+static void fill_bios_directory_to_efs(embedded_firmware *amd_romsig, void *biosdir,
+ context *ctx, amd_cb_config *cb_config)
+{
+ switch (cb_config->soc_id) {
+ case PLATFORM_RENOIR:
+ case PLATFORM_LUCIENNE:
+ case PLATFORM_CEZANNE:
+ if (!cb_config->recovery_ab)
+ amd_romsig->bios3_entry =
+ BUFF_TO_RUN_MODE(*ctx, biosdir, AMD_ADDR_REL_BIOS);
+ break;
+ case PLATFORM_MENDOCINO:
+ case PLATFORM_PHOENIX:
+ case PLATFORM_GLINDA:
+ break;
+ case PLATFORM_CARRIZO:
+ case PLATFORM_STONEYRIDGE:
+ case PLATFORM_RAVEN:
+ case PLATFORM_PICASSO:
+ default:
+ amd_romsig->bios1_entry =
+ BUFF_TO_RUN_MODE(*ctx, biosdir, AMD_ADDR_REL_BIOS);
+ break;
+ }
+}
+
static ssize_t copy_blob(void *dest, const char *src_file, size_t room)
{
int fd;
@@ -2564,31 +2616,11 @@ int main(int argc, char **argv)
amd_psp_fw_table, PSP_COOKIE, &cb_config);
}
- switch (cb_config.soc_id) {
- case PLATFORM_UNKNOWN:
- amd_romsig->psp_directory =
- BUFF_TO_RUN_MODE(ctx, pspdir, AMD_ADDR_REL_BIOS);
- break;
- case PLATFORM_CEZANNE:
- case PLATFORM_MENDOCINO:
- case PLATFORM_PHOENIX:
- case PLATFORM_GLINDA:
- case PLATFORM_CARRIZO:
- case PLATFORM_STONEYRIDGE:
- case PLATFORM_RAVEN:
- case PLATFORM_PICASSO:
- case PLATFORM_LUCIENNE:
- case PLATFORM_RENOIR:
- default:
- amd_romsig->new_psp_directory =
- BUFF_TO_RUN_MODE(ctx, pspdir, AMD_ADDR_REL_BIOS);
- break;
- }
+ fill_psp_directory_to_efs(amd_romsig, pspdir, &ctx, &cb_config);
if (cb_config.use_combo) {
psp_combo_directory *combo_dir = new_combo_dir(&ctx);
- amd_romsig->combo_psp_directory =
- BUFF_TO_RUN_MODE(ctx, combo_dir, AMD_ADDR_REL_BIOS);
+ fill_psp_directory_to_efs(amd_romsig, combo_dir, &ctx, &cb_config);
/* 0 -Compare PSP ID, 1 -Compare chip family ID */
combo_dir->entries[0].id_sel = 0;
combo_dir->entries[0].id = get_psp_id(cb_config.soc_id);
@@ -2631,27 +2663,7 @@ int main(int argc, char **argv)
integrate_bios_firmwares(&ctx, biosdir, NULL,
amd_bios_table, BHD_COOKIE, &cb_config);
}
- switch (cb_config.soc_id) {
- case PLATFORM_RENOIR:
- case PLATFORM_LUCIENNE:
- case PLATFORM_CEZANNE:
- if (!cb_config.recovery_ab)
- amd_romsig->bios3_entry =
- BUFF_TO_RUN_MODE(ctx, biosdir, AMD_ADDR_REL_BIOS);
- break;
- case PLATFORM_MENDOCINO:
- case PLATFORM_PHOENIX:
- case PLATFORM_GLINDA:
- break;
- case PLATFORM_CARRIZO:
- case PLATFORM_STONEYRIDGE:
- case PLATFORM_RAVEN:
- case PLATFORM_PICASSO:
- default:
- amd_romsig->bios1_entry =
- BUFF_TO_RUN_MODE(ctx, biosdir, AMD_ADDR_REL_BIOS);
- break;
- }
+ fill_bios_directory_to_efs(amd_romsig, biosdir, &ctx, &cb_config);
}
targetfd = open(output, O_RDWR | O_CREAT | O_TRUNC, 0666);