summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/usr/hwpf/fapi/fapi.H2
-rw-r--r--src/include/usr/hwpf/fapi/fapiAttributeService.H33
-rw-r--r--src/include/usr/hwpf/fapi/fapiChipEcFeature.H69
-rw-r--r--src/include/usr/hwpf/fapi/fapiReturnCodes.H4
-rwxr-xr-xsrc/include/usr/hwpf/plat/fapiPlatAttributeService.H132
-rw-r--r--src/include/usr/hwpf/plat/fapiPlatReasonCodes.H4
-rwxr-xr-xsrc/usr/hwpf/fapi/fapiParseAttributeInfo.pl237
-rw-r--r--src/usr/hwpf/fapi/makefile3
-rw-r--r--src/usr/hwpf/hwp/chip_attributes.xml16
-rw-r--r--src/usr/hwpf/hwp/chip_ec_attributes.xml74
-rw-r--r--src/usr/hwpf/makefile3
-rw-r--r--src/usr/hwpf/plat/fapiPlatAttributeService.C80
-rw-r--r--src/usr/hwpf/test/hwpftest.H43
13 files changed, 603 insertions, 97 deletions
diff --git a/src/include/usr/hwpf/fapi/fapi.H b/src/include/usr/hwpf/fapi/fapi.H
index a329472c8..5984c05b7 100644
--- a/src/include/usr/hwpf/fapi/fapi.H
+++ b/src/include/usr/hwpf/fapi/fapi.H
@@ -35,6 +35,7 @@
* mjjones 08/08/2011 Updated Executor include
* mjjones 09/23/2011 Added fapiHwpErrorInfo.H
* mjjones 11/10/2011 Use ecmdDataBufferBase
+ * mjjones 04/16/2012 Added fapiChipEcFeature.H
*/
#ifndef FAPI_H_
@@ -48,6 +49,7 @@
#include <fapiPlatTrace.H>
#include <fapiHwpExecutor.H>
#include <fapiAttributeService.H>
+#include <fapiChipEcFeature.H>
#include <fapiHwpReturnCodes.H> // Generated file
#include <fapiHwpErrorInfo.H> // Generated file
#include <fapiAttributeIds.H> // Generated file
diff --git a/src/include/usr/hwpf/fapi/fapiAttributeService.H b/src/include/usr/hwpf/fapi/fapiAttributeService.H
index bffe0341b..35f370c6d 100644
--- a/src/include/usr/hwpf/fapi/fapiAttributeService.H
+++ b/src/include/usr/hwpf/fapi/fapiAttributeService.H
@@ -39,6 +39,7 @@
* mjjones 10/13/2011 Added fapiGetInitFileAttr
* camvanng 10/20/2011 Changed i_pTarget to "const"
* ptr
+ * mjjones 04/10/2012 Support for privileged atts
*/
#ifndef FAPIATTRIBUTESERVICE_H_
@@ -64,18 +65,33 @@
* l_rc = FAPI_ATTR_GET(<ID>, l_pTarget, l_pVal);
* l_rc = FAPI_ATTR_SET(<ID>, l_pTarget, l_pVal);
*
- * The first part of these macros is a call to checkIdType that will cause a
+ * The first part of these macros is a call to fapiCheckIdType that will cause a
* compile failure if the ID or VAL parameters are incorrect.
*
- * The second part of these macros calls a macro named <ID>_GET/SETMACRO. This
+ * For the non-PRIVILEGED macros, the second part is a call to
+ * fapiFailIfPrivileged that will cause a compile failure if the attribute is
+ * privileged (in general, HWPs should not access privileged attributes.
+ * Examples include ATTR_NAME and ATTR_EC, where usage can lead to a non
+ * data-driven design).
+ *
+ * The final part of these macros calls a macro named <ID>_GET/SETMACRO. This
* macro is defined by PLAT and must do the work of getting/setting the
* attribute.
*/
#define FAPI_ATTR_GET(ID, PTARGET, VAL) \
(fapi::fapiCheckIdType<fapi::ID##_Type>(fapi::ID, VAL), \
+ fapi::fapiFailIfPrivileged<fapi::ID##_Privileged>(), \
ID##_GETMACRO(ID, PTARGET, VAL))
#define FAPI_ATTR_SET(ID, PTARGET, VAL) \
(fapi::fapiCheckIdType<fapi::ID##_Type>(fapi::ID, VAL), \
+ fapi::fapiFailIfPrivileged<fapi::ID##_Privileged>(), \
+ ID##_SETMACRO(ID, PTARGET, VAL))
+
+#define FAPI_ATTR_GET_PRIVILEGED(ID, PTARGET, VAL) \
+ (fapi::fapiCheckIdType<fapi::ID##_Type>(fapi::ID, VAL), \
+ ID##_GETMACRO(ID, PTARGET, VAL))
+#define FAPI_ATTR_SET_PRIVILEGED(ID, PTARGET, VAL) \
+ (fapi::fapiCheckIdType<fapi::ID##_Type>(fapi::ID, VAL), \
ID##_SETMACRO(ID, PTARGET, VAL))
namespace fapi
@@ -119,6 +135,19 @@ ReturnCode fapiGetInitFileAttr(const AttributeId i_id,
*/
template<typename T> void fapiCheckIdType(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 fapiFailIfPrivileged()
+{
+ ErrorAccessingPrivilegedAttribute();
+}
+template <> inline void fapiFailIfPrivileged<false>() {}
+
}
#endif // FAPIATTRIBUTESERVICE_H_
diff --git a/src/include/usr/hwpf/fapi/fapiChipEcFeature.H b/src/include/usr/hwpf/fapi/fapiChipEcFeature.H
new file mode 100644
index 000000000..66b611e1a
--- /dev/null
+++ b/src/include/usr/hwpf/fapi/fapiChipEcFeature.H
@@ -0,0 +1,69 @@
+// IBM_PROLOG_BEGIN_TAG
+// This is an automatically generated prolog.
+//
+// $Source: src/include/usr/hwpf/fapi/fapiChipEcFeature.H $
+//
+// IBM CONFIDENTIAL
+//
+// COPYRIGHT International Business Machines Corp. 2012
+//
+// p1
+//
+// Object Code Only (OCO) source materials
+// Licensed Internal Code Source Materials
+// IBM HostBoot Licensed Internal Code
+//
+// The source code for this program is not published or other-
+// wise divested of its trade secrets, irrespective of what has
+// been deposited with the U.S. Copyright Office.
+//
+// Origin: 30
+//
+// IBM_PROLOG_END
+/**
+ * @file fapiChipEcFeature.H
+ *
+ * @brief Defines the fapiQueryChipEcFeature 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
+ * fapiQueryChipEcFeature function implementation is auto-generated.
+ * HWPs should not call this function directly, but should access the
+ * corresponding HWPF attribute using FAPI_ATTR_GET
+ */
+
+/*
+ * Change Log ******************************************************************
+ * Flag Defect/Feature User Date Description
+ * ------ -------------- ---------- ----------- ----------------------------
+ * mjjones 03/26/2012 Created.
+ */
+
+#ifndef FAPICHIPECFEATURE_H_
+#define FAPICHIPECFEATURE_H_
+
+#include <stdint.h>
+#include <fapiAttributeIds.H>
+#include <fapiReturnCode.H>
+
+namespace fapi
+{
+
+class Target;
+
+/**
+ * @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_pTarget Pointer 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
+ */
+fapi::ReturnCode fapiQueryChipEcFeature(fapi::AttributeId i_id,
+ fapi::Target * i_pTarget,
+ uint8_t & o_hasFeature);
+}
+
+#endif
diff --git a/src/include/usr/hwpf/fapi/fapiReturnCodes.H b/src/include/usr/hwpf/fapi/fapiReturnCodes.H
index 011b8e814..4c18346f5 100644
--- a/src/include/usr/hwpf/fapi/fapiReturnCodes.H
+++ b/src/include/usr/hwpf/fapi/fapiReturnCodes.H
@@ -39,6 +39,7 @@
* mjjones 10/28/2011 Trim FAPI/PLAT errors
* mjjones 11/10/2011 Use ecmdDataBufferBase
* mjjones 01/13/2012 Name enumeration
+ * mjjones 04/16/2012 Add FAPI_RC_INVALID_CHIP_EC_FEATURE_GET
*/
#ifndef FAPIRETURNCODES_H_
@@ -66,7 +67,8 @@ enum ReturnCodes
FAPI_RC_ECMD_MASK = ECMD_ERR_ECMD, // ECMD generated error (0x01000000)
// FAPI generated return codes
- FAPI_RC_INVALID_ATTR_GET = FAPI_RC_FAPI_MASK | 0x01,
+ FAPI_RC_INVALID_ATTR_GET = FAPI_RC_FAPI_MASK | 0x01,
+ FAPI_RC_INVALID_CHIP_EC_FEATURE_GET = FAPI_RC_FAPI_MASK | 0x02,
// PLAT generated return codes
FAPI_RC_PLAT_ERR_SEE_DATA = FAPI_RC_PLAT_MASK | 0x01,
diff --git a/src/include/usr/hwpf/plat/fapiPlatAttributeService.H b/src/include/usr/hwpf/plat/fapiPlatAttributeService.H
index 254dfd36e..7b35d919f 100755
--- a/src/include/usr/hwpf/plat/fapiPlatAttributeService.H
+++ b/src/include/usr/hwpf/plat/fapiPlatAttributeService.H
@@ -63,65 +63,41 @@ namespace fapi
namespace platAttrSvc
{
- /**
- * @brief Returns the system target
- *
- * @par Detailed Description:
- * Returns the system target. If the target service has not been
- * initialized -or- there is any failure to acquire it, the function
- * will assert
- *
- * @return Target handle to the system target
- *
- * @retval !NULL An actual target handle
- * @retval NULL Not possible
- */
- TARGETING::Target* getSystemTarget();
- /**
- * @brief Returns a fapiReturn code containing information on an attribute
- * access error
- *
- * @param[in] i_targAttrId Platform attribute ID
- * @param[in] i_fapiAttrId FAPI attribute ID which maps to the platform
- * attribute ID
- * @param[in] i_pFapiTarget Pointer to the FAPI target holding the
- * requested attribute
- *
- * @return fapiReturn code containing a platform generated error log
- *
- * @retval FAPI_RC_PLAT_ERR_SEE_DATA (return code value) which informs
- * caller there is a host boot error log attached
- */
- fapi::ReturnCode createAttrAccessError(
- const TARGETING::ATTRIBUTE_ID i_targAttrId,
- const fapi::AttributeId i_fapiAttrId,
- const fapi::Target* i_pFapiTarget);
+/**
+ * @brief Returns the system target
+ *
+ * @par Detailed Description:
+ * Returns the system target. If the target service has not been
+ * initialized -or- there is any failure to acquire it, the function
+ * will assert
+ *
+ * @return Target handle to the system target
+ *
+ * @retval !NULL An actual target handle
+ * @retval NULL Not possible
+ */
+TARGETING::Target* getSystemTarget();
- /**
- * @brief Macro which directly maps a FAPI request to get a platform
- * attribute to the equivalent host boot request
- */
- #define FAPI_PLAT_ATTR_SVC_GETMACRO_DIRECT(ID, PTARGET, VAL) \
- ( ((PTARGET > 0) ? \
- static_cast<TARGETING::Target*>( \
- static_cast<const fapi::Target*>(PTARGET)->get()) \
- : fapi::platAttrSvc::getSystemTarget())->tryGetAttr< \
- FAPI_PLAT_ATTR_SVC_MACRO_DIRECT_FAPI_##ID>(VAL)) \
- ? fapi::FAPI_RC_SUCCESS : fapi::platAttrSvc::createAttrAccessError( \
- FAPI_PLAT_ATTR_SVC_MACRO_DIRECT_FAPI_##ID,fapi::ID,PTARGET)
- /**
- * @brief Macro which directly maps a FAPI request to set a platform
- * attribute to the equivalent host boot request
- */
- #define FAPI_PLAT_ATTR_SVC_SETMACRO_DIRECT(ID, PTARGET, VAL) \
- ( ((PTARGET > 0) ? \
- static_cast<TARGETING::Target*>( \
- static_cast<const fapi::Target*>(PTARGET)->get()) \
- : fapi::platAttrSvc::getSystemTarget())->trySetAttr< \
- FAPI_PLAT_ATTR_SVC_MACRO_DIRECT_FAPI_##ID>(VAL)) \
- ? fapi::FAPI_RC_SUCCESS : fapi::platAttrSvc::createAttrAccessError( \
- FAPI_PLAT_ATTR_SVC_MACRO_DIRECT_FAPI_##ID,fapi::ID,PTARGET)
+/**
+ * @brief Returns a fapiReturn code containing information on an attribute
+ * access error
+ *
+ * @param[in] i_targAttrId Platform attribute ID
+ * @param[in] i_fapiAttrId FAPI attribute ID which maps to the platform
+ * attribute ID
+ * @param[in] i_pFapiTarget Pointer to the FAPI target holding the
+ * requested attribute
+ *
+ * @return fapiReturn code containing a platform generated error log
+ *
+ * @retval FAPI_RC_PLAT_ERR_SEE_DATA (return code value) which informs
+ * caller there is a host boot error log attached
+ */
+fapi::ReturnCode createAttrAccessError(
+ const TARGETING::ATTRIBUTE_ID i_targAttrId,
+ const fapi::AttributeId i_fapiAttrId,
+ const fapi::Target* i_pFapiTarget);
/**
* @brief This function is called by the FAPI_ATTR_GET macro when accessing
@@ -186,10 +162,46 @@ fapi::ReturnCode fapiPlatGetMirrorBaseAddr(const fapi::Target * i_pMcsTarget,
fapi::ReturnCode fapiPlatGetDqMapping(const fapi::Target * i_pDimmTarget,
uint8_t (&o_data)[DIMM_DQ_NUM_DQS]);
+/**
+ * @brief This function is called by the FAPI_ATTR_GET macro when getting
+ * ATTR_NAME. It should not be called directly
+ *
+ * @param[in] i_pTarget Target pointer
+ * @param[out] o_name Output Name (from enum ATTR_NAME_Enum)
+ * @return ReturnCode. Zero on success, else platform specified error
+ */
+fapi::ReturnCode fapiPlatGetTargetName(const fapi::Target * i_pTarget,
+ uint8_t & o_name);
+
}
}
+/**
+ * @brief Macro which directly maps a FAPI request to get a platform
+ * attribute to the equivalent host boot request
+ */
+#define FAPI_PLAT_ATTR_SVC_GETMACRO_DIRECT(ID, PTARGET, VAL) \
+ ( ((PTARGET > 0) ? \
+ static_cast<TARGETING::Target*>( \
+ static_cast<const fapi::Target*>(PTARGET)->get()) \
+ : fapi::platAttrSvc::getSystemTarget())->tryGetAttr< \
+ FAPI_PLAT_ATTR_SVC_MACRO_DIRECT_FAPI_##ID>(VAL)) \
+ ? fapi::FAPI_RC_SUCCESS : fapi::platAttrSvc::createAttrAccessError( \
+ FAPI_PLAT_ATTR_SVC_MACRO_DIRECT_FAPI_##ID,fapi::ID,PTARGET)
+/**
+ * @brief Macro which directly maps a FAPI request to set a platform
+ * attribute to the equivalent host boot request
+ */
+#define FAPI_PLAT_ATTR_SVC_SETMACRO_DIRECT(ID, PTARGET, VAL) \
+ ( ((PTARGET > 0) ? \
+ static_cast<TARGETING::Target*>( \
+ static_cast<const fapi::Target*>(PTARGET)->get()) \
+ : fapi::platAttrSvc::getSystemTarget())->trySetAttr< \
+ FAPI_PLAT_ATTR_SVC_MACRO_DIRECT_FAPI_##ID>(VAL)) \
+ ? fapi::FAPI_RC_SUCCESS : fapi::platAttrSvc::createAttrAccessError( \
+ FAPI_PLAT_ATTR_SVC_MACRO_DIRECT_FAPI_##ID,fapi::ID,PTARGET)
+
//------------------------------------------------------------------------------
// MACROs to route each ATTR_SPD access to the Hostboot SPD function
//------------------------------------------------------------------------------
@@ -301,4 +313,10 @@ fapi::ReturnCode fapiPlatGetDqMapping(const fapi::Target * i_pDimmTarget,
#define ATTR_CEN_DQ_TO_DIMM_CONN_DQ_GETMACRO(ID, PTARGET, VAL) \
fapi::platAttrSvc::fapiPlatGetDqMapping(PTARGET, VAL)
+//------------------------------------------------------------------------------
+// MACRO to route ATTR_NAME access to the correct Hostboot function
+//------------------------------------------------------------------------------
+#define ATTR_NAME_GETMACRO(ID, PTARGET, VAL) \
+ fapi::platAttrSvc::fapiPlatGetTargetName(PTARGET, VAL)
+
#endif // FAPIPLATATTRIBUTESERVICE_H_
diff --git a/src/include/usr/hwpf/plat/fapiPlatReasonCodes.H b/src/include/usr/hwpf/plat/fapiPlatReasonCodes.H
index b48d43623..f4050a4f1 100644
--- a/src/include/usr/hwpf/plat/fapiPlatReasonCodes.H
+++ b/src/include/usr/hwpf/plat/fapiPlatReasonCodes.H
@@ -47,7 +47,7 @@ namespace fapi
MOD_ATTR_BASE_ADDR_GET = 0x08,
MOD_ATTR_DQ_MAP_GET = 0x09,
MOD_GET_CFAM_CHIP_TARGET = 0x0A,
-
+ MOD_ATTR_GET_TARGET_NAME = 0x0B,
};
/**
@@ -68,7 +68,7 @@ namespace fapi
RC_FAILED_TO_ACCESS_ATTRIBUTE = HWPF_COMP_ID | 0x13,
RC_ECMD_OPERATION_FAILURE = HWPF_COMP_ID | 0x14,
RC_CFAM_ACCESS_ON_PROC_ERR = HWPF_COMP_ID | 0x15,
- RC_ATTR_BASE_BAD_PARAM = HWPF_COMP_ID | 0x16,
+ RC_ATTR_BAD_TARGET_PARAM = HWPF_COMP_ID | 0x16,
RC_INVALID_NUM_PARENT_CHIP = HWPF_COMP_ID | 0x17,
};
diff --git a/src/usr/hwpf/fapi/fapiParseAttributeInfo.pl b/src/usr/hwpf/fapi/fapiParseAttributeInfo.pl
index 54349fadd..988bb208e 100755
--- a/src/usr/hwpf/fapi/fapiParseAttributeInfo.pl
+++ b/src/usr/hwpf/fapi/fapiParseAttributeInfo.pl
@@ -53,6 +53,7 @@
# Generate fapiAttributesSupported.html
# mjjones 02/08/12 Handle attribute files with 1 entry
# mjjones 03/22/12 Generate hash values for enums
+# mjjones 04/10/12 Process Chip EC Feature attributes
#
# End Change Log ******************************************************
@@ -98,6 +99,11 @@ $aiFile .= "/";
$aiFile .= "fapiAttributeIds.H";
open(AIFILE, ">", $aiFile);
+my $ecFile = $ARGV[0];
+$ecFile .= "/";
+$ecFile .= "fapiChipEcFeature.C";
+open(ECFILE, ">", $ecFile);
+
my $acFile = $ARGV[0];
$acFile .= "/";
$acFile .= "fapiAttributePlatCheck.H";
@@ -123,6 +129,41 @@ 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 <fapiChipEcFeature.H>\n";
+print ECFILE "#include <fapiAttributeService.H>\n\n";
+print ECFILE "namespace fapi\n";
+print ECFILE "{\n\n";
+print ECFILE "fapi::ReturnCode fapiQueryChipEcFeature(fapi::AttributeId i_id,\n";
+print ECFILE " 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\n";
+print ECFILE " l_rc = FAPI_ATTR_GET_PRIVILEGED(ATTR_NAME, i_pTarget, 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, i_pTarget, 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 fapiAttributePlatCheck.H
#------------------------------------------------------------------------------
print ACFILE "// fapiAttributePlatCheck.H\n";
@@ -145,11 +186,6 @@ print ASFILE "<table border=\"4\">\n";
print ASFILE "<tr><th>Attribute ID</th><th>Attribute Description</th></tr>";
#------------------------------------------------------------------------------
-# Element names
-#------------------------------------------------------------------------------
-my $attribute = 'attribute';
-
-#------------------------------------------------------------------------------
# For each XML file
#------------------------------------------------------------------------------
foreach my $argnum (1 .. $#ARGV)
@@ -158,8 +194,8 @@ foreach my $argnum (1 .. $#ARGV)
my %enumHash;
# read 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]);
+ # 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";
@@ -222,8 +258,8 @@ foreach my $argnum (1 .. $#ARGV)
my $infile = $ARGV[$argnum];
# read 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]);
+ # elements even if there is only one such element in the file
+ my $attributes = $xml->XMLin($infile, ForceArray => ['attribute', 'chip']);
#--------------------------------------------------------------------------
# For each Attribute
@@ -275,29 +311,49 @@ foreach my $argnum (1 .. $#ARGV)
#----------------------------------------------------------------------
# Print the typedef for each attribute's val type to fapiAttributeIds.H
#----------------------------------------------------------------------
- if (! exists $attr->{valueType})
+ if (exists $attr->{chipEcFeature})
{
- print ("fapiParseAttributeInfo.pl ERROR. Att 'valueType' missing\n");
- exit(1);
+ # The value type of chip EC feature attributes is uint8_t
+ print AIFILE "typedef uint8_t $attr->{id}_Type;\n";
}
-
- if ($attr->{valueType} eq 'uint8')
- {
- print AIFILE "typedef uint8_t $attr->{id}_Type$arrayDimensions;\n";
- }
- elsif ($attr->{valueType} eq 'uint32')
+ else
{
- print AIFILE "typedef uint32_t $attr->{id}_Type$arrayDimensions;\n";
+ 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";
+ }
+ elsif ($attr->{valueType} eq 'uint32')
+ {
+ print AIFILE "typedef uint32_t $attr->{id}_Type$arrayDimensions;\n";
+ }
+ elsif ($attr->{valueType} eq 'uint64')
+ {
+ print AIFILE "typedef uint64_t $attr->{id}_Type$arrayDimensions;\n";
+ }
+ else
+ {
+ print ("fapiParseAttributeInfo.pl ERROR. valueType not recognized: ");
+ print $attr->{valueType}, "\n";
+ exit(1);
+ }
}
- elsif ($attr->{valueType} eq 'uint64')
+
+ #----------------------------------------------------------------------
+ # Print if the attribute is privileged
+ #----------------------------------------------------------------------
+ if (exists $attr->{privileged})
{
- print AIFILE "typedef uint64_t $attr->{id}_Type$arrayDimensions;\n";
+ print AIFILE "const bool $attr->{id}_Privileged = true;\n";
}
else
{
- print ("fapiParseAttributeInfo.pl ERROR. valueType not recognized: ");
- print $attr->{valueType}, "\n";
- exit(1);
+ print AIFILE "const bool $attr->{id}_Privileged = false;\n";
}
#----------------------------------------------------------------------
@@ -322,12 +378,110 @@ foreach my $argnum (1 .. $#ARGV)
}
#----------------------------------------------------------------------
- # If the attribute is read-only then define the _SETMACRO to something
- # that will cause a compile failure if a set is attempted
+ # Print _GETMACRO and _SETMACRO where appropriate to fapiAttributeIds.H
#----------------------------------------------------------------------
- if (! exists $attr->{writeable})
+ if (exists $attr->{chipEcFeature})
{
- print AIFILE "#define $attr->{id}_SETMACRO ATTRIBUTE_NOT_WRITABLE\n";
+ #------------------------------------------------------------------
+ # 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) ";
+ print AIFILE "fapi::fapiQueryChipEcFeature(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
+ #----------------------------------------------------------------------
+ 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";
}
#----------------------------------------------------------------------
@@ -358,6 +512,33 @@ print AIFILE "}\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 " fapi::ReturnCodeFfdc::addEIFfdc(l_rc, 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 " return l_rc;\n";
+print ECFILE "}\n\n";
+print ECFILE "}\n";
+
+
+#------------------------------------------------------------------------------
# Print End of file information to fapiAttributePlatCheck.H
#------------------------------------------------------------------------------
print ACFILE "#endif\n";
diff --git a/src/usr/hwpf/fapi/makefile b/src/usr/hwpf/fapi/makefile
index de126cf31..262a73ece 100644
--- a/src/usr/hwpf/fapi/makefile
+++ b/src/usr/hwpf/fapi/makefile
@@ -33,7 +33,8 @@ OBJS = fapiReturnCode.o \
fapiTarget.o \
fapiHwAccess.o \
fapiErrorInfo.o \
- fapiAttributeService.o
+ fapiAttributeService.o \
+ fapiChipEcFeature.o
include ${ROOTPATH}/config.mk
diff --git a/src/usr/hwpf/hwp/chip_attributes.xml b/src/usr/hwpf/hwp/chip_attributes.xml
index 7ab806ccc..8a71d5bde 100644
--- a/src/usr/hwpf/hwp/chip_attributes.xml
+++ b/src/usr/hwpf/hwp/chip_attributes.xml
@@ -40,6 +40,19 @@
</attribute>
<!-- ********************************************************************* -->
<attribute>
+ <id>ATTR_NAME</id>
+ <targetType>TARGET_TYPE_PROC_CHIP,TARGET_TYPE_MEMBUF_CHIP</targetType>
+ <description>Product name of a chip target</description>
+ <valueType>uint8</valueType>
+ <enum>NONE = 0, VENICE = 1, MURANO = 2, CENTAUR = 3</enum>
+ <platInit/>
+ <persistRuntime/>
+ <!-- To make HWPs data driven, this is a privileged attribute that cannot
+ be accessed by normal HWPs. -->
+ <privileged/>
+ </attribute>
+ <!-- ********************************************************************* -->
+ <attribute>
<id>ATTR_EC</id>
<targetType>TARGET_TYPE_PROC_CHIP,TARGET_TYPE_MEMBUF_CHIP</targetType>
<description>
@@ -49,6 +62,9 @@
<valueType>uint8</valueType>
<platInit/>
<persistRuntime/>
+ <!-- To make HWPs data driven, this is a privileged attribute that cannot
+ be accessed by normal HWPs. -->
+ <privileged/>
</attribute>
<!-- ********************************************************************* -->
<attribute>
diff --git a/src/usr/hwpf/hwp/chip_ec_attributes.xml b/src/usr/hwpf/hwp/chip_ec_attributes.xml
new file mode 100644
index 000000000..c8da585bd
--- /dev/null
+++ b/src/usr/hwpf/hwp/chip_ec_attributes.xml
@@ -0,0 +1,74 @@
+<!-- IBM_PROLOG_BEGIN_TAG
+ This is an automatically generated prolog.
+
+ $Source: src/usr/hwpf/hwp/chip_ec_attributes.xml $
+
+ IBM CONFIDENTIAL
+
+ COPYRIGHT International Business Machines Corp. 2012
+
+ p1
+
+ Object Code Only (OCO) source materials
+ Licensed Internal Code Source Materials
+ IBM HostBoot Licensed Internal Code
+
+ The source code for this program is not published or other-
+ wise divested of its trade secrets, irrespective of what has
+ been deposited with the U.S. Copyright Office.
+
+ Origin: 30
+
+ IBM_PROLOG_END -->
+<!--
+ XML file specifying HWPF attributes.
+ These are example Chip EC Feature attributes that specify chip features
+ based on the EC level of a chip
+-->
+
+<attributes>
+ <!-- ********************************************************************* -->
+ <attribute>
+ <id>ATTR_CHIP_EC_FEATURE_TEST1</id>
+ <targetType>TARGET_TYPE_PROC_CHIP, TARGET_TYPE_MEMBUF_CHIP</targetType>
+ <description>
+ Returns if a chip contains the TEST1 feature. True if either:
+ Centaur EC 10
+ Venice EC greater than 30
+ </description>
+ <chipEcFeature>
+ <chip>
+ <name>ENUM_ATTR_NAME_CENTAUR</name>
+ <ec>
+ <value>10</value>
+ <test>EQUAL</test>
+ </ec>
+ </chip>
+ <chip>
+ <name>ENUM_ATTR_NAME_VENICE</name>
+ <ec>
+ <value>30</value>
+ <test>GREATER_THAN</test>
+ </ec>
+ </chip>
+ </chipEcFeature>
+ </attribute>
+ <!-- ********************************************************************* -->
+ <attribute>
+ <id>ATTR_CHIP_EC_FEATURE_TEST2</id>
+ <targetType>TARGET_TYPE_PROC_CHIP, TARGET_TYPE_MEMBUF_CHIP</targetType>
+ <description>
+ Returns if a chip contains the TEST2 feature. True if:
+ Murano EC less than 20
+ </description>
+ <chipEcFeature>
+ <chip>
+ <name>ENUM_ATTR_NAME_MURANO</name>
+ <ec>
+ <value>20</value>
+ <test>LESS_THAN</test>
+ </ec>
+ </chip>
+ </chipEcFeature>
+ </attribute>
+</attributes>
diff --git a/src/usr/hwpf/makefile b/src/usr/hwpf/makefile
index f49cc482d..781a9934d 100644
--- a/src/usr/hwpf/makefile
+++ b/src/usr/hwpf/makefile
@@ -46,7 +46,8 @@ HWP_ATTR_XML_FILES = hwp/memory_attributes.xml \
hwp/dimm_attributes.xml \
hwp/unit_attributes.xml \
hwp/freq_attributes.xml \
- hwp/proc_mvpd_attributes.xml
+ hwp/proc_mvpd_attributes.xml \
+ hwp/chip_ec_attributes.xml
#------------------------------------------------------------------------------
# Initfiles
diff --git a/src/usr/hwpf/plat/fapiPlatAttributeService.C b/src/usr/hwpf/plat/fapiPlatAttributeService.C
index 72c4a5b3e..c0b9bb3dd 100644
--- a/src/usr/hwpf/plat/fapiPlatAttributeService.C
+++ b/src/usr/hwpf/plat/fapiPlatAttributeService.C
@@ -295,14 +295,14 @@ fapi::ReturnCode fapiPlatBaseAddrCheckMcsGetChip(
/*@
* @errortype
* @moduleid MOD_ATTR_BASE_ADDR_GET
- * @reasoncode RC_ATTR_BASE_BAD_PARAM
+ * @reasoncode RC_ATTR_BAD_TARGET_PARAM
* @devdesc Failed to get MCS base address attribute due to
* bad target parameter.
*/
errlHndl_t l_pError = new ERRORLOG::ErrlEntry(
ERRORLOG::ERRL_SEV_INFORMATIONAL,
fapi::MOD_ATTR_BASE_ADDR_GET,
- fapi::RC_ATTR_BASE_BAD_PARAM);
+ fapi::RC_ATTR_BAD_TARGET_PARAM);
l_rc.setPlatError(reinterpret_cast<void *> (l_pError));
}
@@ -450,14 +450,86 @@ fapi::ReturnCode fapiPlatGetDqMapping(const fapi::Target * i_pDimmTarget,
/*@
* @errortype
* @moduleid MOD_ATTR_DQ_MAP_GET
- * @reasoncode RC_ATTR_BASE_BAD_PARAM
+ * @reasoncode RC_ATTR_BAD_TARGET_PARAM
* @devdesc Failed to get DIMM DQ mapping attribute due to
* bad target parameter.
*/
errlHndl_t l_pError = new ERRORLOG::ErrlEntry(
ERRORLOG::ERRL_SEV_INFORMATIONAL,
fapi::MOD_ATTR_DQ_MAP_GET,
- fapi::RC_ATTR_BASE_BAD_PARAM);
+ fapi::RC_ATTR_BAD_TARGET_PARAM);
+ l_rc.setPlatError(reinterpret_cast<void *> (l_pError));
+ }
+
+ return l_rc;
+}
+
+//******************************************************************************
+// fapiPlatGetTargetName function
+//******************************************************************************
+fapi::ReturnCode fapiPlatGetTargetName(const fapi::Target * i_pTarget,
+ uint8_t & o_name)
+{
+ fapi::ReturnCode l_rc;
+ o_name = ENUM_ATTR_NAME_NONE;
+ bool l_error = false;
+
+ // Check that the FAPI Target pointer is not NULL
+ if (i_pTarget == NULL)
+ {
+ FAPI_ERR("fapiPlatGetTargetName. NULL FAPI Target passed");
+ l_error = true;
+ }
+ else
+ {
+ // Extract the MCS Hostboot Target pointer
+ TARGETING::Target * l_pHbTarget = reinterpret_cast<TARGETING::Target*>(
+ i_pTarget->get());
+
+ // Check that the MCS Hostboot Target pointer is not NULL
+ if (l_pHbTarget == NULL)
+ {
+ FAPI_ERR("fapiPlatGetTargetName. NULL HB Target passed");
+ l_error = true;
+ }
+ else
+ {
+ TARGETING::MODEL l_model = l_pHbTarget->
+ getAttr<TARGETING::ATTR_MODEL>();
+
+ if (l_model == TARGETING::MODEL_VENICE)
+ {
+ o_name = ENUM_ATTR_NAME_VENICE;
+ }
+ else if (l_model == TARGETING::MODEL_MURANO)
+ {
+ o_name = ENUM_ATTR_NAME_MURANO;
+ }
+ else if (l_model == TARGETING::MODEL_CENTAUR)
+ {
+ o_name = ENUM_ATTR_NAME_CENTAUR;
+ }
+ else
+ {
+ FAPI_ERR("fapiPlatGetTargetName. Unknown name 0x%x", l_model);
+ l_error = true;
+ }
+ }
+ }
+
+ if (l_error)
+ {
+ /*@
+ * @errortype
+ * @moduleid MOD_ATTR_GET_TARGET_NAME
+ * @reasoncode RC_ATTR_BAD_TARGET_PARAM
+ * @devdesc Failed to get the Target name due to bad target
+ * parameter.
+ */
+ errlHndl_t l_pError = new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_INFORMATIONAL,
+ fapi::MOD_ATTR_GET_TARGET_NAME,
+ fapi::RC_ATTR_BAD_TARGET_PARAM);
l_rc.setPlatError(reinterpret_cast<void *> (l_pError));
}
diff --git a/src/usr/hwpf/test/hwpftest.H b/src/usr/hwpf/test/hwpftest.H
index ee308701c..a74f357ef 100644
--- a/src/usr/hwpf/test/hwpftest.H
+++ b/src/usr/hwpf/test/hwpftest.H
@@ -401,7 +401,7 @@ public:
// Test ATTR_EC attribute access through FAPI
uint8_t l_EC_R = 0xFF;
- l_rc = FAPI_ATTR_GET(ATTR_EC, &l_fapiTarget, l_EC_R);
+ l_rc = FAPI_ATTR_GET_PRIVILEGED(ATTR_EC, &l_fapiTarget, l_EC_R);
if (l_rc != fapi::FAPI_RC_SUCCESS)
{
TS_FAIL("testHwpf5: ATTR_EC. Error from GET");
@@ -730,6 +730,47 @@ public:
TS_TRACE("testHwpf9: No MBAs found, skipping test");
}
}
+
+ /**
+ * @brief Access the test Chip EC Feature attributes
+ */
+ void testHwpf10()
+ {
+ fapi::ReturnCode l_rc;
+ uint8_t l_chipHasFeature = 0xff;
+
+ // Get the master processor chip
+ TARGETING::Target* l_pTarget = NULL;
+ TARGETING::targetService().masterProcChipTargetHandle(l_pTarget);
+
+ // Create a FAPI Target
+ fapi::Target l_fapiTarget(TARGET_TYPE_PROC_CHIP,
+ reinterpret_cast<void *> (l_pTarget));
+
+ l_rc = FAPI_ATTR_GET(ATTR_CHIP_EC_FEATURE_TEST1, &l_fapiTarget,
+ l_chipHasFeature);
+ if (l_rc)
+ {
+ TS_FAIL("testHwpf10: ATTR_CHIP_EC_FEATURE_TEST1 get failed.");
+ }
+ else
+ {
+ FAPI_INF("testHwpf10: ATTR_CHIP_EC_FEATURE_TEST1: %d", l_chipHasFeature);
+
+ l_chipHasFeature = 0xff;
+ l_rc = FAPI_ATTR_GET(ATTR_CHIP_EC_FEATURE_TEST2, &l_fapiTarget,
+ l_chipHasFeature);
+ if (l_rc)
+ {
+ TS_FAIL("testHwpf10: ATTR_CHIP_EC_FEATURE_TEST2 get failed.");
+ }
+ else
+ {
+ FAPI_INF("testHwpf10: ATTR_CHIP_EC_FEATURE_TEST2: %d", l_chipHasFeature);
+ }
+ }
+ }
+
};
#endif
OpenPOWER on IntegriCloud