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>
This commit is contained in:
parent
c188936dfe
commit
010cc99896
|
@ -2059,63 +2059,6 @@ static ssize_t write_efs(char *output, embedded_firmware *amd_romsig)
|
||||||
return bytes;
|
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 main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
@ -2283,12 +2226,6 @@ int main(int argc, char **argv)
|
||||||
sub = instance = 0;
|
sub = instance = 0;
|
||||||
break;
|
break;
|
||||||
case AMDFW_OPT_SOC_NAME:
|
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;
|
break;
|
||||||
case AMDFW_OPT_SIGNED_OUTPUT:
|
case AMDFW_OPT_SIGNED_OUTPUT:
|
||||||
signed_output_file = optarg;
|
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) {
|
if (config) {
|
||||||
config_handle = fopen(config, "r");
|
config_handle = fopen(config, "r");
|
||||||
if (config_handle == NULL) {
|
if (config_handle == NULL) {
|
||||||
|
|
|
@ -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) \
|
#define SET_LEVEL(tableptr, l, TABLE, ab) \
|
||||||
do { \
|
do { \
|
||||||
switch ((l)) { \
|
switch ((l)) { \
|
||||||
|
@ -646,6 +672,36 @@ static uint8_t process_one_line(char *oneline, regmatch_t *match, char *dir,
|
||||||
return 1;
|
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:
|
return value:
|
||||||
0: The config file can not be parsed correctly.
|
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);
|
assert(dir_len < MAX_LINE_SIZE);
|
||||||
snprintf(dir, MAX_LINE_SIZE, "%.*s", dir_len,
|
snprintf(dir, MAX_LINE_SIZE, "%.*s", dir_len,
|
||||||
&(oneline[match[2].rm_so]));
|
&(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') {
|
if (dir[0] == '\0') {
|
||||||
fprintf(stderr, "No line with FIRMWARE_LOCATION\n");
|
fprintf(stderr, "No line with FIRMWARE_LOCATION\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue