From 629873b2b5a5bf45573c7bf08b13eb6234062a17 Mon Sep 17 00:00:00 2001 From: Martin Peschke Date: Wed, 17 Aug 2016 14:40:32 +0200 Subject: move ppeSetFixed.pl from tools/image to tools/scripts Change-Id: I15e6437594542285fc1ecc3d64165c04fd70d888 RTC: 157865 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/28376 Tested-by: Jenkins Server Tested-by: FSP CI Jenkins Reviewed-by: Prachi Gupta Reviewed-by: Claus M. Olsen Reviewed-by: Martin Peschke --- sbe/image/Makefile | 2 +- tools/image/ppeSetFixed.pl | 260 ------------------------------------------- tools/scripts/ppeSetFixed.pl | 259 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 260 insertions(+), 261 deletions(-) delete mode 100755 tools/image/ppeSetFixed.pl create mode 100755 tools/scripts/ppeSetFixed.pl diff --git a/sbe/image/Makefile b/sbe/image/Makefile index 5ed60626..721a662d 100644 --- a/sbe/image/Makefile +++ b/sbe/image/Makefile @@ -306,7 +306,7 @@ normalize: $(P9_XIP_TOOL) $(OBJDIR)/$(IMAGE_SEEPROM_NAME).bin $(P9_XIP_TOOL) $(OBJDIR)/$(IMAGE_SEEPROM_NAME).bin normalize defaultset: $(SBE_TOOLS) $(OBJDIR)/$(IMAGE_SEEPROM_NAME).bin normalize - $(TOOLS_IMAGE_DIR)/ppeSetFixed.pl $(TOOLS_IMAGE_DIR) $(BASE_OBJDIR)/$(IMAGE_SEEPROM_NAME).bin $(IMPORT_XML_DIR)/attribute_info/p9_sbe_attributes.xml $(ATTRFILES) + $(TOOLS_ATTR_DIR)/ppeSetFixed.pl $(TOOLS_IMAGE_DIR) $(BASE_OBJDIR)/$(IMAGE_SEEPROM_NAME).bin $(IMPORT_XML_DIR)/attribute_info/p9_sbe_attributes.xml $(ATTRFILES) # Build the trace utilities ppe_trace_bin: diff --git a/tools/image/ppeSetFixed.pl b/tools/image/ppeSetFixed.pl deleted file mode 100755 index 701e73e9..00000000 --- a/tools/image/ppeSetFixed.pl +++ /dev/null @@ -1,260 +0,0 @@ -#!/usr/bin/perl -# IBM_PROLOG_BEGIN_TAG -# This is an automatically generated prolog. -# -# $Source: tools/image/ppeSetFixed.pl $ -# -# OpenPOWER sbe Project -# -# Contributors Listed Below - COPYRIGHT 2015,2016 -# [+] International Business Machines Corp. -# -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. See the License for the specific language governing -# permissions and limitations under the License. -# -# IBM_PROLOG_END_TAG -# Purpose: This perl script will parse the attribute and default list and -# and set the default values into the image. - -use strict; - -my $attrpath = "../../importtemp/xml"; -my $sbedefaultpath = "../../script/image"; - -#------------------------------------------------------------------------------ -# Print Command Line Help -#------------------------------------------------------------------------------ -my $numArgs = $#ARGV + 1; -if ($numArgs < 3) -{ - print ("Usage: ppeSetFixed.pl ...\n"); - print (" This perl script will the attributes and default list to lookup the defaults\n"); - print (" and parse the attribute file to lookup the types.\n"); - print (" The default values will be set in the image.\n"); - print ("example:\n"); - print ("./ppeSetFixed.pl \\\n" ); - print (". \\\n" ); - print (" ../../sbe/obj/seeprom_main.bin \\\n" ); - print ("$attrpath/p9_ppe_attributes.xml \\\n" ); - print ("$attrpath/attribute_info/perv_attributes.xml \\\n" ); - print ("$attrpath/attribute_info/proc_attributes.xml \\\n" ); - print ("$attrpath/attribute_info/ex_attributes.xml \\\n" ); - print ("$attrpath/attribute_info/eq_attributes.xml \\\n" ); - print ("$attrpath/attribute_info/core_attributes.xml \\ \n"); - print ("$attrpath/attribute_info/nest_attributes.xml \n"); - exit(1); -} - -#------------------------------------------------------------------------------ -# Specify perl modules to use -#------------------------------------------------------------------------------ -use XML::Simple; -my $xml = new XML::Simple (KeyAttr=>[]); - - -my $xmlFiles = 0; -my $attCount = 0; -my $numIfAttrFiles = 0; -my @attrSystemIds; -my @attrChipIds; -my @attrExIds; -my @attrCoreIds; -my @attrEqIds; -my @attrPervIds; - - - -#------------------------------------------------------------------------------ -# Element names -#------------------------------------------------------------------------------ -my $attribute = 'attribute'; - -#------------------------------------------------------------------------------ -# For each argument -#------------------------------------------------------------------------------ -my $sbedefaultpath = $ARGV[0]; -my $image = $ARGV[1]; -my $argfile = $ARGV[2]; -my $entries = $xml->XMLin($argfile, ForceArray => ['entry']); - -if ( ! -e $image) {die "ppeSetFixed.pl: $image $!"}; - -foreach my $entr (@{$entries->{entry}}) { - - # Skip virtual attributes - if(exists $entr->{virtual}) - { - next; - } - - my $inname = $entr->{name}; - - # read XML file. The ForceArray option ensures that there is an array of - # elements even if there is only one such element in the file - - foreach my $argnum (3 .. $#ARGV) - { - my $infile = $ARGV[$argnum]; - - if ( ! -e $infile) {die "ppeSetFixed.pl: $infile $!"}; - - my $attributes = $xml->XMLin($infile, ForceArray => ['attribute']); - - #-------------------------------------------------------------------------- - # For each Attribute - #-------------------------------------------------------------------------- - foreach my $attr (@{$attributes->{attribute}}) - { - if($attr->{id} eq $inname) { - - #------------------------------------------------------------------ - # Check that the AttributeId exists - #------------------------------------------------------------------ - if (! exists $attr->{id}) - { - print ("ppeSbeFixed.pl ERROR. Att 'id' missing\n"); - exit(1); - } - - my @targets = split(",", $attr->{targetType}); - - my $targetTypeMatched = 0; - - foreach my $target (@targets) - { - if($target eq "TARGET_TYPE_SYSTEM") { - - push(@attrSystemIds, $entr); - $targetTypeMatched = 1; - last; - - } elsif($target eq "TARGET_TYPE_PROC_CHIP") { - - push(@attrChipIds, $entr); - $targetTypeMatched = 1; - last; - - } elsif($target eq "TARGET_TYPE_CORE") { - - push(@attrCoreIds, $entr); - $targetTypeMatched = 1; - last; - - } elsif($target eq "TARGET_TYPE_EQ") { - - push(@attrEqIds, $entr); - $targetTypeMatched = 1; - last; - - } elsif($target eq "TARGET_TYPE_EX") { - - push(@attrExIds, $entr); - $targetTypeMatched = 1; - last; - - } elsif($target eq "TARGET_TYPE_PERV") { - - push(@attrPervIds, $entr); - $targetTypeMatched = 1; - last; - - } else { - - print ("ppeSetFixed.pl WARNING. Ignoring unsupported". - " target type: $target for attribute: $inname\n"); - next; - - } - } - if($targetTypeMatched eq 0) - { - print ("ppeSetFixed.pl ERROR. No matching target type ". - "found for attribute: $inname\n"); - exit(1); - } - - } - } - } -} - - -setFixed("TARGET_TYPE_SYSTEM", @attrSystemIds); -setFixed("TARGET_TYPE_PROC_CHIP", @attrChipIds); -setFixed("TARGET_TYPE_CORE", @attrCoreIds); -setFixed("TARGET_TYPE_EQ", @attrEqIds); -setFixed("TARGET_TYPE_EX", @attrExIds); -setFixed("TARGET_TYPE_PERV", @attrPervIds); - - - -sub setFixed { - - my ($string, @entries) = @_; - - foreach my $attr (@entries) - { - - my $inname = $attr->{name}; - - my @values = $attr->{value}; - - - if(scalar @values > 0) { - foreach my $val (@values) - { - - if(defined $val && ref($val) eq "") { - - if ($val =~ /(0x)?[0-9a-fA-F]+/) { - - my $systemRc = system("$sbedefaultpath/sbe_default_tool $image $inname $val $string 0"); - - if ($systemRc) { - print "sbe_default_tool: error in execution\n"; - exit 1; - } - - } else { - print ("ppeSetFixed.pl ERROR. not hex\n"); - exit(1); - } - - } elsif(defined $val && ref($val) eq "ARRAY") { - - my $index = 0; - - foreach my $arr (@{$val}) { - - if(defined $arr && ref($arr) eq "") { - if ($arr =~ /(0x)?[0-9a-fA-F]+/) { - - my $systemRc = system("$sbedefaultpath/sbe_default_tool $image $inname $arr $string $index"); - - if ($systemRc) { - print "sbe_default_tool: error in execution\n"; - exit 1; - } - - - } - } - $index++; - } - } - } - } - } -} - - diff --git a/tools/scripts/ppeSetFixed.pl b/tools/scripts/ppeSetFixed.pl new file mode 100755 index 00000000..aba25973 --- /dev/null +++ b/tools/scripts/ppeSetFixed.pl @@ -0,0 +1,259 @@ +#!/usr/bin/perl +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: tools/scripts/ppeSetFixed.pl $ +# +# OpenPOWER sbe Project +# +# Contributors Listed Below - COPYRIGHT 2015,2016 +# +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. +# +# IBM_PROLOG_END_TAG +# Purpose: This perl script will parse the attribute and default list and +# and set the default values into the image. + +use strict; + +my $attrpath = "../../importtemp/xml"; +my $sbedefaultpath = "../../script/image"; + +#------------------------------------------------------------------------------ +# Print Command Line Help +#------------------------------------------------------------------------------ +my $numArgs = $#ARGV + 1; +if ($numArgs < 3) +{ + print ("Usage: ppeSetFixed.pl ...\n"); + print (" This perl script will the attributes and default list to lookup the defaults\n"); + print (" and parse the attribute file to lookup the types.\n"); + print (" The default values will be set in the image.\n"); + print ("example:\n"); + print ("./ppeSetFixed.pl \\\n" ); + print (". \\\n" ); + print (" ../../sbe/obj/seeprom_main.bin \\\n" ); + print ("$attrpath/p9_ppe_attributes.xml \\\n" ); + print ("$attrpath/attribute_info/perv_attributes.xml \\\n" ); + print ("$attrpath/attribute_info/proc_attributes.xml \\\n" ); + print ("$attrpath/attribute_info/ex_attributes.xml \\\n" ); + print ("$attrpath/attribute_info/eq_attributes.xml \\\n" ); + print ("$attrpath/attribute_info/core_attributes.xml \\ \n"); + print ("$attrpath/attribute_info/nest_attributes.xml \n"); + exit(1); +} + +#------------------------------------------------------------------------------ +# Specify perl modules to use +#------------------------------------------------------------------------------ +use XML::Simple; +my $xml = new XML::Simple (KeyAttr=>[]); + + +my $xmlFiles = 0; +my $attCount = 0; +my $numIfAttrFiles = 0; +my @attrSystemIds; +my @attrChipIds; +my @attrExIds; +my @attrCoreIds; +my @attrEqIds; +my @attrPervIds; + + + +#------------------------------------------------------------------------------ +# Element names +#------------------------------------------------------------------------------ +my $attribute = 'attribute'; + +#------------------------------------------------------------------------------ +# For each argument +#------------------------------------------------------------------------------ +my $sbedefaultpath = $ARGV[0]; +my $image = $ARGV[1]; +my $argfile = $ARGV[2]; +my $entries = $xml->XMLin($argfile, ForceArray => ['entry']); + +if ( ! -e $image) {die "ppeSetFixed.pl: $image $!"}; + +foreach my $entr (@{$entries->{entry}}) { + + # Skip virtual attributes + if(exists $entr->{virtual}) + { + next; + } + + my $inname = $entr->{name}; + + # read XML file. The ForceArray option ensures that there is an array of + # elements even if there is only one such element in the file + + foreach my $argnum (3 .. $#ARGV) + { + my $infile = $ARGV[$argnum]; + + if ( ! -e $infile) {die "ppeSetFixed.pl: $infile $!"}; + + my $attributes = $xml->XMLin($infile, ForceArray => ['attribute']); + + #-------------------------------------------------------------------------- + # For each Attribute + #-------------------------------------------------------------------------- + foreach my $attr (@{$attributes->{attribute}}) + { + if($attr->{id} eq $inname) { + + #------------------------------------------------------------------ + # Check that the AttributeId exists + #------------------------------------------------------------------ + if (! exists $attr->{id}) + { + print ("ppeSbeFixed.pl ERROR. Att 'id' missing\n"); + exit(1); + } + + my @targets = split(",", $attr->{targetType}); + + my $targetTypeMatched = 0; + + foreach my $target (@targets) + { + if($target eq "TARGET_TYPE_SYSTEM") { + + push(@attrSystemIds, $entr); + $targetTypeMatched = 1; + last; + + } elsif($target eq "TARGET_TYPE_PROC_CHIP") { + + push(@attrChipIds, $entr); + $targetTypeMatched = 1; + last; + + } elsif($target eq "TARGET_TYPE_CORE") { + + push(@attrCoreIds, $entr); + $targetTypeMatched = 1; + last; + + } elsif($target eq "TARGET_TYPE_EQ") { + + push(@attrEqIds, $entr); + $targetTypeMatched = 1; + last; + + } elsif($target eq "TARGET_TYPE_EX") { + + push(@attrExIds, $entr); + $targetTypeMatched = 1; + last; + + } elsif($target eq "TARGET_TYPE_PERV") { + + push(@attrPervIds, $entr); + $targetTypeMatched = 1; + last; + + } else { + + print ("ppeSetFixed.pl WARNING. Ignoring unsupported". + " target type: $target for attribute: $inname\n"); + next; + + } + } + if($targetTypeMatched eq 0) + { + print ("ppeSetFixed.pl ERROR. No matching target type ". + "found for attribute: $inname\n"); + exit(1); + } + + } + } + } +} + + +setFixed("TARGET_TYPE_SYSTEM", @attrSystemIds); +setFixed("TARGET_TYPE_PROC_CHIP", @attrChipIds); +setFixed("TARGET_TYPE_CORE", @attrCoreIds); +setFixed("TARGET_TYPE_EQ", @attrEqIds); +setFixed("TARGET_TYPE_EX", @attrExIds); +setFixed("TARGET_TYPE_PERV", @attrPervIds); + + + +sub setFixed { + + my ($string, @entries) = @_; + + foreach my $attr (@entries) + { + + my $inname = $attr->{name}; + + my @values = $attr->{value}; + + + if(scalar @values > 0) { + foreach my $val (@values) + { + + if(defined $val && ref($val) eq "") { + + if ($val =~ /(0x)?[0-9a-fA-F]+/) { + + my $systemRc = system("$sbedefaultpath/sbe_default_tool $image $inname $val $string 0"); + + if ($systemRc) { + print "sbe_default_tool: error in execution\n"; + exit 1; + } + + } else { + print ("ppeSetFixed.pl ERROR. not hex\n"); + exit(1); + } + + } elsif(defined $val && ref($val) eq "ARRAY") { + + my $index = 0; + + foreach my $arr (@{$val}) { + + if(defined $arr && ref($arr) eq "") { + if ($arr =~ /(0x)?[0-9a-fA-F]+/) { + + my $systemRc = system("$sbedefaultpath/sbe_default_tool $image $inname $arr $string $index"); + + if ($systemRc) { + print "sbe_default_tool: error in execution\n"; + exit 1; + } + + + } + } + $index++; + } + } + } + } + } +} + + -- cgit v1.2.1