Michael Niewöhner has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/35281 )
Change subject: Build fmap from intel descriptor ......................................................................
Build fmap from intel descriptor
Currently coreboot creates a non-working image when ifd, me and/or other reagions are provided because the bios region offset calculation does not take them into account.
When an ifd is provided we can build the fmap by extracting the offsets from it to create working images for such systems.
Signed-off-by: Michael Niewöhner foss@mniewoehner.de Change-Id: Ief153b08788f1f0484e83418e8308261301ebc44 --- M Makefile.inc M util/cbfstool/default-x86.fmd 2 files changed, 72 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/81/35281/1
diff --git a/Makefile.inc b/Makefile.inc index 3c3088d..57f4a59 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -151,6 +151,7 @@ tolower=$(shell echo '$1' | tr '[:upper:]' '[:lower:]') toupper=$(shell echo '$1' | tr '[:lower:]' '[:upper:]') ws_to_under=$(shell echo '$1' | tr ' \t' '_') +cut = $(word $3,$(subst $2, ,$1))
####################################################################### # Helper functions for ramstage postprocess @@ -869,12 +870,75 @@ # entire flash FMAP_ROM_ADDR := $(call int-subtract, 0x100000000 $(CONFIG_ROM_SIZE)) FMAP_ROM_SIZE := $(CONFIG_ROM_SIZE) + +# +# Get regions from ifd +# +FMAP_IFD_ENTRY := +FMAP_ME_ENTRY := +FMAP_EC_ENTRY := +FMAP_GBE_ENTRY := +ifeq ($(CONFIG_HAVE_IFD_BIN),y) + +# IFD region +ifneq ($(CONFIG_IFD_BIN_PATH),) +FMAP_IFD_REGION := $(shell $(IFDTOOL) -f /dev/stdout $(CONFIG_IFD_BIN_PATH) | grep 'fd$$' | sed 's/ .+$$//') +FMAP_IFD_BASE := 0x$(call cut,$(FMAP_IFD_REGION),:,1) +FMAP_IFD_END := 0x$(call cut,$(FMAP_IFD_REGION),:,2) +FMAP_IFD_SIZE := $(call int-subtract, $(call int-add, $(FMAP_IFD_END) 1) $(FMAP_IFD_BASE)) +FMAP_IFD_ENTRY := IFD@$(FMAP_IFD_BASE) $(FMAP_IFD_SIZE) +endif + +# ME region +ifeq ($(CONFIG_HAVE_ME_BIN),y) +ifneq ($(CONFIG_ME_BIN_PATH),) +FMAP_ME_REGION := $(shell $(IFDTOOL) -f /dev/stdout $(CONFIG_IFD_BIN_PATH) | grep 'me$$' | sed 's/ .+$$//') +FMAP_ME_BASE := 0x$(call cut,$(FMAP_ME_REGION),:,1) +FMAP_ME_END := 0x$(call cut,$(FMAP_ME_REGION),:,2) +FMAP_ME_SIZE := $(call int-subtract, $(call int-add, $(FMAP_ME_END) 1) $(FMAP_ME_BASE)) +FMAP_ME_ENTRY := ME@$(FMAP_ME_BASE) $(FMAP_ME_SIZE) +endif # ifneq ($(CONFIG_ME_BIN_PATH),) +endif # ifeq ($(CONFIG_HAVE_ME_BIN),y) + +# EC region +ifeq ($(CONFIG_HAVE_EC_BIN),y) +ifneq ($(CONFIG_EC_BIN_PATH),) +FMAP_EC_REGION := $(shell $(IFDTOOL) -f /dev/stdout $(CONFIG_IFD_BIN_PATH) | grep 'ec$$' | sed 's/ .+$$//') +FMAP_EC_BASE := 0x$(call cut,$(FMAP_EC_REGION),:,1) +FMAP_EC_END := 0x$(call cut,$(FMAP_EC_REGION),:,2) +FMAP_EC_SIZE := $(call int-subtract, $(call int-add, $(FMAP_EC_END) 1) $(FMAP_EC_BASE)) +FMAP_EC_ENTRY := EC@$(FMAP_EC_BASE) $(FMAP_EC_SIZE) +endif # ifneq ($(CONFIG_EC_BIN_PATH),) +endif # ifeq ($(CONFIG_HAVE_EC_BIN),y) + +# GBE region +ifeq ($(CONFIG_HAVE_GBE_BIN),y) +ifneq ($(CONFIG_GBE_BIN_PATH),) +FMAP_GBE_REGION := $(shell $(IFDTOOL) -f /dev/stdout $(CONFIG_IFD_BIN_PATH) | grep 'gbe$$' | sed 's/ .+$$//') +FMAP_GBE_BASE := 0x$(call cut,$(FMAP_GBE_REGION),:,1) +FMAP_GBE_END := 0x$(call cut,$(FMAP_GBE_REGION),:,2) +FMAP_GBE_SIZE := $(call int-subtract, $(call int-add, $(FMAP_GBE_END) 1) $(FMAP_GBE_BASE)) +FMAP_GBE_ENTRY := GBE@$(FMAP_GBE_BASE) $(FMAP_GBE_SIZE) +endif # ifneq ($(CONFIG_GBE_BIN_PATH),) +endif # ifeq ($(CONFIG_HAVE_GBE_BIN),y) + +# BIOS region +FMAP_BIOS_REGION := $(shell $(IFDTOOL) -f /dev/stdout $(CONFIG_IFD_BIN_PATH) | grep 'bios$$' | sed 's/ .+$$//') +FMAP_BIOS_BASE := 0x$(call cut,$(FMAP_BIOS_REGION),:,1) +FMAP_BIOS_END := 0x$(call cut,$(FMAP_BIOS_REGION),:,2) +FMAP_BIOS_SIZE := $(call int-subtract, $(call int-add, $(FMAP_BIOS_END) 1) $(FMAP_BIOS_BASE)) + +else # ifeq ($(CONFIG_HAVE_IFD_BIN),y) + +# BIOS region # entire "BIOS" region (everything directly of concern to the host system) # relative to ROM_BASE FMAP_BIOS_BASE := $(call int-align, $(call int-subtract, $(CONFIG_ROM_SIZE) $(CONFIG_CBFS_SIZE)), 0x10000) FMAP_BIOS_SIZE := $(call int-align-down, $(shell echo $(CONFIG_CBFS_SIZE) | tr A-F a-f), 0x10000) # position and size of flashmap, relative to BIOS_BASE
+endif # ifeq ($(CONFIG_HAVE_IFD_BIN),y) + # # X86 CONSOLE FMAP region # @@ -992,6 +1056,10 @@ $(obj)/fmap.fmd: $(top)/Makefile.inc $(DEFAULT_FLASHMAP) $(obj)/config.h sed -e "s,##ROM_BASE##,$(FMAP_ROM_ADDR)," \ -e "s,##ROM_SIZE##,$(FMAP_ROM_SIZE)," \ + -e "s,##IFD_ENTRY##,$(FMAP_IFD_ENTRY)," \ + -e "s,##ME_ENTRY##,$(FMAP_ME_ENTRY)," \ + -e "s,##EC_ENTRY##,$(FMAP_EC_ENTRY)," \ + -e "s,##GBE_ENTRY##,$(FMAP_GBE_ENTRY)," \ -e "s,##BIOS_BASE##,$(FMAP_BIOS_BASE)," \ -e "s,##BIOS_SIZE##,$(FMAP_BIOS_SIZE)," \ -e "s,##FMAP_BASE##,$(FMAP_FMAP_BASE)," \ diff --git a/util/cbfstool/default-x86.fmd b/util/cbfstool/default-x86.fmd index f0143e9..7554582 100644 --- a/util/cbfstool/default-x86.fmd +++ b/util/cbfstool/default-x86.fmd @@ -8,6 +8,10 @@ # +-------------+ <-- 4GB / end of flash
FLASH@##ROM_BASE## ##ROM_SIZE## { + ##IFD_ENTRY## + ##ME_ENTRY## + ##EC_ENTRY## + ##GBE_ENTRY## BIOS@##BIOS_BASE## ##BIOS_SIZE## { ##CONSOLE_ENTRY## ##MRC_CACHE_ENTRY##