summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsrc/include/usr/hwpf/plat/fapiPlatAttrOverrideSync.H12
-rw-r--r--src/include/usr/pnor/pnorif.H4
-rw-r--r--src/include/usr/targeting/attrPlatOverride.H27
-rw-r--r--src/include/usr/targeting/common/attributeTank.H8
-rw-r--r--src/include/usr/targeting/common/targreasoncodes.H34
-rw-r--r--src/usr/initservice/istepdispatcher/istepdispatcher.C36
-rw-r--r--src/usr/pnor/pnorrp.C3
-rw-r--r--src/usr/targeting/attrPlatOverride.C184
-rw-r--r--src/usr/targeting/common/attributeTank.C6
-rw-r--r--src/usr/targeting/test/testattrtank.H223
10 files changed, 384 insertions, 153 deletions
diff --git a/src/include/usr/hwpf/plat/fapiPlatAttrOverrideSync.H b/src/include/usr/hwpf/plat/fapiPlatAttrOverrideSync.H
index fdcee3db8..fbc036eda 100755
--- a/src/include/usr/hwpf/plat/fapiPlatAttrOverrideSync.H
+++ b/src/include/usr/hwpf/plat/fapiPlatAttrOverrideSync.H
@@ -47,9 +47,8 @@
//******************************************************************************
namespace TARGETING
{
- errlHndl_t getAttrOverrides(PNOR::SectionId section,
- AttributeTank* io_tanks[AttributeTank::TANK_LAYER_LAST],
- uint32_t i_pnorSecOffset);
+ errlHndl_t getAttrOverrides(PNOR::SectionInfo_t &i_sectionInfo,
+ AttributeTank* io_tanks[AttributeTank::TANK_LAYER_LAST]);
}
namespace fapi
@@ -89,9 +88,10 @@ public:
/**
* @brief Allow a attribute override to directly access the override tank
*/
- friend errlHndl_t TARGETING::getAttrOverrides(PNOR::SectionId section,
- TARGETING::AttributeTank* io_tanks[TARGETING::AttributeTank::TANK_LAYER_LAST],
- uint32_t i_pnorSecOffset);
+ friend errlHndl_t TARGETING::getAttrOverrides(
+ PNOR::SectionInfo_t &i_sectionInfo,
+ TARGETING::AttributeTank*
+ io_tanks[TARGETING::AttributeTank::TANK_LAYER_LAST]);
/**
* @brief Maximum size of a direct attribute override
diff --git a/src/include/usr/pnor/pnorif.H b/src/include/usr/pnor/pnorif.H
index 0272ce832..cfda3aeb2 100644
--- a/src/include/usr/pnor/pnorif.H
+++ b/src/include/usr/pnor/pnorif.H
@@ -54,10 +54,11 @@ enum SectionId
DIMM_JEDEC_VPD, /**< DIMM JEDEC VPD */
MODULE_VPD, /**< Module VPD */
CENTAUR_VPD, /**< Centaur VPD */
- ATTR_OVER, /**< Attribute Override */
NVRAM, /**< Opal NVRAM */
OCC, /**< OCC lid */
FIRDATA, /**< FIRDATA */
+ ATTR_TMP, /**< Temporary Attribute Override */
+ ATTR_PERM, /**< Permanent Attribute Override */
TEST, /**< Scratch space for PNOR test cases */
NUM_SECTIONS, /**< Number of defined sections */
@@ -116,7 +117,6 @@ errlHndl_t validateAltMaster( void );
*/
const uint32_t pnorTestSec_readwrite_offset = 0x100;
const uint32_t pnorTestSec_smartwrite_offset = 0x120;
-const uint32_t pnorTestSec_BMCAttrOverride_offset = 0x200;
}
diff --git a/src/include/usr/targeting/attrPlatOverride.H b/src/include/usr/targeting/attrPlatOverride.H
index 61eccd8b5..6461228ab 100644
--- a/src/include/usr/targeting/attrPlatOverride.H
+++ b/src/include/usr/targeting/attrPlatOverride.H
@@ -27,6 +27,7 @@
#include <targeting/common/attributeTank.H>
#include <pnor/pnorif.H>
+#include <utility>
namespace TARGETING
{
@@ -45,6 +46,21 @@ struct AttrOverrideSection
};
/**
+ * @brief Array containing AttributeTank layers to Pnor Override Sections
+ *
+ * The pair is used just to maintain order of AttributeTank::TankLayer
+ * enums and make it obvious which layers map to what PNOR section.
+ * Currrently the pair is only used in a test case to keep it in order
+ */
+const std::pair<AttributeTank::TankLayer, PNOR::SectionId>
+ tankLayerToPnor[AttributeTank::TANK_LAYER_LAST] =
+ {
+ std::make_pair(AttributeTank::TANK_LAYER_FAPI, PNOR::ATTR_TMP),
+ std::make_pair(AttributeTank::TANK_LAYER_TARG, PNOR::ATTR_TMP),
+ std::make_pair(AttributeTank::TANK_LAYER_PERM, PNOR::ATTR_PERM)
+ };
+
+/**
* @brief This function gets any Attribute Overrides in PNOR
*
* This function reads attribute overrides in from PNOR and places them in
@@ -52,19 +68,14 @@ struct AttrOverrideSection
* permanent attribute overrides. Currently there are 3 attribute tanks,
* FAPI, Targeting, and Permanent.
*
- * @param[in] i_section PNOR::SectionId to look for overrides default
- * ATTR_OVER
+ * @param[in] i_sectionInfo PNOR::SectionInfo_t to look for overrides
* @param[in] io_tanks Array of pointers to Attribute tanks, used for
* test cases, default set to NULL
- * @param[in] i_pnorSecOffset Offset within section to read, used for test cases
- * default set to 0
*
* @return errlHndl_t Error log handle.
*/
-errlHndl_t getAttrOverrides(PNOR::SectionId i_section = PNOR::ATTR_OVER,
- AttributeTank* io_tanks[AttributeTank::TANK_LAYER_LAST] = NULL,
- uint32_t i_pnorSecOffset = 0);
-//errlCommit( err, TARG_COMP_ID);
+errlHndl_t getAttrOverrides(PNOR::SectionInfo_t &i_sectionInfo,
+ AttributeTank* io_tanks[AttributeTank::TANK_LAYER_LAST] = NULL);
} // end of namespace
diff --git a/src/include/usr/targeting/common/attributeTank.H b/src/include/usr/targeting/common/attributeTank.H
index 94cb69716..2acd48d42 100644
--- a/src/include/usr/targeting/common/attributeTank.H
+++ b/src/include/usr/targeting/common/attributeTank.H
@@ -86,6 +86,7 @@ public:
TANK_LAYER_TARG,
TANK_LAYER_PERM,
TANK_LAYER_LAST = TANK_LAYER_PERM,
+ TANK_LAYER_TERM = 0xFFFFFFFF,
};
/**
@@ -354,6 +355,13 @@ public:
*/
errlHndl_t writePermAttributes();
+ /**
+ * @brief This retuns the number of attributes overrides in an attr tank
+ *
+ * @return size_t Number of overrides in attr tank
+ */
+ size_t size() const;
+
private:
// Copy constructor and assignment operator disabled
AttributeTank(const AttributeTank & i_right);
diff --git a/src/include/usr/targeting/common/targreasoncodes.H b/src/include/usr/targeting/common/targreasoncodes.H
index 63da83bf3..b26b60d9e 100644
--- a/src/include/usr/targeting/common/targreasoncodes.H
+++ b/src/include/usr/targeting/common/targreasoncodes.H
@@ -50,22 +50,24 @@ enum TargetingModuleId
enum TargetingReasonCode
{
- TARG_RC_TEST_TARGET_FFDC = TARG_COMP_ID | 0x01,
- TARG_RC_BAD_EYECATCH = TARG_COMP_ID | 0x02,
- TARG_RC_MM_BLOCK_FAIL = TARG_COMP_ID | 0x03,
- TARG_RC_MM_PERM_FAIL = TARG_COMP_ID | 0x04,
- TARG_RC_ATTR_MSG_FAIL = TARG_COMP_ID | 0x05,
- TARG_RC_UNHANDLED_ATTR_SEC_TYPE = TARG_COMP_ID | 0x06,
- TARG_RC_ATTR_SYNC_TO_FSP_FAIL = TARG_COMP_ID | 0x07,
- TARG_RC_ATTR_SYNC_REQUEST_TO_HB_FAIL = TARG_COMP_ID | 0x08,
- TARG_RC_ATTR_SYNC_TO_HB_FAIL = TARG_COMP_ID | 0x09,
- TARG_RT_UNIT_TARGET_NOT_FOUND = TARG_COMP_ID | 0x0a,
- TARG_RT_NO_PROC_TARGET = TARG_COMP_ID | 0x0b,
- TARG_RT_TARGET_TYPE_NOT_SUPPORTED = TARG_COMP_ID | 0x0c,
- TARG_RC_ATTR_OVER_PNOR_SEC_SPACE_FAIL = TARG_COMP_ID | 0x0d,
- TARG_RC_ATTR_OVER_ATTR_DATA_SIZE_FAIL = TARG_COMP_ID | 0x0e,
- TARG_RC_WRITE_PERM_ATTR_FAIL = TARG_COMP_ID | 0x0f,
- TARG_RC_WRITE_PERM_ATTR_TARGET_FAIL = TARG_COMP_ID | 0x10,
+ TARG_RC_TEST_TARGET_FFDC = TARG_COMP_ID | 0x01,
+ TARG_RC_BAD_EYECATCH = TARG_COMP_ID | 0x02,
+ TARG_RC_MM_BLOCK_FAIL = TARG_COMP_ID | 0x03,
+ TARG_RC_MM_PERM_FAIL = TARG_COMP_ID | 0x04,
+ TARG_RC_ATTR_MSG_FAIL = TARG_COMP_ID | 0x05,
+ TARG_RC_UNHANDLED_ATTR_SEC_TYPE = TARG_COMP_ID | 0x06,
+ TARG_RC_ATTR_SYNC_TO_FSP_FAIL = TARG_COMP_ID | 0x07,
+ TARG_RC_ATTR_SYNC_REQUEST_TO_HB_FAIL = TARG_COMP_ID | 0x08,
+ TARG_RC_ATTR_SYNC_TO_HB_FAIL = TARG_COMP_ID | 0x09,
+ TARG_RT_UNIT_TARGET_NOT_FOUND = TARG_COMP_ID | 0x0a,
+ TARG_RT_NO_PROC_TARGET = TARG_COMP_ID | 0x0b,
+ TARG_RT_TARGET_TYPE_NOT_SUPPORTED = TARG_COMP_ID | 0x0c,
+ TARG_RC_ATTR_OVER_PNOR_SEC_SPACE_FAIL = TARG_COMP_ID | 0x0d,
+ TARG_RC_ATTR_OVER_ATTR_DATA_SIZE_FAIL = TARG_COMP_ID | 0x0e,
+ TARG_RC_WRITE_PERM_ATTR_FAIL = TARG_COMP_ID | 0x0f,
+ TARG_RC_WRITE_PERM_ATTR_TARGET_FAIL = TARG_COMP_ID | 0x10,
+ TARG_RC_WRITE_ATTR_OVER_WRONG_PNOR_SEC = TARG_COMP_ID | 0x11,
+ TARG_RC_WRITE_ATTR_OVER_NO_TANK_LAYER = TARG_COMP_ID | 0x12,
};
}; // End TARGETING namespace
diff --git a/src/usr/initservice/istepdispatcher/istepdispatcher.C b/src/usr/initservice/istepdispatcher/istepdispatcher.C
index 3ab4e0b8a..6d0df0c3f 100644
--- a/src/usr/initservice/istepdispatcher/istepdispatcher.C
+++ b/src/usr/initservice/istepdispatcher/istepdispatcher.C
@@ -64,6 +64,7 @@
#include <targeting/attrPlatOverride.H>
#include <console/consoleif.H>
#include <hwpisteperror.H>
+#include <pnor/pnorif.H>
namespace ISTEPS_TRACE
{
@@ -246,15 +247,42 @@ void IStepDispatcher::init(errlHndl_t &io_rtaskRetErrl)
// Get Attribute overrides from PNOR
else
{
- err = TARGETING::getAttrOverrides();
+ PNOR::SectionInfo_t l_sectionInfo;
+ // Get temporary attribute overrides from pnor
+ err = PNOR::getSectionInfo(PNOR::ATTR_TMP, l_sectionInfo);
+ // Attr override sections are optional so just delete error
if (err)
{
- TRACFCOMP(g_trac_initsvc,"Failed getAttrOverrides");
- break;
+ delete err;
+ err = NULL;
}
else
{
- TRACFCOMP(g_trac_initsvc,"Success getAttrOverrides");
+ TRACFCOMP(g_trac_initsvc,"init: processing temporary overrides");
+ err = TARGETING::getAttrOverrides(l_sectionInfo);
+ if (err)
+ {
+ TRACFCOMP(g_trac_initsvc,"Failed getAttrOverrides: getting temporary overrides");
+ break;
+ }
+ }
+ // Get permanent attribute overrides from pnor
+ err = PNOR::getSectionInfo(PNOR::ATTR_PERM, l_sectionInfo);
+ // Attr override sections are optional so just delete error
+ if (err)
+ {
+ delete err;
+ err = NULL;
+ }
+ else
+ {
+ TRACFCOMP(g_trac_initsvc,"init: processing permanent overrides");
+ err = TARGETING::getAttrOverrides(l_sectionInfo);
+ if (err)
+ {
+ TRACFCOMP(g_trac_initsvc,"Failed getAttrOverrides: getting permanent overrides");
+ break;
+ }
}
}
diff --git a/src/usr/pnor/pnorrp.C b/src/usr/pnor/pnorrp.C
index 53a05c1de..81358661c 100644
--- a/src/usr/pnor/pnorrp.C
+++ b/src/usr/pnor/pnorrp.C
@@ -71,10 +71,11 @@ const char* cv_EYECATCHER[] = {
"DJVPD", /**< PNOR::DIMM_JEDEC_VPD : Dimm JEDEC VPD */
"MVPD", /**< PNOR::MODULE_VPD : Module VPD */
"CVPD", /**< PNOR::CENTAUR_VPD : Centaur VPD */
- "ATTROVER", /**< PNOR::ATTR_OVER : Attribute Override */
"NVRAM", /**< PNOR::NVRAM : OPAL Storage */
"OCC", /**< PNOR::OCC : OCC LID */
"FIRDATA", /**< PNOR::FIRDATA : FIRDATA */
+ "ATTR_TMP", /**< PNOR::ATTR_TMP : Temporary Attribute Overrides */
+ "ATTR_PERM", /**< PNOR::ATTR_PERM : Permanent Attribute Overrides */
"TEST", /**< PNOR::TEST : Test space for PNOR*/
//Not currently used
diff --git a/src/usr/targeting/attrPlatOverride.C b/src/usr/targeting/attrPlatOverride.C
index 7f67ab221..3f71da189 100644
--- a/src/usr/targeting/attrPlatOverride.C
+++ b/src/usr/targeting/attrPlatOverride.C
@@ -26,13 +26,13 @@
#include <hwpf/plat/fapiPlatAttrOverrideSync.H>
#include <targeting/common/trace.H>
#include <targeting/common/targreasoncodes.H>
+#include <errl/errlmanager.H>
namespace TARGETING
{
-errlHndl_t getAttrOverrides(PNOR::SectionId i_section,
- AttributeTank* io_tanks[AttributeTank::TANK_LAYER_LAST],
- uint32_t pnorSecOffset)
+errlHndl_t getAttrOverrides(PNOR::SectionInfo_t &i_sectionInfo,
+ AttributeTank* io_tanks[AttributeTank::TANK_LAYER_LAST])
{
TRACFCOMP(g_trac_targeting,"attrPlatOverride::getAttrOverrides ENTER");
@@ -63,65 +63,57 @@ errlHndl_t getAttrOverrides(PNOR::SectionId i_section,
do
{
- // Read PNOR section
- PNOR::SectionInfo_t sectionInfo;
- l_err = PNOR::getSectionInfo( i_section, sectionInfo );
- // Attr override sections are optional so just delete error and break
- if (l_err)
- {
- delete l_err;
- l_err = NULL;
- break;
- }
- uint32_t l_index = pnorSecOffset;
+ uint32_t l_index = 0;
// Deserialize each section
- while (l_index < sectionInfo.size)
+ while (l_index < i_sectionInfo.size)
{
AttrOverrideSection * l_pAttrOverSec =
reinterpret_cast<AttrOverrideSection *>
- (sectionInfo.vaddr + l_index);
+ (i_sectionInfo.vaddr + l_index);
- // Reached termination chunck
- if (l_pAttrOverSec->iv_layer == AttributeTank::TANK_LAYER_NONE)
+ // Reached termination chunk
+ if (l_pAttrOverSec->iv_layer == AttributeTank::TANK_LAYER_TERM)
{
TRACFCOMP(g_trac_targeting,"attrPlatOverride::getAttrOverrides Reached termination section at chunk (0x%x)",
- (sectionInfo.size - l_index));
+ (i_sectionInfo.size - l_index));
break;
}
// Remaining chunk smaller than AttrOverrideSection, quit
- if (sizeof(AttrOverrideSection) > (sectionInfo.size - l_index))
+ if (sizeof(AttrOverrideSection) > (i_sectionInfo.size - l_index))
{
TRACFCOMP(g_trac_targeting,"attrPlatOverride::getAttrOverrides AttrOverrideSection too big for chunk (0x%x)",
- (sectionInfo.size - l_index));
- /*@
- * @errortype
- * @moduleid TARG_GET_ATTR_OVER
- * @reasoncode TARG_RC_ATTR_OVER_PNOR_SEC_SPACE_FAIL
- * @userdata1 PNOR Section specified
- * @userdata2 Size of AttrOverrideSection
- * @devdesc AttrOverrideSection too big to fit in remaining
- * chunck of pnor section
- */
- l_err =
- new ERRORLOG::ErrlEntry
- (ERRORLOG::ERRL_SEV_PREDICTIVE,
- TARG_GET_ATTR_OVER,
- TARG_RC_ATTR_OVER_PNOR_SEC_SPACE_FAIL,
- i_section,
- sizeof(AttrOverrideSection),
- true /*SW callout*/);
- break;
+ (i_sectionInfo.size - l_index));
+ /*@
+ * @errortype
+ * @moduleid TARG_GET_ATTR_OVER
+ * @reasoncode TARG_RC_ATTR_OVER_PNOR_SEC_SPACE_FAIL
+ * @userdata1 PNOR Section specified
+ * @userdata2 Size of AttrOverrideSection
+ * @devdesc AttrOverrideSection too big to fit in remaining
+ * chunck of pnor section
+ * @custdesc Invalid configuration data in firmware pnor
+ */
+ l_err =
+ new ERRORLOG::ErrlEntry
+ (ERRORLOG::ERRL_SEV_PREDICTIVE,
+ TARG_GET_ATTR_OVER,
+ TARG_RC_ATTR_OVER_PNOR_SEC_SPACE_FAIL,
+ i_sectionInfo.id,
+ sizeof(AttrOverrideSection));
+ l_err->addProcedureCallout(HWAS::EPUB_PRC_SP_CODE,
+ HWAS::SRCI_PRIORITY_HIGH);
+ break;
}
l_index += sizeof(AttrOverrideSection);
// Remaining chunk smaller than serialized chunk size, quit
- if (l_pAttrOverSec->iv_size > (sectionInfo.size - l_index))
+ if (l_pAttrOverSec->iv_size > (i_sectionInfo.size - l_index))
{
TRACFCOMP(g_trac_targeting,"attrPlatOverride::getAttrOverrides serialized chunk too big for chunk (0x%x)",
- (sectionInfo.size - l_index));
+ (i_sectionInfo.size - l_index));
/*@
* @errortype
* @moduleid TARG_GET_ATTR_OVER
@@ -130,35 +122,113 @@ errlHndl_t getAttrOverrides(PNOR::SectionId i_section,
* @userdata2 Size of Serialized attribute override
* @devdesc Serialized attribute override chunk too big to
* fit in remaining chunck of pnor section
+ * @custdesc Invalid configuration data in firmware pnor
*/
l_err =
new ERRORLOG::ErrlEntry
(ERRORLOG::ERRL_SEV_PREDICTIVE,
TARG_GET_ATTR_OVER,
TARG_RC_ATTR_OVER_ATTR_DATA_SIZE_FAIL,
- i_section,
- l_pAttrOverSec->iv_size,
- true /*SW callout*/);
+ i_sectionInfo.id,
+ l_pAttrOverSec->iv_size);
+ l_err->addProcedureCallout(HWAS::EPUB_PRC_SP_CODE,
+ HWAS::SRCI_PRIORITY_HIGH);
break;
}
- // Get the AttributeTank that corresponds to the TankLayer in the
- // AttrOverrideSection. Enum starts with TANK_LAYER_NONE so need to
- // substract 1
- AttributeTank* l_ptank = l_pOverTanks[l_pAttrOverSec->iv_layer - 1];
-
- // Create serialized chunck with AttrOverrideSection data
- AttributeTank::AttributeSerializedChunk l_chunk;
- l_chunk.iv_size = l_pAttrOverSec->iv_size;
- l_chunk.iv_pAttributes = &l_pAttrOverSec->iv_chunk[0];
-
- // Deserialize the data with the approriate AttributeTank
- l_ptank->deserializeAttributes(l_chunk);
+ // Check if a tank layer is specified, if not we can't apply the
+ // attribute override.
+ if (l_pAttrOverSec->iv_layer == AttributeTank::TANK_LAYER_NONE)
+ {
+ TRACFCOMP(g_trac_targeting,"attrPlatOverride::getAttrOverrides no tank layer specified at chunk (0x%x)",
+ (i_sectionInfo.size - l_index));
+ /*@
+ * @errortype
+ * @moduleid TARG_GET_ATTR_OVER
+ * @reasoncode TARG_RC_WRITE_ATTR_OVER_NO_TANK_LAYER
+ * @userdata1 PNOR Section specified
+ * @userdata2 Chunk location with no tank layer
+ * @devdesc No tank layer was specified for attribute
+ * override.
+ * @custdesc Invalid configuration data in firmware pnor
+ */
+ l_err =
+ new ERRORLOG::ErrlEntry
+ (ERRORLOG::ERRL_SEV_PREDICTIVE,
+ TARG_GET_ATTR_OVER,
+ TARG_RC_WRITE_ATTR_OVER_NO_TANK_LAYER,
+ i_sectionInfo.id,
+ (i_sectionInfo.size - l_index));
+ l_err->collectTrace("TARG",256);
+ l_err->addProcedureCallout(HWAS::EPUB_PRC_SP_CODE,
+ HWAS::SRCI_PRIORITY_HIGH);
+ ERRORLOG::errlCommit(l_err, TARG_COMP_ID);
+ }
+ // Check if the AttrOverSec is in the correct PNOR section
+ // It was decided that this should not cause a failed IPL, so the
+ // override will not be applied, the errl will be committed, then
+ // we move on.
+ else if (tankLayerToPnor[l_pAttrOverSec->iv_layer - 1].second !=
+ i_sectionInfo.id)
+ {
+ TRACFCOMP(g_trac_targeting,"getAttrOverrides: Failed to apply override - override with TankLayer 0x%X should not be in PNOR::%s",
+ l_pAttrOverSec->iv_layer, i_sectionInfo.name);
+ /*@
+ * @errortype
+ * @moduleid TARG_GET_ATTR_OVER
+ * @reasoncode TARG_RC_WRITE_ATTR_OVER_WRONG_PNOR_SEC
+ * @userdata1 Tank Layer of attribute
+ * @userdata2 PNOR Section specified
+ * @devdesc Attribute override is in the wrong pnor section
+ * needs to be moved to the section associated
+ * with its attribute tank layer
+ * @custdesc Invalid configuration data in firmware pnor
+ */
+ l_err =
+ new ERRORLOG::ErrlEntry
+ (ERRORLOG::ERRL_SEV_PREDICTIVE,
+ TARG_GET_ATTR_OVER,
+ TARG_RC_WRITE_ATTR_OVER_WRONG_PNOR_SEC,
+ l_pAttrOverSec->iv_layer,
+ i_sectionInfo.id);
+ l_err->collectTrace("TARG",256);
+ l_err->addProcedureCallout(HWAS::EPUB_PRC_SP_CODE,
+ HWAS::SRCI_PRIORITY_HIGH);
+ ERRORLOG::errlCommit(l_err, TARG_COMP_ID);
+ }
+ // Only apply attribute override if in the correct PNOR section
+ else
+ {
+ // Get the AttributeTank that corresponds to the TankLayer in
+ // the AttrOverrideSection. Enum starts with TANK_LAYER_NONE
+ // so need to substract 1
+ AttributeTank* l_ptank = l_pOverTanks[l_pAttrOverSec->iv_layer - 1];
+
+ // Create serialized chunck with AttrOverrideSection data
+ AttributeTank::AttributeSerializedChunk l_chunk;
+ l_chunk.iv_size = l_pAttrOverSec->iv_size;
+ l_chunk.iv_pAttributes = &l_pAttrOverSec->iv_chunk[0];
+
+ // Deserialize the data with the approriate AttributeTank
+ l_ptank->deserializeAttributes(l_chunk);
+ }
l_index += l_pAttrOverSec->iv_size;
}
+ if (l_err)
+ {
+ break;
+ }
+
// Write permanent attribute overrides
- l_err = l_PermTank.writePermAttributes();
+ if ((i_sectionInfo.id == PNOR::ATTR_PERM) &&
+ (l_PermTank.size() > 0) )
+ {
+ // l_PermTank should be empty if the section is not ATTR_PERM
+ // with the check above, but sanity check
+ l_err = l_PermTank.writePermAttributes();
+ break;
+ }
} while(0);
diff --git a/src/usr/targeting/common/attributeTank.C b/src/usr/targeting/common/attributeTank.C
index 17f6375d7..d23494c14 100644
--- a/src/usr/targeting/common/attributeTank.C
+++ b/src/usr/targeting/common/attributeTank.C
@@ -597,4 +597,10 @@ errlHndl_t AttributeTank::writePermAttributes()
return l_err;
}
+//******************************************************************************
+size_t AttributeTank::size() const
+{
+ return iv_attributes.size();
+}
+
}
diff --git a/src/usr/targeting/test/testattrtank.H b/src/usr/targeting/test/testattrtank.H
index 5a7cb8cc7..247076e58 100644
--- a/src/usr/targeting/test/testattrtank.H
+++ b/src/usr/targeting/test/testattrtank.H
@@ -1149,30 +1149,39 @@ public:
/**
* @brief Test BMC Attr Override function
- * Set attributes into 3 different tanks for attribute override and
- * serialize the data of each tank. Then call getAttrOverrides to
- * deserialize each sections data and check that the data is correct
+ * Set attributes into 3 different tanks. Then place overrides in
+ * both correct/incorrect simulated pnor sections. Finally call
+ * getAttrOverrides to deserialize each sections data and verify
+ * that it did not apply incorrect overrides and applied correct ones
*
*/
void testBMCAttrOverride(void)
{
+ errlHndl_t l_errhdl = NULL;
+ const uint64_t l_chunkSize = 4096;
+
+ // Simulate Pnor ATTR_TMP and ATTR_PERM sections in memory
+ PNOR::SectionInfo_t l_attrTmpSec;
+ l_attrTmpSec.id = PNOR::ATTR_TMP;
+ l_attrTmpSec.name = "Test Attr Tmp";
+ l_attrTmpSec.vaddr = reinterpret_cast<uint64_t>(malloc(3*l_chunkSize));
+
+ PNOR::SectionInfo_t l_attrPermSec;
+ l_attrPermSec.id = PNOR::ATTR_PERM;
+ l_attrPermSec.name = "Test Attr Perm";
+ l_attrPermSec.vaddr = reinterpret_cast<uint64_t>(malloc(3*l_chunkSize));
+
do
{
- errlHndl_t errhdl = NULL;
- // Use the TEST partition as scratch space
- PNOR::SectionInfo_t info;
- errhdl = PNOR::getSectionInfo( PNOR::TEST, info );
- if (errhdl)
- {
- TS_FAIL("testattrtank::testBMCAttrOverride could not get PNOR test section info");
- break;
- }
-
// Create local AttributeTanks
AttributeTank l_FapiTank;
AttributeTank l_TargetTank;
AttributeTank l_PermTank;
+ // Create local array of those tanks
+ AttributeTank* l_tanks[AttributeTank::TANK_LAYER_LAST];
+
+ // Create Attr Overrides
// Add ATTR_SCRATCH_UINT64_1 to the Fapi tank
uint64_t l_val = 4;
l_FapiTank.setAttribute(ATTR_SCRATCH_UINT64_1,
@@ -1197,107 +1206,157 @@ public:
AttributeTank::ATTR_NODE_NA,
0, sizeof(l_val), &l_val);
+
////////////////////////////////////////////////////////////////////
- // Fapi
+ // Fill in simulated pnor sections
+ // Add a fapi, targ, and perm overrides to both sections to test
+ // catching incorrect ones and applying the correct ones
- // Serialize all attributes from each tank
+ uint32_t l_permIndex = 0;
+ uint32_t l_tmpIndex = 0;
+ AttrOverrideSection * l_pAttrOverSec = NULL;
+ AttributeTank::AttributeSerializedChunk l_chunk;
+
+ // Fapi - Serialize all attributes from each tank
AttributeTank::AttributeSerializedChunks_t l_attributes;
l_FapiTank.serializeAttributes(AttributeTank::ALLOC_TYPE_NEW,
- 4096, l_attributes);
+ l_chunkSize, l_attributes);
- // Copy Fapi Override chunk to PNOR
- uint32_t l_index = PNOR::pnorTestSec_BMCAttrOverride_offset;
+ // Copy Fapi Overrides to test tmp and perm sections
for (AttributeTank::AttributeSerializedChunks_t::iterator
chunkIter = l_attributes.begin();
chunkIter != l_attributes.end();
++chunkIter)
{
- AttrOverrideSection * l_pAttrOverSec =
- reinterpret_cast<AttrOverrideSection *>
- (info.vaddr + l_index);
- AttributeTank::AttributeSerializedChunk l_chunk = *chunkIter;
+ l_chunk = *chunkIter;
+
+ // handle tmp section
+ l_pAttrOverSec = reinterpret_cast<AttrOverrideSection *>
+ (l_attrTmpSec.vaddr + l_tmpIndex);
l_pAttrOverSec->iv_layer = AttributeTank::TANK_LAYER_FAPI;
l_pAttrOverSec->iv_size = l_chunk.iv_size;
memcpy(&l_pAttrOverSec->iv_chunk, l_chunk.iv_pAttributes,
l_chunk.iv_size);
- l_index += sizeof(AttrOverrideSection)+l_pAttrOverSec->iv_size;
- }
+ l_tmpIndex += sizeof(AttrOverrideSection)+
+ l_pAttrOverSec->iv_size;
- ////////////////////////////////////////////////////////////////////
- // Targeting
+ // handle perm section
+ l_pAttrOverSec = reinterpret_cast<AttrOverrideSection *>
+ (l_attrPermSec.vaddr + l_permIndex);
+ l_pAttrOverSec->iv_layer = AttributeTank::TANK_LAYER_FAPI;
+ l_pAttrOverSec->iv_size = l_chunk.iv_size;
+ memcpy(&l_pAttrOverSec->iv_chunk, l_chunk.iv_pAttributes,
+ l_chunk.iv_size);
+ l_permIndex += sizeof(AttrOverrideSection)+
+ l_pAttrOverSec->iv_size;
+ }
- // Serialize all attributes from each tank
+ // Targeting - Serialize all attributes from tank
l_attributes.clear();
l_TargetTank.serializeAttributes(AttributeTank::ALLOC_TYPE_NEW,
- 4096, l_attributes);
+ l_chunkSize, l_attributes);
- // Copy Target Override chunk to PNOR
+ // Copy Target Override chunk to test tmp and perm sections
for (AttributeTank::AttributeSerializedChunks_t::iterator
chunkIter = l_attributes.begin();
chunkIter != l_attributes.end();
++chunkIter)
{
- AttrOverrideSection * l_pAttrOverSec =
- reinterpret_cast<AttrOverrideSection *>
- (info.vaddr + l_index);
- AttributeTank::AttributeSerializedChunk l_chunk = *chunkIter;
+ l_chunk = *chunkIter;
+
+ // handle tmp section
+ l_pAttrOverSec = reinterpret_cast<AttrOverrideSection *>
+ (l_attrTmpSec.vaddr + l_tmpIndex);
l_pAttrOverSec->iv_layer = AttributeTank::TANK_LAYER_TARG;
l_pAttrOverSec->iv_size = l_chunk.iv_size;
memcpy(&l_pAttrOverSec->iv_chunk, l_chunk.iv_pAttributes,
l_chunk.iv_size);
- l_index += sizeof(AttrOverrideSection)+l_pAttrOverSec->iv_size;
+ l_tmpIndex += sizeof(AttrOverrideSection)+
+ l_pAttrOverSec->iv_size;
+ // handle perm section
+ l_pAttrOverSec = reinterpret_cast<AttrOverrideSection *>
+ (l_attrPermSec.vaddr + l_permIndex);
+ l_pAttrOverSec->iv_layer = AttributeTank::TANK_LAYER_TARG;
+ l_pAttrOverSec->iv_size = l_chunk.iv_size;
+ memcpy(&l_pAttrOverSec->iv_chunk, l_chunk.iv_pAttributes,
+ l_chunk.iv_size);
+ l_permIndex += sizeof(AttrOverrideSection)+
+ l_pAttrOverSec->iv_size;
}
- ////////////////////////////////////////////////////////////////////
- // Permanent
-
- // Serialize all attributes from each tank
+ // Permanent - Serialize all attributes from tank
l_attributes.clear();
l_PermTank.serializeAttributes(AttributeTank::ALLOC_TYPE_NEW,
- 4096, l_attributes);
+ l_chunkSize, l_attributes);
- // Copy Target Override chunk to PNOR
+ // Copy Perm Override chunk to test tmp and perm sections
for (AttributeTank::AttributeSerializedChunks_t::iterator
chunkIter = l_attributes.begin();
chunkIter != l_attributes.end();
++chunkIter)
{
- AttrOverrideSection * l_pAttrOverSec =
- reinterpret_cast<AttrOverrideSection *>
- (info.vaddr + l_index);
- AttributeTank::AttributeSerializedChunk l_chunk = *chunkIter;
+ l_chunk = *chunkIter;
+
+ // handle tmp section
+ l_pAttrOverSec = reinterpret_cast<AttrOverrideSection *>
+ (l_attrTmpSec.vaddr + l_tmpIndex);
l_pAttrOverSec->iv_layer = AttributeTank::TANK_LAYER_PERM;
l_pAttrOverSec->iv_size = l_chunk.iv_size;
memcpy(&l_pAttrOverSec->iv_chunk, l_chunk.iv_pAttributes,
l_chunk.iv_size);
- l_index += sizeof(AttrOverrideSection)+l_pAttrOverSec->iv_size;
+ l_tmpIndex += sizeof(AttrOverrideSection)+
+ l_pAttrOverSec->iv_size;
+ // handle perm section
+ l_pAttrOverSec = reinterpret_cast<AttrOverrideSection *>
+ (l_attrPermSec.vaddr + l_permIndex);
+ l_pAttrOverSec->iv_layer = AttributeTank::TANK_LAYER_PERM;
+ l_pAttrOverSec->iv_size = l_chunk.iv_size;
+ memcpy(&l_pAttrOverSec->iv_chunk, l_chunk.iv_pAttributes,
+ l_chunk.iv_size);
+ l_permIndex += sizeof(AttrOverrideSection)+
+ l_pAttrOverSec->iv_size;
}
// Add termination section
- AttrOverrideSection * l_pAttrOverSecTerm =
- reinterpret_cast<AttrOverrideSection *>
- (info.vaddr + l_index);
- l_pAttrOverSecTerm->iv_layer = AttributeTank::TANK_LAYER_NONE;
- l_pAttrOverSecTerm->iv_size = 0;
- // Clear tanks
+ // handle tmp section
+ l_pAttrOverSec = reinterpret_cast<AttrOverrideSection *>
+ (l_attrTmpSec.vaddr + l_tmpIndex);
+ l_pAttrOverSec->iv_layer = AttributeTank::TANK_LAYER_TERM;
+ l_pAttrOverSec->iv_size = 0;
+ l_tmpIndex += sizeof(AttrOverrideSection);
+
+ // handle perm section
+ l_pAttrOverSec = reinterpret_cast<AttrOverrideSection *>
+ (l_attrPermSec.vaddr + l_permIndex);
+ l_pAttrOverSec->iv_layer = AttributeTank::TANK_LAYER_TERM;
+ l_pAttrOverSec->iv_size = 0;
+ l_permIndex += sizeof(AttrOverrideSection);
+
+ // Update final size of created section
+ l_attrTmpSec.size = l_tmpIndex;
+ l_attrPermSec.size = l_permIndex;
+
+ ////////////////////////////////////////////////////////////////////
+ // Test simulated pnor sections attr overrides
+
+ // Test Attr Tmp - should only include Fapi and Targ overrides
l_FapiTank.clearAllAttributes();
l_TargetTank.clearAllAttributes();
l_PermTank.clearAllAttributes();
- // Call function that actually reads in attribute overrides
- AttributeTank* l_tanks[AttributeTank::TANK_LAYER_LAST];
l_tanks[AttributeTank::TANK_LAYER_FAPI-1] = &l_FapiTank;
l_tanks[AttributeTank::TANK_LAYER_TARG-1] = &l_TargetTank;
l_tanks[AttributeTank::TANK_LAYER_PERM-1] = &l_PermTank;
- errhdl = getAttrOverrides(PNOR::TEST,
- l_tanks,
- PNOR::pnorTestSec_BMCAttrOverride_offset);
- if (errhdl)
+
+ // Call function that actually reads in attribute overrides
+ l_errhdl = getAttrOverrides(l_attrTmpSec, l_tanks);
+
+ if (l_errhdl)
{
- errlCommit(errhdl, TARG_COMP_ID);
+ errlCommit(l_errhdl, TARG_COMP_ID);
TS_FAIL("testattrtank::testBMCAttrOverride getAttrOverrides() failed");
break;
}
@@ -1341,6 +1400,21 @@ public:
break;
}
+ // Check to make sure no Permanent overrides were applied
+ if (l_PermTank.size() > 0)
+ {
+ TS_FAIL("testattrtank::testBMCAttrOverride: Error. A permanent override was found and applied in the PNOR::TMP section");
+ break;
+ }
+
+ // Test Attr Perm - should only include Perm overrides
+ l_tanks[AttributeTank::TANK_LAYER_FAPI-1]->clearAllAttributes();
+ l_tanks[AttributeTank::TANK_LAYER_TARG-1]->clearAllAttributes();
+ l_tanks[AttributeTank::TANK_LAYER_PERM-1]->clearAllAttributes();
+
+ // Call function that actually reads in attribute overrides
+ l_errhdl = getAttrOverrides(l_attrPermSec, l_tanks);
+
// Check the first attribute made it back into the Perm tank
l_val = 0;
if (!(l_PermTank.getAttribute(ATTR_SCRATCH_UINT64_1,
@@ -1359,8 +1433,39 @@ public:
l_val);
break;
}
+ // Check to make sure no Fapi overrides were applied
+ if (l_FapiTank.size() > 0)
+ {
+ TS_FAIL("testattrtank::testBMCAttrOverride: Error. A fapi override was found and applied in the PNOR::PERM section");
+ break;
+ }
+ // Check to make sure no Targ overrides were applied
+ if (l_TargetTank.size() > 0)
+ {
+ TS_FAIL("testattrtank::testBMCAttrOverride: Error. A targ override was found and applied in the PNOR::PERM section");
+ break;
+ }
+
} while(0);
- TRACFCOMP(g_trac_targeting, "testattrtank::testBMCAttrOverride: Success steve");
+
+ // Free memory
+ free (reinterpret_cast<char *>(l_attrTmpSec.vaddr));
+ free (reinterpret_cast<char *>(l_attrPermSec.vaddr));
+ }
+
+ /**
+ * @brief Test to check if the const array tankLayerToPnor is sorted
+ * which also indicates in enum order
+ */
+ void testLidToPnorSorted(void)
+ {
+ for (size_t i = 0; i < (AttributeTank::TANK_LAYER_LAST - 1); ++i)
+ {
+ if (tankLayerToPnor[i].first > tankLayerToPnor[i+1].first)
+ {
+ TS_FAIL("testattrtank::testTankLayerToPnorSorted: attrPlatOverride.H tankLayerToPnor[] is not sorted");
+ }
+ }
}
};
OpenPOWER on IntegriCloud