Bao Zheng would like Zheng Bao to review this change.

View Change

amdfwtool: Use *number in config file as NVRAM entry

Add the entry like
XXXX_FW_TYPE_STRING *0xXXXXX
to config file. Then the required size of space will
be allocated related to the firmware type.

Change-Id: I98c94b4087f8a174f7d5753a30695a10f1b796ae
Signed-off-by: Zheng Bao <fishbaozi@gmail.com>
---
M src/soc/amd/picasso/Makefile.inc
M src/soc/amd/stoneyridge/Makefile.inc
M src/southbridge/amd/pi/hudson/Makefile.inc
M util/amdfwtool/amdfwtool.c
M util/amdfwtool/amdfwtool.h
M util/amdfwtool/data_parse.c
6 files changed, 35 insertions(+), 13 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/15/49015/1
diff --git a/src/soc/amd/picasso/Makefile.inc b/src/soc/amd/picasso/Makefile.inc
index a0f3ec4..08d2817 100644
--- a/src/soc/amd/picasso/Makefile.inc
+++ b/src/soc/amd/picasso/Makefile.inc
@@ -213,7 +213,7 @@

# Add all the files listed in the config file
POUND_SIGN=$(call strip_quotes, "\#")
-DEP_FILES= $(patsubst %,$(FIRMWARE_LOCATION)/%, $(shell sed -e /^$(POUND_SIGN)/d -e /^FIRMWARE_LOCATION/d $(CONFIG_AMDFW_CONFIG_FILE) | awk '{print $$2}' ))
+DEP_FILES= $(patsubst %,$(FIRMWARE_LOCATION)/%, $(shell sed -e /^$(POUND_SIGN)/d -e /*/d -e /^FIRMWARE_LOCATION/d $(CONFIG_AMDFW_CONFIG_FILE) | awk '{print $$2}' ))

AMDFW_COMMON_ARGS=$(OPT_PSP_APCB_FILES) \
$(OPT_PSP_APCB_FILES_BK) \
diff --git a/src/soc/amd/stoneyridge/Makefile.inc b/src/soc/amd/stoneyridge/Makefile.inc
index 969f512..f7ef699 100644
--- a/src/soc/amd/stoneyridge/Makefile.inc
+++ b/src/soc/amd/stoneyridge/Makefile.inc
@@ -141,7 +141,7 @@

# Add all the files listed in the config file
POUND_SIGN=$(call strip_quotes, "\#")
-DEP_FILES= $(patsubst %,$(FIRMWARE_LOCATION)/%, $(shell sed -e /^$(POUND_SIGN)/d -e /^FIRMWARE_LOCATION/d $(CONFIG_AMDFW_CONFIG_FILE) | awk '{print $$2}' ))
+DEP_FILES= $(patsubst %,$(FIRMWARE_LOCATION)/%, $(shell sed -e /^$(POUND_SIGN)/d -e /*/d -e /^FIRMWARE_LOCATION/d $(CONFIG_AMDFW_CONFIG_FILE) | awk '{print $$2}' ))

$(obj)/amdfw.rom: $(call strip_quotes, $(CONFIG_STONEYRIDGE_XHCI_FWM_FILE)) \
$(call strip_quotes, $(CONFIG_STONEYRIDGE_GEC_FWM_FILE)) \
diff --git a/src/southbridge/amd/pi/hudson/Makefile.inc b/src/southbridge/amd/pi/hudson/Makefile.inc
index 215a5a1..3d96823 100644
--- a/src/southbridge/amd/pi/hudson/Makefile.inc
+++ b/src/southbridge/amd/pi/hudson/Makefile.inc
@@ -110,7 +110,7 @@

# Add all the files listed in the config file
POUND_SIGN=$(call strip_quotes, "\#")
-DEP_FILES= $(patsubst %,$(FIRMWARE_LOCATION)/%, $(shell sed -e /^$(POUND_SIGN)/d -e /^FIRMWARE_LOCATION/d $(CONFIG_AMDFW_CONFIG_FILE) | awk '{print $$2}' ))
+DEP_FILES= $(patsubst %,$(FIRMWARE_LOCATION)/%, $(shell sed -e /^$(POUND_SIGN)/d -e /*/d -e /^FIRMWARE_LOCATION/d $(CONFIG_AMDFW_CONFIG_FILE) | awk '{print $$2}' ))

$(obj)/amdfw.rom: $(call strip_quotes, $(CONFIG_HUDSON_XHCI_FWM_FILE)) \
$(call strip_quotes, $(CONFIG_HUDSON_IMC_FWM_FILE)) \
diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c
index f167e5e..b6c9c8d 100644
--- a/util/amdfwtool/amdfwtool.c
+++ b/util/amdfwtool/amdfwtool.c
@@ -775,6 +775,13 @@
ctx->current = ALIGN(ctx->current + bytes,
BLOB_ALIGNMENT);
count++;
+ } else if (fw_table[i].blank_size != 0) {
+ pspdir->entries[count].type = fw_table[i].type;
+ pspdir->entries[count].subprog = fw_table[i].subprog;
+ pspdir->entries[count].rsvd = 0;
+ pspdir->entries[count].size = (uint32_t)fw_table[i].blank_size;
+ pspdir->entries[count].addr = RUN_CURRENT(*ctx);
+ count++;
} else {
/* This APU doesn't have this firmware. */
}
@@ -1018,11 +1025,15 @@
fw_table[i].type == AMD_BIOS_APCB_BK)
ctx->current = ALIGN(
ctx->current, ERASE_ALIGNMENT);
- bytes = copy_blob(BUFF_CURRENT(*ctx),
- fw_table[i].filename, BUFF_ROOM(*ctx));
- if (bytes <= 0) {
- free(ctx->rom);
- exit(1);
+ if (fw_table[i].filename != NULL) {
+ bytes = copy_blob(BUFF_CURRENT(*ctx),
+ fw_table[i].filename, BUFF_ROOM(*ctx));
+ if (bytes <= 0) {
+ free(ctx->rom);
+ exit(1);
+ }
+ } else if (fw_table[i].blank_size != 0){
+ bytes = fw_table[i].blank_size;
}

biosdir->entries[count].size = (uint32_t)bytes;
diff --git a/util/amdfwtool/amdfwtool.h b/util/amdfwtool/amdfwtool.h
index 6ae4675..beaa360 100644
--- a/util/amdfwtool/amdfwtool.h
+++ b/util/amdfwtool/amdfwtool.h
@@ -109,6 +109,7 @@
uint8_t subprog;
int level;
uint64_t other;
+ uint32_t blank_size;
} amd_fw_entry;

typedef struct _amd_cb_config {
diff --git a/util/amdfwtool/data_parse.c b/util/amdfwtool/data_parse.c
index 017c689..de31242 100644
--- a/util/amdfwtool/data_parse.c
+++ b/util/amdfwtool/data_parse.c
@@ -254,7 +254,10 @@
while (psp_tableptr->type != AMD_FW_INVALID) {
/* instance are not used in PSP table */
if (psp_tableptr->type == fw_type && psp_tableptr->subprog == subprog) {
- psp_tableptr->filename = filename;
+ if (filename[0] == '*')
+ psp_tableptr->blank_size = strtoull(&filename[1], NULL, 16);
+ else
+ psp_tableptr->filename = filename;
break;
}
psp_tableptr++;
@@ -330,7 +333,10 @@
if (bhd_tableptr->type == fw_type &&
bhd_tableptr->subpr == subprog &&
bhd_tableptr->inst == instance) {
- bhd_tableptr->filename = filename;
+ if (filename[0] == '*')
+ bhd_tableptr->blank_size = strtoull(&filename[1], NULL, 16);
+ else
+ bhd_tableptr->filename = filename;
break;
}
bhd_tableptr++;
@@ -440,9 +446,13 @@
continue;
} else {
path_filename = malloc(MAX_LINE_SIZE);
- strcpy(path_filename, dir);
- strcat(path_filename, "/");
- strcat(path_filename, &(oneline[match[2].rm_so]));
+ if (oneline[match[2].rm_so] == '*') {
+ strcpy(path_filename, &(oneline[match[2].rm_so]));
+ } else {
+ strcpy(path_filename, dir);
+ strcat(path_filename, "/");
+ strcat(path_filename, &(oneline[match[2].rm_so]));
+ }

if (find_register_fw_filename_psp_dir(
&(oneline[match[1].rm_so]),

To view, visit change 49015. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I98c94b4087f8a174f7d5753a30695a10f1b796ae
Gerrit-Change-Number: 49015
Gerrit-PatchSet: 1
Gerrit-Owner: Bao Zheng <fishbaozi@gmail.com>
Gerrit-Reviewer: Felix Held <felix-coreboot@felixheld.de>
Gerrit-Reviewer: Jason Glenesk <jason.glenesk@gmail.com>
Gerrit-Reviewer: Marshall Dawson <marshalldawson3rd@gmail.com>
Gerrit-Reviewer: Martin Roth <martinroth@google.com>
Gerrit-Reviewer: Patrick Georgi <pgeorgi@google.com>
Gerrit-Reviewer: Zheng Bao
Gerrit-MessageType: newchange