Kangheui Won has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/59583 )
Change subject: amdfwtool: replace strcmp to switch-case ......................................................................
amdfwtool: replace strcmp to switch-case
Since we have separate function for filename to fw_type conversion, when we determine whether we should include the firmware or not we have fw_type.
Replace strcmp in if-else to switch-case so it looks more clear. However PSPBTLDR_WL_FILE and PSPBTLDR_AB_FILE have same fw_type so we should use strmp for them.
BUG=b:206909680 TEST=build guybrush and confirm amdfw and coreboot.rom are identical
Signed-off-by: Kangheui Won khwon@chromium.org Change-Id: Icf9f3465a36d83cf79f9f4bd1ec824b546a71aaf --- M util/amdfwtool/data_parse.c 1 file changed, 30 insertions(+), 33 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/83/59583/1
diff --git a/util/amdfwtool/data_parse.c b/util/amdfwtool/data_parse.c index e1b6db9..25e739a 100644 --- a/util/amdfwtool/data_parse.c +++ b/util/amdfwtool/data_parse.c @@ -157,6 +157,34 @@ {"PSPBTLDR_AB_FILE", AMD_FW_PSP_BOOTLOADER_AB, 0} };
+static bool should_skip_entry(char *fw_name, amd_fw_type fw_type, + amd_cb_config *cb_config) +{ + switch (fw_type) { + case AMD_FW_PSP_SECURED_DEBUG: + case AMD_DEBUG_UNLOCK: + return !(cb_config->unlock_secure); + case AMD_FW_PSP_SECURED_OS: + case AMD_FW_PSP_TRUSTLETS: + case AMD_FW_PSP_TRUSTLETKEY: + return !(cb_config->use_secureos); + case AMD_MP2_FW: + return !(cb_config->load_mp2_fw); + case AMD_S0I3_DRIVER: + return !(cb_config->s0i3); + case AMD_FW_PSP_BOOTLOADER_AB: + if (strcmp(fw_name, "PSPBTLDR_WL_FILE") == 0) { + return !(cb_config->have_whitelist); + } else { + return (cb_config->have_whitelist); + } + break; + default: + /* default to include */ + return 0; + } +} + static uint8_t find_register_fw_filename_psp_dir(char *fw_name, char *filename, char level_to_set, amd_cb_config *cb_config) { @@ -172,39 +200,8 @@ break; } } - if (strcmp(fw_name, "PSPBTLDR_WL_FILE") == 0) { - if (!cb_config->have_whitelist) - fw_type = AMD_FW_SKIP; - } else if (strcmp(fw_name, "PSPSECUREDEBUG_FILE") == 0) { - if (!cb_config->unlock_secure) - fw_type = AMD_FW_SKIP; - } else if (strcmp(fw_name, "PSP_SEC_DEBUG_FILE") == 0) { - if (!cb_config->unlock_secure) - fw_type = AMD_FW_SKIP; - } else if (strcmp(fw_name, "PSPSECUREOS_FILE") == 0) { - if (!cb_config->use_secureos) - fw_type = AMD_FW_SKIP; - } else if (strcmp(fw_name, "PSPTRUSTLETS_FILE") == 0) { - if (!cb_config->use_secureos) - fw_type = AMD_FW_SKIP; - } else if (strcmp(fw_name, "TRUSTLETKEY_FILE") == 0) { - if (!cb_config->use_secureos) - fw_type = AMD_FW_SKIP; - } else if (strcmp(fw_name, "PSP_MP2FW0_FILE") == 0) { - if (!cb_config->load_mp2_fw) - fw_type = AMD_FW_SKIP; - } else if (strcmp(fw_name, "PSP_MP2FW1_FILE") == 0) { - if (!cb_config->load_mp2_fw) - fw_type = AMD_FW_SKIP; - } else if (strcmp(fw_name, "PSP_MP2FW2_FILE") == 0) { - if (!cb_config->load_mp2_fw) - fw_type = AMD_FW_SKIP; - } else if (strcmp(fw_name, "PSP_S0I3_FILE") == 0) { - if (!cb_config->s0i3) - fw_type = AMD_FW_SKIP; - } else if (strcmp(fw_name, "PSPBTLDR_AB_FILE") == 0) { - if (cb_config->have_whitelist) - fw_type = AMD_FW_SKIP; + if (should_skip_entry(fw_name, fw_type, cb_config)) { + fw_type = AMD_FW_SKIP; }
/* Search and fill the filename */