util/amdfwtool: update to allow building in any location

For the verstage-on-PSP implementation, we need 2 additional copies
of the AMD firmware tables at non-standard locations.  These are
for RW-A & RW-B fmap regions.  This change allows us to build the
AMD firmware tables into those regions.

BUG=b:148767300
TEST=boot with psp_verstage, verify boot location

Signed-off-by: Martin Roth <martin@coreboot.org>
Original-Signed-off-by: Martin Roth <martinroth@chromium.org>
Original-Change-Id: I2b591b50e9b179fdfaead46ff93722fa2a155e9c
Original-Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/coreboot/+/2144534
Original-Reviewed-by: Simon Glass <sjg@chromium.org>
Change-Id: I7f841db8617b953dc671a9c12576145f85263581
Reviewed-on: https://review.coreboot.org/c/coreboot/+/42043
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Raul Rangel <rrangel@chromium.org>
This commit is contained in:
Martin Roth 2020-04-07 14:16:39 -06:00 committed by Martin Roth
parent e9b27e5527
commit 37305e78fc
1 changed files with 31 additions and 16 deletions

View File

@ -48,6 +48,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
@ -211,6 +212,7 @@ static void usage(void)
MIN_ROM_KB); MIN_ROM_KB);
printf(" and must a multiple of 1024\n"); printf(" and must a multiple of 1024\n");
printf("-l | --location Location of Directory\n"); printf("-l | --location Location of Directory\n");
printf("-q | --anywhere Use any 64-byte aligned addr for Directory\n");
printf("-h | --help show this help\n"); printf("-h | --help show this help\n");
} }
@ -1021,8 +1023,8 @@ static void integrate_bios_firmwares(context *ctx,
fill_dir_header(biosdir, count, cookie); fill_dir_header(biosdir, count, cookie);
} }
// Unused values: CDEPqR // Unused values: CDEPR
static const char *optstring = "x:i:g:AMS:p:b:s:r:k:c:n:d:t:u:w:m:T:z:J:B:K:L:Y:N:UW:I:a:Q:V:e:v:j:y:G:O:X:F:H:o:f:l:hZ:"; static const char *optstring = "x:i:g:AMS:p:b:s:r:k:c:n:d:t:u:w:m:T:z:J:B:K:L:Y:N:UW:I:a:Q:V:e:v:j:y:G:O:X:F:H:o:f:l:hZ:q";
static struct option long_options[] = { static struct option long_options[] = {
{"xhci", required_argument, 0, 'x' }, {"xhci", required_argument, 0, 'x' },
@ -1073,6 +1075,7 @@ static struct option long_options[] = {
{"output", required_argument, 0, 'o' }, {"output", required_argument, 0, 'o' },
{"flashsize", required_argument, 0, 'f' }, {"flashsize", required_argument, 0, 'f' },
{"location", required_argument, 0, 'l' }, {"location", required_argument, 0, 'l' },
{"anywhere", no_argument, 0, 'q' },
{"help", no_argument, 0, 'h' }, {"help", no_argument, 0, 'h' },
{NULL, 0, 0, 0 } {NULL, 0, 0, 0 }
}; };
@ -1177,6 +1180,7 @@ int main(int argc, char **argv)
uint8_t sub = 0, instance = 0; uint8_t sub = 0, instance = 0;
int abl_image = 0; int abl_image = 0;
uint32_t dir_location = 0; uint32_t dir_location = 0;
bool any_location = 0;
uint32_t romsig_offset; uint32_t romsig_offset;
uint32_t rom_base_address; uint32_t rom_base_address;
int multi = 0; int multi = 0;
@ -1392,6 +1396,9 @@ int main(int argc, char **argv)
retval = 1; retval = 1;
} }
break; break;
case 'q':
any_location = 1;
break;
case 'h': case 'h':
usage(); usage();
@ -1434,20 +1441,28 @@ int main(int argc, char **argv)
return 1; return 1;
} }
switch (dir_location) { if (any_location) {
case 0: /* Fall through */ if (dir_location & 0x3f) {
case 0xFFFA0000: /* Fall through */ printf("Error: Invalid Directory location.\n");
case 0xFFF20000: /* Fall through */ printf(" Valid locations are 64-byte aligned\n");
case 0xFFE20000: /* Fall through */ return 1;
case 0xFFC20000: /* Fall through */ }
case 0xFF820000: /* Fall through */ } else {
case 0xFF020000: /* Fall through */ switch (dir_location) {
break; case 0: /* Fall through */
default: case 0xFFFA0000: /* Fall through */
printf("Error: Invalid Directory location.\n"); case 0xFFF20000: /* Fall through */
printf(" Valid locations are 0xFFFA0000, 0xFFF20000,\n"); case 0xFFE20000: /* Fall through */
printf(" 0xFFE20000, 0xFFC20000, 0xFF820000, 0xFF020000\n"); case 0xFFC20000: /* Fall through */
return 1; case 0xFF820000: /* Fall through */
case 0xFF020000: /* Fall through */
break;
default:
printf("Error: Invalid Directory location.\n");
printf(" Valid locations are 0xFFFA0000, 0xFFF20000,\n");
printf(" 0xFFE20000, 0xFFC20000, 0xFF820000, 0xFF020000\n");
return 1;
}
} }
ctx.rom = malloc(ctx.rom_size); ctx.rom = malloc(ctx.rom_size);