summaryrefslogtreecommitdiff
path: root/Makefile.inc
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2016-08-19 15:43:06 -0700
committerJulius Werner <jwerner@chromium.org>2016-08-27 01:16:22 +0200
commitf975e55dcdbeb31e39449d22a9c04ff861dae8dd (patch)
tree7a677a6f71a26d2d9c19d98d12c13cb5e5244a0b /Makefile.inc
parent71885a49600db1df58060406c0bb8a5b976c554c (diff)
downloadcoreboot-f975e55dcdbeb31e39449d22a9c04ff861dae8dd.tar.xz
cbfs: Add "struct" file type and associated helpers
This patch adds functionality to compile a C data structure into a raw binary file, add it to CBFS and allow coreboot to load it at runtime. This is useful in all cases where we need to be able to have several larger data sets available in an image, but will only require a small subset of them at boot (a classic example would be DRAM parameters) or only require it in certain boot modes. This allows us to load less data from flash and increase boot speed compared to solutions that compile all data sets into a stage. Each structure has to be defined in a separate .c file which contains no functions and only a single global variable. The data type must be serialization safe (composed of only fixed-width types, paying attention to padding). It must be added to CBFS in a Makefile with the 'struct' file processor. Change-Id: Iab65c0b6ebea235089f741eaa8098743e54d6ccc Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/16272 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'Makefile.inc')
-rw-r--r--Makefile.inc12
1 files changed, 12 insertions, 0 deletions
diff --git a/Makefile.inc b/Makefile.inc
index ff77747a5b..6225152b13 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -278,6 +278,18 @@ cbfs-files-processor-defconfig= \
\mv -f $(2).tmp $(2))
#######################################################################
+# Compile a C file with a bare struct definition into binary
+# arg1: C source file
+# arg2: binary file
+cbfs-files-processor-struct= \
+ $(eval $(2): $(1) $(obj)/build.h $(KCONFIG_AUTOHEADER); \
+ printf " CC+STRIP $(@)\n"; \
+ $(CC_ramstage) -MMD $(CPPFLAGS_ramstage) $(CFLAGS_ramstage) $(ramstage-c-ccopts) -include $(KCONFIG_AUTOHEADER) -MT $(2) -o $(2).tmp -c $(1) && \
+ $(OBJCOPY_ramstage) -O binary $(2).tmp $(2); \
+ rm -f $(2).tmp) \
+ $(eval DEPENDENCIES += $(2).d)
+
+#######################################################################
# Add handler for arbitrary files in CBFS
$(call add-special-class,cbfs-files)
cbfs-files-handler= \