Use nimbus targeting until processMrw changes for serverwiz2 are in
diff --git a/openpower/package/hostboot/p9Patches/hostboot-0004-target-pm-serverwiz1-and-2.patch b/openpower/package/hostboot/p9Patches/hostboot-0004-target-pm-serverwiz1-and-2.patch
new file mode 100644
index 0000000..0a15fc7
--- /dev/null
+++ b/openpower/package/hostboot/p9Patches/hostboot-0004-target-pm-serverwiz1-and-2.patch
@@ -0,0 +1,308 @@
+From 7afb20f3484eb118855d2033e7308cfc4a07fae3 Mon Sep 17 00:00:00 2001
+From: Norm James <njames@us.ibm.com>
+Date: Mon, 12 Sep 2016 18:47:13 -0700
+Subject: [PATCH] Add ability to read old and new Serverwiz xml outputs.
+
+The new Serverwiz format added outer tags for performance
+reasons.  It also added attribute groups for accessing
+like attributes with one API call.
+
+Change-Id: I6b6c6de8defbc5c0f0c8c7d191836e69ac7bfc98
+---
+ src/usr/targeting/common/Targets.pm | 157 +++++++++++++++++++++++++++++-------
+ 1 file changed, 126 insertions(+), 31 deletions(-)
+
+diff --git a/src/usr/targeting/common/Targets.pm b/src/usr/targeting/common/Targets.pm
+index 096db10..35f0842 100644
+--- a/src/usr/targeting/common/Targets.pm
++++ b/src/usr/targeting/common/Targets.pm
+@@ -26,6 +26,7 @@ package Targets;
+ 
+ use strict;
+ use XML::Simple;
++use XML::Parser;
+ use Data::Dumper;
+ 
+ sub new
+@@ -43,9 +44,10 @@ sub new
+         force        => 0,
+         debug        => 0,
+         version      => "",
++        xml_version  => 0,
+         errorsExist  => 0,
+         NUM_PROCS    => 0,
+-        TOP_LEVEL    => "sys-0",
++        TOP_LEVEL    => "",
+         TOPOLOGY     => undef,
+         report_log   => "",
+         vpd_num      => 0,
+@@ -87,9 +89,16 @@ sub loadXML
+     print "Loading MRW XML: $filename\n";
+     $self->{xml} =
+       XMLin($filename,forcearray => [ 'child_id', 'hidden_child_id', 'bus',
+-                                      'property' ]);
++                                      'property', 'field', 'attribute' ]);
++
++    if (defined($self->{xml}->{'enumerationTypes'}))
++    {
++          $self->{xml_version} = 1;
++    }
++
+     $self->storeEnumerations();
+-    $self->buildHierarchy($self->{TOP_LEVEL});
++    $self->storeGroups();
++    $self->buildHierarchy();
+     $self->buildAffinity();
+     $self->{report_filename}=$filename.".rpt";
+     $self->{report_filename}=~s/\.xml//g;
+@@ -230,15 +239,31 @@ sub printAttribute
+ sub storeEnumerations
+ {
+     my $self = shift;
+-
+-    foreach my $enumType (keys(%{ $self->{xml}->{enumerationType} }))
++    my $baseptr = $self->{xml}->{enumerationType};
++    if ($self->{xml_version} == 1)
++    {
++        $baseptr = $self->{xml}->{enumerationTypes}->{enumerationType};
++    }
++    foreach my $enumType (keys(%{ $baseptr }))
+     {
+         foreach my $enum (
+-            keys(%{$self->{xml}->{enumerationType}->{$enumType}->{enumerator}}))
++            keys(%{$baseptr->{$enumType}->{enumerator}}))
+         {
+             $self->{enumeration}->{$enumType}->{$enum} =
+-              $self->{xml}->{enumerationType}->{$enumType}->{enumerator}
+-              ->{$enum}->{value};
++              $baseptr->{$enumType}->{enumerator}->{$enum}->{value};
++        }
++    }
++}
++sub storeGroups
++{
++    my $self = shift;
++    foreach my $grp (keys(%{ $self->{xml}->{attributeGroups}
++        ->{attributeGroup} }))
++    {
++        foreach my $attr (@{$self->{xml}->{attributeGroups}
++            ->{attributeGroup}->{$grp}->{'attribute'}})
++        {
++            $self->{groups}->{$grp}->{$attr} = 1;
+         }
+     }
+ }
+@@ -277,13 +302,45 @@ sub buildHierarchy
+     my $self   = shift;
+     my $target = shift;
+ 
+-    my $old_path        = $self->{data}->{INSTANCE_PATH};
+-    my $target_xml      = $self->{xml}->{'targetInstance'}{$target};
++    my $instance_path = $self->{data}->{INSTANCE_PATH};
++    if (!defined $instance_path)
++    {
++        $instance_path = "";
++    }
++    my $baseptr = $self->{xml}->{'targetInstance'};
++    if ($self->{xml_version} == 1)
++    {
++        $baseptr = $self->{xml}->{'targetInstances'}->{'targetInstance'};
++    }
++    if ($target eq "")
++    {
++        ## find system target
++        foreach my $t (keys(%{$baseptr}))
++        {
++            if ($baseptr->{$t}->{attribute}->{TYPE}->{default} eq "SYS")
++            {
++                $self->{TOP_LEVEL} = $t;
++                $target = $t;
++            }
++        }
++    }
++    if ($target eq "")
++    {
++        die "Unable to find system top level target\n";
++    }
++    my $old_path        = $instance_path;
++    my $target_xml      = $baseptr->{$target};
+     my $affinity_target = $target;
+-    my $key             = $self->{data}->{INSTANCE_PATH} . "/" . $target;
++    my $key             = $instance_path . "/" . $target;
+ 
+-    my $instance_path = $self->{data}->{INSTANCE_PATH};
+-    $instance_path = "instance:" . substr($instance_path, 1);
++    if ($instance_path ne "")
++    {
++        $instance_path = "instance:" . substr($instance_path, 1);
++    }
++    else
++    {
++        $instance_path = "instance:";
++    }
+     $self->setAttribute($key, "INSTANCE_PATH", $instance_path);
+     $self->{data}->{TARGETS}->{$key}->{TARGET} = $target_xml;
+     $self->{data}->{INSTANCE_PATH} = $old_path . "/" . $target;
+@@ -321,9 +378,15 @@ sub buildHierarchy
+         }
+     }
+     ## global attributes overwrite local
+-    foreach my $prop (keys %{$self->{xml}->{globalSetting}->{$key}->{property}})
++    my $settingptr = $self->{xml}->{globalSetting};
++    if ($self->{xml_version} == 1)
+     {
+-        my $val=$self->{xml}->{globalSetting}->{$key}->{property}->
++        $settingptr = $self->{xml}->{globalSettings}->{globalSetting};
++    }
++
++    foreach my $prop (keys %{$settingptr->{$key}->{property}})
++    {
++        my $val=$settingptr->{$key}->{property}->
+                        {$prop}->{value};
+         $self->setAttribute($key, $prop, $val);
+     }
+@@ -413,8 +476,10 @@ sub buildAffinity
+             $node = -1;
+ 
+             $self->{targeting}{SYS}[0]{KEY} = $target;
+-            $self->setAttribute($target, "AFFINITY_PATH", "affinity:sys-0");
+-            $self->setAttribute($target, "PHYS_PATH",     "physical:sys-0");
++            $self->setAttribute($target, "AFFINITY_PATH",
++                                         "affinity:".$self->{TOP_LEVEL});
++            $self->setAttribute($target, "PHYS_PATH",
++                                         "physical:".$self->{TOP_LEVEL});
+             $self->setAttribute($target, "ENTITY_INSTANCE","0");
+         }
+         elsif ($type eq "NODE")
+@@ -424,13 +489,13 @@ sub buildAffinity
+             $self->{dimm_tpos} = 0;
+             $self->{membuf_inst_num}=0;
+             $node++;
+-            $node_phys = "physical:sys-0/node-$node";
+-            $node_aff  = "affinity:sys-0/node-$node";
++            $node_phys = "physical:".$self->{TOP_LEVEL}."/node-$node";
++            $node_aff  = "affinity:".$self->{TOP_LEVEL}."/node-$node";
+             $self->{targeting}{SYS}[0]{NODES}[$node]{KEY} = $target;
+             $self->setAttribute($target, "AFFINITY_PATH",
+-                "affinity:sys-0/node-$node");
++                "affinity:".$self->{TOP_LEVEL}."/node-$node");
+             $self->setAttribute($target, "PHYS_PATH",
+-                "physical:sys-0/node-$node");
++                "physical:".$self->{TOP_LEVEL}."/node-$node");
+             $self->setHuid($target, 0, $node);
+             $self->setAttribute($target, "ENTITY_INSTANCE",$node);
+         }
+@@ -439,9 +504,11 @@ sub buildAffinity
+             $tpm++;
+             $self->{targeting}{SYS}[0]{NODES}[$node]{TPMS}[$tpm]{KEY} = $target;
+             $self->setAttribute($target, "AFFINITY_PATH",
+-                                "affinity:sys-0/node-$node/tpm-$tpm");
++                                "affinity:".$self->{TOP_LEVEL}.
++                                "/node-$node/tpm-$tpm");
+             $self->setAttribute($target, "PHYS_PATH",
+-                                "physical:sys-0/node-$node/tpm-$tpm");
++                                "physical:".$self->{TOP_LEVEL}.
++                                "/node-$node/tpm-$tpm");
+             $self->setHuid($target, 0, $tpm);
+             $self->setAttribute($target, "ENTITY_INSTANCE",$tpm);
+         }
+@@ -469,8 +536,10 @@ sub buildAffinity
+             $self->setHuid($target, 0, $node);
+             my $socket = $self->getTargetParent(
+                          $self->getTargetParent($target));
+-            my $parent_affinity = "affinity:sys-0/node-$node/proc-$proc";
+-            my $parent_physical = "physical:sys-0/node-$node/proc-$proc";
++            my $parent_affinity = "affinity:".$self->{TOP_LEVEL}
++                                  ."/node-$node/proc-$proc";
++            my $parent_physical = "physical:".$self->{TOP_LEVEL}
++                                  ."/node-$node/proc-$proc";
+             $self->setAttribute($target, "AFFINITY_PATH",  $parent_affinity);
+             $self->setAttribute($target, "PHYS_PATH",      $parent_physical);
+             $self->setAttribute($target, "POSITION",       $proc);
+@@ -619,8 +688,6 @@ sub processMcs
+         $self->setFsiAttributes($membuf,"FSICM",0,$proc_path,$fsi_port,0);
+         $self->setAttribute($unit, "DMI_REFCLOCK_SWIZZLE",$fsi_port);
+         my $dmi_swizzle =
+-             $dmi_bus->{bus_attribute}->{DMI_REFCLOCK_SWIZZLE}->{default};
+-        my $dmi_swizzle =
+              $self->getBusAttribute($unit,0,"DMI_REFCLOCK_SWIZZLE");
+         if ($dmi_swizzle ne "")
+         {
+@@ -974,7 +1041,8 @@ sub isBadAttribute
+     {
+         return 1;
+     }
+-    if ($target_ptr->{ATTRIBUTES}->{$attribute}->{default} eq $badvalue)
++    if (defined $badvalue &&
++        $target_ptr->{ATTRIBUTES}->{$attribute}->{default} eq $badvalue)
+     {
+         return 1;
+     }
+@@ -1029,7 +1097,6 @@ sub getAttribute
+         printf("ERROR: getAttribute(%s,%s) | Attribute not defined\n",
+             $target, $attribute);
+ 
+-        #print Dumper($target_ptr);
+         $self->myExit(4);
+     }
+     if (ref($target_ptr->{ATTRIBUTES}->{$attribute}->{default}) eq "HASH")
+@@ -1038,6 +1105,30 @@ sub getAttribute
+     }
+     return $target_ptr->{ATTRIBUTES}->{$attribute}->{default};
+ }
++
++sub getAttributeGroup
++{
++    my $self       = shift;
++    my $target     = shift;
++    my $group      = shift;
++    my $target_ptr = $self->getTarget($target);
++    if (!defined($self->{groups}->{$group})) {
++        printf("ERROR: getAttributeGroup(%s,%s) | Group not defined\n",
++            $target, $group);
++        $self->myExit(4);
++    }
++    my %attr;
++    foreach my $attribute (keys(%{$self->{groups}->{$group}}))
++    {
++        if (defined($target_ptr->{ATTRIBUTES}->{$attribute}->{default}))
++        {
++            $attr{$attribute} = $target_ptr->{ATTRIBUTES}->{$attribute};
++        }
++    }
++    return \%attr;
++}
++
++
+ ## renames a target attribute
+ sub renameAttribute
+ {
+@@ -1141,6 +1232,8 @@ sub getBusAttribute
+     return $target_ptr->{CONNECTION}->{BUS}->[$busnum]->{bus_attribute}->{$attr}
+       ->{default};
+ }
++
++
+ ## returns a pointer to an array of children target names
+ sub getTargetChildren
+ {
+@@ -1216,7 +1309,10 @@ sub setMruid
+ 
+     my $type          = $self->getType($target);
+     my $mru_prefix_id = $self->{enumeration}->{MRU_PREFIX}->{$type};
+-    if ($mru_prefix_id eq "") { $mru_prefix_id = "0xFFFF"; }
++    if (!defined $mru_prefix_id || $mru_prefix_id eq "")
++    {
++         $mru_prefix_id = "0xFFFF";
++    }
+     if ($mru_prefix_id eq "0xFFFF") { return; }
+     my $index = 0;
+     if (defined($self->{mru_idx}->{$node}->{$type}))
+@@ -1486,4 +1582,3 @@ Prints to stdout log message is debug mode is turned on.
+ Norman James <njames@us.ibm.com>
+ 
+ =cut
+-
+-- 
+1.8.2.2
+
diff --git a/openpower/package/hostboot/p9Patches/hostboot-0005-add-nimbus-simics-xml.patch b/openpower/package/hostboot/p9Patches/hostboot-0005-add-nimbus-simics-xml.patch
new file mode 100644
index 0000000..f2f7d0b
--- /dev/null
+++ b/openpower/package/hostboot/p9Patches/hostboot-0005-add-nimbus-simics-xml.patch
@@ -0,0 +1,27 @@
+From 56e613d9e7cb2ef6cc1ab0adfae691cfcbdcf9e5 Mon Sep 17 00:00:00 2001
+From: Matt Ploetz <maploetz@us.ibm.com>
+Date: Wed, 28 Sep 2016 17:06:31 -0500
+Subject: [PATCH] Add nimbus simics xml to openPower until processMrw changes
+ are in
+
+Change-Id: Iac895ed08b7e182301e223d45ce064715e459723
+RTC:143114
+---
+ src/build/mkrules/dist.targets.mk | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/build/mkrules/dist.targets.mk b/src/build/mkrules/dist.targets.mk
+index ecd4b58..0e2434c 100644
+--- a/src/build/mkrules/dist.targets.mk
++++ b/src/build/mkrules/dist.targets.mk
+@@ -81,6 +81,7 @@ COPY_FILES = \
+     src/usr/targeting/common/xmltohb/attribute_types.xml:openpower \
+     src/usr/targeting/common/xmltohb/attribute_types_hb.xml:openpower \
+     src/usr/targeting/common/xmltohb/target_types_hb.xml:openpower \
++    src/usr/targeting/common/xmltohb/simics_NIMBUS.system.xml:openpower \
+     src/usr/targeting/common/xmltohb/xmltohb.pl:openpower \
+     src/usr/targeting/xmltohb/updatetempsxml.pl:openpower \
+     src/include/usr/vmmconst.h:openpower \
+-- 
+1.8.2.2
+
diff --git a/openpower/package/witherspoon-xml/witherspoon.mk b/openpower/package/witherspoon-xml/witherspoon.mk
index 42d892a..1d53545 100644
--- a/openpower/package/witherspoon-xml/witherspoon.mk
+++ b/openpower/package/witherspoon-xml/witherspoon.mk
@@ -4,7 +4,7 @@
 #
 ################################################################################
 
-WITHERSPOON_XML_VERSION ?= 8625696cf60951885b9af780027aa7d047b63949
+WITHERSPOON_XML_VERSION ?= 166b3135edbc7299aaa991a42f6eb0fc40d784e6
 WITHERSPOON_XML_SITE ?= $(call github,open-power,witherspoon-xml,$(WITHERSPOON_XML_VERSION))
 
 WITHERSPOON_XML_LICENSE = Apache-2.0
@@ -32,9 +32,13 @@
         bash -c 'mkdir -p $(MRW_SCRATCH) && cp -r $(@D)/* $(MRW_SCRATCH)'
 
         # generate the system mrw xml
-        perl -I $(MRW_HB_TOOLS) \
+        #perl -I $(MRW_HB_TOOLS) \
         $(MRW_HB_TOOLS)/processMrw.pl -x $(MRW_SCRATCH)/witherspoon.xml
         
+        # copy local simics_NIMBUS xml until processMrw changes are in
+        # RTC: 143114
+        cp $(MRW_HB_TOOLS)/simics_NIMBUS.system.xml $(MRW_SCRATCH)/$(BR2_WITHERSPOON_SYSTEM_XML_FILENAME)
+
         # merge in any system specific attributes, hostboot attributes
         $(MRW_HB_TOOLS)/mergexml.sh $(MRW_SCRATCH)/$(BR2_WITHERSPOON_SYSTEM_XML_FILENAME) \
             $(MRW_HB_TOOLS)/attribute_types.xml \