summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr/hwpf')
-rw-r--r--src/usr/hwpf/fapi/fapiAttributeOverride.C331
-rw-r--r--src/usr/hwpf/fapi/fapiAttributeTank.C443
-rwxr-xr-xsrc/usr/hwpf/fapi/fapiParseAttributeInfo.pl48
-rw-r--r--src/usr/hwpf/fapi/makefile2
-rw-r--r--src/usr/hwpf/hwp/fapiTestHwp.C6
-rwxr-xr-xsrc/usr/hwpf/hwp/fapiTestHwpAttr.C578
-rw-r--r--src/usr/hwpf/plat/fapiPlatAttrOverrideDirect.C56
-rw-r--r--src/usr/hwpf/plat/fapiPlatAttrOverrideSync.C371
-rw-r--r--src/usr/hwpf/plat/fapiPlatAttributeService.C91
-rw-r--r--src/usr/hwpf/plat/fapiPlatTask.C43
-rw-r--r--src/usr/hwpf/plat/makefile30
-rw-r--r--src/usr/hwpf/test/hwpftest.H44
12 files changed, 1227 insertions, 816 deletions
diff --git a/src/usr/hwpf/fapi/fapiAttributeOverride.C b/src/usr/hwpf/fapi/fapiAttributeOverride.C
deleted file mode 100644
index 636bafc25..000000000
--- a/src/usr/hwpf/fapi/fapiAttributeOverride.C
+++ /dev/null
@@ -1,331 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG
- * This is an automatically generated prolog.
- *
- * $Source: src/usr/hwpf/fapi/fapiAttributeOverride.C $
- *
- * 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_TAG
- */
-/**
- * @file fapiAttributeOverride.C
- *
- * @brief Implements the AttributeOverrides and AttributeOverride classes.
- */
-
-/*
- * Change Log ******************************************************************
- * Flag Defect/Feature User Date Description
- * ------ -------------- ---------- ----------- ----------------------------
- * mjjones 06/07/2012 Created
- */
-
-#include <fapiAttributeOverride.H>
-#include <fapiAttributeService.H>
-#include <fapiPlatTrace.H>
-#include <fapiReturnCode.H>
-#include <fapiSystemConfig.H>
-
-namespace fapi
-{
-
-//******************************************************************************
-// Default Constructor
-//******************************************************************************
-AttributeOverrides::AttributeOverrides()
- : iv_overridesExist(false)
-{
- FAPI_IMP("AttributeOverrides: Constructor");
-}
-
-//******************************************************************************
-// Destructor
-//******************************************************************************
-AttributeOverrides::~AttributeOverrides()
-{
- FAPI_IMP("AttributeOverrides: Destructor");
- for (OverridesItr_t l_itr = iv_overrides.begin(); l_itr
- != iv_overrides.end(); ++l_itr)
- {
- delete (*l_itr);
- }
-}
-
-//******************************************************************************
-// clearOverrides
-//******************************************************************************
-void AttributeOverrides::clearOverrides()
-{
- FAPI_IMP("AttributeOverrides: Clearing all overrides");
- platLock();
-
- iv_overridesExist = false;
-
- for (OverridesItr_t l_itr = iv_overrides.begin(); l_itr
- != iv_overrides.end(); ++l_itr)
- {
- delete (*l_itr);
- }
-
- iv_overrides.clear();
-
- platUnlock();
-}
-
-//******************************************************************************
-// clearNonConstOverride
-//******************************************************************************
-void AttributeOverrides::clearNonConstOverride(
- const fapi::AttributeId i_attrId,
- const fapi::Target * const i_pTarget)
-{
- // Do a quick check to see if any overrides exist. This is deliberately done
- // without a lock for performance. Overrides should not be changed while
- // HWPs are setting attributes, but even if they are there is no risk of
- // corruption.
- if (!iv_overridesExist)
- {
- return;
- }
-
- platLock();
-
- // Note that for an array attribute with an override, there will be multiple
- // AttributeOverride objects, one for each element
- OverridesItr_t l_itr = iv_overrides.begin();
-
- while (l_itr != iv_overrides.end())
- {
- if (((*l_itr)->iv_overrideType == ATTR_OVERRIDE_NON_CONST) &&
- overrideMatch(i_attrId, i_pTarget, *(*l_itr)))
- {
- delete (*l_itr);
- l_itr = iv_overrides.erase(l_itr);
- }
- else
- {
- ++l_itr;
- }
- }
-
- if (iv_overrides.empty())
- {
- iv_overridesExist = false;
- }
-
- platUnlock();
-}
-
-//******************************************************************************
-// setOverride
-//******************************************************************************
-void AttributeOverrides::setOverride(const AttributeOverride & i_override)
-{
- if (i_override.iv_overrideType == ATTR_OVERRIDE_CLEAR_ALL)
- {
- clearOverrides();
- }
- else
- {
- FAPI_IMP("Set Override. ID: 0x%x, Val: 0x%llx, Type: %d",
- i_override.iv_attrId, i_override.iv_overrideVal,
- i_override.iv_overrideType);
- FAPI_INF("Set Override. Target Type: 0x%x, Pos: 0x%x, UPos: 0x%x",
- i_override.iv_targetType, i_override.iv_pos,
- i_override.iv_unitPos);
- FAPI_INF("Set Override. Array Dims: %d.%d.%d.%d",
- i_override.iv_arrayD1, i_override.iv_arrayD2,
- i_override.iv_arrayD3, i_override.iv_arrayD4);
-
- AttributeOverride * l_pOverride = new AttributeOverride();
- *l_pOverride = i_override;
-
- platLock();
- iv_overridesExist = true;
- iv_overrides.push_back(l_pOverride);
- platUnlock();
- }
-}
-
-//******************************************************************************
-// getOverride
-//******************************************************************************
-bool AttributeOverrides::getOverride(const fapi::AttributeId i_attrId,
- const fapi::Target * const i_pTarget,
- uint64_t & o_overrideVal,
- const uint8_t i_arrayD1,
- const uint8_t i_arrayD2,
- const uint8_t i_arrayD3,
- const uint8_t i_arrayD4)
-{
- // Do a quick check to see if any overrides exist. This is deliberately done
- // without a lock for performance. Overrides should not be changed while
- // HWPs are getting attributes, but even if they are there is no risk of
- // corruption.
- if (!iv_overridesExist)
- {
- return false;
- }
-
- platLock();
- bool l_found = false;
-
- for (OverridesCItr_t l_itr = iv_overrides.begin(); l_itr
- != iv_overrides.end(); ++l_itr)
- {
- if (overrideMatch(i_attrId, i_pTarget, *(*l_itr)))
- {
- // Check the array dimensions
- if (((*l_itr)->iv_arrayD1 == i_arrayD1) &&
- ((*l_itr)->iv_arrayD2 == i_arrayD2) &&
- ((*l_itr)->iv_arrayD3 == i_arrayD3) &&
- ((*l_itr)->iv_arrayD4 == i_arrayD4))
- {
- l_found = true;
- o_overrideVal = (*l_itr)->iv_overrideVal;
- FAPI_IMP("Returning HWPF Attribute Override, 0x%x = 0x%llx",
- i_attrId, o_overrideVal);
- break;
- }
- }
- }
-
- platUnlock();
- return l_found;
-}
-
-//******************************************************************************
-// overridesExist
-//******************************************************************************
-bool AttributeOverrides::overridesExist()
-{
- platLock();
- bool l_overridesExist = iv_overridesExist;
- platUnlock();
- return l_overridesExist;
-}
-
-//******************************************************************************
-// overrideMatch
-//******************************************************************************
-bool AttributeOverrides::overrideMatch(
- const fapi::AttributeId i_attrId,
- const fapi::Target * const i_pTarget,
- const AttributeOverride & i_candidate)
-{
- // Note that any errors querying a parent chip or a position attribute are
- // dropped and the function returns false (attribute is not a match)
-
- // Check the Attribute ID
- if (i_candidate.iv_attrId != static_cast<uint32_t>(i_attrId))
- {
- return false;
- }
-
- // Check the Target Type
- if (i_pTarget == NULL)
- {
- if (i_candidate.iv_targetType !=
- static_cast<uint32_t>(TARGET_TYPE_SYSTEM))
- {
- return false;
- }
- }
- else if (i_candidate.iv_targetType !=
- static_cast<uint32_t>(i_pTarget->getType()))
- {
- return false;
- }
-
- // Check the Target position if applicable and not the system Target
- if ((i_candidate.iv_pos != ATTR_POS_NA) &&
- (i_pTarget != NULL) &&
- (i_pTarget->getType() != TARGET_TYPE_SYSTEM))
- {
- ReturnCode l_rc;
- uint32_t l_pos = 0xffffffff;
-
- if (i_pTarget->isChiplet())
- {
- // Target is a chiplet, iv_pos is the parent chip position
- Target l_chip;
-
- l_rc = fapiGetParentChip(*i_pTarget, l_chip);
-
- if (l_rc)
- {
- FAPI_ERR("Error (0x%x) from fapiGetParentChip",
- static_cast<uint32_t>(l_rc));
- return false;
- }
-
- l_rc = FAPI_ATTR_GET(ATTR_POS, &l_chip, l_pos);
-
- if (l_rc)
- {
- FAPI_ERR("Error (0x%x) getting parent chip position attr",
- static_cast<uint32_t>(l_rc));
- return false;
- }
- }
- else
- {
- // Target is not a chiplet, iv_pos is the Target position
- l_rc = FAPI_ATTR_GET(ATTR_POS, i_pTarget, l_pos);
-
- if (l_rc)
- {
- FAPI_ERR("Error (0x%x) getting position attr",
- static_cast<uint32_t>(l_rc));
- return false;
- }
- }
-
- if (i_candidate.iv_pos != l_pos)
- {
- return false;
- }
- }
-
- // Check the Unit Target position if applicable and a unit Target
- if ((i_candidate.iv_unitPos != ATTR_UNIT_POS_NA) &&
- (i_pTarget != NULL) &&
- (i_pTarget->isChiplet()))
- {
- ReturnCode l_rc;
- uint8_t l_unitPos = 0xff;
-
- l_rc = FAPI_ATTR_GET(ATTR_CHIP_UNIT_POS, i_pTarget, l_unitPos);
-
- if (l_rc)
- {
- FAPI_ERR("Error (0x%x) getting chiplet position attr",
- static_cast<uint32_t>(l_rc));
- return false;
- }
-
- if (i_candidate.iv_unitPos != l_unitPos)
- {
- return false;
- }
- }
-
- // Match
- return true;
-}
-
-}
diff --git a/src/usr/hwpf/fapi/fapiAttributeTank.C b/src/usr/hwpf/fapi/fapiAttributeTank.C
new file mode 100644
index 000000000..20f5fc081
--- /dev/null
+++ b/src/usr/hwpf/fapi/fapiAttributeTank.C
@@ -0,0 +1,443 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/hwpf/fapi/fapiAttributeTank.C $ */
+/* */
+/* 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 otherwise */
+/* divested of its trade secrets, irrespective of what has been */
+/* deposited with the U.S. Copyright Office. */
+/* */
+/* Origin: 30 */
+/* */
+/* IBM_PROLOG_END_TAG */
+/**
+ * @file fapiAttributeTank.C
+ *
+ * @brief Implements the AttributeTank and Attribute classes.
+ */
+
+/*
+ * Change Log ******************************************************************
+ * Flag Defect/Feature User Date Description
+ * ------ -------------- ---------- ----------- ----------------------------
+ * mjjones 06/07/2012 Created
+ */
+#include <stdlib.h>
+#include <fapiAttributeTank.H>
+#include <fapiAttributeService.H>
+#include <fapiPlatTrace.H>
+#include <fapiReturnCode.H>
+#include <fapiSystemConfig.H>
+
+namespace fapi
+{
+
+//******************************************************************************
+AttributeTank::AttributeTank() :
+ iv_pName("AttributeTank"), iv_attributesExist(false)
+{
+ FAPI_IMP("AttributeTank: Constructor");
+}
+
+//******************************************************************************
+AttributeTank::~AttributeTank()
+{
+ FAPI_IMP("AttributeTank: Destructor");
+}
+
+//******************************************************************************
+void AttributeTank::clearAllAttributes()
+{
+ platLock();
+ FAPI_DBG("%s: Clearing all attributes", iv_pName);
+ iv_attributesExist = false;
+ iv_attributes.clear();
+ platUnlock();
+}
+
+//******************************************************************************
+void AttributeTank::clearNonConstAttribute(const fapi::AttributeId i_attrId,
+ const fapi::Target * const i_pTarget)
+{
+ // Do a quick check to see if any attributes exist. This is deliberately
+ // done without a lock for performance. The use-case for this function is
+ // FAPI_ATTR_SET calling to clear any constant override, overrides should
+ // not be changed while HWPs are setting attributes, but even if they are
+ // there is no risk of corruption.
+ if (!iv_attributesExist)
+ {
+ return;
+ }
+
+ uint32_t l_targetType = getTargetType(i_pTarget);
+ uint16_t l_pos = getTargetPos(i_pTarget);
+ uint8_t l_unitPos = getTargetUnitPos(i_pTarget);
+
+ platLock();
+
+ // Note that for an array attribute, there will be multiple Attribute
+ // objects, one for each element
+ AttributesItr_t l_itr = iv_attributes.begin();
+
+ while (l_itr != iv_attributes.end())
+ {
+ if ( (!((*l_itr).iv_flags & ATTR_FLAG_CONST)) &&
+ ((*l_itr).iv_attrId == static_cast<uint32_t>(i_attrId)) &&
+ ((*l_itr).iv_targetType == l_targetType) &&
+ ((*l_itr).iv_pos == l_pos) &&
+ ((*l_itr).iv_unitPos == l_unitPos) )
+ {
+ FAPI_INF("%s: Clearing non-const attr 0x%x", iv_pName, i_attrId);
+ l_itr = iv_attributes.erase(l_itr);
+ }
+ else
+ {
+ ++l_itr;
+ }
+ }
+
+ if (iv_attributes.empty())
+ {
+ iv_attributesExist = false;
+ }
+
+ platUnlock();
+}
+
+//******************************************************************************
+void AttributeTank::setAttribute(const fapi::AttributeId i_attrId,
+ const fapi::Target * const i_pTarget,
+ const uint64_t i_val,
+ const uint8_t i_arrayD1,
+ const uint8_t i_arrayD2,
+ const uint8_t i_arrayD3,
+ const uint8_t i_arrayD4)
+{
+ // Create an Attribute structure
+ Attribute l_attr;
+
+ l_attr.iv_val = i_val;
+ l_attr.iv_attrId = i_attrId;
+ l_attr.iv_targetType = getTargetType(i_pTarget);
+ l_attr.iv_pos = getTargetPos(i_pTarget);
+ l_attr.iv_unitPos = getTargetUnitPos(i_pTarget);
+ l_attr.iv_flags = 0;
+ l_attr.iv_arrayD1 = i_arrayD1;
+ l_attr.iv_arrayD2 = i_arrayD2;
+ l_attr.iv_arrayD3 = i_arrayD3;
+ l_attr.iv_arrayD4 = i_arrayD4;
+
+ // Set the attribute in the tank
+ setAttribute(l_attr);
+}
+
+//******************************************************************************
+void AttributeTank::setAttribute(const Attribute & i_attribute)
+{
+ platLock();
+
+ // Search for an existing matching attribute
+ bool l_found = false;
+ AttributesItr_t l_itr = iv_attributes.begin();
+
+ for (AttributesItr_t l_itr = iv_attributes.begin(); l_itr
+ != iv_attributes.end(); ++l_itr)
+ {
+ if ( ((*l_itr).iv_attrId == i_attribute.iv_attrId) &&
+ ((*l_itr).iv_targetType == i_attribute.iv_targetType) &&
+ ((*l_itr).iv_pos == i_attribute.iv_pos) &&
+ ((*l_itr).iv_unitPos == i_attribute.iv_unitPos) &&
+ ((*l_itr).iv_arrayD1 == i_attribute.iv_arrayD1) &&
+ ((*l_itr).iv_arrayD2 == i_attribute.iv_arrayD2) &&
+ ((*l_itr).iv_arrayD3 == i_attribute.iv_arrayD3) &&
+ ((*l_itr).iv_arrayD4 == i_attribute.iv_arrayD4) )
+ {
+ // Found existing attribute, update it unless the existing attribute
+ // is const and the new attribute is non-const
+ if (!( ((*l_itr).iv_flags & ATTR_FLAG_CONST) &&
+ (!(i_attribute.iv_flags & ATTR_FLAG_CONST)) ) )
+ {
+ FAPI_DBG("%s: Updating attr 0x%x", iv_pName,
+ i_attribute.iv_attrId);
+ (*l_itr).iv_flags = i_attribute.iv_flags;
+ (*l_itr).iv_val = i_attribute.iv_val;
+ }
+ l_found = true;
+ break;
+ }
+ }
+
+ if (!l_found)
+ {
+ // Add the attribute to the tank
+ FAPI_DBG("%s: Setting attr 0x%x", iv_pName, i_attribute.iv_attrId);
+ iv_attributesExist = true;
+ iv_attributes.push_back(i_attribute);
+ }
+
+ platUnlock();
+}
+
+//******************************************************************************
+bool AttributeTank::getAttribute(const fapi::AttributeId i_attrId,
+ const fapi::Target * const i_pTarget,
+ uint64_t & o_val,
+ const uint8_t i_arrayD1,
+ const uint8_t i_arrayD2,
+ const uint8_t i_arrayD3,
+ const uint8_t i_arrayD4) const
+{
+ // Do a quick check to see if any attributes exist. This is deliberately
+ // done without a lock for performance. The use-case for this function is
+ // FAPI_ATTR_GET calling to get an override, overrides should not be changed
+ // while HWPs are getting attributes, but even if they are there is no risk
+ // of corruption.
+ if (!iv_attributesExist)
+ {
+ return false;
+ }
+
+ // Do not return any override for ATTR_POS or ATTR_CHIP_UNIT_POS because
+ // this function calls getTargetPos and getTargetUnitPos which will query
+ // ATTR_POS and ATTR_CHIP_UNIT_POS again resulting in an infinite loop
+ if ((i_attrId == ATTR_POS) || (i_attrId == ATTR_CHIP_UNIT_POS))
+ {
+ return false;
+ }
+
+ bool l_found = false;
+ uint32_t l_targetType = getTargetType(i_pTarget);
+ uint16_t l_pos = getTargetPos(i_pTarget);
+ uint8_t l_unitPos = getTargetUnitPos(i_pTarget);
+
+ platLock();
+
+ for (AttributesCItr_t l_itr = iv_attributes.begin(); l_itr
+ != iv_attributes.end(); ++l_itr)
+ {
+ if ( ((*l_itr).iv_attrId == static_cast<uint32_t>(i_attrId)) &&
+ ((*l_itr).iv_targetType == l_targetType) &&
+ (((*l_itr).iv_pos == ATTR_POS_NA) || ((*l_itr).iv_pos == l_pos)) &&
+ (((*l_itr).iv_unitPos == ATTR_UNIT_POS_NA) ||
+ ((*l_itr).iv_unitPos == l_unitPos)) &&
+ ((*l_itr).iv_arrayD1 == i_arrayD1) &&
+ ((*l_itr).iv_arrayD2 == i_arrayD2) &&
+ ((*l_itr).iv_arrayD3 == i_arrayD3) &&
+ ((*l_itr).iv_arrayD4 == i_arrayD4) )
+ {
+ FAPI_INF("%s: Getting attr 0x%x:0x%llx", iv_pName, i_attrId,
+ (*l_itr).iv_val);
+ l_found = true;
+ o_val = (*l_itr).iv_val;
+ break;
+ }
+ }
+
+ platUnlock();
+ return l_found;
+}
+
+//******************************************************************************
+void AttributeTank::getAllAttributes(
+ AllocType i_allocType,
+ std::vector<AttributeChunk> & o_attributes) const
+{
+ platLock();
+
+ FAPI_DBG("%s: Getting all attributes", iv_pName);
+
+ if (iv_attributes.size())
+ {
+ AttributesCItr_t l_itr = iv_attributes.begin();
+ size_t l_numAttrsRemaining = iv_attributes.size();
+
+ while (l_numAttrsRemaining)
+ {
+ AttributeChunk l_chunk;
+ l_chunk.iv_numAttributes = l_numAttrsRemaining;
+
+ if (l_chunk.iv_numAttributes > AttributeChunk::MAX_ATTRS_PER_CHUNK)
+ {
+ l_chunk.iv_numAttributes = AttributeChunk::MAX_ATTRS_PER_CHUNK;
+ }
+
+ if (i_allocType == ALLOC_TYPE_MALLOC)
+ {
+ l_chunk.iv_pAttributes = static_cast<uint8_t *>
+ (malloc(sizeof(Attribute) * l_chunk.iv_numAttributes));
+ }
+ else
+ {
+ l_chunk.iv_pAttributes =
+ new uint8_t[sizeof(Attribute) * l_chunk.iv_numAttributes];
+ }
+
+ Attribute * l_pAttr = reinterpret_cast<Attribute *>
+ (l_chunk.iv_pAttributes);
+
+ for(size_t i = 0; i < l_chunk.iv_numAttributes; i++)
+ {
+ *l_pAttr++ = (*l_itr);
+ l_itr++;
+ }
+
+ o_attributes.push_back(l_chunk);
+ l_numAttrsRemaining -= l_chunk.iv_numAttributes;
+ }
+ }
+
+ platUnlock();
+}
+
+//******************************************************************************
+bool AttributeTank::attributesExist()
+{
+ platLock();
+ bool l_attributesExist = iv_attributesExist;
+ platUnlock();
+ return l_attributesExist;
+}
+
+//******************************************************************************
+uint32_t AttributeTank::getTargetType(const fapi::Target * const i_pTarget)
+{
+ if (i_pTarget == NULL)
+ {
+ return static_cast<uint32_t>(TARGET_TYPE_SYSTEM);
+ }
+ else
+ {
+ return static_cast<uint32_t>(i_pTarget->getType());
+ }
+}
+
+//******************************************************************************
+uint16_t AttributeTank::getTargetPos(const fapi::Target * const i_pTarget)
+{
+ // Note that any errors querying a parent chip or a position attribute are
+ // ignored and the function returns ATTR_POS_NA
+ uint16_t l_ret = ATTR_POS_NA;
+
+ if (i_pTarget != NULL)
+ {
+ ReturnCode l_rc;
+ uint32_t l_pos = 0xffffffff;
+
+ if (i_pTarget->isChiplet())
+ {
+ // Target is a chiplet, o_pos is the parent chip position
+ Target l_chip;
+
+ l_rc = fapiGetParentChip(*i_pTarget, l_chip);
+
+ if (l_rc)
+ {
+ FAPI_ERR("Error (0x%x) from fapiGetParentChip",
+ static_cast<uint32_t>(l_rc));
+ }
+ else
+ {
+ l_rc = FAPI_ATTR_GET(ATTR_POS, &l_chip, l_pos);
+
+ if (l_rc)
+ {
+ FAPI_ERR("Error (0x%x) getting parent chip position attr",
+ static_cast<uint32_t>(l_rc));
+ }
+ else
+ {
+ l_ret = l_pos;
+ }
+ }
+ }
+ else
+ {
+ // Target is not a chiplet, iv_pos is the Target position
+ l_rc = FAPI_ATTR_GET(ATTR_POS, i_pTarget, l_pos);
+
+ if (l_rc)
+ {
+ FAPI_ERR("Error (0x%x) getting position attr",
+ static_cast<uint32_t>(l_rc));
+ }
+ else
+ {
+ l_ret = l_pos;
+ }
+ }
+ }
+
+ return l_ret;
+}
+
+//******************************************************************************
+uint8_t AttributeTank::getTargetUnitPos(const fapi::Target * const i_pTarget)
+{
+ // Note that any errors querying a position attribute are ignored and the
+ // function returns ATTR_UNIT_POS_NA
+ uint8_t l_ret = ATTR_UNIT_POS_NA;
+
+ if (i_pTarget != NULL)
+ {
+ if (i_pTarget->isChiplet())
+ {
+ uint8_t l_unitPos = 0xff;
+
+ ReturnCode l_rc = FAPI_ATTR_GET(ATTR_CHIP_UNIT_POS, i_pTarget,
+ l_unitPos);
+
+ if (l_rc)
+ {
+ FAPI_ERR("Error (0x%x) getting chiplet position attr",
+ static_cast<uint32_t>(l_rc));
+ }
+ else
+ {
+ l_ret = l_unitPos;
+ }
+ }
+ }
+
+ return l_ret;
+}
+//******************************************************************************
+OverrideAttributeTank::OverrideAttributeTank()
+{
+ iv_pName = "OverrideAttributeTank";
+ FAPI_IMP("OverrideAttributeTank: Constructor");
+}
+
+//******************************************************************************
+SyncAttributeTank::SyncAttributeTank()
+{
+ iv_pName = "SyncAttributeTank";
+ FAPI_IMP("SyncAttributeTank: Constructor");
+}
+
+//******************************************************************************
+void SyncAttributeTank::setAttribute(const fapi::AttributeId i_attrId,
+ const fapi::Target * const i_pTarget,
+ const uint64_t i_val,
+ const uint8_t i_arrayD1,
+ const uint8_t i_arrayD2,
+ const uint8_t i_arrayD3,
+ const uint8_t i_arrayD4)
+{
+ if (platSyncEnabled())
+ {
+ AttributeTank::setAttribute(i_attrId, i_pTarget, i_val, i_arrayD1,
+ i_arrayD2, i_arrayD3, i_arrayD4);
+ }
+}
+
+}
diff --git a/src/usr/hwpf/fapi/fapiParseAttributeInfo.pl b/src/usr/hwpf/fapi/fapiParseAttributeInfo.pl
index 3a0ab3bea..bff32a105 100755
--- a/src/usr/hwpf/fapi/fapiParseAttributeInfo.pl
+++ b/src/usr/hwpf/fapi/fapiParseAttributeInfo.pl
@@ -62,6 +62,8 @@
# mjjones 06/12/12 Add new include file to fapiChipEcFeature.C
# mjjones 08/08/12 Output target types and if PlatInit
# mjjones 09/28/12 Minor change to add FFDC on error
+# mjjones 11/05/12 Generate fapiAttributeIds.txt
+# Generate fapiAttributeEnums.txt
#
# End Change Log ******************************************************
@@ -80,6 +82,8 @@ if ($numArgs < 2)
print (" - fapiAttributePlatCheck.H. Contains compile time checks that all attributes are\n");
print (" handled by the platform\n");
print (" - fapiAttributesSupported.html Contains the HWPF attributes supported\n");
+ print (" - fapiAttributeIds.txt Used to xlate between AttrID string and value\n");
+ print (" - fapiAttributeEnums.txt Used to xlate between AttrEnum string and value\n");
exit(1);
}
@@ -123,6 +127,16 @@ $asFile .= "/";
$asFile .= "fapiAttributesSupported.html";
open(ASFILE, ">", $asFile);
+my $itFile = $ARGV[0];
+$itFile .= "/";
+$itFile .= "fapiAttributeIds.txt";
+open(ITFILE, ">", $itFile);
+
+my $etFile = $ARGV[0];
+$etFile .= "/";
+$etFile .= "fapiAttributeEnums.txt";
+open(ETFILE, ">", $etFile);
+
#------------------------------------------------------------------------------
# Print Start of file information to fapiAttributeIds.H
#------------------------------------------------------------------------------
@@ -196,8 +210,8 @@ 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>";
-my %enumHash;
-my %attrIdHash;
+my %attrIdHash; # Records which Attribute IDs have been used
+my %attrValHash; # Records which Attribute values have been used
#------------------------------------------------------------------------------
# For each XML file
@@ -219,9 +233,9 @@ foreach my $argnum (1 .. $#ARGV)
foreach my $attr (@{$attributes->{attribute}})
{
#----------------------------------------------------------------------
- # Print the AttributeId enum to fapiAttributeIds.H
- # The enumerator value for each attribute is a hash value generated
- # from the attribute name, this ties a specific enumerator value to a
+ # Print the Attribute ID and calculated value to fapiAttributeIds.H and
+ # fapiAttributeIds.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.
@@ -248,9 +262,14 @@ foreach my $argnum (1 .. $#ARGV)
# Calculate a 28 bit hash value.
my $attrHash128Bit = md5_hex($attr->{id});
my $attrHash28Bit = substr($attrHash128Bit, 0, 7);
+
+ # Print the attribute ID/value to fapiAttributeIds.H
print AIFILE " $attr->{id} = 0x$attrHash28Bit,\n";
- if (exists($enumHash{$attrHash28Bit}))
+ # Print the attribute ID/value to fapiAttributeIds.txt
+ print ITFILE "$attr->{id} 0x$attrHash28Bit\n";
+
+ if (exists($attrValHash{$attrHash28Bit}))
{
# Two different attributes generate the same hash-value!
print ("fapiParseAttributeInfo.pl ERROR. Duplicate attr id hash value for ",
@@ -258,7 +277,7 @@ foreach my $argnum (1 .. $#ARGV)
exit(1);
}
- $enumHash{$attrHash28Bit} = 1;
+ $attrValHash{$attrHash28Bit} = 1;
};
}
@@ -316,8 +335,6 @@ foreach my $argnum (1 .. $#ARGV)
my $numArrayDimensions = 0;
if ($attr->{array})
{
- # Figure out the array dimensions
-
# Remove leading whitespace
my $dimText = $attr->{array};
$dimText =~ s/^\s+//;
@@ -424,7 +441,8 @@ foreach my $argnum (1 .. $#ARGV)
}
#----------------------------------------------------------------------
- # Print the value enumeration (if specified) to fapiAttributeIds.H
+ # Print the value enumeration (if specified) to fapiAttributeIds.H and
+ # fapiAttributeEnums.txt
#----------------------------------------------------------------------
if (exists $attr->{enum})
{
@@ -440,8 +458,15 @@ foreach my $argnum (1 .. $#ARGV)
$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 fapiAttributeEnums.txt
+ my $attrEnumTxt = "$attr->{id}_${val}\n";
+ $attrEnumTxt =~ s/= //;
+ print ETFILE $attrEnumTxt;
+
if ($attr->{valueType} eq 'uint64')
{
print AIFILE "ULL";
@@ -630,6 +655,9 @@ print ASFILE "</html>\n";
# Close output files
#------------------------------------------------------------------------------
close(AIFILE);
+close(ECFILE);
close(ACFILE);
close(ASFILE);
+close(ITFILE);
+close(ETFILE);
diff --git a/src/usr/hwpf/fapi/makefile b/src/usr/hwpf/fapi/makefile
index ddb17b4b9..0a76de05f 100644
--- a/src/usr/hwpf/fapi/makefile
+++ b/src/usr/hwpf/fapi/makefile
@@ -36,7 +36,7 @@ OBJS = fapiReturnCode.o \
fapiErrorInfo.o \
fapiAttributeService.o \
fapiChipEcFeature.o \
- fapiAttributeOverride.o \
+ fapiAttributeTank.o \
fapiCollectRegFfdc.o
include ${ROOTPATH}/config.mk
diff --git a/src/usr/hwpf/hwp/fapiTestHwp.C b/src/usr/hwpf/hwp/fapiTestHwp.C
index 2d299b19b..6dc4ef853 100644
--- a/src/usr/hwpf/hwp/fapiTestHwp.C
+++ b/src/usr/hwpf/hwp/fapiTestHwp.C
@@ -96,7 +96,7 @@ fapi::ReturnCode hwpInitialTest(const std::vector<fapi::Target> & i_target)
// --------------------------------------------------------
// 2. fapiPutScom test
// --------------------------------------------------------
- uint64_t l_scomWriteValue = 0x9000000000000000;
+ uint64_t l_scomWriteValue = 0x9000000000000000ULL;
l_ecmdRc = l_ScomData.setDoubleWord(0, l_scomWriteValue);
if (l_ecmdRc != ECMD_DBUF_SUCCESS)
@@ -120,8 +120,8 @@ fapi::ReturnCode hwpInitialTest(const std::vector<fapi::Target> & i_target)
// --------------------------------------------------------
// 3. fapiPutScomUnderMask test
// --------------------------------------------------------
- l_scomWriteValue = 0xA000000000000000;
- uint64_t l_mask = 0x3000000000000000;
+ l_scomWriteValue = 0xA000000000000000ULL;
+ uint64_t l_mask = 0x3000000000000000ULL;
ecmdDataBufferBase l_maskData(64);
l_ecmdRc = l_ScomData.setDoubleWord(0, l_scomWriteValue);
diff --git a/src/usr/hwpf/hwp/fapiTestHwpAttr.C b/src/usr/hwpf/hwp/fapiTestHwpAttr.C
index bb7701595..0cee8edf5 100755
--- a/src/usr/hwpf/hwp/fapiTestHwpAttr.C
+++ b/src/usr/hwpf/hwp/fapiTestHwpAttr.C
@@ -42,14 +42,12 @@
* camvanng 11/09/2011 Update attr enum test
* mjjones 11/17/2011 Removed some initfile attr tests
* mjjones 11/22/2011 Demonstrate use of heap based array
+ * mjjones 10/19/2012 Update AttributeTank tests
*
* HWP_IGNORE_VERSION_CHECK
*/
#include <fapiTestHwpAttr.H>
-#include <targeting/common/target.H>
-#include <targeting/common/commontargeting.H>
-#include <targeting/common/utilFilter.H>
extern "C"
{
@@ -57,7 +55,8 @@ extern "C"
//******************************************************************************
// hwpTestAttributes function
//******************************************************************************
-fapi::ReturnCode hwpTestAttributes()
+fapi::ReturnCode hwpTestAttributes(fapi::Target & i_mbaTarget,
+ fapi::Target & i_procTarget)
{
FAPI_INF("hwpTestAttributes: Start HWP");
fapi::ReturnCode l_rc;
@@ -65,69 +64,6 @@ fapi::ReturnCode hwpTestAttributes()
do
{
//----------------------------------------------------------------------
- // Test ATTR_MSS_DIMM_MFG_ID_CODE
- //----------------------------------------------------------------------
- {
- uint32_t l_data;
- TARGETING::TargetHandleList l_dimmList;
- getAllLogicalCards( l_dimmList, TARGETING::TYPE_DIMM );
-
- for( size_t i = 0; i < l_dimmList.size(); i++)
- {
- fapi::Target l_target( fapi::TARGET_TYPE_DIMM,
- (void *)(l_dimmList[i]) );
- l_rc = FAPI_ATTR_GET(ATTR_POS, &l_target, l_data);
-
- if (l_rc)
- {
- FAPI_ERR("hwpTestAttributes: ATTR_POS. Error from GET");
- break;
- }
- else
- {
- FAPI_INF("hwpTestAttributes: ATTR_POS = %d", l_data);
- }
- }
-
- if (l_rc)
- {
- break;
- }
- }
-
- //----------------------------------------------------------------------
- // Test ATTR_MSS_DIMM_MFG_ID_CODE
- //----------------------------------------------------------------------
- {
- uint32_t l_data[2][2];
-
- TARGETING::PredicateCTM l_pred(TARGETING::CLASS_UNIT, TARGETING::TYPE_MBA);
- TARGETING::TargetRangeFilter l_filter(TARGETING::targetService().begin(),
- TARGETING::targetService().end(),
- &l_pred);
-
- // Just look at the first MBA chiplet
- if (l_filter)
- {
- fapi::Target l_target(fapi::TARGET_TYPE_MBA_CHIPLET, *l_filter);
-
- l_rc = FAPI_ATTR_GET(ATTR_MSS_DIMM_MFG_ID_CODE, &l_target, l_data);
-
- if (l_rc)
- {
- FAPI_ERR("hwpTestAttributes: ATTR_MSS_DIMM_MFG_ID_CODE. Error from GET");
- break;
- }
- }
- else
- {
- FAPI_ERR("hwpTestAttributes: ATTR_MSS_DIMM_MFG_ID_CODE. No MBAs found");
- FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
- break;
- }
- }
-
- //----------------------------------------------------------------------
// Test ATTR_SCRATCH_UINT8_1
//----------------------------------------------------------------------
{
@@ -940,260 +876,312 @@ fapi::ReturnCode hwpTestAttributes()
}
//----------------------------------------------------------------------
- // Test non-const Attribute Override on ATTR_SCRATCH_UINT64_1
+ // Test AttributeTank functions with empty tank
//----------------------------------------------------------------------
{
- if (fapi::platAttrSvc::overridesExistWrap())
+ // Create a local OverrideAttributeTank (this is not the singleton)
+ fapi::OverrideAttributeTank l_tank;
+
+ // Check that tank is empty
+ if (l_tank.attributesExist())
{
- FAPI_INF("hwpTestAttributes: OverrideUint64. Overrides exist, skipping test");
+ FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
+ FAPI_ERR("hwpTestAttributes: Error. AttributeTank is not empty (1.1)");
+ break;
}
- else
+
+ // Clear all attributes from empty tank
+ l_tank.clearAllAttributes();
+
+ // Clear a non-const system attribute from empty tank
+ l_tank.clearNonConstAttribute(fapi::ATTR_SCRATCH_UINT64_1, NULL);
+
+ // Try to get a system attribute from empty tank
+ uint64_t l_val = 0;
+ if (l_tank.getAttribute(fapi::ATTR_SCRATCH_UINT64_1, NULL, l_val))
{
- // Set the attribute to a known value
- uint64_t l_val = 4;
- l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_1, NULL, l_val);
-
- if (l_rc)
- {
- FAPI_ERR("hwpTestAttributes: OverrideUint64. Error from SET");
- break;
- }
-
- // Create an non-const override
- fapi::AttributeOverride l_override;
- l_override.iv_overrideVal = 9;
- l_override.iv_attrId =
- static_cast<uint32_t>(fapi::ATTR_SCRATCH_UINT64_1);
- l_override.iv_targetType =
- static_cast<uint32_t>(fapi::TARGET_TYPE_SYSTEM);
- l_override.iv_pos = fapi::ATTR_POS_NA;
- l_override.iv_unitPos = fapi::ATTR_UNIT_POS_NA;
- l_override.iv_overrideType = fapi::ATTR_OVERRIDE_NON_CONST;
- l_override.iv_arrayD1 = fapi::ATTR_ARRAYD_NA;
- l_override.iv_arrayD2 = fapi::ATTR_ARRAYD_NA;
- l_override.iv_arrayD3 = fapi::ATTR_ARRAYD_NA;
- l_override.iv_arrayD4 = fapi::ATTR_ARRAYD_NA;
- fapi::platAttrSvc::setOverrideWrap(l_override);
-
- // Check that the override value is returned
- l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_1, NULL, l_val);
-
- if (l_rc)
- {
- FAPI_ERR("hwpTestAttributes: OverrideUint64. Error from GET");
- break;
- }
-
- if (l_val != 9)
- {
- FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
- FAPI_ERR("hwpTestAttributes: OverrideUint64 GET returned %d",
- static_cast<uint32_t>(l_val));
- break;
- }
-
- // Set the attribute to a known value
- l_val = 8;
- l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_1, NULL, l_val);
-
- if (l_rc)
- {
- FAPI_ERR("hwpTestAttributes: OverrideUint64. Error from SET (2)");
- break;
- }
-
- // Check that the override was cancelled (it is a non-const override)
- l_val = 0;
- l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_1, NULL, l_val);
-
- if (l_rc)
- {
- FAPI_ERR("hwpTestAttributes: OverrideUint64. Error from GET (2)");
- break;
- }
-
- if (l_val != 8)
- {
- FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
- FAPI_ERR("hwpTestAttributes: OverrideUint64 GET returned %d (2)",
- static_cast<uint32_t>(l_val));
- break;
- }
-
- // Clear all overrides
- fapi::platAttrSvc::clearOverridesWrap();
+ FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
+ FAPI_ERR("hwpTestAttributes: Error. Got sys attr from empty tank (1.2)");
+ break;
}
+
+ // Try to get a chiplet attribute from empty tank
+ if (l_tank.getAttribute(fapi::ATTR_SCRATCH_UINT64_1, &i_mbaTarget,
+ l_val))
+ {
+ FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
+ FAPI_ERR("hwpTestAttributes: Error. Got chiplet attr from empty tank (1.3)");
+ break;
}
+
+ // Try to get all attributes from empty tank
+ std::vector<fapi::AttributeChunk> l_attributes;
+ l_tank.getAllAttributes(fapi::AttributeTank::ALLOC_TYPE_MALLOC,
+ l_attributes);
+ if (l_attributes.size())
+ {
+ FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
+ FAPI_ERR("hwpTestAttributes: Error. Got all attrs from empty tank (1.4)");
+ break;
+ }
+ }
+
//----------------------------------------------------------------------
- // Test const Attribute Override on ATTR_SCRATCH_UINT8_1
+ // Test AttributeTank functions with single attribute in tank
//----------------------------------------------------------------------
{
- if (fapi::platAttrSvc::overridesExistWrap())
+ // Create a local OverrideAttributeTank (this is not the singleton)
+ fapi::OverrideAttributeTank l_tank;
+
+ // Add ATTR_SCRATCH_UINT64_1 as a sytem attribute to the tank
+ uint64_t l_val = 4;
+ l_tank.setAttribute(fapi::ATTR_SCRATCH_UINT64_1, NULL, l_val);
+
+ // Check that attributes exist in the tank
+ if (!l_tank.attributesExist())
{
- FAPI_INF("hwpTestAttributes: OverrideUint8. Overrides exist, skipping test");
+ FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
+ FAPI_ERR("hwpTestAttributes: Error. AttributeTank is empty (2.1)");
+ break;
}
- else
+
+ // Try to get the wrong attribute from the tank
+ l_val = 0;
+ if (l_tank.getAttribute(fapi::ATTR_SCRATCH_UINT64_2, NULL, l_val))
{
- // Set the attribute to a known value
- uint8_t l_val = 1;
- l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_1, NULL, l_val);
-
- if (l_rc)
- {
- FAPI_ERR("hwpTestAttributes: OverrideUint8. Error from SET");
- break;
- }
-
- // Create a const override
- fapi::AttributeOverride l_override;
- l_override.iv_overrideVal = 2;
- l_override.iv_attrId =
- static_cast<uint32_t>(fapi::ATTR_SCRATCH_UINT8_1);
- l_override.iv_targetType =
- static_cast<uint32_t>(fapi::TARGET_TYPE_SYSTEM);
- l_override.iv_pos = fapi::ATTR_POS_NA;
- l_override.iv_unitPos = fapi::ATTR_UNIT_POS_NA;
- l_override.iv_overrideType = fapi::ATTR_OVERRIDE_CONST;
- l_override.iv_arrayD1 = fapi::ATTR_ARRAYD_NA;
- l_override.iv_arrayD2 = fapi::ATTR_ARRAYD_NA;
- l_override.iv_arrayD3 = fapi::ATTR_ARRAYD_NA;
- l_override.iv_arrayD4 = fapi::ATTR_ARRAYD_NA;
- fapi::platAttrSvc::setOverrideWrap(l_override);
-
- // Check that the override value is returned
- l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT8_1, NULL, l_val);
-
- if (l_rc)
- {
- FAPI_ERR("hwpTestAttributes: OverrideUint8. Error from GET");
- break;
- }
-
- if (l_val != 2)
- {
- FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
- FAPI_ERR("hwpTestAttributes: OverrideUint8 GET returned %d",
- l_val);
- break;
- }
-
- // Set the attribute to a known value
- l_val = 3;
- l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_1, NULL, l_val);
-
- if (l_rc)
- {
- FAPI_ERR("hwpTestAttributes: OverrideUint8. Error from SET (2)");
- break;
- }
-
- // Check that the override value is still returned
- l_val = 0;
- l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT8_1, NULL, l_val);
-
- if (l_rc)
- {
- FAPI_ERR("hwpTestAttributes: OverrideUint8. Error from GET (2)");
- break;
- }
-
- if (l_val != 2)
- {
- FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
- FAPI_ERR("hwpTestAttributes: OverrideUint8 GET returned %d (2)",
- l_val);
- break;
- }
-
- // Clear all overrides
- fapi::platAttrSvc::clearOverridesWrap();
-
- // Check that the real value is now returned
- l_val = 0;
- l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT8_1, NULL, l_val);
-
- if (l_rc)
- {
- FAPI_ERR("hwpTestAttributes: OverrideUint8. Error from GET (3)");
- break;
- }
-
- if (l_val != 3)
- {
- FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
- FAPI_ERR("hwpTestAttributes: OverrideUint8 GET returned %d (3)",
- l_val);
- break;
- }
+ FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
+ FAPI_ERR("hwpTestAttributes: Error. Got wrong attr from tank (2.2)");
+ break;
+ }
+
+ // Get the attribute from the tank
+ if (!(l_tank.getAttribute(fapi::ATTR_SCRATCH_UINT64_1, NULL, l_val)))
+ {
+ FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
+ FAPI_ERR("hwpTestAttributes: Error. Did not get attr from tank (2.3)");
+ break;
}
+
+ if (l_val != 4)
+ {
+ FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
+ FAPI_ERR("hwpTestAttributes: Error. Got bad value (0x%llx) from tank (2.4)",
+ l_val);
+ break;
}
+ // Get all attributes from the tank
+ std::vector<fapi::AttributeChunk> l_attributes;
+ l_tank.getAllAttributes(fapi::AttributeTank::ALLOC_TYPE_NEW,
+ l_attributes);
+
+ if (l_attributes.size() != 1)
+ {
+ FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
+ FAPI_ERR("hwpTestAttributes: Error. Got wrong chunk size (%d) of attrs from tank (2.5)",
+ l_attributes.size());
+ break;
+ }
+
+ if (l_attributes[0].iv_numAttributes != 1)
+ {
+ FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
+ FAPI_ERR("hwpTestAttributes: Error. Got wrong size (%d) of attrs from tank (2.6)",
+ l_attributes[0].iv_numAttributes);
+ break;
+ }
+
+ fapi::Attribute * l_pAttr = reinterpret_cast<fapi::Attribute *>
+ (l_attributes[0].iv_pAttributes);
+ if (l_pAttr[0].iv_val != 4)
+ {
+ FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
+ FAPI_ERR("hwpTestAttributes: Error. Got bad value (0x%llx) from tank (2.7)",
+ l_pAttr[0].iv_val);
+ break;
+ }
+ delete [] l_attributes[0].iv_pAttributes;
+ }
//----------------------------------------------------------------------
- // Test non-const Attribute Override on ATTR_SCRATCH_UINT64_ARRAY_2
+ // Test AttributeTank functions with multiple attributes in tank
//----------------------------------------------------------------------
{
- if (fapi::platAttrSvc::overridesExistWrap())
+ // Create a local OverrideAttributeTank (this is not the singleton)
+ fapi::OverrideAttributeTank l_tank;
+
+ // Add ATTR_SCRATCH_UINT64_1 as a chip attribute to the tank
+ uint64_t l_val = 4;
+ l_tank.setAttribute(fapi::ATTR_SCRATCH_UINT64_1, &i_procTarget, l_val);
+
+ // Add ATTR_SCRATCH_UINT64_2 as an MBA attribute to the tank
+ l_val = 5;
+ l_tank.setAttribute(fapi::ATTR_SCRATCH_UINT64_2, &i_mbaTarget, l_val);
+
+ // Get the first attribute from the tank
+ if (!(l_tank.getAttribute(fapi::ATTR_SCRATCH_UINT64_1, &i_procTarget, l_val)))
{
- FAPI_INF("hwpTestAttributes: OverrideUint64array. Overrides exist, skipping test");
+ FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
+ FAPI_ERR("hwpTestAttributes: Error. Did not get attr from tank (3.1)");
+ break;
}
- else
+
+ if (l_val != 4)
{
- // Create a non-const override
- fapi::AttributeOverride l_override;
- l_override.iv_attrId =
- static_cast<uint32_t>(fapi::ATTR_SCRATCH_UINT64_ARRAY_2);
- l_override.iv_targetType =
- static_cast<uint32_t>(fapi::TARGET_TYPE_SYSTEM);
- l_override.iv_pos = fapi::ATTR_POS_NA;
- l_override.iv_unitPos = fapi::ATTR_UNIT_POS_NA;
- l_override.iv_overrideType = fapi::ATTR_OVERRIDE_NON_CONST;
- l_override.iv_arrayD3 = fapi::ATTR_ARRAYD_NA;
- l_override.iv_arrayD4 = fapi::ATTR_ARRAYD_NA;
-
- l_override.iv_overrideVal = 20;
- l_override.iv_arrayD1 = 0;
- l_override.iv_arrayD2 = 0;
- fapi::platAttrSvc::setOverrideWrap(l_override);
-
- l_override.iv_overrideVal = 21;
- l_override.iv_arrayD1 = 0;
- l_override.iv_arrayD2 = 1;
- fapi::platAttrSvc::setOverrideWrap(l_override);
-
- l_override.iv_overrideVal = 22;
- l_override.iv_arrayD1 = 1;
- l_override.iv_arrayD2 = 0;
- fapi::platAttrSvc::setOverrideWrap(l_override);
-
- l_override.iv_overrideVal = 0xfffffffe;
- l_override.iv_arrayD1 = 1;
- l_override.iv_arrayD2 = 1;
- fapi::platAttrSvc::setOverrideWrap(l_override);
-
- // Check that the override value is returned
- uint64_t l_val[2][2];
- l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_ARRAY_2, NULL, l_val);
-
- if (l_rc)
- {
- FAPI_ERR("hwpTestAttributes: OverrideUint64array. Error from GET");
- break;
- }
-
- if ((l_val[0][0] != 20) || (l_val[0][1] != 21) ||
- (l_val[1][0] != 22) || (l_val[1][1] != 0xfffffffe))
- {
- FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
- FAPI_ERR("hwpTestAttributes: OverrideUint64array GET returned 0x%llx:0x%llx:0x%llx:0x%llx",
- l_val[0][0], l_val[0][1], l_val[1][0], l_val[1][1]);
- break;
- }
+ FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
+ FAPI_ERR("hwpTestAttributes: Error. Got bad value (0x%llx) from tank (3.2)",
+ l_val);
+ break;
+ }
+
+ // Get the second attribute from the tank
+ if (!(l_tank.getAttribute(fapi::ATTR_SCRATCH_UINT64_2, &i_mbaTarget, l_val)))
+ {
+ FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
+ FAPI_ERR("hwpTestAttributes: Error. Did not get attr from tank (3.3)");
+ break;
+ }
+
+ if (l_val != 5)
+ {
+ FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
+ FAPI_ERR("hwpTestAttributes: Error. Got bad value (0x%llx) from tank (3.4)",
+ l_val);
+ break;
+ }
+
+ // Get all attributes from the tank
+ std::vector<fapi::AttributeChunk> l_attributes;
+ l_tank.getAllAttributes(fapi::AttributeTank::ALLOC_TYPE_MALLOC,
+ l_attributes);
+
+ if (l_attributes.size() != 1)
+ {
+ FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
+ FAPI_ERR("hwpTestAttributes: Error. Got wrong chunk size (%d) of attrs from tank (3.5)",
+ l_attributes.size());
+ break;
+ }
+
+ if (l_attributes[0].iv_numAttributes != 2)
+ {
+ FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
+ FAPI_ERR("hwpTestAttributes: Error. Got wrong size (%d) of attrs from tank (3.6)",
+ l_attributes[0].iv_numAttributes);
+ break;
+ }
+
+ fapi::Attribute * l_pAttr = reinterpret_cast<fapi::Attribute *>
+ (l_attributes[0].iv_pAttributes);
+ if (l_pAttr[0].iv_val != 4)
+ {
+ FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
+ FAPI_ERR("hwpTestAttributes: Error. Got bad value (0x%llx) from tank (3.7)",
+ l_pAttr[0].iv_val);
+ break;
+ }
+
+ if (l_pAttr[1].iv_val != 5)
+ {
+ FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
+ FAPI_ERR("hwpTestAttributes: Error. Got bad value (0x%llx) from tank (3.8)",
+ l_pAttr->iv_val);
+ break;
+ }
+
+ free (l_attributes[0].iv_pAttributes);
+ }
+
+ //----------------------------------------------------------------------
+ // Test AttributeTank functions with constant attribute
+ //----------------------------------------------------------------------
+ {
+ // Create a local OverrideAttributeTank (this is not the singleton)
+ fapi::OverrideAttributeTank l_tank;
+
+ // Set const attribute
+ fapi::Attribute l_attr;
+ l_attr.iv_val = 7;
+ l_attr.iv_attrId = fapi::ATTR_SCRATCH_UINT64_2;
+ l_attr.iv_targetType = fapi::TARGET_TYPE_SYSTEM;
+ l_attr.iv_pos = fapi::ATTR_POS_NA;
+ l_attr.iv_unitPos = fapi::ATTR_UNIT_POS_NA;
+ l_attr.iv_flags = fapi::ATTR_FLAG_CONST;
+ l_attr.iv_arrayD1 = 0;
+ l_attr.iv_arrayD2 = 0;
+ l_attr.iv_arrayD3 = 0;
+ l_attr.iv_arrayD4 = 0;
+ l_tank.setAttribute(l_attr);
- // Clear all overrides
- fapi::platAttrSvc::clearOverridesWrap();
+ // Try to clear the attribute, it should not be cleared
+ l_tank.clearNonConstAttribute(fapi::ATTR_SCRATCH_UINT64_2, NULL);
+
+ // Check that tank is not-empty
+ if (!l_tank.attributesExist())
+ {
+ FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
+ FAPI_ERR("hwpTestAttributes: Error. AttributeTank is empty (4.1)");
+ break;
}
+
+ // Clear all attribute
+ l_tank.clearAllAttributes();
+
+ // Check that tank is empty
+ if (l_tank.attributesExist())
+ {
+ FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
+ FAPI_ERR("hwpTestAttributes: Error. AttributeTank is not empty (4.2)");
+ break;
+ }
+ }
+
+ //----------------------------------------------------------------------
+ // Test adding the same attribute twice to a tank
+ //----------------------------------------------------------------------
+ {
+ // Create a local OverrideAttributeTank (this is not the singleton)
+ fapi::OverrideAttributeTank l_tank;
+
+ // Add ATTR_SCRATCH_UINT64_1 to the tank twice
+ uint64_t l_val = 4;
+ l_tank.setAttribute(fapi::ATTR_SCRATCH_UINT64_1, NULL, l_val);
+ l_val = 5;
+ l_tank.setAttribute(fapi::ATTR_SCRATCH_UINT64_1, NULL, l_val);
+
+ // Get all attributes from the tank
+ std::vector<fapi::AttributeChunk> l_attributes;
+ l_tank.getAllAttributes(fapi::AttributeTank::ALLOC_TYPE_MALLOC,
+ l_attributes);
+
+ if (l_attributes.size() != 1)
+ {
+ FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
+ FAPI_ERR("hwpTestAttributes: Error. Got wrong chunk size (%d) of attrs from tank (5.1)",
+ l_attributes.size());
+ break;
+ }
+
+ if (l_attributes[0].iv_numAttributes != 1)
+ {
+ FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
+ FAPI_ERR("hwpTestAttributes: Error. Got wrong size (%d) of attrs from tank (5.2)",
+ l_attributes[0].iv_numAttributes);
+ break;
+ }
+
+ fapi::Attribute * l_pAttr = reinterpret_cast<fapi::Attribute *>
+ (l_attributes[0].iv_pAttributes);
+ if (l_pAttr[0].iv_val != 5)
+ {
+ FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL);
+ FAPI_ERR("hwpTestAttributes: Error. Got bad value (0x%llx) from tank (5.3)",
+ l_pAttr[0].iv_val);
+ break;
+ }
+
+ free (l_attributes[0].iv_pAttributes);
}
} while (0);
diff --git a/src/usr/hwpf/plat/fapiPlatAttrOverrideDirect.C b/src/usr/hwpf/plat/fapiPlatAttrOverrideDirect.C
deleted file mode 100644
index 436a63477..000000000
--- a/src/usr/hwpf/plat/fapiPlatAttrOverrideDirect.C
+++ /dev/null
@@ -1,56 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG
- * This is an automatically generated prolog.
- *
- * $Source: src/usr/hwpf/plat/fapiPlatAttrOverrideDirect.C $
- *
- * 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_TAG
- */
-/**
- * @file fapiPlatAttrOverrideDirect.C
- *
- * @brief Defines a PLAT function that applies a HWPF Attribute Override
- * written directly into Hostboot memory from the Simics/VBU console
- */
-
-//******************************************************************************
-// Includes
-//******************************************************************************
-#include <util/singleton.H>
-#include <hwpf/fapi/fapiAttributeOverride.H>
-
-namespace fapi
-{
-
-//******************************************************************************
-// Global Variables
-//******************************************************************************
-AttributeOverride g_attrOverride;
-
-//******************************************************************************
-// platAttrOverrideDirect
-// Apply a HWPF Attribute Override written directly into Hostboot memory from
-// the Simics/VBU console. This function is called by a Simics/VBU debug tool
-//******************************************************************************
-void platAttrOverrideDirect()
-{
- // Apply the attribute override
- Singleton<fapi::AttributeOverrides>::instance().setOverride(g_attrOverride);
-}
-
-}
diff --git a/src/usr/hwpf/plat/fapiPlatAttrOverrideSync.C b/src/usr/hwpf/plat/fapiPlatAttrOverrideSync.C
new file mode 100644
index 000000000..4217ad828
--- /dev/null
+++ b/src/usr/hwpf/plat/fapiPlatAttrOverrideSync.C
@@ -0,0 +1,371 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/hwpf/plat/fapiPlatAttrOverrideSync.C $ */
+/* */
+/* 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 otherwise */
+/* divested of its trade secrets, irrespective of what has been */
+/* deposited with the U.S. Copyright Office. */
+/* */
+/* Origin: 30 */
+/* */
+/* IBM_PROLOG_END_TAG */
+/**
+ * @file fapiPlatAttrOverrideSync.C
+ *
+ * @brief Implements the functions for Attribute Override and Sync
+ *
+ */
+
+//******************************************************************************
+// Includes
+//******************************************************************************
+#include <limits.h>
+#include <sys/msg.h>
+#include <string.h>
+#include <vector>
+#include <sys/msg.h>
+#include <util/singleton.H>
+#include <errl/errlentry.H>
+#include <errl/errlmanager.H>
+#include <mbox/mboxif.H>
+#include <hwpf/fapi/fapiAttributeTank.H>
+#include <hwpf/plat/fapiPlatAttrOverrideSync.H>
+#include <hwpf/plat/fapiPlatTrace.H>
+
+namespace fapi
+{
+
+//******************************************************************************
+// Global Variables
+//******************************************************************************
+
+// Attribute set directly by debug tool in standalone Hostboot mode to apply
+// an Attribute Override
+fapi::Attribute g_attrOverride;
+
+namespace attrOverrideSync
+{
+
+/**
+ * @brief Attribute Override/Sync Mailbox Message Type Constants
+ * These must be kept in sync with FSP firmware
+ */
+enum MAILBOX_MSG_TYPE
+{
+ MSG_SET_OVERRIDES = MBOX::FIRST_UNSECURE_MSG + 0x10, // FSP<->Hostboot
+ MSG_CLEAR_ALL_OVERRIDES = MBOX::FIRST_UNSECURE_MSG + 0x11, // FSP<->Hostboot
+ MSG_SET_SYNC_ATTS = MBOX::FIRST_UNSECURE_MSG + 0x12, // FSP<--Hostboot
+};
+
+//******************************************************************************
+// Apply a HWPF Attribute Override written directly into Hostboot memory from
+// the Simics/VBU console. This function is called by a Simics/VBU debug tool
+//******************************************************************************
+void directOverride()
+{
+ // Apply the attribute override
+ Singleton<fapi::OverrideAttributeTank>::instance().
+ setAttribute(g_attrOverride);
+}
+
+//******************************************************************************
+void monitorForFspMessages()
+{
+ FAPI_IMP("monitorForFspMessages starting");
+
+ // Register a message queue with the mailbox
+ msg_q_t l_pMsgQ = msg_q_create();
+ errlHndl_t l_pErr = MBOX::msgq_register(MBOX::HB_HWPF_ATTR_MSGQ, l_pMsgQ);
+
+ if (l_pErr)
+ {
+ // In the unlikely event that registering fails, the code will commit an
+ // error and then wait forever for a message to appear on the queue
+ FAPI_ERR("monitorForFspMessages: Error registering msgq with mailbox");
+ errlCommit(l_pErr, HWPF_COMP_ID);
+ }
+
+ while (1)
+ {
+ msg_t * l_pMsg = msg_wait(l_pMsgQ);
+
+ if (l_pMsg->type == MSG_SET_OVERRIDES)
+ {
+ // FSP is setting attribute override(s).
+ FAPI_INF("monitorForFspMessages: MSG_SET_OVERRIDES");
+ uint64_t l_size = l_pMsg->data[1];
+ Attribute * l_pAttribute =
+ reinterpret_cast<Attribute *>(l_pMsg->extra_data);
+
+ while (l_size > sizeof(fapi::Attribute))
+ {
+ Singleton<fapi::OverrideAttributeTank>::instance().
+ setAttribute(*l_pAttribute);
+ l_pAttribute++;
+ l_size -= sizeof(fapi::Attribute);
+ }
+
+ // Free the memory
+ free(l_pMsg->extra_data);
+ l_pMsg->extra_data = NULL;
+ l_pMsg->data[1] = 0;
+
+ if (msg_is_async(l_pMsg))
+ {
+ msg_free(l_pMsg);
+ }
+ else
+ {
+ // Send the message back as a response
+ msg_respond(l_pMsgQ, l_pMsg);
+ }
+ }
+ else if (l_pMsg->type == MSG_CLEAR_ALL_OVERRIDES)
+ {
+ // FSP is clearing all attribute overrides.
+ FAPI_INF("monitorForFspMessages: MSG_CLEAR_ALL_OVERRIDES");
+ Singleton<fapi::OverrideAttributeTank>::instance().
+ clearAllAttributes();
+
+ // Send message back as response
+ msg_respond(l_pMsgQ, l_pMsg);
+ }
+ else
+ {
+ FAPI_ERR("monitorForFspMessages: Unrecognized message 0x%x",
+ l_pMsg->type);
+ }
+ }
+}
+
+//******************************************************************************
+// Utility function called by sendAttrOverridesAndSyncsToFsp
+//******************************************************************************
+errlHndl_t sendAttrsToFsp(const MAILBOX_MSG_TYPE i_msgType,
+ std::vector<AttributeChunk> & i_attributes)
+{
+ errlHndl_t l_pErr = NULL;
+
+ // Send Attributes through the mailbox chunk by chunk.
+ for (size_t i = 0; i < i_attributes.size(); i++)
+ {
+ msg_t * l_pMsg = msg_allocate();
+ l_pMsg->type = i_msgType;
+ l_pMsg->data[0] = 0;
+ l_pMsg->data[1] = i_attributes[i].iv_numAttributes * sizeof(Attribute);
+ l_pMsg->extra_data = i_attributes[i].iv_pAttributes;
+
+ // Send the message and wait for a response, the response message is not
+ // read, it just ensures that the code waits until the FSP is done
+ // Note: A possible performance boost could be to send only the last
+ // message synchronously to avoid the small delay between each
+ // message
+ l_pErr = MBOX::sendrecv(MBOX::FSP_HWPF_ATTR_MSGQ, l_pMsg);
+
+ if (l_pErr)
+ {
+ FAPI_ERR("sendAttrsToFsp: Error sending to FSP");
+ msg_free(l_pMsg);
+ break;
+ }
+
+ // Mailbox freed the chunk data
+ i_attributes[i].iv_pAttributes = NULL;
+ msg_free(l_pMsg);
+ }
+
+ // Free any memory (only in error case will there be memory to free) and
+ // clear the vector of Attribute Chunks
+ for (size_t i = 0; i < i_attributes.size(); i++)
+ {
+ free(i_attributes[i].iv_pAttributes);
+ i_attributes[i].iv_pAttributes = NULL;
+ }
+ i_attributes.clear();
+
+ return l_pErr;
+}
+
+//******************************************************************************
+void sendAttrOverridesAndSyncsToFsp()
+{
+ if (MBOX::mailbox_enabled())
+ {
+ // Clear all current FSP Attribute Overrides
+ msg_t * l_pMsg = msg_allocate();
+ l_pMsg->type = MSG_CLEAR_ALL_OVERRIDES;
+ l_pMsg->data[0] = 0;
+ l_pMsg->data[1] = 0;
+ l_pMsg->extra_data = NULL;
+
+ // Send the message and wait for a response, the response message is not
+ // read, it just ensures that the code waits until the FSP is done
+ errlHndl_t l_pErr = MBOX::sendrecv(MBOX::FSP_HWPF_ATTR_MSGQ, l_pMsg);
+ msg_free(l_pMsg);
+
+ if (l_pErr)
+ {
+ FAPI_ERR("SendAttrOverridesToFsp: Error clearing FSP overrides");
+ errlCommit(l_pErr, HWPF_COMP_ID);
+ }
+ else
+ {
+ // Send Hostboot Attribute Overrides to the FSP
+ std::vector<AttributeChunk> l_attributes;
+
+ Singleton<fapi::OverrideAttributeTank>::instance().
+ getAllAttributes(AttributeTank::ALLOC_TYPE_MALLOC,
+ l_attributes);
+
+ if (l_attributes.size())
+ {
+ l_pErr = sendAttrsToFsp(MSG_SET_OVERRIDES, l_attributes);
+
+ if (l_pErr)
+ {
+ FAPI_ERR("SendAttrOverridesToFsp: Error sending overrides to FSP");
+ errlCommit(l_pErr, HWPF_COMP_ID);
+ }
+ }
+
+ if (l_pErr == NULL)
+ {
+ // Send Hostboot Attributes to Sync to the FSP
+ std::vector<AttributeChunk> l_attributes;
+
+ Singleton<fapi::SyncAttributeTank>::instance().
+ getAllAttributes(AttributeTank::ALLOC_TYPE_MALLOC,
+ l_attributes);
+
+ if (l_attributes.size())
+ {
+ l_pErr = sendAttrsToFsp(MSG_SET_SYNC_ATTS, l_attributes);
+
+ if (l_pErr)
+ {
+ FAPI_ERR("SendAttrOverridesToFsp: Error sending syncs to FSP");
+ errlCommit(l_pErr, HWPF_COMP_ID);
+ }
+ else
+ {
+ // Clear Hostboot Attributes to Sync
+ Singleton<fapi::SyncAttributeTank>::instance().
+ clearAllAttributes();
+ }
+ }
+ }
+ }
+ }
+}
+
+//******************************************************************************
+AttributeTank & theOverrideAttrTank()
+{
+ return Singleton<fapi::OverrideAttributeTank>::instance();
+}
+
+//******************************************************************************
+AttributeTank & theSyncAttrTank()
+{
+ return Singleton<fapi::SyncAttributeTank>::instance();
+}
+
+//******************************************************************************
+// This is used as a singleton and contains the lock used to serialize access
+// to the OverrideAttributeTank
+//******************************************************************************
+class OverrideAttributeTankLock
+{
+public:
+ OverrideAttributeTankLock()
+ {
+ mutex_init(&iv_mutex);
+ }
+
+ ~OverrideAttributeTankLock()
+ {
+ mutex_destroy(&iv_mutex);
+ }
+ mutex_t iv_mutex;
+};
+
+//******************************************************************************
+// This is used as a singleton and contains the lock used to serialize access
+// to the SyncAttributeTank
+//******************************************************************************
+class SyncAttributeTankLock
+{
+public:
+ SyncAttributeTankLock()
+ {
+ mutex_init(&iv_mutex);
+ }
+
+ ~SyncAttributeTankLock()
+ {
+ mutex_destroy(&iv_mutex);
+ }
+ mutex_t iv_mutex;
+};
+
+} // End attrOverrideSync namespace
+
+//******************************************************************************
+// This is the Hostboot PLAT implementation of a FAPI function
+//******************************************************************************
+void OverrideAttributeTank::platLock() const
+{
+ mutex_lock(&(Singleton<fapi::attrOverrideSync::
+ OverrideAttributeTankLock>::instance().iv_mutex));
+}
+
+//******************************************************************************
+// This is the Hostboot PLAT implementation of a FAPI function
+//******************************************************************************
+void OverrideAttributeTank::platUnlock() const
+{
+ mutex_unlock(&(Singleton<fapi::attrOverrideSync::
+ OverrideAttributeTankLock>::instance().iv_mutex));
+}
+
+//******************************************************************************
+// This is the Hostboot PLAT implementation of a FAPI function
+//******************************************************************************
+void SyncAttributeTank::platLock() const
+{
+ mutex_lock(&(Singleton<fapi::attrOverrideSync::
+ SyncAttributeTankLock>::instance().iv_mutex));
+}
+
+//******************************************************************************
+// This is the Hostboot PLAT implementation of a FAPI function
+//******************************************************************************
+void SyncAttributeTank::platUnlock() const
+{
+ mutex_unlock(&(Singleton<fapi::attrOverrideSync::
+ SyncAttributeTankLock>::instance().iv_mutex));
+}
+
+//******************************************************************************
+// This is the Hostboot PLAT implementation of a FAPI function
+//******************************************************************************
+bool SyncAttributeTank::platSyncEnabled()
+{
+ // TODO, RTC 42642. Check for CronusMode, probably using a FAPI Attribute
+ // but TBD. If CronusMode is not enabled then there should not be the
+ // performance hit of adding written attributes to the SyncAttributeTank
+ return false;
+}
+
+} // End fapi namespace
diff --git a/src/usr/hwpf/plat/fapiPlatAttributeService.C b/src/usr/hwpf/plat/fapiPlatAttributeService.C
index a1778861d..d24d3665f 100644
--- a/src/usr/hwpf/plat/fapiPlatAttributeService.C
+++ b/src/usr/hwpf/plat/fapiPlatAttributeService.C
@@ -23,7 +23,7 @@
/**
* @file fapiPlatAttributeService.C
*
- * @brief Implements HWP attribute -> HB attribute bridging functions
+ * @brief Implements the functions that access attributes
*
*/
@@ -706,75 +706,6 @@ fapi::ReturnCode fapiPlatGetTargetPos(const fapi::Target * i_pFapiTarget,
return l_rc;
}
-//******************************************************************************
-// fapi::platAttrSvc::getOverrideWrap function
-//******************************************************************************
-bool getOverrideWrap(const fapi::AttributeId i_attrId,
- const fapi::Target * const i_pTarget,
- uint64_t & o_overrideVal,
- const uint8_t i_arrayD1,
- const uint8_t i_arrayD2,
- const uint8_t i_arrayD3,
- const uint8_t i_arrayD4)
-{
- return Singleton<fapi::AttributeOverrides>::instance().getOverride(
- i_attrId, i_pTarget, o_overrideVal, i_arrayD1, i_arrayD2, i_arrayD3,
- i_arrayD4);
-}
-
-//******************************************************************************
-// fapi::platAttrSvc::clearNonConstOverrideWrap function
-//******************************************************************************
-void clearNonConstOverrideWrap(const fapi::AttributeId i_attrId,
- const fapi::Target * const i_pTarget)
-{
- Singleton<fapi::AttributeOverrides>::instance().clearNonConstOverride(
- i_attrId, i_pTarget);
-}
-
-//******************************************************************************
-// fapi::platAttrSvc::setOverrideWrap function
-//******************************************************************************
-void setOverrideWrap(const AttributeOverride & i_override)
-{
- Singleton<fapi::AttributeOverrides>::instance().setOverride(i_override);
-}
-
-//******************************************************************************
-// fapi::platAttrSvc::clearOverridesWrap function
-//******************************************************************************
-void clearOverridesWrap()
-{
- Singleton<fapi::AttributeOverrides>::instance().clearOverrides();
-}
-
-//******************************************************************************
-// fapi::platAttrSvc::overridesExistWrap function
-//******************************************************************************
-bool overridesExistWrap()
-{
- return Singleton<fapi::AttributeOverrides>::instance().overridesExist();
-}
-
-//******************************************************************************
-// fapi::platAttrSvc::AttributeOverridesLock class
-// This is a simple container for a mutex
-//******************************************************************************
-class AttributeOverridesLock
-{
-public:
- AttributeOverridesLock()
- {
- mutex_init(&iv_mutex);
- }
-
- ~AttributeOverridesLock()
- {
- mutex_destroy(&iv_mutex);
- }
- mutex_t iv_mutex;
-};
-
/**
* @enum
* Return values for ATTR_PROC_*_BAR_ENABLE
@@ -1494,24 +1425,4 @@ fapi::ReturnCode fapiPlatGetProcPcieBarSize (
} // End platAttrSvc namespace
-//******************************************************************************
-// fapi::AttributeOverrides::platLock function
-// This is the Hostboot PLAT implementation of the FAPI function
-//******************************************************************************
-void AttributeOverrides::platLock()
-{
- mutex_lock(&(Singleton
- <fapi::platAttrSvc::AttributeOverridesLock>::instance().iv_mutex));
-}
-
-//******************************************************************************
-// fapi::AttributeOverrides::platUnlock function
-// This is the Hostboot PLAT implementation of the FAPI function
-//******************************************************************************
-void AttributeOverrides::platUnlock()
-{
- mutex_unlock(&(Singleton
- <fapi::platAttrSvc::AttributeOverridesLock>::instance().iv_mutex));
-}
-
} // End fapi namespace
diff --git a/src/usr/hwpf/plat/fapiPlatTask.C b/src/usr/hwpf/plat/fapiPlatTask.C
index c5cade74b..4232f7aae 100644
--- a/src/usr/hwpf/plat/fapiPlatTask.C
+++ b/src/usr/hwpf/plat/fapiPlatTask.C
@@ -30,10 +30,10 @@
//******************************************************************************
// Includes
//******************************************************************************
-#include <sys/task.h>
#include <initservice/taskargs.H>
-#include <hwpf/fapi/fapiAttributeOverride.H>
-#include <fapiPlatTrace.H>
+#include <hwpf/fapi/fapiAttributeTank.H>
+#include <hwpf/plat/fapiPlatAttrOverrideSync.H>
+#include <hwpf/plat/fapiPlatTrace.H>
namespace fapi
{
@@ -41,23 +41,40 @@ namespace fapi
//******************************************************************************
// Global Variables
//******************************************************************************
-// Defined in fapiPlatAttrOverrideDirect.C
-extern AttributeOverride g_attrOverride;
+// Defined in fapiPlatAttrOverrideSync.C
+extern Attribute g_attrOverride;
//******************************************************************************
-// platTaskEntry
-// This function writes the g_attrOverride global variable first written by the
-// Simics/VBU console and then read by fapiPlatAttrOverrideDirect.C to ensure
-// it is paged and pinned in memory
+// This function monitors for FSP mailbox messages
+//******************************************************************************
+void * platMonitorForFspMessages(void * i_pContext)
+{
+ FAPI_IMP("Starting platMonitorForFspMessages");
+ fapi::attrOverrideSync::monitorForFspMessages();
+ return NULL; // Execution should never reach here
+}
+
+//******************************************************************************
+// This function is run when the extended initservice loads the plat module
+//
+// It writes the g_attrOverride global to ensure it is paged and pinned in
+// memory. This variable is used by a debug tool to override HWPF Attributes
+//
+// It starts a task that monitors for FSP mailbox messages on the
+// HB_HWPF_ATTR_MSGQ message queue
//******************************************************************************
void platTaskEntry(errlHndl_t &io_errl)
{
FAPI_IMP("Starting platTaskEntry");
- g_attrOverride.iv_overrideVal = 0;
- io_errl=NULL;
+
+ // Write the g_attrOverride global
+ g_attrOverride.iv_val = 0;
+
+ // Start task that monitors for FSP mailbox messages
+ task_create(fapi::platMonitorForFspMessages, NULL);
}
+} // End fapi namespace
+
// Macro that creates the _start function
TASK_ENTRY_MACRO(fapi::platTaskEntry);
-
-} // End fapi namespace
diff --git a/src/usr/hwpf/plat/makefile b/src/usr/hwpf/plat/makefile
index 4bb17e545..11a7a8c11 100644
--- a/src/usr/hwpf/plat/makefile
+++ b/src/usr/hwpf/plat/makefile
@@ -1,25 +1,25 @@
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
#
-# $Source: src/usr/hwpf/plat/makefile $
+# $Source: src/usr/hwpf/plat/makefile $
#
-# IBM CONFIDENTIAL
+# IBM CONFIDENTIAL
#
-# COPYRIGHT International Business Machines Corp. 2011-2012
+# COPYRIGHT International Business Machines Corp. 2011,2012
#
-# p1
+# p1
#
-# Object Code Only (OCO) source materials
-# Licensed Internal Code Source Materials
-# IBM HostBoot Licensed Internal Code
+# 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.
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
#
-# Origin: 30
+# Origin: 30
#
-# IBM_PROLOG_END_TAG
+# IBM_PROLOG_END_TAG
ROOTPATH = ../../../..
MODULE = plat
@@ -37,6 +37,6 @@ OBJS = fapiPlatHwAccess.o \
fapiPlatAttributeService.o \
fapiPlatMvpdAccess.o \
fapiPlatTask.o \
- fapiPlatAttrOverrideDirect.o
+ fapiPlatAttrOverrideSync.o
include ${ROOTPATH}/config.mk
diff --git a/src/usr/hwpf/test/hwpftest.H b/src/usr/hwpf/test/hwpftest.H
index 07d00044d..2f8ce4195 100644
--- a/src/usr/hwpf/test/hwpftest.H
+++ b/src/usr/hwpf/test/hwpftest.H
@@ -252,13 +252,53 @@ public:
/**
* @brief Test HWPF Attributes: call a test procedure that exercises
- * the FAPI scratch attributes
+ * FAPI attributes
*/
void testHwpf4()
{
errlHndl_t l_err = NULL;
- FAPI_INVOKE_HWP(l_err, hwpTestAttributes);
+ // Get the first MBA chiplet
+ fapi::Target l_mbaChiplet;
+ {
+ TARGETING::PredicateCTM l_pred(TARGETING::CLASS_UNIT, TARGETING::TYPE_MBA);
+ TARGETING::TargetRangeFilter l_filter(TARGETING::targetService().begin(),
+ TARGETING::targetService().end(),
+ &l_pred);
+ if (l_filter)
+ {
+ l_mbaChiplet.setType(fapi::TARGET_TYPE_MBA_CHIPLET);
+ l_mbaChiplet.set(*l_filter);
+ }
+ else
+ {
+ FAPI_ERR("testHwpf4: No MBAs found");
+ TS_FAIL("testHwpf4: No MBAs found");
+ return;
+ }
+ }
+
+ // Get the first proc chip
+ fapi::Target l_procChip;
+ {
+ TARGETING::PredicateCTM l_pred(TARGETING::CLASS_CHIP, TARGETING::TYPE_PROC);
+ TARGETING::TargetRangeFilter l_filter(TARGETING::targetService().begin(),
+ TARGETING::targetService().end(),
+ &l_pred);
+ if (l_filter)
+ {
+ l_procChip.setType(fapi::TARGET_TYPE_PROC_CHIP);
+ l_procChip.set(*l_filter);
+ }
+ else
+ {
+ FAPI_ERR("testHwpf4: No proc chips found");
+ TS_FAIL("testHwpf4: No proc chips found");
+ return;
+ }
+ }
+
+ FAPI_INVOKE_HWP(l_err, hwpTestAttributes, l_mbaChiplet, l_procChip);
if (l_err)
{
OpenPOWER on IntegriCloud