summaryrefslogtreecommitdiffstats
path: root/src/import/hwpf
diff options
context:
space:
mode:
authorThi Tran <thi@us.ibm.com>2015-04-24 08:35:51 -0500
committerPatrick Williams <iawillia@us.ibm.com>2015-12-11 13:40:20 -0600
commitae01239e70a47a93067c183ede3fb8616c44901b (patch)
tree9c9f08d749f4ce3683402886bd6bf1eccb2903a2 /src/import/hwpf
parentc0f82c2f21b4ef647baf05d887219e23ec5b0919 (diff)
downloadtalos-hostboot-ae01239e70a47a93067c183ede3fb8616c44901b.tar.gz
talos-hostboot-ae01239e70a47a93067c183ede3fb8616c44901b.zip
FAPI2 Direct attribute access support
Change-Id: Icc127aa36d53cd18f9bf16414efcaa2cc35b8c14 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/17400 Tested-by: Jenkins Server Reviewed-by: Matt K. Light <mklight@us.ibm.com> Reviewed-by: Brian Silver <bsilver@us.ibm.com>
Diffstat (limited to 'src/import/hwpf')
-rw-r--r--src/import/hwpf/fapi2/include/fapi2.H45
-rw-r--r--src/import/hwpf/fapi2/include/fapi2_attribute_service.H127
-rw-r--r--src/import/hwpf/fapi2/include/fapi2_chip_ec_feature.H39
-rw-r--r--src/import/hwpf/fapi2/include/fapi2_hwp_executor.H24
-rw-r--r--src/import/hwpf/fapi2/include/fapi2_target.H69
-rw-r--r--src/import/hwpf/fapi2/include/target_types.H26
-rw-r--r--src/import/hwpf/fapi2/include/utils.H1
-rwxr-xr-xsrc/import/hwpf/fapi2/tools/createIfAttrService.pl274
-rwxr-xr-xsrc/import/hwpf/fapi2/tools/parseAttributeInfo.pl743
9 files changed, 1257 insertions, 91 deletions
diff --git a/src/import/hwpf/fapi2/include/fapi2.H b/src/import/hwpf/fapi2/include/fapi2.H
index 1efede789..12a428132 100644
--- a/src/import/hwpf/fapi2/include/fapi2.H
+++ b/src/import/hwpf/fapi2/include/fapi2.H
@@ -1,31 +1,7 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: $ */
-/* */
-/* OpenPOWER HostBoot Project */
-/* */
-/* Contributors Listed Below - COPYRIGHT 2012,2014 */
-/* [+] 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 fapi2.H
- * @brief top level header for fapi2
- */
+///
+/// @file fapi2.H
+/// @brief top level header for fapi2
+///
#ifndef __FAPI2_TOP_LEVEL__
#define __FAPI2_TOP_LEVEL__
@@ -34,7 +10,6 @@
#include <return_code.H>
#include <buffer.H>
#include <hw_access.H>
-
#include <utils.H>
#include <plat_trace.H>
@@ -45,16 +20,8 @@
// Block of headers not currently in fapi2
#ifdef FAPI2_MISSING_HEADERS
#include <fapi2SystemConfig.H>
- #include <fapi2HwpExecutor.H>
- #include <fapi2AttributeService.H>
- #include <fapi2MvpdAccess.H>
- #include <fapi2MBvpdAccess.H>
-#endif
-
-// Block of auto generated headers not presently in fapi2
-#ifdef FAPI2_AUTOGEN_HEADERS
- #include <fapi2AttributeIds.H> // Generated file
- #include <fapi2ChipEcFeature.H> // Generated file
+ #include <mvpdAccess.H>
+ #include <mbvpdAccess.H>
#endif
#endif // __FAPI2_TOP_LEVEL__
diff --git a/src/import/hwpf/fapi2/include/fapi2_attribute_service.H b/src/import/hwpf/fapi2/include/fapi2_attribute_service.H
new file mode 100644
index 000000000..b031f6e80
--- /dev/null
+++ b/src/import/hwpf/fapi2/include/fapi2_attribute_service.H
@@ -0,0 +1,127 @@
+///
+/// @file src/include/usr/hwpf/fapi2/fapi2_attribute_service.H
+///
+/// @brief Defines the FAPI_ATTR_GET and FAPI_ATTR_SET macros that a user
+/// calls to get/set attributes and a check function that the macros use to
+/// verify correct usage
+///
+
+#ifndef FAPI2ATTRIBUTESERVICE_H_
+#define FAPI2ATTRIBUTESERVICE_H_
+#include <stdint.h>
+#include <attribute_ids.H>
+#include <target.H>
+#include <target_types.H>
+#include <plat_attribute_service.H>
+
+/// @brief Macros called by user to get/set attributes for FAPI2 targets
+///
+/// Code must have a reference to a FAPI2 Target and an attribute ID (from
+/// XML file):
+/// fapi2::ReturnCode l_rc;
+/// fapi2::Target<target type>& l_target = ????;
+/// Ex: Target<TARGET_TYPE_PROC_CHIP>& l_target = ????;
+///
+/// To get a copy of an integer attribute and set the attribute
+/// uint64_t l_val = 0;
+/// l_rc = FAPI_ATTR_GET(<ID>, l_target, l_val);
+/// l_rc = FAPI_ATTR_SET(<ID>, l_target, l_val);
+///
+/// To get a copy of an integer array attribute and set the attribute
+/// uint32_t l_pVal[4] = {0};
+/// l_rc = FAPI_ATTR_GET(<ID>, l_target, l_pVal);
+/// l_rc = FAPI_ATTR_SET(<ID>, l_target, l_pVal);
+///
+/// A priveleged attribute is one that a HWP should not generally access,
+/// examples include ATTR_NAME and ATTR_EC, where usage can lead to a non
+/// data-driven design. A privileged attribute can be accessed with
+/// FAPI_ATTR_GET_PRIVILEGED and FAPI_ATTR_SET_PRIVILEGED
+///
+/// The non-PRIVILEGED macros first call a template function (compiler will
+/// optimize out) that will cause a compile failure if the attribute is
+/// privileged, they then call a PRIVILEGED macro to get/set the attribute
+///
+/// The PRIVILEGED macros call a template function (compiler will optimize out)
+/// that will cause a compile failure if the ID is not valid or VAL is not the
+/// correct type.
+//
+
+#define FAPI_ATTR_GET(ID, TARGET, VAL) \
+ (fapi2::failIfPrivileged<ID##_Privileged>(), \
+ fapi2::Target<ID##_TargetType>(TARGET), \
+ fapi2::checkIdType<ID##_Type>(ID, VAL), \
+ ID##_GETMACRO(ID, TARGET, VAL))
+
+#define FAPI_ATTR_SET(ID, TARGET, VAL) \
+ (fapi2::failIfPrivileged<ID##_Privileged>(), \
+ fapi2::Target<ID##_TargetType>(TARGET), \
+ fapi2::checkIdType<ID##_Type>(ID, VAL), \
+ ID##_SETMACRO(ID, TARGET, VAL))
+
+#define FAPI_ATTR_GET_PRIVILEGED(ID, TARGET, VAL) \
+ (fapi2::checkIdType<ID##_Type>(ID, VAL), \
+ ID##_GETMACRO(ID, TARGET, VAL))
+
+#define FAPI_ATTR_SET_PRIVILEGED(ID, TARGET, VAL) \
+ (fapi2::checkIdType<ID##_Type>(ID, VAL), \
+ ID##_SETMACRO(ID, TARGET, VAL))
+
+namespace fapi2
+{
+
+///
+/// @brief Get an InitFile attribute for FAPI2
+///
+/// This function gets a copy of an attribute. In the case of an array attribute,
+/// The value in the specified index is retrieved. This should be used by the
+/// InitFile HWP only, that HWP processes a binary InitFile and therefore needs
+/// to read a variable ID of a variable data type. Standard HWPs should use the
+/// FAPI2_ATTR_GET macro which automatically checks the type for correct usage.
+///
+/// If there are ever attributes with more than 4 dimensions then this function
+/// will need to be updated.
+///
+/// @Tparam K template parameter, passed in target.
+/// @param[in] i_id AttributeID
+/// @param[in] i_target Reference to fapi2::Target (can be NULL for system)
+/// @param[out] o_val Reference to uint64_t where attribute value is set
+/// @param[in] i_arrayIndex1 If array attribute then index1
+/// @param[in] i_arrayIndex2 If at least 2D array attribute then index2
+/// @param[in] i_arrayIndex3 If at least 3D array attribute then index3
+/// @param[in] i_arrayIndex4 If at least 4D array attribute then index4
+///
+/// @return ReturnCode. Zero if success
+///
+template< TargetType K >
+ReturnCode getInitFileAttr(const AttributeId i_id,
+ const Target<K>& i_target,
+ uint64_t & o_val,
+ const uint32_t i_arrayIndex1 = 0,
+ const uint32_t i_arrayIndex2 = 0,
+ const uint32_t i_arrayIndex3 = 0,
+ const uint32_t i_arrayIndex4 = 0);
+
+/**
+ * @brief Check the ID and TYPE
+ *
+ * This is called by FAPI code to check at compile time that a FAPI attribute
+ * access is using the correct data type and a valid AttributeId
+ */
+template<typename T> inline void checkIdType(AttributeId, T &) {}
+
+/**
+ * @brief Fail if attribute privileged
+ *
+ * This is called by FAPI code to check at compile time that a standard FAPI
+ * attribute access (FAPI_ATTR_GET) is not accessing a privileged attribute
+ */
+class ErrorAccessingPrivilegedAttribute;
+template<const bool PRIVILEGED> void failIfPrivileged()
+{
+ ErrorAccessingPrivilegedAttribute();
+}
+template <> inline void failIfPrivileged<false>() {}
+
+}
+
+#endif // FAPI2ATTRIBUTESERVICE_H_
diff --git a/src/import/hwpf/fapi2/include/fapi2_chip_ec_feature.H b/src/import/hwpf/fapi2/include/fapi2_chip_ec_feature.H
new file mode 100644
index 000000000..2398b5dad
--- /dev/null
+++ b/src/import/hwpf/fapi2/include/fapi2_chip_ec_feature.H
@@ -0,0 +1,39 @@
+///
+/// @file src/include/usr/hwpf/fapi2/fapi2_chip_ec_feature.H
+///
+/// @brief Defines the queryChipEcFeature function that allows HWPs to
+/// query if a particular chip has a feature determined by its EC level.
+/// Chip EC features are specified in attribute XML files and the
+/// queryChipEcFeature function implementation is auto-generated.
+/// HWPs should not call this function directly, but should access the
+/// corresponding HWPF attribute using FAPI_ATTR_GET
+///
+
+#ifndef FAPI2CHIPECFEATURE_H_
+#define FAPI2CHIPECFEATURE_H_
+
+#include <stdint.h>
+#include <target.H>
+#include <return_code.H>
+
+namespace fapi2
+{
+
+///
+/// @brief Queries if a Chip has a particular feature
+///
+/// This should only be called by FAPI during the processing of a FAPI_ATTR_GET
+/// for a Chip EC Feature attribute
+///
+/// @param[in] i_id Attribute ID of the Chip EC Feature
+/// @param[in] i_target Reference to chip target
+/// @param[out] o_hasFeature Set to 1 if chip has feature else 0
+/// @return ReturnCode. Zero on success, else platform specified error
+///
+template< TargetType K >
+ReturnCode queryChipEcFeature(AttributeId i_id,
+ const Target<K>& i_target,
+ uint8_t & o_hasFeature);
+}
+
+#endif
diff --git a/src/import/hwpf/fapi2/include/fapi2_hwp_executor.H b/src/import/hwpf/fapi2/include/fapi2_hwp_executor.H
new file mode 100644
index 000000000..e92d14275
--- /dev/null
+++ b/src/import/hwpf/fapi2/include/fapi2_hwp_executor.H
@@ -0,0 +1,24 @@
+///
+/// @file fapi2_hwp_executor.H
+///
+/// @brief Defines the FAPI2 HWP Executor Macro.
+///
+/// The FAPI2 HWP Executor macro is called when a PLAT invoker function or a HWP
+/// wants to execute a HWP.
+///
+
+#ifndef FAPI2HWPEXECUTOR_H_
+#define FAPI2HWPEXECUTOR_H_
+
+#include <hwp_executor.H>
+
+/**
+ * @brief HWP Executor macro
+ *
+ * This macro calls a PLAT macro which will do any platform specific work to
+ * execute the HWP (e.g. dlopening a shared library)
+ */
+#define FAPI_EXEC_HWP(RC, FUNC, _args_...) \
+ FAPI_PLAT_EXEC_HWP(RC, FUNC, ##_args_)
+
+#endif // FAPI2HWPEXECUTOR_H_
diff --git a/src/import/hwpf/fapi2/include/fapi2_target.H b/src/import/hwpf/fapi2/include/fapi2_target.H
index ce0e950cc..b479fca77 100644
--- a/src/import/hwpf/fapi2/include/fapi2_target.H
+++ b/src/import/hwpf/fapi2/include/fapi2_target.H
@@ -1,31 +1,7 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: $ */
-/* */
-/* OpenPOWER HostBoot Project */
-/* */
-/* Contributors Listed Below - COPYRIGHT 2012,2014 */
-/* [+] 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 fapi2_target.H
- * @brief common definitions for fapi2 targets
- */
+///
+/// @file fapi2_target.H
+/// @brief Common definitions for fapi2 targets
+///
#ifndef __FAPI2_COMMON_TARGET__
#define __FAPI2_COMMON_TARGET__
@@ -173,6 +149,43 @@ namespace fapi2
inline Target<T> getParent(void) const;
///
+ /// @brief Is this target a chip?
+ /// @return Return true if this target is a chip, false otherwise
+ ///
+ inline constexpr bool isChip(void) const
+ {
+ return ( (K == TARGET_TYPE_PROC_CHIP) ||
+ (K == TARGET_TYPE_MEMBUF_CHIP) );
+ }
+
+ ///
+ /// @brief Is this target a chiplet?
+ /// @return Return true if this target is a chiplet, false otherwise
+ ///
+ inline constexpr bool isChiplet(void) const
+ {
+ return ( (K == TARGET_TYPE_EX) ||
+ (K == TARGET_TYPE_MBA) ||
+ (K == TARGET_TYPE_MCS) ||
+ (K == TARGET_TYPE_XBUS) ||
+ (K == TARGET_TYPE_ABUS) ||
+ (K == TARGET_TYPE_L4) ||
+ (K == TARGET_TYPE_CORE) ||
+ (K == TARGET_TYPE_EQ) ||
+ (K == TARGET_TYPE_MCA) ||
+ (K == TARGET_TYPE_MCBIST) ||
+ (K == TARGET_TYPE_MI) ||
+ (K == TARGET_TYPE_DMI) ||
+ (K == TARGET_TYPE_OBUS) ||
+ (K == TARGET_TYPE_NV) ||
+ (K == TARGET_TYPE_SBE) ||
+ (K == TARGET_TYPE_PPE) ||
+ (K == TARGET_TYPE_PERV) ||
+ (K == TARGET_TYPE_PEC) ||
+ (K == TARGET_TYPE_PHB) );
+ }
+
+ ///
/// @brief Get this target's children
/// @tparam T The type of the parent
/// @param[in] i_state The desired TargetState of the children
diff --git a/src/import/hwpf/fapi2/include/target_types.H b/src/import/hwpf/fapi2/include/target_types.H
index bdbb3d50b..561f45700 100644
--- a/src/import/hwpf/fapi2/include/target_types.H
+++ b/src/import/hwpf/fapi2/include/target_types.H
@@ -1,27 +1,3 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: $ */
-/* */
-/* OpenPOWER HostBoot Project */
-/* */
-/* Contributors Listed Below - COPYRIGHT 2012,2014 */
-/* [+] 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 target_types.H
* @brief definitions for fapi2 target types
@@ -40,6 +16,7 @@ namespace fapi2
/// or tables. TYPE_ALL is used to pass targets to methods which
/// can act generally on any type of target
///
+
/// Target Kind
enum TargetType
{
@@ -99,6 +76,7 @@ namespace fapi2
static const uint8_t count = 0;
};
/// @endcond
+
}
#endif
diff --git a/src/import/hwpf/fapi2/include/utils.H b/src/import/hwpf/fapi2/include/utils.H
index 85f334b9a..0f10b32ee 100644
--- a/src/import/hwpf/fapi2/include/utils.H
+++ b/src/import/hwpf/fapi2/include/utils.H
@@ -82,6 +82,7 @@ namespace fapi2
/// @return ReturnCode. Zero on success, else platform specified error.
///
ReturnCode delay(uint64_t i_nanoSeconds, uint64_t i_simCycles);
+
};
#endif // FAPI2_UTILS_H_
diff --git a/src/import/hwpf/fapi2/tools/createIfAttrService.pl b/src/import/hwpf/fapi2/tools/createIfAttrService.pl
new file mode 100755
index 000000000..9a552bea9
--- /dev/null
+++ b/src/import/hwpf/fapi2/tools/createIfAttrService.pl
@@ -0,0 +1,274 @@
+#!/usr/bin/perl
+
+use strict;
+use Getopt::Long qw(:config pass_through);
+
+#------------------------------------------------------------------------------
+# Print Command Line Help
+#------------------------------------------------------------------------------
+my $arg_output_dir = undef;
+
+# Get the options from the command line - the rest of @ARGV will
+# be filenames
+GetOptions("output-dir=s" => \$arg_output_dir);
+
+my $numArgs = $#ARGV + 1;
+if (($numArgs < 3) || ($arg_output_dir eq undef))
+{
+ print ("Usage: createIfAttrService.pl --output-dir=<output dir>\n");
+ print (" [<if-attr-file1> <if-attr-file2> ...]\n");
+ print (" -a <attr-xml-file1> [<attr-xml-file2> ...]\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 (" getInitFileAttr() function in a file called\n");
+ print (" fapi2_attribute_service.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 $asFile = $arg_output_dir;
+$asFile .= "/";
+$asFile .= "fapi2_attribute_service.C";
+open(ASFILE, ">", $asFile);
+
+#------------------------------------------------------------------------------
+# Print Start of file information to fapi2_attribute_service.C
+#------------------------------------------------------------------------------
+print ASFILE "// fapi2_attribute_service.C\n";
+print ASFILE "// This file is generated by perl script createIfAttrService.pl\n\n";
+print ASFILE "#include <fapi2_attribute_service.H>\n";
+print ASFILE "#include <chip_ec_feature.H>\n";
+print ASFILE "#include <plat_trace.H>\n\n";
+print ASFILE "namespace fapi2\n";
+print ASFILE "{\n\n";
+print ASFILE "template< TargetType K >\n";
+print ASFILE "ReturnCode getInitFileAttr(const AttributeId i_id,\n";
+print ASFILE " const Target<K>& i_pTarget,\n";
+print ASFILE " uint64_t & o_val,\n";
+print ASFILE " const uint32_t i_arrayIndex1,\n";
+print ASFILE " const uint32_t i_arrayIndex2,\n";
+print ASFILE " const uint32_t i_arrayIndex3,\n";
+print ASFILE " const uint32_t i_arrayIndex4)\n";
+print ASFILE "{\n";
+print ASFILE " ReturnCode l_rc;\n\n";
+
+my $xmlFiles = 0;
+my $attCount = 0;
+my $numIfAttrFiles = 0;
+my @attrIds;
+
+#------------------------------------------------------------------------------
+# Element names
+#------------------------------------------------------------------------------
+my $attribute = 'attribute';
+
+#------------------------------------------------------------------------------
+# For each argument
+#------------------------------------------------------------------------------
+foreach my $argnum (1 .. $#ARGV)
+{
+ my $infile = $ARGV[$argnum];
+
+ if ($infile eq '-a')
+ {
+ # Start of attribute XML files
+ $xmlFiles = 1;
+ next;
+ }
+
+ if ($xmlFiles == 0)
+ {
+ #----------------------------------------------------------------------
+ # Process initfile attr file. This file contains the HWPF attributes
+ # that the initfile uses.
+ #----------------------------------------------------------------------
+ $numIfAttrFiles++;
+ open(ATTRFILE, "<", $infile);
+
+ # Read each line of the file (each line contains an attribute)
+ while(my $fileAttrId = <ATTRFILE>)
+ {
+ # Remove newline
+ chomp($fileAttrId);
+
+ # Store the attribute in @attrIds if it does not already exist
+ my $match = 0;
+
+ foreach my $attrId (@attrIds)
+ {
+ if ($fileAttrId eq $attrId)
+ {
+ $match = 1;
+ last;
+ }
+ }
+
+ if (!($match))
+ {
+ push(@attrIds, $fileAttrId);
+ }
+ }
+
+ close(ATTRFILE);
+ }
+ else
+ {
+ #----------------------------------------------------------------------
+ # Process XML file. The ForceArray option ensures that there is an
+ # array of attributes even if there is only one attribute in the file
+ #----------------------------------------------------------------------
+ my $attributes = $xml->XMLin($infile, ForceArray => [$attribute]);
+
+ #----------------------------------------------------------------------
+ # For each Attribute
+ #----------------------------------------------------------------------
+ foreach my $attr (@{$attributes->{attribute}})
+ {
+ #------------------------------------------------------------------
+ # Check that the AttributeId exists
+ #------------------------------------------------------------------
+ if (! exists $attr->{id})
+ {
+ print ("createIfAttrService.pl ERROR. Att 'id' missing\n");
+ exit(1);
+ }
+
+ #------------------------------------------------------------------
+ # Find if the attribute is used by any initfile. If no if-attr
+ # files were specified then support all attributes
+ #------------------------------------------------------------------
+ my $match = 0;
+
+ if ($numIfAttrFiles)
+ {
+ foreach my $attrId (@attrIds)
+ {
+ if ($attr->{id} eq $attrId)
+ {
+ $match = 1;
+ last;
+ }
+ }
+ }
+ else
+ {
+ $match = 1;
+ }
+
+ if (!($match))
+ {
+ # Look at the next attribute in the XML file
+ next;
+ }
+
+ #------------------------------------------------------------------
+ # Figure out the number of attribute array dimensions
+ #------------------------------------------------------------------
+ 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);
+
+ $numArrayDimensions=@vals;
+ }
+
+ #------------------------------------------------------------------
+ # Print the attribute get code to fapi2_attribute_service.C
+ #------------------------------------------------------------------
+ if ($attCount > 0)
+ {
+ print ASFILE " else ";
+ }
+ else
+ {
+ print ASFILE " ";
+ }
+ $attCount++;
+
+ print ASFILE "if (i_id == $attr->{id})\n";
+ print ASFILE " {\n";
+ print ASFILE " $attr->{id}_Type l_attr;\n";
+
+ if (exists $attr->{privileged})
+ {
+ print ASFILE " l_rc = FAPI2_ATTR_GET_PRIVILEGED($attr->{id}, i_pTarget, l_attr);\n";
+ }
+ else
+ {
+ print ASFILE " l_rc = FAPI_ATTR_GET($attr->{id}, i_pTarget, l_attr);\n";
+ }
+ print ASFILE " o_val = l_attr";
+
+ if ($numArrayDimensions >= 5)
+ {
+ print ("createIfAttrService.pl ERROR. More than 4 array dimensions!!\n");
+ exit(1);
+ }
+ else
+ {
+ for (my $i = 0; $i < $numArrayDimensions; $i++)
+ {
+ print ASFILE "[i_arrayIndex";
+ print ASFILE $i+1;
+ print ASFILE "]";
+ }
+ }
+
+ print ASFILE ";\n";
+ print ASFILE " }\n";
+ }
+ }
+}
+
+#------------------------------------------------------------------------------
+# Print End of file information to fapi2_attribute_service.C
+#--------------------------------------------------------------------------
+if ($attCount > 0)
+{
+ print ASFILE " else\n";
+}
+print ASFILE " {\n";
+print ASFILE " FAPI_ERR(\"getInitFileAttr: Unrecognized attr ID: 0x%x\", i_id);\n";
+#print ASFILE " @thi TODO: - Resolve FFDC\n";
+print ASFILE " }\n\n";
+print ASFILE " if (l_rc)\n";
+print ASFILE " {\n";
+print ASFILE " if (i_pTarget)\n";
+print ASFILE " {\n";
+print ASFILE " FAPI_ERR(\"getInitFileAttr: Error getting attr ID 0x%x from targType 0x%x\",\n";
+print ASFILE " i_id, i_pTarget->getType());\n";
+print ASFILE " }\n";
+print ASFILE " else\n";
+print ASFILE " {\n";
+print ASFILE " FAPI_ERR(\"getInitFileAttr: Error getting attr ID 0x%x from system target\",\n";
+print ASFILE " i_id);\n";
+print ASFILE " }\n";
+print ASFILE " }\n\n";
+print ASFILE " return l_rc;\n";
+print ASFILE "}\n\n";
+print ASFILE "}\n";
+
+
+#------------------------------------------------------------------------------
+# Close output file
+#------------------------------------------------------------------------------
+close(ASFILE);
diff --git a/src/import/hwpf/fapi2/tools/parseAttributeInfo.pl b/src/import/hwpf/fapi2/tools/parseAttributeInfo.pl
new file mode 100755
index 000000000..d3a7512f7
--- /dev/null
+++ b/src/import/hwpf/fapi2/tools/parseAttributeInfo.pl
@@ -0,0 +1,743 @@
+#!/usr/bin/perl
+
+use strict;
+use Getopt::Long;
+
+#------------------------------------------------------------------------------
+# Print Command Line Help
+#------------------------------------------------------------------------------
+my $arg_output_dir = undef;
+
+# Get the options from the command line - the rest of @ARGV will
+# be filenames
+GetOptions("output-dir=s" => \$arg_output_dir);
+
+my $numArgs = $#ARGV + 1;
+if (($numArgs < 1) || ($arg_output_dir eq undef))
+{
+ print ("Usage: parseAttributeInfo.pl --output-dir=<output dir> <attr-xml-file1> [<attr-xml-file2> ...]\n");
+ print (" This perl script will parse attribute XML files and create the following files:\n");
+ print (" - attribute_ids.H. Contains IDs, type, value enums and other information\n");
+ print (" - fapi2_chip_ec_feature.C. Contains a function to query chip EC features\n");
+ print (" - attribute_plat_check.H Contains compile time checks that all attributes are\n");
+ print (" handled by the platform\n");
+ print (" - attributesSupported.html Contains the HWPF attributes supported\n");
+ print (" - attrInfo.csv Used to process Attribute Override Text files\n");
+ print (" - attrEnumInfo.csv Used to process Attribute Override Text files\n");
+ exit(1);
+}
+
+#------------------------------------------------------------------------------
+# Specify perl modules to use
+#------------------------------------------------------------------------------
+use Digest::MD5 qw(md5_hex);
+use XML::Simple;
+my $xml = new XML::Simple (KeyAttr=>[]);
+
+# Uncomment to enable debug output
+#use Data::Dumper;
+
+#------------------------------------------------------------------------------
+# Set PREFERRED_PARSER to XML::Parser. Otherwise it uses XML::SAX which contains
+# bugs that result in XML parse errors that can be fixed by adjusting white-
+# space (i.e. parse errors that do not make sense).
+#------------------------------------------------------------------------------
+$XML::Simple::PREFERRED_PARSER = 'XML::Parser';
+
+#------------------------------------------------------------------------------
+# Open output files for writing
+#------------------------------------------------------------------------------
+my $aiFile = $arg_output_dir;
+$aiFile .= "/";
+$aiFile .= "attribute_ids.H";
+open(AIFILE, ">", $aiFile);
+
+my $ecFile = $arg_output_dir;
+$ecFile .= "/";
+$ecFile .= "fapi2_chip_ec_feature.C";
+open(ECFILE, ">", $ecFile);
+
+my $acFile = $arg_output_dir;
+$acFile .= "/";
+$acFile .= "attribute_plat_check.H";
+open(ACFILE, ">", $acFile);
+
+my $asFile = $arg_output_dir;
+$asFile .= "/";
+$asFile .= "attributesSupported.html";
+open(ASFILE, ">", $asFile);
+
+my $itFile = $arg_output_dir;
+$itFile .= "/";
+$itFile .= "attrInfo.csv";
+open(ITFILE, ">", $itFile);
+
+my $etFile = $arg_output_dir;
+$etFile .= "/";
+$etFile .= "attrEnumInfo.csv";
+open(ETFILE, ">", $etFile);
+
+# TODO: This for platform use only, will support later via RTC 128106
+##my $fmFile = $ARGV[0];
+#$fmFile .= "/";
+#$fmFile .= "fapi2AttrOverrideData.H";
+#open(FMFILE, ">", $fmFile);
+
+#my $feFile = $ARGV[0];
+#$feFile .= "/";
+#$feFile .= "fapi2AttrOverrideEnums.H";
+#open(FEFILE, ">", $feFile);
+
+
+#------------------------------------------------------------------------------
+# Print Start of file information to attribute_ids.H
+#------------------------------------------------------------------------------
+print AIFILE "// attribute_ids.H\n";
+print AIFILE "// This file is generated by perl script parseAttributeInfo.pl\n\n";
+print AIFILE "#ifndef ATTRIBUTEIDS_H_\n";
+print AIFILE "#define ATTRIBUTEIDS_H_\n\n";
+print AIFILE "#include <target_types.H>\n\n";
+print AIFILE "\/**\n";
+print AIFILE " * \@brief Enumeration of attribute IDs\n";
+print AIFILE " *\/\n";
+print AIFILE "enum AttributeId\n{\n";
+
+#------------------------------------------------------------------------------
+# Print Start of file information to fapi2_chip_ec_feature.C
+#------------------------------------------------------------------------------
+print ECFILE "// fapi2_chip_ec_feature.C\n";
+print ECFILE "// This file is generated by perl script parseAttributeInfo.pl\n";
+print ECFILE "// It implements the queryfapi2_chip_ec_feature function\n\n";
+print ECFILE "#include <fapi2_chip_ec_feature.H>\n";
+print ECFILE "#include <fapi2_attribute_service.H>\n";
+print ECFILE "#include <systemConfig.H>\n";
+print ECFILE "#include <plat_trace.H>\n\n";
+print ECFILE "namespace fapi2\n";
+print ECFILE "{\n\n";
+print ECFILE "template< TargetType K >\n";
+print ECFILE "ReturnCode queryChipEcFeature(AttributeId i_id,\n";
+print ECFILE " const Target<K>& i_pTarget,\n";
+print ECFILE " uint8_t & o_hasFeature)\n";
+print ECFILE "{\n";
+print ECFILE " o_hasFeature = false;\n";
+print ECFILE " ReturnCode l_rc;\n";
+print ECFILE " uint8_t l_chipName = 0;\n";
+print ECFILE " uint8_t l_chipEc = 0;\n\n";
+print ECFILE " if (i_pTarget.isChiplet())\n";
+print ECFILE " {\n";
+print ECFILE " Target<TARGET_TYPE_ALL> l_target = i_pTarget.getParent();\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(\"queryChipEcFeature: 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(\"queryChipEcFeature: 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 attribute_plat_check.H
+#------------------------------------------------------------------------------
+print ACFILE "// attribute_plat_check.H\n";
+print ACFILE "// This file is generated by perl script parseAttributeInfo.pl\n";
+print ACFILE "// A platform can include it to ensure that it handles all HWPF\n";
+print ACFILE "// attributes\n\n";
+print ACFILE "#ifndef ATTRIBUTEPLATCHECK_H_\n";
+print ACFILE "#define ATTRIBUTEPLATCHECK_H_\n\n";
+
+#------------------------------------------------------------------------------
+# Print Start of file information to attributesSupported.html
+#------------------------------------------------------------------------------
+print ASFILE "<html>\n";
+print ASFILE "<body>\n\n";
+print ASFILE "<!-- attributesSupported.html -->\n";
+print ASFILE "<!-- This file is generated by perl script parseAttributeInfo.pl -->\n";
+print ASFILE "<!-- It lists all HWPF attributes supported -->\n\n";
+print ASFILE "<h4>HWPF Attributes supported by this build.</h4>\n";
+print ASFILE "<table border=\"4\">\n";
+print ASFILE "<tr><th>Attribute ID</th><th>Attribute Description</th></tr>";
+
+#------------------------------------------------------------------------------
+# Print Start of file information to attrInfo.csv
+#------------------------------------------------------------------------------
+print ITFILE "# attrInfo.csv\n";
+print ITFILE "# This file is generated by perl script parseAttributeInfo.pl\n";
+print ITFILE "# It lists information about FAPI attributes and is used to\n";
+print ITFILE "# process FAPI Attribute text files (overrides/syncs)\n";
+print ITFILE "# Format:\n";
+print ITFILE "# <FAPI-ATTR-ID-STR>,<LAYER-ATTR-ID-STR>,<ATTR-ID-VAL>,<ATTR-TYPE>\n";
+print ITFILE "# Note that for the AttributeTanks at the FAPI layer, the\n";
+print ITFILE "# FAPI-ATTR-ID-STR and LAYER-ATTR-ID-STR will be identical\n";
+
+#------------------------------------------------------------------------------
+# Print Start of file information to attrEnumInfo.csv
+#------------------------------------------------------------------------------
+print ETFILE "# attrEnumInfo.csv\n";
+print ETFILE "# This file is generated by perl script parseAttributeInfo.pl\n";
+print ETFILE "# It lists information about FAPI attribute enumeratorss and is\n";
+print ETFILE "# used to process FAPI Attribute text files (overrides/syncs)\n";
+print ETFILE "# Format:\n";
+print ETFILE "# <ENUM-STR>,<ENUM-VAL>\n";
+
+#-------------------------------------------------------------------------------
+# Print header of getFapiAttrData.C
+# ------------------------------------------------------------------------------
+#print FMFILE "const AttributeData g_FapiAttrs[] = {\n";
+#my %attrOverrideData = ();
+
+#-------------------------------------------------------------------------------
+# Print header of getFapiAttrEnumData.C
+# ------------------------------------------------------------------------------
+#print FEFILE "const AttributeEnum g_FapiEnums[] = {\n";
+#my @attrOverrideEnums = ();
+
+my %attrIdHash; # Records which Attribute IDs have been used
+my %attrValHash; # Records which Attribute values have been used
+
+#------------------------------------------------------------------------------
+# For each XML file
+#------------------------------------------------------------------------------
+foreach my $argnum (0 .. $#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']);
+
+ # Uncomment to get debug output of all attributes
+ #print "\nFile: ", $infile, "\n", Dumper($attributes), "\n";
+
+ #--------------------------------------------------------------------------
+ # For each Attribute
+ #--------------------------------------------------------------------------
+ foreach my $attr (@{$attributes->{attribute}})
+ {
+ #----------------------------------------------------------------------
+ # Print the Attribute ID and calculated value to attribute_ids.H and
+ # attribute_ids.txt. The value for an attribute is a hash value
+ # generated from the attribute name, this ties a specific value to a
+ # specific attribute name. This is done for Cronus so that if a HWP is
+ # not recompiled against a new eCMD/Cronus version where the attributes
+ # have changed then there will not be a mismatch in enumerator values.i
+ # Historically in P8, this is a 28bit hash value because the Initfile
+ # compiler has a requirement that the top nibble of the 32 bit attribute
+ # ID be zero to store flags. In P9, this may change because the
+ # Initfile compiler is re-designed.
+ #----------------------------------------------------------------------
+ if (! exists $attr->{id})
+ {
+ print ("parseAttributeInfo.pl ERROR. Att 'id' missing\n");
+ exit(1);
+ }
+
+ if (exists($attrIdHash{$attr->{id}}))
+ {
+ # Two different attributes with the same id!
+ print ("parseAttributeInfo.pl ERROR. Duplicate attr id ",
+ $attr->{id}, "\n");
+ exit(1);
+ }
+
+ # Calculate a 28 bit hash value.
+ my $attrHash128Bit = md5_hex($attr->{id});
+ my $attrHash28Bit = substr($attrHash128Bit, 0, 7);
+
+ # Print the attribute ID/value to attribute_ids.H
+ print AIFILE " $attr->{id} = 0x$attrHash28Bit,\n";
+
+ if (exists($attrValHash{$attrHash28Bit}))
+ {
+ # Two different attributes generate the same hash-value!
+ print ("parseAttributeInfo.pl ERROR. Duplicate attr id hash value for ",
+ $attr->{id}, "\n");
+ exit(1);
+ }
+
+ $attrIdHash{$attr->{id}} = $attrHash28Bit;
+ $attrValHash{$attrHash28Bit} = 1;
+ };
+}
+
+#------------------------------------------------------------------------------
+# Print AttributeId enumeration end to attribute_ids.H
+#------------------------------------------------------------------------------
+print AIFILE "};\n\n";
+
+#------------------------------------------------------------------------------
+# Print Attribute Information comment to attribute_ids.H
+#------------------------------------------------------------------------------
+print AIFILE "\/**\n";
+print AIFILE " * \@brief Attribute Information\n";
+print AIFILE " *\/\n";
+
+#------------------------------------------------------------------------------
+# For each XML file
+#------------------------------------------------------------------------------
+foreach my $argnum (0 .. $#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}})
+ {
+# my $attrOverride = "";
+ #----------------------------------------------------------------------
+ # Print a comment with the attribute ID attribute_ids.H
+ #----------------------------------------------------------------------
+ print AIFILE "/* $attr->{id} */\n";
+
+ #----------------------------------------------------------------------
+ # Print the AttributeId and description to attributesSupported.html
+ #----------------------------------------------------------------------
+ if (! exists $attr->{description})
+ {
+ print ("parseAttributeInfo.pl ERROR. Att 'description' missing\n");
+ exit(1);
+ }
+
+ print ASFILE "<tr>\n";
+ print ASFILE " <td>$attr->{id}</td>\n";
+ print ASFILE " <td>$attr->{description}</td>\n";
+ print ASFILE "</tr>\n";
+
+ #----------------------------------------------------------------------
+ # Print the assignment of each attribute to the local l_name
+ #----------------------------------------------------------------------
+# $attrOverride .= "\t{\n";
+# $attrOverride .= "\t\t\"$attr->{id}\",\n";
+
+ #----------------------------------------------------------------------
+ # Figure out the attribute array dimensions (if array)
+ #----------------------------------------------------------------------
+ my $arrayDimensions = "";
+ my @arrayDims = ();
+ if ($attr->{array})
+ {
+ # Remove leading whitespace
+ my $dimText = $attr->{array};
+ $dimText =~ s/^\s+//;
+
+ # Split on commas or whitespace
+ @arrayDims = split(/\s*,\s*|\s+/, $dimText);
+
+
+ foreach my $val (@arrayDims)
+ {
+ $arrayDimensions .= "[${val}]";
+ }
+ }
+ until ($#arrayDims == 3)
+ {
+ push @arrayDims, 1;
+ }
+ my $arrayDimString = join(", ", @arrayDims);
+
+ #----------------------------------------------------------------------
+ # Print the typedef for each attribute's val type to attribute_ids.H
+ # Print the attribute information to attrInfo.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},";
+ print ITFILE "0x$attrIdHash{$attr->{id}},u8\n";
+# $attrOverride .= "\t\t0x$attrIdHash{$attr->{id}},\n";
+# $attrOverride .= "\t\tsizeof(uint8_t),\n";
+# $attrOverride .= "\t\t{ $arrayDimString }\n";
+# $attrOverride .= "\t},\n";
+ }
+ else
+ {
+ if (! exists $attr->{valueType})
+ {
+ print ("parseAttributeInfo.pl ERROR. Att 'valueType' missing\n");
+ exit(1);
+ }
+
+ my @sizes = ( 'uint8', 'uint32', 'uint64', 'int8', 'int32', 'int64' );
+ my $actualSize = '';
+ foreach my $size (@sizes)
+ {
+ if ($attr->{valueType} eq $size)
+ {
+ $actualSize = $size;
+ last;
+ }
+ }
+ if ($actualSize ne '')
+ {
+
+ print AIFILE "typedef ${actualSize}_t $attr->{id}_Type$arrayDimensions;\n";
+ print ITFILE "$attr->{id},$attr->{id},0x$attrIdHash{$attr->{id}},u8" .
+ "$arrayDimensions\n";
+# $attrOverride .= "\t\t0x$attrIdHash{$attr->{id}},\n";
+# $attrOverride .= "\t\tsizeof(${actualSize}_t),\n";
+ }
+ else
+ {
+ print ("parseAttributeInfo.pl ERROR. valueType not recognized: ");
+ print $attr->{valueType}, "\n";
+ exit(1);
+ }
+# $attrOverride .= "\t\t{ $arrayDimString }\n";
+# $attrOverride .= "\t},\n";
+ }
+
+ #----------------------------------------------------------------------
+ # 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 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 target type(s) that the attribute is associated with
+ #----------------------------------------------------------------------
+ if (! exists $attr->{targetType})
+ {
+ print ("parseAttributeInfo.pl ERROR. Att 'targetType' missing\n");
+ exit(1);
+ }
+
+ print AIFILE "const fapi2::TargetType $attr->{id}_TargetType = ";
+
+ # 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 "fapi2::$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 the value enumeration (if specified) to attribute_ids.H and
+ # attributeEnums.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: <enum>VAL_A = 3, VAL_B = 5, VAL_C = 0x23</enum>
+ my @vals = split(',', $attr->{enum});
+
+ foreach my $val (@vals)
+ {
+ # Remove newlines and leading/trailing whitespace
+ $val =~ s/\n//;
+ $val =~ s/^\s+//;
+ $val =~ s/\s+$//;
+
+ my @values = split('=', ${val});
+ # Remove newlines and leading/trailing whitespace
+
+ foreach my $value (@values)
+ {
+ $value =~ s/\n//;
+ $value =~ s/^\s+//;
+ $value =~ s/\s+$//;
+ }
+
+# push @attrOverrideEnums,
+# "\t{ \"$attr->{id}_$values[0]\", $values[1] },\n";
+
+ # Print the attribute enum to attribute_ids.H
+ print AIFILE " ENUM_$attr->{id}_${val}";
+
+ # Print the attribute enum to attrEnumInfo.csv
+ my $attrEnumTxt = "$attr->{id}_${val}\n";
+
+
+ $attrEnumTxt =~ s/ = /,/;
+ print ETFILE $attrEnumTxt;
+
+
+ if ($attr->{valueType} eq 'uint64')
+ {
+ print AIFILE "ULL";
+ }
+ elsif ($attr->{valueType} eq 'int64')
+ {
+ print AIFILE "LL";
+ }
+
+ print AIFILE ",\n";
+ }
+
+ print AIFILE "};\n";
+ }
+
+ #----------------------------------------------------------------------
+ # Print _GETMACRO and _SETMACRO where appropriate to attribute_ids.H
+ #----------------------------------------------------------------------
+ if (exists $attr->{chipEcFeature})
+ {
+ #------------------------------------------------------------------
+ # The attribute is a Chip EC Feature, define _GETMACRO to call a
+ # fapi2 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) ? fapi2::FAPI2_RC_SUCCESS : \\\n";
+ print AIFILE " fapi2::queryChipEcFeature(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 fapi2_chip_ec_feature.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 ("parseAttributeInfo.pl ERROR. Att 'name' missing\n");
+ exit(1);
+ }
+
+ if (! exists $chip->{ec})
+ {
+ print ("parseAttributeInfo.pl ERROR. Att 'ec' missing\n");
+ exit(1);
+ }
+
+ if (! exists $chip->{ec}->{value})
+ {
+ print ("parseAttributeInfo.pl ERROR. Att 'value' missing\n");
+ exit(1);
+ }
+
+ if (! exists $chip->{ec}->{test})
+ {
+ print ("parseAttributeInfo.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 ("parseAttributeInfo.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 attribute_plat_check.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 attribute_ids.H
+ #----------------------------------------------------------------------
+ print AIFILE "\n";
+
+ #----------------------------------------------------------------------
+ # Add attribute override string to map.
+ #----------------------------------------------------------------------
+# $attrOverrideData{$attr->{id}} = $attrOverride;
+ };
+}
+
+#------------------------------------------------------------------------------
+# Print End of file information to attribute_ids.H
+#------------------------------------------------------------------------------
+#print AIFILE "}\n\n";
+print AIFILE "#endif\n";
+
+#------------------------------------------------------------------------------
+# Print End of file information to fapi2_chip_ec_feature.C
+#------------------------------------------------------------------------------
+print ECFILE " default:\n";
+print ECFILE " FAPI_ERR(\"queryChipEcFeature: 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(\"queryChipEcFeature: 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(\"queryChipEcFeature: 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 End of file information to attribute_plat_check.H
+#------------------------------------------------------------------------------
+print ACFILE "#endif\n";
+
+#------------------------------------------------------------------------------
+# Print End of file information to attributesSupported.html
+#------------------------------------------------------------------------------
+print ASFILE "</table>\n\n";
+print ASFILE "</body>\n";
+print ASFILE "</html>\n";
+
+#------------------------------------------------------------------------------
+# Print content for getFapiAttrData.C
+#------------------------------------------------------------------------------
+#foreach my $override (sort keys %attrOverrideData)
+#{
+# print FMFILE $attrOverrideData{$override};
+#}
+#print FMFILE "};\n";
+
+#------------------------------------------------------------------------------
+# Print footer for getFapiAttrEnumData.C
+#------------------------------------------------------------------------------
+#foreach my $override (sort @attrOverrideEnums)
+#{
+# print FEFILE $override;
+#}
+#print FEFILE "};\n";
+
+
+
+#------------------------------------------------------------------------------
+# Close output files
+#------------------------------------------------------------------------------
+close(AIFILE);
+close(ECFILE);
+close(ACFILE);
+close(ASFILE);
+close(ITFILE);
+close(ETFILE);
+#close(FMFILE);
+#close(FEFILE);
+
OpenPOWER on IntegriCloud