Fred Reitberger has submitted this change. ( https://review.coreboot.org/c/coreboot/+/58552 )
Change subject: amdfwtool: Put soc name setting to fw.cfg from command line ......................................................................
amdfwtool: Put soc name setting to fw.cfg from command line
The fw.cfg should combine the SOC name. This is for future combo feature. Each entry in combo has its own fw.cfg. The soc_id in struct cb_config can only be available after the fw.cfg is processed. Some functions which take soc_id as a parameter can be simplified.
3/5 (and the key one with same change ID) of split changes of https://review.coreboot.org/c/coreboot/+/58552/28
Change-Id: Ib0eead1f2156542ea03d58145f5ad67683bf9b52 Signed-off-by: Zheng Bao fishbaozi@gmail.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/58552 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Fred Reitberger reitbergerfred@gmail.com --- M util/amdfwtool/amdfwtool.c M util/amdfwtool/data_parse.c 2 files changed, 93 insertions(+), 75 deletions(-)
Approvals: build bot (Jenkins): Verified Fred Reitberger: Looks good to me, approved
diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c index 82825e1..4ed7094 100644 --- a/util/amdfwtool/amdfwtool.c +++ b/util/amdfwtool/amdfwtool.c @@ -2059,63 +2059,6 @@ return bytes; }
-static int identify_platform(char *soc_name) -{ - if (!strcasecmp(soc_name, "Stoneyridge")) - return PLATFORM_STONEYRIDGE; - else if (!strcasecmp(soc_name, "Carrizo")) - return PLATFORM_CARRIZO; - else if (!strcasecmp(soc_name, "Raven")) - return PLATFORM_RAVEN; - else if (!strcasecmp(soc_name, "Picasso")) - return PLATFORM_PICASSO; - else if (!strcasecmp(soc_name, "Cezanne")) - return PLATFORM_CEZANNE; - else if (!strcasecmp(soc_name, "Mendocino")) - return PLATFORM_MENDOCINO; - else if (!strcasecmp(soc_name, "Renoir")) - return PLATFORM_RENOIR; - else if (!strcasecmp(soc_name, "Lucienne")) - return PLATFORM_LUCIENNE; - else if (!strcasecmp(soc_name, "Phoenix")) - return PLATFORM_PHOENIX; - else if (!strcasecmp(soc_name, "Glinda")) - return PLATFORM_GLINDA; - else - return PLATFORM_UNKNOWN; - -} - -static bool needs_ish(enum platform platform_type) -{ - if (platform_type == PLATFORM_MENDOCINO || platform_type == PLATFORM_PHOENIX || platform_type == PLATFORM_GLINDA) - return true; - else - return false; -} - -static bool is_second_gen(enum platform platform_type) -{ - switch (platform_type) { - case PLATFORM_CARRIZO: - case PLATFORM_STONEYRIDGE: - case PLATFORM_RAVEN: - case PLATFORM_PICASSO: - return false; - case PLATFORM_RENOIR: - case PLATFORM_LUCIENNE: - case PLATFORM_CEZANNE: - case PLATFORM_MENDOCINO: - case PLATFORM_PHOENIX: - case PLATFORM_GLINDA: - return true; - case PLATFORM_UNKNOWN: - default: - fprintf(stderr, "Error: Invalid SOC name.\n\n"); - return false; - } -} - int main(int argc, char **argv) { int c; @@ -2283,12 +2226,6 @@ sub = instance = 0; break; case AMDFW_OPT_SOC_NAME: - cb_config.soc_id = identify_platform(optarg); - if (cb_config.soc_id == PLATFORM_UNKNOWN) { - fprintf(stderr, "Error: Invalid SOC name specified\n\n"); - retval = 1; - } - sub = instance = 0; break; case AMDFW_OPT_SIGNED_OUTPUT: signed_output_file = optarg; @@ -2380,17 +2317,6 @@ } }
- cb_config.second_gen = is_second_gen(cb_config.soc_id); - - if (needs_ish(cb_config.soc_id)) - cb_config.need_ish = true; - - if (cb_config.need_ish) - cb_config.recovery_ab = true; - - if (cb_config.recovery_ab) - cb_config.multi_level = true; - if (config) { config_handle = fopen(config, "r"); if (config_handle == NULL) { diff --git a/util/amdfwtool/data_parse.c b/util/amdfwtool/data_parse.c index 6962481..2f33830 100644 --- a/util/amdfwtool/data_parse.c +++ b/util/amdfwtool/data_parse.c @@ -78,6 +78,32 @@ } }
+static enum platform identify_platform(char *soc_name) +{ + if (!strcasecmp(soc_name, "Stoneyridge")) + return PLATFORM_STONEYRIDGE; + else if (!strcasecmp(soc_name, "Carrizo")) + return PLATFORM_CARRIZO; + else if (!strcasecmp(soc_name, "Raven")) + return PLATFORM_RAVEN; + else if (!strcasecmp(soc_name, "Picasso")) + return PLATFORM_PICASSO; + else if (!strcasecmp(soc_name, "Cezanne")) + return PLATFORM_CEZANNE; + else if (!strcasecmp(soc_name, "Mendocino")) + return PLATFORM_MENDOCINO; + else if (!strcasecmp(soc_name, "Renoir")) + return PLATFORM_RENOIR; + else if (!strcasecmp(soc_name, "Lucienne")) + return PLATFORM_LUCIENNE; + else if (!strcasecmp(soc_name, "Phoenix")) + return PLATFORM_PHOENIX; + else if (!strcasecmp(soc_name, "Glinda")) + return PLATFORM_GLINDA; + else + return PLATFORM_UNKNOWN; +} + #define SET_LEVEL(tableptr, l, TABLE, ab) \ do { \ switch ((l)) { \ @@ -646,6 +672,36 @@ return 1; }
+static bool needs_ish(enum platform platform_type) +{ + if (platform_type == PLATFORM_MENDOCINO || platform_type == PLATFORM_PHOENIX || platform_type == PLATFORM_GLINDA) + return true; + else + return false; +} + +static bool is_second_gen(enum platform platform_type) +{ + switch (platform_type) { + case PLATFORM_CARRIZO: + case PLATFORM_STONEYRIDGE: + case PLATFORM_RAVEN: + case PLATFORM_PICASSO: + return false; + case PLATFORM_RENOIR: + case PLATFORM_LUCIENNE: + case PLATFORM_CEZANNE: + case PLATFORM_MENDOCINO: + case PLATFORM_PHOENIX: + case PLATFORM_GLINDA: + return true; + case PLATFORM_UNKNOWN: + default: + fprintf(stderr, "Error: Invalid SOC name.\n\n"); + return false; + } +} + /* return value: 0: The config file can not be parsed correctly. @@ -683,11 +739,24 @@ assert(dir_len < MAX_LINE_SIZE); snprintf(dir, MAX_LINE_SIZE, "%.*s", dir_len, &(oneline[match[2].rm_so])); - break; + } else if (strcmp(&(oneline[match[1].rm_so]), "SOC_NAME") == 0) { + cb_config->soc_id = + identify_platform(&(oneline[match[2].rm_so])); } } }
+ cb_config->second_gen = is_second_gen(cb_config->soc_id); + + if (needs_ish(cb_config->soc_id)) + cb_config->need_ish = true; + + if (cb_config->need_ish) + cb_config->recovery_ab = true; + + if (cb_config->recovery_ab) + cb_config->multi_level = true; + if (dir[0] == '\0') { fprintf(stderr, "No line with FIRMWARE_LOCATION\n"); return 0;