util/amdfwtool: Clarify APOB NV requirements

Relocate the first size check.  This was automatically continuing
and not looking for the caller incorrectly passing a destination.

New information indicates that the APOB_NV should always be present
in the system.  Augment the missing size check to inferring whether
a missing size is valid, as in the case of older products, or truly
missing when it's needed.

Signed-off-by: Marshall Dawson <marshalldawson3rd@gmail.com>
Change-Id: I51f5333de4392dec1478bd84563c053a508b9e9e
Reviewed-on: https://review.coreboot.org/c/coreboot/+/38690
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
Marshall Dawson 2020-01-21 17:17:59 -07:00 committed by Martin Roth
parent 4062b6a3b1
commit c4a8c48b2f
1 changed files with 25 additions and 3 deletions

View File

@ -808,6 +808,17 @@ static int have_bios_tables(amd_bios_entry *table)
return 0;
}
static int find_bios_entry(amd_bios_type type)
{
int i;
for (i = 0; amd_bios_table[i].type != AMD_BIOS_INVALID; i++) {
if (amd_bios_table[i].type == type)
return i;
}
return -1;
}
static void integrate_bios_firmwares(context *ctx,
bios_directory_table *biosdir,
bios_directory_table *biosdir2,
@ -817,6 +828,7 @@ static void integrate_bios_firmwares(context *ctx,
ssize_t bytes;
unsigned int i, count;
int level;
int apob_idx;
/* This function can create a primary table, a secondary table, or a
* flattened table which contains all applicable types. These if-else
@ -843,9 +855,6 @@ static void integrate_bios_firmwares(context *ctx,
fw_table[i].type != AMD_BIOS_L2_PTR &&
fw_table[i].type != AMD_BIOS_BIN))
continue;
/* APOB_NV needs a size, else no S3 and skip item */
if (fw_table[i].type == AMD_BIOS_APOB_NV && !fw_table[i].size)
continue;
/* BIOS Directory items may have additional requirements */
@ -857,6 +866,19 @@ static void integrate_bios_firmwares(context *ctx,
exit(1);
}
}
/* APOB_NV needs a size, else no choice but to skip the item */
if (fw_table[i].type == AMD_BIOS_APOB_NV && !fw_table[i].size) {
/* Attempt to determine whether this is an error */
apob_idx = find_bios_entry(AMD_BIOS_APOB);
if (apob_idx < 0 || !fw_table[apob_idx].dest) {
/* APOV NV not expected to be used */
continue;
} else {
printf("Error: APOB NV must have a size\n");
free(ctx->rom);
exit(1);
}
}
/* APOB_DATA needs destination */
if (fw_table[i].type == AMD_BIOS_APOB && !fw_table[i].dest) {