diff options
-rw-r--r-- | src/include/runtime/interface.h | 8 | ||||
-rw-r--r-- | src/include/usr/errl/errlentry.H | 9 | ||||
-rw-r--r-- | src/include/usr/errl/errlprvt.H | 9 | ||||
-rw-r--r-- | src/include/usr/errl/errlreasoncodes.H | 1 | ||||
-rw-r--r-- | src/include/usr/errl/errlsctnhdr.H | 52 | ||||
-rw-r--r-- | src/include/usr/errl/errlsrc.H | 16 | ||||
-rw-r--r-- | src/include/usr/errl/errlud.H | 51 | ||||
-rw-r--r-- | src/include/usr/errl/errluh.H | 7 | ||||
-rw-r--r-- | src/makefile | 4 | ||||
-rw-r--r-- | src/usr/errl/errlentry.C | 52 | ||||
-rw-r--r-- | src/usr/errl/errlprvt.C | 17 | ||||
-rw-r--r-- | src/usr/errl/errlsctnhdr.C | 57 | ||||
-rw-r--r-- | src/usr/errl/errlsrc.C | 27 | ||||
-rw-r--r-- | src/usr/errl/errlud.C | 18 | ||||
-rw-r--r-- | src/usr/errl/errludcallout.C | 4 | ||||
-rw-r--r-- | src/usr/errl/errluh.C | 59 | ||||
-rw-r--r-- | src/usr/errl/makefile | 2 | ||||
-rw-r--r-- | src/usr/errl/runtime/makefile | 39 | ||||
-rw-r--r-- | src/usr/errl/runtime/rt_errlmanager.C | 283 | ||||
-rw-r--r-- | src/usr/errl/runtime/test/makefile | 29 | ||||
-rw-r--r-- | src/usr/errl/runtime/test/rt_errltest.H | 348 | ||||
-rw-r--r-- | src/usr/testcore/rtloader/loader.H | 27 |
22 files changed, 1022 insertions, 97 deletions
diff --git a/src/include/runtime/interface.h b/src/include/runtime/interface.h index fd3e1ba79..082f2440c 100644 --- a/src/include/runtime/interface.h +++ b/src/include/runtime/interface.h @@ -59,6 +59,14 @@ typedef struct hostInterfaces /** realloc */ void* (*realloc)(void*, size_t); + /** sendErrorLog + * @param[in] plid Platform Log identifier + * @param[in] data size in bytes + * @param[in] pointer to data + * @return 0 on success else error code + */ + int (*sendErrorLog)(uint32_t,uint32_t,void *); + } hostInterfaces_t; typedef struct runtimeInterfaces diff --git a/src/include/usr/errl/errlentry.H b/src/include/usr/errl/errlentry.H index 7bc971ed0..48af65a22 100644 --- a/src/include/usr/errl/errlentry.H +++ b/src/include/usr/errl/errlentry.H @@ -500,6 +500,15 @@ public: void addProcedureCallout(const HWAS::epubProcedureID i_procedure, const HWAS::callOutPriority i_priority); + /** + * @brief Import flatened error log + * + * @param[in] i_buffer, pointer to flat data + * @param[in] i_len length of flat data + * @return Status 0==SUCCESS + */ + uint64_t unflatten( const void * i_buffer, uint64_t i_len); + private: /** diff --git a/src/include/usr/errl/errlprvt.H b/src/include/usr/errl/errlprvt.H index 86bfb820a..fbdf82588 100644 --- a/src/include/usr/errl/errlprvt.H +++ b/src/include/usr/errl/errlprvt.H @@ -5,7 +5,7 @@ /* */ /* IBM CONFIDENTIAL */ /* */ -/* COPYRIGHT International Business Machines Corp. 2011,2012 */ +/* COPYRIGHT International Business Machines Corp. 2011,2013 */ /* */ /* p1 */ /* */ @@ -100,6 +100,13 @@ private: */ uint64_t flatten( void * o_pBuffer, const uint64_t i_cbBuffer ); + /** + * @brief Import flattened data + * @parm[in] i_buf, pointer to the flattened data + * @return The number of bytes consumed + */ + uint64_t unflatten( const void * i_buf ); + // Instance data diff --git a/src/include/usr/errl/errlreasoncodes.H b/src/include/usr/errl/errlreasoncodes.H index 4e3de79db..6369f6926 100644 --- a/src/include/usr/errl/errlreasoncodes.H +++ b/src/include/usr/errl/errlreasoncodes.H @@ -40,6 +40,7 @@ namespace ERRORLOG ERRL_FIRST_MODULE_ID = 0x00, ERRL_USERDATA_TEST_MOD_ID = 0x01, ERRL_TEST_MOD_ID = 0x02, + ERRL_RT_TEST_MOD_ID = 0x03, //........ ERRL_LAST_MODULE_ID = 0xFF }; diff --git a/src/include/usr/errl/errlsctnhdr.H b/src/include/usr/errl/errlsctnhdr.H index 870c101ed..295ae6cd7 100644 --- a/src/include/usr/errl/errlsctnhdr.H +++ b/src/include/usr/errl/errlsctnhdr.H @@ -1,25 +1,25 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: src/include/usr/errl/errlsctnhdr.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/errl/errlsctnhdr.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 */ #ifndef ERRLSCTNHDR_H #define ERRLSCTNHDR_H /** @@ -130,8 +130,12 @@ private: */ uint64_t flatten( void * o_pbuffer, const uint64_t i_cbBuffer ); - - + /** + * @brief Import flattened data + * @param[in] i_buf, pointer to flattened data + * @return number of bytes consumed in the flattened data + */ + uint64_t unflatten( const void * i_buf ); // Instance data. diff --git a/src/include/usr/errl/errlsrc.H b/src/include/usr/errl/errlsrc.H index 42c75158b..89fa9cbef 100644 --- a/src/include/usr/errl/errlsrc.H +++ b/src/include/usr/errl/errlsrc.H @@ -116,6 +116,13 @@ private: uint64_t flatSize() const; /** + * @brief Import data + * @param[in] i_buf, pointer to the flattened data + * @return number of bytes consumed + */ + uint64_t unflatten( const void * i_buf ); + + /** * @brief return the failing subsystem id value * * @return Failing subsystem ID @@ -131,6 +138,15 @@ private: void setSubSys( epubSubSystem_t i_ssid ){ iv_ssid = i_ssid; }; + /** + * Convert ascii hex digit to binary + * @param[in] c, the ascii hex digit + * @return the binary value 0-15 + * @note return value is only valid if input is valid hex digit + * '0'-'9', 'A'-'F', 'a'='f' + */ + uint64_t aschex2bin(char c); + // Instance data srcType_t iv_srcType : 8; // SRC type, the ?? in SRC ??xxxxxx uint8_t iv_modId; // module ID diff --git a/src/include/usr/errl/errlud.H b/src/include/usr/errl/errlud.H index 30817e112..04da45210 100644 --- a/src/include/usr/errl/errlud.H +++ b/src/include/usr/errl/errlud.H @@ -1,25 +1,25 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: src/include/usr/errl/errlud.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/errl/errlud.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 */ #ifndef ERRLUD_H #define ERRLUD_H /** @@ -112,6 +112,13 @@ private: + /** + * @brief Import data + * Imports data created with flatten. + * @param[in] i_buf, pointer to the flattened data + * @return number of bytes consumed + */ + uint64_t unflatten( const void * i_buf ); /** diff --git a/src/include/usr/errl/errluh.H b/src/include/usr/errl/errluh.H index 0e2f35e09..6c1caf4a3 100644 --- a/src/include/usr/errl/errluh.H +++ b/src/include/usr/errl/errluh.H @@ -93,6 +93,13 @@ private: uint64_t flatten( void * io_pBuffer, const uint64_t i_cbBuffer ); /** + * @brief Import data + * @param[in] i_buf, the pointer to the flattened data + * @return number of bytes consumed + */ + uint64_t unflatten( const void * i_buf ); + + /** * @brief return the failing subsystem id value * * @return Failing subsystem ID diff --git a/src/makefile b/src/makefile index bccb0965c..b03e08b04 100644 --- a/src/makefile +++ b/src/makefile @@ -71,9 +71,9 @@ TESTCASE_MODULES = cxxtest testtrace testerrl testdevicefw testsyslib \ RUNTIME_OBJECTS = rt_start.o rt_main.o rt_console.o rt_stdlib.o rt_sync.o \ rt_assert.o rt_vfs.o -RUNTIME_MODULES = trace_rt targeting_rt +RUNTIME_MODULES = trace_rt targeting_rt errl_rt RUNTIME_DATA_MODULES = -RUNTIME_TESTCASE_MODULES = cxxtest_rt testsyslib_rt testtargeting_rt +RUNTIME_TESTCASE_MODULES = cxxtest_rt testsyslib_rt testtargeting_rt testerrl_rt RELOCATABLE_IMAGE_LDFLAGS = -pie --export-dynamic diff --git a/src/usr/errl/errlentry.C b/src/usr/errl/errlentry.C index e201f4454..a9b252df9 100644 --- a/src/usr/errl/errlentry.C +++ b/src/usr/errl/errlentry.C @@ -956,7 +956,59 @@ uint64_t ErrlEntry::flatten( void * o_pBuffer, uint64_t i_bufsize ) } +uint64_t ErrlEntry::unflatten( const void * i_buffer, uint64_t i_len ) +{ + const uint8_t * l_buf = static_cast<const uint8_t *>(i_buffer); + uint64_t consumed = 0; + uint64_t bytes_used = 0; + uint64_t rc = 0; + + TRACDCOMP(g_trac_errl, INFO_MRK"Unflatten private section..."); + bytes_used = iv_Private.unflatten(l_buf); + consumed += bytes_used; + l_buf += bytes_used; + + TRACDCOMP(g_trac_errl, INFO_MRK"Unflatten User header section..."); + bytes_used = iv_User.unflatten(l_buf); + consumed += bytes_used; + l_buf += bytes_used; + + TRACDCOMP(g_trac_errl, INFO_MRK"Unflatten SRC section..."); + bytes_used = iv_Src.unflatten(l_buf); + consumed += bytes_used; + l_buf += bytes_used; + + iv_SectionVector.clear(); + iv_btAddrs.clear(); + removeBackTrace(); + + while(consumed < i_len) + { + TRACDCOMP(g_trac_errl, INFO_MRK"Unflatten User data section..."); + const ERRORLOG::pelSectionHeader_t * p = + reinterpret_cast<const ERRORLOG::pelSectionHeader_t *>(l_buf); + + if(p->sid != ERRORLOG::ERRL_SID_USER_DEFINED) // 'UD' + { + // yikes - bad section + TRACFCOMP(g_trac_errl, ERR_MRK"Bad UserData section found while " + "importing flattened data into error log. plid=%08x", + iv_Private.iv_plid); + rc = -1; + break; + } + const void * data = l_buf + sizeof(p); + uint64_t d_size = p->len - sizeof(p); + + ErrlUD * ud = new ErrlUD(data,d_size,p->compId,p->ver,p->sst); + consumed += p->len; + l_buf += p->len; + iv_SectionVector.push_back(ud); + } + + return rc; +} } // End namespace diff --git a/src/usr/errl/errlprvt.C b/src/usr/errl/errlprvt.C index 6b8a85ce2..f64301645 100644 --- a/src/usr/errl/errlprvt.C +++ b/src/usr/errl/errlprvt.C @@ -5,7 +5,7 @@ /* */ /* IBM CONFIDENTIAL */ /* */ -/* COPYRIGHT International Business Machines Corp. 2011,2012 */ +/* COPYRIGHT International Business Machines Corp. 2011,2013 */ /* */ /* p1 */ /* */ @@ -128,6 +128,21 @@ uint64_t ErrlPrvt::flatten( void * o_pBuffer, const uint64_t i_cbBuffer ) return l_rc; } +uint64_t ErrlPrvt::unflatten( const void * i_buf ) +{ + const pelPrivateHeaderSection_t * p = + static_cast<const pelPrivateHeaderSection_t *>(i_buf); + + iv_header.unflatten(&(p->sectionheader)); + iv_created = p->creationTime; + iv_committed = p->commitTime; + iv_cid = p->creatorId; + iv_sctns = p->sectionCount; + iv_plid = p->plid; + iv_eid = p->eid; + + return flatSize(); +} } // namespace diff --git a/src/usr/errl/errlsctnhdr.C b/src/usr/errl/errlsctnhdr.C index d56ff5008..8a24ab431 100644 --- a/src/usr/errl/errlsctnhdr.C +++ b/src/usr/errl/errlsctnhdr.C @@ -1,25 +1,25 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: src/usr/errl/errlsctnhdr.C $ -// -// 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/usr/errl/errlsctnhdr.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 errlsctnhdr.C * @@ -100,5 +100,18 @@ uint64_t ErrlSctnHdr::flatten( void * o_pBuffer, const uint64_t i_cbBuffer ) return l_rc; }; +uint64_t ErrlSctnHdr::unflatten( const void * i_buf ) +{ + const pelSectionHeader_t * p = + static_cast<const pelSectionHeader_t *>(i_buf); + + iv_sid = p->sid; + iv_slen = p->len; + iv_ver = p->ver; + iv_sst = p->sst; + iv_compId = p->compId; + + return sizeof( pelSectionHeader_t ); +} } // End namespace diff --git a/src/usr/errl/errlsrc.C b/src/usr/errl/errlsrc.C index 69d29e18a..41df75b27 100644 --- a/src/usr/errl/errlsrc.C +++ b/src/usr/errl/errlsrc.C @@ -168,6 +168,33 @@ uint64_t ErrlSrc::flatten( void * o_pBuffer, const uint64_t i_cbBuffer ) return l_rc; } +uint64_t ErrlSrc::unflatten( const void * i_buf) +{ + const pelSRCSection_t * p = + static_cast<const pelSRCSection_t *>(i_buf); + + iv_header.unflatten(&(p->sectionheader)); + + iv_srcType = (srcType_t)((16 * aschex2bin(p->srcString[0])) + + aschex2bin(p->srcString[1])); + iv_modId = p->moduleId; + iv_reasonCode = p->reserved1; + iv_ssid = (epubSubSystem_t)((16 * aschex2bin(p->srcString[2])) + + aschex2bin(p->srcString[3])); + iv_user1 = p->word6; + iv_user2 = p->word8; + + return flatSize(); +} + +uint64_t ErrlSrc::aschex2bin(char c) +{ + if(c >= 'a') c = c + 10 - 'a'; + else if (c >= 'A') c = c + 10 - 'A'; + else c -= '0'; + + return c; +} } // namespace diff --git a/src/usr/errl/errlud.C b/src/usr/errl/errlud.C index 09be2bacf..08b3f175d 100644 --- a/src/usr/errl/errlud.C +++ b/src/usr/errl/errlud.C @@ -165,4 +165,22 @@ uint64_t ErrlUD::flatten( void * o_pBuffer, const uint64_t i_cbBuffer ) return l_rc; } + + +uint64_t ErrlUD::unflatten( const void * i_buf ) +{ + const uint8_t * p = + static_cast<const uint8_t *>(i_buf); + + p += iv_header.unflatten(p); + + iv_Size = iv_header.iv_slen - iv_header.flatSize(); + + iv_pData = static_cast<uint8_t*>(realloc(iv_pData, iv_Size)); + + memcpy(iv_pData,p,iv_Size); + + return flatSize(); +} + } //namespace diff --git a/src/usr/errl/errludcallout.C b/src/usr/errl/errludcallout.C index 2e9b42cf7..2abb8e604 100644 --- a/src/usr/errl/errludcallout.C +++ b/src/usr/errl/errludcallout.C @@ -122,7 +122,11 @@ ErrlUserDetailsCallout::ErrlUserDetailsCallout( (reallocUsrBuf(pDataLength)); pData->type = HWAS::HW_CALLOUT; pData->priority = i_priority; +#ifndef __HOSTBOOT_RUNTIME pData->cpuid = task_getcpuid(); +#else + pData->cpuid = (uint32_t)(-1); +#endif pData->deconfigState = i_deconfigState; pData->gardErrorType = i_gardErrorType; memcpy(pData + 1, i_pTargetData, i_targetDataLength); diff --git a/src/usr/errl/errluh.C b/src/usr/errl/errluh.C index cdaaa1619..4312ea23d 100644 --- a/src/usr/errl/errluh.C +++ b/src/usr/errl/errluh.C @@ -1,25 +1,25 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: src/usr/errl/errluh.C $ -// -// 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/usr/errl/errluh.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 errluh.C * @@ -106,9 +106,22 @@ uint64_t ErrlUH::flatten( void * io_pBuffer, const uint64_t i_cbBuffer ) return l_rc; } +uint64_t ErrlUH::unflatten(const void * i_buf ) +{ + const pelUserHeaderSection_t * p = + static_cast<const pelUserHeaderSection_t *>(i_buf); + iv_header.unflatten(&(p->sectionheader)); + iv_ssid = (epubSubSystem_t)p->ssid; + iv_severity = (errlSeverity_t)p->sev; + iv_scope = (errlScope_t)p->scope; + iv_etype = (errlEventType_t)p->etype; + iv_domain = (errlDomain_t)p->domain; + iv_vector = (errlVector_t)p->vector; + iv_actions = p->actions; - + return flatSize(); +} } // namespace diff --git a/src/usr/errl/makefile b/src/usr/errl/makefile index 6535ef642..544fa9695 100644 --- a/src/usr/errl/makefile +++ b/src/usr/errl/makefile @@ -28,7 +28,7 @@ OBJS = errlentry.o errlmanager.o errlsctn.o errlsctnhdr.o errlprvt.o errluh.o \ errludstring.o errludbacktrace.o errludattribute.o errludlogregister.o \ errludcallout.o -SUBDIRS = test.d parser.d +SUBDIRS = test.d parser.d runtime.d include ${ROOTPATH}/config.mk diff --git a/src/usr/errl/runtime/makefile b/src/usr/errl/runtime/makefile new file mode 100644 index 000000000..dd47962ea --- /dev/null +++ b/src/usr/errl/runtime/makefile @@ -0,0 +1,39 @@ +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: src/usr/trace/runtime/makefile $ +# +# IBM CONFIDENTIAL +# +# COPYRIGHT International Business Machines Corp. 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 +HOSTBOOT_RUNTIME = 1 +ROOTPATH = ../../../.. +MODULE = errl_rt + +OBJS = errlentry.o rt_errlmanager.o errlsctn.o errlsctnhdr.o errlprvt.o errluh.o \ + errlud.o errlsrc.o errluserdetails.o backtrace.o errludtarget.o \ + errludstring.o errludbacktrace.o errludattribute.o \ + errludcallout.o + +SUBDIRS = test.d + +VPATH += .. +include $(ROOTPATH)/config.mk + +# to find errludattribute.[CH] and errludtarget.[CH] - they are generated +# by src/usr/targeting/common/xmltohb/xmltohb.pl +vpath %.C ${GENDIR} diff --git a/src/usr/errl/runtime/rt_errlmanager.C b/src/usr/errl/runtime/rt_errlmanager.C new file mode 100644 index 000000000..6fb120168 --- /dev/null +++ b/src/usr/errl/runtime/rt_errlmanager.C @@ -0,0 +1,283 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/errl/runtime/rt_errlmanager.C $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 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 */ +/*****************************************************************************/ +// I n c l u d e s +/*****************************************************************************/ +#include <errl/errlmanager.H> +#include <trace/interface.H> +#include <errl/errlentry.H> +#include <sys/task.h> +#include <stdlib.h> +#include <string.h> +#include <runtime/interface.h> +#include <targeting/common/targetservice.H> + +namespace ERRORLOG +{ + +extern trace_desc_t* g_trac_errl; + +////////////////////////////////////////////////////////////////////////////// +// Local functions +////////////////////////////////////////////////////////////////////////////// + +/** + * Override the HWAS processCallout function at runtime + * @param[in] io_errl Error log handle reference + * @param[in] i_pData Pointer to the callout bundle + * @param[in] i_Size size of the data in the callout bundle + * @param[in] i_DeferredOnly bool - true if ONLY check for defered deconfig + */ +bool rt_processCallout(errlHndl_t &io_errl, + uint8_t * i_pData, + uint64_t i_Size, + bool i_DeferredOnly); + +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +ErrlManager::ErrlManager() + : + iv_currLogId(0), + iv_pStorage(NULL), + iv_hwasProcessCalloutFn(NULL), + iv_msgQ(NULL) +{ + TRACFCOMP( g_trac_errl, ENTER_MRK "ErrlManager::ErrlManager constructor" ); + + + iv_hwasProcessCalloutFn = rt_processCallout; + + TARGETING::Target * sys = NULL; + TARGETING::targetService().getTopLevelTarget( sys ); + + if(sys) + { + iv_currLogId = sys->getAttr<TARGETING::ATTR_HOSTSVC_PLID>(); + } + else + { + iv_currLogId = 0x9fbad000; + TRACFCOMP( g_trac_errl, ERR_MRK"HOSTSVC_PLID not available" ); + } + + TRACFCOMP( g_trac_errl, EXIT_MRK "ErrlManager::ErrlManager constructor." ); +} + +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +ErrlManager::~ErrlManager() +{ + TRACFCOMP( g_trac_errl, INFO_MRK"ErrlManager::ErrlManager destructor" ); +} + +/////////////////////////////////////////////////////////////////////////////// +// ErrlManager::msgQueueInit() +/////////////////////////////////////////////////////////////////////////////// +void ErrlManager::msgQueueInit ( void ) +{ +} + +/////////////////////////////////////////////////////////////////////////////// +// ErrlManager::startup() +/////////////////////////////////////////////////////////////////////////////// +void * ErrlManager::startup ( void* i_self ) +{ + return NULL; +} + + +/////////////////////////////////////////////////////////////////////////////// +// ErrlManager::errlogMsgHndlr() +/////////////////////////////////////////////////////////////////////////////// +void ErrlManager::errlogMsgHndlr ( void ) +{ + // Not used in HB_RUNTIME +} + + +/////////////////////////////////////////////////////////////////////////////// +// ErrlManager::sendMboxMsg() +/////////////////////////////////////////////////////////////////////////////// +void ErrlManager::sendMboxMsg ( errlHndl_t& io_err ) +{ + TRACFCOMP( g_trac_errl, ENTER_MRK"ErrlManager::sendToHypervisor" ); + do + { + + uint32_t l_msgSize = io_err->flattenedSize(); + + + void * temp_buff = malloc( l_msgSize ); + io_err->flatten ( temp_buff, l_msgSize ); + + TRACDCOMP(g_trac_errl, + INFO_MRK"Send msg to FSP for errlogId [0x%08x]", + io_err->plid() ); + + if(g_hostInterfaces && g_hostInterfaces->sendErrorLog) + { + int rc = g_hostInterfaces->sendErrorLog(io_err->plid(), + l_msgSize, + temp_buff); + + if(rc) + { + TRACFCOMP(g_trac_errl, ERR_MRK + "Failed sending error log to FSP. rc: %d. " + "plid: 0x%08x", + rc, + io_err->plid() ); + } + } + else + { + TRACFCOMP(g_trac_errl, ERR_MRK + "Host interfaces not initialized, error log not sent. " + "plid: 0x%08x", + io_err->plid() + ); + } + + delete (uint8_t *)temp_buff; + + } while (0); + + TRACFCOMP( g_trac_errl, EXIT_MRK"sendToHypervisor()" ); + return; +} + +/////////////////////////////////////////////////////////////////////////////// +// Handling commit error log. +/////////////////////////////////////////////////////////////////////////////// +void ErrlManager::commitErrLog(errlHndl_t& io_err, compId_t i_committerComp ) +{ + + TRACDCOMP( g_trac_errl, ENTER_MRK"ErrlManager::commitErrLog" ); + do + { + if (io_err == NULL) + { + // put out warning trace + TRACFCOMP(g_trac_errl, ERR_MRK "commitErrLog() - NULL pointer"); + break; + } + + TRACFCOMP(g_trac_errl, "commitErrLog() called by %.4X for plid=0x%X," + "Reasoncode=%.4X", i_committerComp, + io_err->plid(), io_err->reasonCode() ); + + // Deferred callouts not allowed at runtime - this call will check, + // flag and change any that are found. + io_err->deferredDeconfigure(); + + TRACFCOMP( g_trac_errl, INFO_MRK + "Send an error log to hypervisor to commit. plid=0x%X", + io_err->plid() ); + + io_err->commit(i_committerComp); + sendMboxMsg(io_err); + io_err = NULL; + + } while( 0 ); + + TRACDCOMP( g_trac_errl, EXIT_MRK"ErrlManager::commitErrLog" ); + + return; +} + +/////////////////////////////////////////////////////////////////////////////// +// ErrlManager::saveErrLogEntry() +/////////////////////////////////////////////////////////////////////////////// +void ErrlManager::saveErrLogEntry( errlHndl_t& io_err ) +{ + return; +} + + + +/////////////////////////////////////////////////////////////////////////////// +// Atomically increment log id and return it. +uint32_t ErrlManager::getUniqueErrId() +{ + return (__sync_add_and_fetch(&iv_currLogId, 1)); +} + +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +void ErrlManager::setHwasProcessCalloutFn(HWAS::processCalloutFn i_fn) +{ + ERRORLOG::theErrlManager::instance().iv_hwasProcessCalloutFn = i_fn; +} + +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +// Global function (not a method on an object) to commit the error log. +void errlCommit(errlHndl_t& io_err, compId_t i_committerComp ) +{ + ERRORLOG::theErrlManager::instance().commitErrLog(io_err, i_committerComp ); + return; +} + + +/////////////////////////////////////////////////////////////////////////////// +// ErrlManager::sendErrlogToMessageQueue() +/////////////////////////////////////////////////////////////////////////////// +void ErrlManager::sendErrlogToMessageQueue ( errlHndl_t& io_err, + compId_t i_committerComp ) +{ + return; +} + +/////////////////////////////////////////////////////////////////////////////// +// ErrlManager::errlogShutdown() +/////////////////////////////////////////////////////////////////////////////// +void ErrlManager::errlogShutdown(void) +{ + return; +} + +// Runtime processCallout +bool rt_processCallout(errlHndl_t &io_errl, + uint8_t * i_pData, + uint64_t i_Size, + bool i_DeferredOnly) +{ + HWAS::callout_ud_t *pCalloutUD = (HWAS::callout_ud_t *)i_pData; + if(i_DeferredOnly) + { + if ((pCalloutUD->type == HWAS::HW_CALLOUT) && + (pCalloutUD->deconfigState == HWAS::DELAYED_DECONFIG)) + { + pCalloutUD->deconfigState = HWAS::NO_DECONFIG; + + TRACFCOMP( g_trac_errl, ERR_MRK + "Runtime errorlog callout with DELAYED_DECONFIG not " + "allowed! Changed to NO_DECONFIG. plid: 0x%X", + io_errl->plid() ); + } + + } + return true; +} + +} // End namespace diff --git a/src/usr/errl/runtime/test/makefile b/src/usr/errl/runtime/test/makefile new file mode 100644 index 000000000..4c78ecdbd --- /dev/null +++ b/src/usr/errl/runtime/test/makefile @@ -0,0 +1,29 @@ +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: src/usr/errl/runtime/test/makefile $ +# +# IBM CONFIDENTIAL +# +# COPYRIGHT International Business Machines Corp. 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 +HOSTBOOT_RUNTIME = 1 +ROOTPATH = ../../../../.. + +MODULE = testerrl_rt +TESTS = *.H + +include ${ROOTPATH}/config.mk diff --git a/src/usr/errl/runtime/test/rt_errltest.H b/src/usr/errl/runtime/test/rt_errltest.H new file mode 100644 index 000000000..dfb7ec9fb --- /dev/null +++ b/src/usr/errl/runtime/test/rt_errltest.H @@ -0,0 +1,348 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/errl/test/errltest.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 */ +#ifndef __RT_ERRLTEST_H +#define __RT_ERRLTEST_H + +/** + * @file errltest.H + * + * @brief Test case for Error Logging +*/ + +#include <cxxtest/TestSuite.H> +#include <errl/errlmanager.H> +#include <errl/errlentry.H> +#include <errl/errlreasoncodes.H> +#include <trace/trace.H> +#include <hbotcompid.H> + +#include <errl/errludtarget.H> +#include <targeting/common/target.H> +#include <targeting/common/iterators/rangefilter.H> +#include <targeting/common/predicates/predicates.H> +#include <hwas/common/hwasCallout.H> +#include <hwas/common/deconfigGard.H> + +#include "../../../trace/entry.H" + +#define TEST_SEVERITY ERRORLOG::ERRL_SEV_INFORMATIONAL + + +#define TEST_USR_8BIT_1 0x80 +#define TEST_USR_8BIT_2 0x93 + +#define TEST_USR_16BIT_1 0x8000 +#define TEST_USR_16BIT_2 0x9003 + +#define TEST_USR_32BIT_1 0x80000001 +#define TEST_USR_32BIT_2 0x90000003 + +#define TEST_USR_64BIT_1 0x8000000000000001 +#define TEST_USR_64BIT_2 0x9000000000000003 + + + +class RT_ErrlTest: public CxxTest::TestSuite +{ +public: + + + /** + * @brief Test error log creation + * - Create an error log + * - Verify data of created log + * - Commit an error log + * - Delete an error log + */ + void testErrl1(void) + { + ERRORLOG::ErrlUD * pffdc; + + // An example that shows how to use macros to stuff data into + // the two 64-bit user data parameters in the error log. + // l_userData1 = 16bit(0):l_bit8_1:l_bit8_2:l_32bit_1 + uint8_t l_8bit_1 = TEST_USR_8BIT_1; // 0x80 + uint8_t l_8bit_2 = TEST_USR_8BIT_2; // 0x93 + uint32_t l_32bit_1 = TEST_USR_32BIT_1; // 0x80000001 + uint64_t l_userData1 = + TWO_UINT32_TO_UINT64( TO_UINT32(TWO_UINT8_TO_UINT16(l_8bit_1, l_8bit_2)), l_32bit_1); + // yields 0x0000809380000001 + + + // l_userData2 = l_16bit_1:l_16bit_2:l_32bit_2 + uint16_t l_16bit_1 = TEST_USR_16BIT_1; // 0x8000 + uint16_t l_16bit_2 = TEST_USR_16BIT_2; // 0x9003 + uint32_t l_32bit_2 = TEST_USR_32BIT_2; // 0x90000003 + uint64_t l_userData2 = TWO_UINT16_ONE_UINT32_TO_UINT64(l_16bit_1, l_16bit_2, l_32bit_2); + // yields 0x8000900390000003 + + + + do + { + /*@ + * @errortype + * @reasoncode ERRORLOG::ERRL_TEST_REASON_CODE + * @severity ERRORLOG::ERRL_SEV_INFORMATIONAL + * @moduleid ERRORLOG::ERRL_RT_TEST_MOD_ID + * @devdesc Errl test. Error with non-decoded string + * and lots of trace buffers. + */ + + // Create an error log + errlHndl_t l_err = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_INFORMATIONAL, + ERRORLOG::ERRL_RT_TEST_MOD_ID, + ERRORLOG::ERRL_TEST_REASON_CODE, + l_userData1, + l_userData2); + + // These addFFDC() calls return a pointer to class ERRORLOG::ErrlFFDC + // but errlffdc.H is not publicly includable to give me the definition + // for it. addFFDC() should return a Boolean indication of success. + + // really short user data + const char * pch = "A"; + pffdc = l_err->addFFDC( DEVFW_COMP_ID, pch, strlen( pch ), 0, 0); + if ( NULL == pffdc ) + { + TS_FAIL("testErrl1: addFFDC() output NULL pointer"); + break; + } + + // Append data to something already added. + pch = " test-user-data-string"; + l_err->appendToFFDC( pffdc, pch, strlen(pch) ); + + // Collect trace + // NOTE Trace buffers are not currently kept in Runtime + // - tests deleted + + // Add null data. + pffdc = l_err->addFFDC( ERRL_COMP_ID, NULL, 0, 9, 10 ); + if ( NULL != pffdc ) + { + TS_FAIL("testErrl1: addFFDC() returned non null"); + break; + } + + // Verify log data + if (l_err->sev() != ERRORLOG::ERRL_SEV_INFORMATIONAL) + { + TS_FAIL("testErrl1: createErrlLog() returns incorrect severity!"); + break; + } + + if (l_err->reasonCode() != ERRORLOG::ERRL_TEST_REASON_CODE) + { + TS_FAIL("testErrl1: createErrlLog() returns incorrect reason code!"); + break; + } + + if (l_err->eventType() != ERRORLOG::ERRL_ETYPE_NOT_APPLICABLE) + { + TS_FAIL("testErrl1: createErrlLog() returns incorrect event type!"); + break; + } + + if (l_err->subSys() != ERRORLOG::EPUB_FIRMWARE_SUBSYS ) + { + TS_FAIL("testErrl1: createErrlLog() returns incorrect sub system!"); + break; + } + + if (l_err->srcType() != ERRORLOG::SRC_ERR_INFO) + { + TS_FAIL("testErrl1: createErrlLog() returns incorrect SRC type!"); + break; + } + + if (l_err->termState() != ERRORLOG::TERM_STATE_UNKNOWN) + { + TS_FAIL("testErrl1: termState() returns incorrect term state!"); + break; + } + + + + // Commit error log with different component ID. + errlCommit(l_err, CXXTEST_COMP_ID); + + // Make sure error log has been deleted by manager + if (l_err != NULL) + { + TS_FAIL("testErrl1: commitErrLog() did not delete error!"); + break; + } + + } + while(0); + } + + /** + * @brief Test error log parameter settings + */ + void testErrl2(void) + { + // An example that shows how to use macros to stuff data into + // the two 64-bit user data parameters in the error log. + // l_userData1 = l_bit32_1:l_bit32_2 + uint32_t l_32bit_1 = TEST_USR_32BIT_1; + uint32_t l_32bit_2 = TEST_USR_32BIT_2; + uint64_t l_userData1 = TWO_UINT32_TO_UINT64(l_32bit_1, l_32bit_2); + + // l_userData2 = 24bit(0):l_8bit_1:16bit(0):l_16bit_1 + uint8_t l_8bit_1 = TEST_USR_8BIT_1; + uint16_t l_16bit_1 = TEST_USR_16BIT_1; + uint64_t l_userData2 = + TWO_UINT32_TO_UINT64(TO_UINT32(l_8bit_1), TO_UINT32(l_16bit_1)); + + // Create an error log + errlHndl_t l_err = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_UNRECOVERABLE, + ERRORLOG::ERRL_RT_TEST_MOD_ID, + ERRORLOG::ERRL_TEST_REASON_CODE, + l_userData1, + l_userData2); + + // Set and verify log data + l_err->setSev(ERRORLOG::ERRL_SEV_UNKNOWN); + l_err->setEventType(ERRORLOG::ERRL_ETYPE_CAPACITY_UPGRADE); + l_err->setSubSys(ERRORLOG::EPUB_UNKNOWN); + l_err->setSrcType(ERRORLOG::SRC_ERR_INFO); + l_err->setTermState(ERRORLOG::TERM_STATE_NO_FLAGS); + + if (l_err->sev() != ERRORLOG::ERRL_SEV_UNKNOWN) + { + TS_FAIL("testErrl2: setSev() fails!"); + } + else if (l_err->eventType() != ERRORLOG::ERRL_ETYPE_CAPACITY_UPGRADE) + { + TS_FAIL("testErrl2: setEventType() fails!"); + } + else if (l_err->subSys() != ERRORLOG::EPUB_UNKNOWN) + { + TS_FAIL("testErrl2: setSubSys() fails!"); + } + else if (l_err->srcType() != ERRORLOG::SRC_ERR_INFO) + { + TS_FAIL("testErrl2: setSrcType() fails!"); + } + else if (l_err->termState() != ERRORLOG::TERM_STATE_NO_FLAGS) + { + TS_FAIL("testErrl2: setTermState() fails!"); + } + + // Delete the log + delete l_err; + l_err = NULL; + } + + /** + * @brief Test callouts + */ + void testErrl3(void) + { + TS_TRACE( "test testErrl3"); + do + { + // find some ex units that we can play with + TARGETING::Target * pSys; + TARGETING::targetService().getTopLevelTarget(pSys); + + TARGETING::PredicateCTM predEx(TARGETING::CLASS_UNIT, + TARGETING::TYPE_EX); + TARGETING::PredicateHwas predFunctional; + predFunctional.poweredOn(true).present(true).functional(true); + TARGETING::PredicatePostfixExpr checkExpr; + checkExpr.push(&predEx).push(&predFunctional).And(); + TARGETING::TargetHandleList pExList; + TARGETING::targetService().getAssociated( pExList, pSys, + TARGETING::TargetService::CHILD, TARGETING::TargetService::ALL, + &checkExpr ); + + if (pExList.empty()) + { + TS_FAIL("testErrl3: empty pExList"); + break; + } + TARGETING::TargetHandle_t pTarget = *pExList.begin(); + + // Create an error log + errlHndl_t errl = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_UNRECOVERABLE, + ERRORLOG::ERRL_RT_TEST_MOD_ID, + ERRORLOG::ERRL_TEST_REASON_CODE); + + // test the different callout types + TS_TRACE("test callout target %.8X", TARGETING::get_huid(pTarget)); + ERRORLOG::ErrlUserDetailsTarget(pTarget).addToLog(errl); + + errl->addHwCallout(pTarget, + HWAS::SRCI_PRIORITY_LOW, + HWAS::DELAYED_DECONFIG, + HWAS::GARD_Fatal); + + errl->addHwCallout(pTarget, + HWAS::SRCI_PRIORITY_MED, + HWAS::DELAYED_DECONFIG, + HWAS::GARD_NULL); + + errl->addHwCallout(TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL, + HWAS::SRCI_PRIORITY_LOW, + HWAS::NO_DECONFIG, + HWAS::GARD_PHYP); + + errl->addHwCallout(TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL, + HWAS::SRCI_PRIORITY_MED, + HWAS::DELAYED_DECONFIG, + HWAS::GARD_NULL); + + errl->addProcedureCallout( + HWAS::EPUB_PRC_MEMORY_PLUGGING_ERROR, + HWAS::SRCI_PRIORITY_HIGH); + + errl->addClockCallout( + pExList[0], + HWAS::TODCLK_TYPE, + HWAS::SRCI_PRIORITY_MED); + + if (pExList.size() > 1) + { + errl->addBusCallout( + pExList[0], + pExList[1], + HWAS::A_BUS_TYPE, + HWAS::SRCI_PRIORITY_LOW); + } + + errlCommit(errl, CXXTEST_COMP_ID); + + TS_TRACE( "testErrl3 done"); + + } + while(0); + } +}; + +#endif diff --git a/src/usr/testcore/rtloader/loader.H b/src/usr/testcore/rtloader/loader.H index 9b17fcea5..205522536 100644 --- a/src/usr/testcore/rtloader/loader.H +++ b/src/usr/testcore/rtloader/loader.H @@ -26,6 +26,8 @@ #include <pnor/pnorif.H> #include <util/align.H> #include <sys/mm.h> +#include <errl/errlentry.H> +#include <errl/errlmanager.H> #include <runtime/interface.h> @@ -97,6 +99,7 @@ class RuntimeLoaderTest : public CxxTest::TestSuite intf->free = free; intf->realloc = realloc; intf->assert = rt_assert; + intf->sendErrorLog = rt_logErr; // Call init. runtimeInterfaces_t* rtInterface = @@ -159,6 +162,28 @@ class RuntimeLoaderTest : public CxxTest::TestSuite { assert(false); } -}; + static int rt_logErr(uint32_t plid, + uint32_t data_len, + void * data) + { + uint64_t rc = 0; + TRACFCOMP(g_trac_test, + "RUNTIME MSG: Log error. Plid: %d len: %d", + plid, + data_len); + + TRACDBIN(g_trac_test, "RUNTIME ERROR LOG:",data,data_len); + + + errlHndl_t err = + new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_INFORMATIONAL, + 0,0); + rc = err->unflatten(data, data_len); + + errlCommit(err,CXXTEST_COMP_ID); + + return rc; + } +}; #endif |