package/zaius-xml: add new package to hold Zaius MRW MXL

This points to my person repository for the moment until we can get
this package added to the open-power github repository.

Signed-off-by: Robert Lippert <rlippert@google.com>
diff --git a/openpower/package/Config.in b/openpower/package/Config.in
index 2f91c56..db58166 100755
--- a/openpower/package/Config.in
+++ b/openpower/package/Config.in
@@ -19,3 +19,4 @@
 source "$BR2_EXTERNAL_OP_BUILD_PATH/package/witherspoon-xml/Config.in"
 source "$BR2_EXTERNAL_OP_BUILD_PATH/package/ppe42-binutils/Config.in"
 source "$BR2_EXTERNAL_OP_BUILD_PATH/package/ppe42-gcc/Config.in"
+source "$BR2_EXTERNAL_OP_BUILD_PATH/package/zaius-xml/Config.in"
diff --git a/openpower/package/openpower-pnor/Config.in b/openpower/package/openpower-pnor/Config.in
index b39e3b8..3750609 100644
--- a/openpower/package/openpower-pnor/Config.in
+++ b/openpower/package/openpower-pnor/Config.in
@@ -7,6 +7,7 @@
         select BR2_PACKAGE_OPENPOWER_FFS
         select BR2_PACKAGE_OCC
         select BR2_PACKAGE_CAPP_UCODE
+        select BR2_PACKAGE_ZAIUS_XML if (BR2_OPENPOWER_XML_PACKAGE = "zaius-xml")
         select BR2_PACKAGE_WITHERSPOON_XML if (BR2_OPENPOWER_XML_PACKAGE = "witherspoon-xml")
         select BR2_PACKAGE_BARRELEYE_XML if (BR2_OPENPOWER_XML_PACKAGE = "barreleye-xml")
         select BR2_PACKAGE_FIRESTONE_XML if (BR2_OPENPOWER_XML_PACKAGE = "firestone-xml")
diff --git a/openpower/package/zaius-xml/Config.in b/openpower/package/zaius-xml/Config.in
new file mode 100755
index 0000000..b335ff3
--- /dev/null
+++ b/openpower/package/zaius-xml/Config.in
@@ -0,0 +1,23 @@
+config BR2_PACKAGE_ZAIUS_XML
+        bool "zaius_xml"
+        default y if (BR2_OPENPOWER_CONFIG_NAME = "zaius")
+        help
+            Utilities for building xml and the targeting binary image
+
+config BR2_ZAIUS_SYSTEM_XML_FILENAME
+        string "Zaius targeting system xml filename"
+        default ""
+        help
+            Defines the name of the system XML filename to be used when creating targeting binary image
+
+config BR2_ZAIUS_MRW_XML_FILENAME
+        string "Zaius targeting mrw xml filename"
+        default ""
+        help
+            Defines the name of the mrw XML filename to be used when creating targeting binary image
+
+config BR2_ZAIUS_BIOS_XML_FILENAME
+        string "Zaius 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/zaius-xml/zaius.mk b/openpower/package/zaius-xml/zaius.mk
new file mode 100644
index 0000000..1da69aa
--- /dev/null
+++ b/openpower/package/zaius-xml/zaius.mk
@@ -0,0 +1,77 @@
+################################################################################
+#
+# zaius_xml
+#
+################################################################################
+
+ZAIUS_XML_VERSION ?= e0cc4f8f9d983dbc1b762ca4cb6e6b95eb88ab76
+ZAIUS_XML_SITE ?= $(call github,rlippert,zaius-xml,$(ZAIUS_XML_VERSION))
+
+ZAIUS_XML_LICENSE = Apache-2.0
+ZAIUS_XML_DEPENDENCIES = hostboot-install-images openpower-mrw-install-images common-p8-xml-install-images
+
+ZAIUS_XML_INSTALL_IMAGES = YES
+ZAIUS_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
+ZAIUS_BIOS_XML_CONFIG_FILE = $(MRW_SCRATCH)/$(BR2_ZAIUS_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 ZAIUS_XML_BUILD_CMDS
+        # copy the zaius xml where the common lives
+        bash -c 'mkdir -p $(MRW_SCRATCH) && cp -r $(@D)/* $(MRW_SCRATCH)'
+
+        # generate the system mrw xml
+        perl -I $(MRW_HB_TOOLS) \
+        $(MRW_HB_TOOLS)/processMrw.pl -x $(MRW_SCRATCH)/zaius.xml
+
+        # merge in any system specific attributes, hostboot attributes
+        $(MRW_HB_TOOLS)/mergexml.sh $(MRW_SCRATCH)/$(BR2_ZAIUS_SYSTEM_XML_FILENAME) \
+            $(MRW_HB_TOOLS)/attribute_types.xml \
+            $(MRW_HB_TOOLS)/attribute_types_hb.xml \
+            $(MRW_HB_TOOLS)/attribute_types_oppowervm.xml \
+            $(MRW_HB_TOOLS)/target_types_merged.xml \
+            $(MRW_HB_TOOLS)/target_types_hb.xml \
+            $(MRW_HB_TOOLS)/target_types_oppowervm.xml \
+            $(MRW_SCRATCH)/$(BR2_ZAIUS_MRW_XML_FILENAME) > $(MRW_HB_TOOLS)/temporary_hb.hb.xml;
+
+        # creating the targeting binary
+        $(MRW_HB_TOOLS)/xmltohb.pl  \
+            --hb-xml-file=$(MRW_HB_TOOLS)/temporary_hb.hb.xml \
+            --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 \
+            --bios-xml-file=$(ZAIUS_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 ZAIUS_XML_INSTALL_IMAGES_CMDS
+        mv $(MRW_HB_TOOLS)/targeting.bin $(MRW_HB_TOOLS)/$(BR2_OPENPOWER_TARGETING_BIN_FILENAME)
+endef
+
+define ZAIUS_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))