From 3837a7143776c6ea55fcda737e3425860c75a28c Mon Sep 17 00:00:00 2001 From: Corey Swenson Date: Wed, 29 May 2013 12:41:40 -0500 Subject: FAPI updates from HostServices Change-Id: I0d8f0fb43ead61a8a37f7f9ca7be12efec09e144 RTC: 52953 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/4738 Tested-by: Jenkins Server Reviewed-by: A. Patrick Williams III --- src/usr/hwpf/fapi/fapiErrorInfo.C | 94 ++++++++++++++++++++++++++++++- src/usr/hwpf/fapi/fapiReturnCode.C | 9 ++- src/usr/hwpf/fapi/fapiReturnCodeDataRef.C | 65 +++++++++++++-------- src/usr/hwpf/fapi/fapiTarget.C | 24 ++------ src/usr/hwpf/plat/fapiPlatTarget.C | 19 +++++++ src/usr/hwpf/plat/fapiPlatUtil.C | 2 +- 6 files changed, 164 insertions(+), 49 deletions(-) (limited to 'src/usr') diff --git a/src/usr/hwpf/fapi/fapiErrorInfo.C b/src/usr/hwpf/fapi/fapiErrorInfo.C index 237be79a5..ce2107dfb 100644 --- a/src/usr/hwpf/fapi/fapiErrorInfo.C +++ b/src/usr/hwpf/fapi/fapiErrorInfo.C @@ -45,6 +45,7 @@ #include #include +#include namespace fapi { @@ -57,8 +58,16 @@ ErrorInfoFfdc::ErrorInfoFfdc(const uint32_t i_ffdcId, const uint32_t i_size) : iv_ffdcId(i_ffdcId), iv_size(i_size) { - iv_pFfdc = new uint8_t[i_size]; - memcpy(iv_pFfdc, i_pFfdc, i_size); + iv_pFfdc = reinterpret_cast(fapiMalloc(i_size)); + if(iv_pFfdc != NULL) + { + memcpy(iv_pFfdc, i_pFfdc, i_size); + } + else + { + FAPI_ERR("ErrorInfoFfdc - could not allocate storage"); + iv_size = 0; + } } //****************************************************************************** @@ -66,7 +75,7 @@ ErrorInfoFfdc::ErrorInfoFfdc(const uint32_t i_ffdcId, //****************************************************************************** ErrorInfoFfdc::~ErrorInfoFfdc() { - delete [] iv_pFfdc; + fapiFree(iv_pFfdc); iv_pFfdc = NULL; } @@ -79,6 +88,26 @@ const void * ErrorInfoFfdc::getData(uint32_t & o_size) const return iv_pFfdc; } +//****************************************************************************** +// ErrorInfoFfdc new Operator Overload +//****************************************************************************** +#ifdef FAPI_CUSTOM_MALLOC +void * ErrorInfoFfdc::operator new(size_t i_sz) +{ + return fapiMalloc(i_sz); +} +#endif + +//****************************************************************************** +// ErrorInfoFfdc delete Operator Overload +//****************************************************************************** +#ifdef FAPI_CUSTOM_MALLOC +void ErrorInfoFfdc::operator delete(void * i_ptr) +{ + fapiFree(i_ptr); +} +#endif + //****************************************************************************** // ErrorInfoProcedureCallout Constructor //****************************************************************************** @@ -100,8 +129,27 @@ ErrorInfoBusCallout::ErrorInfoBusCallout( : iv_target1(i_target1), iv_target2(i_target2), iv_calloutPriority(i_calloutPriority) { +} +//****************************************************************************** +// ErrorInfoProcedureCallout new Operator Overload +//****************************************************************************** +#ifdef FAPI_CUSTOM_MALLOC +void * ErrorInfoProcedureCallout::operator new(size_t i_sz) +{ + return fapiMalloc(i_sz); } +#endif + +//****************************************************************************** +// ErrorInfoProcedureCallout delete Operator Overload +//****************************************************************************** +#ifdef FAPI_CUSTOM_MALLOC +void ErrorInfoProcedureCallout::operator delete(void * i_ptr) +{ + fapiFree(i_ptr); +} +#endif //****************************************************************************** // ErrorInfoCDG Constructor @@ -117,6 +165,26 @@ ErrorInfoCDG::ErrorInfoCDG(const Target & i_target, } +//****************************************************************************** +// ErrorInfoCDG new Operator Overload +//****************************************************************************** +#ifdef FAPI_CUSTOM_MALLOC +void * ErrorInfoCDG::operator new(size_t i_sz) +{ + return fapiMalloc(i_sz); +} +#endif + +//****************************************************************************** +// ErrorInfoCDG delete Operator Overload +//****************************************************************************** +#ifdef FAPI_CUSTOM_MALLOC +void ErrorInfoCDG::operator delete(void * i_ptr) +{ + fapiFree(i_ptr); +} +#endif + //****************************************************************************** // ErrorInfoChildrenCDG Constructor //****************************************************************************** @@ -161,4 +229,24 @@ ErrorInfo::~ErrorInfo() } } +//****************************************************************************** +// ErrorInfo new Operator Overload +//****************************************************************************** +#ifdef FAPI_CUSTOM_MALLOC +void * ErrorInfo::operator new(size_t i_sz) +{ + return fapiMalloc(i_sz); +} +#endif + +//****************************************************************************** +// ErrorInfo delete Operator Overload +//****************************************************************************** +#ifdef FAPI_CUSTOM_MALLOC +void ErrorInfo::operator delete(void * i_ptr) +{ + fapiFree(i_ptr); +} +#endif + } diff --git a/src/usr/hwpf/fapi/fapiReturnCode.C b/src/usr/hwpf/fapi/fapiReturnCode.C index 2b15a82f6..6d42b44f5 100644 --- a/src/usr/hwpf/fapi/fapiReturnCode.C +++ b/src/usr/hwpf/fapi/fapiReturnCode.C @@ -57,6 +57,7 @@ #include #include #include +#include namespace fapi { @@ -251,7 +252,9 @@ void ReturnCode::addErrorInfo(const void * const * i_pObjects, const ecmdDataBufferBase * l_pDb = static_cast(l_pObject); - uint32_t * l_pData = new uint32_t[l_pDb->getWordLength()]; + size_t byteLength = l_pDb->getWordLength() * sizeof(uint32_t); + uint32_t * l_pData = + reinterpret_cast(fapiMalloc(byteLength)); // getWordLength rounds up to the next 32bit boundary, ensure // that after extracting, any unset bits are zero @@ -261,7 +264,7 @@ void ReturnCode::addErrorInfo(const void * const * i_pObjects, l_pDb->extract(l_pData, 0, l_pDb->getBitLength()); addEIFfdc(l_ffdcId, l_pData, (l_pDb->getWordLength() * 4)); - delete [] l_pData; + fapiFree(l_pData); } else if (l_size == ReturnCodeFfdc::EI_FFDC_SIZE_TARGET) { @@ -371,6 +374,8 @@ void ReturnCode::addEIFfdc(const uint32_t i_ffdcId, ErrorInfoFfdc * l_pFfdc = new ErrorInfoFfdc(i_ffdcId, i_pFfdc, i_size); getCreateReturnCodeDataRef().getCreateErrorInfo(). iv_ffdcs.push_back(l_pFfdc); + + // Note: This gets deallocated in ~ErrorInfo() } diff --git a/src/usr/hwpf/fapi/fapiReturnCodeDataRef.C b/src/usr/hwpf/fapi/fapiReturnCodeDataRef.C index ac7df403b..8272afbd7 100644 --- a/src/usr/hwpf/fapi/fapiReturnCodeDataRef.C +++ b/src/usr/hwpf/fapi/fapiReturnCodeDataRef.C @@ -1,26 +1,25 @@ -/* IBM_PROLOG_BEGIN_TAG - * This is an automatically generated prolog. - * - * $Source: src/usr/hwpf/fapi/fapiReturnCodeDataRef.C $ - * - * IBM CONFIDENTIAL - * - * COPYRIGHT International Business Machines Corp. 2011-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/hwpf/fapi/fapiReturnCodeDataRef.C $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2011,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 fapiReturnCodeDataRef.C * @@ -155,4 +154,24 @@ ErrorInfo & ReturnCodeDataRef::getCreateErrorInfo() return *iv_pErrorInfo; } +//****************************************************************************** +// Overload Operator new function +//****************************************************************************** +#ifdef FAPI_CUSTOM_MALLOC +void * ReturnCodeDataRef::operator new(size_t i_sz) +{ + return fapiMalloc(i_sz); +} +#endif + +//****************************************************************************** +// Overload Operator delete function +//****************************************************************************** +#ifdef FAPI_CUSTOM_MALLOC +void ReturnCodeDataRef::operator delete(void * i_ptr) +{ + fapiFree(i_ptr); +} +#endif + } diff --git a/src/usr/hwpf/fapi/fapiTarget.C b/src/usr/hwpf/fapi/fapiTarget.C index e1b901e61..0608ee2ac 100644 --- a/src/usr/hwpf/fapi/fapiTarget.C +++ b/src/usr/hwpf/fapi/fapiTarget.C @@ -40,6 +40,7 @@ */ #include +#include namespace fapi { @@ -78,7 +79,7 @@ Target::Target(const Target & i_right) : Target::~Target() { (void) deleteHandle(); - delete [] iv_pEcmdString; + fapiFree(iv_pEcmdString); } //****************************************************************************** @@ -91,7 +92,7 @@ Target & Target::operator=(const Target & i_right) { iv_type = i_right.iv_type; (void) copyHandle(i_right); - delete [] iv_pEcmdString; + fapiFree(iv_pEcmdString); iv_pEcmdString = NULL; } return *this; @@ -127,7 +128,7 @@ bool Target::operator!=(const Target & i_right) const void Target::set(void * i_pHandle) { iv_pHandle = i_pHandle; - delete [] iv_pEcmdString; + fapiFree(iv_pEcmdString); iv_pEcmdString = NULL; } @@ -152,21 +153,4 @@ bool Target::isChiplet() const TARGET_TYPE_L4 )) != 0); } -//****************************************************************************** -// Get the ecmd-format string -//****************************************************************************** -const char * Target::toEcmdString() const -{ - if (iv_pEcmdString == NULL) - { - iv_pEcmdString = new char[fapi::MAX_ECMD_STRING_LEN]; - char (&l_ecmdString)[fapi::MAX_ECMD_STRING_LEN] = - *(reinterpret_cast - (iv_pEcmdString)); - toString(l_ecmdString); - } - - return iv_pEcmdString; -} - } diff --git a/src/usr/hwpf/plat/fapiPlatTarget.C b/src/usr/hwpf/plat/fapiPlatTarget.C index bff705233..01b4f03f7 100644 --- a/src/usr/hwpf/plat/fapiPlatTarget.C +++ b/src/usr/hwpf/plat/fapiPlatTarget.C @@ -38,6 +38,7 @@ #include #include +#include #include #include @@ -72,6 +73,24 @@ void Target::deleteHandle() // Intentionally does nothing. The component must not be deleted } +//****************************************************************************** +// Get the ecmd-format string +//****************************************************************************** +const char * Target::toEcmdString() const +{ + if (iv_pEcmdString == NULL) + { + iv_pEcmdString = reinterpret_cast( + fapiMalloc(fapi::MAX_ECMD_STRING_LEN * sizeof(char))); + char (&l_ecmdString)[fapi::MAX_ECMD_STRING_LEN] = + *(reinterpret_cast + (iv_pEcmdString)); + toString(l_ecmdString); + } + + return iv_pEcmdString; +} + //****************************************************************************** // Get the ECMD String //****************************************************************************** diff --git a/src/usr/hwpf/plat/fapiPlatUtil.C b/src/usr/hwpf/plat/fapiPlatUtil.C index ae447881a..1b8575c9e 100644 --- a/src/usr/hwpf/plat/fapiPlatUtil.C +++ b/src/usr/hwpf/plat/fapiPlatUtil.C @@ -5,7 +5,7 @@ /* */ /* IBM CONFIDENTIAL */ /* */ -/* COPYRIGHT International Business Machines Corp. 2011,2012 */ +/* COPYRIGHT International Business Machines Corp. 2011,2013 */ /* */ /* p1 */ /* */ -- cgit v1.2.3