util/amdfwtool: Introduce combo-capable option

There are effectively two unique sets of arguments for the utility,
causing one of two tables to be constructed.  Both tables are
identical, however, and therefore the only practical difference is
the offset in the Embedded Firmware Structure which holds the pointer
to the table.

This patch is part 1 of 2 to reduce the number of command-line options
to amdfwtool.  Create a new option that is used as an indicator for
which Embedded Firmware offset to use.  Part 2 will be added once
makefiles no longer use the duplicated options.

This patch also adds two new options for fanless SMU firmware to be
used instead of the ones that will be removed in part 2.

TEST=Verify no difference in amdfw.rom for google/grunt before
     and after the patch is applied
BUG=b:126691068

Change-Id: I249700c6addad1c0ecb495a406ffe7a022dd920b
Signed-off-by: Marshall Dawson <marshalldawson3rd@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/31729
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
Marshall Dawson 2019-02-28 11:43:40 -07:00 committed by Martin Roth
parent 8a45a4dc3f
commit 67d868d04b
1 changed files with 29 additions and 7 deletions

View File

@ -164,9 +164,12 @@ static void usage(void)
printf("-g | --gec <FILE> Add GEC blob\n"); printf("-g | --gec <FILE> Add GEC blob\n");
printf("\nPSP options:\n"); printf("\nPSP options:\n");
printf("-A | --combo-capable Place PSP directory pointer at Embedded Firmware\n");
printf(" offset able to support combo directory\n");
printf("-p | --pubkey <FILE> Add pubkey\n"); printf("-p | --pubkey <FILE> Add pubkey\n");
printf("-b | --bootloader <FILE> Add bootloader\n"); printf("-b | --bootloader <FILE> Add bootloader\n");
printf("-s | --smufirmware <FILE> Add smufirmware\n"); printf("-s | --smufirmware <FILE> Add smufirmware\n");
printf("-j | --smufnfirmware <FILE> Add fanless smufirmware\n");
printf("-r | --recovery <FILE> Add recovery\n"); printf("-r | --recovery <FILE> Add recovery\n");
printf("-k | --rtmpubkey <FILE> Add rtmpubkey\n"); printf("-k | --rtmpubkey <FILE> Add rtmpubkey\n");
printf("-c | --secureos <FILE> Add secureos\n"); printf("-c | --secureos <FILE> Add secureos\n");
@ -175,6 +178,7 @@ static void usage(void)
printf("-t | --trustlets <FILE> Add trustlets\n"); printf("-t | --trustlets <FILE> Add trustlets\n");
printf("-u | --trustletkey <FILE> Add trustletkey\n"); printf("-u | --trustletkey <FILE> Add trustletkey\n");
printf("-w | --smufirmware2 <FILE> Add smufirmware2\n"); printf("-w | --smufirmware2 <FILE> Add smufirmware2\n");
printf("-e | --smufnfirmware2 <FILE> Add fanless smufirmware2\n");
printf("-m | --smuscs <FILE> Add smuscs\n"); printf("-m | --smuscs <FILE> Add smuscs\n");
#if PSP2 #if PSP2
@ -474,9 +478,9 @@ static uint32_t integrate_psp_firmwares(char *base, uint32_t pos,
#if PSP2 #if PSP2
static const char *optstring = static const char *optstring =
"x:i:g:p:b:s:r:k:c:n:d:t:u:w:m:P:B:S:L:R:K:C:N:D:T:U:W:E:M:o:f:l:h"; "x:i:g:Ap:b:s:r:k:c:n:d:t:u:w:e:j:m:P:B:S:L:R:K:C:N:D:T:U:W:E:M:o:f:l:h";
#else #else
static const char *optstring = "x:i:g:p:b:s:r:k:c:n:d:t:u:w:m:o:f:l:h"; static const char *optstring = "x:i:g:Ap:b:s:r:k:c:n:d:t:u:w:e:j:m:o:f:l:h";
#endif #endif
static struct option long_options[] = { static struct option long_options[] = {
@ -484,9 +488,11 @@ static struct option long_options[] = {
{"imc", required_argument, 0, 'i' }, {"imc", required_argument, 0, 'i' },
{"gec", required_argument, 0, 'g' }, {"gec", required_argument, 0, 'g' },
/* PSP */ /* PSP */
{"combo-capable", no_argument, 0, 'A' },
{"pubkey", required_argument, 0, 'p' }, {"pubkey", required_argument, 0, 'p' },
{"bootloader", required_argument, 0, 'b' }, {"bootloader", required_argument, 0, 'b' },
{"smufirmware", required_argument, 0, 's' }, {"smufirmware", required_argument, 0, 's' },
{"smufnfirmware", required_argument, 0, 'j' },
{"recovery", required_argument, 0, 'r' }, {"recovery", required_argument, 0, 'r' },
{"rtmpubkey", required_argument, 0, 'k' }, {"rtmpubkey", required_argument, 0, 'k' },
{"secureos", required_argument, 0, 'c' }, {"secureos", required_argument, 0, 'c' },
@ -495,6 +501,7 @@ static struct option long_options[] = {
{"trustlets", required_argument, 0, 't' }, {"trustlets", required_argument, 0, 't' },
{"trustletkey", required_argument, 0, 'u' }, {"trustletkey", required_argument, 0, 'u' },
{"smufirmware2", required_argument, 0, 'w' }, {"smufirmware2", required_argument, 0, 'w' },
{"smufnfirmware2", required_argument, 0, 'e' },
{"smuscs", required_argument, 0, 'm' }, {"smuscs", required_argument, 0, 'm' },
/* TODO: PSP2 */ /* TODO: PSP2 */
@ -574,6 +581,7 @@ int main(int argc, char **argv)
uint32_t current; uint32_t current;
embedded_firmware *amd_romsig; embedded_firmware *amd_romsig;
psp_directory_table *pspdir; psp_directory_table *pspdir;
int comboable = 0;
int targetfd; int targetfd;
char *output = NULL; char *output = NULL;
@ -600,6 +608,9 @@ int main(int argc, char **argv)
case 'g': case 'g':
register_fw_filename(AMD_FW_GEC, optarg, 0); register_fw_filename(AMD_FW_GEC, optarg, 0);
break; break;
case 'A':
comboable = 1;
break;
case 'p': case 'p':
register_fw_filename(AMD_FW_PSP_PUBKEY, optarg, 1); register_fw_filename(AMD_FW_PSP_PUBKEY, optarg, 1);
pspflag = 1; pspflag = 1;
@ -613,6 +624,11 @@ int main(int argc, char **argv)
optarg, 1); optarg, 1);
pspflag = 1; pspflag = 1;
break; break;
case 'j':
register_fw_filename(AMD_FW_PSP_SMU_FN_FIRMWARE,
optarg, 1);
pspflag = 1;
break;
case 'r': case 'r':
register_fw_filename(AMD_FW_PSP_RECOVERY, optarg, 1); register_fw_filename(AMD_FW_PSP_RECOVERY, optarg, 1);
pspflag = 1; pspflag = 1;
@ -647,6 +663,11 @@ int main(int argc, char **argv)
optarg, 1); optarg, 1);
pspflag = 1; pspflag = 1;
break; break;
case 'e':
register_fw_filename(AMD_FW_PSP_SMU_FN_FIRMWARE2,
optarg, 1);
pspflag = 1;
break;
case 'm': case 'm':
register_fw_filename(AMD_FW_PSP_SMUSCS, optarg, 1); register_fw_filename(AMD_FW_PSP_SMUSCS, optarg, 1);
pspflag = 1; pspflag = 1;
@ -816,11 +837,14 @@ int main(int argc, char **argv)
current = integrate_firmwares(rom, current, amd_romsig, current = integrate_firmwares(rom, current, amd_romsig,
amd_fw_table, rom_size); amd_fw_table, rom_size);
if (pspflag == 1) { current = ALIGN(current, 0x10000U);
current = ALIGN(current, 0x10000U); if (psp2flag || comboable)
pspdir = (void *)(rom + current); amd_romsig->comboable = current + rom_base_address;
else
amd_romsig->psp_entry = current + rom_base_address; amd_romsig->psp_entry = current + rom_base_address;
if (pspflag == 1) {
pspdir = (void *)(rom + current);
current += 0x200; /* Conservative size of pspdir */ current += 0x200; /* Conservative size of pspdir */
current = integrate_psp_firmwares(rom, current, pspdir, current = integrate_psp_firmwares(rom, current, pspdir,
amd_psp_fw_table, rom_size); amd_psp_fw_table, rom_size);
@ -828,9 +852,7 @@ int main(int argc, char **argv)
#if PSP2 #if PSP2
if (psp2flag == 1) { if (psp2flag == 1) {
current = ALIGN(current, 0x10000U); /* PSP2 dir */
psp2dir = (void *)(rom + current); psp2dir = (void *)(rom + current);
amd_romsig->comboable = current + rom_base_address;
current += 0x200; /* Add conservative size of psp2dir. */ current += 0x200; /* Add conservative size of psp2dir. */
#if PSP_COMBO #if PSP_COMBO