diff options
author | Mike Jones <mjjones@us.ibm.com> | 2013-03-13 20:39:31 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2013-04-15 15:42:50 -0500 |
commit | 54a7754855469231b10e644abaa5b3f367fcf00e (patch) | |
tree | b3439b41b90e9b6d315ad43cf3d463e64fc97612 /src/usr/hwpf | |
parent | 6e42444a52f2910a0a6f9a898c2ba4a9e8201a17 (diff) | |
download | talos-hostboot-54a7754855469231b10e644abaa5b3f367fcf00e.tar.gz talos-hostboot-54a7754855469231b10e644abaa5b3f367fcf00e.zip |
Extend Attribute Override/Sync to work on Targeting attributes
Change-Id: Icf8d84e741212f31c1065146ac1ea96c4c7d75c5
RTC: 51707
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/3548
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Tested-by: Jenkins Server
Diffstat (limited to 'src/usr/hwpf')
-rw-r--r-- | src/usr/hwpf/fapi/fapiAttributeTank.C | 458 | ||||
-rwxr-xr-x | src/usr/hwpf/fapi/fapiParseAttributeInfo.pl | 49 | ||||
-rw-r--r-- | src/usr/hwpf/fapi/makefile | 1 | ||||
-rwxr-xr-x | src/usr/hwpf/hwp/fapiTestHwpAttr.C | 1196 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/makefile | 1 | ||||
-rw-r--r-- | src/usr/hwpf/makefile | 4 | ||||
-rw-r--r-- | src/usr/hwpf/plat/fapiPlatAttrOverrideSync.C | 503 | ||||
-rw-r--r-- | src/usr/hwpf/plat/fapiPlatTask.C | 63 | ||||
-rw-r--r-- | src/usr/hwpf/test/fapiAttrTest.C | 585 | ||||
-rw-r--r-- | src/usr/hwpf/test/fapiattrtest.H | 98 | ||||
-rw-r--r-- | src/usr/hwpf/test/hwpftest.H | 63 |
11 files changed, 1108 insertions, 1913 deletions
diff --git a/src/usr/hwpf/fapi/fapiAttributeTank.C b/src/usr/hwpf/fapi/fapiAttributeTank.C deleted file mode 100644 index a2f84f68d..000000000 --- a/src/usr/hwpf/fapi/fapiAttributeTank.C +++ /dev/null @@ -1,458 +0,0 @@ -/* 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 -{ - -//****************************************************************************** -Attribute::Attribute() : - iv_val(0), iv_attrId(0), iv_targetType(0), iv_pos(0), iv_unitPos(0), - iv_flags(0), iv_arrayD1(0), iv_arrayD2(0), iv_arrayD3(0), iv_arrayD4(0) -{ - -} - -//****************************************************************************** -AttributeChunk::AttributeChunk() : - iv_numAttributes(0), iv_pAttributes(NULL) -{ - -} - -//****************************************************************************** -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( - const 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 deb2fa174..0f3f10d1f 100755 --- a/src/usr/hwpf/fapi/fapiParseAttributeInfo.pl +++ b/src/usr/hwpf/fapi/fapiParseAttributeInfo.pl @@ -65,6 +65,8 @@ # mjjones 11/05/12 Generate fapiAttributeIds.txt # Generate fapiAttributeEnums.txt # mjjones 03/21/13 Add fapi namespace to Chip EC Feature macro +# mjjones 02/27/13 Generate fapiAttrInfo.csv +# Generate fapiAttrEnumInfo.csv # # End Change Log ****************************************************** @@ -83,8 +85,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"); + print (" - fapiAttrInfo.csv Used to process Attribute Override Text files\n"); + print (" - fapiAttrEnumInfo.csv Used to process Attribute Override Text files\n"); exit(1); } @@ -130,12 +132,12 @@ open(ASFILE, ">", $asFile); my $itFile = $ARGV[0]; $itFile .= "/"; -$itFile .= "fapiAttributeIds.txt"; +$itFile .= "fapiAttrInfo.csv"; open(ITFILE, ">", $itFile); my $etFile = $ARGV[0]; $etFile .= "/"; -$etFile .= "fapiAttributeEnums.txt"; +$etFile .= "fapiAttrEnumInfo.csv"; open(ETFILE, ">", $etFile); #------------------------------------------------------------------------------ @@ -211,6 +213,28 @@ print ASFILE "<h4>HWPF Attributes supported by this build.</h4>\n"; print ASFILE "<table border=\"4\">\n"; print ASFILE "<tr><th>Attribute ID</th><th>Attribute Description</th></tr>"; +#------------------------------------------------------------------------------ +# Print Start of file information to fapiAttrInfo.csv +#------------------------------------------------------------------------------ +print ITFILE "# fapiAttrInfo.csv\n"; +print ITFILE "# This file is generated by perl script fapiParseAttributeInfo.pl\n"; +print ITFILE "# It lists information about FAPI attributes and is used to\n"; +print ITFILE "# process FAPI Attribute text files (overrides/syncs)\n"; +print ITFILE "# Format:\n"; +print ITFILE "# <FAPI-ATTR-ID-STR>,<LAYER-ATTR-ID-STR>,<ATTR-ID-VAL>,<ATTR-TYPE>\n"; +print ITFILE "# Note that for the AttributeTanks at the FAPI layer, the\n"; +print ITFILE "# FAPI-ATTR-ID-STR and LAYER-ATTR-ID-STR will be identical\n"; + +#------------------------------------------------------------------------------ +# Print Start of file information to fapiAttrEnumInfo.csv +#------------------------------------------------------------------------------ +print ETFILE "# fapiAttrEnumInfo.csv\n"; +print ETFILE "# This file is generated by perl script fapiParseAttributeInfo.pl\n"; +print ETFILE "# It lists information about FAPI attribute enumeratorss and is\n"; +print ETFILE "# used to process FAPI Attribute text files (overrides/syncs)\n"; +print ETFILE "# Format:\n"; +print ETFILE "# <ENUM-STR>,<ENUM-VAL>\n"; + my %attrIdHash; # Records which Attribute IDs have been used my %attrValHash; # Records which Attribute values have been used @@ -258,8 +282,6 @@ foreach my $argnum (1 .. $#ARGV) exit(1); } - $attrIdHash{$attr->{id}} = 1; - # Calculate a 28 bit hash value. my $attrHash128Bit = md5_hex($attr->{id}); my $attrHash28Bit = substr($attrHash128Bit, 0, 7); @@ -267,9 +289,6 @@ foreach my $argnum (1 .. $#ARGV) # Print the attribute ID/value to fapiAttributeIds.H print AIFILE " $attr->{id} = 0x$attrHash28Bit,\n"; - # 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! @@ -278,6 +297,7 @@ foreach my $argnum (1 .. $#ARGV) exit(1); } + $attrIdHash{$attr->{id}} = $attrHash28Bit; $attrValHash{$attrHash28Bit} = 1; }; } @@ -352,6 +372,7 @@ foreach my $argnum (1 .. $#ARGV) #---------------------------------------------------------------------- # Print the typedef for each attribute's val type to fapiAttributeIds.H + # Print the attribute information to fapiAttrInfo.csv #---------------------------------------------------------------------- if (exists $attr->{chipEcFeature}) { @@ -369,14 +390,20 @@ foreach my $argnum (1 .. $#ARGV) if ($attr->{valueType} eq 'uint8') { print AIFILE "typedef uint8_t $attr->{id}_Type$arrayDimensions;\n"; + print ITFILE "$attr->{id},$attr->{id},0x$attrIdHash{$attr->{id}},u8" . + "$arrayDimensions\n"; } elsif ($attr->{valueType} eq 'uint32') { print AIFILE "typedef uint32_t $attr->{id}_Type$arrayDimensions;\n"; + print ITFILE "$attr->{id},$attr->{id},0x$attrIdHash{$attr->{id}},u32" . + "$arrayDimensions\n"; } elsif ($attr->{valueType} eq 'uint64') { print AIFILE "typedef uint64_t $attr->{id}_Type$arrayDimensions;\n"; + print ITFILE "$attr->{id},$attr->{id},0x$attrIdHash{$attr->{id}},u64" . + "$arrayDimensions\n"; } else { @@ -463,9 +490,9 @@ foreach my $argnum (1 .. $#ARGV) # Print the attribute enum to fapiAttributeIds.H print AIFILE " ENUM_$attr->{id}_${val}"; - # Print the attribute enum to fapiAttributeEnums.txt + # Print the attribute enum to fapiAttrEnumInfo.csv my $attrEnumTxt = "$attr->{id}_${val}\n"; - $attrEnumTxt =~ s/= //; + $attrEnumTxt =~ s/ = /,/; print ETFILE $attrEnumTxt; if ($attr->{valueType} eq 'uint64') diff --git a/src/usr/hwpf/fapi/makefile b/src/usr/hwpf/fapi/makefile index a6b5a3348..5af2f587f 100644 --- a/src/usr/hwpf/fapi/makefile +++ b/src/usr/hwpf/fapi/makefile @@ -36,7 +36,6 @@ OBJS = fapiReturnCode.o \ fapiErrorInfo.o \ fapiAttributeService.o \ fapiChipEcFeature.o \ - fapiAttributeTank.o \ fapiCollectRegFfdc.o include ${ROOTPATH}/config.mk diff --git a/src/usr/hwpf/hwp/fapiTestHwpAttr.C b/src/usr/hwpf/hwp/fapiTestHwpAttr.C deleted file mode 100755 index ad01d43c0..000000000 --- a/src/usr/hwpf/hwp/fapiTestHwpAttr.C +++ /dev/null @@ -1,1196 +0,0 @@ -/* 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 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 fapiTestHwpAttr.C - * - * @brief Implements the test Hardware Procedure that exercises the scratch - * attributes - */ - -/* - * Change Log ****************************************************************** - * Flag Defect/Feature User Date Description - * ------ -------------- ---------- ----------- ---------------------------- - * mjjones 06/30/2011 Created. - * mjjones 09/07/2011 Update to test scratch attrs - * mjjones 10/06/2011 Updates traces - * mjjones 10/07/2011 Removed target param - * mjjones 10/15/2011 Test scratch attributes - * mjjones 10/17/2011 Update scratch test - * camvanng 10/26/2011 Update scratch test - * mjjones 10/28/2011 Fix error generation - * 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> - -extern "C" -{ - -//****************************************************************************** -// hwpTestAttributes function -//****************************************************************************** -fapi::ReturnCode hwpTestAttributes(fapi::Target & i_mbaTarget, - fapi::Target & i_procTarget) -{ - FAPI_INF("hwpTestAttributes: Start HWP"); - fapi::ReturnCode l_rc; - - do - { - //---------------------------------------------------------------------- - // Test ATTR_SCRATCH_UINT8_1 - //---------------------------------------------------------------------- - { - uint8_t l_uint8 = 7; - - // Test set - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_1, NULL, l_uint8); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_1. Error from SET"); - break; - } - - // Test get - l_uint8 = 8; - l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT8_1, NULL, l_uint8); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_1. Error from GET"); - break; - } - - // Check value - if (l_uint8 != 7) - { - FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL); - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_1. GET returned %d", - l_uint8); - break; - } - - // Set to zero - l_uint8 = 0; - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_1, NULL, l_uint8); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_1. Error from SET (2)"); - break; - } - } - - //---------------------------------------------------------------------- - // Test ATTR_SCRATCH_UINT8_2 - //---------------------------------------------------------------------- - { - uint8_t l_uint8 = 6; - - // Test set - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_2, NULL, l_uint8); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_2. Error from SET"); - break; - } - - // Test get - l_uint8 = 8; - l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT8_2, NULL, l_uint8); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_2. Error from GET"); - break; - } - - // Check value - if (l_uint8 != 6) - { - FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL); - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_2. GET returned %d", - l_uint8); - break; - } - - // Set to zero - l_uint8 = 0; - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_2, NULL, l_uint8); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_2. Error from SET (2)"); - break; - } - } - - //---------------------------------------------------------------------- - // Test ATTR_SCRATCH_UINT32_1 - //---------------------------------------------------------------------- - { - uint32_t l_uint32 = 5; - - // Test set - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT32_1, NULL, l_uint32); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_1. Error from SET"); - break; - } - - // Test get - l_uint32 = 8; - l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT32_1, NULL, l_uint32); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_1. Error from GET"); - break; - } - - // Check value - if (l_uint32 != 5) - { - FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL); - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_1. GET returned %d", - l_uint32); - break; - } - - // Set to zero - l_uint32 = 0; - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT32_1, NULL, l_uint32); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_1. Error from SET (2)"); - break; - } - } - - //---------------------------------------------------------------------- - // Test ATTR_SCRATCH_UINT32_2 - //---------------------------------------------------------------------- - { - uint32_t l_uint32 = 4; - - // Test set - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT32_2, NULL, l_uint32); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_2. Error from SET"); - break; - } - - // Test get - l_uint32 = 8; - l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT32_2, NULL, l_uint32); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_2. Error from GET"); - break; - } - - // Check value - if (l_uint32 != 4) - { - FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL); - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_2. GET returned %d", - l_uint32); - break; - } - - // Set to zero - l_uint32 = 0; - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT32_2, NULL, l_uint32); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_2. Error from SET (2)"); - break; - } - } - - //---------------------------------------------------------------------- - // Test ATTR_SCRATCH_UINT64_1 - //---------------------------------------------------------------------- - { - uint64_t l_uint64 = 3; - - // Test set - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_1, NULL, l_uint64); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_1. Error from SET"); - break; - } - - // Test get - l_uint64 = 8; - l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_1, NULL, l_uint64); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_1. Error from GET"); - break; - } - - // Check value - if (l_uint64 != 3) - { - FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL); - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_1. GET returned %d", - static_cast<uint32_t>(l_uint64)); - break; - } - - // Set to zero - l_uint64 = 0; - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_1, NULL, l_uint64); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_1. Error from SET (2)"); - break; - } - } - - //---------------------------------------------------------------------- - // Test ATTR_SCRATCH_UINT64_2 - //---------------------------------------------------------------------- - { - uint64_t l_uint64 = 2; - - // Test set - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_2, NULL, l_uint64); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_2. Error from SET"); - break; - } - - // Test get - l_uint64 = 8; - l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_2, NULL, l_uint64); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_2. Error from GET"); - break; - } - - // Check value - if (l_uint64 != 2) - { - FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL); - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_2. GET returned %d", - static_cast<uint32_t>(l_uint64)); - break; - } - - // Set to zero - l_uint64 = 0; - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_2, NULL, l_uint64); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_2. Error from SET (2)"); - break; - } - } - - //---------------------------------------------------------------------- - // Test ATTR_SCRATCH_UINT8_ARRAY_1 - //---------------------------------------------------------------------- - { - uint8_t l_uint8array1[32]; - - // Test set - for (uint32_t i = 0; i < 32; i++) - { - l_uint8array1[i] = i + 1; - } - - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_ARRAY_1, NULL, l_uint8array1); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_ARRAY_1. Error from SET"); - break; - } - - // Test get - for (uint32_t i = 0; i < 32; i++) - { - l_uint8array1[i] = 0; - } - - l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT8_ARRAY_1, NULL, l_uint8array1); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_ARRAY_1. Error from GET"); - break; - } - - // Check value - for (uint32_t i = 0; i < 32; i++) - { - if (l_uint8array1[i] != (i + 1)) - { - FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL); - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_ARRAY_1. GET [%d] returned %d", - i, l_uint8array1[i]); - break; - } - } - - if (l_rc) - { - break; - } - - // Set to zero - for (uint32_t i = 0; i < 32; i++) - { - l_uint8array1[i] = 0; - } - - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_ARRAY_1, NULL, l_uint8array1); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_ARRAY_1. Error from SET (2)"); - break; - } - } - - //---------------------------------------------------------------------- - // Test ATTR_SCRATCH_UINT8_ARRAY_2 - //---------------------------------------------------------------------- - { - uint8_t l_uint8 = 1; - uint8_t l_uint8array2[2][3][4]; - - // Test set - l_uint8 = 1; - for (uint32_t i = 0; i < 2; i++) - { - for (uint32_t j = 0; j < 3; j++) - { - for (uint32_t k = 0; k < 4; k++) - { - l_uint8array2[i][j][k] = l_uint8++; - } - } - } - - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_ARRAY_2, NULL, l_uint8array2); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_ARRAY_2. Error from SET"); - break; - } - - // Test get - for (uint32_t i = 0; i < 2; i++) - { - for (uint32_t j = 0; j < 3; j++) - { - for (uint32_t k = 0; k < 4; k++) - { - l_uint8array2[i][j][k] = 0; - } - } - } - - l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT8_ARRAY_2, NULL, l_uint8array2); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_ARRAY_2. Error from GET"); - break; - } - - // Check value - l_uint8 = 1; - for (uint32_t i = 0; i < 2; i++) - { - for (uint32_t j = 0; j < 3; j++) - { - for (uint32_t k = 0; k < 4; k++) - { - if (l_uint8array2[i][j][k] != l_uint8++) - { - FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL); - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_ARRAY_2. GET [%d:%d:%d] returned %d", - i, j, k, l_uint8array2[i][j][k]); - break; - } - } - if (l_rc) - { - break; - } - } - if (l_rc) - { - break; - } - } - - if (l_rc) - { - break; - } - - // Set to zero - for (uint32_t i = 0; i < 2; i++) - { - for (uint32_t j = 0; j < 3; j++) - { - for (uint32_t k = 0; k < 4; k++) - { - l_uint8array2[i][j][k] = 0; - } - } - } - - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_ARRAY_2, NULL, l_uint8array2); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT8_ARRAY_2. Error from SET (2)"); - break; - } - } - - //---------------------------------------------------------------------- - // Test ATTR_SCRATCH_UINT32_ARRAY_1 - //---------------------------------------------------------------------- - { - uint32_t l_uint32array1[8]; - - // Test set - for (uint32_t i = 0; i < 8; i++) - { - l_uint32array1[i] = i + 1; - } - - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT32_ARRAY_1, NULL, l_uint32array1); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_ARRAY_1. Error from SET"); - break; - } - - // Test get - for (uint32_t i = 0; i < 8; i++) - { - l_uint32array1[i] = 0; - } - - l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT32_ARRAY_1, NULL, l_uint32array1); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_ARRAY_1. Error from GET"); - break; - } - - // Check value - for (uint32_t i = 0; i < 8; i++) - { - if (l_uint32array1[i] != (i + 1)) - { - FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL); - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_ARRAY_1. GET [%d] returned %d", - i, l_uint32array1[i]); - break; - } - } - - if (l_rc) - { - break; - } - - // Set to zero - for (uint32_t i = 0; i < 8; i++) - { - l_uint32array1[i] = 0; - } - - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT32_ARRAY_1, NULL, l_uint32array1); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_ARRAY_1. Error from SET (2)"); - break; - } - } - - //---------------------------------------------------------------------- - // Test ATTR_SCRATCH_UINT32_ARRAY_2 - //---------------------------------------------------------------------- - { - uint32_t l_uint32 = 1; - uint32_t l_uint32array2[2][3]; - - // Test set - l_uint32 = 1; - for (uint32_t i = 0; i < 2; i++) - { - for (uint32_t j = 0; j < 3; j++) - { - l_uint32array2[i][j] = l_uint32++; - } - } - - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT32_ARRAY_2, NULL, l_uint32array2); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_ARRAY_2. Error from SET"); - break; - } - - // Test get - for (uint32_t i = 0; i < 2; i++) - { - for (uint32_t j = 0; j < 3; j++) - { - l_uint32array2[i][j] = 0; - } - } - - l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT32_ARRAY_2, NULL, l_uint32array2); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_ARRAY_2. Error from GET"); - break; - } - - // Check value - l_uint32 = 1; - for (uint32_t i = 0; i < 2; i++) - { - for (uint32_t j = 0; j < 3; j++) - { - if (l_uint32array2[i][j] != l_uint32++) - { - FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL); - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_ARRAY_2. GET [%d:%d] returned %d", - i, j, l_uint32array2[i][j]); - break; - } - } - if (l_rc) - { - break; - } - } - - if (l_rc) - { - break; - } - - // Set to zero - for (uint32_t i = 0; i < 2; i++) - { - for (uint32_t j = 0; j < 3; j++) - { - l_uint32array2[i][j]= 0; - } - } - - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT32_ARRAY_2, NULL, l_uint32array2); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT32_ARRAY_2. Error from SET (2)"); - break; - } - } - - //---------------------------------------------------------------------- - // Test ATTR_SCRATCH_UINT64_ARRAY_1 - //---------------------------------------------------------------------- - { - // Demonstrate the use of a heap based array - uint64_t (&l_uint64array1)[4] = *(reinterpret_cast<uint64_t(*)[4]>(new uint64_t[4])); - - // Test set - for (uint32_t i = 0; i < 4; i++) - { - l_uint64array1[i] = i + 1; - } - - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_ARRAY_1, NULL, l_uint64array1); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_ARRAY_1. Error from SET"); - break; - } - - // Test get - for (uint32_t i = 0; i < 4; i++) - { - l_uint64array1[i] = 0; - } - - l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_ARRAY_1, NULL, l_uint64array1); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_ARRAY_1. Error from GET"); - break; - } - - // Check value - for (uint32_t i = 0; i < 4; i++) - { - if (l_uint64array1[i] != (i + 1)) - { - FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL); - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_ARRAY_1. GET [%d] returned %d", - i, static_cast<uint32_t>(l_uint64array1[i])); - break; - } - } - - if (l_rc) - { - break; - } - - // Set to zero - for (uint32_t i = 0; i < 4; i++) - { - l_uint64array1[i] = 0; - } - - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_ARRAY_1, NULL, l_uint64array1); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_ARRAY_1. Error from SET (2)"); - break; - } - - delete [] &l_uint64array1; - } - - //---------------------------------------------------------------------- - // Test ATTR_SCRATCH_UINT64_ARRAY_2 - //---------------------------------------------------------------------- - { - uint64_t l_uint64 = 1; - uint64_t l_uint64array2[2][2]; - - // Test set - l_uint64 = 1; - for (uint32_t i = 0; i < 2; i++) - { - for (uint32_t j = 0; j < 2; j++) - { - l_uint64array2[i][j] = l_uint64++; - } - } - - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_ARRAY_2, NULL, l_uint64array2); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_ARRAY_2. Error from SET"); - break; - } - - // Test get - for (uint32_t i = 0; i < 2; i++) - { - for (uint32_t j = 0; j < 2; j++) - { - l_uint64array2[i][j] = 0; - } - } - - l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_ARRAY_2, NULL, l_uint64array2); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_ARRAY_2. Error from GET"); - break; - } - - // Check value - l_uint64 = 1; - for (uint32_t i = 0; i < 2; i++) - { - for (uint32_t j = 0; j < 2; j++) - { - if (l_uint64array2[i][j] != l_uint64++) - { - FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL); - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_ARRAY_2. GET [%d:%d] returned %d", - i, j, static_cast<uint32_t>(l_uint64array2[i][j])); - break; - } - } - if (l_rc) - { - break; - } - } - - if (l_rc) - { - break; - } - - // Set to zero - for (uint32_t i = 0; i < 2; i++) - { - for (uint32_t j = 0; j < 2; j++) - { - l_uint64array2[i][j]= 0; - } - } - - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_ARRAY_2, NULL, l_uint64array2); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_ARRAY_2. Error from SET (2)"); - break; - } - } - - //---------------------------------------------------------------------- - // Test setting and getting an enum value from a scratch attribute - //---------------------------------------------------------------------- - { - uint64_t l_uint64 = fapi::ENUM_ATTR_SCRATCH_UINT64_2_VAL_C; - - // Test set - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_2, NULL, l_uint64); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_2. Error from SET (enum)"); - break; - } - - // Test get - l_uint64 = 0; - l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_2, NULL, l_uint64); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_2. Error from GET (enum)"); - break; - } - - // Check value - if (l_uint64 != fapi::ENUM_ATTR_SCRATCH_UINT64_2_VAL_C) - { - FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL); - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_2. GET returned %d (enum)", - static_cast<uint32_t>(l_uint64)); - break; - } - - // Set to zero - l_uint64 = 0; - l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_2, NULL, l_uint64); - if (l_rc) - { - FAPI_ERR("hwpTestAttributes: ATTR_SCRATCH_UINT64_2. Error from SET (enum2)"); - break; - } - } - - //---------------------------------------------------------------------- - // Removed getting scratch attributes using fapiGetInitFileAttr(). This - // now only supports the getting of attributes that are actually used by - // initfiles and those are excercised by the test initfile - //---------------------------------------------------------------------- - - //---------------------------------------------------------------------- - // Test getting an invalid attribute using fapiGetInitFileAttr() - //---------------------------------------------------------------------- - uint64_t l_val = 0; - fapi::AttributeId l_badId = static_cast<fapi::AttributeId>(0xff); - l_rc = fapiGetInitFileAttr(l_badId, NULL, l_val); - - if (l_rc) - { - // Delete the error rather than logging it to avoid it getting - // interpreted as a real problem - FAPI_INF("hwpTestAttributes: Deleting expected error 0x%x from fapiGetInitFileAttr", - static_cast<uint32_t>(l_rc)); - l_rc = fapi::FAPI_RC_SUCCESS; - } - else - { - FAPI_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL); - FAPI_ERR("hwpTestAttributes: Did not get error from fapiGetInitFileAttr"); - break; - } - - //---------------------------------------------------------------------- - // Test invalid accesses - //---------------------------------------------------------------------- - - // All of the following should not compile due to wrong types used - { - //uint32_t l_val; - //l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT8_1, NULL, l_val); - //l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_1, NULL, l_val); - } - { - //uint64_t l_val; - //l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT32_1, NULL, l_val); - //l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT32_1, NULL, l_val); - } - { - //uint8_t l_val; - //l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_1, NULL, l_val); - //l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_1, NULL, l_val); - } - { - //uint8_t l_array[33]; // size should be 32 - //l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT8_ARRAY_1, NULL, l_array); - //l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_ARRAY_1, NULL, l_array); - } - { - //uint8_t l_array[2][3]; // type should be uint32_t - //l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT32_ARRAY_2, NULL, l_array); - //l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT32_ARRAY_2, NULL, l_array); - } - { - //uint64_t l_array[2][1]; // second dimension should be 2 - //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 AttributeTank functions with empty tank - //---------------------------------------------------------------------- - { - // Create a local OverrideAttributeTank (this is not the singleton) - fapi::OverrideAttributeTank l_tank; - - // 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 (1.1)"); - break; - } - - // 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)) - { - 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 AttributeTank functions with single attribute in tank - //---------------------------------------------------------------------- - { - // 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_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL); - FAPI_ERR("hwpTestAttributes: Error. AttributeTank is empty (2.1)"); - break; - } - - // Try to get the wrong attribute from the tank - l_val = 0; - if (l_tank.getAttribute(fapi::ATTR_SCRATCH_UINT64_2, NULL, l_val)) - { - 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%016llx) from tank (2.7)", - l_pAttr[0].iv_val); - break; - } - delete [] l_attributes[0].iv_pAttributes; - l_attributes[0].iv_pAttributes = NULL; - } - - //---------------------------------------------------------------------- - // Test AttributeTank functions with multiple attributes in tank - //---------------------------------------------------------------------- - { - // 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_SET_HWP_ERROR(l_rc, RC_HWP_ATTR_UNIT_TEST_FAIL); - FAPI_ERR("hwpTestAttributes: Error. Did not get attr from tank (3.1)"); - 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%016llx) 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); - l_attributes[0].iv_pAttributes = NULL; - } - - //---------------------------------------------------------------------- - // 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); - - // 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); - l_attributes[0].iv_pAttributes = NULL; - } - - } while (0); - - FAPI_INF("hwpTestAttributes: End HWP"); - return l_rc; -} - -} // extern "C" diff --git a/src/usr/hwpf/hwp/makefile b/src/usr/hwpf/hwp/makefile index 2e8d7357e..b0390cb17 100644 --- a/src/usr/hwpf/hwp/makefile +++ b/src/usr/hwpf/hwp/makefile @@ -36,7 +36,6 @@ OBJS = fapiTestHwp.o \ fapiTestHwpError.o \ fapiTestHwpFfdc.o \ fapiTestHwpConfig.o \ - fapiTestHwpAttr.o \ fapiTestHwpDq.o \ fapiHwpExecInitFile.o \ dimmBadDqBitmapFuncs.o \ diff --git a/src/usr/hwpf/makefile b/src/usr/hwpf/makefile index f83583a28..a8ae92228 100644 --- a/src/usr/hwpf/makefile +++ b/src/usr/hwpf/makefile @@ -164,8 +164,8 @@ FAPI_ATTR_ID_TARGET = fapiAttributeIds.H # The FAPI files generated from Attribute XML files FAPI_ATTR_TARGETS = fapiChipEcFeature.C fapiAttributePlatCheck.H \ - fapiAttributesSupported.html fapiAttributeIds.txt \ - fapiAttributeEnums.txt + fapiAttributesSupported.html fapiAttrInfo.csv \ + fapiAttrEnumInfo.csv # The binary, list and attr files generated from Initfiles # Generation depends on ifcompiler and fapiAttributeIds.H diff --git a/src/usr/hwpf/plat/fapiPlatAttrOverrideSync.C b/src/usr/hwpf/plat/fapiPlatAttrOverrideSync.C index baadaec83..4b3989029 100644 --- a/src/usr/hwpf/plat/fapiPlatAttrOverrideSync.C +++ b/src/usr/hwpf/plat/fapiPlatAttrOverrideSync.C @@ -35,13 +35,13 @@ #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> +#include <targeting/common/utilFilter.H> +#include <targeting/common/attributeTank.H> namespace fapi { @@ -50,23 +50,10 @@ 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 -}; +// Set by a debug tool to directly apply an Attribute Override +TARGETING::AttributeTank::AttributeHeader g_attrOverrideHeader; +uint8_t g_attrOverride[AttrOverrideSync::MAX_DIRECT_OVERRIDE_ATTR_SIZE_BYTES]; +uint8_t g_attrOverrideFapiTank = 0; //****************************************************************************** // Apply a HWPF Attribute Override written directly into Hostboot memory from @@ -75,19 +62,92 @@ enum MAILBOX_MSG_TYPE void directOverride() { // Apply the attribute override - Singleton<fapi::OverrideAttributeTank>::instance(). - setAttribute(g_attrOverride); + if (g_attrOverrideFapiTank) + { + FAPI_IMP( + "directOverride: Applying direct attr override to FAPI tank (0x%08x:0x%08x:0x%04x:0x%02x)", + g_attrOverrideHeader.iv_attrId, g_attrOverrideHeader.iv_targetType, + g_attrOverrideHeader.iv_pos, g_attrOverrideHeader.iv_unitPos); + + theAttrOverrideSync().iv_overrideTank.setAttribute( + g_attrOverrideHeader.iv_attrId, + g_attrOverrideHeader.iv_targetType, + g_attrOverrideHeader.iv_pos, + g_attrOverrideHeader.iv_unitPos, + g_attrOverrideHeader.iv_flags, + g_attrOverrideHeader.iv_valSize, + &g_attrOverride); + } + else + { + // Convert the FAPI targeting type to TARGETING + TARGETING::TYPE l_targetType = TARGETING::TYPE_SYS; + + switch (g_attrOverrideHeader.iv_targetType) + { + case fapi::TARGET_TYPE_DIMM: + l_targetType = TARGETING::TYPE_DIMM; + break; + case fapi::TARGET_TYPE_PROC_CHIP: + l_targetType = TARGETING::TYPE_PROC; + break; + case fapi::TARGET_TYPE_MEMBUF_CHIP: + l_targetType = TARGETING::TYPE_MEMBUF; + break; + case fapi::TARGET_TYPE_EX_CHIPLET: + l_targetType = TARGETING::TYPE_EX; + break; + case fapi::TARGET_TYPE_MBA_CHIPLET: + l_targetType = TARGETING::TYPE_MBA; + break; + case fapi::TARGET_TYPE_MCS_CHIPLET: + l_targetType = TARGETING::TYPE_MCS; + break; + case fapi::TARGET_TYPE_XBUS_ENDPOINT: + l_targetType = TARGETING::TYPE_XBUS; + break; + case fapi::TARGET_TYPE_ABUS_ENDPOINT: + l_targetType = TARGETING::TYPE_ABUS; + break; + } + + FAPI_IMP( + "directOverride: Applying direct attr override to TARG tank (0x%08x:0x%08x:0x%04x:0x%02x)", + g_attrOverrideHeader.iv_attrId, l_targetType, + g_attrOverrideHeader.iv_pos, g_attrOverrideHeader.iv_unitPos); + + TARGETING::Target::theTargOverrideAttrTank().setAttribute( + g_attrOverrideHeader.iv_attrId, + l_targetType, + g_attrOverrideHeader.iv_pos, + g_attrOverrideHeader.iv_unitPos, + g_attrOverrideHeader.iv_flags, + g_attrOverrideHeader.iv_valSize, + &g_attrOverride); + } } //****************************************************************************** -void monitorForFspMessages() +AttrOverrideSync & theAttrOverrideSync() +{ + return Singleton<AttrOverrideSync>::instance(); +} + +//****************************************************************************** +AttrOverrideSync::AttrOverrideSync() {} + +//****************************************************************************** +AttrOverrideSync::~AttrOverrideSync() {} + +//****************************************************************************** +void AttrOverrideSync::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 @@ -95,33 +155,41 @@ void monitorForFspMessages() 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). - uint64_t l_size = l_pMsg->data[1]; - FAPI_INF("monitorForFspMessages: MSG_SET_OVERRIDES (%lld overrides)", - l_size / sizeof(fapi::Attribute)); - Attribute * l_pAttribute = - reinterpret_cast<Attribute *>(l_pMsg->extra_data); - - while (l_size >= sizeof(fapi::Attribute)) + uint64_t l_tank = l_pMsg->data[0]; + TARGETING::AttributeTank::AttributeSerializedChunk l_chunk; + l_chunk.iv_size = l_pMsg->data[1]; + l_chunk.iv_pAttributes = static_cast<uint8_t *>(l_pMsg->extra_data); + + if (l_tank == TARGETING::AttributeTank::TANK_LAYER_FAPI) + { + FAPI_INF( + "monitorForFspMessages: MSG_SET_OVERRIDES FAPI (size %lld)", + l_pMsg->data[1]); + iv_overrideTank.deserializeAttributes(l_chunk); + } + else { - Singleton<fapi::OverrideAttributeTank>::instance(). - setAttribute(*l_pAttribute); - l_pAttribute++; - l_size -= sizeof(fapi::Attribute); + FAPI_INF( + "monitorForFspMessages: MSG_SET_OVERRIDES TARG (size %lld)", + l_pMsg->data[1]); + TARGETING::Target::theTargOverrideAttrTank(). + deserializeAttributes(l_chunk); } - + // Free the memory free(l_pMsg->extra_data); l_pMsg->extra_data = NULL; + l_pMsg->data[0] = 0; l_pMsg->data[1] = 0; - + if (msg_is_async(l_pMsg)) { msg_free(l_pMsg); @@ -136,9 +204,9 @@ void monitorForFspMessages() { // FSP is clearing all attribute overrides. FAPI_INF("monitorForFspMessages: MSG_CLEAR_ALL_OVERRIDES"); - Singleton<fapi::OverrideAttributeTank>::instance(). - clearAllAttributes(); - + iv_overrideTank.clearAllAttributes(); + TARGETING::Target::theTargOverrideAttrTank().clearAllAttributes(); + if (msg_is_async(l_pMsg)) { msg_free(l_pMsg); @@ -158,58 +226,68 @@ void monitorForFspMessages() } //****************************************************************************** -// Utility function called by sendAttrOverridesAndSyncsToFsp -//****************************************************************************** -errlHndl_t sendAttrsToFsp(const MAILBOX_MSG_TYPE i_msgType, - std::vector<AttributeChunk> & i_attributes) +errlHndl_t AttrOverrideSync::sendAttrsToFsp( + const MAILBOX_MSG_TYPE i_msgType, + const TARGETING::AttributeTank::TankLayer i_tankLayer, + std::vector<TARGETING::AttributeTank::AttributeSerializedChunk> & + io_attributes) { errlHndl_t l_pErr = NULL; - + + std::vector<TARGETING::AttributeTank::AttributeSerializedChunk>::iterator + l_itr; + // Send Attributes through the mailbox chunk by chunk. - for (size_t i = 0; i < i_attributes.size(); i++) + for (l_itr = io_attributes.begin(); l_itr != io_attributes.end(); ++l_itr) { 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; - + l_pMsg->data[0] = i_tankLayer; + l_pMsg->data[1] = (*l_itr).iv_size; + l_pMsg->extra_data = (*l_itr).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); + l_pMsg = NULL; break; } - + // Mailbox freed the chunk data - i_attributes[i].iv_pAttributes = NULL; + (*l_itr).iv_pAttributes = NULL; msg_free(l_pMsg); + l_pMsg = NULL; } - + // 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++) + for (l_itr = io_attributes.begin(); l_itr != io_attributes.end(); ++l_itr) { - free(i_attributes[i].iv_pAttributes); - i_attributes[i].iv_pAttributes = NULL; + free((*l_itr).iv_pAttributes); + (*l_itr).iv_pAttributes = NULL; } - i_attributes.clear(); - + io_attributes.clear(); + return l_pErr; } //****************************************************************************** -void sendAttrOverridesAndSyncsToFsp() +void AttrOverrideSync::sendAttrOverridesAndSyncsToFsp() { + const uint32_t MAILBOX_CHUNK_SIZE = 4096; + if (MBOX::mailbox_enabled()) { + errlHndl_t l_pErr = NULL; + // Clear all current FSP Attribute Overrides msg_t * l_pMsg = msg_allocate(); l_pMsg->type = MSG_CLEAR_ALL_OVERRIDES; @@ -218,11 +296,12 @@ void sendAttrOverridesAndSyncsToFsp() l_pMsg->extra_data = NULL; // Send the message - errlHndl_t l_pErr = MBOX::send(MBOX::FSP_HWPF_ATTR_MSGQ, l_pMsg); - + l_pErr = MBOX::send(MBOX::FSP_HWPF_ATTR_MSGQ, l_pMsg); + if (l_pErr) { - FAPI_ERR("SendAttrOverridesToFsp: Error clearing FSP overrides"); + FAPI_ERR( + "sendAttrOverridesAndSyncsToFsp: Error clearing overrides"); errlCommit(l_pErr, HWPF_COMP_ID); msg_free(l_pMsg); l_pMsg = NULL; @@ -232,46 +311,93 @@ void sendAttrOverridesAndSyncsToFsp() l_pMsg = NULL; // 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()) + for (uint32_t i = TARGETING::AttributeTank::TANK_LAYER_FAPI; + i <= TARGETING::AttributeTank::TANK_LAYER_TARG; i++) { - l_pErr = sendAttrsToFsp(MSG_SET_OVERRIDES, l_attributes); + std::vector<TARGETING::AttributeTank::AttributeSerializedChunk> + l_attributes; - if (l_pErr) + if (i == TARGETING::AttributeTank::TANK_LAYER_FAPI) { - FAPI_ERR("SendAttrOverridesToFsp: Error sending overrides to FSP"); - errlCommit(l_pErr, HWPF_COMP_ID); + iv_overrideTank.serializeAttributes( + TARGETING::AttributeTank::ALLOC_TYPE_MALLOC, + MAILBOX_CHUNK_SIZE, l_attributes); + } + else + { + TARGETING::Target::theTargOverrideAttrTank(). + serializeAttributes( + TARGETING::AttributeTank::ALLOC_TYPE_MALLOC, + MAILBOX_CHUNK_SIZE, l_attributes); + } + + if (l_attributes.size()) + { + l_pErr = sendAttrsToFsp(MSG_SET_OVERRIDES, + static_cast<TARGETING::AttributeTank::TankLayer>(i), + l_attributes); + + if (l_pErr) + { + FAPI_ERR( + "sendAttrOverridesAndSyncsToFsp: Error sending overrides (%d)", + i); + errlCommit(l_pErr, HWPF_COMP_ID); + break; + } } } + } - if (l_pErr == NULL) + if (!l_pErr) + { + // Send Hostboot Attributes to Sync to the FSP + for (uint32_t i = TARGETING::AttributeTank::TANK_LAYER_FAPI; + i <= TARGETING::AttributeTank::TANK_LAYER_TARG; i++) { - // Send Hostboot Attributes to Sync to the FSP - std::vector<AttributeChunk> l_attributes; - - Singleton<fapi::SyncAttributeTank>::instance(). - getAllAttributes(AttributeTank::ALLOC_TYPE_MALLOC, - l_attributes); + std::vector<TARGETING::AttributeTank::AttributeSerializedChunk> + l_attributes; + + if (i == TARGETING::AttributeTank::TANK_LAYER_FAPI) + { + iv_syncTank.serializeAttributes( + TARGETING::AttributeTank::ALLOC_TYPE_MALLOC, + MAILBOX_CHUNK_SIZE, l_attributes); + } + else + { + TARGETING::Target::theTargSyncAttrTank(). + serializeAttributes( + TARGETING::AttributeTank::ALLOC_TYPE_MALLOC, + MAILBOX_CHUNK_SIZE, l_attributes); + } if (l_attributes.size()) { - l_pErr = sendAttrsToFsp(MSG_SET_SYNC_ATTS, l_attributes); + l_pErr = sendAttrsToFsp(MSG_SET_SYNC_ATTS, + static_cast<TARGETING::AttributeTank::TankLayer>(i), + l_attributes); if (l_pErr) { - FAPI_ERR("SendAttrOverridesToFsp: Error sending syncs to FSP"); + FAPI_ERR( + "sendAttrOverridesAndSyncsToFsp: Error sending syncs (%d)", + i); errlCommit(l_pErr, HWPF_COMP_ID); + break; } else { - // Clear Hostboot Attributes to Sync - Singleton<fapi::SyncAttributeTank>::instance(). - clearAllAttributes(); + // Clear Sync tank + if (i == TARGETING::AttributeTank::TANK_LAYER_FAPI) + { + iv_syncTank.clearAllAttributes(); + } + else + { + TARGETING::Target::theTargSyncAttrTank(). + clearAllAttributes(); + } } } } @@ -280,102 +406,177 @@ void sendAttrOverridesAndSyncsToFsp() } //****************************************************************************** -AttributeTank & theOverrideAttrTank() -{ - return Singleton<fapi::OverrideAttributeTank>::instance(); -} - -//****************************************************************************** -AttributeTank & theSyncAttrTank() +bool AttrOverrideSync::getAttrOverride(const fapi::AttributeId i_attrId, + const fapi::Target * const i_pTarget, + void * o_pVal) const { - return Singleton<fapi::SyncAttributeTank>::instance(); -} + // Very fast check to see if there are any overrides at all + if (!(iv_overrideTank.attributesExist())) + { + return false; + } -//****************************************************************************** -// This is used as a singleton and contains the lock used to serialize access -// to the OverrideAttributeTank -//****************************************************************************** -class OverrideAttributeTankLock -{ -public: - OverrideAttributeTankLock() + // Check to see if there are any overrides for this attr ID + if (!(iv_overrideTank.attributeExists(i_attrId))) { - mutex_init(&iv_mutex); + return false; } - ~OverrideAttributeTankLock() + // Do the work of figuring out the target's type/position and find out + // if there is an override for this target + uint32_t l_targetType = getTargetType(i_pTarget); + uint16_t l_pos = getTargetPos(i_pTarget); + uint8_t l_unitPos = getTargetUnitPos(i_pTarget); + + bool l_override = iv_overrideTank.getAttribute(i_attrId, l_targetType, + l_pos, l_unitPos, o_pVal); + + if (l_override) { - mutex_destroy(&iv_mutex); + FAPI_INF("getAttrOverride: Returning Override for 0x%08x", i_attrId); } - mutex_t iv_mutex; -}; + + return l_override; +} //****************************************************************************** -// This is used as a singleton and contains the lock used to serialize access -// to the SyncAttributeTank +bool AttrOverrideSync::getAttrOverrideFunc(const fapi::AttributeId i_attrId, + const fapi::Target * const i_pTarget, + void * o_pVal) +{ + return Singleton<AttrOverrideSync>::instance().getAttrOverride(i_attrId, + i_pTarget, o_pVal); +} + + //****************************************************************************** -class SyncAttributeTankLock +void AttrOverrideSync::setAttrActions(const fapi::AttributeId i_attrId, + const fapi::Target * const i_pTarget, + const uint32_t i_size, + const void * i_pVal) { -public: - SyncAttributeTankLock() + // Figure out if effort should be expended figuring out the target's type/ + // position in order to clear any non-const attribute overrides and/or to + // store the attribute for syncing to Cronus + + bool l_clearAnyNonConstOverride = false; + + // Very fast check to see if there are any overrides at all for this Attr ID + if (iv_overrideTank.attributesExist()) { - mutex_init(&iv_mutex); + // Fast check to see if there are any overrides for this attr ID + if (iv_overrideTank.attributeExists(i_attrId)) + { + l_clearAnyNonConstOverride = true; + } } - ~SyncAttributeTankLock() + bool l_syncAttribute = TARGETING::AttributeTank::syncEnabled(); + + if (l_clearAnyNonConstOverride || l_syncAttribute) { - mutex_destroy(&iv_mutex); - } - mutex_t iv_mutex; -}; + uint32_t l_targetType = getTargetType(i_pTarget); + uint16_t l_pos = getTargetPos(i_pTarget); + uint8_t l_unitPos = getTargetUnitPos(i_pTarget); -} // End attrOverrideSync namespace + if (l_clearAnyNonConstOverride) + { + // Clear any non const override for this attribute because the + // attribute is being written + iv_overrideTank.clearNonConstAttribute(i_attrId, l_targetType, + l_pos, l_unitPos); + } -//****************************************************************************** -// This is the Hostboot PLAT implementation of a FAPI function -//****************************************************************************** -void OverrideAttributeTank::platLock() const -{ - mutex_lock(&(Singleton<fapi::attrOverrideSync:: - OverrideAttributeTankLock>::instance().iv_mutex)); + if (l_syncAttribute) + { + // Write the attribute to the SyncAttributeTank to sync to Cronus + iv_syncTank.setAttribute(i_attrId, l_targetType, l_pos, l_unitPos, + 0, i_size, i_pVal); + } + } } //****************************************************************************** -// This is the Hostboot PLAT implementation of a FAPI function -//****************************************************************************** -void OverrideAttributeTank::platUnlock() const +void AttrOverrideSync::setAttrActionsFunc(const fapi::AttributeId i_attrId, + const fapi::Target * const i_pTarget, + const uint32_t i_size, + const void * i_pVal) { - mutex_unlock(&(Singleton<fapi::attrOverrideSync:: - OverrideAttributeTankLock>::instance().iv_mutex)); + Singleton<AttrOverrideSync>::instance().setAttrActions(i_attrId, i_pTarget, + i_size, i_pVal); } + //****************************************************************************** -// This is the Hostboot PLAT implementation of a FAPI function -//****************************************************************************** -void SyncAttributeTank::platLock() const +uint32_t AttrOverrideSync::getTargetType(const fapi::Target * const i_pTarget) { - mutex_lock(&(Singleton<fapi::attrOverrideSync:: - SyncAttributeTankLock>::instance().iv_mutex)); + uint32_t l_targetType = fapi::TARGET_TYPE_SYSTEM; + + if (i_pTarget != NULL) + { + l_targetType = i_pTarget->getType(); + } + + return l_targetType; } //****************************************************************************** -// This is the Hostboot PLAT implementation of a FAPI function -//****************************************************************************** -void SyncAttributeTank::platUnlock() const +uint16_t AttrOverrideSync::getTargetPos(const fapi::Target * const i_pTarget) { - mutex_unlock(&(Singleton<fapi::attrOverrideSync:: - SyncAttributeTankLock>::instance().iv_mutex)); + // Note that an error querying a parent chip is ignored and the function + // returns ATTR_POS_NA + uint16_t l_pos = TARGETING::AttributeTank::ATTR_POS_NA; + + if (i_pTarget != NULL) + { + // Get the Target pointer + TARGETING::Target * l_pTarget = + reinterpret_cast<TARGETING::Target*>(i_pTarget->get()); + + if (l_pTarget->getAttr<TARGETING::ATTR_CLASS>() == + TARGETING::CLASS_UNIT) + { + // Target is a chiplet. The position is the parent chip position + const TARGETING::Target * l_pChip = getParentChip(l_pTarget); + + if (l_pChip == NULL) + { + FAPI_ERR("getParentChip failed to return parent"); + } + else + { + l_pos = l_pChip->getAttr<TARGETING::ATTR_POSITION>(); + } + } + else + { + // Target is not a chiplet + l_pos = l_pTarget->getAttr<TARGETING::ATTR_POSITION>(); + } + } + + return l_pos; } //****************************************************************************** -// This is the Hostboot PLAT implementation of a FAPI function -//****************************************************************************** -bool SyncAttributeTank::platSyncEnabled() +uint8_t AttrOverrideSync::getTargetUnitPos(const fapi::Target * const i_pTarget) { - // 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; + uint8_t l_unitPos = TARGETING::AttributeTank::ATTR_UNIT_POS_NA; + + if (i_pTarget != NULL) + { + // Get the Target pointer + TARGETING::Target * l_pTarget = + reinterpret_cast<TARGETING::Target*>(i_pTarget->get()); + + if (l_pTarget->getAttr<TARGETING::ATTR_CLASS>() == + TARGETING::CLASS_UNIT) + { + l_unitPos = l_pTarget->getAttr<TARGETING::ATTR_CHIP_UNIT>(); + } + } + + return l_unitPos; } } // End fapi namespace diff --git a/src/usr/hwpf/plat/fapiPlatTask.C b/src/usr/hwpf/plat/fapiPlatTask.C index 4232f7aae..a03cff99b 100644 --- a/src/usr/hwpf/plat/fapiPlatTask.C +++ b/src/usr/hwpf/plat/fapiPlatTask.C @@ -1,26 +1,25 @@ -/* 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 - */ +/* 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,2013 */ +/* */ +/* 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 fapiPlatTask.C * @@ -31,7 +30,6 @@ // Includes //****************************************************************************** #include <initservice/taskargs.H> -#include <hwpf/fapi/fapiAttributeTank.H> #include <hwpf/plat/fapiPlatAttrOverrideSync.H> #include <hwpf/plat/fapiPlatTrace.H> @@ -42,7 +40,9 @@ namespace fapi // Global Variables //****************************************************************************** // Defined in fapiPlatAttrOverrideSync.C -extern Attribute g_attrOverride; +extern TARGETING::AttributeTank::AttributeHeader g_attrOverrideHeader; +extern uint8_t g_attrOverride[AttrOverrideSync::MAX_DIRECT_OVERRIDE_ATTR_SIZE_BYTES]; +extern uint8_t g_attrOverrideFapiTank; //****************************************************************************** // This function monitors for FSP mailbox messages @@ -50,15 +50,16 @@ extern Attribute g_attrOverride; void * platMonitorForFspMessages(void * i_pContext) { FAPI_IMP("Starting platMonitorForFspMessages"); - fapi::attrOverrideSync::monitorForFspMessages(); + fapi::theAttrOverrideSync().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 writes the global variables associated with direct attribute override to +// ensure they are paged and pinned in memory. These variables are used by a +// debug tool to override attributes // // It starts a task that monitors for FSP mailbox messages on the // HB_HWPF_ATTR_MSGQ message queue @@ -67,8 +68,10 @@ void platTaskEntry(errlHndl_t &io_errl) { FAPI_IMP("Starting platTaskEntry"); - // Write the g_attrOverride global - g_attrOverride.iv_val = 0; + // Write the global variables associated with direct attribute override + g_attrOverrideHeader.iv_attrId = 0; + g_attrOverride[0] = 0; + g_attrOverrideFapiTank = 0; // Start task that monitors for FSP mailbox messages task_create(fapi::platMonitorForFspMessages, NULL); diff --git a/src/usr/hwpf/test/fapiAttrTest.C b/src/usr/hwpf/test/fapiAttrTest.C new file mode 100644 index 000000000..1a97afaf3 --- /dev/null +++ b/src/usr/hwpf/test/fapiAttrTest.C @@ -0,0 +1,585 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/hwpf/test/fapiAttrTest.C $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2013 */ +/* */ +/* 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 fapiAttrTest.C + * + * @brief Implements FAPI Attribute unit test functions. + * + * This is provided by FAPI and can be pulled into any unit test framework. + * Each unit test returns 0 for success, else error value. + */ + +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 02/15/2013 Created. Ported from HWP. + */ + +#include <fapi.H> + +namespace fapi +{ + +//****************************************************************************** +// attrTest1. Test ATTR_SCRATCH_UINT8_1 +//****************************************************************************** +uint32_t attrTest1() +{ + uint32_t l_result = 0; + + do + { + fapi::ReturnCode l_rc; + + uint8_t l_uint8 = 0x87; + + // Test set + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_1, NULL, l_uint8); + if (l_rc) + { + fapiLogError(l_rc); + FAPI_ERR("attrTest1: ATTR_SCRATCH_UINT8_1. Error from SET (1)"); + l_result = 1; + break; + } + + // Test get + l_uint8 = 8; + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT8_1, NULL, l_uint8); + if (l_rc) + { + fapiLogError(l_rc); + FAPI_ERR("attrTest1: ATTR_SCRATCH_UINT8_1. Error from GET (2)"); + l_result = 2; + break; + } + + // Check value + if (l_uint8 != 0x87) + { + FAPI_ERR("attrTest1: ATTR_SCRATCH_UINT8_1. GET returned %d (3)", + l_uint8); + l_result = 3; + break; + } + + // Set to zero + l_uint8 = 0; + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_1, NULL, l_uint8); + if (l_rc) + { + fapiLogError(l_rc); + FAPI_ERR("attrTest1: ATTR_SCRATCH_UINT8_1. Error from SET (4)"); + l_result = 4; + break; + } + + } while (0); + + if (!l_result) + { + FAPI_INF("attrTest1: unit test success"); + } + return l_result; +} + +//****************************************************************************** +// attrTest2. Test ATTR_SCRATCH_UINT32_1 +//****************************************************************************** +uint32_t attrTest2() +{ + uint32_t l_result = 0; + + do + { + fapi::ReturnCode l_rc; + + uint32_t l_uint32 = 0x80000001; + + // Test set + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT32_1, NULL, l_uint32); + if (l_rc) + { + fapiLogError(l_rc); + FAPI_ERR("attrTest2: ATTR_SCRATCH_UINT32_1. Error from SET (1)"); + l_result = 1; + break; + } + + // Test get + l_uint32 = 8; + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT32_1, NULL, l_uint32); + if (l_rc) + { + fapiLogError(l_rc); + FAPI_ERR("attrTest2: ATTR_SCRATCH_UINT32_1. Error from GET (2)"); + l_result = 2; + break; + } + + // Check value + if (l_uint32 != 0x80000001) + { + FAPI_ERR("attrTest2: ATTR_SCRATCH_UINT32_1. GET returned %d (3)", + l_uint32); + l_result = 3; + break; + } + + // Set to zero + l_uint32 = 0; + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT32_1, NULL, l_uint32); + if (l_rc) + { + fapiLogError(l_rc); + FAPI_ERR("attrTest2: ATTR_SCRATCH_UINT32_1. Error from SET (4)"); + l_result = 4; + break; + } + + } while (0); + + if (!l_result) + { + FAPI_INF("attrTest2: unit test success"); + } + return l_result; +} + +//****************************************************************************** +// attrTest3. Test ATTR_SCRATCH_UINT64_1 +//****************************************************************************** +uint32_t attrTest3() +{ + uint32_t l_result = 0; + + do + { + fapi::ReturnCode l_rc; + + uint64_t l_uint64 = 3; + + // Test set + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_1, NULL, l_uint64); + if (l_rc) + { + fapiLogError(l_rc); + FAPI_ERR("attrTest3: ATTR_SCRATCH_UINT64_1. Error from SET (1)"); + l_result = 1; + break; + } + + // Test get + l_uint64 = 8; + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_1, NULL, l_uint64); + if (l_rc) + { + fapiLogError(l_rc); + FAPI_ERR("attrTest3: ATTR_SCRATCH_UINT64_1. Error from GET (2)"); + l_result = 2; + break; + } + + // Check value + if (l_uint64 != 3) + { + FAPI_ERR("attrTest3: ATTR_SCRATCH_UINT64_1. GET returned %d (3)", + static_cast<uint32_t>(l_uint64)); + l_result = 3; + break; + } + + // Set to zero + l_uint64 = 0; + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_1, NULL, l_uint64); + if (l_rc) + { + fapiLogError(l_rc); + FAPI_ERR("attrTest3: ATTR_SCRATCH_UINT64_1. Error from SET (4)"); + l_result = 4; + break; + } + + } while (0); + + if (!l_result) + { + FAPI_INF("attrTest3: unit test success"); + } + return l_result; +} + +//****************************************************************************** +// attrTest4. Test ATTR_SCRATCH_UINT8_ARRAY_1 +//****************************************************************************** +uint32_t attrTest4() +{ + uint32_t l_result = 0; + + do + { + fapi::ReturnCode l_rc; + + uint8_t l_uint8array1[32]; + + // Test set + for (uint32_t i = 0; i < 32; i++) + { + l_uint8array1[i] = i + 1; + } + + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_ARRAY_1, NULL, l_uint8array1); + if (l_rc) + { + fapiLogError(l_rc); + FAPI_ERR("attrTest4: ATTR_SCRATCH_UINT8_ARRAY_1. Error from SET (1)"); + l_result = 1; + break; + } + + // Test get + for (uint32_t i = 0; i < 32; i++) + { + l_uint8array1[i] = 0; + } + + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT8_ARRAY_1, NULL, l_uint8array1); + if (l_rc) + { + fapiLogError(l_rc); + FAPI_ERR("attrTest4: ATTR_SCRATCH_UINT8_ARRAY_1. Error from GET (2)"); + l_result = 2; + break; + } + + // Check value + for (uint32_t i = 0; i < 32; i++) + { + if (l_uint8array1[i] != (i + 1)) + { + FAPI_ERR("attrTest4: ATTR_SCRATCH_UINT8_ARRAY_1. GET [%d] returned %d (3)", + i, l_uint8array1[i]); + l_result = 3; + break; + } + } + + if (l_result) + { + break; + } + + // Set to zero + for (uint32_t i = 0; i < 32; i++) + { + l_uint8array1[i] = 0; + } + + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT8_ARRAY_1, NULL, l_uint8array1); + if (l_rc) + { + fapiLogError(l_rc); + FAPI_ERR("attrTest4: ATTR_SCRATCH_UINT8_ARRAY_1. Error from SET (4)"); + l_result = 4; + break; + } + + } while (0); + + if (!l_result) + { + FAPI_INF("attrTest4: unit test success"); + } + return l_result; +} + +//****************************************************************************** +// attrTest5. Test ATTR_SCRATCH_UINT32_ARRAY_2 +//****************************************************************************** +uint32_t attrTest5() +{ + uint32_t l_result = 0; + + do + { + fapi::ReturnCode l_rc; + + uint32_t l_uint32 = 1; + uint32_t l_uint32array2[2][3]; + + // Test set + l_uint32 = 1; + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 3; j++) + { + l_uint32array2[i][j] = l_uint32++; + } + } + + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT32_ARRAY_2, NULL, l_uint32array2); + if (l_rc) + { + fapiLogError(l_rc); + FAPI_ERR("attrTest5: ATTR_SCRATCH_UINT32_ARRAY_2. Error from SET (1)"); + l_result = 1; + break; + } + + // Test get + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 3; j++) + { + l_uint32array2[i][j] = 0; + } + } + + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT32_ARRAY_2, NULL, l_uint32array2); + if (l_rc) + { + fapiLogError(l_rc); + FAPI_ERR("attrTest5: ATTR_SCRATCH_UINT32_ARRAY_2. Error from GET (2)"); + l_result = 2; + break; + } + + // Check value + l_uint32 = 1; + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 3; j++) + { + if (l_uint32array2[i][j] != l_uint32++) + { + FAPI_ERR("attrTest5: ATTR_SCRATCH_UINT32_ARRAY_2. GET [%d:%d] returned %d (3)", + i, j, l_uint32array2[i][j]); + l_result = 3; + break; + } + } + if (l_result) + { + break; + } + } + + if (l_result) + { + break; + } + + // Set to zero + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 3; j++) + { + l_uint32array2[i][j]= 0; + } + } + + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT32_ARRAY_2, NULL, l_uint32array2); + if (l_rc) + { + fapiLogError(l_rc); + FAPI_ERR("attrTest5: ATTR_SCRATCH_UINT32_ARRAY_2. Error from SET (4)"); + l_result = 4; + break; + } + + } while (0); + + if (!l_result) + { + FAPI_INF("attrTest5: unit test success"); + } + return l_result; +} + +//****************************************************************************** +// attrTest6. Test ATTR_SCRATCH_UINT64_ARRAY_2 +//****************************************************************************** +uint32_t attrTest6() +{ + uint32_t l_result = 0; + + do + { + fapi::ReturnCode l_rc; + + uint64_t l_uint64 = 1; + uint64_t l_uint64array2[2][2]; + + // Test set + l_uint64 = 1; + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 2; j++) + { + l_uint64array2[i][j] = l_uint64++; + } + } + + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_ARRAY_2, NULL, l_uint64array2); + if (l_rc) + { + fapiLogError(l_rc); + FAPI_ERR("attrTest6: ATTR_SCRATCH_UINT64_ARRAY_2. Error from SET (1)"); + l_result = 1; + break; + } + + // Test get + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 2; j++) + { + l_uint64array2[i][j] = 0; + } + } + + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_ARRAY_2, NULL, l_uint64array2); + if (l_rc) + { + fapiLogError(l_rc); + FAPI_ERR("attrTest6: ATTR_SCRATCH_UINT64_ARRAY_2. Error from GET (2)"); + l_result = 2; + break; + } + + // Check value + l_uint64 = 1; + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 2; j++) + { + if (l_uint64array2[i][j] != l_uint64++) + { + FAPI_ERR("attrTest6: ATTR_SCRATCH_UINT64_ARRAY_2. GET [%d:%d] returned %d (3)", + i, j, static_cast<uint32_t>(l_uint64array2[i][j])); + l_result = 3; + break; + } + } + if (l_result) + { + break; + } + } + + if (l_result) + { + break; + } + + // Set to zero + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 2; j++) + { + l_uint64array2[i][j]= 0; + } + } + + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_ARRAY_2, NULL, l_uint64array2); + if (l_rc) + { + fapiLogError(l_rc); + FAPI_ERR("attrTest6: ATTR_SCRATCH_UINT64_ARRAY_2. Error from SET (4)"); + l_result = 4; + break; + } + } while (0); + + if (!l_result) + { + FAPI_INF("attrTest6: unit test success"); + } + return l_result; +} + +//****************************************************************************** +// attrTest7. Test setting and getting an enum value from a scratch attribute +//****************************************************************************** +uint32_t attrTest7() +{ + uint32_t l_result = 0; + + do + { + fapi::ReturnCode l_rc; + + uint64_t l_uint64 = fapi::ENUM_ATTR_SCRATCH_UINT64_2_VAL_C; + + // Test set + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_2, NULL, l_uint64); + if (l_rc) + { + fapiLogError(l_rc); + FAPI_ERR("attrTest7: ATTR_SCRATCH_UINT64_2. Error from SET (enum) (1)"); + l_result = 1; + break; + } + + // Test get + l_uint64 = 0; + l_rc = FAPI_ATTR_GET(ATTR_SCRATCH_UINT64_2, NULL, l_uint64); + if (l_rc) + { + fapiLogError(l_rc); + FAPI_ERR("attrTest7: ATTR_SCRATCH_UINT64_2. Error from GET (enum) (2)"); + l_result = 2; + break; + } + + // Check value + if (l_uint64 != fapi::ENUM_ATTR_SCRATCH_UINT64_2_VAL_C) + { + FAPI_ERR("attrTest7: ATTR_SCRATCH_UINT64_2. GET returned %d (enum) (3)", + static_cast<uint32_t>(l_uint64)); + l_result = 3; + break; + } + + // Set to zero + l_uint64 = 0; + l_rc = FAPI_ATTR_SET(ATTR_SCRATCH_UINT64_2, NULL, l_uint64); + if (l_rc) + { + fapiLogError(l_rc); + FAPI_ERR("attrTest7: ATTR_SCRATCH_UINT64_2. Error from SET (enum2) (4)"); + l_result = 4; + break; + } + + } while (0); + + if (!l_result) + { + FAPI_INF("attrTest7: unit test success"); + } + return l_result; +} + +} diff --git a/src/usr/hwpf/test/fapiattrtest.H b/src/usr/hwpf/test/fapiattrtest.H new file mode 100644 index 000000000..4610acb50 --- /dev/null +++ b/src/usr/hwpf/test/fapiattrtest.H @@ -0,0 +1,98 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/hwpf/test/fapiattrtest.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2013 */ +/* */ +/* 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 */ +#ifndef FAPIATTRTEST_H +#define FAPIATTRTEST_H + +/** + * @file fapiattrtanktest.H + * + * @brief Test case for FAPI AttributeTank +*/ + +#include <cxxtest/TestSuite.H> +#include "fapiAttrTest.C" + +using namespace fapi; + +class FapiAttrTest: public CxxTest::TestSuite +{ +public: + + void test1(void) + { + if (attrTest1() != 0) + { + TS_FAIL("attrTest1. Fail"); + } + } + + void test2(void) + { + if (attrTest2() != 0) + { + TS_FAIL("attrTest2. Fail"); + } + } + + void test3(void) + { + if (attrTest3() != 0) + { + TS_FAIL("attrTest3. Fail"); + } + } + + void test4(void) + { + if (attrTest4() != 0) + { + TS_FAIL("attrTest4. Fail"); + } + } + + void test5(void) + { + if (attrTest5() != 0) + { + TS_FAIL("attrTest5. Fail"); + } + } + + void test6(void) + { + if (attrTest6() != 0) + { + TS_FAIL("attrTest6. Fail"); + } + } + + void test7(void) + { + if (attrTest7() != 0) + { + TS_FAIL("attrTest7. Fail"); + } + } +}; + +#endif diff --git a/src/usr/hwpf/test/hwpftest.H b/src/usr/hwpf/test/hwpftest.H index ebf401df9..f2e9604b5 100644 --- a/src/usr/hwpf/test/hwpftest.H +++ b/src/usr/hwpf/test/hwpftest.H @@ -251,69 +251,6 @@ public: } /** - * @brief Test HWPF Attributes: call a test procedure that exercises - * FAPI attributes - */ - void testHwpf4() - { - errlHndl_t l_err = NULL; - - // 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) - { - TS_FAIL("testHwpf4: Unit Test failed. " - "hwpTestAttributes failed. Error logged"); - errlCommit(l_err,HWPF_COMP_ID); - } - else - { - TS_TRACE("testHwpf4: Unit Test passed. " - "hwpTestAttributes passed. Error logged"); - } - } - - /** * @brief Test HWPF InitFile: call the procedure that exercises a * sample initfile */ |