<p>Martin Roth has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/21865">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">util/amdfwtool: Add option for directory location<br><br>The AMD firmware directory can go in a number of different locations.<br>This patch allows amdfwtool to write the directory correctly for those<br>different locations.<br><br>If the --location switch is not added to the command line, the default<br>location at ROM base address + 0x20000 is used as before.<br><br>BUG=b:65484600<br>TEST=Set PSP firmware location, compare amdfw.rom to previously built<br>version. Verify new location pointers.<br><br>Change-Id: Ief32e5e37d56088946b623d305c6e93bfd6abeaf<br>Signed-off-by: Martin Roth <martinroth@google.com><br>---<br>M util/amdfwtool/amdfwtool.c<br>1 file changed, 45 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/65/21865/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c<br>index 0c1bde5..1ecb80d 100644<br>--- a/util/amdfwtool/amdfwtool.c<br>+++ b/util/amdfwtool/amdfwtool.c<br>@@ -190,6 +190,7 @@<br> printf(" size must be larger than %dKB\n",<br> MIN_ROM_KB);<br> printf(" and must a multiple of 1024\n");<br>+ printf("-l | --location Location of Directory\n");<br> printf("-h | --help show this help\n");<br> <br> }<br>@@ -377,9 +378,9 @@<br> <br> #if PSP2<br> static const char *optstring =<br>- "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";<br>+ "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";<br> #else<br>-static const char *optstring = "x:i:g:p:b:s:r:k:c:n:d:t:u:w:m:o:f:h";<br>+static const char *optstring = "x:i:g:p:b:s:r:k:c:n:d:t:u:w:m:o:f:l:h";<br> #endif<br> <br> static struct option long_options[] = {<br>@@ -420,6 +421,7 @@<br> <br> {"output", required_argument, 0, 'o' },<br> {"flashsize", required_argument, 0, 'f' },<br>+ {"location", required_argument, 0, 'l' },<br> {"help", no_argument, 0, 'h' },<br> <br> {NULL, 0, 0, 0 }<br>@@ -479,6 +481,8 @@<br> int targetfd;<br> char *output = NULL;<br> uint32_t rom_size = CONFIG_ROM_SIZE;<br>+ uint32_t dir_location = 0;<br>+ uint32_t romsig_offset;<br> uint32_t rom_base_address;<br> <br> while (1) {<br>@@ -624,6 +628,15 @@<br> retval = 1;<br> }<br> break;<br>+ case 'l':<br>+ dir_location = (uint32_t)strtoul(optarg, &tmp, 16);<br>+ if (*tmp != '\0') {<br>+ printf("Error: Directory Location specified"<br>+ " incorrectly (%s)\n\n", optarg);<br>+ retval = 1;<br>+ }<br>+ break;<br>+<br> case 'h':<br> usage();<br> return 0;<br>@@ -662,13 +675,40 @@<br> printf(" AMDFWTOOL Using ROM size of %dKB\n", rom_size / 1024);<br> <br> rom_base_address = 0xFFFFFFFF - rom_size + 1;<br>+ if ((dir_location) && (dir_location < rom_base_address)) {<br>+ printf("Error: Directory location outside of ROM.\n\n");<br>+ return 1;<br>+ }<br>+<br>+ switch (dir_location) {<br>+ case 0: /* Fall through */<br>+ case 0xFFFA0000: /* Fall through */<br>+ case 0xFFF20000: /* Fall through */<br>+ case 0xFFE20000: /* Fall through */<br>+ case 0xFFC20000: /* Fall through */<br>+ case 0xFF820000: /* Fall through */<br>+ case 0xFF020000: /* Fall through */<br>+ break;<br>+ default:<br>+ printf("Error: Invalid Directory location.\n");<br>+ printf(" Valid locations are 0xFFFA0000, 0xFFF20000,\n");<br>+ printf(" 0xFFE20000, 0xFFC20000, 0xFF820000, 0xFF020000\n");<br>+ return 1;<br>+ }<br>+<br> rom = malloc(rom_size);<br> if (!rom)<br> return 1;<br> memset(rom, 0xFF, rom_size);<br> <br>- current = AMD_ROMSIG_OFFSET;<br>- amd_romsig = (void *)(rom + AMD_ROMSIG_OFFSET);<br>+ if (dir_location)<br>+ romsig_offset = current = dir_location - rom_base_address;<br>+ else<br>+ romsig_offset = current = AMD_ROMSIG_OFFSET;<br>+ printf(" AMDFWTOOL Using firmware directory location of %08lx\n",<br>+ (unsigned long)rom_base_address + current);<br>+<br>+ amd_romsig = (void *)(rom + romsig_offset);<br> amd_romsig[0] = 0x55AA55AA; /* romsig */<br> amd_romsig[1] = 0;<br> amd_romsig[2] = 0;<br>@@ -731,7 +771,7 @@<br> <br> targetfd = open(output, O_RDWR | O_CREAT | O_TRUNC, 0666);<br> if (targetfd >= 0) {<br>- write(targetfd, amd_romsig, current - AMD_ROMSIG_OFFSET);<br>+ write(targetfd, amd_romsig, current - romsig_offset);<br> close(targetfd);<br> } else {<br> printf("Error: could not open file: %s\n", output);<br></pre><p>To view, visit <a href="https://review.coreboot.org/21865">change 21865</a>. To unsubscribe, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/21865"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ief32e5e37d56088946b623d305c6e93bfd6abeaf </div>
<div style="display:none"> Gerrit-Change-Number: 21865 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Martin Roth <martinroth@google.com> </div>