From 3d300befe268bde97200b2aa0f5e391da000e58c Mon Sep 17 00:00:00 2001 From: Santosh Puranik Date: Fri, 17 Jun 2016 05:26:41 -0500 Subject: Support EC feature attributes Change-Id: I045dc6cda8d9d5237caef24b62cbe89405121d15 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/25978 Tested-by: Jenkins Server Reviewed-by: Sachin Gupta Reviewed-by: Gregory S. Still Reviewed-by: Santosh S. Puranik --- tools/image/ppeSetFixed.pl | 89 +++- tools/scripts/ppeParseAttributeInfo.pl | 608 ++++++-------------------- tools/scripts/ppeParseProcSbeFixed.pl | 86 +++- tools/scripts/src/fapi2PlatAttributeService.H | 28 +- 4 files changed, 309 insertions(+), 502 deletions(-) (limited to 'tools') diff --git a/tools/image/ppeSetFixed.pl b/tools/image/ppeSetFixed.pl index def03f5f..701e73e9 100755 --- a/tools/image/ppeSetFixed.pl +++ b/tools/image/ppeSetFixed.pl @@ -1,4 +1,28 @@ #!/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. @@ -67,6 +91,12 @@ 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 @@ -96,36 +126,63 @@ foreach my $entr (@{$entries->{entry}}) { exit(1); } - if($attr->{targetType} eq "TARGET_TYPE_SYSTEM") { + my @targets = split(",", $attr->{targetType}); - push(@attrSystemIds, $entr); + my $targetTypeMatched = 0; - } elsif($attr->{targetType} eq "TARGET_TYPE_PROC_CHIP") { + foreach my $target (@targets) + { + if($target eq "TARGET_TYPE_SYSTEM") { - push(@attrChipIds, $entr); + push(@attrSystemIds, $entr); + $targetTypeMatched = 1; + last; - } elsif($attr->{targetType} eq "TARGET_TYPE_CORE") { + } elsif($target eq "TARGET_TYPE_PROC_CHIP") { - push(@attrCoreIds, $entr); + push(@attrChipIds, $entr); + $targetTypeMatched = 1; + last; - } elsif($attr->{targetType} eq "TARGET_TYPE_EQ") { + } elsif($target eq "TARGET_TYPE_CORE") { - push(@attrEqIds, $entr); + push(@attrCoreIds, $entr); + $targetTypeMatched = 1; + last; - } elsif($attr->{targetType} eq "TARGET_TYPE_EX") { + } elsif($target eq "TARGET_TYPE_EQ") { - push(@attrExIds, $entr); + push(@attrEqIds, $entr); + $targetTypeMatched = 1; + last; - } elsif($attr->{targetType} eq "TARGET_TYPE_PERV") { + } elsif($target eq "TARGET_TYPE_EX") { - push(@attrPervIds, $entr); + push(@attrExIds, $entr); + $targetTypeMatched = 1; + last; - } else { + } elsif($target eq "TARGET_TYPE_PERV") { - print ("ppeSetFixed.pl ERROR. Wrong attribute type: $attr->{targetType}\n"); - exit(1); + 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); + } + } } } @@ -142,7 +199,7 @@ setFixed("TARGET_TYPE_PERV", @attrPervIds); sub setFixed { - + my ($string, @entries) = @_; foreach my $attr (@entries) diff --git a/tools/scripts/ppeParseAttributeInfo.pl b/tools/scripts/ppeParseAttributeInfo.pl index 1ad5ba91..b137a9b0 100755 --- a/tools/scripts/ppeParseAttributeInfo.pl +++ b/tools/scripts/ppeParseAttributeInfo.pl @@ -1,4 +1,28 @@ #!/usr/bin/perl -w +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: tools/scripts/ppeParseAttributeInfo.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 HWP Attribute XML files # and add attribute information to a file called fapi2AttributeIds.H @@ -56,7 +80,7 @@ if ($DEBUG) } # Uncomment to enable debug output -#use Data::Dumper; +# use Data::Dumper; #------------------------------------------------------------------------------ # Set PREFERRED_PARSER to XML::Parser. Otherwise it uses XML::SAX which contains @@ -73,10 +97,10 @@ $aiFile .= "/"; $aiFile .= "fapi2AttributeIds.H"; open(AIFILE, ">", $aiFile); -my $ecFile = $ARGV[0]; -$ecFile .= "/"; -$ecFile .= "fapi2ChipEcFeature.C"; -open(ECFILE, ">", $ecFile); +my $echFile = $ARGV[0]; +$echFile .= "/"; +$echFile .= "fapi2ChipEcFeature.H"; +open(ECHFILE, ">", $echFile); my $acFile = $ARGV[0]; $acFile .= "/"; @@ -116,52 +140,43 @@ print AIFILE " *\/\n"; print AIFILE "enum AttributeId\n{\n"; #------------------------------------------------------------------------------ -# Print Start of file information to fapiChipEcFeature.C -#------------------------------------------------------------------------------ -print ECFILE "// fapiChipEcFeature.C\n"; -print ECFILE "// This file is generated by perl script fapiParseAttributeInfo.pl\n"; -print ECFILE "// It implements the fapiQueryChipEcFeature function\n\n"; -print ECFILE "#include \n"; -print ECFILE "#include \n"; -print ECFILE "#include \n"; -print ECFILE "#include \n\n"; -print ECFILE "namespace fapi2\n"; -print ECFILE "{\n\n"; -print ECFILE "fapi::ReturnCode fapiQueryChipEcFeature(fapi::AttributeId i_id,\n"; -print ECFILE " const fapi::Target * i_pTarget,\n"; -print ECFILE " uint8_t & o_hasFeature)\n"; -print ECFILE "{\n"; -print ECFILE " o_hasFeature = false;\n"; -print ECFILE " fapi::ReturnCode l_rc;\n"; -print ECFILE " uint8_t l_chipName = 0;\n"; -print ECFILE " uint8_t l_chipEc = 0;\n"; -print ECFILE " fapi::Target l_target = *i_pTarget;\n\n"; -print ECFILE " if (i_pTarget->isChiplet())\n"; -print ECFILE " {\n"; -print ECFILE " l_rc = fapiGetParentChip(*i_pTarget, l_target);\n\n"; -print ECFILE " if (l_rc)\n"; -print ECFILE " {\n"; -print ECFILE " FAPI_ERR(\"fapiQueryChipEcFeature: error getting parent chip\");\n"; -print ECFILE " }\n"; -print ECFILE " }\n\n"; -print ECFILE " if (!l_rc)\n"; -print ECFILE " {\n"; -print ECFILE " l_rc = FAPI_ATTR_GET_PRIVILEGED(ATTR_NAME, &l_target, l_chipName);\n\n"; -print ECFILE " if (l_rc)\n"; -print ECFILE " {\n"; -print ECFILE " FAPI_ERR(\"fapiQueryChipEcFeature: error getting chip name\");\n"; -print ECFILE " }\n"; -print ECFILE " else\n"; -print ECFILE " {\n"; -print ECFILE " l_rc = FAPI_ATTR_GET_PRIVILEGED(ATTR_EC, &l_target, l_chipEc);\n\n"; -print ECFILE " if (l_rc)\n"; -print ECFILE " {\n"; -print ECFILE " FAPI_ERR(\"fapiQueryChipEcFeature: error getting chip ec\");\n"; -print ECFILE " }\n"; -print ECFILE " else\n"; -print ECFILE " {\n"; -print ECFILE " switch (i_id)\n"; -print ECFILE " {\n"; +# Print Start of file information to fapi2_chip_ec_feature.H +#------------------------------------------------------------------------------ +print ECHFILE "// This file is generated by perl script parseAttributeInfo.pl\n"; +print ECHFILE "// It implements the fapi2_chip_ec_feature function\n\n"; +print ECHFILE "#ifndef __FAPI2_CHIP_EC_FEATURE_H_\n"; +print ECHFILE "#define __FAPI2_CHIP_EC_FEATURE_H_\n"; +print ECHFILE "#include \n"; +print ECHFILE "#include \n"; +print ECHFILE "namespace fapi2\n"; +print ECHFILE "{\n\n"; +print ECHFILE "// create a unique type from an int ( or attribute id) \n"; +print ECHFILE "template\n"; +print ECHFILE "struct int2Type {\n"; +print ECHFILE "enum { value = I };\n"; +print ECHFILE "};\n"; +print ECHFILE "ReturnCode queryChipEcAndName(\n"; +print ECHFILE " const Target& i_target,\n"; +print ECHFILE " fapi2::ATTR_NAME_Type& , fapi2::ATTR_EC_Type & );\n\n"; +print ECHFILE "template\n"; +print ECHFILE "ReturnCode queryChipEcFeature(int2Type id,\n"; +print ECHFILE " const Target& i_target,\n"; +print ECHFILE " uint8_t & o_hasFeature)\n"; +print ECHFILE "{\n"; +print ECHFILE " fapi2::ATTR_NAME_Type l_chipName;\n"; +print ECHFILE " fapi2::ATTR_EC_Type l_chipEc;\n\n"; +print ECHFILE " o_hasFeature = 0;\n\n"; +print ECHFILE " ReturnCode l_rc = queryChipEcAndName(i_target, l_chipName, l_chipEc);\n"; +print ECHFILE " if (l_rc)\n"; +print ECHFILE " {\n"; +print ECHFILE " FAPI_ERR(\"queryChipEcFeature: error getting chip name\");\n"; +print ECHFILE " }\n"; +print ECHFILE " else\n"; +print ECHFILE " {\n"; +print ECHFILE " o_hasFeature = hasFeature(int2Type(), l_chipName, l_chipEc);\n"; +print ECHFILE " }\n"; +print ECHFILE " return l_rc;\n"; +print ECHFILE "}\n\n"; #------------------------------------------------------------------------------ # Print Start of file information to fapiAttributePlatCheck.H @@ -228,7 +243,7 @@ foreach my $entr (@{$entries->{entry}}) { # 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 - my $attributes = $xml->XMLin($infile, ForceArray => ['attribute']); + my $attributes = $xml->XMLin($infile, ForceArray => ['attribute', 'chip']); if ($DEBUG) { print "DEBUG:: File: ", $infile, "\n", Dumper($attributes), "\n"; } @@ -316,7 +331,7 @@ foreach my $entr (@{$entries->{entry}}) { { my $infile = $ARGV[$argnum]; - my $attributes = $xml->XMLin($infile, ForceArray => ['attribute']); + my $attributes = $xml->XMLin($infile, ForceArray => ['attribute', 'chip']); # Uncomment to get debug output of all attributes if ($DEBUG) { print "DEBUG:: File: ", $infile, "\n", Dumper($attributes), "\n"; } @@ -464,8 +479,8 @@ foreach my $entr (@{$entries->{entry}}) { # Split on commas my @targTypes = split(',', $attr->{targetType}); + my $targType = $targTypes[0]; - my $targTypeCount = 0; foreach my $targType (@targTypes) { # Remove newlines and leading/trailing whitespace @@ -473,12 +488,18 @@ foreach my $entr (@{$entries->{entry}}) { $targType =~ s/^\s+//; $targType =~ s/\s+$//; - if ($targTypeCount != 0) + # Consider only supported target types. The rest are ignored + if($targType ~~ ["TARGET_TYPE_PROC_CHIP", "TARGET_TYPE_SYSTEM", + "TARGET_TYPE_CORE", "TARGET_TYPE_MCS", "TARGET_TYPE_PERV", + "TARGET_TYPE_EQ", "TARGET_TYPE_EX"]) + { + print AIFILE "$targType"; + last; + } + else { - print AIFILE " | "; + next; } - print AIFILE "$targType"; - $targTypeCount++; } print AIFILE ";\n"; @@ -555,8 +576,8 @@ foreach my $entr (@{$entries->{entry}}) { # compile failure if a set is attempted #------------------------------------------------------------------ print AIFILE "#define $attr->{id}_GETMACRO(ID, PTARGET, VAL) \\\n"; - print AIFILE " PLAT_GET_CHIP_EC_FEATURE_OVERRIDE(ID, PTARGET, VAL) ? fapi::FAPI_RC_SUCCESS : \\\n"; - print AIFILE " fapi::fapiQueryChipEcFeature(fapi::ID, PTARGET, VAL)\n"; + print AIFILE " PLAT_GET_CHIP_EC_FEATURE_OVERRIDE(ID, PTARGET, VAL) ? fapi2::FAPI2_RC_SUCCESS : \\\n"; + print AIFILE " fapi2::queryChipEcFeature(fapi2::int2Type(), PTARGET, VAL)\n"; print AIFILE "#define $attr->{id}_SETMACRO(ID, PTARGET, VAL) "; print AIFILE "CHIP_EC_FEATURE_ATTRIBUTE_NOT_WRITABLE\n"; } @@ -572,389 +593,55 @@ foreach my $entr (@{$entries->{entry}}) { } } - #---------------------------------------------------------------------- - # If the attribute is a Chip EC Feature, print the chip EC feature - # query to fapiChipEcFeature.C - #---------------------------------------------------------------------- - if (exists $attr->{chipEcFeature}) - { - my $chipCount = 0; - print ECFILE " case $attr->{id}:\n"; - print ECFILE " if (\n"; - - foreach my $chip (@{$attr->{chipEcFeature}->{chip}}) - { - $chipCount++; - - if (! exists $chip->{name}) - { - print ("fapiParseAttributeInfo.pl ERROR. Att 'name' missing\n"); - exit(1); - } - - if (! exists $chip->{ec}) - { - print ("fapiParseAttributeInfo.pl ERROR. Att 'ec' missing\n"); - exit(1); - } - - if (! exists $chip->{ec}->{value}) - { - print ("fapiParseAttributeInfo.pl ERROR. Att 'value' missing\n"); - exit(1); - } - - if (! exists $chip->{ec}->{test}) - { - print ("fapiParseAttributeInfo.pl ERROR. Att 'test' missing\n"); - exit(1); - } - - my $test; - if ($chip->{ec}->{test} eq 'EQUAL') - { - $test = '=='; - } - elsif ($chip->{ec}->{test} eq 'GREATER_THAN') - { - $test = '>'; - } - elsif ($chip->{ec}->{test} eq 'GREATER_THAN_OR_EQUAL') - { - $test = '>='; - } - elsif ($chip->{ec}->{test} eq 'LESS_THAN') - { - $test = '<'; - } - elsif ($chip->{ec}->{test} eq 'LESS_THAN_OR_EQUAL') - { - $test = '<='; - } - else - { - print ("fapiParseAttributeInfo.pl ERROR. test '$chip->{ec}->{test}' unrecognized\n"); - exit(1); - } - - if ($chipCount > 1) - { - print ECFILE " ||\n"; - } - print ECFILE " ((l_chipName == $chip->{name}) &&\n"; - print ECFILE " (l_chipEc $test $chip->{ec}->{value}))\n"; - } - - print ECFILE " )\n"; - print ECFILE " {\n"; - print ECFILE " o_hasFeature = true;\n"; - print ECFILE " }\n"; - print ECFILE " break;\n"; - } - - #---------------------------------------------------------------------- - # Print the platform attribute checks to fapiAttributePlatCheck.H - #---------------------------------------------------------------------- - if (exists $attr->{writeable}) - { - print ACFILE "#ifndef $attr->{id}_SETMACRO\n"; - print ACFILE "#error Platform does not support set of HWPF attr $attr->{id}\n"; - print ACFILE "#endif\n"; - } - - print ACFILE "#ifndef $attr->{id}_GETMACRO\n"; - print ACFILE "#error Platform does not support get of HWPF attr $attr->{id}\n"; - print ACFILE "#endif\n\n"; - - #---------------------------------------------------------------------- - # Print newline between each attribute's info to fapiAttributeIds.H - #---------------------------------------------------------------------- - print AIFILE "\n"; - - - - - - } - }; - } -} - - - -=for comment - -#------------------------------------------------------------------------------ -# For each XML file -#------------------------------------------------------------------------------ -foreach my $argnum (1 .. $#ARGV) -{ - my $infile = $ARGV[$argnum]; - - # 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 - my $attributes = $xml->XMLin($infile, ForceArray => ['attribute', 'chip']); - - #-------------------------------------------------------------------------- - # For each Attribute - #-------------------------------------------------------------------------- - foreach my $attr (@{$attributes->{attribute}}) - { - #---------------------------------------------------------------------- - # Print a comment with the attribute ID fapiAttributeIds.H - #---------------------------------------------------------------------- - print AIFILE "/* $attr->{id} */\n"; - - #---------------------------------------------------------------------- - # Print the AttributeId and description to fapiAttributesSupported.html - #---------------------------------------------------------------------- - if (! exists $attr->{description}) - { - print ("fapiParseAttributeInfo.pl ERROR. Att 'description' missing\n"); - exit(1); - } - - print ASFILE "\n"; - print ASFILE " $attr->{id}\n"; - print ASFILE " $attr->{description}\n"; - print ASFILE "\n"; - - #---------------------------------------------------------------------- - # Figure out the attribute array dimensions (if array) - #---------------------------------------------------------------------- - my $arrayDimensions = ""; - my $numArrayDimensions = 0; - if ($attr->{array}) - { - # Remove leading whitespace - my $dimText = $attr->{array}; - $dimText =~ s/^\s+//; - - # Split on commas or whitespace - my @vals = split(/\s*,\s*|\s+/, $dimText); - - foreach my $val (@vals) - { - $arrayDimensions .= "[${val}]"; - $numArrayDimensions++; - } - } - - #---------------------------------------------------------------------- - # Print the typedef for each attribute's val type to fapiAttributeIds.H - # Print the attribute information to fapiAttrInfo.csv - #---------------------------------------------------------------------- - if (exists $attr->{chipEcFeature}) - { - # The value type of chip EC feature attributes is uint8_t - print AIFILE "typedef uint8_t $attr->{id}_Type;\n"; - print ITFILE "$attr->{id},$attr->{id},0x$attrIdHash{$attr->{id}},u8\n" - } - else - { - if (! exists $attr->{valueType}) - { - print ("fapiParseAttributeInfo.pl ERROR. Att 'valueType' missing\n"); - exit(1); - } - - if ($attr->{valueType} eq 'uint8') - { - print AIFILE "typedef uint8_t $attr->{id}_Type$arrayDimensions;\n"; - print ITFILE "$attr->{id},$attr->{id},0x$attrIdHash{$attr->{id}},u8" . - "$arrayDimensions\n"; - } - elsif ($attr->{valueType} eq 'uint32') - { - print AIFILE "typedef uint32_t $attr->{id}_Type$arrayDimensions;\n"; - print ITFILE "$attr->{id},$attr->{id},0x$attrIdHash{$attr->{id}},u32" . - "$arrayDimensions\n"; - } - elsif ($attr->{valueType} eq 'uint64') - { - print AIFILE "typedef uint64_t $attr->{id}_Type$arrayDimensions;\n"; - print ITFILE "$attr->{id},$attr->{id},0x$attrIdHash{$attr->{id}},u64" . - "$arrayDimensions\n"; - } - else - { - print ("fapiParseAttributeInfo.pl ERROR. valueType not recognized: "); - print $attr->{valueType}, "\n"; - exit(1); - } - } - - #---------------------------------------------------------------------- - # Print if the attribute is privileged - #---------------------------------------------------------------------- - if (exists $attr->{privileged}) - { - print AIFILE "const bool $attr->{id}_Privileged = true;\n"; - } - else - { - print AIFILE "const bool $attr->{id}_Privileged = false;\n"; - } - - #---------------------------------------------------------------------- - # Print the target type(s) that the attribute is associated with - #---------------------------------------------------------------------- - if (! exists $attr->{targetType}) - { - print ("fapiParseAttributeInfo.pl ERROR. Att 'targetType' missing\n"); - exit(1); - } - - print AIFILE "const TargetTypes_t $attr->{id}_TargetTypes = "; - - # Split on commas - my @targTypes = split(',', $attr->{targetType}); - - my $targTypeCount = 0; - foreach my $targType (@targTypes) - { - # Remove newlines and leading/trailing whitespace - $targType =~ s/\n//; - $targType =~ s/^\s+//; - $targType =~ s/\s+$//; - - if ($targTypeCount != 0) - { - print AIFILE " | "; - } - print AIFILE "$targType"; - $targTypeCount++; - } - print AIFILE ";\n"; - - #---------------------------------------------------------------------- - # Print if the attribute is a platInit attribute - #---------------------------------------------------------------------- - if (exists $attr->{platInit}) - { - print AIFILE "const bool $attr->{id}_PlatInit = true;\n"; - } - else - { - print AIFILE "const bool $attr->{id}_PlatInit = false;\n"; - } - - #---------------------------------------------------------------------- - # Print if the attribute is a initToZero attribute - #---------------------------------------------------------------------- - if (exists $attr->{initToZero}) - { - print AIFILE "const bool $attr->{id}_InitToZero = true;\n"; - } - else - { - print AIFILE "const bool $attr->{id}_InitToZero = false;\n"; - } - - #---------------------------------------------------------------------- - # Print the value enumeration (if specified) to fapiAttributeIds.H and - # fapiAttributeEnums.txt - #---------------------------------------------------------------------- - if (exists $attr->{enum}) - { - print AIFILE "enum $attr->{id}_Enum\n{\n"; - - # Values must be separated by commas to allow for values to be - # specified: VAL_A = 3, VAL_B = 5, VAL_C = 0x23 - my @vals = split(',', $attr->{enum}); - - foreach my $val (@vals) - { - # Remove newlines and leading/trailing whitespace - $val =~ s/\n//; - $val =~ s/^\s+//; - $val =~ s/\s+$//; - - # Print the attribute enum to fapiAttributeIds.H - print AIFILE " ENUM_$attr->{id}_${val}"; - - # Print the attribute enum to fapiAttrEnumInfo.csv - my $attrEnumTxt = "$attr->{id}_${val}\n"; - $attrEnumTxt =~ s/ = /,/; - print ETFILE $attrEnumTxt; - - if ($attr->{valueType} eq 'uint64') - { - print AIFILE "ULL"; - } - - print AIFILE ",\n"; - } - - print AIFILE "};\n"; - } - - #---------------------------------------------------------------------- - # Print _GETMACRO and _SETMACRO where appropriate to fapiAttributeIds.H - #---------------------------------------------------------------------- - if (exists $attr->{chipEcFeature}) - { - #------------------------------------------------------------------ - # The attribute is a Chip EC Feature, define _GETMACRO to call a - # fapi function and define _SETMACRO to something that will cause a - # compile failure if a set is attempted - #------------------------------------------------------------------ - print AIFILE "#define $attr->{id}_GETMACRO(ID, PTARGET, VAL) \\\n"; - print AIFILE " PLAT_GET_CHIP_EC_FEATURE_OVERRIDE(ID, PTARGET, VAL) ? fapi::FAPI_RC_SUCCESS : \\\n"; - print AIFILE " fapi::fapiQueryChipEcFeature(fapi::ID, PTARGET, VAL)\n"; - print AIFILE "#define $attr->{id}_SETMACRO(ID, PTARGET, VAL) "; - print AIFILE "CHIP_EC_FEATURE_ATTRIBUTE_NOT_WRITABLE\n"; - } - elsif (! exists $attr->{writeable}) - { - #------------------------------------------------------------------ - # The attribute is read-only, define the _SETMACRO to something - # that will cause a compile failure if a set is attempted - #------------------------------------------------------------------ - if (! exists $attr->{writeable}) - { - print AIFILE "#define $attr->{id}_SETMACRO ATTRIBUTE_NOT_WRITABLE\n"; - } - } - #---------------------------------------------------------------------- # If the attribute is a Chip EC Feature, print the chip EC feature - # query to fapiChipEcFeature.C + # query to fapi2_chip_ec_feature.H #---------------------------------------------------------------------- + # Each EC attribute will generate a new inline overloaded version of + # hasFeature with the attribute specific logic if (exists $attr->{chipEcFeature}) { my $chipCount = 0; - print ECFILE " case $attr->{id}:\n"; - print ECFILE " if (\n"; + print ECHFILE " inline uint8_t hasFeature(int2Type<$attr->{id}>,\n"; + print ECHFILE " fapi2::ATTR_NAME_Type i_name,\n"; + print ECHFILE " fapi2::ATTR_EC_Type i_ec)\n"; + print ECHFILE " {\n"; + print ECHFILE " uint8_t hasFeature = 0;\n\n"; + print ECHFILE " if("; foreach my $chip (@{$attr->{chipEcFeature}->{chip}}) { - $chipCount++; - if (! exists $chip->{name}) { - print ("fapiParseAttributeInfo.pl ERROR. Att 'name' missing\n"); + print ("parseAttributeInfo.pl ERROR. Att 'name' missing\n"); exit(1); } if (! exists $chip->{ec}) { - print ("fapiParseAttributeInfo.pl ERROR. Att 'ec' missing\n"); + print ("parseAttributeInfo.pl ERROR. Att 'ec' missing\n"); exit(1); } if (! exists $chip->{ec}->{value}) { - print ("fapiParseAttributeInfo.pl ERROR. Att 'value' missing\n"); + print ("parseAttributeInfo.pl ERROR. Att 'value' missing\n"); exit(1); } if (! exists $chip->{ec}->{test}) { - print ("fapiParseAttributeInfo.pl ERROR. Att 'test' missing\n"); + print ("parseAttributeInfo.pl ERROR. Att 'test' missing\n"); exit(1); } + if($chip->{name} eq 'ENUM_ATTR_NAME_CENTAUR') + { + # Skip Centaur chip + next; + } + + $chipCount++; my $test; if ($chip->{ec}->{test} eq 'EQUAL') { @@ -978,47 +665,52 @@ foreach my $argnum (1 .. $#ARGV) } else { - print ("fapiParseAttributeInfo.pl ERROR. test '$chip->{ec}->{test}' unrecognized\n"); + print ("parseAttributeInfo.pl ERROR. test '$chip->{ec}->{test}' unrecognized\n"); exit(1); } if ($chipCount > 1) { - print ECFILE " ||\n"; + print ECHFILE " ||\n\t"; } - print ECFILE " ((l_chipName == $chip->{name}) &&\n"; - print ECFILE " (l_chipEc $test $chip->{ec}->{value}))\n"; + print ECHFILE "((i_name == $chip->{name}) && "; + print ECHFILE " (i_ec $test $chip->{ec}->{value}))"; + } + print ECHFILE ")\n"; + print ECHFILE " {\n"; + print ECHFILE " hasFeature = 1;\n"; + print ECHFILE " }\n"; + print ECHFILE " return hasFeature;\n"; + print ECHFILE " };\n"; + } + + #---------------------------------------------------------------------- + # Print the platform attribute checks to fapiAttributePlatCheck.H + #---------------------------------------------------------------------- + if (exists $attr->{writeable}) + { + print ACFILE "#ifndef $attr->{id}_SETMACRO\n"; + print ACFILE "#error Platform does not support set of HWPF attr $attr->{id}\n"; + print ACFILE "#endif\n"; } - print ECFILE " )\n"; - print ECFILE " {\n"; - print ECFILE " o_hasFeature = true;\n"; - print ECFILE " }\n"; - print ECFILE " break;\n"; - } + print ACFILE "#ifndef $attr->{id}_GETMACRO\n"; + print ACFILE "#error Platform does not support get of HWPF attr $attr->{id}\n"; + print ACFILE "#endif\n\n"; + + #---------------------------------------------------------------------- + # Print newline between each attribute's info to fapiAttributeIds.H + #---------------------------------------------------------------------- + print AIFILE "\n"; - #---------------------------------------------------------------------- - # Print the platform attribute checks to fapiAttributePlatCheck.H - #---------------------------------------------------------------------- - if (exists $attr->{writeable}) - { - print ACFILE "#ifndef $attr->{id}_SETMACRO\n"; - print ACFILE "#error Platform does not support set of HWPF attr $attr->{id}\n"; - print ACFILE "#endif\n"; - } - print ACFILE "#ifndef $attr->{id}_GETMACRO\n"; - print ACFILE "#error Platform does not support get of HWPF attr $attr->{id}\n"; - print ACFILE "#endif\n\n"; - #---------------------------------------------------------------------- - # Print newline between each attribute's info to fapiAttributeIds.H - #---------------------------------------------------------------------- - print AIFILE "\n"; - }; -} -=cut + + } + }; + } +} #------------------------------------------------------------------------------ # Print End of file information to fapiAttributeIds.H @@ -1027,32 +719,8 @@ print AIFILE "} //fapi2 \n\n"; print AIFILE "#endif // __ASSEMBLER__\n\n"; print AIFILE "#endif\n"; -#------------------------------------------------------------------------------ -# Print End of file information to fapiChipEcFeature.C -#------------------------------------------------------------------------------ -print ECFILE " default:\n"; -print ECFILE " FAPI_ERR(\"fapiQueryChipEcFeature: Unknown feature 0x%x\",\n"; -print ECFILE " i_id);\n"; -print ECFILE " l_rc.setFapiError(FAPI_RC_INVALID_CHIP_EC_FEATURE_GET);\n"; -print ECFILE " l_rc.addEIFfdc(0, &i_id, sizeof(i_id));\n"; -print ECFILE " break;\n"; -print ECFILE " }\n\n"; -print ECFILE " if (o_hasFeature)\n"; -print ECFILE " {\n"; -print ECFILE " FAPI_INF(\"fapiQueryChipEcFeature: Chip (0x%x:0x%x) has "; -print ECFILE "feature (0x%x)\", l_chipName, l_chipEc, i_id);\n"; -print ECFILE " }\n"; -print ECFILE " else\n"; -print ECFILE " {\n"; -print ECFILE " FAPI_INF(\"fapiQueryChipEcFeature: Chip (0x%x:0x%x) does not "; -print ECFILE "have feature (0x%x)\", l_chipName, l_chipEc, i_id);\n"; -print ECFILE " }\n"; -print ECFILE " }\n"; -print ECFILE " }\n"; -print ECFILE " }\n"; -print ECFILE " return l_rc;\n"; -print ECFILE "}\n\n"; -print ECFILE "}\n"; +print ECHFILE "}\n"; +print ECHFILE "#endif\n"; #------------------------------------------------------------------------------ @@ -1072,7 +740,7 @@ print ASFILE "\n"; # Close output files #------------------------------------------------------------------------------ close(AIFILE); -close(ECFILE); +close(ECHFILE); close(ACFILE); close(ASFILE); close(ITFILE); diff --git a/tools/scripts/ppeParseProcSbeFixed.pl b/tools/scripts/ppeParseProcSbeFixed.pl index ddcd5558..2d10cd25 100755 --- a/tools/scripts/ppeParseProcSbeFixed.pl +++ b/tools/scripts/ppeParseProcSbeFixed.pl @@ -1,4 +1,28 @@ #!/usr/bin/perl +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: tools/scripts/ppeParseProcSbeFixed.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 HWP Attribute XML files and # initfile attr files and create the fapiGetInitFileAttr() function # in a file called fapiAttributeService.C @@ -94,6 +118,12 @@ foreach my $entr (@{$entries->{entry}}) { my $inname = $entr->{name}; + # Skip virtual attributes + if(exists $entr->{virtual}) + { + next; + } + # 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 @@ -123,35 +153,61 @@ foreach my $entr (@{$entries->{entry}}) { exit(1); } - if ($attr->{targetType} eq "TARGET_TYPE_SYSTEM") { + my @targets = split(",", $attr->{targetType}); + my $targetTypeMatched = 0; - push(@attrSystemIds, $attr); + foreach my $target (@targets) + { - } elsif ($attr->{targetType} eq "TARGET_TYPE_PROC_CHIP") { + if ($target eq "TARGET_TYPE_SYSTEM") { - push(@attrChipIds, $attr); + push(@attrSystemIds, $attr); + $targetTypeMatched = 1; + last; - } elsif ($attr->{targetType} eq "TARGET_TYPE_CORE") { + } elsif ($target eq "TARGET_TYPE_PROC_CHIP") { - push(@attrCoreIds, $attr); + push(@attrChipIds, $attr); + $targetTypeMatched = 1; + last; - } elsif ($attr->{targetType} eq "TARGET_TYPE_EQ") { + } elsif ($target eq "TARGET_TYPE_CORE") { - push(@attrEqIds, $attr); + push(@attrCoreIds, $attr); + $targetTypeMatched = 1; + last; - } elsif ($attr->{targetType} eq "TARGET_TYPE_EX") { + } elsif ($target eq "TARGET_TYPE_EQ") { - push(@attrExIds, $attr); + push(@attrEqIds, $attr); + $targetTypeMatched = 1; + last; - } elsif ($attr->{targetType} eq "TARGET_TYPE_PERV") { + } elsif ($target eq "TARGET_TYPE_EX") { - push(@attrPervIds, $attr); + push(@attrExIds, $attr); + $targetTypeMatched = 1; + last; - } else { + } elsif ($target eq "TARGET_TYPE_PERV") { - print ("ppeParseProcSbeFixed.pl ERROR. Wrong attribute type: $attr->{targetType} for attribute $attr->{id} in $infile\n"); - exit(1); + push(@attrPervIds, $attr); + $targetTypeMatched = 1; + last; + } else { + + print ("ppeParseProcSbeFixed.pl WARNING. Unsupported ". + "target type: $target for attribute $inname in $infile\n"); + next; + + } + } + if($targetTypeMatched eq 0) + { + print ("ppeParseProcSbeFixed.pl ERROR. Unsupported ". + "target type: $attr->{targetType} for attribute $inname in $infile\n"); + exit(1); } } } diff --git a/tools/scripts/src/fapi2PlatAttributeService.H b/tools/scripts/src/fapi2PlatAttributeService.H index ada3681c..739db1f8 100644 --- a/tools/scripts/src/fapi2PlatAttributeService.H +++ b/tools/scripts/src/fapi2PlatAttributeService.H @@ -1,3 +1,27 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: tools/scripts/src/fapi2PlatAttributeService.H $ */ +/* */ +/* 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 */ /** * @file fapiPlatAttributeService.H * @@ -12,7 +36,9 @@ #include #include +#include #include +#include #include #include "proc_sbe_fixed.H" #include "plat_target_parms.H" @@ -462,7 +488,7 @@ ReturnCode _getOverride(const AttributeId i_id, //****************************************************************************** // Get override EC Feature (uint8_t) //****************************************************************************** -template +template ReturnCode _getEcFeatureOverride(const AttributeId i_id, const Target & i_pTarget, uint8_t& o_value) -- cgit v1.2.1