amdfwtool: Use relative address for EFS gen2
The second generation EFS (offset 0x24[0]=0) uses "binary relative" offsets and not "x86 physical MMIO address" like gen1. Chips like Cezanne can run in both cases, so no problem comes up so far. BUG=b:188754219 Test=Majolica (Cezanne) Change-Id: I3a54f8ce5004915a7fa407dcd7d59a64d88aad0d Signed-off-by: Zheng Bao <fishbaozi@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/55211 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin Roth <martinroth@google.com> Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
This commit is contained in:
parent
595b940ef0
commit
0fc87e31e0
|
@ -343,11 +343,12 @@ amd_bios_entry amd_bios_table[] = {
|
||||||
typedef struct _context {
|
typedef struct _context {
|
||||||
char *rom; /* target buffer, size of flash device */
|
char *rom; /* target buffer, size of flash device */
|
||||||
uint32_t rom_size; /* size of flash device */
|
uint32_t rom_size; /* size of flash device */
|
||||||
|
uint32_t abs_address; /* produce absolute or relative address */
|
||||||
uint32_t current; /* pointer within flash & proxy buffer */
|
uint32_t current; /* pointer within flash & proxy buffer */
|
||||||
} context;
|
} context;
|
||||||
|
|
||||||
#define RUN_BASE(ctx) (0xFFFFFFFF - (ctx).rom_size + 1)
|
#define RUN_BASE(ctx) (0xFFFFFFFF - (ctx).rom_size + 1)
|
||||||
#define RUN_OFFSET(ctx, offset) (RUN_BASE(ctx) + (offset))
|
#define RUN_OFFSET(ctx, offset) ((ctx).abs_address ? RUN_BASE(ctx) + (offset) : (offset))
|
||||||
#define RUN_CURRENT(ctx) RUN_OFFSET((ctx), (ctx).current)
|
#define RUN_CURRENT(ctx) RUN_OFFSET((ctx), (ctx).current)
|
||||||
#define BUFF_OFFSET(ctx, offset) ((void *)((ctx).rom + (offset)))
|
#define BUFF_OFFSET(ctx, offset) ((void *)((ctx).rom + (offset)))
|
||||||
#define BUFF_CURRENT(ctx) BUFF_OFFSET((ctx), (ctx).current)
|
#define BUFF_CURRENT(ctx) BUFF_OFFSET((ctx), (ctx).current)
|
||||||
|
@ -1536,8 +1537,6 @@ int main(int argc, char **argv)
|
||||||
romsig_offset = ctx.current = dir_location - rom_base_address;
|
romsig_offset = ctx.current = dir_location - rom_base_address;
|
||||||
else
|
else
|
||||||
romsig_offset = ctx.current = AMD_ROMSIG_OFFSET;
|
romsig_offset = ctx.current = AMD_ROMSIG_OFFSET;
|
||||||
printf(" AMDFWTOOL Using firmware directory location of 0x%08x\n",
|
|
||||||
RUN_CURRENT(ctx));
|
|
||||||
|
|
||||||
amd_romsig = BUFF_OFFSET(ctx, romsig_offset);
|
amd_romsig = BUFF_OFFSET(ctx, romsig_offset);
|
||||||
amd_romsig->signature = EMBEDDED_FW_SIGNATURE;
|
amd_romsig->signature = EMBEDDED_FW_SIGNATURE;
|
||||||
|
@ -1556,6 +1555,13 @@ int main(int argc, char **argv)
|
||||||
fprintf(stderr, "WARNING: No SOC name specified.\n");
|
fprintf(stderr, "WARNING: No SOC name specified.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (amd_romsig->efs_gen.gen == EFS_SECOND_GEN)
|
||||||
|
ctx.abs_address = 0;
|
||||||
|
else
|
||||||
|
ctx.abs_address = 1;
|
||||||
|
printf(" AMDFWTOOL Using firmware directory location of %s address: 0x%08x\n",
|
||||||
|
ctx.abs_address == 1 ? "absolute" : "relative", RUN_CURRENT(ctx));
|
||||||
|
|
||||||
integrate_firmwares(&ctx, amd_romsig, amd_fw_table);
|
integrate_firmwares(&ctx, amd_romsig, amd_fw_table);
|
||||||
|
|
||||||
ctx.current = ALIGN(ctx.current, 0x10000U); /* TODO: is it necessary? */
|
ctx.current = ALIGN(ctx.current, 0x10000U); /* TODO: is it necessary? */
|
||||||
|
|
Loading…
Reference in New Issue