From bb6dc0455116376808c3bc090ceb58d80c9d7a90 Mon Sep 17 00:00:00 2001 From: "Richard J. Knight" Date: Wed, 6 Sep 2017 11:59:01 -0500 Subject: Add prototype for releasing platform data pointer storage function Change-Id: I94dbc2125a2c8e0a75f35df067f14c4ca01463d0 CQ:SW401034 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/45718 Tested-by: FSP CI Jenkins Tested-by: Jenkins Server Tested-by: HWSV CI Tested-by: PPE CI Tested-by: Hostboot CI Reviewed-by: Sachin Gupta Reviewed-by: Jennifer A. Stofer Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/45727 Tested-by: Jenkins OP Build CI Tested-by: Jenkins OP HW Reviewed-by: Christian R. Geddes --- src/import/hwpf/fapi2/include/collect_reg_ffdc.H | 10 +++++++++ src/import/hwpf/fapi2/include/ffdc.H | 10 ++++++--- src/import/hwpf/fapi2/include/utils.H | 8 ++++++- src/usr/fapi2/plat_utils.C | 12 +++++++++- src/usr/fapi2/test/fapi2CreatePlatLogTest.H | 28 ++++++++++++++++++++++-- 5 files changed, 61 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/import/hwpf/fapi2/include/collect_reg_ffdc.H b/src/import/hwpf/fapi2/include/collect_reg_ffdc.H index bf62d7b25..aa5dd5176 100644 --- a/src/import/hwpf/fapi2/include/collect_reg_ffdc.H +++ b/src/import/hwpf/fapi2/include/collect_reg_ffdc.H @@ -382,6 +382,12 @@ ReturnCode collectRegisterData(std::vector& 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 { @@ -418,6 +424,10 @@ ReturnCode collectRegisterAndAddressData(std::vector& 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 { diff --git a/src/import/hwpf/fapi2/include/ffdc.H b/src/import/hwpf/fapi2/include/ffdc.H index 28976a44c..48a8979bd 100644 --- a/src/import/hwpf/fapi2/include/ffdc.H +++ b/src/import/hwpf/fapi2/include/ffdc.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015,2016 */ +/* Contributors Listed Below - COPYRIGHT 2015,2018 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -142,7 +142,7 @@ class FirstFailureData inline void* releaseData(void) { void* l_pData = iv_info; - iv_info = NULL; + iv_info = nullptr; return l_pData; } @@ -213,7 +213,11 @@ class FirstFailureData /// inline void* getPlatDataPtr() { - return iv_platDataPtr; + void* l_platDataPtr = iv_platDataPtr; + + iv_platDataPtr = nullptr; + + return l_platDataPtr; }; /// diff --git a/src/import/hwpf/fapi2/include/utils.H b/src/import/hwpf/fapi2/include/utils.H index cd6a27717..8534d3bdb 100644 --- a/src/import/hwpf/fapi2/include/utils.H +++ b/src/import/hwpf/fapi2/include/utils.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015,2017 */ +/* Contributors Listed Below - COPYRIGHT 2015,2018 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -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 /// diff --git a/src/usr/fapi2/plat_utils.C b/src/usr/fapi2/plat_utils.C index b83eb1ec1..2825ffaa5 100644 --- a/src/usr/fapi2/plat_utils.C +++ b/src/usr/fapi2/plat_utils.C @@ -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) { @@ -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(io_rc.getPlatDataPtr())); +} /// /// @brief Internal Function associates PRD and HW elogs @@ -1416,6 +1424,8 @@ void set_log_id( const Target& i_fapiTrgt, errlHndl_t errl = reinterpret_cast(io_rc.getPlatDataPtr()); uint32_t plid = ERRL_GETPLID_SAFE(errl); + io_rc.setPlatDataPtr(reinterpret_cast(errl)); + // Set the PLID in this attribute. if ( ! attrTrgt->trySetAttr(plid) ) { diff --git a/src/usr/fapi2/test/fapi2CreatePlatLogTest.H b/src/usr/fapi2/test/fapi2CreatePlatLogTest.H index 3cccd74c1..99d71354c 100644 --- a/src/usr/fapi2/test/fapi2CreatePlatLogTest.H +++ b/src/usr/fapi2/test/fapi2CreatePlatLogTest.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2018 */ +/* Contributors Listed Below - COPYRIGHT 2017,2018 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -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(l_rc.getPlatDataPtr()); @@ -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(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()); } @@ -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(l_errl)); + createPlatLog(l_rc, l_sev); l_errl = reinterpret_cast(l_rc.getPlatDataPtr()); if(l_errl->sev() != ERRORLOG::ERRL_SEV_PREDICTIVE) @@ -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(l_errl)); + createPlatLog(l_rc, l_sev); l_errl = reinterpret_cast(l_rc.getPlatDataPtr()); if(l_errl->sev() != ERRORLOG::ERRL_SEV_UNRECOVERABLE) @@ -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(l_rc.getPlatDataPtr()); @@ -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(l_rc.getPlatDataPtr()); -- cgit v1.2.1