[coreboot-gerrit] New patch to review for coreboot: build system: allow allocating files to regions by stage

Patrick Georgi (pgeorgi@google.com) gerrit at coreboot.org
Mon Jan 18 16:57:22 CET 2016


Patrick Georgi (pgeorgi at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13039

-gerrit

commit 0cbfcae0ef0b01a284fe269de4d6d51169f581f1
Author: Patrick Georgi <pgeorgi at chromium.org>
Date:   Mon Jan 18 16:24:10 2016 +0100

    build system: allow allocating files to regions by stage
    
    $(FILENAME)-stages is now parsed for stages, which are then mapped to
    fmap regions to put files into.
    
    Change-Id: I5e2e6b8e8759fda2cfb0144d5b998ba3e05650c8
    Signed-off-by: Patrick Georgi <pgeorgi at chromium.org>
---
 Makefile.inc | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/Makefile.inc b/Makefile.inc
index b1f5595..b0c4159 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -112,6 +112,7 @@ spc :=
 spc +=
 $(spc) :=
 $(spc) +=
+comma := ,
 
 # files-in-dir-recursive,dir,files
 files-in-dir-recursive=$(filter $(1)%,$(2))
@@ -254,6 +255,8 @@ cbfs-files-handler= \
 			$(if $(wildcard $(1)$($(2)-file)), \
 				$(eval tmp-cbfs-file:= $(wildcard $(1)$($(2)-file))), \
 				$(eval tmp-cbfs-file:= $($(2)-file)))) \
+		$(if $(strip $($(2)-stages)),, \
+			$(eval $(2)-stages:=payload)) \
 		$(if $(strip $($(2)-required)), \
 			$(if $(wildcard $(tmp-cbfs-file)),, \
 				$(info This build configuration requires $($(2)-required)) \
@@ -274,13 +277,14 @@ cbfs-files-handler= \
 			$(eval tmp-cbfs-file:=$(shell mkdir -p $(obj)/mainboard/$(MAINBOARDDIR); mktemp $(obj)/mainboard/$(MAINBOARDDIR)/cbfs-file.XXXXXX).out) \
 			$(call cbfs-files-processor-$(tmp-cbfs-method),$(tmp-old-cbfs-file),$(tmp-cbfs-file))) \
 		$(if $(tmp-cbfs-file), \
-			$(eval cbfs-files-$(_cbfs-bucket) += $(subst $(spc),*,$(tmp-cbfs-file)|$(2)|$($(2)-type)|$($(2)-compression)|$(strip $($(2)-position))|$($(2)-align)|$($(2)-options)))) \
+			$(eval cbfs-files-$(_cbfs-bucket) += $(subst $(spc),*,$(tmp-cbfs-file)|$(2)|$($(2)-type)|$($(2)-compression)|$(strip $($(2)-position))|$($(2)-align)|$($(2)-options)|$($(2)-stages)))) \
 		$(eval $(2)-name:=) \
 		$(eval $(2)-type:=) \
 		$(eval $(2)-compression:=) \
 		$(eval $(2)-position:=) \
 		$(eval $(2)-required:=) \
 		$(eval $(2)-options:=) \
+		$(eval $(2)-stages:=) \
 		$(eval $(2)-align:=)
 
 #######################################################################
@@ -622,7 +626,7 @@ $(objcbfs)/%.elf: $(objcbfs)/%.debug
 # extract_nth - Return a subsection of the $file string
 #
 # the input string looks like this:
-# ./build/cbfs/fallback/romstage.elf|fallback/romstage|stage|none||64|--xip*-S*.car.data*-P*0x10000
+# ./build/cbfs/fallback/romstage.elf|fallback/romstage|stage|none||64|--xip*-S*.car.data*-P*0x10000|payload
 #
 # Sections:
 # 1 - Path and name of file [FILENAME: Added to cbfs-files-y list variable]
@@ -636,6 +640,11 @@ $(objcbfs)/%.elf: $(objcbfs)/%.debug
 # 5 - Base address          [$(FILANAME)-position]
 # 6 - Alignment             [$(FILENAME)-align]
 # 7 - cbfstool flags        [$(FILENAME)-options]
+# 8 - stages                [$(FILENAME)-stages]
+#                verstage, romstage, ramstage, payload, defaults to payload.
+#                Multiple stages can be declared (space separated)
+#                In combination with stage-to-region-$(stagename), it can be
+#                used to map files to region(s).
 #
 # Input:
 #  $(1) = Section to extract
@@ -648,6 +657,15 @@ $(objcbfs)/%.elf: $(objcbfs)/%.debug
 # 4) replace all '*' characters with spaces
 extract_nth=$(subst *,$(spc),$(patsubst -%-,%,$(word $(1), $(subst |,- -,-$(2)-))))
 
+# stages-to-regions
+#
+# map a space separated enumeration of stages to comma-separated regions,
+# using the # stage-to-region-$(stage) variables for the mapping.
+#
+# "stage1 stage2" translates to a sorted version of
+# "$(stage-to-region-$(stage1)),$(stage-to-region-$(stage2))"
+stages-to-regions=$(subst $(spc),$(comma),$(sort $(foreach stage,$(1),$(stage-to-region-$(stage)) )))
+
 cbfs-add-cmd = \
                printf "    CBFS       $(call extract_nth,2,$(file))\n"; \
 	       $(CBFSTOOL) $@.tmp \
@@ -656,6 +674,7 @@ cbfs-add-cmd = \
 	       -n $(call extract_nth,2,$(file)) \
 	       $(if $(filter-out stage,$(call extract_nth,3,$(file))),-t $(call extract_nth,3,$(file))) \
 	       $(if $(call extract_nth,4,$(file)),-c $(call extract_nth,4,$(file))) \
+	       -r $(call stages-to-regions,$(call extract_nth,8,$(file))) \
 	       $(call extract_nth,7,$(file))
 
 cbfs-files=$(cbfs-files-fixed) $(cbfs-files-aligned) $(cbfs-files-regular)
@@ -667,6 +686,12 @@ prebuild-files = \
 prebuilt-files = $(foreach file,$(cbfs-files), $(call extract_nth,1,$(file)))
 
 ifeq ($(CONFIG_FMDFILE),)
+# for default FMDs, there's only one region, "COREBOOT"
+stage-to-region-verstage := COREBOOT
+stage-to-region-romstage := COREBOOT
+stage-to-region-ramstage := COREBOOT
+stage-to-region-payload  := COREBOOT
+
 # For a description of the flash layout described by these variables, check
 # the $(DEFAULT_FLASHMAP) .fmd files.
 ifeq ($(CONFIG_ARCH_X86),y)



More information about the coreboot-gerrit mailing list