From 26c198fd789aa058c84f1b2229e93aedd6a422ea Mon Sep 17 00:00:00 2001 From: Shakeeb Date: Fri, 26 Aug 2016 04:54:37 -0500 Subject: SBE code restructure: Set up tools directory Change-Id: I2ad810c3310a7b2ae0a1e1a57b3bd04ef7e9f256 RTC:159709 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/28836 Tested-by: Jenkins Server Tested-by: FSP CI Jenkins Reviewed-by: RAJA DAS Reviewed-by: Sachin Gupta --- sbe/tools/scripts/ppeParseAttrGetSetMacros.pl | 286 ++++++++++++++++++++++++++ 1 file changed, 286 insertions(+) create mode 100644 sbe/tools/scripts/ppeParseAttrGetSetMacros.pl (limited to 'sbe/tools/scripts/ppeParseAttrGetSetMacros.pl') diff --git a/sbe/tools/scripts/ppeParseAttrGetSetMacros.pl b/sbe/tools/scripts/ppeParseAttrGetSetMacros.pl new file mode 100644 index 00000000..8466f3c9 --- /dev/null +++ b/sbe/tools/scripts/ppeParseAttrGetSetMacros.pl @@ -0,0 +1,286 @@ +#!/usr/bin/perl +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: sbe/tools/scripts/ppeParseAttrGetSetMacros.pl $ +# +# OpenPOWER sbe Project +# +# Contributors Listed Below - COPYRIGHT 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 HWP Attribute XML files and +# initfile attr files and create the fapiGetInitFileAttr() function +# in a file called fapiAttributeService.C + +use strict; + +#------------------------------------------------------------------------------ +# Print Command Line Help +#------------------------------------------------------------------------------ +my $numArgs = $#ARGV + 1; +if ($numArgs < 3) +{ + print ("Usage: ppeParseAttrGetSetMacros.pl \n"); + print (" [ ...]\n"); + print (" -a [ ...]\n"); + print (" This perl script will parse if-attr files (containing the\n"); + print (" attributes used by the initfile) and attribute XML files\n"); + print (" (containing all HWPF attributes) and create the\n"); + print (" fapiGetInitFileAttr() function in a file called\n"); + print (" fapiAttributeService.C. Only the attributes specified in\n"); + print (" the if-attr files are supported. If no if-attr files are\n"); + print (" specified then all attributes are supported\n"); + exit(1); +} + +#------------------------------------------------------------------------------ +# Specify perl modules to use +#------------------------------------------------------------------------------ +use XML::Simple; +my $xml = new XML::Simple (KeyAttr=>[]); + +# Uncomment to enable debug output +#use Data::Dumper; + +#------------------------------------------------------------------------------ +# Open output file for writing +#------------------------------------------------------------------------------ +my $chipFile = $ARGV[0]; +$chipFile .= "/"; +$chipFile .= "proc_sbe_fixed_proc_chip.H"; +open(CHFILE, ">", $chipFile); + +my $exFile = $ARGV[0]; +$exFile .= "/"; +$exFile .= "proc_sbe_fixed_ex.H"; +open(EXFILE, ">", $exFile); + +my $coreFile = $ARGV[0]; +$coreFile .= "/"; +$coreFile .= "proc_sbe_fixed_core.H"; +open(COFILE, ">", $coreFile); + +my $eqFile = $ARGV[0]; +$eqFile .= "/"; +$eqFile .= "proc_sbe_fixed_eq.H"; +open(EQFILE, ">", $eqFile); + +my $pervFile = $ARGV[0]; +$pervFile .= "/"; +$pervFile .= "proc_sbe_fixed_perv.H"; +open(PEFILE, ">", $pervFile); + + +#------------------------------------------------------------------------------ +# Print Start of file information to fapiAttributeService.C +#------------------------------------------------------------------------------ +#print ASFILE "// proc_sbe_func.H\n"; +#print ASFILE "// This file is generated by perl script fapi2ParseProcSbeFixed.pl\n\n"; +#print ASFILE "#ifndef __PROC_SBE_FIXED_H__\n"; +#print ASFILE "#define __PROC_SBE_FIXED_H__\n"; +#print ASFILE "#include \"p9_sbe.H\"\n"; +#print ASFILE "#include \"plat_target_parms.H\"\n"; +#print ASFILE "#include \"fapi2AttributeIds.H\"\n\n"; + + +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 $argfile = $ARGV[1]; +my $entries = $xml->XMLin($argfile, ForceArray => ['entry']); +foreach my $entr (@{$entries->{entry}}) { + + 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 (2 .. $#ARGV) + { + my $infile = $ARGV[$argnum]; + + my $attributes = $xml->XMLin($infile, ForceArray => ['attribute']); + + # Uncomment to get debug output of all attributes + #print "\nFile: ", $infile, "\n", Dumper($attributes), "\n"; + + #-------------------------------------------------------------------------- + # For each Attribute + #-------------------------------------------------------------------------- + foreach my $attr (@{$attributes->{attribute}}) + { + + if($attr->{id} eq $inname) { + + #------------------------------------------------------------------ + # Check that the AttributeId exists + #------------------------------------------------------------------ + if (! exists $attr->{id}) + { + print ("ppeParseGetSetMacros.pl ERROR. Att 'id' missing\n"); + exit(1); + } + + if($attr->{targetType} eq "TARGET_TYPE_SYSTEM") { + + push(@attrSystemIds, $attr); + + } elsif($attr->{targetType} eq "TARGET_TYPE_PROC_CHIP") { + + push(@attrChipIds, $attr); + + } elsif($attr->{targetType} eq "TARGET_TYPE_CORE") { + + push(@attrCoreIds, $attr); + + } elsif($attr->{targetType} eq "TARGET_TYPE_EQ") { + + push(@attrEqIds, $attr); + + } elsif($attr->{targetType} eq "TARGET_TYPE_EX") { + + push(@attrExIds, $attr); + + } elsif($attr->{targetType} eq "TARGET_TYPE_PERV") { + +# push(@attrPervIds, $attr->{id}); + push(@attrPervIds, $attr); + + } else { + + print ("ppeParseAttrGetSetMacros.pl ERROR. Wrong attribute type: $attr->{targetType}\n"); + exit(1); + + } + + } + } + } +} + +print SYFILE "// proc_sbe_fixed_system.H\n"; +print SYFILE "// This file is generated by perl script ppeParseAttrGetSetMacros.pl\n\n"; +print SYFILE "#ifndef __PROC_SBE_FIXED_SYSTEM_H__\n"; +print SYFILE "#define __PROC_SBE_FIXED_SYSTEM_H__\n\n"; +foreach my $attr (@attrSystemIds) +{ + + my $value = uc $attr->{valueType}; + print SYFILE "PROC_SBE_FIXED_$value($attr->{id});\n" + + +} +print SYFILE "\n#endif // __PROC_SBE_FIXED_SYSTEM_H__"; + +print CHFILE "// proc_sbe_fixed_proc_chip.H\n"; +print CHFILE "// This file is generated by perl script ppeParseAttrGetSetMacros.pl\n\n"; +print CHFILE "#ifndef __PROC_SBE_FIXED_PROC_CHIP_H__\n"; +print CHFILE "#define __PROC_SBE_FIXED_PROC_CHIP_H__\n\n"; +foreach my $attr (@attrChipIds) +{ + + my $value = uc $attr->{valueType}; + print CHFILE "PROC_SBE_FIXED_$value($attr->{id});\n" + + +} +print CHFILE "\n#endif // __PROC_SBE_FIXED_PROC_CHIP_H__"; + +print EXFILE "// proc_sbe_fixed_ex.H\n"; +print EXFILE "// This file is generated by perl script ppeParseAttrGetSetMacros.pl\n\n"; +print EXFILE "#ifndef __PROC_SBE_FIXED_EX_H__\n"; +print EXFILE "#define __PROC_SBE_FIXED_EX_H__\n"; +foreach my $attr (@attrExIds) +{ + + my $value = uc $attr->{valueType}; + print EXFILE "PROC_SBE_FIXED_TARGET_$value($attr->{id}, EX_TARGET_COUNT);\n" + + +} +print EXFILE "\n#endif // __PROC_SBE_FIXED_EX_H__"; + +print COFILE "// proc_sbe_fixed_co.H\n"; +print COFILE "// This file is generated by perl script ppeParseAttrGetSetMacros.pl\n\n"; +print COFILE "#ifndef __PROC_SBE_FIXED_CO_H__\n"; +print COFILE "#define __PROC_SBE_FIXED_CO_H__\n"; +foreach my $attr (@attrCoreIds) +{ + + my $value = uc $attr->{valueType}; + print COFILE "PROC_SBE_FIXED_TARGET_$value($attr->{id}, CORE_TARGET_COUNT);\n" + + +} +print COFILE "\n#endif // __PROC_SBE_FIXED_CO_H__"; + +print EQFILE "// proc_sbe_fixed_eq.H\n"; +print EQFILE "// This file is generated by perl script ppeParseAttrGetSetMacros.pl\n\n"; +print EQFILE "#ifndef __PROC_SBE_FIXED_EQ_H__\n"; +print EQFILE "#define __PROC_SBE_FIXED_EQ_H__\n"; +foreach my $attr (@attrEqIds) +{ + + my $value = uc $attr->{valueType}; + print EQFILE "PROC_SBE_FIXED_TARGET_$value($attr->{id}, EQ_TARGET_COUNT);\n" + + +} +print EQFILE "\n#endif // __PROC_SBE_FIXED_EQ_H__"; + +print PEFILE "// proc_sbe_fixed_perv.H\n"; +print PEFILE "// This file is generated by perl script ppeParseAttrGetSetMacros.pl\n\n"; +print PEFILE "#ifndef __PROC_SBE_FIXED_PERV_H__\n"; +print PEFILE "#define __PROC_SBE_FIXED_PERV_H__\n"; +foreach my $attr (@attrPervIds) +{ + + my $value = uc $attr->{valueType}; + print PEFILE "PROC_SBE_FIXED_TARGET_$value($attr->{id}, PERV_TARGET_COUNT);\n" + + +} +print PEFILE "\n#endif // __PROC_SBE_FIXED_PERV_H__"; + +#print ASFILE "#endif // __PROC_SBE_FIXED_H__"; + +#------------------------------------------------------------------------------ +# Close output file +#------------------------------------------------------------------------------ +close(CHFILE); +close(COFILE); +close(EXFILE); +close(PEFILE); +close(EQFILE); + -- cgit v1.2.1