Skip to content

Commit

Permalink
Add prototype for releasing platform data pointer storage function
Browse files Browse the repository at this point in the history
Change-Id: I94dbc2125a2c8e0a75f35df067f14c4ca01463d0
CQ:SW401034
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/45718
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: HWSV CI <hwsv-ci+hostboot@us.ibm.com>
Tested-by: PPE CI <ppe-ci+hostboot@us.ibm.com>
Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com>
Reviewed-by: Sachin Gupta <sgupta2m@in.ibm.com>
Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com>
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/45727
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com>
  • Loading branch information
rjknight authored and crgeddes committed Sep 6, 2018
1 parent fd77849 commit bb6dc04
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 7 deletions.
10 changes: 10 additions & 0 deletions src/import/hwpf/fapi2/include/collect_reg_ffdc.H
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,12 @@ ReturnCode collectRegisterData(std::vector<T>& i_addresses, U& i_reader,
if(l_rc)
{
l_data = 0xbaddbadd;

#ifdef __DELETE_PLATFORMDATA_SUPPORTED
// delete the platform log if it exits
deletePlatformDataPointer(l_rc);
#endif

}
else
{
Expand Down Expand Up @@ -418,6 +424,10 @@ ReturnCode collectRegisterAndAddressData(std::vector<T>& i_addresses, U& i_reade
if(l_rc)
{
l_data = 0xbaddbadd;
#ifdef __DELETE_PLATFORMDATA_SUPPORTED
// delete the platform data pointer if it exists
deletePlatformDataPointer(l_rc);
#endif
}
else
{
Expand Down
10 changes: 7 additions & 3 deletions src/import/hwpf/fapi2/include/ffdc.H
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2015,2016 */
/* Contributors Listed Below - COPYRIGHT 2015,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -142,7 +142,7 @@ class FirstFailureData
inline void* releaseData(void)
{
void* l_pData = iv_info;
iv_info = NULL;
iv_info = nullptr;
return l_pData;
}

Expand Down Expand Up @@ -213,7 +213,11 @@ class FirstFailureData
///
inline void* getPlatDataPtr()
{
return iv_platDataPtr;
void* l_platDataPtr = iv_platDataPtr;

iv_platDataPtr = nullptr;

return l_platDataPtr;
};

///
Expand Down
8 changes: 7 additions & 1 deletion src/import/hwpf/fapi2/include/utils.H
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2015,2017 */
/* Contributors Listed Below - COPYRIGHT 2015,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -129,6 +129,12 @@ void createPlatLog(
fapi2::errlSeverity_t i_sev = fapi2::FAPI2_ERRL_SEV_UNRECOVERABLE
);

///
/// @brief delete platform data ptr - free platform data from the
// passed in RC.
///
void deletePlatformDataPointer(fapi2::ReturnCode& io_rc);

///
/// @brief Associate an error to PRD PLID
///
Expand Down
12 changes: 11 additions & 1 deletion src/usr/fapi2/plat_utils.C
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,7 @@ errlHndl_t rcToErrl(ReturnCode & io_rc,
// PLAT error, get the platform data from the return code
FAPI_ERR("rcToErrl: PLAT error: 0x%08x", l_rcValue);
}
else if (NULL == l_pError)
else if (nullptr == l_pError)
{
if (l_creator == ReturnCode::CREATOR_HWP)
{
Expand Down Expand Up @@ -1389,6 +1389,14 @@ void logError(
fapi2::current_err = fapi2::FAPI2_RC_SUCCESS;
return;
}
///
/// @brief Free platform log ptr - free a platform error from the
/// passed in RC.
///
void deletePlatformDataPointer(fapi2::ReturnCode & io_rc)
{
delete(reinterpret_cast<errlHndl_t>(io_rc.getPlatDataPtr()));
}

///
/// @brief Internal Function associates PRD and HW elogs
Expand Down Expand Up @@ -1416,6 +1424,8 @@ void set_log_id( const Target<TARGET_TYPE_ALL>& i_fapiTrgt,
errlHndl_t errl = reinterpret_cast<errlHndl_t>(io_rc.getPlatDataPtr());
uint32_t plid = ERRL_GETPLID_SAFE(errl);

io_rc.setPlatDataPtr(reinterpret_cast<void*>(errl));

// Set the PLID in this attribute.
if ( ! attrTrgt->trySetAttr<TARGETING::ATTR_PRD_HWP_PLID>(plid) )
{
Expand Down
28 changes: 26 additions & 2 deletions src/usr/fapi2/test/fapi2CreatePlatLogTest.H
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2018 */
/* Contributors Listed Below - COPYRIGHT 2017,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -59,6 +59,7 @@ public:
l_rc.forgetData();


l_rc = fapi2::FAPI2_RC_INVALID_ATTR_GET;
l_sev = fapi2::FAPI2_ERRL_SEV_PREDICTIVE;
createPlatLog(l_rc, l_sev);
l_errl = reinterpret_cast<errlHndl_t>(l_rc.getPlatDataPtr());
Expand All @@ -76,13 +77,15 @@ public:
l_rc.forgetData();


l_rc = fapi2::FAPI2_RC_INVALID_ATTR_GET;
l_sev = fapi2::FAPI2_ERRL_SEV_UNRECOVERABLE;
createPlatLog(l_rc, l_sev);
l_errl = reinterpret_cast<errlHndl_t>(l_rc.getPlatDataPtr());
if(l_errl->sev() != ERRORLOG::ERRL_SEV_UNRECOVERABLE)
{
TS_FAIL("testCreatePlatLogCreatorFapi2: incorrect errl severity. "
"Expected: %x Actual: %x",
ERRORLOG::ERRL_SEV_PREDICTIVE,
ERRORLOG::ERRL_SEV_UNRECOVERABLE,
l_errl->sev());

}
Expand Down Expand Up @@ -123,7 +126,17 @@ public:
TRACDCOMP(g_trac_runtime, "testCreatePlatLogCreatorPlat: ERRL_SEV_RECOVERED passed");
}

l_rc = fapi2::FAPI2_RC_PLAT_ERR_SEE_DATA;
l_sev = fapi2::FAPI2_ERRL_SEV_PREDICTIVE;
// Allocate a fake error log since PLAT code path expects a non-null ptr
l_errl = new ERRORLOG::ErrlEntry(
ERRORLOG::ERRL_SEV_INFORMATIONAL,
ERRORLOG::ERRL_FIRST_MODULE_ID,
fapi2::RC_HWP_GENERATED_ERROR,
ERRORLOG::ERRL_TEST_REASON_CODE);

l_rc.setPlatDataPtr(reinterpret_cast<void *>(l_errl));

createPlatLog(l_rc, l_sev);
l_errl = reinterpret_cast<errlHndl_t>(l_rc.getPlatDataPtr());
if(l_errl->sev() != ERRORLOG::ERRL_SEV_PREDICTIVE)
Expand All @@ -138,7 +151,16 @@ public:
TRACDCOMP(g_trac_runtime, "testCreatePlatLogCreatorPlat: ERRL_SEV_PREDICTIVE passed");
}

l_rc = fapi2::FAPI2_RC_PLAT_ERR_SEE_DATA;
l_sev = fapi2::FAPI2_ERRL_SEV_UNRECOVERABLE;
l_errl = new ERRORLOG::ErrlEntry(
ERRORLOG::ERRL_SEV_INFORMATIONAL,
ERRORLOG::ERRL_FIRST_MODULE_ID,
fapi2::RC_HWP_GENERATED_ERROR,
ERRORLOG::ERRL_TEST_REASON_CODE);

l_rc.setPlatDataPtr(reinterpret_cast<void *>(l_errl));

createPlatLog(l_rc, l_sev);
l_errl = reinterpret_cast<errlHndl_t>(l_rc.getPlatDataPtr());
if(l_errl->sev() != ERRORLOG::ERRL_SEV_UNRECOVERABLE)
Expand Down Expand Up @@ -179,6 +201,7 @@ public:
}
l_rc.forgetData();

l_rc = 0x00000001; // Fake return code wit creator == HWP
l_sev = fapi2::FAPI2_ERRL_SEV_PREDICTIVE;
createPlatLog(l_rc, l_sev);
l_errl = reinterpret_cast<errlHndl_t>(l_rc.getPlatDataPtr());
Expand All @@ -195,6 +218,7 @@ public:
}
l_rc.forgetData();

l_rc = 0x00000001; // Fake return code wit creator == HWP
l_sev = fapi2::FAPI2_ERRL_SEV_UNRECOVERABLE;
createPlatLog(l_rc, l_sev);
l_errl = reinterpret_cast<errlHndl_t>(l_rc.getPlatDataPtr());
Expand Down

0 comments on commit bb6dc04

Please sign in to comment.