diff options
-rw-r--r-- | src/include/usr/hwas/common/deconfigGard.H | 195 | ||||
-rw-r--r-- | src/include/usr/hwas/hwasPlatDeconfigGard.H | 12 | ||||
-rw-r--r-- | src/usr/errl/test/errltest.H | 102 | ||||
-rw-r--r-- | src/usr/errl/test/errluserdetailtest.H | 26 | ||||
-rw-r--r-- | src/usr/hwas/common/deconfigGard.C | 620 | ||||
-rw-r--r-- | src/usr/hwas/common/hwas.C | 4 | ||||
-rw-r--r-- | src/usr/hwas/hwasPlat.C | 71 | ||||
-rw-r--r-- | src/usr/hwas/hwasPlatCallout.C | 2 | ||||
-rw-r--r-- | src/usr/hwas/hwasPlatDeconfigGard.C | 379 | ||||
-rw-r--r-- | src/usr/hwas/makefile | 4 | ||||
-rw-r--r-- | src/usr/hwas/test/hwasGardTest.H | 445 |
11 files changed, 834 insertions, 1026 deletions
diff --git a/src/include/usr/hwas/common/deconfigGard.H b/src/include/usr/hwas/common/deconfigGard.H index 147686037..eddd7d7cf 100644 --- a/src/include/usr/hwas/common/deconfigGard.H +++ b/src/include/usr/hwas/common/deconfigGard.H @@ -79,9 +79,6 @@ DeconfigGard & theDeconfigGard(); class DeconfigGard { - // allow GardAddress to access private methods. - friend class GardAddress; - public: enum @@ -237,34 +234,33 @@ public: * * Any error creating the GARD Record will be returned to the user. * - * @param[in] i_target Reference to Target to create GARD Record for. + * @param[in] i_pTarget Pointer to Target to create GARD Record for. * @param[in] i_errlPlid Error log PLID to store in GARD Record. * @param[in] i_errorType error type of the GARD Record. * * @return errlHndl_t. Error log handle. */ - errlHndl_t createGardRecord(const TARGETING::Target & i_target, + errlHndl_t createGardRecord(const TARGETING::Target * const i_pTarget, const uint32_t i_errlPlid, const GARD_ErrorType i_errorType); /** - * @brief Clears the specified GARD Records. - * - * Called by an administrator to clear GARD records manually. - * - * If the specified record does not exist then no error is returned. The - * only errors returned are usage errors and errors accessing the GARD - * Records. + * @brief Platform specific function that + * Creates a GARD Record for a Target. * - * @param[in] i_recordId RecordId to clear. If zero (CLEAR_ALL_GARD_RECORDS) - * then all GARD Records cleared. + * @param[in] i_pTarget Pointer to Target to create GARD Record for. + * @param[in] i_errlPlid Error log PLID to store in GARD Record. + * @param[in] i_errorType error type of the GARD Record. * * @return errlHndl_t. Error log handle. */ - errlHndl_t clearGardRecords(const uint32_t i_recordId); + errlHndl_t platCreateGardRecord(const TARGETING::Target * const i_pTarget, + const uint32_t i_errlPlid, + const GARD_ErrorType i_errorType); /** - * @brief Clears all GARD Records for the specified Target. + * @brief Clears GARD Record for the specified Target, or ALL GARD + * records. * * Called by an administrator to clear GARD records manually. * @@ -272,47 +268,53 @@ public: * only errors returned are usage errors and errors accessing the GARD * Records. * - * @param[in] i_targetId Reference to Target ID to clear GARD Records for. + * @param[in] i_pTarget Pointer to Target to clear GARD record for. + * If NULL, then ALL GARD Records will be cleared. + * + * @return errlHndl_t. Error log handle. + */ + errlHndl_t clearGardRecords(const TARGETING::Target * const i_pTarget); + + /** + * @brief Platform specific function that + * Clears Record for the specified Target. + * + * @param[in] i_pTarget Pointer to Target to clear GARD record for. + * If NULL, then ALL GARD Records will be cleared. * * @return errlHndl_t. Error log handle. */ - errlHndl_t clearGardRecords(const TARGETING::EntityPath & i_targetId); + errlHndl_t platClearGardRecords(const TARGETING::Target * const i_pTarget); /** - * @brief Gets the specified GARD Records. + * @brief Gets all GARD Records for the specified Target. * * Called by an administrator to view GARD Records. * - * If the specified record does not exist then no error is returned. The + * If no GARD Records exist for the Target then no error is returned. The * only errors returned are usage errors and errors accessing the GARD * Records. * - * @param[in] i_recordId RecordId to get. If zero then all GARD Records are - * retrieved. + * @param[in] i_pTarget Pointer to Sys or Node Target * @param[out] o_records Reference to vector of GardRecords that is cleared * then filled in with records. * * @return errlHndl_t. Error log handle. */ - errlHndl_t getGardRecords(const uint32_t i_recordId, + errlHndl_t getGardRecords(const TARGETING::Target * const i_pTarget, GardRecords_t & o_records); /** - * @brief Gets all GARD Records for the specified Target. - * - * Called by an administrator to view GARD Records. - * - * If no GARD Records exist for the Target then no error is returned. The - * only errors returned are usage errors and errors accessing the GARD - * Records. + * @brief Platform specific function that + * Gets all GARD Records for the specified Target. * - * @param[in] i_targetId Reference to Target ID to get GARD Records for. + * @param[in] i_pTarget Pointer to Sys or Node Target * @param[out] o_records Reference to vector of GardRecords that is cleared * then filled in with records. * * @return errlHndl_t. Error log handle. */ - errlHndl_t getGardRecords(const TARGETING::EntityPath & i_targetId, + errlHndl_t platGetGardRecords(const TARGETING::Target * const i_pTarget, GardRecords_t & o_records); protected: @@ -390,7 +392,7 @@ public: * * @return errlHndl_t. Error log handle. */ - errlHndl_t _getDeconfigureRecords(const TARGETING::Target * i_pTarget, + errlHndl_t _getDeconfigureRecords(const TARGETING::Target * const i_pTarget, DeconfigureRecords_t & o_records); /** @@ -400,7 +402,7 @@ public: * Records for. If NULL then all Deconfigure Records * are cleared. */ - void clearDeconfigureRecords(const TARGETING::Target * i_pTarget); + void clearDeconfigureRecords(const TARGETING::Target * const i_pTarget); /** @@ -414,135 +416,20 @@ public: private: - /** - * @brief Creates a GARD Record for a Target. - * - * @param[in] i_target Reference to Target to create GARD Record for. - * @param[in] i_errlPlid Error log PLID to store in GARD Record. - * @param[in] i_errorType Error Type of the GARD Record. - * - * @return errlHndl_t. Error log handle. - */ - errlHndl_t _createGardRecord(const TARGETING::Target & i_target, - const uint32_t i_errlPlid, - const GARD_ErrorType i_errorType); - - /** - * @brief Clears the specified GARD Records. - * - * @param[in] i_recordId RecordId to clear. If CLEAR_ALL_GARD_RECORDS - * then all GARD Records cleared. - * - * @return errlHndl_t. Error log handle. - */ - errlHndl_t _clearGardRecords(const uint32_t i_recordId); - - /** - * @brief Clears all GARD Records for the specified Target. - * - * @param[in] i_targetId Reference to Target ID to clear GARD Records for. - * - * @return errlHndl_t. Error log handle. - */ - errlHndl_t _clearGardRecords(const TARGETING::EntityPath & i_targetId); - - /** - * @brief Gets the specified GARD Records. - * - * @param[in] i_recordId RecordId to get. If zero then all GARD Records are - * retrieved. - * @param[out] o_records Reference to vector of GardRecords that is cleared - * then filled in with records. - * - * @return errlHndl_t. Error log handle. - */ - errlHndl_t _getGardRecords(const uint32_t i_recordId, - GardRecords_t & o_records); - - /** - * @brief Gets all GARD Records for the specified Target. - * - * - * @param[in] i_targetId Reference to Target ID to get GARD Records for. - * @param[out] o_records Reference to vector of GardRecords that is cleared - * then filled in with records. - * - * @return errlHndl_t. Error log handle. - */ - errlHndl_t _getGardRecords(const TARGETING::EntityPath & i_targetId, - GardRecords_t & o_records); - - /** - * @brief sets the maxGardRecords and nextGardRecordId variables - * - * @param[in] i_size size of GARD area in PNOR/memory - */ - void _GardRecordIdSetup(uint32_t i_size); - // Mutex for thread safety HWAS_MUTEX_TYPE iv_mutex; - // GARD Record Data - uint32_t iv_nextGardRecordId; // Next GARD Record ID to use - uint32_t iv_maxGardRecords; // Maximum number of GARD Records - GardRecord * iv_pGardRecords; // Pointer to the GARD Records in PNOR - // The Deconfigure Records DeconfigureRecords_t iv_deconfigureRecords; + // pointer to plat specific data + // platform functions can malloc space here if needed; + // deconfigGard dtor will free() + void *iv_platDeconfigGard; + }; // DeconfigGard HWAS_DECLARE_SINGLETON(HWAS::DeconfigGard,theDeconfigGardSingleton); -// The HWAS Common code needs to allow for the fact that the platforms -// may need to know when the DeconfigGard functions are done using the -// PNOR area for GARD record access. To this end, GardAddress is an -// object that the common code will create when it needs to use the -// address to the GARD records data (iv_pGardRecords). When this object -// goes out of scope, the destructor will get called, and the platform -// code will know that access to the PNOR area is complete. -class GardAddress -{ -public: - - /** - * @brief Constructor. - * PLATFORM must implement this function - * - * @param[in] o_errl errlHndl_t set if there was an error - */ - GardAddress(errlHndl_t &o_errl); - - /** - * @brief Destructor. - * PLATFORM must implement this function - */ - ~GardAddress(); - - /** - * @brief flush. flush all of the waiting addresses out - * - */ - void flush(); - - /** - * @brief writeRecord. Add the indicated address to a vector, so - * that the destructor knows which GARD records were updated. - * - * @param[in] i_addr address of GARD record that was updated. - */ - void writeRecord(void *i_addr) - { - if (i_addr !=NULL) - { - iv_addr.push_back(i_addr); - } - } - -protected: - - std::vector<void *>iv_addr; - -}; // GardAddress } #endif diff --git a/src/include/usr/hwas/hwasPlatDeconfigGard.H b/src/include/usr/hwas/hwasPlatDeconfigGard.H index 2f229c164..098e2c08b 100644 --- a/src/include/usr/hwas/hwasPlatDeconfigGard.H +++ b/src/include/usr/hwas/hwasPlatDeconfigGard.H @@ -53,5 +53,17 @@ #define HWAS_GET_SINGLETON(__TYPE__) \ __TYPE__::instance() +namespace HWAS +{ + +struct HBDeconfigGard +{ + // GARD Record Data + uint32_t iv_nextGardRecordId; // Next GARD Record ID to use + uint32_t iv_maxGardRecords; // Maximum number of GARD Records + void *iv_pGardRecords; // Pointer to the GARD Records in PNOR +}; + +} // namespace HWAS #endif // HWASPLATDECONFIGGARD_H_ diff --git a/src/usr/errl/test/errltest.H b/src/usr/errl/test/errltest.H index 07a453e9e..708c46084 100644 --- a/src/usr/errl/test/errltest.H +++ b/src/usr/errl/test/errltest.H @@ -344,27 +344,27 @@ public: #else do { - // find some cores that we can play with + // find some ex units that we can play with TARGETING::Target * pSys; TARGETING::targetService().getTopLevelTarget(pSys); - TARGETING::PredicateCTM predCore(TARGETING::CLASS_UNIT, - TARGETING::TYPE_CORE); + TARGETING::PredicateCTM predEx(TARGETING::CLASS_UNIT, + TARGETING::TYPE_EX); TARGETING::PredicateHwas predFunctional; predFunctional.poweredOn(true).present(true).functional(true); TARGETING::PredicatePostfixExpr checkExpr; - checkExpr.push(&predCore).push(&predFunctional).And(); - TARGETING::TargetHandleList pCoreList; - TARGETING::targetService().getAssociated( pCoreList, pSys, + checkExpr.push(&predEx).push(&predFunctional).And(); + TARGETING::TargetHandleList pExList; + TARGETING::targetService().getAssociated( pExList, pSys, TARGETING::TargetService::CHILD, TARGETING::TargetService::ALL, &checkExpr ); - if (pCoreList.empty()) + if (pExList.empty()) { - TS_FAIL("testErrl3: empty pCoreList"); + TS_FAIL("testErrl3: empty pExList"); break; } - TARGETING::TargetHandle_t pTarget = *pCoreList.begin(); + TARGETING::TargetHandle_t pTarget = *pExList.begin(); errlHndl_t gard_errl = NULL; HWAS::DeconfigGard::DeconfigureRecords_t l_deconfigRecords; @@ -389,7 +389,7 @@ public: } gard_errl = HWAS::theDeconfigGard().getGardRecords( - HWAS::DeconfigGard::GET_ALL_GARD_RECORDS, l_gardRecords); + NULL, l_gardRecords); if (gard_errl) { TS_FAIL("testErrl3: Error from getGardRecords"); @@ -441,11 +441,11 @@ public: HWAS::EPUB_PRC_MEMORY_PLUGGING_ERROR, HWAS::SRCI_PRIORITY_HIGH); - if (pCoreList.size() > 1) + if (pExList.size() > 1) { errl->addBusCallout( - pCoreList[0], - pCoreList[1], + pExList[0], + pExList[1], HWAS::A_BUS_TYPE, HWAS::SRCI_PRIORITY_LOW); } @@ -454,7 +454,7 @@ public: // confirm there are the correct number of deconfig and gard records gard_errl = HWAS::theDeconfigGard().getGardRecords( - HWAS::DeconfigGard::GET_ALL_GARD_RECORDS, l_gardRecords); + NULL, l_gardRecords); if (gard_errl) { TS_FAIL("testCallout: Error from getGardRecords"); @@ -481,7 +481,7 @@ public: // delete these deconfigure and gard records HWAS::theDeconfigGard().clearDeconfigureRecords(NULL); - gard_errl = HWAS::theDeconfigGard().clearGardRecords(0); + gard_errl = HWAS::theDeconfigGard().clearGardRecords(NULL); if (gard_errl) { errlCommit(gard_errl,HWAS_COMP_ID); @@ -513,13 +513,29 @@ public: #else do { - // find a proc target - TARGETING::PredicateCTM procChipFilter( - TARGETING::CLASS_CHIP, TARGETING::TYPE_PROC); - TARGETING::TargetRangeFilter pProc( - TARGETING::targetService().begin(), - TARGETING::targetService().end(), - &procChipFilter); + // find a ex unit that we can play with + TARGETING::Target * pSys; + TARGETING::targetService().getTopLevelTarget(pSys); + + TARGETING::PredicateCTM predEx(TARGETING::CLASS_UNIT, + TARGETING::TYPE_EX); + TARGETING::PredicateHwas predFunctional; + predFunctional.poweredOn(true).present(true).functional(true); + TARGETING::PredicatePostfixExpr checkExpr; + checkExpr.push(&predEx).push(&predFunctional).And(); + + TARGETING::TargetHandleList pExList; + TARGETING::targetService().getAssociated( pExList, pSys, + TARGETING::TargetService::CHILD, TARGETING::TargetService::ALL, + &checkExpr ); + + if (pExList.empty()) + { + TS_FAIL("test callout: empty pExList"); + break; + } + + TARGETING::TargetHandle_t l_target = *pExList.begin(); TARGETING::PredicateCTM l_L4s(TARGETING::CLASS_UNIT, TARGETING::TYPE_L4); @@ -535,11 +551,9 @@ public: ERRL_TEST_MOD_ID, ERRL_TEST_REASON_CODE); - printk("\n\nelog = 0x%X\n\n", errl->eid() ); - // test the different callout types - TS_TRACE( "test callout pProc %p", *pProc); - ERRORLOG::ErrlUserDetailsTarget(*pProc).addToLog(errl); + TS_TRACE( "test callout pEx %p", l_target); + ERRORLOG::ErrlUserDetailsTarget(l_target).addToLog(errl); errl->addHwCallout(*pL4, HWAS::SRCI_PRIORITY_HIGH, @@ -548,7 +562,7 @@ public: // make this one high too - should end up with B120 src // as the first high priority callout is mem subsys - errl->addHwCallout( *pProc, + errl->addHwCallout( l_target, HWAS::SRCI_PRIORITY_HIGH, HWAS::DECONFIG, HWAS::GARD_NULL); @@ -585,13 +599,29 @@ public: #else do { - // find a proc target - TARGETING::PredicateCTM procChipFilter( - TARGETING::CLASS_CHIP, TARGETING::TYPE_PROC); - TARGETING::TargetRangeFilter pProc( - TARGETING::targetService().begin(), - TARGETING::targetService().end(), - &procChipFilter); + // find a ex unit that we can play with + TARGETING::Target * pSys; + TARGETING::targetService().getTopLevelTarget(pSys); + + TARGETING::PredicateCTM predEx(TARGETING::CLASS_UNIT, + TARGETING::TYPE_EX); + TARGETING::PredicateHwas predFunctional; + predFunctional.poweredOn(true).present(true).functional(true); + TARGETING::PredicatePostfixExpr checkExpr; + checkExpr.push(&predEx).push(&predFunctional).And(); + + TARGETING::TargetHandleList pExList; + TARGETING::targetService().getAssociated( pExList, pSys, + TARGETING::TargetService::CHILD, TARGETING::TargetService::ALL, + &checkExpr ); + + if (pExList.empty()) + { + TS_FAIL("test callout: empty pExList"); + break; + } + + TARGETING::TargetHandle_t l_target = *pExList.begin(); // find a membuf target TARGETING::PredicateCTM membufChipFilter( @@ -608,8 +638,8 @@ public: ERRL_TEST_REASON_CODE); // test the different callout types - TS_TRACE( "test callout pProc %p", *pProc); - ERRORLOG::ErrlUserDetailsTarget(*pProc).addToLog(errl); + TS_TRACE( "test callout pEx %p", l_target); + ERRORLOG::ErrlUserDetailsTarget(l_target).addToLog(errl); errl->addHwCallout(*pMembuf, HWAS::SRCI_PRIORITY_HIGH, diff --git a/src/usr/errl/test/errluserdetailtest.H b/src/usr/errl/test/errluserdetailtest.H index 3fdf714d0..92b65578e 100644 --- a/src/usr/errl/test/errluserdetailtest.H +++ b/src/usr/errl/test/errluserdetailtest.H @@ -490,7 +490,7 @@ public: } gard_errl = HWAS::theDeconfigGard().getGardRecords( - HWAS::DeconfigGard::GET_ALL_GARD_RECORDS, l_gardRecords); + NULL, l_gardRecords); if (gard_errl) { TS_FAIL("testCallout: Error from getGardRecords"); @@ -540,25 +540,25 @@ public: HWAS::DELAYED_DECONFIG, HWAS::GARD_NULL).addToLog(errl); - // find some cores that we can play with + // find some ex units that we can play with Target * pSys; targetService().getTopLevelTarget(pSys); - PredicateCTM predCore(CLASS_UNIT, TYPE_CORE); + PredicateCTM predEx(CLASS_UNIT, TYPE_EX); PredicateHwas predFunctional; predFunctional.poweredOn(true).present(true).functional(true); PredicatePostfixExpr checkExpr; - checkExpr.push(&predCore).push(&predFunctional).And(); - TargetHandleList pCoreList; - targetService().getAssociated( pCoreList, pSys, + checkExpr.push(&predEx).push(&predFunctional).And(); + TargetHandleList pExList; + targetService().getAssociated( pExList, pSys, TargetService::CHILD, TargetService::ALL, &checkExpr ); - if (pCoreList.empty()) + if (pExList.empty()) { - TS_FAIL("testCallout: empty pCoreList"); + TS_FAIL("testCallout: empty pExList"); break; } - TargetHandle_t l_pTarget = *pCoreList.begin(); + TargetHandle_t l_pTarget = *pExList.begin(); TARGETING::EntityPath ep; ep = l_pTarget->getAttr<TARGETING::ATTR_PHYS_PATH>(); @@ -580,10 +580,10 @@ public: HWAS::EPUB_PRC_FSI_PATH, HWAS::SRCI_PRIORITY_HIGH).addToLog(errl); - if (pCoreList.size() > 1) + if (pExList.size() > 1) { TARGETING::EntityPath ep2; - ep2 = pCoreList[1]->getAttr<TARGETING::ATTR_PHYS_PATH>(); + ep2 = pExList[1]->getAttr<TARGETING::ATTR_PHYS_PATH>(); // size is total EntityPath size minus unused path elements uint32_t ep2_size = sizeof(ep2) - (TARGETING::EntityPath::MAX_PATH_ELEMENTS - ep2.size()) * @@ -604,7 +604,7 @@ public: #if 0 // GARD records are created asynchronously, so can't really test this // confirm there are the correct number of deconfig and gard records gard_errl = HWAS::theDeconfigGard().getGardRecords( - HWAS::DeconfigGard::GET_ALL_GARD_RECORDS, l_gardRecords); + NULL, l_gardRecords); if (gard_errl) { TS_FAIL("testCallout: Error from getGardRecords"); @@ -632,7 +632,7 @@ public: // delete these deconfigure and gard records HWAS::theDeconfigGard().clearDeconfigureRecords(NULL); - gard_errl = HWAS::theDeconfigGard().clearGardRecords(0); + gard_errl = HWAS::theDeconfigGard().clearGardRecords(NULL); if (gard_errl) { errlCommit(gard_errl,HWAS_COMP_ID); diff --git a/src/usr/hwas/common/deconfigGard.C b/src/usr/hwas/common/deconfigGard.C index e2a21bf9b..f271237e6 100644 --- a/src/usr/hwas/common/deconfigGard.C +++ b/src/usr/hwas/common/deconfigGard.C @@ -78,7 +78,6 @@ errlHndl_t collectGard(const PredicateBase *i_pPredicate) do { - errl = theDeconfigGard().clearGardRecordsForReplacedTargets(); if (errl) { @@ -121,10 +120,8 @@ DeconfigGard & theDeconfigGard() } //****************************************************************************** -DeconfigGard::DeconfigGard() -: iv_nextGardRecordId(0), - iv_maxGardRecords(0), - iv_pGardRecords(NULL) +DeconfigGard::DeconfigGard() : + iv_platDeconfigGard(NULL) { HWAS_INF("DeconfigGard Constructor"); HWAS_MUTEX_INIT(iv_mutex); @@ -135,6 +132,7 @@ DeconfigGard::~DeconfigGard() { HWAS_INF("DeconfigGard Destructor"); HWAS_MUTEX_DESTROY(iv_mutex); + free(iv_platDeconfigGard); } //****************************************************************************** @@ -147,35 +145,36 @@ errlHndl_t DeconfigGard::clearGardRecordsForReplacedTargets() PredicateHwasChanged l_predicateHwasChanged; l_predicateHwasChanged.changedBit(HWAS_CHANGED_BIT_GARD, true); - HWAS_MUTEX_LOCK(iv_mutex); do { - GardAddress l_GardAddress(l_pErr); + GardRecords_t l_gardRecords; + + l_pErr = platGetGardRecords(NULL, l_gardRecords); if (l_pErr) { - HWAS_ERR("Error from l_GardAddress"); + HWAS_ERR("Error 0x%X from platGetGardRecords", l_pErr->plid()); break; } // For each GARD Record - for (uint32_t i = 0; i < iv_maxGardRecords; i++) + for (GardRecordsCItr_t l_itr = l_gardRecords.begin(); + l_itr != l_gardRecords.end(); + ++l_itr) { - if (iv_pGardRecords[i].iv_recordId == EMPTY_GARD_RECORDID) - { - // if this isn't a valid/filled GARD record, skip - continue; - } + GardRecord l_gardRecord = *l_itr; // Find the associated Target Target* l_pTarget = targetService(). - toTarget(iv_pGardRecords[i].iv_targetId); + toTarget(l_gardRecord.iv_targetId); if (l_pTarget == NULL) { // could be a platform specific target for the other // ie, we are hostboot and this is an FSP target, or vice-versa - DG_INF_TARGET("Could not find Target for", - &(iv_pGardRecords[i].iv_targetId)); + HWAS_INF("Could not find Target for %.8X", + get_huid(l_pTarget)); + + // we just skip this GARD record continue; } @@ -190,20 +189,22 @@ errlHndl_t DeconfigGard::clearGardRecordsForReplacedTargets() // Clear the gard record HWAS_INF("clearing GARD for %.8X, recordId %d", get_huid(l_pTarget), - iv_pGardRecords[i].iv_recordId); - iv_pGardRecords[i].iv_recordId = EMPTY_GARD_RECORDID; - l_GardAddress.writeRecord(&iv_pGardRecords[i]); - l_GardAddress.flush(); + l_gardRecord.iv_recordId); - // now clear our 'changed' bit - clear_hwas_changed_bit( - l_pTarget,HWAS_CHANGED_BIT_GARD); + l_pErr = platClearGardRecords(l_pTarget); + if (l_pErr) + { + HWAS_ERR("Error 0x%X from platClearGardRecords", + l_pErr->plid()); + break; + } + // now clear our 'changed' bit + clear_hwas_changed_bit(l_pTarget,HWAS_CHANGED_BIT_GARD); } // for } while (0); - HWAS_MUTEX_UNLOCK(iv_mutex); return l_pErr; } @@ -215,12 +216,6 @@ errlHndl_t DeconfigGard::deconfigureTargetsFromGardRecordsForIpl( errlHndl_t l_pErr = NULL; GardRecords_t l_gardRecords; - // TODO If deconfiguring all Targets with a GARD Record will result in a - // configuration that cannot IPL then need to figure out which - // subset of Targets to deconfigure to give the best chance of IPL - // This is known as Resource Recovery - - HWAS_MUTEX_LOCK(iv_mutex); do { Target* pSys; @@ -239,10 +234,10 @@ errlHndl_t DeconfigGard::deconfigureTargetsFromGardRecordsForIpl( } // Get all GARD Records - l_pErr = _getGardRecords(GET_ALL_GARD_RECORDS, l_gardRecords); + l_pErr = platGetGardRecords(NULL, l_gardRecords); if (l_pErr) { - HWAS_ERR("Error from _getGardRecords"); + HWAS_ERR("Error 0x%X from platGetGardRecords", l_pErr->plid()); break; } @@ -312,6 +307,9 @@ errlHndl_t DeconfigGard::deconfigureTargetsFromGardRecordsForIpl( (l_gardRecord.iv_errorType == GARD_User_Manual) ? DECONFIGURED_BY_MANUAL_GARD : l_gardRecord.iv_errlogPlid; + // all ok - do the work + HWAS_MUTEX_LOCK(iv_mutex); + // Deconfigure the Target // don't need to check ATTR_DECONFIG_GARDABLE -- if we get // here, it's because of a gard record on this target @@ -319,6 +317,8 @@ errlHndl_t DeconfigGard::deconfigureTargetsFromGardRecordsForIpl( // Deconfigure other Targets by association _deconfigureByAssoc(*l_pTarget, l_errlogPlid); + + HWAS_MUTEX_UNLOCK(iv_mutex); } // for // check and see if we still have enough hardware to continue @@ -331,15 +331,13 @@ errlHndl_t DeconfigGard::deconfigureTargetsFromGardRecordsForIpl( } while (0); - HWAS_MUTEX_UNLOCK(iv_mutex); return l_pErr; } -bool compareTargetHuid(TARGETING::TargetHandle_t t1, - TARGETING::TargetHandle_t t2) +bool compareTargetHuid(TargetHandle_t t1, TargetHandle_t t2) { - return (t1->getAttr<TARGETING::ATTR_HUID>() < - t2->getAttr<TARGETING::ATTR_HUID>()); + return (t1->getAttr<ATTR_HUID>() < + t2->getAttr<ATTR_HUID>()); } //****************************************************************************** @@ -352,19 +350,17 @@ errlHndl_t DeconfigGard::processFieldCoreOverride() { // otherwise, process and reduce cores. // find all functional NODE targets - TARGETING::Target* pSys; - TARGETING::targetService().getTopLevelTarget(pSys); - TARGETING::PredicateCTM predNode(TARGETING::CLASS_ENC, - TARGETING::TYPE_NODE); - TARGETING::PredicateHwas predFunctional; + Target* pSys; + targetService().getTopLevelTarget(pSys); + PredicateCTM predNode(CLASS_ENC, TYPE_NODE); + PredicateHwas predFunctional; predFunctional.functional(true); - TARGETING::PredicatePostfixExpr nodeCheckExpr; + PredicatePostfixExpr nodeCheckExpr; nodeCheckExpr.push(&predNode).push(&predFunctional).And(); - TARGETING::TargetHandleList pNodeList; - TARGETING::targetService().getAssociated(pNodeList, pSys, - TARGETING::TargetService::CHILD, - TARGETING::TargetService::ALL, + TargetHandleList pNodeList; + targetService().getAssociated(pNodeList, pSys, + TargetService::CHILD, TargetService::ALL, &nodeCheckExpr); // sort the list by ATTR_HUID to ensure that we @@ -373,13 +369,13 @@ errlHndl_t DeconfigGard::processFieldCoreOverride() compareTargetHuid); // for each of the nodes - for (TARGETING::TargetHandleList::const_iterator + for (TargetHandleList::const_iterator pNode_it = pNodeList.begin(); pNode_it != pNodeList.end(); ++pNode_it ) { - const TARGETING::TargetHandle_t pNode = *pNode_it; + const TargetHandle_t pNode = *pNode_it; // Get FCO value uint32_t l_fco = 0; @@ -394,18 +390,17 @@ errlHndl_t DeconfigGard::processFieldCoreOverride() if (l_fco == 0) { HWAS_INF("FCO: node %.8X: no overrides, done.", - TARGETING::get_huid(pNode)); + get_huid(pNode)); continue; // next node } HWAS_INF("FCO: node %.8X: value %d", - TARGETING::get_huid(pNode), l_fco); + get_huid(pNode), l_fco); // find all functional child PROC targets - TARGETING::TargetHandleList pProcList; - TARGETING::getChildAffinityTargets(pProcList, pNode, - TARGETING::CLASS_CHIP, TARGETING::TYPE_PROC, - true); + TargetHandleList pProcList; + getChildAffinityTargets(pProcList, pNode, + CLASS_CHIP, TYPE_PROC, true); // sort the list by ATTR_HUID to ensure that we // start at the same place each time @@ -415,18 +410,18 @@ errlHndl_t DeconfigGard::processFieldCoreOverride() // create list for restrictEXunits() function procRestrict_t l_procEntry; std::vector <procRestrict_t> l_procRestrictList; - for (TARGETING::TargetHandleList::const_iterator + for (TargetHandleList::const_iterator pProc_it = pProcList.begin(); pProc_it != pProcList.end(); ++pProc_it ) { - const TARGETING::TargetHandle_t pProc = *pProc_it; + const TargetHandle_t pProc = *pProc_it; // save info so that we can // restrict the number of EX units HWAS_INF("pProc %.8X - pushing to proclist", - TARGETING::get_huid(pProc)); + get_huid(pProc)); l_procEntry.target = pProc; l_procEntry.group = 0; l_procEntry.procs = pProcList.size(); @@ -453,6 +448,105 @@ errlHndl_t DeconfigGard::processFieldCoreOverride() } //****************************************************************************** +errlHndl_t DeconfigGard::createGardRecord(const Target * const i_pTarget, + const uint32_t i_errlPlid, + const GARD_ErrorType i_errorType) +{ + errlHndl_t l_pErr = NULL; + + do + { + const uint8_t lDeconfigGardable = + i_pTarget->getAttr<ATTR_DECONFIG_GARDABLE>(); + const uint8_t lPresent = + i_pTarget->getAttr<ATTR_HWAS_STATE>().present; + if (!lDeconfigGardable || !lPresent) + { + // Target is not GARDable. Commit an error + HWAS_ERR("Target not GARDable"); + + /*@ + * @errortype + * @moduleid HWAS::MOD_DECONFIG_GARD + * @reasoncode HWAS::RC_TARGET_NOT_GARDABLE + * @devdesc Attempt to create a GARD Record for a target that + * is not GARDable + * (not DECONFIG_GARDABLE or not present) + * @userdata1 HUID of input target // GARD errlog PLID + * @userdata2 ATTR_DECONFIG_GARDABLE // ATTR_HWAS_STATE.present + */ + const uint64_t userdata1 = + (static_cast<uint64_t>(get_huid(i_pTarget)) << 32) | + i_errlPlid; + const uint64_t userdata2 = + (static_cast<uint64_t>(lDeconfigGardable) << 32) | lPresent; + l_pErr = hwasError( + ERRL_SEV_UNRECOVERABLE, + HWAS::MOD_DECONFIG_GARD, + HWAS::RC_TARGET_NOT_GARDABLE, + userdata1, + userdata2); + break; + } + + Target* pSys; + targetService().getTopLevelTarget(pSys); + HWAS_ASSERT(pSys, "HWAS createGardRecord: no TopLevelTarget"); + + // check for system CDM Policy + const ATTR_CDM_POLICIES_type l_sys_policy = + pSys->getAttr<ATTR_CDM_POLICIES>(); + if (l_sys_policy & CDM_POLICIES_MANUFACTURING_DISABLED) + { + // manufacturing records are disabled + // - don't process + HWAS_INF("Manufacturing policy: disabled - skipping GARD Record create"); + break; + } + + if ((l_sys_policy & CDM_POLICIES_PREDICTIVE_DISABLED) && + (i_errorType == GARD_Predictive)) + { + // predictive records are disabled AND gard record is predictive + // - don't process + HWAS_INF("Predictive policy: disabled - skipping GARD Record create"); + break; + } + + if ((l_sys_policy & CDM_POLICIES_FUNCTIONAL_DISABLED) && + (i_errorType == GARD_Func)) + { + // functional records are disabled AND gard record is Functional + // - don't process + HWAS_INF("Functional policy: disabled - skipping GARD Record create"); + break; + } + + l_pErr = platCreateGardRecord(i_pTarget, i_errlPlid, i_errorType); + } + while (0); + + return l_pErr; +} + +//****************************************************************************** +errlHndl_t DeconfigGard::clearGardRecords( + const Target * const i_pTarget) +{ + errlHndl_t l_pErr = platClearGardRecords(i_pTarget); + return l_pErr; +} + +//****************************************************************************** +errlHndl_t DeconfigGard::getGardRecords( + const Target * const i_pTarget, + GardRecords_t & o_records) +{ + errlHndl_t l_pErr = platGetGardRecords(i_pTarget, o_records); + return l_pErr; +} + +//****************************************************************************** errlHndl_t DeconfigGard::deconfigureTarget(Target & i_target, const uint32_t i_errlPlid, bool i_evenAtRunTime) @@ -543,27 +637,15 @@ void DeconfigGard::registerDeferredDeconfigure( } //****************************************************************************** -errlHndl_t DeconfigGard::createGardRecord(const Target & i_target, - const uint32_t i_errlPlid, - const GARD_ErrorType i_errorType) -{ - HWAS_INF("Create GARD Record"); - HWAS_MUTEX_LOCK(iv_mutex); - errlHndl_t l_pErr = _createGardRecord(i_target, i_errlPlid, i_errorType); - HWAS_MUTEX_UNLOCK(iv_mutex); - return l_pErr; -} - -//****************************************************************************** errlHndl_t DeconfigGard::_getDeconfigureRecords( - const Target * i_pTarget, + const Target * const i_pTarget, DeconfigureRecords_t & o_records) { HWAS_INF("Get Deconfigure Record(s)"); - HWAS_MUTEX_LOCK(iv_mutex); + o_records.clear(); + HWAS_MUTEX_LOCK(iv_mutex); DeconfigureRecordsCItr_t l_itr = iv_deconfigureRecords.begin(); - o_records.clear(); if (i_pTarget == NULL) { @@ -603,50 +685,6 @@ errlHndl_t DeconfigGard::_getDeconfigureRecords( //****************************************************************************** -errlHndl_t DeconfigGard::clearGardRecords(const uint32_t i_recordId) -{ - HWAS_INF("Clear GARD Record(s) by Record ID"); - HWAS_MUTEX_LOCK(iv_mutex); - errlHndl_t l_pErr = _clearGardRecords(i_recordId); - HWAS_MUTEX_UNLOCK(iv_mutex); - return l_pErr; -} - -//****************************************************************************** -errlHndl_t DeconfigGard::clearGardRecords( - const EntityPath & i_targetId) -{ - HWAS_INF("Clear GARD Record(s) by Target ID"); - HWAS_MUTEX_LOCK(iv_mutex); - errlHndl_t l_pErr = _clearGardRecords(i_targetId); - HWAS_MUTEX_UNLOCK(iv_mutex); - return l_pErr; -} - -//****************************************************************************** -errlHndl_t DeconfigGard::getGardRecords( - const uint32_t i_recordId, - GardRecords_t & o_records) -{ - HWAS_INF("Get GARD Record(s) by Record ID"); - HWAS_MUTEX_LOCK(iv_mutex); - errlHndl_t l_pErr = _getGardRecords(i_recordId, o_records); - HWAS_MUTEX_UNLOCK(iv_mutex); - return l_pErr; -} - -//****************************************************************************** -errlHndl_t DeconfigGard::getGardRecords( - const EntityPath & i_targetId, - GardRecords_t & o_records) -{ - HWAS_INF("Get GARD Record(s) by Target ID"); - HWAS_MUTEX_LOCK(iv_mutex); - errlHndl_t l_pErr = _getGardRecords(i_targetId, o_records); - HWAS_MUTEX_UNLOCK(iv_mutex); - return l_pErr; -} - /** * @brief simple helper fn to find and return the list of MCS targets * that are in the same MSS_MEM_MC_IN_GROUP as the input. @@ -1087,7 +1125,7 @@ void DeconfigGard::_createDeconfigureRecord( //****************************************************************************** void DeconfigGard::clearDeconfigureRecords( - const TARGETING::Target * i_pTarget) + const Target * const i_pTarget) { if (i_pTarget == NULL) { @@ -1155,348 +1193,4 @@ bool DeconfigGard::_processDeferredDeconfig() return rc; } // _processDeferredDeconfig -//****************************************************************************** -errlHndl_t DeconfigGard::_createGardRecord(const Target & i_target, - const uint32_t i_errlPlid, - const GARD_ErrorType i_errorType) -{ - HWAS_INF("Creating GARD Record for %.8X", - get_huid(&i_target)); - errlHndl_t l_pErr = NULL; - - do - { - const ATTR_DECONFIG_GARDABLE_type lDeconfigGardable = - i_target.getAttr<ATTR_DECONFIG_GARDABLE>(); - const uint8_t lPresent = - i_target.getAttr<ATTR_HWAS_STATE>().present; - if (!lDeconfigGardable || !lPresent) - { - // Target is not GARDable. Commit an error - HWAS_ERR("Target not GARDable"); - - /*@ - * @errortype - * @moduleid HWAS::MOD_DECONFIG_GARD - * @reasoncode HWAS::RC_TARGET_NOT_GARDABLE - * @devdesc Attempt to create a GARD Record for a target that - * is not GARDable - * (not DECONFIG_GARDABLE or not present) - * @userdata1 HUID of input target // GARD errlog PLID - * @userdata2 ATTR_DECONFIG_GARDABLE // ATTR_HWAS_STATE.present - */ - const uint64_t userdata1 = - (static_cast<uint64_t>(get_huid(&i_target)) << 32) | - i_errlPlid; - const uint64_t userdata2 = - (static_cast<uint64_t>(lDeconfigGardable) << 32) | lPresent; - l_pErr = hwasError( - ERRL_SEV_UNRECOVERABLE, - HWAS::MOD_DECONFIG_GARD, - HWAS::RC_TARGET_NOT_GARDABLE, - userdata1, - userdata2); - break; - } - - Target* pSys; - targetService().getTopLevelTarget(pSys); - HWAS_ASSERT(pSys, "HWAS _createGardRecord: no TopLevelTarget"); - - // check for system CDM Policy - const ATTR_CDM_POLICIES_type l_sys_policy = - pSys->getAttr<ATTR_CDM_POLICIES>(); - if (l_sys_policy & CDM_POLICIES_MANUFACTURING_DISABLED) - { - // manufacturing records are disabled - // - don't process - HWAS_INF("Manufacturing policy: disabled - skipping GARD Record"); - break; - } - - if ((l_sys_policy & CDM_POLICIES_PREDICTIVE_DISABLED) && - (i_errorType == GARD_Predictive)) - { - // predictive records are disabled AND gard record is predictive - // - don't process - HWAS_INF("Predictive policy: disabled - skipping GARD Record"); - break; - } - - if ((l_sys_policy & CDM_POLICIES_FUNCTIONAL_DISABLED) && - (i_errorType == GARD_Func)) - { - // functional records are disabled AND gard record is Functional - // - don't process - HWAS_INF("Functional policy: disabled - skipping GARD Record"); - break; - } - - GardAddress l_GardAddress(l_pErr); - if (l_pErr) - { - HWAS_ERR("Error from l_GardAddress"); - break; - } - - // Find an empty GARD Record slot - GardRecord * l_pRecord = NULL; - for (uint32_t i = 0; i < iv_maxGardRecords; i++) - { - if (iv_pGardRecords[i].iv_recordId == EMPTY_GARD_RECORDID) - { - l_pRecord = &(iv_pGardRecords[i]); - break; - } - } - - if (!l_pRecord) - { - HWAS_ERR("GARD Record Repository full"); - - /*@ - * @errortype - * @moduleid HWAS::MOD_DECONFIG_GARD - * @reasoncode HWAS::RC_GARD_REPOSITORY_FULL - * @devdesc Attempt to create a GARD Record and the GARD - * Repository is full - * @userdata1 HUID of input target // GARD errlog PLID - */ - const uint64_t userdata1 = - (static_cast<uint64_t> (get_huid(&i_target)) << 32) | - i_errlPlid; - l_pErr = hwasError( - ERRL_SEV_UNRECOVERABLE, - HWAS::MOD_DECONFIG_GARD, - HWAS::RC_GARD_REPOSITORY_FULL, - userdata1); - break; - } - - l_pRecord->iv_recordId = iv_nextGardRecordId++; - l_pRecord->iv_targetId = i_target.getAttr<ATTR_PHYS_PATH>(); - l_pRecord->iv_errlogPlid = i_errlPlid; - l_pRecord->iv_errorType = i_errorType; - l_pRecord->iv_ResourceRecovery = 0; //Finished by Story 35114 & 62392. - l_pRecord->iv_padding[0] = 0xff; - l_pRecord->iv_padding[1] = 0xff; - l_pRecord->iv_padding[2] = 0xff; - l_pRecord->iv_padding[3] = 0xff; - l_pRecord->iv_padding[4] = 0xff; - l_pRecord->iv_padding[5] = 0xff; - - l_GardAddress.writeRecord((void *)l_pRecord); - } - while (0); - - return l_pErr; -} - -//****************************************************************************** -errlHndl_t DeconfigGard::_clearGardRecords(const uint32_t i_recordId) -{ - errlHndl_t l_pErr = NULL; - - GardAddress l_GardAddress(l_pErr); - if (!l_pErr) - { - if (i_recordId == CLEAR_ALL_GARD_RECORDS) - { - HWAS_INF("Clearing all GARD Records"); - - // Only clear valid GARD Records to avoid excessive PNOR access - for (uint32_t i = 0; i < iv_maxGardRecords; i++) - { - if (iv_pGardRecords[i].iv_recordId != EMPTY_GARD_RECORDID) - { - // clear iv_recordId - iv_pGardRecords[i].iv_recordId = EMPTY_GARD_RECORDID; - l_GardAddress.writeRecord(&iv_pGardRecords[i]); - } - } - } - else - { - uint32_t i = 0; - for (; i < iv_maxGardRecords; i++) - { - if (iv_pGardRecords[i].iv_recordId == i_recordId) - { - HWAS_INF("Clearing GARD Record ID 0x%x", i_recordId); - // clear iv_recordId - iv_pGardRecords[i].iv_recordId = EMPTY_GARD_RECORDID; - l_GardAddress.writeRecord(&iv_pGardRecords[i]); - break; - } - } - - if (i == iv_maxGardRecords) - { - HWAS_INF("No GARD Record ID 0x%x to clear", i_recordId); - } - } - } - else - { - HWAS_ERR("Error from l_GardAddress"); - } - - return l_pErr; -} - -//****************************************************************************** -errlHndl_t DeconfigGard::_clearGardRecords( - const EntityPath & i_targetId) -{ - errlHndl_t l_pErr = NULL; - - GardAddress l_GardAddress(l_pErr); - if (!l_pErr) - { - bool l_gardRecordsCleared = false; - - for (uint32_t i = 0; i < iv_maxGardRecords; i++) - { - if ((iv_pGardRecords[i].iv_recordId != EMPTY_GARD_RECORDID) && - (iv_pGardRecords[i].iv_targetId == i_targetId) - ) - { - DG_INF_TARGET("Clearing GARD Record for: ", &i_targetId); - l_gardRecordsCleared = true; - // clear iv_recordId - iv_pGardRecords[i].iv_recordId = EMPTY_GARD_RECORDID; - l_GardAddress.writeRecord(&iv_pGardRecords[i]); - } - } - - if (!l_gardRecordsCleared) - { - DG_INF_TARGET("No GARD Records to clear for: ", &i_targetId); - } - } - else - { - HWAS_ERR("Error from l_GardAddress"); - } - - return l_pErr; -} - -//****************************************************************************** -errlHndl_t DeconfigGard::_getGardRecords(const uint32_t i_recordId, - GardRecords_t & o_records) -{ - errlHndl_t l_pErr = NULL; - o_records.clear(); - - GardAddress l_GardAddress(l_pErr); - if (!l_pErr) - { - if (i_recordId == GET_ALL_GARD_RECORDS) - { - HWAS_DBG("Getting all GARD Records"); - for (uint32_t i = 0; i < iv_maxGardRecords; i++) - { - if (iv_pGardRecords[i].iv_recordId != EMPTY_GARD_RECORDID) - { - HWAS_DBG("Getting GARD Record ID 0x%x", - iv_pGardRecords[i].iv_recordId); - o_records.push_back(iv_pGardRecords[i]); - } - } - } - else - { - for (uint32_t i = 0; i < iv_maxGardRecords; i++) - { - if (iv_pGardRecords[i].iv_recordId == i_recordId) - { - HWAS_DBG("Getting GARD Record ID 0x%x", i_recordId); - o_records.push_back(iv_pGardRecords[i]); - break; - } - } - } - HWAS_INF("%d GARD Records found", o_records.size()); - } - else - { - HWAS_ERR("Error from l_GardAddress"); - } - - return l_pErr; -} - -//****************************************************************************** -errlHndl_t DeconfigGard::_getGardRecords( - const EntityPath & i_targetId, - GardRecords_t & o_records) -{ - errlHndl_t l_pErr = NULL; - o_records.clear(); - - GardAddress l_GardAddress(l_pErr); - if (!l_pErr) - { - for (uint32_t i = 0; i < iv_maxGardRecords; i++) - { - if ((iv_pGardRecords[i].iv_recordId != EMPTY_GARD_RECORDID) && - (iv_pGardRecords[i].iv_targetId == i_targetId) - ) - { - DG_INF_TARGET("Getting GARD Record for: ", &i_targetId); - o_records.push_back(iv_pGardRecords[i]); - } - } - - if (o_records.empty()) - { - DG_INF_TARGET("No GARD Records to get for: ", &i_targetId); - } - } - else - { - HWAS_ERR("Error from l_GardAddress"); - } - - return l_pErr; -} - -//****************************************************************************** -void DeconfigGard::_GardRecordIdSetup(uint32_t i_size) -{ - if (iv_maxGardRecords == 0) - { - // hasn't been computed yet - HWAS_INF("GardRecordIdSetup(size=%d)", i_size); - - iv_maxGardRecords = i_size / sizeof(GardRecord); - - // Figure out the next GARD Record ID to use - uint32_t l_numGardRecords = 0; - for (uint32_t i = 0; i < iv_maxGardRecords; i++) - { - // if this gard record is already fill out: - if (iv_pGardRecords[i].iv_recordId != EMPTY_GARD_RECORDID) - { - // count how many gard records are already defined - l_numGardRecords++; - - // find the 'last' recordId, so that we can start after it - if (iv_pGardRecords[i].iv_recordId > iv_nextGardRecordId) - { - iv_nextGardRecordId = iv_pGardRecords[i].iv_recordId; - } - } - } // for - - // next record will start after the highest Id we found - iv_nextGardRecordId++; - - HWAS_INF("GARD setup. maxRecords %d nextID %d numRecords %d", - iv_maxGardRecords, iv_nextGardRecordId, l_numGardRecords); - } -} - - } // namespce HWAS diff --git a/src/usr/hwas/common/hwas.C b/src/usr/hwas/common/hwas.C index 7cd53f9e9..cf0bc6185 100644 --- a/src/usr/hwas/common/hwas.C +++ b/src/usr/hwas/common/hwas.C @@ -658,7 +658,7 @@ errlHndl_t checkMinimumHardware() // check for functional cores TargetHandleList l_cores; getAllChiplets(l_cores, TYPE_CORE, true ); - HWAS_DBG( "platCheckMinimumHardware: %d functional cores", + HWAS_DBG( "checkMinimumHardware: %d functional cores", l_cores.size() ); if ( l_cores.empty() ) { @@ -700,7 +700,7 @@ errlHndl_t checkMinimumHardware() // check here for functional dimms TargetHandleList l_dimms; getAllLogicalCards(l_dimms, TYPE_DIMM, true ); - HWAS_DBG( "platCheckMinimumHardware: %d functional dimms", + HWAS_DBG( "checkMinimumHardware: %d functional dimms", l_dimms.size() ); if ( l_dimms.empty() ) { diff --git a/src/usr/hwas/hwasPlat.C b/src/usr/hwas/hwasPlat.C index 2095277ec..21dd4a086 100644 --- a/src/usr/hwas/hwasPlat.C +++ b/src/usr/hwas/hwasPlat.C @@ -429,76 +429,6 @@ errlHndl_t hwasChangeDetection() return errl; } // hwasChangeDetection - -GardAddress::GardAddress(errlHndl_t &o_errl) -{ - DeconfigGard::GardRecord *l_addr = HWAS::theDeconfigGard().iv_pGardRecords; - HWAS_INF("GardAddress ctor: iv_pGardRecords %p", l_addr); - - do - { - // if this is the first time thru here, get the PNOR address. - if (l_addr == NULL) - { - PNOR::SectionInfo_t l_section; - o_errl = PNOR::getSectionInfo(PNOR::GUARD_DATA, PNOR::CURRENT_SIDE, - l_section); - if (o_errl) - { - HWAS_ERR("PNOR::getSectionInfo failed!!!"); - // no support for GARD in this configuration. - break; - } - - l_addr = reinterpret_cast<DeconfigGard::GardRecord *> - (l_section.vaddr); - HWAS_DBG("PNOR vaddr=%p size=%d", - l_section.vaddr, l_section.size); - - // tell the DeconfigGard what the address - HWAS::theDeconfigGard().iv_pGardRecords = l_addr; - - // and let him compute and save maxRecords and nextRecordId - HWAS::theDeconfigGard()._GardRecordIdSetup(l_section.size); - - HWAS_INF("GardAddress iv_pGardRecords=%p", l_addr); - } - } - while (0); -} - - -void GardAddress::flush() -{ - // flush PNOR iff we wrote - if (!iv_addr.empty()) - { - for (std::vector<void *>::const_iterator iter = iv_addr.begin(); - iter != iv_addr.end(); - ++iter) - { - HWAS_DBG("flushing GARD in PNOR: addr=%p", *iter); - int l_rc = mm_remove_pages(FLUSH, (void *) *iter, - sizeof(DeconfigGard::GardRecord)); - if (l_rc) - { - HWAS_ERR("mm_remove_pages(FLUSH,%p,%d) returned %d", - *iter, sizeof(DeconfigGard::GardRecord),l_rc); - } - } - - // all done - just get rid of them all - iv_addr.clear(); - } -} - - -GardAddress::~GardAddress() -{ - flush(); -} - - //****************************************************************************** // platCheckMinimumHardware() // Don't forget to add a procedure callout and update the common plid @@ -509,4 +439,5 @@ void platCheckMinimumHardware(uint32_t & io_plid) // nothing to do yet... } + } // namespace HWAS diff --git a/src/usr/hwas/hwasPlatCallout.C b/src/usr/hwas/hwasPlatCallout.C index a11b8081d..6a9127d7f 100644 --- a/src/usr/hwas/hwasPlatCallout.C +++ b/src/usr/hwas/hwasPlatCallout.C @@ -89,7 +89,7 @@ errlHndl_t platHandleHWCallout( } default: { - errl = HWAS::theDeconfigGard().createGardRecord(*i_pTarget, + errl = HWAS::theDeconfigGard().createGardRecord(i_pTarget, io_errl->plid(), i_gardErrorType); break; diff --git a/src/usr/hwas/hwasPlatDeconfigGard.C b/src/usr/hwas/hwasPlatDeconfigGard.C new file mode 100644 index 000000000..e8187743e --- /dev/null +++ b/src/usr/hwas/hwasPlatDeconfigGard.C @@ -0,0 +1,379 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/hwas/hwasPlatDeconfigGard.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 hwasPlatDeconfigGard.C + * + * @brief Platform specific deconfigGard functions + */ + +#include <hwas/common/hwas.H> +#include <hwas/common/hwas_reasoncodes.H> +#include <hwas/common/hwasCommon.H> +#include <hwas/common/hwasCallout.H> +#include <hwas/common/deconfigGard.H> +#include <hwas/hwasPlat.H> + +#include <devicefw/driverif.H> +#include <initservice/taskargs.H> +#include <vpd/mvpdenums.H> +#include <stdio.h> +#include <sys/mm.h> + +#include <pnor/pnorif.H> + +namespace HWAS +{ + +using namespace HWAS::COMMON; +using namespace TARGETING; + +void _flush(void *i_addr); +errlHndl_t _GardRecordIdSetup(void *&io_platDeconfigGard); + +errlHndl_t DeconfigGard::platClearGardRecords( + const Target * const i_pTarget) +{ + errlHndl_t l_pErr = NULL; + + EntityPath l_targetId; + if (i_pTarget) + { + HWAS_INF("Clear GARD Records for %.8X", get_huid(i_pTarget)); + l_targetId = i_pTarget->getAttr<ATTR_PHYS_PATH>(); + } + else + { + HWAS_INF("Clear all GARD Records"); + } + + HWAS_MUTEX_LOCK(iv_mutex); + l_pErr = _GardRecordIdSetup(iv_platDeconfigGard); + if (!l_pErr) + { + uint32_t l_gardRecordsCleared = 0; + HBDeconfigGard *l_hbDeconfigGard = + (HBDeconfigGard *)iv_platDeconfigGard; + DeconfigGard::GardRecord * l_pGardRecords = + (DeconfigGard::GardRecord *)l_hbDeconfigGard->iv_pGardRecords; + const uint32_t l_maxGardRecords = l_hbDeconfigGard->iv_maxGardRecords; + for (uint32_t i = 0; i < l_maxGardRecords; i++) + { + if (l_pGardRecords[i].iv_recordId != EMPTY_GARD_RECORDID) + { + // specific or all + if (i_pTarget) + { + // if we have a match + if (l_pGardRecords[i].iv_targetId == l_targetId) + { + HWAS_INF("Clearing GARD Record for %.8X", + get_huid(i_pTarget)); + l_pGardRecords[i].iv_recordId = EMPTY_GARD_RECORDID; + _flush(&l_pGardRecords[i]); + l_gardRecordsCleared++; + break; // done - can only be 1 GARD record per target + } + } + else // Clear all records + { + l_pGardRecords[i].iv_recordId = EMPTY_GARD_RECORDID; + _flush(&l_pGardRecords[i]); + l_gardRecordsCleared++; + } + } + } // for + + HWAS_INF("GARD Records to Cleared: %d", l_gardRecordsCleared); + } + else + { + HWAS_ERR("Error from _GardRecordIdSetup"); + } + + HWAS_MUTEX_UNLOCK(iv_mutex); + return l_pErr; +} + +errlHndl_t DeconfigGard::platGetGardRecords( + const Target * const i_pTarget, + GardRecords_t &o_records) +{ + errlHndl_t l_pErr = NULL; + o_records.clear(); + + EntityPath l_targetId; + if (i_pTarget) + { + HWAS_INF("Get GARD Record for %.8X", get_huid(i_pTarget)); + l_targetId = i_pTarget->getAttr<ATTR_PHYS_PATH>(); + } + else + { + HWAS_INF("Get all GARD Records"); + } + + HWAS_MUTEX_LOCK(iv_mutex); + l_pErr = _GardRecordIdSetup(iv_platDeconfigGard); + if (!l_pErr) + { + HBDeconfigGard *l_hbDeconfigGard = + (HBDeconfigGard *)iv_platDeconfigGard; + DeconfigGard::GardRecord * l_pGardRecords = + (DeconfigGard::GardRecord *)l_hbDeconfigGard->iv_pGardRecords; + const uint32_t l_maxGardRecords = l_hbDeconfigGard->iv_maxGardRecords; + for (uint32_t i = 0; i < l_maxGardRecords; i++) + { + if (l_pGardRecords[i].iv_recordId != EMPTY_GARD_RECORDID) + { + // specific or all + if (i_pTarget) + { + // if we have a match + if (l_pGardRecords[i].iv_targetId == l_targetId) + { + HWAS_INF("Getting GARD Record for %.8X", + get_huid(i_pTarget)); + o_records.push_back(l_pGardRecords[i]); + break; // done - can only be 1 GARD record per target + } + } + else // get all records + { + o_records.push_back(l_pGardRecords[i]); + } + } + } // for + } + else + { + HWAS_ERR("Error from _GardRecordIdSetup"); + } + + HWAS_MUTEX_UNLOCK(iv_mutex); + HWAS_INF("Get returning %d GARD Records", o_records.size()); + return l_pErr; +} + + +errlHndl_t DeconfigGard::platCreateGardRecord( + const Target * const i_pTarget, + const uint32_t i_errlPlid, + const GARD_ErrorType i_errorType) +{ + HWAS_INF("Creating GARD Record for %.8X, errl 0x%X", + get_huid(i_pTarget), i_errlPlid); + errlHndl_t l_pErr = NULL; + + HWAS_MUTEX_LOCK(iv_mutex); + + do + { + l_pErr = _GardRecordIdSetup(iv_platDeconfigGard); + if (l_pErr) + { + HWAS_ERR("Error from _GardRecordIdSetup"); + break; + } + + // Find an empty GARD Record slot + // AND check to make sure we don't have a GARD record already + EntityPath l_targetId = i_pTarget->getAttr<ATTR_PHYS_PATH>(); + GardRecord * l_pRecord = NULL; + bool l_duplicate = false; + HBDeconfigGard *l_hbDeconfigGard = + (HBDeconfigGard *)iv_platDeconfigGard; + DeconfigGard::GardRecord *l_pGardRecords = + (DeconfigGard::GardRecord *)l_hbDeconfigGard->iv_pGardRecords; + const uint32_t l_maxGardRecords = l_hbDeconfigGard->iv_maxGardRecords; + for (uint32_t i = 0; i < l_maxGardRecords; i++) + { + if (l_pGardRecords[i].iv_recordId == EMPTY_GARD_RECORDID) + { + if (!l_pRecord) + { + // save the first empty location we find + l_pRecord = &(l_pGardRecords[i]); + } + } + else + { + if (l_pGardRecords[i].iv_targetId == l_targetId) + { + l_duplicate = true; + l_pRecord = &(l_pGardRecords[i]); + HWAS_INF("Duplicate GARD Record from error 0x%X", + l_pGardRecords[i].iv_errlogPlid); + break; + } + } + } // for + + if (l_duplicate) + { + // there's already a GARD record for this target + + // if this GARD record was a manual gard - overwrite + // with this new one + if (l_pRecord->iv_errorType == GARD_User_Manual) + { + HWAS_INF("Duplicate is GARD_User_Manual - overwriting"); + l_pRecord->iv_errlogPlid = i_errlPlid; + l_pRecord->iv_errorType = i_errorType; + _flush((void *)l_pRecord); + } + + // either way, return success + break; + } + + if (!l_pRecord) + { + HWAS_ERR("GARD Record Repository full"); + + /*@ + * @errortype + * @moduleid HWAS::MOD_DECONFIG_GARD + * @reasoncode HWAS::RC_GARD_REPOSITORY_FULL + * @devdesc Attempt to create a GARD Record and the GARD + * Repository is full + * @userdata1 HUID of input target // GARD errlog PLID + */ + const uint64_t userdata1 = + (static_cast<uint64_t> (get_huid(i_pTarget)) << 32) | + i_errlPlid; + l_pErr = hwasError( + ERRL_SEV_UNRECOVERABLE, + HWAS::MOD_DECONFIG_GARD, + HWAS::RC_GARD_REPOSITORY_FULL, + userdata1); + break; + } + + l_pRecord->iv_recordId = l_hbDeconfigGard->iv_nextGardRecordId++; + l_pRecord->iv_targetId = l_targetId; + l_pRecord->iv_errlogPlid = i_errlPlid; + l_pRecord->iv_errorType = i_errorType; + l_pRecord->iv_padding[0] = 0; + l_pRecord->iv_padding[1] = 0; + l_pRecord->iv_padding[2] = 0; + l_pRecord->iv_padding[3] = 0; + l_pRecord->iv_padding[4] = 0; + l_pRecord->iv_padding[5] = 0; + + _flush((void *)l_pRecord); + } + while (0); + + HWAS_MUTEX_UNLOCK(iv_mutex); + return l_pErr; +} + + +//****************************************************************************** +errlHndl_t _GardRecordIdSetup( void *&io_platDeconfigGard) +{ + HWAS_DBG("_GardRecordIdSetup: io_platDeconfigGard %p", io_platDeconfigGard); + errlHndl_t l_pErr = NULL; + + do + { + // if this is NOT the first time thru here, we're done + if (io_platDeconfigGard != NULL) + { + break; + } + + // allocate our memory and set things up + io_platDeconfigGard = malloc(sizeof(HBDeconfigGard)); + HBDeconfigGard *l_hbDeconfigGard = + (HBDeconfigGard *)io_platDeconfigGard; + + // get the PNOR address. + PNOR::SectionInfo_t l_section; + l_pErr = PNOR::getSectionInfo(PNOR::GUARD_DATA, PNOR::CURRENT_SIDE, + l_section); + if (l_pErr) + { + HWAS_ERR("PNOR::getSectionInfo failed!!!"); + // no support for GARD in this configuration. + break; + } + + l_hbDeconfigGard->iv_pGardRecords = + reinterpret_cast<DeconfigGard::GardRecord *> (l_section.vaddr); + HWAS_DBG("PNOR vaddr=%p size=%d", l_section.vaddr, l_section.size); + + l_hbDeconfigGard->iv_maxGardRecords = l_section.size / + sizeof(DeconfigGard::GardRecord); + l_hbDeconfigGard->iv_nextGardRecordId = 0; + + // Figure out the next GARD Record ID to use + uint32_t l_numGardRecords = 0; + const uint32_t l_maxGardRecords = l_hbDeconfigGard->iv_maxGardRecords; + DeconfigGard::GardRecord *l_pGardRecords = + (DeconfigGard::GardRecord *)l_hbDeconfigGard->iv_pGardRecords; + for (uint32_t i = 0; i < l_maxGardRecords; i++) + { + // if this gard record is already filled out + if (l_pGardRecords[i].iv_recordId + != EMPTY_GARD_RECORDID) + { + // count how many gard records are already defined + l_numGardRecords++; + + // find the 'last' recordId, so that we can start after it + if (l_pGardRecords[i].iv_recordId > + l_hbDeconfigGard->iv_nextGardRecordId) + { + l_hbDeconfigGard->iv_nextGardRecordId = + l_pGardRecords[i].iv_recordId; + } + } + } // for + + // next record will start after the highest Id we found + l_hbDeconfigGard->iv_nextGardRecordId++; + + HWAS_INF("GARD setup. maxRecords %d nextID %d numRecords %d", + l_hbDeconfigGard->iv_maxGardRecords, + l_hbDeconfigGard->iv_nextGardRecordId, + l_numGardRecords); + } + while (0); + + return l_pErr; +} + +void _flush(void *i_addr) +{ + HWAS_DBG("flushing GARD in PNOR: addr=%p", i_addr); + int l_rc = mm_remove_pages(FLUSH, i_addr, + sizeof(DeconfigGard::GardRecord)); + if (l_rc) + { + HWAS_ERR("mm_remove_pages(FLUSH,%p,%d) returned %d", + i_addr, sizeof(DeconfigGard::GardRecord),l_rc); + } +} + +} // namespace HWAS diff --git a/src/usr/hwas/makefile b/src/usr/hwas/makefile index 047c0bd38..a37f7a8a9 100644 --- a/src/usr/hwas/makefile +++ b/src/usr/hwas/makefile @@ -34,7 +34,9 @@ MODULE = hwas OBJS = hwas.o hwasCallout.o deconfigGard.o # files in this directory -OBJS += hwasPlat.o hostbootIstep.o hwasPlatError.o hwasPlatCallout.o +OBJS += hwasPlat.o hostbootIstep.o \ + hwasPlatError.o hwasPlatCallout.o \ + hwasPlatDeconfigGard.o SUBDIRS = test.d diff --git a/src/usr/hwas/test/hwasGardTest.H b/src/usr/hwas/test/hwasGardTest.H index 433180840..6a217149f 100644 --- a/src/usr/hwas/test/hwasGardTest.H +++ b/src/usr/hwas/test/hwasGardTest.H @@ -76,25 +76,25 @@ public: break; } - // find a core that we can play with + // find a ex unit that we can play with Target * pSys; targetService().getTopLevelTarget(pSys); - PredicateCTM predCore(CLASS_UNIT, TYPE_CORE); + PredicateCTM predEx(CLASS_UNIT, TYPE_EX); PredicateHwas predFunctional; predFunctional.poweredOn(true).present(true).functional(true); PredicatePostfixExpr checkExpr; - checkExpr.push(&predCore).push(&predFunctional).And(); - TargetHandleList pCoreList; - targetService().getAssociated( pCoreList, pSys, + checkExpr.push(&predEx).push(&predFunctional).And(); + TargetHandleList pExList; + targetService().getAssociated( pExList, pSys, TargetService::CHILD, TargetService::ALL, &checkExpr ); - if (pCoreList.empty()) + if (pExList.empty()) { - TS_FAIL("testDeconfigure3a: empty pCoreList"); + TS_FAIL("testDeconfigure3a: empty pExList"); break; } - TargetHandle_t l_pTarget = *pCoreList.begin(); + TargetHandle_t l_pTarget = *pExList.begin(); // create a deconfigure record theDeconfigGard(). @@ -165,25 +165,25 @@ public: do { - // find a core that we can play with + // find a ex unit that we can play with Target * pSys; targetService().getTopLevelTarget(pSys); - PredicateCTM predCore(CLASS_UNIT, TYPE_CORE); + PredicateCTM predEx(CLASS_UNIT, TYPE_EX); PredicateHwas predFunctional; predFunctional.poweredOn(true).present(true).functional(true); PredicatePostfixExpr checkExpr; - checkExpr.push(&predCore).push(&predFunctional).And(); - TargetHandleList pCoreList; - targetService().getAssociated( pCoreList, pSys, + checkExpr.push(&predEx).push(&predFunctional).And(); + TargetHandleList pExList; + targetService().getAssociated( pExList, pSys, TargetService::CHILD, TargetService::ALL, &checkExpr ); - if (pCoreList.empty()) + if (pExList.empty()) { - TS_FAIL("testDeconfigure3: empty pCoreList"); + TS_FAIL("testDeconfigure3: empty pExList"); break; } - TargetHandle_t l_pTarget = *pCoreList.begin(); + TargetHandle_t l_pTarget = *pExList.begin(); // Get the original HWAS_STATE of the target HwasState l_origState = l_pTarget->getAttr<ATTR_HWAS_STATE>(); @@ -242,25 +242,25 @@ public: do { - // find a core that we can play with + // find a ex unit that we can play with Target * pSys; targetService().getTopLevelTarget(pSys); - PredicateCTM predCore(CLASS_UNIT, TYPE_CORE); + PredicateCTM predEx(CLASS_UNIT, TYPE_EX); PredicateHwas predFunctional; predFunctional.poweredOn(true).present(true).functional(true); PredicatePostfixExpr checkExpr; - checkExpr.push(&predCore).push(&predFunctional).And(); - TargetHandleList pCoreList; - targetService().getAssociated( pCoreList, pSys, + checkExpr.push(&predEx).push(&predFunctional).And(); + TargetHandleList pExList; + targetService().getAssociated( pExList, pSys, TargetService::CHILD, TargetService::ALL, &checkExpr ); - if (pCoreList.empty()) + if (pExList.empty()) { - TS_FAIL("testDeconfigure4: empty pCoreList"); + TS_FAIL("testDeconfigure4: empty pExList"); break; } - TargetHandle_t l_pTarget = *pCoreList.begin(); + TargetHandle_t l_pTarget = *pExList.begin(); // Get the current HWAS_STATE of the target HwasState l_origState = l_pTarget->getAttr<ATTR_HWAS_STATE>(); @@ -647,25 +647,25 @@ public: do { - // find a core that we can play with + // find a ex unit that we can play with Target * pSys; targetService().getTopLevelTarget(pSys); - PredicateCTM predCore(CLASS_UNIT, TYPE_CORE); + PredicateCTM predEx(CLASS_UNIT, TYPE_EX); PredicateHwas predFunctional; predFunctional.poweredOn(true).present(true).functional(true); PredicatePostfixExpr checkExpr; - checkExpr.push(&predCore).push(&predFunctional).And(); - TargetHandleList pCoreList; - targetService().getAssociated( pCoreList, pSys, + checkExpr.push(&predEx).push(&predFunctional).And(); + TargetHandleList pExList; + targetService().getAssociated( pExList, pSys, TargetService::CHILD, TargetService::ALL, &checkExpr ); - if (pCoreList.empty()) + if (pExList.empty()) { - TS_FAIL("testDefDeconfig1: empty pCoreList"); + TS_FAIL("testDefDeconfig1: empty pExList"); break; } - TargetHandle_t l_pTarget = *pCoreList.begin(); + TargetHandle_t l_pTarget = *pExList.begin(); // Get any existing Deconfigure Record for the target l_pErr = theDeconfigGard(). @@ -748,104 +748,21 @@ public: errlHndl_t l_pErr = NULL; DeconfigGard::GardRecords_t l_records; - l_pErr = theDeconfigGard().getGardRecords( - DeconfigGard::GET_ALL_GARD_RECORDS, l_records); + l_pErr = theDeconfigGard().getGardRecords(NULL, l_records); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); - TS_FAIL("testGard1: Error from getGardRecords"); + TS_FAIL("testGard1: Error from getGardRecords(NULL)"); } else { - TS_TRACE(INFO_MRK "testGard1: Success. %d records", + TS_TRACE(INFO_MRK "testGard1: get(NULL) Success. %d records", l_records.size()); } } /** - * @brief Test getting GARD Records with a bad record ID). - */ - void testGard2() - { - TS_TRACE(INFO_MRK "testGard2: Started"); - - errlHndl_t l_pErr = NULL; - DeconfigGard::GardRecords_t l_records; - - l_pErr = theDeconfigGard().getGardRecords(0x12345678, l_records); - - if (l_pErr) - { - errlCommit(l_pErr,HWAS_COMP_ID); - TS_FAIL("testGard2: Error from getGardRecords"); - } - else - { - if (l_records.size()) - { - TS_FAIL("testGard2: %d records found for bad ID", - l_records.size()); - } - else - { - TS_TRACE(INFO_MRK "testGard2: Success"); - } - } - } - - /** - * @brief Test getting GARD Records for a specific target - */ - void testGard3() - { - TS_TRACE(INFO_MRK "testGard3: Started"); - - errlHndl_t l_pErr = NULL; - DeconfigGard::GardRecords_t l_records; - - do - { - // find a core that we can play with - Target * pSys; - targetService().getTopLevelTarget(pSys); - - PredicateCTM predCore(CLASS_UNIT, TYPE_CORE); - PredicateHwas predFunctional; - predFunctional.poweredOn(true).present(true).functional(true); - PredicatePostfixExpr checkExpr; - checkExpr.push(&predCore).push(&predFunctional).And(); - TargetHandleList pCoreList; - targetService().getAssociated( pCoreList, pSys, - TargetService::CHILD, TargetService::ALL, &checkExpr ); - - if (pCoreList.empty()) - { - TS_FAIL("testGard3: empty pCoreList"); - break; - } - TargetHandle_t l_pTarget = *pCoreList.begin(); - - EntityPath l_id = l_pTarget->getAttr<ATTR_PHYS_PATH>(); - - // Get all GARD Records for the Target - l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); - - if (l_pErr) - { - errlCommit(l_pErr,HWAS_COMP_ID); - TS_FAIL("testGard3: Error from getGardRecords"); - } - else - { - TS_TRACE(INFO_MRK "testGard3: Success. %d records", - l_records.size()); - } - } - while (0); - } - - /** * @brief Test creating a GARD Record, getting the GARD Record and * clearing the GARD Record */ @@ -869,31 +786,28 @@ public: do { - // find a core that we can play with + // find a ex unit that we can play with Target * pSys; targetService().getTopLevelTarget(pSys); - PredicateCTM predCore(CLASS_UNIT, TYPE_CORE); + PredicateCTM predEx(CLASS_UNIT, TYPE_EX); PredicateHwas predFunctional; predFunctional.poweredOn(true).present(true).functional(true); PredicatePostfixExpr checkExpr; - checkExpr.push(&predCore).push(&predFunctional).And(); - TargetHandleList pCoreList; - targetService().getAssociated( pCoreList, pSys, + checkExpr.push(&predEx).push(&predFunctional).And(); + TargetHandleList pExList; + targetService().getAssociated( pExList, pSys, TargetService::CHILD, TargetService::ALL, &checkExpr ); - if (pCoreList.empty()) + if (pExList.empty()) { - TS_FAIL("testGard4: empty pCoreList"); + TS_FAIL("testGard4: empty pExList"); break; } - TargetHandle_t l_pTarget = *pCoreList.begin(); - - EntityPath l_id = l_pTarget->getAttr<ATTR_PHYS_PATH>(); + TargetHandle_t l_pTarget = *pExList.begin(); // Get any existing GARD Records for the target - l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); - + l_pErr = theDeconfigGard().getGardRecords(l_pTarget, l_records); if (l_pErr) { TS_FAIL("testGard4: Error from getGardRecords"); @@ -909,7 +823,7 @@ public: // Create a GARD Record for the target. l_pErr = theDeconfigGard(). - createGardRecord(*l_pTarget, 0x12, GARD_Predictive); + createGardRecord(l_pTarget, 0x12, GARD_Predictive); if (l_pErr) { @@ -918,7 +832,7 @@ public: } // Get the GARD Records for the target - l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); + l_pErr = theDeconfigGard().getGardRecords(l_pTarget, l_records); if (l_pErr) { @@ -941,7 +855,7 @@ public: } // Clear the GARD Records for the target - l_pErr = theDeconfigGard().clearGardRecords(l_id); + l_pErr = theDeconfigGard().clearGardRecords(l_pTarget); if (l_pErr) { @@ -952,7 +866,7 @@ public: // Get the GARD Records for the target l_records.clear(); - l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); + l_pErr = theDeconfigGard().getGardRecords(l_pTarget, l_records); if (l_pErr) { @@ -1001,30 +915,28 @@ public: do { - // find a core that we can play with + // find a ex unit that we can play with Target * pSys; targetService().getTopLevelTarget(pSys); - PredicateCTM predCore(CLASS_UNIT, TYPE_CORE); + PredicateCTM predEx(CLASS_UNIT, TYPE_EX); PredicateHwas predFunctional; predFunctional.poweredOn(true).present(true).functional(true); PredicatePostfixExpr checkExpr; - checkExpr.push(&predCore).push(&predFunctional).And(); - TargetHandleList pCoreList; - targetService().getAssociated( pCoreList, pSys, + checkExpr.push(&predEx).push(&predFunctional).And(); + TargetHandleList pExList; + targetService().getAssociated( pExList, pSys, TargetService::CHILD, TargetService::ALL, &checkExpr ); - if (pCoreList.empty()) + if (pExList.empty()) { - TS_FAIL("testGard5: empty pCoreList"); + TS_FAIL("testGard5: empty pExList"); break; } - TargetHandle_t l_pTarget = *pCoreList.begin(); - - EntityPath l_id = l_pTarget->getAttr<ATTR_PHYS_PATH>(); + TargetHandle_t l_pTarget = *pExList.begin(); // Get any existing GARD Records for the target - l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); + l_pErr = theDeconfigGard().getGardRecords(l_pTarget, l_records); if (l_pErr) { @@ -1041,7 +953,7 @@ public: // Create a GARD Record for the target. l_pErr = theDeconfigGard(). - createGardRecord(*l_pTarget, 0x23, GARD_Predictive); + createGardRecord(l_pTarget, 0x23, GARD_Predictive); if (l_pErr) { @@ -1051,7 +963,7 @@ public: // Create another GARD Record for the target l_pErr = theDeconfigGard(). - createGardRecord(*l_pTarget, 0x45, GARD_Fatal); + createGardRecord(l_pTarget, 0x45, GARD_Fatal); if (l_pErr) { @@ -1060,7 +972,7 @@ public: } // Get the GARD Records for the target - l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); + l_pErr = theDeconfigGard().getGardRecords(l_pTarget, l_records); if (l_pErr) { @@ -1068,15 +980,15 @@ public: break; } - if (l_records.size() != 2) + if (l_records.size() != 1) { - TS_FAIL("testGard5: %d records for target, expected 2", + TS_FAIL("testGard5: %d records for target, expected 1", l_records.size()); break; } - // Clear the GARD Records for the target - l_pErr = theDeconfigGard().clearGardRecords(l_id); + // Clear the GARD Record for the target + l_pErr = theDeconfigGard().clearGardRecords(l_pTarget); if (l_pErr) { @@ -1087,7 +999,7 @@ public: // Get the GARD Records for the target l_records.clear(); - l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); + l_pErr = theDeconfigGard().getGardRecords(l_pTarget, l_records); if (l_pErr) { @@ -1114,7 +1026,7 @@ public: } /** - * @brief Test getting and clearing GARD Records by recordID + * @brief Test creating a 2nd GARD Record overwrites manual gard */ void testGard6() { @@ -1136,30 +1048,28 @@ public: do { - // find a core that we can play with + // find a ex unit that we can play with Target * pSys; targetService().getTopLevelTarget(pSys); - PredicateCTM predCore(CLASS_UNIT, TYPE_CORE); + PredicateCTM predEx(CLASS_UNIT, TYPE_EX); PredicateHwas predFunctional; predFunctional.poweredOn(true).present(true).functional(true); PredicatePostfixExpr checkExpr; - checkExpr.push(&predCore).push(&predFunctional).And(); - TargetHandleList pCoreList; - targetService().getAssociated( pCoreList, pSys, + checkExpr.push(&predEx).push(&predFunctional).And(); + TargetHandleList pExList; + targetService().getAssociated( pExList, pSys, TargetService::CHILD, TargetService::ALL, &checkExpr ); - if (pCoreList.empty()) + if (pExList.empty()) { - TS_FAIL("testGard6: empty pCoreList"); + TS_FAIL("testGard6: empty pExList"); break; } - TargetHandle_t l_pTarget = *pCoreList.begin(); - - EntityPath l_id = l_pTarget->getAttr<ATTR_PHYS_PATH>(); + TargetHandle_t l_pTarget = *pExList.begin(); // Get any existing GARD Records for the target - l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); + l_pErr = theDeconfigGard().getGardRecords(l_pTarget, l_records); if (l_pErr) { @@ -1174,10 +1084,9 @@ public: break; } - // Create a GARD Record for the target. Production code will pass a - // valid PLID + // Create a GARD Record for the target. l_pErr = theDeconfigGard(). - createGardRecord(*l_pTarget, 0, GARD_Predictive); + createGardRecord(l_pTarget, 0x23, GARD_User_Manual); if (l_pErr) { @@ -1185,9 +1094,9 @@ public: break; } - // Create another GARD Record for the target + // Create another GARD Record for the target - should overwrite l_pErr = theDeconfigGard(). - createGardRecord(*l_pTarget, 0, GARD_Fatal); + createGardRecord(l_pTarget, 0x46, GARD_Fatal); if (l_pErr) { @@ -1196,7 +1105,7 @@ public: } // Get the GARD Records for the target - l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); + l_pErr = theDeconfigGard().getGardRecords(l_pTarget, l_records); if (l_pErr) { @@ -1204,35 +1113,23 @@ public: break; } - if (l_records.size() != 2) + if (l_records.size() != 1) { - TS_FAIL("testGard6: %d records for target, expected 2", + TS_FAIL("testGard6: %d records for target, expected 1", l_records.size()); break; } - // Get the first GARD Record for the target by Record ID - uint32_t l_recordID = l_records[0].iv_recordId; - l_records.clear(); - - l_pErr = theDeconfigGard(). - getGardRecords(l_recordID, l_records); - - if (l_pErr) - { - TS_FAIL("testGard6: Error from getGardRecords (3)"); - break; - } - - if (l_records.size() != 1) + if ((l_records[0].iv_errlogPlid != 0x46) || + (l_records[0].iv_errorType != GARD_Fatal)) { - TS_FAIL("testGard6: %d records for target, expected 1", - l_records.size()); + TS_FAIL("testGard6: unexpected data - errl 0x%X type %x", + l_records[0].iv_errlogPlid, l_records[0].iv_errorType); break; } - // Clear the first GARD Record for the target by Record ID - l_pErr = theDeconfigGard().clearGardRecords(l_recordID); + // Clear the GARD Record for the target + l_pErr = theDeconfigGard().clearGardRecords(l_pTarget); if (l_pErr) { @@ -1243,30 +1140,21 @@ public: // Get the GARD Records for the target l_records.clear(); - l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); + l_pErr = theDeconfigGard().getGardRecords(l_pTarget, l_records); if (l_pErr) { - TS_FAIL("testGard6: Error from getGardRecords (4)"); + TS_FAIL("testGard6: Error from getGardRecords (3)"); break; } - if (l_records.size() != 1) + if (l_records.size() != 0) { - TS_FAIL("testGard6: %d records for target, expected 1 (2)", + TS_FAIL("testGard6: %d records for target, expected 0", l_records.size()); break; } - // Clear the GARD Records for the target - l_pErr = theDeconfigGard().clearGardRecords(l_id); - - if (l_pErr) - { - TS_FAIL("testGard6: Error from clearGardRecords"); - break; - } - TS_TRACE(INFO_MRK "testGard6: Success"); } while (0); @@ -1301,29 +1189,28 @@ public: do { - // find a core that we can play with + // find a ex unit that we can play with Target * pSys; targetService().getTopLevelTarget(pSys); - PredicateCTM predCore(CLASS_UNIT, TYPE_CORE); + PredicateCTM predEx(CLASS_UNIT, TYPE_EX); PredicateHwas predFunctional; predFunctional.poweredOn(true).present(true).functional(true); PredicatePostfixExpr checkExpr; - checkExpr.push(&predCore).push(&predFunctional).And(); - TargetHandleList pCoreList; - targetService().getAssociated( pCoreList, pSys, + checkExpr.push(&predEx).push(&predFunctional).And(); + TargetHandleList pExList; + targetService().getAssociated( pExList, pSys, TargetService::CHILD, TargetService::ALL, &checkExpr ); - if (pCoreList.empty()) + if (pExList.empty()) { - TS_FAIL("testGard7: empty pCoreList"); + TS_FAIL("testGard7: empty pExList"); break; } - TargetHandle_t l_pTarget = *pCoreList.begin(); + TargetHandle_t l_pTarget = *pExList.begin(); // Get all existing GARD Records - l_pErr = theDeconfigGard().getGardRecords( - DeconfigGard::GET_ALL_GARD_RECORDS, l_records); + l_pErr = theDeconfigGard().getGardRecords(NULL, l_records); if (l_pErr) { @@ -1338,10 +1225,9 @@ public: break; } - // Create a GARD Record for the target. Production code will pass a - // valid PLID + // Create a GARD Record for the target. l_pErr = theDeconfigGard(). - createGardRecord(*l_pTarget, 0, GARD_Predictive); + createGardRecord(l_pTarget, 0x71, GARD_Predictive); if (l_pErr) { @@ -1349,31 +1235,19 @@ public: break; } - // Create another GARD Record for the target - l_pErr = theDeconfigGard(). - createGardRecord(*l_pTarget, 0, GARD_Fatal); - - if (l_pErr) - { - TS_FAIL("testGard7: Error from createGardRecord (2)"); - break; - } - // Clear all GARD Records - l_pErr = theDeconfigGard(). - clearGardRecords(DeconfigGard::CLEAR_ALL_GARD_RECORDS); + l_pErr = theDeconfigGard().clearGardRecords(NULL); if (l_pErr) { - TS_FAIL("testGard7: Error from clearGardRecords"); + TS_FAIL("testGard7: Error from clearGardRecords(NULL)"); break; } // Get the GARD Records l_records.clear(); - l_pErr = theDeconfigGard().getGardRecords( - DeconfigGard::GET_ALL_GARD_RECORDS, l_records); + l_pErr = theDeconfigGard().getGardRecords(NULL, l_records); if (l_pErr) { @@ -1423,8 +1297,7 @@ public: do { - l_pErr = theDeconfigGard().getGardRecords( - DeconfigGard::GET_ALL_GARD_RECORDS, l_records); + l_pErr = theDeconfigGard().getGardRecords(NULL, l_records); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); @@ -1439,40 +1312,39 @@ public: break; } - // find a core that we can play with + // find a ex unit that we can play with Target * pSys; targetService().getTopLevelTarget(pSys); - PredicateCTM predCore(CLASS_UNIT, TYPE_CORE); + PredicateCTM predEx(CLASS_UNIT, TYPE_EX); PredicateHwas predFunctional; predFunctional.poweredOn(true).present(true).functional(true); PredicatePostfixExpr checkExpr; - checkExpr.push(&predCore).push(&predFunctional).And(); + checkExpr.push(&predEx).push(&predFunctional).And(); - TargetHandleList pCoreList; - targetService().getAssociated( pCoreList, pSys, + TargetHandleList pExList; + targetService().getAssociated( pExList, pSys, TargetService::CHILD, TargetService::ALL, &checkExpr ); - if (pCoreList.empty()) + if (pExList.empty()) { - TS_FAIL("testGard8: empty pCoreList"); + TS_FAIL("testGard8: empty pExList"); break; } - TargetHandle_t l_target = *pCoreList.begin(); + TargetHandle_t l_target = *pExList.begin(); // create GARD record, call 'doGard' step and confirm target is // deconfigured l_pErr = theDeconfigGard(). - createGardRecord( *l_target, 0x12, GARD_User_Manual); + createGardRecord(l_target, 0x12, GARD_User_Manual); if (l_pErr) { TS_FAIL("testGard8: Error from createGardRecord"); break; } - l_pErr = theDeconfigGard().getGardRecords( - DeconfigGard::GET_ALL_GARD_RECORDS, l_records); + l_pErr = theDeconfigGard().getGardRecords(NULL, l_records); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); @@ -1514,8 +1386,7 @@ public: break; } - l_pErr = theDeconfigGard().getGardRecords( - DeconfigGard::GET_ALL_GARD_RECORDS, l_records); + l_pErr = theDeconfigGard().getGardRecords(NULL, l_records); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); @@ -1570,30 +1441,28 @@ public: do { - // find a core that we can play with + // find a ex unit that we can play with Target * pSys; targetService().getTopLevelTarget(pSys); - PredicateCTM predCore(CLASS_UNIT, TYPE_CORE); + PredicateCTM predEx(CLASS_UNIT, TYPE_EX); PredicateHwas predFunctional; predFunctional.poweredOn(true).present(true).functional(true); PredicatePostfixExpr checkExpr; - checkExpr.push(&predCore).push(&predFunctional).And(); - TargetHandleList pCoreList; - targetService().getAssociated( pCoreList, pSys, + checkExpr.push(&predEx).push(&predFunctional).And(); + TargetHandleList pExList; + targetService().getAssociated( pExList, pSys, TargetService::CHILD, TargetService::ALL, &checkExpr ); - if (pCoreList.empty()) + if (pExList.empty()) { - TS_FAIL("testGard9: empty pCoreList"); + TS_FAIL("testGard9: empty pExList"); break; } - TargetHandle_t l_pTarget = *pCoreList.begin(); - - EntityPath l_id = l_pTarget->getAttr<ATTR_PHYS_PATH>(); + TargetHandle_t l_pTarget = *pExList.begin(); // Get any existing GARD Records for the target - l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); + l_pErr = theDeconfigGard().getGardRecords(l_pTarget, l_records); if (l_pErr) { @@ -1617,7 +1486,7 @@ public: // (try to) Create a GARD Record for the target. l_pErr = theDeconfigGard(). - createGardRecord(*l_pTarget, 0x12, GARD_Fatal); + createGardRecord(l_pTarget, 0x12, GARD_Fatal); if (l_pErr) { @@ -1626,7 +1495,7 @@ public: } // Get the GARD Records for the target - shouldn't be any - l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); + l_pErr = theDeconfigGard().getGardRecords(l_pTarget, l_records); if (l_pErr) { @@ -1648,7 +1517,7 @@ public: // (try to) Create a GARD Record for the target. l_pErr = theDeconfigGard(). - createGardRecord(*l_pTarget, 0x12, GARD_Predictive); + createGardRecord(l_pTarget, 0x12, GARD_Predictive); if (l_pErr) { @@ -1657,7 +1526,7 @@ public: } // Get the GARD Records for the target - shouldn't be any - l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); + l_pErr = theDeconfigGard().getGardRecords(l_pTarget, l_records); if (l_pErr) { @@ -1679,7 +1548,7 @@ public: // (try to) Create a GARD Record for the target. l_pErr = theDeconfigGard(). - createGardRecord(*l_pTarget, 0x12, GARD_Func); + createGardRecord(l_pTarget, 0x12, GARD_Func); if (l_pErr) { @@ -1688,7 +1557,7 @@ public: } // Get the GARD Records for the target - shouldn't be any - l_pErr = theDeconfigGard().getGardRecords(l_id, l_records); + l_pErr = theDeconfigGard().getGardRecords(l_pTarget, l_records); if (l_pErr) { @@ -1739,8 +1608,7 @@ public: do { - l_pErr = theDeconfigGard().getGardRecords( - DeconfigGard::GET_ALL_GARD_RECORDS, l_records); + l_pErr = theDeconfigGard().getGardRecords(NULL, l_records); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); @@ -1755,40 +1623,39 @@ public: break; } - // find a core that we can play with + // find a ex unit that we can play with Target * pSys; targetService().getTopLevelTarget(pSys); - PredicateCTM predCore(CLASS_UNIT, TYPE_CORE); + PredicateCTM predEx(CLASS_UNIT, TYPE_EX); PredicateHwas predFunctional; predFunctional.poweredOn(true).present(true).functional(true); PredicatePostfixExpr checkExpr; - checkExpr.push(&predCore).push(&predFunctional).And(); + checkExpr.push(&predEx).push(&predFunctional).And(); - TargetHandleList pCoreList; - targetService().getAssociated( pCoreList, pSys, + TargetHandleList pExList; + targetService().getAssociated( pExList, pSys, TargetService::CHILD, TargetService::ALL, &checkExpr ); - if (pCoreList.empty()) + if (pExList.empty()) { - TS_FAIL("testGard10: empty pCoreList"); + TS_FAIL("testGard10: empty pExList"); break; } - TargetHandle_t l_target = *pCoreList.begin(); + TargetHandle_t l_target = *pExList.begin(); // create GARD record, set Policy, call 'doGard' step and confirm // target is NOT deconfigured l_pErr = theDeconfigGard(). - createGardRecord( *l_target, 0x12, GARD_Predictive); + createGardRecord(l_target, 0x12, GARD_Predictive); if (l_pErr) { TS_FAIL("testGard10: Error from createGardRecord"); break; } - l_pErr = theDeconfigGard().getGardRecords( - DeconfigGard::GET_ALL_GARD_RECORDS, l_records); + l_pErr = theDeconfigGard().getGardRecords(NULL, l_records); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); @@ -1843,11 +1710,14 @@ public: } // Clear all GARD Records - l_pErr = theDeconfigGard(). - clearGardRecords(DeconfigGard::CLEAR_ALL_GARD_RECORDS); + l_pErr = theDeconfigGard().clearGardRecords(NULL); + if (l_pErr) + { + TS_FAIL("testGard7: Error from clearGardRecords(NULL)"); + break; + } - l_pErr = theDeconfigGard().getGardRecords( - DeconfigGard::GET_ALL_GARD_RECORDS, l_records); + l_pErr = theDeconfigGard().getGardRecords(NULL, l_records); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); @@ -1864,15 +1734,14 @@ public: // create GARD record, set Policy, call 'doGard' step and confirm // target is NOT deconfigured l_pErr = theDeconfigGard(). - createGardRecord( *l_target, 0x12, GARD_Func); + createGardRecord(l_target, 0x12, GARD_Func); if (l_pErr) { TS_FAIL("testGard10: Error from createGardRecord"); break; } - l_pErr = theDeconfigGard().getGardRecords( - DeconfigGard::GET_ALL_GARD_RECORDS, l_records); + l_pErr = theDeconfigGard().getGardRecords(NULL, l_records); if (l_pErr) { errlCommit(l_pErr,HWAS_COMP_ID); @@ -1906,8 +1775,12 @@ public: } // Clear all GARD Records - l_pErr = theDeconfigGard(). - clearGardRecords(DeconfigGard::CLEAR_ALL_GARD_RECORDS); + l_pErr = theDeconfigGard().clearGardRecords(NULL); + if (l_pErr) + { + TS_FAIL("testGard7: Error from clearGardRecords(NULL)"); + break; + } // restore l_policies = 0; |