Add support to build (and run) an image with Measured Boot and fTPM support.

This patch enables Measured Boot on TF-A and builds the TSS tools
and the TPM Kernel Module for the FVP toolkit.

The functionality is disabled by default. To enable it, build with
MEASURED_BOOT=y.

Signed-off-by: Javier Almansa Sobrino <javier.almansasobrino@arm.com>
Reviewed-by: Jerome Forissier <jerome@forissier.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
diff --git a/br-ext/package/linux_ftpm_mod_ext/CMakeLists.txt b/br-ext/package/linux_ftpm_mod_ext/CMakeLists.txt
new file mode 100644
index 0000000..d2a0632
--- /dev/null
+++ b/br-ext/package/linux_ftpm_mod_ext/CMakeLists.txt
@@ -0,0 +1,3 @@
+# This is a dummy Makefile. When this package is invoked, the TPM Kernel
+# module has been built already.
+install(FILES /dev/null DESTINATION /dev/null)
diff --git a/br-ext/package/linux_ftpm_mod_ext/Config.in b/br-ext/package/linux_ftpm_mod_ext/Config.in
new file mode 100644
index 0000000..02d40d5
--- /dev/null
+++ b/br-ext/package/linux_ftpm_mod_ext/Config.in
@@ -0,0 +1,20 @@
+config BR2_PACKAGE_LINUX_FTPM_MOD_EXT
+       bool "Enable TPM Kernel module"
+       help
+         Enable TPM Kernel module.
+	 NOTE: This package currently only takes care of installing files
+	 into the root FS, that have been compiled already.
+	 The build of the TPM Kernel module is assumed to have been done
+	 previously.
+
+config BR2_PACKAGE_LINUX_FTPM_MOD_EXT_SITE
+	string "TPM Kernel Module installation package path"
+	default ""
+	help
+	  The path to this installation package.
+
+config BR2_PACKAGE_LINUX_FTPM_MOD_EXT_PATH
+	string "Path to the TPM Kernel module"
+	default ""
+	help
+	  The path of the TPM Kernel sources.
diff --git a/br-ext/package/linux_ftpm_mod_ext/linux_ftpm_mod_ext.mk b/br-ext/package/linux_ftpm_mod_ext/linux_ftpm_mod_ext.mk
new file mode 100644
index 0000000..6df8a73
--- /dev/null
+++ b/br-ext/package/linux_ftpm_mod_ext/linux_ftpm_mod_ext.mk
@@ -0,0 +1,18 @@
+LINUX_FTPM_MOD_EXT_VERSION = 1.0
+LINUX_FTPM_MOD_EXT_SOURCE = local
+LINUX_FTPM_MOD_EXT_SITE = $(BR2_PACKAGE_LINUX_FTPM_MOD_EXT_SITE)
+LINUX_FTPM_MOD_EXT_PATH = $(BR2_PACKAGE_LINUX_FTPM_MOD_EXT_PATH)
+LINUX_FTPM_MOD_EXT_SITE_METHOD = local
+LINUX_FTPM_MOD_EXT_INSTALL_DIR=$(TARGET_DIR)/lib/modules/extra
+
+define LINUX_FTPM_MOD_EXT_INSTALL
+	echo "Installing TPM kernel module" && \
+		mkdir -p $(LINUX_FTPM_MOD_EXT_INSTALL_DIR)
+		$(INSTALL) -v -p --mode=444 \
+		--target-directory=$(LINUX_FTPM_MOD_EXT_INSTALL_DIR) \
+		$(LINUX_FTPM_MOD_EXT_PATH)/drivers/char/tpm/tpm_ftpm_tee.ko
+endef
+
+LINUX_FTPM_MOD_EXT_POST_INSTALL_TARGET_HOOKS += LINUX_FTPM_MOD_EXT_INSTALL
+
+$(eval $(cmake-package))