diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/usr/errl/errlUserDetailsTarget.H | 171 | ||||
-rw-r--r-- | src/include/usr/errl/errltypes.H | 1 | ||||
-rw-r--r-- | src/include/usr/targeting/entitypath.H | 9 | ||||
-rw-r--r-- | src/include/usr/targeting/target.H | 12 | ||||
-rw-r--r-- | src/usr/errl/errlUserDetailsTarget.C | 79 | ||||
-rw-r--r-- | src/usr/errl/makefile | 2 | ||||
-rw-r--r-- | src/usr/hwpf/test/hwpftest.H | 6 | ||||
-rw-r--r-- | src/usr/targeting/entitypath.C | 43 | ||||
-rw-r--r-- | src/usr/targeting/target.C | 53 | ||||
-rw-r--r-- | src/usr/targeting/test/targetingtest.H | 34 |
10 files changed, 402 insertions, 8 deletions
diff --git a/src/include/usr/errl/errlUserDetailsTarget.H b/src/include/usr/errl/errlUserDetailsTarget.H new file mode 100644 index 000000000..e8afd9da1 --- /dev/null +++ b/src/include/usr/errl/errlUserDetailsTarget.H @@ -0,0 +1,171 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/include/usr/errl/errlUserDetailsTarget.H $ +// +// 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 +#ifndef ERRL_USERDETAILS_TARGET_H +#define ERRL_USERDETAILS_TARGET_H + +/** + * @file ErrlTarget.H + * + * Target FFDC Helper + * + * Framework defining how User Detail Data sections of error logs should + * be created and parsed. + * + * Creation methods will show up when the PARSER macro is NOT defined. + * These will compile and run under HostBoot. + * + * Parsing methods will show up when the PARSER macro IS defined. + * These will compile and run in the errl tool. + * +*/ + +/*****************************************************************************/ +// I n c l u d e s +/*****************************************************************************/ +#include <stdint.h> +#include <errl/errluserdetails.H> +#include <targeting/targetservice.H> + +namespace ERRORLOG +{ + +#ifndef PARSER + +class ErrlUserDetailsTarget : public ErrlUserDetails +{ +public: + + /** + * @brief Constructor + * + */ + ErrlUserDetailsTarget(TARGETING::Target * i_target); + + /** + * @brief Destructor + * + */ + virtual ~ErrlUserDetailsTarget(); + + /** + * @brief Adds or appends FFDC data to error log + * + * @param i_errl + * Error log handle to add detail data to. + * + * @param i_buf + * pointer to the new data buffer to be added/appended. + * + * @param i_len + * length of the new data buffer to be added/appended in bytes + * + * @return none + * + */ + void addToLog( errlHndl_t i_errl, void *i_buf, const uint32_t i_len ); + +private: + + // Disabled + ErrlUserDetailsTarget(const ErrlUserDetailsTarget &); + ErrlUserDetailsTarget & operator=(const ErrlUserDetailsTarget &); + + TARGETING::Target *iv_pTarget; +}; + +#else // (if PARSER defined) + +/** + * @brief Target FFDC Helper + * + * Framework defining how User Detail Data sections of error logs should + * be created and parsed. + * + * Creation methods will show up when the PARSER macro is NOT defined. + * These will compile and run under HostBoot. + * + * Parsing methods will show up when the PARSER macro IS defined. + * These will compile and run in the errl tool. + * +*/ + +class ErrlUserDetailsTarget : public ErrlUserDetails +{ +public: + + /** + * @brief Constructor + * + */ + ErrlUserDetailsTarget() : ErrlUserDetails() {} + + /** + * @brief Destructor + * + */ + virtual ~ErrlUserDetailsTarget() {} + + /** + * @brief Parses user detail data from an error log + * + * @param i_version + * Version of the data + * + * @param i_parse + * ErrlUsrParser object for outputting information + * + * @param i_pBuffer + * Pointer to buffer containing detail data + * + * @param i_buflen + * Length of the buffer + * + * @return None + * + */ + virtual void parse(errlver_t i_version, + ErrlUsrParser & i_parser, + const void * i_pBuffer, const uint32_t i_buflen) const + { + char * l_ptr = i_pBuffer; + for (uint32_t i = 0; i < i_buflen; ) + { + i_parser.PrintString( "", l_ptr ); + i += strlen(l_ptr) + 1; + l_ptr += strlen(l_ptr) + 1; + } + } + +private: + + // Disabled + ErrlUserDetailsTarget(const ErrlUserDetailsTarget &); + ErrlUserDetailsTarget & operator=(const ErrlUserDetailsTarget &); + +}; + +#endif + +} + +#endif diff --git a/src/include/usr/errl/errltypes.H b/src/include/usr/errl/errltypes.H index e3435eef5..ecd6e8187 100644 --- a/src/include/usr/errl/errltypes.H +++ b/src/include/usr/errl/errltypes.H @@ -273,6 +273,7 @@ enum errlTermState_t enum errlUserDataType_t { ERRL_UDT_TRACE = 0x0C, // A trace buffer + ERRL_UDT_TARGET_FFDC = 0x0D, // A target FFDC buffer }; diff --git a/src/include/usr/targeting/entitypath.H b/src/include/usr/targeting/entitypath.H index da31e0380..4e24a9410 100644 --- a/src/include/usr/targeting/entitypath.H +++ b/src/include/usr/targeting/entitypath.H @@ -421,6 +421,15 @@ class EntityPath */ void dump() const; + /** + * @brief Save the entity path as a c-string + * + * @return the dynamic buffer pointer of the c-string + * + * @note caller must call free() to release the buffer + */ + char * toString() const; + private: PATH_TYPE iv_type : 4; ///< Entity path type (4 bits) diff --git a/src/include/usr/targeting/target.H b/src/include/usr/targeting/target.H index 25a43bd48..84c8459b8 100644 --- a/src/include/usr/targeting/target.H +++ b/src/include/usr/targeting/target.H @@ -236,6 +236,18 @@ class Target "returned false",A); } + /** + * @brief Perform FFDC for the target instance + * + * @param[out] io_size + * number of bytes of buffer filled with FFDC + * + * @return pointer to dynamically allocated FFDC buffer + * + * @post caller must call free() to release the buffer + */ + char * targetFFDC( uint32_t & o_size ) const; + private: // Private helper interfaces /** diff --git a/src/usr/errl/errlUserDetailsTarget.C b/src/usr/errl/errlUserDetailsTarget.C new file mode 100644 index 000000000..ece6874bf --- /dev/null +++ b/src/usr/errl/errlUserDetailsTarget.C @@ -0,0 +1,79 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/usr/errl/errlUserDetailsTarget.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 +/*****************************************************************************/ +// I n c l u d e s +/*****************************************************************************/ +#include <hbotcompid.H> // list of compid's supported +#include <errl/errlentry.H> +#include <errl/errlUserDetailsTarget.H> +#include <targeting/targetservice.H> + +namespace ERRORLOG +{ + +//#ifndef PARSER + +// Constructor +ErrlUserDetailsTarget::ErrlUserDetailsTarget( TARGETING::Target * i_target ) : + ErrlUserDetails() +{ + iv_pTarget = i_target; +} + +// Destructor +ErrlUserDetailsTarget::~ErrlUserDetailsTarget() {} + +// @brief Add FFDC to an user detailed data section of the errorlog +// Each data is always terminated with nul-char +void ErrlUserDetailsTarget::addToLog( errlHndl_t i_errl, + void *i_buf, const uint32_t i_len ) +{ + if (i_errl != NULL) + { + if (iv_pTarget == TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL) + { + const char *l_bufPtr = "MASTER_PROCESSOR_CHIP_TARGET_SENTINEL"; + iv_pErrlFFDC = i_errl->addFFDC( ERRL_COMP_ID, + l_bufPtr, strlen(l_bufPtr)+1, + ERRL_UDV_DEFAULT_VER_1, + ERRL_UDT_TARGET_FFDC ); + } + else + { + uint32_t l_bufSize = 0; + char * l_bufPtr = NULL; + + l_bufPtr = iv_pTarget->targetFFDC( l_bufSize ); + if (l_bufPtr) + { + iv_pErrlFFDC = i_errl->addFFDC( ERRL_COMP_ID, + l_bufPtr, l_bufSize, + ERRL_UDV_DEFAULT_VER_1, + ERRL_UDT_TARGET_FFDC ); + free (l_bufPtr); + } + } + } +} + +} diff --git a/src/usr/errl/makefile b/src/usr/errl/makefile index 8020e07a9..bad776ee9 100644 --- a/src/usr/errl/makefile +++ b/src/usr/errl/makefile @@ -24,7 +24,7 @@ ROOTPATH = ../../.. MODULE = errl OBJS = errlentry.o errlmanager.o errlsctn.o errlsctnhdr.o errlprvt.o errluh.o \ - errlud.o errlsrc.o errluserdetails.o backtrace.o + errlud.o errlsrc.o errluserdetails.o backtrace.o errlUserDetailsTarget.o SUBDIRS = test.d parser.d diff --git a/src/usr/hwpf/test/hwpftest.H b/src/usr/hwpf/test/hwpftest.H index 6368e93d5..4776ea41e 100644 --- a/src/usr/hwpf/test/hwpftest.H +++ b/src/usr/hwpf/test/hwpftest.H @@ -49,7 +49,7 @@ struct hwpfTestArgs_t { ifScom_t ifScom; fapi::Target fapiTarget; uint32_t count; - tid_t tid; + tid_t tid; struct { uint64_t Write:1; // 1 = Write uint64_t AttrTest:1; // 1 = run Attr access test @@ -393,15 +393,13 @@ public: TARGETING::Target* l_pTarget = NULL; TARGETING::targetService().masterProcChipTargetHandle(l_pTarget); - // Create a FAPI Target and invoke the hwpInitialTest HWP fapi::Target l_fapiTarget(TARGET_TYPE_PROC_CHIP, reinterpret_cast<void *> (l_pTarget)); // Test ATTR_EC attribute access through FAPI uint8_t l_EC_R = 0xFF; - fapi::Target *l_pfapiTarget = &l_fapiTarget; - l_rc = FAPI_ATTR_GET(ATTR_EC, l_pfapiTarget, l_EC_R); + l_rc = FAPI_ATTR_GET(ATTR_EC, &l_fapiTarget, l_EC_R); if (l_rc != fapi::FAPI_RC_SUCCESS) { TS_FAIL("testHwpf5: ATTR_EC. Error from GET"); diff --git a/src/usr/targeting/entitypath.C b/src/usr/targeting/entitypath.C index c61ad87c3..d593937cd 100644 --- a/src/usr/targeting/entitypath.C +++ b/src/usr/targeting/entitypath.C @@ -101,7 +101,7 @@ EntityPath& EntityPath::removeLast() assert(size() >= 1, TARG_LOC "EntityPath empty (size = %d); cannot remove " "any path elements", size()); - + iv_pathElement[size() - 1].type = TYPE_NA; iv_pathElement[size() - 1].instance = 0; --iv_size; @@ -229,7 +229,7 @@ const EntityPath::PathElement& EntityPath::operator[]( assert(i_index < size(), TARG_LOC "Caller specified invalid entity path " "subscript of %d when size is only %d",i_index,size()); - + return iv_pathElement[i_index]; #undef TARG_FN @@ -250,7 +250,7 @@ const EntityPath::PathElement EntityPath::pathElementOfType( { return iv_pathElement[x]; } - } + } PathElement na_path = { TYPE_NA, 0 }; return na_path; @@ -429,6 +429,43 @@ void EntityPath::dump() const #undef TARG_FN } +//****************************************************************************** +// EntityPath::toString +//****************************************************************************** + +char * EntityPath::toString() const +{ + #define TARG_FN "toString()" + + void* l_ptr = NULL; + char* l_pString = NULL; + const char* l_ptr1 = NULL; + size_t l_len1, l_len2; + + l_ptr1 = pathTypeAsString(); + l_len1 = strlen( l_ptr1 ) + 1; // add 1 for the ':' char + // allocate extra 1 bytes for the nul char + l_pString = static_cast<char*>( malloc( l_len1 + 1 ) ); + sprintf( l_pString, "%s:", l_ptr1 ); + + for (uint32_t i=0; i < size(); ++i) + { + l_ptr1 = pathElementTypeAsString( operator[](i).type ); + l_len2 = strlen( l_ptr1 ) + 1; // add 1 for '/' char + // realloc with extra 33 bytes (more than enough) + // for the %d conversion and the nul char. + l_ptr = realloc( l_pString, (l_len1 + l_len2 + 33) ); + l_pString = static_cast<char*>( l_ptr ); + // append at the nul char of previous string + l_len2 = sprintf( l_pString + l_len1, "/%s%d", + l_ptr1, operator[](i).instance ); + l_len1 += l_len2; + } + + return (l_pString); + + #undef TARG_FN +} #undef TARG_CLASS #undef TARG_NAMESPACE diff --git a/src/usr/targeting/target.C b/src/usr/targeting/target.C index 714e614bd..10fbab4b8 100644 --- a/src/usr/targeting/target.C +++ b/src/usr/targeting/target.C @@ -178,6 +178,59 @@ Target::Target() #undef TARG_FN } +//****************************************************************************** +// Target::targetFFDC() +//****************************************************************************** + +char * Target::targetFFDC( uint32_t & o_size ) const +{ + #define TARG_FN "targetFFDC(...)" + + char l_buff[128]; + char *l_pFFDC = NULL; + char *l_ptr = NULL; + void *l_ptr1 = NULL; + uint32_t l_len; + + o_size = sprintf( l_buff, "Class = 0x%X, Type = 0x%X, Model = 0x%X", + getAttr<ATTR_CLASS>(), + getAttr<ATTR_TYPE>(), + getAttr<ATTR_MODEL>() ); + + l_pFFDC = static_cast<char*>( malloc( ++o_size ) ); + memcpy( l_pFFDC, l_buff, o_size ); + + l_ptr = getAttr<ATTR_PHYS_PATH>().toString(); + if (l_ptr) + { + l_len = strlen( l_ptr ) + 1; + l_ptr1 = realloc( l_pFFDC, o_size + l_len ); + l_pFFDC = static_cast<char*>( l_ptr1 ); + memcpy( l_pFFDC + o_size, l_ptr, l_len ); + o_size += l_len; + free( l_ptr ); + } + + EntityPath l_entityPath; + if( tryGetAttr<ATTR_AFFINITY_PATH>(l_entityPath) ) + { + l_ptr = l_entityPath.toString(); + if (l_ptr) + { + l_len = strlen( l_ptr ) + 1; + l_ptr1 = realloc( l_pFFDC, o_size + l_len ); + l_pFFDC = static_cast<char*>( l_ptr1 ); + memcpy( l_pFFDC + o_size, l_ptr, l_len ); + o_size += l_len; + free( l_ptr ); + } + } + + return l_pFFDC; + + #undef TARG_FN +} + #undef TARG_CLASS #undef TARG_NAMESPACE diff --git a/src/usr/targeting/test/targetingtest.H b/src/usr/targeting/test/targetingtest.H index 25065e701..9ae8dcca6 100644 --- a/src/usr/targeting/test/targetingtest.H +++ b/src/usr/targeting/test/targetingtest.H @@ -56,6 +56,7 @@ #include <targeting/iterators/rangefilter.H> #include <targeting/predicates/predicatectm.H> #include <targeting/predicates/predicatepostfixexpr.H> +#include <errl/errlUserDetailsTarget.H> #include <kernel/console.H> //@fixme @@ -1462,6 +1463,39 @@ class TargetingTestSuite: public CxxTest::TestSuite TS_TRACE(EXIT_MRK "testHbMutexAttr"); } + void testErrlTargetFFDC() + { + TS_TRACE(ENTER_MRK "testErrlTargetFFDC" ); + + using namespace ERRORLOG; + using namespace TARGETING; + using namespace fapi; + + // Get a reference to the target service + TargetService& l_service = targetService(); + + // Get the master proc target + TARGETING::Target* l_pTarget1 = NULL; + TARGETING::Target* l_pTarget2 = MASTER_PROCESSOR_CHIP_TARGET_SENTINEL; + l_service.masterProcChipTargetHandle( l_pTarget1); + + ErrlUserDetailsTarget l_errlUdTarget1( l_pTarget1 ); + ErrlUserDetailsTarget l_errlUdTarget2( l_pTarget2 ); + + // Create errorlogs to test FFDC capture of a target + errlHndl_t l_err1, l_err2; + l_err1 = new ErrlEntry( ERRL_SEV_UNRECOVERABLE, 1, 2, 3, 4); + l_err2 = new ErrlEntry( ERRL_SEV_UNRECOVERABLE, 5, 6, 7, 8); + + l_errlUdTarget1.addToLog( l_err1, NULL, 0 ); + l_errlUdTarget2.addToLog( l_err2, NULL, 0 ); + l_errlUdTarget1.addToLog( l_err1, NULL, 0 ); + + ERRORLOG::errlCommit( l_err1, TARG_COMP_ID ); + ERRORLOG::errlCommit( l_err2, TARG_COMP_ID ); + + TS_TRACE(EXIT_MRK "testErrlTargetFFDC"); + } }; #endif // End __TESTTARGETING_H |