summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorZheng Bao <fishbaozi@gmail.com>2022-11-21 21:34:45 +0800
committerFred Reitberger <reitbergerfred@gmail.com>2023-02-09 13:04:08 +0000
commit4e8fb3503cc1791d3812d5bd5792d4ff44ad10d5 (patch)
tree1ff627c5af08c5d74b33c067a85f4139842e4609 /util
parent3b3bb7cd627379963219bad12163430f9af94007 (diff)
downloadcoreboot-4e8fb3503cc1791d3812d5bd5792d4ff44ad10d5.tar.gz
coreboot-4e8fb3503cc1791d3812d5bd5792d4ff44ad10d5.tar.bz2
coreboot-4e8fb3503cc1791d3812d5bd5792d4ff44ad10d5.zip
amdfwtool: Allow the location to be a relative address
When the BIOS size is more than 32M, the physical address of EFS header will be complicated, like 0xfe020000 or 0xfc020000. So we make it simpler to allow to use relative address. This CL works with https://review.coreboot.org/c/coreboot/+/69852 TEST=Result image is binary same on amd/birman amd/majolica amd/gardina amd/mandolin Change-Id: I4308ec9ea05a87329aba0b409508c79ebf42325c Signed-off-by: Zheng Bao <fishbaozi@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/69856 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Fred Reitberger <reitbergerfred@gmail.com>
Diffstat (limited to 'util')
-rw-r--r--util/amdfwtool/amdfwtool.c48
1 files changed, 38 insertions, 10 deletions
diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c
index 9b250b52b717..e1e689dddbeb 100644
--- a/util/amdfwtool/amdfwtool.c
+++ b/util/amdfwtool/amdfwtool.c
@@ -2478,6 +2478,10 @@ int main(int argc, char **argv)
fprintf(stderr, " Require safe spacing of 256 bytes\n");
return 1;
}
+ if (efs_location & 0xFF000000)
+ efs_location = efs_location - rom_base_address;
+ if (body_location & 0xFF000000)
+ body_location = body_location - rom_base_address;
if (any_location) {
if ((body_location & 0x3f) || (efs_location & 0x3f)) {
@@ -2486,19 +2490,43 @@ int main(int argc, char **argv)
return 1;
}
} else {
+ /* efs_location is relative address now. */
switch (efs_location) {
case 0:
- case 0xFFFA0000:
- case 0xFFF20000:
- case 0xFFE20000:
- case 0xFFC20000:
- case 0xFF820000:
- case 0xFF020000:
+ case 0xFA0000:
+ case 0xF20000:
+ case 0xE20000:
+ case 0xC20000:
+ case 0x820000:
+ case 0x020000:
+ break;
+ case 0x7A0000:
+ case 0x720000:
+ case 0x620000:
+ case 0x420000:
+ /* Special cases for 8M. */
+ if (ctx.rom_size != 0x800000) {
+ fprintf(stderr, "Error: Invalid Directory location.\n");
+ fprintf(stderr, "%x is only for 8M image size.", efs_location);
+ return 1;
+ }
+ break;
+ case 0x3A0000:
+ case 0x320000:
+ case 0x220000:
+ /* Special cases for 4M. */
+ if (ctx.rom_size != 0x400000) {
+ fprintf(stderr, "Error: Invalid Directory location.\n");
+ fprintf(stderr, "%x is only for 4M image size.", efs_location);
+ return 1;
+ }
break;
default:
fprintf(stderr, "Error: Invalid Directory location.\n");
fprintf(stderr, " Valid locations are 0xFFFA0000, 0xFFF20000,\n");
fprintf(stderr, " 0xFFE20000, 0xFFC20000, 0xFF820000, 0xFF020000\n");
+ fprintf(stderr, " 0xFA0000, 0xF20000, 0xE20000, 0xC20000,\n");
+ fprintf(stderr, " 0x820000, 0x020000\n");
return 1;
}
}
@@ -2511,10 +2539,10 @@ int main(int argc, char **argv)
if (efs_location) {
if (efs_location != body_location) {
- romsig_offset = efs_location - rom_base_address;
- ctx.current = body_location - rom_base_address;
+ romsig_offset = efs_location;
+ ctx.current = body_location;
} else {
- romsig_offset = efs_location - rom_base_address;
+ romsig_offset = efs_location;
ctx.current = romsig_offset + sizeof(embedded_firmware);
}
} else {
@@ -2671,7 +2699,7 @@ int main(int argc, char **argv)
targetfd = open(output, O_RDWR | O_CREAT | O_TRUNC, 0666);
if (targetfd >= 0) {
ssize_t bytes;
- uint32_t offset = body_location ? body_location - rom_base_address : AMD_ROMSIG_OFFSET;
+ uint32_t offset = body_location ? body_location : AMD_ROMSIG_OFFSET;
bytes = write(targetfd, BUFF_OFFSET(ctx, offset), ctx.current - offset);
if (bytes != ctx.current - offset) {