[coreboot-gerrit] Patch set updated for coreboot: Switch to fmap based firmware layout
Patrick Georgi (pgeorgi@google.com)
gerrit at coreboot.org
Tue Sep 22 14:40:31 CET 2015
Patrick Georgi (pgeorgi at google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11692
-gerrit
commit 8b34927b806681c30d2dedc4dfa19774730db116
Author: Patrick Georgi <pgeorgi at chromium.org>
Date: Wed Sep 16 18:10:52 2015 +0200
Switch to fmap based firmware layout
We still add a master header for compatibility purposes, and the default
layouts don't cover anything non-coreboot (eg. IFD regions) yet.
The default layouts can be overridden by specifying an fmd file, from
which the fmap is generated.
Future work:
- map IFD regions to fmap regions
- non-x86: build minimalistic trampolines that jump into the first cbfs
file, so the bootblock can be part of CBFS instead of reserving a
whole 64K for it.
- teach coreboot's cbfs code to work without the master header
- teach coreboot's cbfs code to work on different fmap regions
Change-Id: Id1085dcd5107cf0e02e8dc1e77dc0dd9497a819c
Signed-off-by: Patrick Georgi <pgeorgi at chromium.org>
---
Makefile.inc | 75 +++++++++++++++++++++++++++++++++++++++++--
util/cbfstool/default-x86.fmd | 15 +++++++++
util/cbfstool/default.fmd | 17 ++++++++++
3 files changed, 104 insertions(+), 3 deletions(-)
diff --git a/Makefile.inc b/Makefile.inc
index 46d6eb2..606d081 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -566,10 +566,79 @@ prebuild-files = \
$(cbfs-add-cmd) $(if $(call extract_nth,5,$(file)),-b $(call extract_nth,5,$(file))) &&))
prebuilt-files = $(foreach file,$(cbfs-files), $(call extract_nth,1,$(file)))
+ifeq ($(CONFIG_ARCH_X86),y)
+DEFAULT_FLASHMAP:=$(top)/util/cbfstool/default-x86.fmd
+# entire flash
+FMAP_ROM_BASE := $(call int-subtract, 0x100000000 $(CONFIG_ROM_SIZE))
+FMAP_ROM_SIZE := $(CONFIG_ROM_SIZE)
+# entire "BIOS" region (everything directly of concern to the host system)
+# relative to ROM_BASE
+FMAP_BIOS_BASE := $(call int-subtract, $(CONFIG_ROM_SIZE) $(CONFIG_CBFS_SIZE))
+FMAP_BIOS_SIZE := $(CONFIG_CBFS_SIZE)
+# position and size of flashmap, relative to BIOS_BASE
+FMAP_FMAP_BASE := 0
+FMAP_FMAP_SIZE := 0x100
+# position and size of CBFS, relative to BIOS_BASE
+FMAP_CBFS_BASE := $(FMAP_FMAP_SIZE)
+FMAP_CBFS_SIZE := $(call int-subtract, $(FMAP_BIOS_SIZE) $(FMAP_FMAP_SIZE))
+else
+DEFAULT_FLASHMAP:=$(top)/util/cbfstool/default.fmd
+# entire flash
+FMAP_ROM_BASE := 0
+FMAP_ROM_SIZE := $(CONFIG_ROM_SIZE)
+# entire "BIOS" region (everything directly of concern to the host system)
+# relative to ROM_BASE
+FMAP_BIOS_BASE := 0
+FMAP_BIOS_SIZE := $(CONFIG_CBFS_SIZE)
+# position and size of flashmap, relative to BIOS_BASE
+FMAP_FMAP_BASE := 0x10000
+FMAP_FMAP_SIZE := 0x100
+# position and size of CBFS, relative to BIOS_BASE
+FMAP_CBFS_BASE := $(call int-add,$(FMAP_FMAP_BASE) $(FMAP_FMAP_SIZE))
+FMAP_CBFS_SIZE := $(call int-subtract,$(FMAP_BIOS_SIZE) $(FMAP_CBFS_BASE))
+endif
+
$(obj)/coreboot.pre1: $(objcbfs)/bootblock.bin $$(prebuilt-files) $(FMAPTOOL) $(CBFSTOOL) $$(cpu_ucode_cbfs_file)
- $(CBFSTOOL) $@.tmp create \
- -B $(objcbfs)/bootblock.bin \
- $(CBFSTOOL_PRE1_OPTS)
+ifeq ($(CONFIG_FMDFILE),)
+ sed -e "s,##ROM_BASE##,$(FMAP_ROM_BASE)," \
+ -e "s,##ROM_SIZE##,$(FMAP_ROM_SIZE)," \
+ -e "s,##BIOS_BASE##,$(FMAP_BIOS_BASE)," \
+ -e "s,##BIOS_SIZE##,$(FMAP_BIOS_SIZE)," \
+ -e "s,##FMAP_BASE##,$(FMAP_FMAP_BASE)," \
+ -e "s,##FMAP_SIZE##,$(FMAP_FMAP_SIZE)," \
+ -e "s,##CBFS_BASE##,$(FMAP_CBFS_BASE)," \
+ -e "s,##CBFS_SIZE##,$(FMAP_CBFS_SIZE)," \
+ $(DEFAULT_FLASHMAP) > $@.tmp.fmd
+ $(FMAPTOOL) $@.tmp.fmd $@.tmp.fmap
+else
+ $(FMAPTOOL) $(CONFIG_FMDFILE) $@.tmp.fmap
+endif
+ $(CBFSTOOL) $@.tmp create -M $@.tmp.fmap
+ifeq ($(CONFIG_ARCH_X86),y)
+ $(CBFSTOOL) $@.tmp add \
+ -f $(objcbfs)/bootblock.bin \
+ -n bootblock \
+ -t bootblock \
+ -b -$(call file-size,$(objcbfs)/bootblock.bin)
+else
+ # don't add bootblock to cbfs yet, it's just a waste of space
+ true $(CBFSTOOL) $@.tmp add \
+ -f $(objcbfs)/bootblock.bin \
+ -n bootblock \
+ -t bootblock \
+ -b 0
+ $(CBFSTOOL) $@.tmp write -u \
+ -r BOOTBLOCK \
+ -f $(objcbfs)/bootblock.bin
+ printf "ptr_" > $@.tmp.2 # 4 characters
+ $(CBFSTOOL) $@.tmp add \
+ -f $@.tmp.2 \
+ -n "header pointer" \
+ -t "cbfs header" \
+ -b -4
+ rm -f $@.tmp.2
+endif
+ $(CBFSTOOL) $@.tmp add-master-header
$(prebuild-files) true
mv $@.tmp $@
else
diff --git a/util/cbfstool/default-x86.fmd b/util/cbfstool/default-x86.fmd
new file mode 100644
index 0000000..d7d0326
--- /dev/null
+++ b/util/cbfstool/default-x86.fmd
@@ -0,0 +1,15 @@
+# layout for firmware residing at top of 4GB address space
+# 4GB - ROM_SIZE: start of flash
+# 4GB - CBFS_SIZE: start of fmap
+# + 0x100: start of CBFS
+# 4GB end of flash
+
+# ##CBFS_SIZE## differs from the CBFS_SIZE specified above in that it already
+# excludes the fmap size. CONFIG_CBFS_SIZE contains it.
+
+FLASH@##ROM_BASE## ##ROM_SIZE## {
+ BIOS@##BIOS_BASE## ##BIOS_SIZE## {
+ FMAP@##FMAP_BASE## ##FMAP_SIZE##
+ COREBOOT(CBFS)@##CBFS_BASE## ##CBFS_SIZE##
+ }
+}
diff --git a/util/cbfstool/default.fmd b/util/cbfstool/default.fmd
new file mode 100644
index 0000000..21617d5
--- /dev/null
+++ b/util/cbfstool/default.fmd
@@ -0,0 +1,17 @@
+# layout for firmware when flash address space matches used address layout
+# 0: start of flash, start of bootblock region
+# 0x10000: start of fmap
+# 0x10100: start of cbfs
+# CBFS_SIZE end of fmap, end of used flash space
+# ROM_SIZE end of flash
+
+# ##CBFS_SIZE## differs from the CBFS_SIZE specified above in that it already
+# excludes the fmap size. CONFIG_CBFS_SIZE contains it.
+
+FLASH@##ROM_BASE## ##ROM_SIZE## {
+ BIOS@##BIOS_BASE## ##BIOS_SIZE## {
+ BOOTBLOCK 64K
+ FMAP@##FMAP_BASE## ##FMAP_SIZE##
+ COREBOOT(CBFS)@##CBFS_BASE## ##CBFS_SIZE##
+ }
+}
More information about the coreboot-gerrit
mailing list