diff options
author | Corey Swenson <cswenson@us.ibm.com> | 2013-05-29 12:41:40 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2013-07-10 16:22:56 -0500 |
commit | 3837a7143776c6ea55fcda737e3425860c75a28c (patch) | |
tree | beb0237c0d0853724a05ab77adb062915a89c82a /src | |
parent | b035c67e8f54336b31b5586f6f92ca7aba0fa130 (diff) | |
download | talos-hostboot-3837a7143776c6ea55fcda737e3425860c75a28c.tar.gz talos-hostboot-3837a7143776c6ea55fcda737e3425860c75a28c.zip |
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 <iawillia@us.ibm.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/include/usr/hwpf/fapi/fapiAttributeService.H | 2 | ||||
-rw-r--r-- | src/include/usr/hwpf/fapi/fapiErrorInfo.H | 73 | ||||
-rw-r--r-- | src/include/usr/hwpf/fapi/fapiReturnCode.H | 4 | ||||
-rw-r--r-- | src/include/usr/hwpf/fapi/fapiReturnCodeDataRef.H | 62 | ||||
-rw-r--r-- | src/include/usr/hwpf/fapi/fapiUtil.H | 6 | ||||
-rw-r--r-- | src/include/usr/hwpf/plat/fapiPlatUtil.H | 3 | ||||
-rw-r--r-- | src/usr/hwpf/fapi/fapiErrorInfo.C | 94 | ||||
-rw-r--r-- | src/usr/hwpf/fapi/fapiReturnCode.C | 9 | ||||
-rw-r--r-- | src/usr/hwpf/fapi/fapiReturnCodeDataRef.C | 65 | ||||
-rw-r--r-- | src/usr/hwpf/fapi/fapiTarget.C | 24 | ||||
-rw-r--r-- | src/usr/hwpf/plat/fapiPlatTarget.C | 19 | ||||
-rw-r--r-- | src/usr/hwpf/plat/fapiPlatUtil.C | 2 |
12 files changed, 288 insertions, 75 deletions
diff --git a/src/include/usr/hwpf/fapi/fapiAttributeService.H b/src/include/usr/hwpf/fapi/fapiAttributeService.H index 3c6b0dff4..cc98b5778 100644 --- a/src/include/usr/hwpf/fapi/fapiAttributeService.H +++ b/src/include/usr/hwpf/fapi/fapiAttributeService.H @@ -137,7 +137,7 @@ ReturnCode fapiGetInitFileAttr(const AttributeId i_id, * This is called by FAPI code to check at compile time that a FAPI attribute * access is using the correct data type and a valid AttributeId */ -template<typename T> void fapiCheckIdType(AttributeId, T &) {} +template<typename T> inline void fapiCheckIdType(AttributeId, T &) {} /** * @brief Fail if attribute privileged diff --git a/src/include/usr/hwpf/fapi/fapiErrorInfo.H b/src/include/usr/hwpf/fapi/fapiErrorInfo.H index 336552957..60c0b29f0 100644 --- a/src/include/usr/hwpf/fapi/fapiErrorInfo.H +++ b/src/include/usr/hwpf/fapi/fapiErrorInfo.H @@ -133,6 +133,25 @@ public: */ uint32_t getFfdcId() {return iv_ffdcId;} +#ifdef FAPI_CUSTOM_MALLOC + /** + * @brief Overload new operator to use platform-specific allocator + * + * @param[in] i_sz Size of memory to allocate in bytes + * + * @return Pointer to allocated memory + */ + static void * operator new(size_t i_sz); + + /** + * @brief Overload delete operator to use platform-specific deallocator + * + * @param[in] i_ptr Pointer to memory previously allocated with new + */ + static void operator delete(void * i_ptr); +#endif + + private: // FFDC Identifier @@ -166,6 +185,24 @@ struct ErrorInfoProcedureCallout const ProcedureCallouts::ProcedureCallout i_procedure, const CalloutPriorities::CalloutPriority i_calloutPriority); +#ifdef FAPI_CUSTOM_MALLOC + /** + * @brief Overload new operator to use platform-specific allocator + * + * @param[in] i_sz Size of memory to allocate in bytes + * + * @return Pointer to allocated memory + */ + static void * operator new(size_t i_sz); + + /** + * @brief Overload delete operator to use platform-specific deallocator + * + * @param[in] i_ptr Pointer to memory previously allocated with new + */ + static void operator delete(void * i_ptr); +#endif + // The procedure to callout ProcedureCallouts::ProcedureCallout iv_procedure; @@ -222,6 +259,24 @@ struct ErrorInfoCDG const bool i_gard, const CalloutPriorities::CalloutPriority i_priority); +#ifdef FAPI_CUSTOM_MALLOC + /** + * @brief Overload new operator to use platform-specific allocator + * + * @param[in] i_sz Size of memory to allocate in bytes + * + * @return Pointer to allocated memory + */ + static void * operator new(size_t i_sz); + + /** + * @brief Overload delete operator to use platform-specific deallocator + * + * @param[in] i_ptr Pointer to memory previously allocated with new + */ + static void operator delete(void * i_ptr); +#endif + // The target to callout/deconfigure/GARD Target iv_target; @@ -290,6 +345,24 @@ struct ErrorInfo */ ~ErrorInfo(); +#ifdef FAPI_CUSTOM_MALLOC + /** + * @brief Overload new operator to use platform-specific allocator + * + * @param[in] i_sz Size of memory to allocate in bytes + * + * @return Pointer to allocated memory + */ + static void * operator new(size_t i_sz); + + /** + * @brief Overload delete operator to use platform-specific deallocator + * + * @param[in] i_ptr Pointer to memory previously allocated with new + */ + static void operator delete(void * i_ptr); +#endif + // Vector of FFDC Data std::vector<ErrorInfoFfdc *> iv_ffdcs; typedef std::vector<ErrorInfoFfdc *>::iterator ErrorInfoFfdcItr_t; diff --git a/src/include/usr/hwpf/fapi/fapiReturnCode.H b/src/include/usr/hwpf/fapi/fapiReturnCode.H index 957aee200..08756293d 100644 --- a/src/include/usr/hwpf/fapi/fapiReturnCode.H +++ b/src/include/usr/hwpf/fapi/fapiReturnCode.H @@ -534,7 +534,7 @@ namespace ReturnCodeFfdc * @return uint16_t. Size of the FFDC data */ template<typename T> - uint16_t getErrorInfoFfdcSize(const T &) + inline uint16_t getErrorInfoFfdcSize(const T &) { checkFfdcSize<(sizeof(T) > EI_FFDC_MAX_SIZE)>(); return sizeof(T); @@ -568,7 +568,7 @@ namespace ReturnCodeFfdc */ class Error_PtrPassedToGetErrorInfoFfdcSize; template<typename T> - int16_t getErrorInfoFfdcSize(const T *) + inline int16_t getErrorInfoFfdcSize(const T *) { Error_PtrPassedToGetErrorInfoFfdcSize(); return 0; diff --git a/src/include/usr/hwpf/fapi/fapiReturnCodeDataRef.H b/src/include/usr/hwpf/fapi/fapiReturnCodeDataRef.H index f0a6b5146..94f04618a 100644 --- a/src/include/usr/hwpf/fapi/fapiReturnCodeDataRef.H +++ b/src/include/usr/hwpf/fapi/fapiReturnCodeDataRef.H @@ -1,25 +1,25 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: src/include/usr/hwpf/fapi/fapiReturnCodeDataRef.H $ -// -// IBM CONFIDENTIAL -// -// COPYRIGHT International Business Machines Corp. 2011 -// -// 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 +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/hwpf/fapi/fapiReturnCodeDataRef.H $ */ +/* */ +/* 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.H * @@ -131,6 +131,24 @@ public: */ ErrorInfo & getCreateErrorInfo(); +#ifdef FAPI_CUSTOM_MALLOC + /** + * @brief Overload new operator to use platform-specific allocator + * + * @param[in] i_sz Size of memory to allocate in bytes + * + * @return Pointer to allocated memory + */ + static void * operator new(size_t i_sz); + + /** + * @brief Overload delete operator to use platform-specific deallocator + * + * @param[in] i_ptr Pointer to memory previously allocated with new + */ + static void operator delete(void * i_ptr); +#endif + private: /** diff --git a/src/include/usr/hwpf/fapi/fapiUtil.H b/src/include/usr/hwpf/fapi/fapiUtil.H index 6b5a9e3fb..fa7728271 100644 --- a/src/include/usr/hwpf/fapi/fapiUtil.H +++ b/src/include/usr/hwpf/fapi/fapiUtil.H @@ -5,7 +5,7 @@ /* */ /* IBM CONFIDENTIAL */ /* */ -/* COPYRIGHT International Business Machines Corp. 2011,2012 */ +/* COPYRIGHT International Business Machines Corp. 2011,2013 */ /* */ /* p1 */ /* */ @@ -70,6 +70,10 @@ #define FAPI_HTOBE64(x) FAPI_PLAT_HTOBE64(x) #define FAPI_HTOLE64(x) FAPI_PLAT_HTOLE64(x) +// Defines for platform-specific memory allocation +#define fapiMalloc(s) fapiPlatMalloc(s) +#define fapiFree(p) fapiPlatFree(p) + // It is an eCMD requirement that these functions have a "C" symbol // because they may be used from a dynamically linked shared library extern "C" diff --git a/src/include/usr/hwpf/plat/fapiPlatUtil.H b/src/include/usr/hwpf/plat/fapiPlatUtil.H index 41c2fd124..a27bc140b 100644 --- a/src/include/usr/hwpf/plat/fapiPlatUtil.H +++ b/src/include/usr/hwpf/plat/fapiPlatUtil.H @@ -39,6 +39,7 @@ #define FAPIPLATUTIL_H_ #include <endian.h> +#include <stdlib.h> // defines for endian conversion #define FAPI_PLAT_BE16TOH(x) be16toh(x) @@ -56,5 +57,7 @@ #define FAPI_PLAT_HTOBE64(x) htobe64(x) #define FAPI_PLAT_HTOLE64(x) htole64(x) +#define fapiPlatMalloc(s) malloc(s) +#define fapiPlatFree(p) free(p) #endif // FAPIPLATUTIL_H_ 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 <fapiErrorInfo.H> #include <string.h> +#include <fapiUtil.H> 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<uint8_t *>(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; } @@ -80,6 +89,26 @@ const void * ErrorInfoFfdc::getData(uint32_t & o_size) const } //****************************************************************************** +// 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 //****************************************************************************** ErrorInfoProcedureCallout::ErrorInfoProcedureCallout( @@ -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 @@ -118,6 +166,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 //****************************************************************************** ErrorInfoChildrenCDG::ErrorInfoChildrenCDG( @@ -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 <fapiReturnCodeDataRef.H> #include <fapiPlatTrace.H> #include <fapiTarget.H> +#include <fapiUtil.H> namespace fapi { @@ -251,7 +252,9 @@ void ReturnCode::addErrorInfo(const void * const * i_pObjects, const ecmdDataBufferBase * l_pDb = static_cast<const ecmdDataBufferBase *>(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<uint32_t*>(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 <fapiTarget.H> +#include <fapiUtil.H> 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<char(*)[fapi::MAX_ECMD_STRING_LEN]> - (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 <fapiTarget.H> #include <fapiPlatTrace.H> +#include <fapiUtil.H> #include <targeting/common/attributes.H> #include <string.h> @@ -73,6 +74,24 @@ void Target::deleteHandle() } //****************************************************************************** +// Get the ecmd-format string +//****************************************************************************** +const char * Target::toEcmdString() const +{ + if (iv_pEcmdString == NULL) + { + iv_pEcmdString = reinterpret_cast<char(*)>( + fapiMalloc(fapi::MAX_ECMD_STRING_LEN * sizeof(char))); + char (&l_ecmdString)[fapi::MAX_ECMD_STRING_LEN] = + *(reinterpret_cast<char(*)[fapi::MAX_ECMD_STRING_LEN]> + (iv_pEcmdString)); + toString(l_ecmdString); + } + + return iv_pEcmdString; +} + +//****************************************************************************** // Get the ECMD String //****************************************************************************** void Target::toString(char (&o_ecmdString)[MAX_ECMD_STRING_LEN]) const 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 */ /* */ |