summaryrefslogtreecommitdiff
path: root/util/amdfwtool
diff options
context:
space:
mode:
authorMartin Roth <martinroth@google.com>2017-10-03 14:16:04 -0600
committerMartin Roth <martinroth@google.com>2017-10-05 02:49:09 +0000
commit0d3b11898b3ea117696b49c8a27854228e471902 (patch)
treeaa88a2649d231725eefc243ddb753342efd5fbc6 /util/amdfwtool
parentb0b4fd45e534e03bfc0023a31111215eae391a92 (diff)
downloadcoreboot-0d3b11898b3ea117696b49c8a27854228e471902.tar.xz
util/amdfwtool: Add option for directory location
The AMD firmware directory can go in a number of different locations. This patch allows amdfwtool to write the directory correctly for those different locations. If the --location switch is not added to the command line, the default location at ROM base address + 0x20000 is used as before. BUG=b:65484600 TEST=Set PSP firmware location, compare amdfw.rom to previously built version. Verify new location pointers. Change-Id: Ief32e5e37d56088946b623d305c6e93bfd6abeaf Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/21865 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'util/amdfwtool')
-rw-r--r--util/amdfwtool/amdfwtool.c50
1 files changed, 45 insertions, 5 deletions
diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c
index 0c1bde5807..61c2a0587d 100644
--- a/util/amdfwtool/amdfwtool.c
+++ b/util/amdfwtool/amdfwtool.c
@@ -190,6 +190,7 @@ static void usage(void)
printf(" size must be larger than %dKB\n",
MIN_ROM_KB);
printf(" and must a multiple of 1024\n");
+ printf("-l | --location Location of Directory\n");
printf("-h | --help show this help\n");
}
@@ -377,9 +378,9 @@ static uint32_t integrate_psp_firmwares(char *base, uint32_t pos,
#if PSP2
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:h";
+ "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";
#else
-static const char *optstring = "x:i:g:p:b:s:r:k:c:n:d:t:u:w:m:o:f:h";
+static const char *optstring = "x:i:g:p:b:s:r:k:c:n:d:t:u:w:m:o:f:l:h";
#endif
static struct option long_options[] = {
@@ -420,6 +421,7 @@ static struct option long_options[] = {
{"output", required_argument, 0, 'o' },
{"flashsize", required_argument, 0, 'f' },
+ {"location", required_argument, 0, 'l' },
{"help", no_argument, 0, 'h' },
{NULL, 0, 0, 0 }
@@ -479,6 +481,8 @@ int main(int argc, char **argv)
int targetfd;
char *output = NULL;
uint32_t rom_size = CONFIG_ROM_SIZE;
+ uint32_t dir_location = 0;
+ uint32_t romsig_offset;
uint32_t rom_base_address;
while (1) {
@@ -624,6 +628,15 @@ int main(int argc, char **argv)
retval = 1;
}
break;
+ case 'l':
+ dir_location = (uint32_t)strtoul(optarg, &tmp, 16);
+ if (*tmp != '\0') {
+ printf("Error: Directory Location specified"
+ " incorrectly (%s)\n\n", optarg);
+ retval = 1;
+ }
+ break;
+
case 'h':
usage();
return 0;
@@ -662,13 +675,40 @@ int main(int argc, char **argv)
printf(" AMDFWTOOL Using ROM size of %dKB\n", rom_size / 1024);
rom_base_address = 0xFFFFFFFF - rom_size + 1;
+ if (dir_location && (dir_location < rom_base_address)) {
+ printf("Error: Directory location outside of ROM.\n\n");
+ return 1;
+ }
+
+ switch (dir_location) {
+ case 0: /* Fall through */
+ case 0xFFFA0000: /* Fall through */
+ case 0xFFF20000: /* Fall through */
+ case 0xFFE20000: /* Fall through */
+ case 0xFFC20000: /* Fall through */
+ 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;
+ }
+
rom = malloc(rom_size);
if (!rom)
return 1;
memset(rom, 0xFF, rom_size);
- current = AMD_ROMSIG_OFFSET;
- amd_romsig = (void *)(rom + AMD_ROMSIG_OFFSET);
+ if (dir_location)
+ romsig_offset = current = dir_location - rom_base_address;
+ else
+ romsig_offset = current = AMD_ROMSIG_OFFSET;
+ printf(" AMDFWTOOL Using firmware directory location of %08lx\n",
+ (unsigned long)rom_base_address + current);
+
+ amd_romsig = (void *)(rom + romsig_offset);
amd_romsig[0] = 0x55AA55AA; /* romsig */
amd_romsig[1] = 0;
amd_romsig[2] = 0;
@@ -731,7 +771,7 @@ int main(int argc, char **argv)
targetfd = open(output, O_RDWR | O_CREAT | O_TRUNC, 0666);
if (targetfd >= 0) {
- write(targetfd, amd_romsig, current - AMD_ROMSIG_OFFSET);
+ write(targetfd, amd_romsig, current - romsig_offset);
close(targetfd);
} else {
printf("Error: could not open file: %s\n", output);