diff options
Diffstat (limited to 'src/usr/hwpf')
-rw-r--r-- | src/usr/hwpf/fapi/fapiAttributeOverride.C | 331 | ||||
-rw-r--r-- | src/usr/hwpf/fapi/makefile | 3 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/chip_attributes.xml | 16 | ||||
-rwxr-xr-x | src/usr/hwpf/hwp/fapiTestHwpAttr.C | 303 | ||||
-rw-r--r-- | src/usr/hwpf/plat/fapiPlatAttrOverrideDirect.C | 56 | ||||
-rw-r--r-- | src/usr/hwpf/plat/fapiPlatAttributeService.C | 197 | ||||
-rw-r--r-- | src/usr/hwpf/plat/fapiPlatTask.C | 63 | ||||
-rw-r--r-- | src/usr/hwpf/plat/makefile | 4 |
8 files changed, 945 insertions, 28 deletions
diff --git a/src/usr/hwpf/fapi/fapiAttributeOverride.C b/src/usr/hwpf/fapi/fapiAttributeOverride.C new file mode 100644 index 000000000..636bafc25 --- /dev/null +++ b/src/usr/hwpf/fapi/fapiAttributeOverride.C @@ -0,0 +1,331 @@ +/* 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/makefile b/src/usr/hwpf/fapi/makefile index 9df36f54c..5b3db9e72 100644 --- a/src/usr/hwpf/fapi/makefile +++ b/src/usr/hwpf/fapi/makefile @@ -35,7 +35,8 @@ OBJS = fapiReturnCode.o \ fapiHwAccess.o \ fapiErrorInfo.o \ fapiAttributeService.o \ - fapiChipEcFeature.o + fapiChipEcFeature.o \ + fapiAttributeOverride.o include ${ROOTPATH}/config.mk diff --git a/src/usr/hwpf/hwp/chip_attributes.xml b/src/usr/hwpf/hwp/chip_attributes.xml index 8a71d5bde..eb1ef23c3 100644 --- a/src/usr/hwpf/hwp/chip_attributes.xml +++ b/src/usr/hwpf/hwp/chip_attributes.xml @@ -1,11 +1,11 @@ <!-- IBM_PROLOG_BEGIN_TAG This is an automatically generated prolog. - $Source: src/usr/hwpf/hwp/fapiHwpAttributeInfo.xml $ + $Source: src/usr/hwpf/hwp/chip_attributes.xml $ IBM CONFIDENTIAL - COPYRIGHT International Business Machines Corp. 2011 + COPYRIGHT International Business Machines Corp. 2011-2012 p1 @@ -19,7 +19,7 @@ Origin: 30 - IBM_PROLOG_END --> + IBM_PROLOG_END_TAG --> <!-- XML file specifying HWPF attributes. These are platInit attributes associated with chips. @@ -28,6 +28,16 @@ <attributes> <!-- ********************************************************************* --> <attribute> + <id>ATTR_POS</id> + <targetType>TARGET_TYPE_PROC_CHIP,TARGET_TYPE_MEMBUF_CHIP,TARGET_TYPE_DIMM</targetType> + <description> + Position of chip/dimm relative to drawer + </description> + <valueType>uint32</valueType> + <platInit/> + </attribute> + <!-- ********************************************************************* --> + <attribute> <id>ATTR_CHIP_ID</id> <targetType>TARGET_TYPE_PROC_CHIP,TARGET_TYPE_MEMBUF_CHIP</targetType> <description> diff --git a/src/usr/hwpf/hwp/fapiTestHwpAttr.C b/src/usr/hwpf/hwp/fapiTestHwpAttr.C index 0d22b984b..021502f39 100755 --- a/src/usr/hwpf/hwp/fapiTestHwpAttr.C +++ b/src/usr/hwpf/hwp/fapiTestHwpAttr.C @@ -1,25 +1,26 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: src/usr/hwpf/hwp/fapiTestHwpAttr.C $ -// -// IBM CONFIDENTIAL -// -// COPYRIGHT International Business Machines Corp. 2011 -// -// 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 +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/hwpf/hwp/fapiTestHwpAttr.C $ + * + * IBM CONFIDENTIAL + * + * COPYRIGHT International Business Machines Corp. 2011-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 fapiTestHwpAttr.C * @@ -885,7 +886,6 @@ fapi::ReturnCode hwpTestAttributes() FAPI_INF("hwpTestAttributes: Deleting expected error 0x%x from fapiGetInitFileAttr", static_cast<uint32_t>(l_rc)); l_rc = fapi::FAPI_RC_SUCCESS; - break; } else { @@ -929,7 +929,264 @@ fapi::ReturnCode hwpTestAttributes() //l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_ARRAY_2, NULL, l_array); //l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_ARRAY_2, NULL, l_array); } + + //---------------------------------------------------------------------- + // Test non-const Attribute Override on ATTR_SCRATCH_UINT64_1 + //---------------------------------------------------------------------- + { + if (fapi::platAttrSvc::overridesExistWrap()) + { + FAPI_INF("hwpTestAttributes: OverrideUint64. Overrides exist, skipping test"); + } + else + { + // 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(); + } + } + //---------------------------------------------------------------------- + // Test const Attribute Override on ATTR_SCRATCH_UINT8_1 + //---------------------------------------------------------------------- + { + if (fapi::platAttrSvc::overridesExistWrap()) + { + FAPI_INF("hwpTestAttributes: OverrideUint8. Overrides exist, skipping test"); + } + else + { + // 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; + } + } + } + + + //---------------------------------------------------------------------- + // Test non-const Attribute Override on ATTR_SCRATCH_UINT64_ARRAY_2 + //---------------------------------------------------------------------- + { + if (fapi::platAttrSvc::overridesExistWrap()) + { + FAPI_INF("hwpTestAttributes: OverrideUint64array. Overrides exist, skipping test"); + } + else + { + // 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; + } + + // Clear all overrides + fapi::platAttrSvc::clearOverridesWrap(); + } + } + } while (0); FAPI_INF("hwpTestAttributes: End HWP"); diff --git a/src/usr/hwpf/plat/fapiPlatAttrOverrideDirect.C b/src/usr/hwpf/plat/fapiPlatAttrOverrideDirect.C new file mode 100644 index 000000000..436a63477 --- /dev/null +++ b/src/usr/hwpf/plat/fapiPlatAttrOverrideDirect.C @@ -0,0 +1,56 @@ +/* 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/fapiPlatAttributeService.C b/src/usr/hwpf/plat/fapiPlatAttributeService.C index c08da58cd..75cff6ced 100644 --- a/src/usr/hwpf/plat/fapiPlatAttributeService.C +++ b/src/usr/hwpf/plat/fapiPlatAttributeService.C @@ -56,6 +56,90 @@ namespace platAttrSvc { //****************************************************************************** +// fapi::platAttrSvc::getHostbootTarget +//****************************************************************************** +fapi::ReturnCode getHostbootTarget( + const fapi::Target* i_pFapiTarget, + TARGETING::Target* & o_pTarget, + const TARGETING::TYPE i_expectedType = TARGETING::TYPE_NA) +{ + fapi::ReturnCode l_rc; + + // Check that the FAPI Target pointer is not NULL + if (i_pFapiTarget == NULL) + { + FAPI_ERR("getHostbootTarget. NULL FAPI Target passed"); + + /*@ + * @errortype + * @moduleid MOD_ATTR_GET_HB_TARGET + * @reasoncode RC_NULL_FAPI_TARGET + * @devdesc NULL FAPI Target passed to attribute access macro + */ + errlHndl_t l_pError = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_INFORMATIONAL, + fapi::MOD_ATTR_GET_HB_TARGET, + fapi::RC_NULL_FAPI_TARGET); + l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); + } + else + { + // Extract the Hostboot Target pointer + o_pTarget = reinterpret_cast<TARGETING::Target*>(i_pFapiTarget->get()); + + // Check that the Hostboot Target pointer is not NULL + if (o_pTarget == NULL) + { + FAPI_ERR("getHostbootTarget. NULL Hostbot Target passed"); + + /*@ + * @errortype + * @moduleid MOD_ATTR_GET_HB_TARGET + * @reasoncode RC_EMBEDDED_NULL_TARGET_PTR + * @devdesc NULL HOSTBOOT Target passed to attribute access macro + */ + errlHndl_t l_pError = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_INFORMATIONAL, + fapi::MOD_ATTR_GET_HB_TARGET, + fapi::RC_EMBEDDED_NULL_TARGET_PTR); + l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); + } + else + { + // Check that the Target Type is as expected + if (i_expectedType != TARGETING::TYPE_NA) + { + TARGETING::TYPE l_type = + o_pTarget->getAttr<TARGETING::ATTR_TYPE>(); + + if (l_type != i_expectedType) + { + FAPI_ERR("getHostbootTarget. Type: %d, expected %d", + l_type, i_expectedType); + + /*@ + * @errortype + * @moduleid MOD_ATTR_GET_HB_TARGET + * @reasoncode RC_UNEXPECTED_TARGET_TYPE + * @userdata1 Target Type + * @userdata2 Expected Target Type + * @devdesc Unexpected Target Type passed to attribute access macro + */ + errlHndl_t l_pError = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_INFORMATIONAL, + fapi::MOD_ATTR_GET_HB_TARGET, + fapi::RC_UNEXPECTED_TARGET_TYPE, + l_type, i_expectedType); + l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); + } + } + } + } + + return l_rc; +} + +//****************************************************************************** // fapi::platAttrSvc::getSystemTarget //****************************************************************************** @@ -438,7 +522,120 @@ fapi::ReturnCode fapiPlatGetFunctional(const fapi::Target * i_pTarget, return l_rc; } +//****************************************************************************** +// fapi::platAttrSvc::fapiPlatGetTargetPos function +//****************************************************************************** +fapi::ReturnCode fapiPlatGetTargetPos(const fapi::Target * i_pFapiTarget, + uint32_t & o_pos) +{ + fapi::ReturnCode l_rc; + TARGETING::Target * l_pTarget = NULL; + + // Get the Hostboot Target + l_rc = getHostbootTarget(i_pFapiTarget, l_pTarget); + + if (l_rc) + { + FAPI_ERR("getTargetName: Error getting Hostboot Target"); + } + else + { + uint16_t l_pos = l_pTarget->getAttr<TARGETING::ATTR_POSITION>(); + o_pos = l_pos; + } + + 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; +}; } // 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 new file mode 100644 index 000000000..dfab334a9 --- /dev/null +++ b/src/usr/hwpf/plat/fapiPlatTask.C @@ -0,0 +1,63 @@ +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/hwpf/plat/fapiPlatTask.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 fapiPlatTask.C + * + * @brief Performs the Hostboot fapi::plat startup task + */ + +//****************************************************************************** +// Includes +//****************************************************************************** +#include <sys/task.h> +#include <initservice/taskargs.H> +#include <hwpf/fapi/fapiAttributeOverride.H> +#include <fapiPlatTrace.H> + +namespace fapi +{ + +//****************************************************************************** +// Global Variables +//****************************************************************************** +// Defined in fapiPlatAttrOverrideDirect.C +extern AttributeOverride 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 +//****************************************************************************** +void platTaskEntry(errlHndl_t &io_errl) +{ + FAPI_IMP("Starting platTaskEntry"); + g_attrOverride.iv_overrideVal = 0; + task_end(); +} + +// 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 5fd92402a..1056e9ecd 100644 --- a/src/usr/hwpf/plat/makefile +++ b/src/usr/hwpf/plat/makefile @@ -35,6 +35,8 @@ OBJS = fapiPlatHwAccess.o \ fapiPlatTarget.o \ fapiPlatUtil.o \ fapiPlatAttributeService.o \ - fapiMvpdAccess.o + fapiMvpdAccess.o \ + fapiPlatTask.o \ + fapiPlatAttrOverrideDirect.o include ${ROOTPATH}/config.mk |