summaryrefslogtreecommitdiff
path: root/util/amdfwtool
diff options
context:
space:
mode:
authorZheng Bao <fishbaozi@gmail.com>2023-01-25 22:58:49 +0800
committerFred Reitberger <reitbergerfred@gmail.com>2023-02-11 12:58:17 +0000
commit010cc99896ae67b7267d21c08363fb4391cde421 (patch)
treeac1c710fe3c3d1626074d79268126db69e8d917e /util/amdfwtool
parentc188936dfe2f384228344d69801e10d97600d748 (diff)
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>
Diffstat (limited to 'util/amdfwtool')
-rw-r--r--util/amdfwtool/amdfwtool.c74
-rw-r--r--util/amdfwtool/data_parse.c71
2 files changed, 70 insertions, 75 deletions
diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c
index 82825e1fc0..4ed709417d 100644
--- a/util/amdfwtool/amdfwtool.c
+++ b/util/amdfwtool/amdfwtool.c
@@ -2059,63 +2059,6 @@ static ssize_t write_efs(char *output, embedded_firmware *amd_romsig)
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 @@ int main(int argc, char **argv)
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 @@ int main(int argc, char **argv)
}
}
- 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 696248176a..2f338309ed 100644
--- a/util/amdfwtool/data_parse.c
+++ b/util/amdfwtool/data_parse.c
@@ -78,6 +78,32 @@ void compile_reg_expr(int cflags, const char *expr, regex_t *reg)
}
}
+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 @@ static uint8_t process_one_line(char *oneline, regmatch_t *match, char *dir,
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 @@ uint8_t process_config(FILE *config, amd_cb_config *cb_config, uint8_t print_dep
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;