the following patch was just integrated into master:
commit efe1feda19e4799a2acb2e57205604662dde17cc
Author: Nico Huber <nico.huber(a)secunet.com>
Date: Mon Apr 29 18:00:57 2013 +0200
kontron/ktqm77: New board
Change-Id: Ife1c0a8597c2de04773899cdd87af6b6c630906a
Signed-off-by: Nico Huber <nico.huber(a)secunet.com>
Signed-off-by: Patrick Georgi <patrick.georgi(a)secunet.com>
Reviewed-on: http://review.coreboot.org/3392
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich(a)gmail.com>
See http://review.coreboot.org/3392 for details.
-gerrit
the following patch was just integrated into master:
commit a15cd66b9ecba4033ec4ccf767847876236af70b
Author: Nico Huber <nico.huber(a)secunet.com>
Date: Wed Jun 19 16:16:05 2013 +0200
sandybridge: Make build possible without descriptor.bin
On newer Intel systems, the flash ROM is shared between the host
processor (BIOS), it's Management Engine (ME) and an integrated ethernet
controller (GbE). The layout of the flash ROM (and other information) is
kept in the so called Intel Firmware Descriptor (IFD). If we only want
to build coreboot to update the BIOS section, all we need is the flash
layout.
This patch adds the option to specify the flash layout in the
mainboard's Kconfig, and thus, to build without the real IFD. However,
with such a build, one has to make sure that the IFD section on the
flash ROM won't be written over (nor any other section that hasn't been
included by coreboot). A patch to write selected sections of a flash ROM
with IFD has been sent to the flashrom mailing list [1].
[1] http://www.flashrom.org/pipermail/flashrom/2013-June/011083.html
Change-Id: Ia23e439a00a197fb54852263f8e206f16c3e8851
Signed-off-by: Nico Huber <nico.huber(a)secunet.com>
Reviewed-on: http://review.coreboot.org/3524
Reviewed-by: Paul Menzel <paulepanter(a)users.sourceforge.net>
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich(a)gmail.com>
See http://review.coreboot.org/3524 for details.
-gerrit
Marc Jones (marc.jones(a)se-eng.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3350
-gerrit
commit faf86e9f46f3c5967a3ba14c156166d3e839376a
Author: Marc Jones <marc.jones(a)se-eng.com>
Date: Fri May 31 13:33:30 2013 -0600
abuild: Add xgcc tools to the path
abuild checks the path for toolchains prior to building a
mainboard. It didn't check xgcc/, which would be picked up
by the coreboot make, and fail to build when it shouldn't.
Change-Id: If0ca4238e8c57a6b015fdad623ccdbf237ef1ba6
Signed-off-by: Marc Jones <marc.jones(a)se-eng.com>
---
util/abuild/abuild | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/util/abuild/abuild b/util/abuild/abuild
index aad066c..d419e87 100755
--- a/util/abuild/abuild
+++ b/util/abuild/abuild
@@ -6,6 +6,7 @@
#
# (C) 2004 by Stefan Reinauer <stepan(a)openbios.org>
# (C) 2006-2010 by coresystems GmbH <info(a)coresystems.de>
+# (C) 2013 Sage Electronic Engineering, LLC
#
# This file is subject to the terms and conditions of the GNU General
# Public License. See the file COPYING in the main directory of this
@@ -14,8 +15,8 @@
#set -x # Turn echo on....
-ABUILD_DATE="December 10th, 2010"
-ABUILD_VERSION="0.9.1"
+ABUILD_DATE="May 31, 2013"
+ABUILD_VERSION="0.9.2"
TOP=$PWD
@@ -27,6 +28,14 @@ REAL_XMLFILE=$XMLFILE
# path to payload. Should be more generic
PAYLOAD=/dev/null
+# path to coreboot XGCC
+XGCCPATH="`pwd`/util/crossgcc/xgcc/bin/"
+
+# Add XGCC to the path.
+if [ -d "$XGCCPATH" ] && [[ ":$PATH:" != *":$XGCCPATH:"* ]]; then
+ PATH="$XGCCPATH:$PATH"
+fi
+
# Lines of error context to be printed in FAILURE case
CONTEXT=6
the following patch was just integrated into master:
commit 6aeb4a269c2ded6e6f72bf87da12b9295ef903f7
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Tue Jun 11 17:00:11 2013 +0300
AMD: Drop empty root_complex
There are no files to build left under AMD nortbridge/x/root_complex
directories. For some cases, even the Kconfig file was no longer sourced.
Remove all such references and empty files.
For devicetree.cb treat component paths with "/root_complex" in them valid
even when the directory does not exists. This is because AMD boards us this
dummy chip component as the root node in their devicetree.cb.
The generated devicetree file static.c remains unchanged.
Change-Id: I9278ebb50a83cebbf149b06afb5669899a8e4d0b
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Reviewed-on: http://review.coreboot.org/3434
Tested-by: build bot (Jenkins)
Reviewed-by: Marc Jones <marc.jones(a)se-eng.com>
See http://review.coreboot.org/3434 for details.
-gerrit
Nico Huber (nico.huber(a)secunet.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3524
-gerrit
commit 24598d65ea027b58b83f7517204ade85eb863a8e
Author: Nico Huber <nico.huber(a)secunet.com>
Date: Wed Jun 19 16:16:05 2013 +0200
sandybridge: Make build possible without descriptor.bin
On newer Intel systems, the flash ROM is shared between the host
processor (BIOS), it's Management Engine (ME) and an integrated ethernet
controller (GbE). The layout of the flash ROM (and other information) is
kept in the so called Intel Firmware Descriptor (IFD). If we only want
to build coreboot to update the BIOS section, all we need is the flash
layout.
This patch adds the option to specify the flash layout in the
mainboard's Kconfig, and thus, to build without the real IFD. However,
with such a build, one has to make sure that the IFD section on the
flash ROM won't be written over (nor any other section that hasn't been
included by coreboot). A patch to write selected sections of a flash ROM
with IFD has been sent to the flashrom mailing list [1].
[1] http://www.flashrom.org/pipermail/flashrom/2013-June/011083.html
Change-Id: Ia23e439a00a197fb54852263f8e206f16c3e8851
Signed-off-by: Nico Huber <nico.huber(a)secunet.com>
---
Makefile.inc | 8 ++++-
src/southbridge/intel/bd82x6x/Kconfig | 51 +++++++++++++++++++++++++++---
src/southbridge/intel/bd82x6x/Makefile.inc | 24 ++++++++++++--
3 files changed, 75 insertions(+), 8 deletions(-)
diff --git a/Makefile.inc b/Makefile.inc
index da350d1..69ad3a1 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -212,7 +212,8 @@ CFLAGS += -Werror
endif
CFLAGS += -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer
-additional-dirs := $(objutil)/cbfstool $(objutil)/romcc $(objutil)/ifdtool $(objutil)/options
+additional-dirs := $(objutil)/cbfstool $(objutil)/romcc $(objutil)/ifdtool \
+ $(objutil)/ifdfake $(objutil)/options
#######################################################################
# generate build support files
@@ -275,6 +276,11 @@ $(IFDTOOL): $(top)/util/ifdtool/ifdtool.c
@printf " HOSTCC $(subst $(obj)/,,$(@))\n"
$(HOSTCC) $(HOSTCFLAGS) -o $@ $<
+IFDFAKE:=$(objutil)/ifdfake/ifdfake
+$(IFDFAKE): $(top)/util/ifdfake/ifdfake.c
+ @printf " HOSTCC $(subst $(obj)/,,$(@))\n"
+ $(HOSTCC) $(HOSTCFLAGS) -o $@ $<
+
#######################################################################
# needed objects that every mainboard uses
# Creation of these is architecture and mainboard independent
diff --git a/src/southbridge/intel/bd82x6x/Kconfig b/src/southbridge/intel/bd82x6x/Kconfig
index 1d544de..0be875e 100644
--- a/src/southbridge/intel/bd82x6x/Kconfig
+++ b/src/southbridge/intel/bd82x6x/Kconfig
@@ -59,6 +59,52 @@ config HPET_MIN_TICKS
hex
default 0x80
+config HAVE_IFD_BIN
+ bool
+ default y
+
+config BUILD_WITH_FAKE_IFD
+ bool "Build with a fake IFD"
+ default y if !HAVE_IFD_BIN
+ help
+ If you don't have an Intel Firmware Descriptor (ifd.bin) for your
+ board, you can select this option and coreboot will build without it.
+ Though, the resulting coreboot.rom will not contain all parts required
+ to get coreboot running on your board. You can however write only the
+ BIOS section to your board's flash ROM and keep the other sections
+ untouched. Unfortunately the current version of flashrom doesn't
+ support this yet. But there is a patch pending [1].
+
+ WARNING: Never write a complete coreboot.rom to your flash ROM if it
+ was built with a fake IFD. It just won't work.
+
+ [1] http://www.flashrom.org/pipermail/flashrom/2013-June/011083.html
+
+config IFD_BIOS_SECTION
+ depends on BUILD_WITH_FAKE_IFD
+ string
+ default ""
+
+config IFD_ME_SECTION
+ depends on BUILD_WITH_FAKE_IFD
+ string
+ default ""
+
+config IFD_GBE_SECTION
+ depends on BUILD_WITH_FAKE_IFD
+ string
+ default ""
+
+config IFD_PLATFORM_SECTION
+ depends on BUILD_WITH_FAKE_IFD
+ string
+ default ""
+
+config IFD_BIN_PATH
+ string "Path to intel firmware descriptor"
+ depends on !BUILD_WITH_FAKE_IFD
+ default "3rdparty/mainboard/$(MAINBOARDDIR)/descriptor.bin"
+
config HAVE_GBE_BIN
bool "Add gigabit ethernet firmware"
default n
@@ -88,12 +134,9 @@ config ME_BIN_PATH
depends on HAVE_ME_BIN
default "3rdparty/mainboard/$(MAINBOARDDIR)/me.bin"
-config IFD_BIN_PATH
- string "Path to intel firmware descriptor"
- default "3rdparty/mainboard/$(MAINBOARDDIR)/descriptor.bin"
-
config LOCK_MANAGEMENT_ENGINE
bool "Lock Management Engine section"
+ depends on !BUILD_WITH_FAKE_IFD
default n
help
The Intel Management Engine supports preventing write accesses
diff --git a/src/southbridge/intel/bd82x6x/Makefile.inc b/src/southbridge/intel/bd82x6x/Makefile.inc
index 73948d2..c717586 100644
--- a/src/southbridge/intel/bd82x6x/Makefile.inc
+++ b/src/southbridge/intel/bd82x6x/Makefile.inc
@@ -52,9 +52,27 @@ smm-$(CONFIG_USBDEBUG) += usb_debug.c
romstage-y += reset.c
romstage-y += early_spi.c
-bd82x6x_add_me: $(obj)/coreboot.pre $(IFDTOOL)
+ifeq ($(CONFIG_BUILD_WITH_FAKE_IFD),y)
+IFD_BIN_PATH := $(objgenerated)/ifdfake.bin
+IFD_SECTIONS := $(addprefix -b ,$(CONFIG_IFD_BIOS_SECTION:"%"=%)) \
+ $(addprefix -m ,$(CONFIG_IFD_ME_SECTION:"%"=%)) \
+ $(addprefix -g ,$(CONFIG_IFD_GBE_SECTION:"%"=%)) \
+ $(addprefix -p ,$(CONFIG_IFD_PLATFORM_SECTION:"%"=%))
+else
+IFD_BIN_PATH := $(CONFIG_IFD_BIN_PATH)
+endif
+
+bd82x6x_add_me: $(obj)/coreboot.pre $(IFDTOOL) $(IFDFAKE)
+ifeq ($(CONFIG_BUILD_WITH_FAKE_IFD),y)
+ printf "\n** WARNING **\n"
+ printf "Coreboot will be built with a fake Intel Firmware Descriptor (IFD).\n"
+ printf "Never write a complete coreboot.rom with a fake IFD to your board's\n"
+ printf "flash ROM! Make sure that you only write valid flash regions.\n\n"
+ printf " IFDFAKE Building a fake Intel Firmware Descriptor\n"
+ $(IFDFAKE) $(IFD_SECTIONS) $(IFD_BIN_PATH)
+endif
printf " DD Adding Intel Firmware Descriptor\n"
- dd if=$(CONFIG_IFD_BIN_PATH) \
+ dd if=$(IFD_BIN_PATH) \
of=$(obj)/coreboot.pre conv=notrunc >/dev/null 2>&1
ifeq ($(CONFIG_HAVE_ME_BIN),y)
printf " IFDTOOL me.bin -> coreboot.pre\n"
@@ -74,7 +92,7 @@ ifeq ($(CONFIG_LOCK_MANAGEMENT_ENGINE),y)
printf " IFDTOOL Locking Management Engine\n"
$(objutil)/ifdtool/ifdtool -l $(obj)/coreboot.pre
mv $(obj)/coreboot.pre.new $(obj)/coreboot.pre
-else
+else ifneq ($(CONFIG_BUILD_WITH_FAKE_IFD),y)
printf " IFDTOOL Unlocking Management Engine\n"
$(objutil)/ifdtool/ifdtool -u $(obj)/coreboot.pre
mv $(obj)/coreboot.pre.new $(obj)/coreboot.pre
Nico Huber (nico.huber(a)secunet.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3524
-gerrit
commit adcf00926fd39e302a823e0f7a5ddc98df454e44
Author: Nico Huber <nico.huber(a)secunet.com>
Date: Wed Jun 19 16:16:05 2013 +0200
sandybridge: Make build possible without descriptor.bin
On newer Intel systems, the flash ROM is shared between the host
processor (BIOS), it's Management Engine (ME) and an integrated ethernet
controller (GbE). The layout of the flash ROM (and other information) is
kept in the so called Intel Firmware Descriptor (IFD). If we only want
to build coreboot to update the BIOS section, all we need is the flash
layout.
This patch adds the option to specify the flash layout in the
mainboard's Kconfig, and thus, build without the real IFD. However,
with such a build, one has to make sure that the IFD section on the
flash ROM won't be written over (nor any other section that hasn't been
included by coreboot). A patch to write selected sections of a flash ROM
with IFD has been sent to the flashrom mailing list [1].
[1] http://www.flashrom.org/pipermail/flashrom/2013-June/011083.html
Change-Id: Ia23e439a00a197fb54852263f8e206f16c3e8851
Signed-off-by: Nico Huber <nico.huber(a)secunet.com>
---
Makefile.inc | 8 ++++-
src/southbridge/intel/bd82x6x/Kconfig | 51 +++++++++++++++++++++++++++---
src/southbridge/intel/bd82x6x/Makefile.inc | 24 ++++++++++++--
3 files changed, 75 insertions(+), 8 deletions(-)
diff --git a/Makefile.inc b/Makefile.inc
index da350d1..69ad3a1 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -212,7 +212,8 @@ CFLAGS += -Werror
endif
CFLAGS += -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer
-additional-dirs := $(objutil)/cbfstool $(objutil)/romcc $(objutil)/ifdtool $(objutil)/options
+additional-dirs := $(objutil)/cbfstool $(objutil)/romcc $(objutil)/ifdtool \
+ $(objutil)/ifdfake $(objutil)/options
#######################################################################
# generate build support files
@@ -275,6 +276,11 @@ $(IFDTOOL): $(top)/util/ifdtool/ifdtool.c
@printf " HOSTCC $(subst $(obj)/,,$(@))\n"
$(HOSTCC) $(HOSTCFLAGS) -o $@ $<
+IFDFAKE:=$(objutil)/ifdfake/ifdfake
+$(IFDFAKE): $(top)/util/ifdfake/ifdfake.c
+ @printf " HOSTCC $(subst $(obj)/,,$(@))\n"
+ $(HOSTCC) $(HOSTCFLAGS) -o $@ $<
+
#######################################################################
# needed objects that every mainboard uses
# Creation of these is architecture and mainboard independent
diff --git a/src/southbridge/intel/bd82x6x/Kconfig b/src/southbridge/intel/bd82x6x/Kconfig
index 1d544de..0be875e 100644
--- a/src/southbridge/intel/bd82x6x/Kconfig
+++ b/src/southbridge/intel/bd82x6x/Kconfig
@@ -59,6 +59,52 @@ config HPET_MIN_TICKS
hex
default 0x80
+config HAVE_IFD_BIN
+ bool
+ default y
+
+config BUILD_WITH_FAKE_IFD
+ bool "Build with a fake IFD"
+ default y if !HAVE_IFD_BIN
+ help
+ If you don't have an Intel Firmware Descriptor (ifd.bin) for your
+ board, you can select this option and coreboot will build without it.
+ Though, the resulting coreboot.rom will not contain all parts required
+ to get coreboot running on your board. You can however write only the
+ BIOS section to your board's flash ROM and keep the other sections
+ untouched. Unfortunately the current version of flashrom doesn't
+ support this yet. But there is a patch pending [1].
+
+ WARNING: Never write a complete coreboot.rom to your flash ROM if it
+ was built with a fake IFD. It just won't work.
+
+ [1] http://www.flashrom.org/pipermail/flashrom/2013-June/011083.html
+
+config IFD_BIOS_SECTION
+ depends on BUILD_WITH_FAKE_IFD
+ string
+ default ""
+
+config IFD_ME_SECTION
+ depends on BUILD_WITH_FAKE_IFD
+ string
+ default ""
+
+config IFD_GBE_SECTION
+ depends on BUILD_WITH_FAKE_IFD
+ string
+ default ""
+
+config IFD_PLATFORM_SECTION
+ depends on BUILD_WITH_FAKE_IFD
+ string
+ default ""
+
+config IFD_BIN_PATH
+ string "Path to intel firmware descriptor"
+ depends on !BUILD_WITH_FAKE_IFD
+ default "3rdparty/mainboard/$(MAINBOARDDIR)/descriptor.bin"
+
config HAVE_GBE_BIN
bool "Add gigabit ethernet firmware"
default n
@@ -88,12 +134,9 @@ config ME_BIN_PATH
depends on HAVE_ME_BIN
default "3rdparty/mainboard/$(MAINBOARDDIR)/me.bin"
-config IFD_BIN_PATH
- string "Path to intel firmware descriptor"
- default "3rdparty/mainboard/$(MAINBOARDDIR)/descriptor.bin"
-
config LOCK_MANAGEMENT_ENGINE
bool "Lock Management Engine section"
+ depends on !BUILD_WITH_FAKE_IFD
default n
help
The Intel Management Engine supports preventing write accesses
diff --git a/src/southbridge/intel/bd82x6x/Makefile.inc b/src/southbridge/intel/bd82x6x/Makefile.inc
index 73948d2..c717586 100644
--- a/src/southbridge/intel/bd82x6x/Makefile.inc
+++ b/src/southbridge/intel/bd82x6x/Makefile.inc
@@ -52,9 +52,27 @@ smm-$(CONFIG_USBDEBUG) += usb_debug.c
romstage-y += reset.c
romstage-y += early_spi.c
-bd82x6x_add_me: $(obj)/coreboot.pre $(IFDTOOL)
+ifeq ($(CONFIG_BUILD_WITH_FAKE_IFD),y)
+IFD_BIN_PATH := $(objgenerated)/ifdfake.bin
+IFD_SECTIONS := $(addprefix -b ,$(CONFIG_IFD_BIOS_SECTION:"%"=%)) \
+ $(addprefix -m ,$(CONFIG_IFD_ME_SECTION:"%"=%)) \
+ $(addprefix -g ,$(CONFIG_IFD_GBE_SECTION:"%"=%)) \
+ $(addprefix -p ,$(CONFIG_IFD_PLATFORM_SECTION:"%"=%))
+else
+IFD_BIN_PATH := $(CONFIG_IFD_BIN_PATH)
+endif
+
+bd82x6x_add_me: $(obj)/coreboot.pre $(IFDTOOL) $(IFDFAKE)
+ifeq ($(CONFIG_BUILD_WITH_FAKE_IFD),y)
+ printf "\n** WARNING **\n"
+ printf "Coreboot will be built with a fake Intel Firmware Descriptor (IFD).\n"
+ printf "Never write a complete coreboot.rom with a fake IFD to your board's\n"
+ printf "flash ROM! Make sure that you only write valid flash regions.\n\n"
+ printf " IFDFAKE Building a fake Intel Firmware Descriptor\n"
+ $(IFDFAKE) $(IFD_SECTIONS) $(IFD_BIN_PATH)
+endif
printf " DD Adding Intel Firmware Descriptor\n"
- dd if=$(CONFIG_IFD_BIN_PATH) \
+ dd if=$(IFD_BIN_PATH) \
of=$(obj)/coreboot.pre conv=notrunc >/dev/null 2>&1
ifeq ($(CONFIG_HAVE_ME_BIN),y)
printf " IFDTOOL me.bin -> coreboot.pre\n"
@@ -74,7 +92,7 @@ ifeq ($(CONFIG_LOCK_MANAGEMENT_ENGINE),y)
printf " IFDTOOL Locking Management Engine\n"
$(objutil)/ifdtool/ifdtool -l $(obj)/coreboot.pre
mv $(obj)/coreboot.pre.new $(obj)/coreboot.pre
-else
+else ifneq ($(CONFIG_BUILD_WITH_FAKE_IFD),y)
printf " IFDTOOL Unlocking Management Engine\n"
$(objutil)/ifdtool/ifdtool -u $(obj)/coreboot.pre
mv $(obj)/coreboot.pre.new $(obj)/coreboot.pre
Nico Huber (nico.huber(a)secunet.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3523
-gerrit
commit cb3987fd82382f17b2581e0fa5fcc3028867cb18
Author: Nico Huber <nico.huber(a)secunet.com>
Date: Wed Jun 19 12:41:19 2013 +0200
ifdfake - Create an IFD with just a section layout
This new tool called `ifdfake` just creates an empty Intel Firmware
Descriptor (IFD) and writes the IFD signature plus the section layout
given on the command line.
usage: ifdfake [(-b|-m|-g|-p) <start>:<end>]... <output file>
-b | --bios <start>:<end> BIOS region
-m | --me <start>:<end> Intel ME region
-g | --gbe <start>:<end> Gigabit Ethernet region
-p | --platform <start>:<end> Platform Data region
-h | --help print this help
<start> and <end> bounds are given in Bytes, the <end> bound is inclusive.
All regions must be multiples of 4K in size and 4K aligned.
The descriptor region always resides in the first 4K.
An IFD created with ifdfake won't work as a replacement for a real IFD.
Never try to flash such an IFD to your board!
The output of ifdfake can be utilized to build an image with just the
later added sections (like coreboot itself) being valid. The resulting
image can then be partially written to a machines flash ROM to just
update coreboot (i.e. the BIOS section).
Change-Id: I925b47cab5c6d490a79d684bdd7a7a45ac442640
Signed-off-by: Nico Huber <nico.huber(a)secunet.com>
---
.gitignore | 1 +
util/ifdfake/Makefile | 43 ++++++++++
util/ifdfake/ifdfake.c | 208 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 252 insertions(+)
diff --git a/.gitignore b/.gitignore
index e57e32f..0061152 100644
--- a/.gitignore
+++ b/.gitignore
@@ -62,6 +62,7 @@ util/dumpmmcr/dumpmmcr
util/ectool/ectool
util/getpir/getpir
util/ifdtool/ifdtool
+util/ifdfake/ifdfake
util/inteltool/.dependencies
util/inteltool/inteltool
util/k8resdump/k8resdump
diff --git a/util/ifdfake/Makefile b/util/ifdfake/Makefile
new file mode 100644
index 0000000..3a896ee
--- /dev/null
+++ b/util/ifdfake/Makefile
@@ -0,0 +1,43 @@
+#
+# ifdfake - Create an Intel Firmware Descriptor with just a section layout
+#
+# Copyright (C) 2013 secunet Security Networks AG
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
+#
+
+PROGRAM = ifdfake
+
+CC ?= gcc
+INSTALL ?= /usr/bin/install
+PREFIX ?= /usr/local
+CFLAGS ?= -O2 -g -Wall -W
+
+OBJS = ifdfake.o
+
+all: $(PROGRAM)
+
+$(PROGRAM): $(OBJS)
+ $(CC) -o $(PROGRAM) $(OBJS) $(LDFLAGS)
+
+clean:
+ rm -f $(PROGRAM) *.o *~
+
+distclean: clean
+
+install: $(PROGRAM)
+ mkdir -p $(DESTDIR)$(PREFIX)/bin
+ $(INSTALL) $(PROGRAM) $(DESTDIR)$(PREFIX)/bin
+
+.PHONY: all clean distclean
diff --git a/util/ifdfake/ifdfake.c b/util/ifdfake/ifdfake.c
new file mode 100644
index 0000000..8eb34a9
--- /dev/null
+++ b/util/ifdfake/ifdfake.c
@@ -0,0 +1,208 @@
+/*
+ * ifdfake - Create an Intel Firmware Descriptor with just a section layout
+ *
+ * Copyright (C) 2013 secunet Security Networks AG
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <getopt.h>
+
+#define FDBAR_OFFSET 0x10
+#define FRBA_OFFSET 0x40
+
+typedef struct {
+ uint32_t base, limit, size;
+} region_t;
+
+static void write_image(const region_t regions[], const char *const image)
+{
+ FILE *const f = fopen(image, "w");
+ if (!f) {
+ perror("Could not open file");
+ exit(EXIT_FAILURE);
+ }
+
+ if (fseek(f, 0x1000 - 1, SEEK_SET)) {
+ perror("Failed to seek to end of descriptor");
+ exit(EXIT_FAILURE);
+ }
+ char zero = '\0';
+ if (fwrite(&zero, 1, 1, f) != 1) {
+ fprintf(stderr, "Failed to write at end of descriptor.\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if (fseek(f, FDBAR_OFFSET, SEEK_SET)) {
+ perror("Failed to seek to fdbar");
+ exit(EXIT_FAILURE);
+ }
+
+ struct {
+ uint32_t flvalsig;
+ uint32_t flmap0;
+ } fdbar;
+ memset(&fdbar, 0x00, sizeof(fdbar));
+ fdbar.flvalsig = 0x0ff0a55a;
+ fdbar.flmap0 = (FRBA_OFFSET >> 4) << 16;
+ if (fwrite(&fdbar, sizeof(fdbar), 1, f) != 1) {
+ fprintf(stderr, "Failed to write fdbar.\n");
+ exit(EXIT_FAILURE);
+ }
+
+ int i;
+ uint32_t frba[5];
+ for (i = 0; i < 5; ++i) {
+ if (regions[i].size)
+ frba[i] = ((regions[i].limit & 0xfff000) << (16 - 12)) |
+ ((regions[i].base & 0xfff000) >> 12);
+ else
+ frba[i] = 0x00000fff;
+ }
+
+ if (fseek(f, FRBA_OFFSET, SEEK_SET)) {
+ perror("Failed to seek to frba");
+ exit(EXIT_FAILURE);
+ }
+ if (fwrite(frba, sizeof(frba), 1, f) != 1) {
+ fprintf(stderr, "Failed to write frba.\n");
+ exit(EXIT_FAILURE);
+ }
+
+ fclose(f);
+}
+
+static int parse_region(const char *_arg, region_t *const region)
+{
+ char *const start = strdup(_arg);
+ if (!start) {
+ fprintf(stderr, "Out of memory.\n");
+ exit(EXIT_FAILURE);
+ }
+
+ char *const colon = strchr(start, ':');
+ if (!colon) {
+ free(start);
+ return -1;
+ }
+ *colon = '\0';
+
+ char *const end = colon + 1;
+
+ errno = 0;
+ region->base = strtoul(start, NULL, 0);
+ region->limit = strtoul(end, NULL, 0);
+ region->size = region->limit - region->base + 1;
+
+ free(start);
+ if (errno) {
+ perror("Failed to parse region");
+ return -1;
+ } else {
+ return 0;
+ }
+}
+
+static void print_usage(const char *name)
+{
+ printf("usage: %s [(-b|-m|-g|-p) <start>:<end>]... <output file>\n", name);
+ printf("\n"
+ " -b | --bios <start>:<end> BIOS region\n"
+ " -m | --me <start>:<end> Intel ME region\n"
+ " -g | --gbe <start>:<end> Gigabit Ethernet region\n"
+ " -p | --platform <start>:<end> Platform Data region\n"
+ " -h | --help print this help\n\n"
+ "<start> and <end> bounds are given in bytes, the <end> bound is inclusive.\n"
+ "All regions must be multiples of 4K in size and 4K aligned.\n"
+ "The descriptor region always resides in the first 4K.\n\n"
+ "An IFD created with ifdfake won't work as a replacement for a real IFD.\n"
+ "Never try to flash such an IFD to your board!\n\n");
+}
+
+int main(int argc, char *argv[])
+{
+ int opt, option_index = 0, idx;
+ region_t regions[5];
+
+ memset(regions, 0x00, sizeof(regions));
+
+ static struct option long_options[] = {
+ {"bios", 1, NULL, 'b'},
+ {"me", 1, NULL, 'm'},
+ {"gbe", 1, NULL, 'g'},
+ {"platform", 1, NULL, 'p'},
+ {"help", 0, NULL, 'h'},
+ {0, 0, 0, 0}
+ };
+
+ while ((opt = getopt_long(argc, argv, "b:m:g:p:h?",
+ long_options, &option_index)) != EOF) {
+ switch (opt) {
+ case 'b': case 'm': case 'g': case 'p':
+ switch (opt) {
+ case 'b': idx = 1; break;
+ case 'm': idx = 2; break;
+ case 'g': idx = 3; break;
+ case 'p': idx = 4; break;
+ default: idx = 0; break; /* can't happen */
+ }
+ if (parse_region(optarg, ®ions[idx])) {
+ print_usage(argv[0]);
+ exit(EXIT_FAILURE);
+ }
+ break;
+ case 'h':
+ case '?':
+ default:
+ print_usage(argv[0]);
+ exit(EXIT_SUCCESS);
+ break;
+ }
+ }
+
+ if (optind + 1 != argc) {
+ fprintf(stderr, "No output file given.\n\n");
+ print_usage(argv[0]);
+ exit(EXIT_FAILURE);
+ }
+
+ regions[0].base = 0x00000000;
+ regions[0].limit = 0x00000fff;
+ regions[0].size = 0x00001000;
+ for (idx = 1; idx < 5; ++idx) {
+ if (regions[idx].size) {
+ if (regions[idx].base & 0xfff)
+ fprintf(stderr, "Region %d is "
+ "not 4K aligned.\n", idx);
+ else if (regions[idx].size & 0xfff)
+ fprintf(stderr, "Region %d size is "
+ "no multiple of 4K.\n", idx);
+ else if (regions[idx].limit <= regions[idx].base)
+ fprintf(stderr, "Region %d is empty.\n", idx);
+ else
+ continue;
+ print_usage(argv[0]);
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ write_image(regions, argv[optind]);
+
+ return 0;
+}