summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Horton <brianh@linux.ibm.com>2012-12-10 17:35:07 -0600
committerA. Patrick Williams III <iawillia@us.ibm.com>2013-01-02 16:44:16 -0600
commitd6dd563c5b0ed676757d6ab4dc916df073f44564 (patch)
tree79a72937f5c382c682940ff58a0e870faeae1d5f /src
parent48d9ff25aa0886aaba13b3fde521aaeb87f2eea6 (diff)
downloadtalos-hostboot-d6dd563c5b0ed676757d6ab4dc916df073f44564.tar.gz
talos-hostboot-d6dd563c5b0ed676757d6ab4dc916df073f44564.zip
deconfigGard - enable reading GARD records from PNOR
update common and platform interface so that both hostboot and FSP can access GARD records in PNOR. Change-Id: I1eb36238076bcbb421cf1d149538eba1c7faeda6 RTC: 33551 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/2628 Tested-by: Jenkins Server Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src')
-rw-r--r--src/include/usr/hwas/common/deconfigGard.H80
-rw-r--r--src/include/usr/hwas/hwasPlatDeconfigGard.H34
-rw-r--r--src/include/usr/hwas/hwasPlatThread.H10
-rw-r--r--src/usr/hwas/common/deconfigGard.C188
-rw-r--r--src/usr/hwas/hwasPlat.C124
-rw-r--r--src/usr/hwas/test/hwasGardTest.H14
6 files changed, 246 insertions, 204 deletions
diff --git a/src/include/usr/hwas/common/deconfigGard.H b/src/include/usr/hwas/common/deconfigGard.H
index 77c2f21bd..01493ecb9 100644
--- a/src/include/usr/hwas/common/deconfigGard.H
+++ b/src/include/usr/hwas/common/deconfigGard.H
@@ -5,7 +5,7 @@
/* */
/* IBM CONFIDENTIAL */
/* */
-/* COPYRIGHT International Business Machines Corp. 2011,2012 */
+/* COPYRIGHT International Business Machines Corp. 2011,2013 */
/* */
/* p1 */
/* */
@@ -66,6 +66,10 @@ DeconfigGard & theDeconfigGard();
*/
class DeconfigGard
{
+
+ // allow GardAddress to access private methods.
+ friend class GardAddress;
+
public:
/**
@@ -80,6 +84,12 @@ public:
DECONFIG_CAUSE_DECONFIG_BY_ASSOC = 3, // Deconfigure by Association
};
+ enum
+ {
+ CLEAR_ALL_GARD_RECORDS = EMPTY_GARD_RECORDID,
+ GET_ALL_GARD_RECORDS = EMPTY_GARD_RECORDID,
+ };
+
/**
* @struct GardRecord
*
@@ -222,8 +232,8 @@ public:
* only errors returned are usage errors and errors accessing the GARD
* Records.
*
- * @param[in] i_recordId RecordId to clear. If zero then all GARD Records
- * are cleared.
+ * @param[in] i_recordId RecordId to clear. If zero (CLEAR_ALL_GARD_RECORDS)
+ * then all GARD Records cleared.
*
* @return errlHndl_t. Error log handle.
*/
@@ -380,8 +390,8 @@ private:
/**
* @brief Clears the specified GARD Records.
*
- * @param[in] i_recordId RecordId to clear. If zero then all GARD Records
- * are cleared.
+ * @param[in] i_recordId RecordId to clear. If zero (CLEAR_ALL_GARD_RECORDS)
+ * then all GARD Records cleared.
*
* @return errlHndl_t. Error log handle.
*/
@@ -423,15 +433,15 @@ private:
GardRecords_t & o_records);
/**
- * @brief Ensures that the GARD Record data is setup
+ * @brief sets the maxGardRecords and nextGardRecordId variables
*
- * @return errlHndl_t. Error log handle.
+ * @param[in] i_size size of GARD area in PNOR/memory
*/
- errlHndl_t _ensureGardRecordDataSetup();
-
+ 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
@@ -439,9 +449,57 @@ private:
// The Deconfigure Records
DeconfigureRecords_t iv_deconfigureRecords;
-};
+
+}; // 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_gardEnabled boolean returned:
+ * true - reading/writing of gard records is enabled;
+ * false - not enabled
+ */
+ GardAddress(bool &o_gardEnabled);
+
+ /**
+ * @brief Destructor.
+ * PLATFORM must implement this function
+ */
+ ~GardAddress();
+
+ /**
+ * @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 3cddf8dd5..2f229c164 100644
--- a/src/include/usr/hwas/hwasPlatDeconfigGard.H
+++ b/src/include/usr/hwas/hwasPlatDeconfigGard.H
@@ -5,7 +5,7 @@
/* */
/* IBM CONFIDENTIAL */
/* */
-/* COPYRIGHT International Business Machines Corp. 2012 */
+/* COPYRIGHT International Business Machines Corp. 2012,2013 */
/* */
/* p1 */
/* */
@@ -30,38 +30,6 @@
#ifndef HWASPLATDECONFIGGARD_H_
#define HWASPLATDECONFIGGARD_H_
-#include <sys/mm.h>
-#include <trace/interface.H>
-#include <errl/errlentry.H>
-#include <hwas/hwasPlatError.H>
-
-//******************************************************************************
-// Trace descriptors that are defined in a C file
-//******************************************************************************
-namespace HWAS
-{
-
-#if 0
-//TODO: RTC 37739: flush PNOR
-// questions -- what address and what size do it need to use? the section
-// starting address and section size? or the address and size of the
-// gard record that is being flushed?
-
-/**
- * @brief function to push GARD records 'out' to PNOR
- */
-inline void pushGardRecords(void *i_pAddr, uint64_t i_size)
-{
- int l_rc = mm_remove_pages(FLUSH, i_pAddr, i_size);
- if (l_rc )
- { // mm_remove_pages returns none zero for error
- HWAS_ERR("Fail to flush the page");
- }
-}
-#endif
-
-}
-
/**
* @brief Adapt common singleton declaration to specific platform
*
diff --git a/src/include/usr/hwas/hwasPlatThread.H b/src/include/usr/hwas/hwasPlatThread.H
index b68b9e1a3..ff3a75de2 100644
--- a/src/include/usr/hwas/hwasPlatThread.H
+++ b/src/include/usr/hwas/hwasPlatThread.H
@@ -5,7 +5,7 @@
/* */
/* IBM CONFIDENTIAL */
/* */
-/* COPYRIGHT International Business Machines Corp. 2012 */
+/* COPYRIGHT International Business Machines Corp. 2012,2013 */
/* */
/* p1 */
/* */
@@ -37,15 +37,15 @@
mutable mutex_t
#define HWAS_MUTEX_INIT(_t) \
- mutex_init(_t)
+ mutex_init(&(_t))
#define HWAS_MUTEX_DESTROY(_t) \
- mutex_destroy(_t)
+ mutex_destroy(&(_t))
#define HWAS_MUTEX_LOCK(_t) \
- mutex_lock(_t)
+ mutex_lock(&(_t))
#define HWAS_MUTEX_UNLOCK(_t) \
- mutex_unlock(_t)
+ mutex_unlock(&(_t))
#endif // __HWAS_PLAT_THREAD_H
diff --git a/src/usr/hwas/common/deconfigGard.C b/src/usr/hwas/common/deconfigGard.C
index 61fdc42cb..c6a7f79ac 100644
--- a/src/usr/hwas/common/deconfigGard.C
+++ b/src/usr/hwas/common/deconfigGard.C
@@ -5,7 +5,7 @@
/* */
/* IBM CONFIDENTIAL */
/* */
-/* COPYRIGHT International Business Machines Corp. 2011,2012 */
+/* COPYRIGHT International Business Machines Corp. 2011,2013 */
/* */
/* p1 */
/* */
@@ -94,26 +94,26 @@ DeconfigGard::DeconfigGard()
iv_pGardRecords(NULL)
{
HWAS_INF("DeconfigGard Constructor");
- HWAS_MUTEX_INIT(&iv_mutex);
+ HWAS_MUTEX_INIT(iv_mutex);
}
//******************************************************************************
DeconfigGard::~DeconfigGard()
{
HWAS_INF("DeconfigGard Destructor");
- HWAS_MUTEX_DESTROY(&iv_mutex);
+ HWAS_MUTEX_DESTROY(iv_mutex);
}
//******************************************************************************
errlHndl_t DeconfigGard::clearGardRecordsForReplacedTargets()
{
HWAS_INF("****TBD****Usr Request: Clear GARD Records for replaced Targets");
- HWAS_MUTEX_LOCK(&iv_mutex);
+ HWAS_MUTEX_LOCK(iv_mutex);
errlHndl_t l_pErr = NULL;
// TODO
- HWAS_MUTEX_UNLOCK(&iv_mutex);
+ HWAS_MUTEX_UNLOCK(iv_mutex);
return l_pErr;
}
@@ -121,7 +121,7 @@ errlHndl_t DeconfigGard::clearGardRecordsForReplacedTargets()
errlHndl_t DeconfigGard::deconfigureTargetsFromGardRecordsForIpl()
{
HWAS_INF("Usr Request: Deconfigure Targets from GARD Records for IPL");
- HWAS_MUTEX_LOCK(&iv_mutex);
+ HWAS_MUTEX_LOCK(iv_mutex);
errlHndl_t l_pErr = NULL;
GardRecords_t l_gardRecords;
@@ -131,7 +131,7 @@ errlHndl_t DeconfigGard::deconfigureTargetsFromGardRecordsForIpl()
// This is known as Resource Recovery
// Get all GARD Records
- l_pErr = _getGardRecords(0, l_gardRecords);
+ l_pErr = _getGardRecords(GET_ALL_GARD_RECORDS, l_gardRecords);
if (l_pErr)
{
@@ -178,7 +178,7 @@ errlHndl_t DeconfigGard::deconfigureTargetsFromGardRecordsForIpl()
}
}
- HWAS_MUTEX_UNLOCK(&iv_mutex);
+ HWAS_MUTEX_UNLOCK(iv_mutex);
return l_pErr;
}
@@ -186,8 +186,8 @@ errlHndl_t DeconfigGard::deconfigureTargetsFromGardRecordsForIpl()
errlHndl_t DeconfigGard::deconfigureTarget(TARGETING::Target & i_target,
const uint32_t i_errlPlid)
{
- HWAS_ERR("Usr Request: Deconfigure Target");
- HWAS_MUTEX_LOCK(&iv_mutex);
+ HWAS_INF("Usr Request: Deconfigure Target");
+ HWAS_MUTEX_LOCK(iv_mutex);
// Deconfigure the Target
_deconfigureTarget(i_target, i_errlPlid, DECONFIG_CAUSE_FIRMWARE_REQ);
@@ -195,7 +195,7 @@ errlHndl_t DeconfigGard::deconfigureTarget(TARGETING::Target & i_target,
// Deconfigure other Targets by association
_deconfigureByAssoc(i_target, i_errlPlid);
- HWAS_MUTEX_UNLOCK(&iv_mutex);
+ HWAS_MUTEX_UNLOCK(iv_mutex);
return NULL;
}
@@ -204,10 +204,10 @@ errlHndl_t DeconfigGard::createGardRecord(const TARGETING::Target & i_target,
const uint32_t i_errlPlid,
const GARD_ErrorType i_errorType)
{
- HWAS_ERR("Usr Request: Create GARD Record");
- HWAS_MUTEX_LOCK(&iv_mutex);
+ HWAS_INF("Usr Request: Create GARD Record");
+ HWAS_MUTEX_LOCK(iv_mutex);
errlHndl_t l_pErr = _createGardRecord(i_target, i_errlPlid, i_errorType);
- HWAS_MUTEX_UNLOCK(&iv_mutex);
+ HWAS_MUTEX_UNLOCK(iv_mutex);
return l_pErr;
}
@@ -217,9 +217,9 @@ errlHndl_t DeconfigGard::getDeconfigureRecords(
DeconfigureRecords_t & o_records)
{
HWAS_INF("Usr Request: Get Deconfigure Record(s)");
- HWAS_MUTEX_LOCK(&iv_mutex);
+ HWAS_MUTEX_LOCK(iv_mutex);
_getDeconfigureRecords(i_pTargetId, o_records);
- HWAS_MUTEX_UNLOCK(&iv_mutex);
+ HWAS_MUTEX_UNLOCK(iv_mutex);
return NULL;
}
@@ -228,9 +228,9 @@ errlHndl_t DeconfigGard::getDeconfigureRecords(
errlHndl_t DeconfigGard::clearGardRecords(const uint32_t i_recordId)
{
HWAS_INF("Usr Request: Clear GARD Record(s) by Record ID");
- HWAS_MUTEX_LOCK(&iv_mutex);
+ HWAS_MUTEX_LOCK(iv_mutex);
errlHndl_t l_pErr = _clearGardRecords(i_recordId);
- HWAS_MUTEX_UNLOCK(&iv_mutex);
+ HWAS_MUTEX_UNLOCK(iv_mutex);
return l_pErr;
}
@@ -239,9 +239,9 @@ errlHndl_t DeconfigGard::clearGardRecords(
const TARGETING::EntityPath & i_targetId)
{
HWAS_INF("Usr Request: Clear GARD Record(s) by Target ID");
- HWAS_MUTEX_LOCK(&iv_mutex);
+ HWAS_MUTEX_LOCK(iv_mutex);
errlHndl_t l_pErr = _clearGardRecords(i_targetId);
- HWAS_MUTEX_UNLOCK(&iv_mutex);
+ HWAS_MUTEX_UNLOCK(iv_mutex);
return l_pErr;
}
@@ -251,9 +251,9 @@ errlHndl_t DeconfigGard::getGardRecords(
GardRecords_t & o_records)
{
HWAS_INF("Usr Request: Get GARD Record(s) by Record ID");
- HWAS_MUTEX_LOCK(&iv_mutex);
+ HWAS_MUTEX_LOCK(iv_mutex);
errlHndl_t l_pErr = _getGardRecords(i_recordId, o_records);
- HWAS_MUTEX_UNLOCK(&iv_mutex);
+ HWAS_MUTEX_UNLOCK(iv_mutex);
return l_pErr;
}
@@ -263,9 +263,9 @@ errlHndl_t DeconfigGard::getGardRecords(
GardRecords_t & o_records)
{
HWAS_INF("Usr Request: Get GARD Record(s) by Target ID");
- HWAS_MUTEX_LOCK(&iv_mutex);
+ HWAS_MUTEX_LOCK(iv_mutex);
errlHndl_t l_pErr = _getGardRecords(i_targetId, o_records);
- HWAS_MUTEX_UNLOCK(&iv_mutex);
+ HWAS_MUTEX_UNLOCK(iv_mutex);
return l_pErr;
}
@@ -273,7 +273,7 @@ errlHndl_t DeconfigGard::getGardRecords(
void DeconfigGard::_deconfigureByAssoc(TARGETING::Target & i_target,
const uint32_t i_errlPlid)
{
- HWAS_ERR("****TBD****: Deconfiguring by Association for: %.8X",
+ HWAS_INF("****TBD****: Deconfiguring by Association for: %.8X",
i_target.getAttr<TARGETING::ATTR_HUID>());
// TODO
@@ -290,7 +290,9 @@ void DeconfigGard::_deconfigureTarget(TARGETING::Target & i_target,
if (!i_target.getAttr<TARGETING::ATTR_DECONFIG_GARDABLE>())
{
// Target is not Deconfigurable. Commit an error
- HWAS_ERR("Target not Deconfigurable");
+ HWAS_ERR("Target %.8X not Deconfigurable",
+ i_target.getAttr<TARGETING::ATTR_HUID>());
+
/*@
* @errortype
* @moduleid HWAS::MOD_DECONFIG_GARD
@@ -299,10 +301,9 @@ void DeconfigGard::_deconfigureTarget(TARGETING::Target & i_target,
* deconfigurable
* @userdata1 HUID of input target
*/
- const uint64_t userdata1 =
- (uint64_t)i_target.getAttr<TARGETING::ATTR_HUID>() << 32;
- errlHndl_t l_pErr = NULL;
- l_pErr = hwasError(
+ const uint64_t userdata1 = static_cast<uint64_t>
+ (i_target.getAttr<TARGETING::ATTR_HUID>()) << 32;
+ errlHndl_t l_pErr = hwasError(
ERRL_SEV_INFORMATIONAL,
HWAS::MOD_DECONFIG_GARD,
HWAS::RC_TARGET_NOT_DECONFIGURABLE,
@@ -319,11 +320,11 @@ void DeconfigGard::_deconfigureTarget(TARGETING::Target & i_target,
if (!l_state.functional)
{
- HWAS_ERR("Target HWAS_STATE already non-functional");
+ HWAS_DBG("Target HWAS_STATE already non-functional");
}
else
{
- HWAS_ERR("Setting Target HWAS_STATE to non-functional");
+ HWAS_INF("Setting Target HWAS_STATE to non-functional");
l_state.functional = 0;
i_target.setAttr<TARGETING::ATTR_HWAS_STATE>(l_state);
}
@@ -364,12 +365,12 @@ void DeconfigGard::_createDeconfigureRecord(
if (l_itr != iv_deconfigureRecords.end())
{
- HWAS_ERR("Not creating a Deconfigure Record, one already exists");
+ HWAS_DBG("Not creating a Deconfigure Record, one already exists");
}
else
{
// Create a DeconfigureRecord
- HWAS_ERR("Creating a Deconfigure Record");
+ HWAS_INF("Creating a Deconfigure Record");
DeconfigureRecord l_record;
l_record.iv_targetId = l_id;
@@ -418,10 +419,6 @@ void DeconfigGard::_clearDeconfigureRecords(
DG_TRAC_TARGET(INFO_MRK "Did not find a Deconfigure Record to clear for: ",
i_pTargetId);
}
- else
- {
- //TODO: RTC 37739: flush PNOR as well
- }
}
}
@@ -484,6 +481,7 @@ errlHndl_t DeconfigGard::_createGardRecord(const TARGETING::Target & i_target,
{
// Target is not GARDable. Commit an error
HWAS_ERR("Target not GARDable");
+
/*@
* @errortype
* @moduleid HWAS::MOD_DECONFIG_GARD
@@ -503,11 +501,12 @@ errlHndl_t DeconfigGard::_createGardRecord(const TARGETING::Target & i_target,
break;
}
- l_pErr = _ensureGardRecordDataSetup();
+ bool l_gardEnabled;
+ GardAddress l_GardAddress(l_gardEnabled);
- if (l_pErr)
+ if (!l_gardEnabled)
{
- HWAS_ERR("Error from _ensureGardRecordDataSetup");
+ HWAS_ERR("Error from l_GardAddress");
break;
}
@@ -526,6 +525,7 @@ errlHndl_t DeconfigGard::_createGardRecord(const TARGETING::Target & i_target,
if (!l_pRecord)
{
HWAS_ERR("GARD Record Repository full");
+
/*@
* @errortype
* @moduleid HWAS::MOD_DECONFIG_GARD
@@ -554,7 +554,8 @@ errlHndl_t DeconfigGard::_createGardRecord(const TARGETING::Target & i_target,
l_pRecord->iv_padding[2] = 0;
l_pRecord->iv_gardTime = 0; // TODO Get epoch time
- //TODO: RTC 37739: flush PNOR as well
+ l_GardAddress.writeRecord((void *)l_pRecord);
+
}
while (0);
@@ -566,15 +567,12 @@ errlHndl_t DeconfigGard::_clearGardRecords(const uint32_t i_recordId)
{
errlHndl_t l_pErr = NULL;
- l_pErr = _ensureGardRecordDataSetup();
+ bool l_gardEnabled;
+ GardAddress l_GardAddress(l_gardEnabled);
- if (l_pErr)
- {
- HWAS_ERR("Error from _ensureGardRecordDataSetup");
- }
- else
+ if (l_gardEnabled)
{
- if (i_recordId == 0)
+ if (i_recordId == CLEAR_ALL_GARD_RECORDS)
{
HWAS_INF("Clearing all GARD Records");
@@ -585,7 +583,7 @@ errlHndl_t DeconfigGard::_clearGardRecords(const uint32_t i_recordId)
{
// clear iv_recordId
iv_pGardRecords[i].iv_recordId = EMPTY_GARD_RECORDID;
- //TODO: RTC 37739: flush PNOR as well
+ l_GardAddress.writeRecord(&iv_pGardRecords[i]);
}
}
}
@@ -599,7 +597,7 @@ errlHndl_t DeconfigGard::_clearGardRecords(const uint32_t i_recordId)
HWAS_INF("Clearing GARD Record ID 0x%x", i_recordId);
// clear iv_recordId
iv_pGardRecords[i].iv_recordId = EMPTY_GARD_RECORDID;
- //TODO: RTC 37739: flush PNOR as well
+ l_GardAddress.writeRecord(&iv_pGardRecords[i]);
break;
}
}
@@ -610,6 +608,10 @@ errlHndl_t DeconfigGard::_clearGardRecords(const uint32_t i_recordId)
}
}
}
+ else
+ {
+ HWAS_ERR("Error from l_GardAddress");
+ }
return l_pErr;
}
@@ -620,13 +622,10 @@ errlHndl_t DeconfigGard::_clearGardRecords(
{
errlHndl_t l_pErr = NULL;
- l_pErr = _ensureGardRecordDataSetup();
+ bool l_gardEnabled;
+ GardAddress l_GardAddress(l_gardEnabled);
- if (l_pErr)
- {
- HWAS_ERR("Error from _ensureGardRecordDataSetup");
- }
- else
+ if (l_gardEnabled)
{
bool l_gardRecordsCleared = false;
@@ -641,6 +640,7 @@ errlHndl_t DeconfigGard::_clearGardRecords(
// clear iv_recordId
iv_pGardRecords[i].iv_recordId = EMPTY_GARD_RECORDID;
l_gardRecordsCleared = true;
+ l_GardAddress.writeRecord(&iv_pGardRecords[i]);
}
}
@@ -649,7 +649,10 @@ errlHndl_t DeconfigGard::_clearGardRecords(
DG_TRAC_TARGET(INFO_MRK "No GARD Records to clear for: ",
&i_targetId);
}
- //TODO: RTC 37739: flush PNOR as well
+ }
+ else
+ {
+ HWAS_ERR("Error from l_GardAddress");
}
return l_pErr;
@@ -662,22 +665,19 @@ errlHndl_t DeconfigGard::_getGardRecords(const uint32_t i_recordId,
errlHndl_t l_pErr = NULL;
o_records.clear();
- l_pErr = _ensureGardRecordDataSetup();
+ bool l_gardEnabled;
+ GardAddress l_GardAddress(l_gardEnabled);
- if (l_pErr)
+ if (l_gardEnabled)
{
- HWAS_ERR("Error from _ensureGardRecordDataSetup");
- }
- else
- {
- if (i_recordId == 0)
+ if (i_recordId == GET_ALL_GARD_RECORDS)
{
- HWAS_INF("Getting 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_INF("Getting GARD Record ID 0x%x",
+ HWAS_DBG("Getting GARD Record ID 0x%x",
iv_pGardRecords[i].iv_recordId);
o_records.push_back(iv_pGardRecords[i]);
}
@@ -690,7 +690,7 @@ errlHndl_t DeconfigGard::_getGardRecords(const uint32_t i_recordId,
{
if (iv_pGardRecords[i].iv_recordId == i_recordId)
{
- HWAS_INF("Getting GARD Record ID 0x%x", i_recordId);
+ HWAS_DBG("Getting GARD Record ID 0x%x", i_recordId);
o_records.push_back(iv_pGardRecords[i]);
break;
}
@@ -698,10 +698,14 @@ errlHndl_t DeconfigGard::_getGardRecords(const uint32_t i_recordId,
if (i == iv_maxGardRecords)
{
- HWAS_INF("No GARD Record ID 0x%x to get", i_recordId);
+ HWAS_DBG("No GARD Record ID 0x%x to get", i_recordId);
}
}
}
+ else
+ {
+ HWAS_ERR("Error from l_GardAddress");
+ }
return l_pErr;
}
@@ -714,13 +718,10 @@ errlHndl_t DeconfigGard::_getGardRecords(
errlHndl_t l_pErr = NULL;
o_records.clear();
- l_pErr = _ensureGardRecordDataSetup();
+ bool l_gardEnabled;
+ GardAddress l_GardAddress(l_gardEnabled);
- if (l_pErr)
- {
- HWAS_ERR("Error from _ensureGardRecordDataSetup");
- }
- else
+ if (l_gardEnabled)
{
bool l_gardRecordsGot = false;
@@ -743,36 +744,23 @@ errlHndl_t DeconfigGard::_getGardRecords(
&i_targetId);
}
}
+ else
+ {
+ HWAS_ERR("Error from l_GardAddress");
+ }
return l_pErr;
}
//******************************************************************************
-errlHndl_t DeconfigGard::_ensureGardRecordDataSetup()
+void DeconfigGard::_GardRecordIdSetup(uint32_t i_size)
{
- errlHndl_t l_pErr = NULL;
-
- do
+ if (iv_maxGardRecords == 0)
{
- if (iv_pGardRecords != NULL)
- {
- // already set, just get out of here.
- break;
- }
-
- uint64_t gardSectionSize = 0;
- void *l_addr = NULL;
- l_pErr = platGetGardPnorAddr(l_addr, gardSectionSize);
- if (l_pErr)
- {
- HWAS_ERR("Error getting GARD Record PNOR section info");
- break;
- }
- iv_pGardRecords = (GardRecord *)l_addr;
- HWAS_INF("GARD in PNOR: addr=%p, size=%lld",
- iv_pGardRecords, gardSectionSize);
+ // hasn't been computed yet
+ HWAS_INF("GardRecordIdSetup(size=%d)", i_size);
- iv_maxGardRecords = gardSectionSize / sizeof(GardRecord);
+ iv_maxGardRecords = i_size / sizeof(GardRecord);
// Figure out the next GARD Record ID to use
uint32_t l_numGardRecords = 0;
@@ -795,13 +783,9 @@ errlHndl_t DeconfigGard::_ensureGardRecordDataSetup()
// next record will start after the highest Id we found
iv_nextGardRecordId++;
- HWAS_INF("GARD setup. MaxRecords %d NextID %d NumRecords %d",
+ HWAS_INF("GARD setup. maxRecords %d nextID %d numRecords %d",
iv_maxGardRecords, iv_nextGardRecordId, l_numGardRecords);
-
}
- while (0);
-
- return l_pErr;
}
} // namespce HWAS
diff --git a/src/usr/hwas/hwasPlat.C b/src/usr/hwas/hwasPlat.C
index 898d82a45..9a38ba23d 100644
--- a/src/usr/hwas/hwasPlat.C
+++ b/src/usr/hwas/hwasPlat.C
@@ -1,26 +1,25 @@
-/* IBM_PROLOG_BEGIN_TAG
- * This is an automatically generated prolog.
- *
- * $Source: src/usr/hwas/hwasPlat.C $
- *
- * IBM CONFIDENTIAL
- *
- * COPYRIGHT International Business Machines Corp. 2012
- *
- * p1
- *
- * Object Code Only (OCO) source materials
- * Licensed Internal Code Source Materials
- * IBM HostBoot Licensed Internal Code
- *
- * The source code for this program is not published or other-
- * wise divested of its trade secrets, irrespective of what has
- * been deposited with the U.S. Copyright Office.
- *
- * Origin: 30
- *
- * IBM_PROLOG_END_TAG
- */
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/hwas/hwasPlat.C $ */
+/* */
+/* IBM CONFIDENTIAL */
+/* */
+/* COPYRIGHT International Business Machines Corp. 2012,2013 */
+/* */
+/* p1 */
+/* */
+/* Object Code Only (OCO) source materials */
+/* Licensed Internal Code Source Materials */
+/* IBM HostBoot Licensed Internal Code */
+/* */
+/* The source code for this program is not published or otherwise */
+/* divested of its trade secrets, irrespective of what has been */
+/* deposited with the U.S. Copyright Office. */
+/* */
+/* Origin: 30 */
+/* */
+/* IBM_PROLOG_END_TAG */
/**
* @file hwasPlat.C
*
@@ -35,6 +34,7 @@
#include <initservice/taskargs.H>
#include <mvpd/mvpdenums.H>
#include <stdio.h>
+#include <sys/mm.h>
#include <pnor/pnorif.H>
@@ -221,42 +221,70 @@ errlHndl_t platPresenceDetect(TargetHandleList &io_targets)
} // platPresenceDetect
-
-
-//******************************************************************************
-// platGetGardPnorAddr function
-//******************************************************************************
-errlHndl_t platGetGardPnorAddr(void *& o_addr,uint64_t &o_size)
+GardAddress::GardAddress(bool &o_gardEnabled)
{
- errlHndl_t errl = NULL;
+ DeconfigGard::GardRecord *l_addr = HWAS::theDeconfigGard().iv_pGardRecords;
+ HWAS_INF("GardAddress ctor: iv_pGardRecords %p", l_addr);
+ o_gardEnabled = true;
- do
+ // if this is the first time thru here, get the PNOR address.
+ if (l_addr == NULL)
{
-#if 0
- //TODO: RTC 37739
PNOR::SectionInfo_t l_section;
+ errlHndl_t errl;
errl = PNOR::getSectionInfo(PNOR::GUARD_DATA, PNOR::CURRENT_SIDE,
- l_section);
+ l_section);
if (errl)
{
- // TODO: do the malloc and store it locally?
- break;
+ HWAS_ERR("PNOR::getSectionInfo failed!!!");
+ // no support for GARD in this configuration.
+ // Commit the log as unrecoverable and keep going.
+ errlCommit(errl, HWAS_COMP_ID);
+ // errl is now NULL
+
+ // set flag so that we don't continue to try to write GARD records
+ o_gardEnabled = false;
}
+ else
+ {
+ l_addr = reinterpret_cast<DeconfigGard::GardRecord *>
+ (l_section.vaddr);
+ HWAS_DBG("PNOR vaddr=%p size=%d", l_section.vaddr, l_section.size);
- o_addr = reinterpret_cast<void *>(l_section.vaddr);
- o_size = l_section.size;
-#else
- // just use a buffer instead of PNOR
- o_size = 20 * sizeof(DeconfigGard::GardRecord);
- o_addr = malloc(o_size);
- memset(o_addr, EMPTY_GARD_VALUE, o_size);
-#endif
+ // 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("GARD in PNOR: addr=%p, size=%d", o_addr, o_size);
+ HWAS_INF("GardAddress iv_pGardRecords=%p", l_addr);
}
- while (0);
+}
- return errl;
-} // platGetGardPnorAddr
+
+GardAddress::~GardAddress()
+{
+ // flush PNOR iff we wrote
+ if (iv_addr.size() > 0)
+ {
+ for (std::vector<void *>::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();
+ }
+}
} // namespace HWAS
diff --git a/src/usr/hwas/test/hwasGardTest.H b/src/usr/hwas/test/hwasGardTest.H
index d195899a1..575b246db 100644
--- a/src/usr/hwas/test/hwasGardTest.H
+++ b/src/usr/hwas/test/hwasGardTest.H
@@ -5,7 +5,7 @@
/* */
/* IBM CONFIDENTIAL */
/* */
-/* COPYRIGHT International Business Machines Corp. 2011,2012 */
+/* COPYRIGHT International Business Machines Corp. 2011,2013 */
/* */
/* p1 */
/* */
@@ -353,7 +353,8 @@ public:
errlHndl_t l_pErr = NULL;
HWAS::DeconfigGard::GardRecords_t l_records;
- l_pErr = HWAS::theDeconfigGard().getGardRecords(0, l_records);
+ l_pErr = HWAS::theDeconfigGard().getGardRecords(
+ HWAS::DeconfigGard::GET_ALL_GARD_RECORDS, l_records);
if (l_pErr)
{
@@ -853,7 +854,8 @@ public:
do
{
// Get all existing GARD Records
- l_pErr = HWAS::theDeconfigGard().getGardRecords(0, l_records);
+ l_pErr = HWAS::theDeconfigGard().getGardRecords(
+ HWAS::DeconfigGard::GET_ALL_GARD_RECORDS, l_records);
if (l_pErr)
{
@@ -892,7 +894,8 @@ public:
}
// Clear all GARD Records
- l_pErr = HWAS::theDeconfigGard().clearGardRecords(0);
+ l_pErr = HWAS::theDeconfigGard().clearGardRecords(
+ HWAS::DeconfigGard::CLEAR_ALL_GARD_RECORDS);
if (l_pErr)
{
@@ -903,7 +906,8 @@ public:
// Get the GARD Records
l_records.clear();
- l_pErr = HWAS::theDeconfigGard().getGardRecords(0, l_records);
+ l_pErr = HWAS::theDeconfigGard().getGardRecords(
+ HWAS::DeconfigGard::GET_ALL_GARD_RECORDS, l_records);
if (l_pErr)
{
OpenPOWER on IntegriCloud