Merge pull request #55 from bofferdn/patch-3

op-build pull request to support BIOS infrastructure
diff --git a/openpower/configs/habanero_defconfig b/openpower/configs/habanero_defconfig
index 0d94114..8febc0c 100644
--- a/openpower/configs/habanero_defconfig
+++ b/openpower/configs/habanero_defconfig
@@ -13,6 +13,7 @@
 
 BR2_HABANERO_SYSTEM_XML_FILENAME="HABANERO_hb.system.xml"
 BR2_HABANERO_MRW_XML_FILENAME="HABANERO_hb.mrw.xml"
+BR2_HABANERO_BIOS_XML_FILENAME="HABANERO_bios.xml"
 
 BR2_OPENPOWER_TARGETING_BIN_FILENAME="HABANERO_HB.targeting.bin"
 BR2_OPENPOWER_TARGETING_ECC_FILENAME="HABANERO_HB.targeting.bin.ecc"
diff --git a/openpower/configs/palmetto_defconfig b/openpower/configs/palmetto_defconfig
index bbdaca1..c208972 100644
--- a/openpower/configs/palmetto_defconfig
+++ b/openpower/configs/palmetto_defconfig
@@ -13,6 +13,8 @@
 
 BR2_PALMETTO_SYSTEM_XML_FILENAME="PALMETTO_hb.system.xml"
 BR2_PALMETTO_MRW_XML_FILENAME="PALMETTO_hb.mrw.xml"
+BR2_PALMETTO_BIOS_XML_FILENAME="PALMETTO_bios.xml"
+
 BR2_OPENPOWER_TARGETING_BIN_FILENAME="PALMETTO_HB.targeting.bin"
 BR2_OPENPOWER_TARGETING_ECC_FILENAME="PALMETTO_HB.targeting.bin.ecc"
 
diff --git a/openpower/package/habanero-xml/Config.in b/openpower/package/habanero-xml/Config.in
index c6d945e..2939cb6 100755
--- a/openpower/package/habanero-xml/Config.in
+++ b/openpower/package/habanero-xml/Config.in
@@ -15,3 +15,9 @@
         default ""
         help
             Defines the name of the mrw XML filename to be used when creating targeting binary image
+            
+config BR2_HABANERO_BIOS_XML_FILENAME
+        string "Habanero BIOS metadata XML filename"
+        default ""
+        help
+            Defines the name of the BIOS XML filename to parse when generating BIOS metadata
diff --git a/openpower/package/habanero-xml/habanero-xml.mk b/openpower/package/habanero-xml/habanero-xml.mk
index 4405f1c..84608a1 100644
--- a/openpower/package/habanero-xml/habanero-xml.mk
+++ b/openpower/package/habanero-xml/habanero-xml.mk
@@ -11,11 +11,22 @@
 HABANERO_XML_DEPENDENCIES = hostboot-install-images openpower-mrw-install-images common-p8-xml-install-images
 
 HABANERO_XML_INSTALL_IMAGES = YES
-HABANERO_XML_INSTALL_TARGET = NO
+HABANERO_XML_INSTALL_TARGET = YES
 
 MRW_SCRATCH=$(STAGING_DIR)/openpower_mrw_scratch
 MRW_HB_TOOLS=$(STAGING_DIR)/hostboot_build_images
 
+# Defines for BIOS metadata creation
+BIOS_SCHEMA_FILE = $(MRW_HB_TOOLS)/bios.xsd
+HABANERO_BIOS_XML_CONFIG_FILE = $(MRW_SCRATCH)/$(BR2_HABANERO_BIOS_XML_FILENAME)
+BIOS_XML_METADATA_FILE = \
+    $(MRW_HB_TOOLS)/$(BR2_OPENPOWER_CONFIG_NAME)_bios_metadata.xml
+PETITBOOT_XSLT_FILE = $(MRW_HB_TOOLS)/bios_metadata_petitboot.xslt
+PETITBOOT_BIOS_XML_METADATA_FILE = \
+    $(MRW_HB_TOOLS)/$(BR2_OPENPOWER_CONFIG_NAME)_bios_metadata_petitboot.xml
+PETITBOOT_BIOS_XML_METADATA_INITRAMFS_FILE = \
+    $(TARGET_DIR)/usr/share/bios_metadata.xml
+
 define HABANERO_XML_BUILD_CMDS
         # copy the habanero xml where the common lives
         bash -c 'mkdir -p $(MRW_SCRATCH) && cp -r $(@D)/* $(MRW_SCRATCH)'
@@ -23,10 +34,7 @@
         # generate the system mrw xml
         perl -I $(MRW_HB_TOOLS) \
         $(MRW_HB_TOOLS)/processMrw.pl -x $(MRW_SCRATCH)/habanero.xml
-endef
-
-define HABANERO_XML_INSTALL_IMAGES_CMDS
-
+        
         # merge in any system specific attributes, hostboot attributes
         $(MRW_HB_TOOLS)/mergexml.sh $(MRW_SCRATCH)/$(BR2_HABANERO_SYSTEM_XML_FILENAME) \
             $(MRW_HB_TOOLS)/attribute_types.xml \
@@ -41,9 +49,27 @@
             --fapi-attributes-xml-file=$(MRW_HB_TOOLS)/fapiattrs.xml \
             --src-output-dir=none \
             --img-output-dir=$(MRW_HB_TOOLS)/ \
-            --vmm-consts-file=$(MRW_HB_TOOLS)/vmmconst.h --noshort-enums
+            --vmm-consts-file=$(MRW_HB_TOOLS)/vmmconst.h --noshort-enums \
+            --bios-xml-file=$(HABANERO_BIOS_XML_CONFIG_FILE) \
+            --bios-schema-file=$(BIOS_SCHEMA_FILE) \
+            --bios-output-file=$(BIOS_XML_METADATA_FILE)
 
+        # Transform BIOS XML into Petitboot specific BIOS XML via the schema
+        xsltproc -o \
+            $(PETITBOOT_BIOS_XML_METADATA_FILE) \
+            $(PETITBOOT_XSLT_FILE) \
+            $(BIOS_XML_METADATA_FILE)
+endef
+
+define HABANERO_XML_INSTALL_IMAGES_CMDS
         mv $(MRW_HB_TOOLS)/targeting.bin $(MRW_HB_TOOLS)/$(BR2_OPENPOWER_TARGETING_BIN_FILENAME)
 endef
 
+define HABANERO_XML_INSTALL_IMAGES_CMDS
+        # Install Petitboot specific BIOS XML into initramfs's usr/share/ dir
+        $(INSTALL) -D -m 0644 \
+            $(PETITBOOT_BIOS_XML_METADATA_FILE) \
+            $(PETITBOOT_BIOS_XML_METADATA_INITRAMFS_FILE)
+endef
+
 $(eval $(generic-package))
diff --git a/openpower/package/palmetto-xml/Config.in b/openpower/package/palmetto-xml/Config.in
index 6c5fd3c..b07d517 100755
--- a/openpower/package/palmetto-xml/Config.in
+++ b/openpower/package/palmetto-xml/Config.in
@@ -15,3 +15,9 @@
         default ""
         help
             Defines the name of the mrw XML filename to be used when creating targeting binary image
+
+config BR2_PALMETTO_BIOS_XML_FILENAME
+        string "Palmetto BIOS metadata XML filename"
+        default ""
+        help
+            Defines the name of the BIOS XML filename to parse when generating BIOS metadata
diff --git a/openpower/package/palmetto-xml/palmetto-xml.mk b/openpower/package/palmetto-xml/palmetto-xml.mk
index 2592f1b..0c8f41d 100644
--- a/openpower/package/palmetto-xml/palmetto-xml.mk
+++ b/openpower/package/palmetto-xml/palmetto-xml.mk
@@ -11,11 +11,22 @@
 PALMETTO_XML_DEPENDENCIES = hostboot-install-images openpower-mrw-install-images common-p8-xml-install-images
 
 PALMETTO_XML_INSTALL_IMAGES = YES
-PALMETTO_XML_INSTALL_TARGET = NO
+PALMETTO_XML_INSTALL_TARGET = YES
 
 MRW_SCRATCH=$(STAGING_DIR)/openpower_mrw_scratch
 MRW_HB_TOOLS=$(STAGING_DIR)/hostboot_build_images
 
+# Defines for BIOS metadata creation
+BIOS_SCHEMA_FILE = $(MRW_HB_TOOLS)/bios.xsd
+PALMETTO_BIOS_XML_CONFIG_FILE = $(MRW_SCRATCH)/$(BR2_PALMETTO_BIOS_XML_FILENAME)
+BIOS_XML_METADATA_FILE = \
+    $(MRW_HB_TOOLS)/$(BR2_OPENPOWER_CONFIG_NAME)_bios_metadata.xml
+PETITBOOT_XSLT_FILE = $(MRW_HB_TOOLS)/bios_metadata_petitboot.xslt
+PETITBOOT_BIOS_XML_METADATA_FILE = \
+    $(MRW_HB_TOOLS)/$(BR2_OPENPOWER_CONFIG_NAME)_bios_metadata_petitboot.xml
+PETITBOOT_BIOS_XML_METADATA_INITRAMFS_FILE = \
+    $(TARGET_DIR)/usr/share/bios_metadata.xml
+
 define PALMETTO_XML_BUILD_CMDS
         # copy the palmetto xml where the common lives
         bash -c 'mkdir -p $(MRW_SCRATCH) && cp -r $(@D)/* $(MRW_SCRATCH)'
@@ -23,10 +34,7 @@
         # generate the system mrw xml
         perl -I $(MRW_HB_TOOLS) \
         $(MRW_HB_TOOLS)/processMrw.pl -x $(MRW_SCRATCH)/palmetto.xml
-endef
-
-define PALMETTO_XML_INSTALL_IMAGES_CMDS
-
+        
         # merge in any system specific attributes, hostboot attributes
         $(MRW_HB_TOOLS)/mergexml.sh $(MRW_SCRATCH)/$(BR2_PALMETTO_SYSTEM_XML_FILENAME) \
             $(MRW_HB_TOOLS)/attribute_types.xml \
@@ -41,9 +49,27 @@
             --fapi-attributes-xml-file=$(MRW_HB_TOOLS)/fapiattrs.xml \
             --src-output-dir=none \
             --img-output-dir=$(MRW_HB_TOOLS)/ \
-            --vmm-consts-file=$(MRW_HB_TOOLS)/vmmconst.h --noshort-enums
+            --vmm-consts-file=$(MRW_HB_TOOLS)/vmmconst.h --noshort-enums \
+            --bios-xml-file=$(PALMETTO_BIOS_XML_CONFIG_FILE) \
+            --bios-schema-file=$(BIOS_SCHEMA_FILE) \
+            --bios-output-file=$(BIOS_XML_METADATA_FILE)
 
+        # Transform BIOS XML into Petitboot specific BIOS XML via the schema
+        xsltproc -o \
+            $(PETITBOOT_BIOS_XML_METADATA_FILE) \
+            $(PETITBOOT_XSLT_FILE) \
+            $(BIOS_XML_METADATA_FILE)
+endef
+
+define PALMETTO_XML_INSTALL_IMAGES_CMDS
         mv $(MRW_HB_TOOLS)/targeting.bin $(MRW_HB_TOOLS)/$(BR2_OPENPOWER_TARGETING_BIN_FILENAME)
 endef
 
+define PALMETTO_XML_INSTALL_TARGET_CMDS
+        # Install Petitboot specific BIOS XML into initramfs's usr/share/ dir
+        $(INSTALL) -D -m 0644 \
+            $(PETITBOOT_BIOS_XML_METADATA_FILE) \
+            $(PETITBOOT_BIOS_XML_METADATA_INITRAMFS_FILE)
+endef
+
 $(eval $(generic-package))