amdfwtool: Change .rom.efs to .rom and .rom to .rom.body
To support 32M flash, the non-vboot also need to split amdfw. The amdfw.rom is the default filename added to CBFS. Keep the default filename and then we don't have to change all the CBFS definition. This is one of series of patches to support 32/64M flash. BUG=b:255374782 Change-Id: Id77b11422d4549cf57a1cd8980c7a9cf3597d1bc Signed-off-by: Zheng Bao <fishbaozi@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/72702 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Fred Reitberger <reitbergerfred@gmail.com>
This commit is contained in:
parent
0b101fc338
commit
69ea83c3c5
|
@ -171,8 +171,8 @@ SIGNED_AMDFW_A_POSITION=$(call int-subtract, \
|
|||
SIGNED_AMDFW_B_POSITION=$(call int-subtract, \
|
||||
$(shell awk '$$2 == "FMAP_SECTION_SIGNED_AMDFW_B_START" {print $$3}' $(obj)/fmap_config.h) \
|
||||
$(shell awk '$$2 == "FMAP_SECTION_FLASH_START" {print $$3}' $(obj)/fmap_config.h))
|
||||
SIGNED_AMDFW_A_FILE=$(obj)/amdfw_a.rom.signed
|
||||
SIGNED_AMDFW_B_FILE=$(obj)/amdfw_b.rom.signed
|
||||
SIGNED_AMDFW_A_FILE=$(obj)/amdfw_a.rom.body.signed
|
||||
SIGNED_AMDFW_B_FILE=$(obj)/amdfw_b.rom.body.signed
|
||||
endif # CONFIG_SEPARATE_SIGNED_PSPFW
|
||||
|
||||
# Helper function to return a value with given bit set
|
||||
|
@ -306,41 +306,41 @@ $(obj)/amdfw_b.rom: $(obj)/amdfw.rom
|
|||
--anywhere \
|
||||
--output $@
|
||||
|
||||
$(obj)/amdfw_a.rom.efs: $(obj)/amdfw_a.rom
|
||||
$(obj)/amdfw_b.rom.efs: $(obj)/amdfw_b.rom
|
||||
$(obj)/amdfw_a.rom.body: $(obj)/amdfw_a.rom
|
||||
$(obj)/amdfw_b.rom.body: $(obj)/amdfw_b.rom
|
||||
|
||||
ifeq ($(CONFIG_VBOOT_SLOTS_RW_A)$(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),yy)
|
||||
cbfs-files-y += apu/amdfw_a
|
||||
apu/amdfw_a-file := $(obj)/amdfw_a.rom.efs
|
||||
apu/amdfw_a-file := $(obj)/amdfw_a.rom
|
||||
apu/amdfw_a-position := $(AMD_FW_AB_POSITION)
|
||||
apu/amdfw_a-type := raw
|
||||
|
||||
cbfs-files-y += apu/amdfw_a_body
|
||||
apu/amdfw_a_body-file := $(obj)/amdfw_a.rom
|
||||
apu/amdfw_a_body-file := $(obj)/amdfw_a.rom.body
|
||||
apu/amdfw_a_body-position := $(call int-add, $(AMD_FW_AB_POSITION) $(MENDOCINO_FW_BODY_OFFSET))
|
||||
apu/amdfw_a_body-type := raw
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_VBOOT_SLOTS_RW_AB)$(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),yy)
|
||||
cbfs-files-y += apu/amdfw_b
|
||||
apu/amdfw_b-file := $(obj)/amdfw_b.rom.efs
|
||||
apu/amdfw_b-file := $(obj)/amdfw_b.rom
|
||||
apu/amdfw_b-position := $(AMD_FW_AB_POSITION)
|
||||
apu/amdfw_b-type := raw
|
||||
|
||||
cbfs-files-y += apu/amdfw_b_body
|
||||
apu/amdfw_b_body-file := $(obj)/amdfw_b.rom
|
||||
apu/amdfw_b_body-file := $(obj)/amdfw_b.rom.body
|
||||
apu/amdfw_b_body-position := $(call int-add, $(AMD_FW_AB_POSITION) $(MENDOCINO_FW_BODY_OFFSET))
|
||||
apu/amdfw_b_body-type := raw
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SEPARATE_SIGNED_PSPFW)$(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),yy)
|
||||
build_complete:: $(obj)/amdfw_a.rom $(obj)/amdfw_b.rom
|
||||
build_complete:: $(obj)/amdfw_a.rom.body $(obj)/amdfw_b.rom.body
|
||||
@printf " Adding Signed ROM and HASH\n"
|
||||
$(CBFSTOOL) $(obj)/coreboot.rom write -u -r SIGNED_AMDFW_A -i 0 -f $(obj)/amdfw_a.rom.signed
|
||||
$(CBFSTOOL) $(obj)/coreboot.rom write -u -r SIGNED_AMDFW_B -i 0 -f $(obj)/amdfw_b.rom.signed
|
||||
$(CBFSTOOL) $(obj)/coreboot.rom add -r FW_MAIN_A -f $(obj)/amdfw_a.rom.signed.hash \
|
||||
$(CBFSTOOL) $(obj)/coreboot.rom write -u -r SIGNED_AMDFW_A -i 0 -f $(obj)/amdfw_a.rom.body.signed
|
||||
$(CBFSTOOL) $(obj)/coreboot.rom write -u -r SIGNED_AMDFW_B -i 0 -f $(obj)/amdfw_b.rom.body.signed
|
||||
$(CBFSTOOL) $(obj)/coreboot.rom add -r FW_MAIN_A -f $(obj)/amdfw_a.rom.body.signed.hash \
|
||||
-n apu/amdfw_a_hash -t raw
|
||||
$(CBFSTOOL) $(obj)/coreboot.rom add -r FW_MAIN_B -f $(obj)/amdfw_b.rom.signed.hash \
|
||||
$(CBFSTOOL) $(obj)/coreboot.rom add -r FW_MAIN_B -f $(obj)/amdfw_b.rom.body.signed.hash \
|
||||
-n apu/amdfw_b_hash -t raw
|
||||
endif
|
||||
|
||||
|
|
|
@ -111,6 +111,7 @@ enum signature_id {
|
|||
#define HASH_FILE_SUFFIX ".hash"
|
||||
#define EFS_FILE_SUFFIX ".efs"
|
||||
#define TMP_FILE_SUFFIX ".tmp"
|
||||
#define BODY_FILE_SUFFIX ".body"
|
||||
|
||||
/*
|
||||
* Beginning with Family 15h Models 70h-7F, a.k.a Stoney Ridge, the PSP
|
||||
|
@ -2043,53 +2044,53 @@ static int set_efs_table(uint8_t soc_id, amd_cb_config *cb_config,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t write_efs(char *output, embedded_firmware *amd_romsig, context *ctx)
|
||||
static ssize_t write_body(char *output, void *body_offset, ssize_t body_size, context *ctx)
|
||||
{
|
||||
char efs_name[PATH_MAX], efs_tmp_name[PATH_MAX];
|
||||
char body_name[PATH_MAX], body_tmp_name[PATH_MAX];
|
||||
int ret;
|
||||
int fd;
|
||||
ssize_t bytes = -1;
|
||||
|
||||
/* Create a tmp file and rename it at the end so that make does not get confused
|
||||
if amdfwtool is killed for some unexpected reasons. */
|
||||
ret = snprintf(efs_tmp_name, sizeof(efs_tmp_name), "%s%s%s",
|
||||
output, EFS_FILE_SUFFIX, TMP_FILE_SUFFIX);
|
||||
ret = snprintf(body_tmp_name, sizeof(body_tmp_name), "%s%s%s",
|
||||
output, BODY_FILE_SUFFIX, TMP_FILE_SUFFIX);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error %s forming EFS tmp file name: %d\n",
|
||||
fprintf(stderr, "Error %s forming BODY tmp file name: %d\n",
|
||||
strerror(errno), ret);
|
||||
amdfwtool_cleanup(ctx);
|
||||
exit(1);
|
||||
} else if ((unsigned int)ret >= sizeof(efs_tmp_name)) {
|
||||
fprintf(stderr, "EFS File name %d > %zu\n", ret, sizeof(efs_tmp_name));
|
||||
} else if ((unsigned int)ret >= sizeof(body_tmp_name)) {
|
||||
fprintf(stderr, "BODY File name %d > %zu\n", ret, sizeof(body_tmp_name));
|
||||
amdfwtool_cleanup(ctx);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fd = open(efs_tmp_name, O_RDWR | O_CREAT | O_TRUNC, 0666);
|
||||
fd = open(body_tmp_name, O_RDWR | O_CREAT | O_TRUNC, 0666);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "Error: Opening %s file: %s\n", efs_tmp_name, strerror(errno));
|
||||
fprintf(stderr, "Error: Opening %s file: %s\n", body_tmp_name, strerror(errno));
|
||||
amdfwtool_cleanup(ctx);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
bytes = write_from_buf_to_file(fd, amd_romsig, sizeof(*amd_romsig));
|
||||
if (bytes != sizeof(*amd_romsig)) {
|
||||
fprintf(stderr, "Error: Writing to file %s failed\n", efs_tmp_name);
|
||||
bytes = write_from_buf_to_file(fd, body_offset, body_size);
|
||||
if (bytes != body_size) {
|
||||
fprintf(stderr, "Error: Writing to file %s failed\n", body_tmp_name);
|
||||
amdfwtool_cleanup(ctx);
|
||||
exit(1);
|
||||
}
|
||||
close(fd);
|
||||
|
||||
/* Rename the tmp file */
|
||||
ret = snprintf(efs_name, sizeof(efs_name), "%s%s", output, EFS_FILE_SUFFIX);
|
||||
ret = snprintf(body_name, sizeof(body_name), "%s%s", output, BODY_FILE_SUFFIX);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Error %s forming EFS file name: %d\n", strerror(errno), ret);
|
||||
fprintf(stderr, "Error %s forming BODY file name: %d\n", strerror(errno), ret);
|
||||
amdfwtool_cleanup(ctx);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (rename(efs_tmp_name, efs_name)) {
|
||||
fprintf(stderr, "Error: renaming file %s to %s\n", efs_tmp_name, efs_name);
|
||||
if (rename(body_tmp_name, body_name)) {
|
||||
fprintf(stderr, "Error: renaming file %s to %s\n", body_tmp_name, body_name);
|
||||
amdfwtool_cleanup(ctx);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -2666,11 +2667,13 @@ 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 : AMD_ROMSIG_OFFSET;
|
||||
uint32_t offset = efs_location;
|
||||
uint32_t bytes = efs_location == body_location ?
|
||||
ctx.current - offset : sizeof(*amd_romsig);
|
||||
uint32_t ret_bytes;
|
||||
|
||||
bytes = write(targetfd, BUFF_OFFSET(ctx, offset), ctx.current - offset);
|
||||
if (bytes != ctx.current - offset) {
|
||||
ret_bytes = write(targetfd, BUFF_OFFSET(ctx, offset), bytes);
|
||||
if (bytes != ret_bytes) {
|
||||
fprintf(stderr, "Error: Writing to file %s failed\n", output);
|
||||
retval = 1;
|
||||
}
|
||||
|
@ -2683,9 +2686,10 @@ int main(int argc, char **argv)
|
|||
if (efs_location != body_location) {
|
||||
ssize_t bytes;
|
||||
|
||||
bytes = write_efs(output, amd_romsig, &ctx);
|
||||
if (bytes != sizeof(*amd_romsig)) {
|
||||
fprintf(stderr, "Error: Writing EFS\n");
|
||||
bytes = write_body(output, BUFF_OFFSET(ctx, body_location),
|
||||
ctx.current - body_location, &ctx);
|
||||
if (bytes != ctx.current - body_location) {
|
||||
fprintf(stderr, "Error: Writing body\n");
|
||||
retval = 1;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue