diff options
author | Brian Horton <brianh@linux.ibm.com> | 2012-04-25 15:48:55 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2012-05-08 17:20:50 -0500 |
commit | cd9263254cacd7948aad8ba1bd3a98af469b02af (patch) | |
tree | 26e6c8a9856ac9d5b782173b1f2df9b35fe53e18 /src/usr/targeting/common/target.C | |
parent | 8c8f1b51f8f7d366e60ce8ae899b77cd122f86f4 (diff) | |
download | talos-hostboot-cd9263254cacd7948aad8ba1bd3a98af469b02af.tar.gz talos-hostboot-cd9263254cacd7948aad8ba1bd3a98af469b02af.zip |
Errlog User Details: Log Arbitrary Attributes
Add code so that a hostboot or procedure developer can save attributes
into an error log and have them display in a human-readable way in order
to aid debug and FA. All data is stored in errlog in binary format and
decoded into strings and enum 'constants' with the parse function.
Methods to dump and parse the attributes are auto-generated by the
xmltohb.pl script.
In addition, cleanup up Target User Details so that blanks lines aren't
output and so that the attribute name isn't put into the error log and
is instead added by the parse function (smaller errlog usage), and change
to same coding style as other UserDetail functions (data put into buffer
in ctor and not in addToLog function).
following will be added in future story/task work:
- parsing for complex attributes.
- combining multiple attribute user details together instead of
generating a separate log entry for each.
Change-Id: I6baafa36ef095aafabb5bf86d6054bcb3db47019
RTC: 35275
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/944
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Tested-by: Jenkins Server
Diffstat (limited to 'src/usr/targeting/common/target.C')
-rw-r--r-- | src/usr/targeting/common/target.C | 96 |
1 files changed, 57 insertions, 39 deletions
diff --git a/src/usr/targeting/common/target.C b/src/usr/targeting/common/target.C index 9da4de170..96e6c89e0 100644 --- a/src/usr/targeting/common/target.C +++ b/src/usr/targeting/common/target.C @@ -148,7 +148,7 @@ void Target::_getAttrPtr( // Only translate addresses on platforms where addresses are 4 bytes // wide (FSP). The compiler should perform dead code elimination of - // this path on platforms with 8 byte wide addresses (Hostboot), + // this path on platforms with 8 byte wide addresses (Hostboot), // since the "if" check can be statically computed at compile time. if(TARG_ADDR_TRANSLATION_REQUIRED) { @@ -177,12 +177,12 @@ mutex_t* Target::_getHbMutexAttr( void* l_pAttr = NULL; (void)_getAttrPtr(i_attribute,l_pAttr); - //@TODO Remove assert once release has stablized + //@TODO Remove assert once release has stablized TARG_ASSERT(l_pAttr,"TARGETING::Target::_getHbMutexAttr<%d>: _getAttrPtr " "returned NULL",i_attribute); return static_cast<mutex_t*>(l_pAttr); - + #undef TARG_FN } @@ -195,12 +195,12 @@ bool Target::_tryGetHbMutexAttr( mutex_t*& o_pMutex) const { #define TARG_FN "_tryGetHbMutexAttr()" - + void* l_pAttr = NULL; (void)_getAttrPtr(i_attribute,l_pAttr); o_pMutex = static_cast<mutex_t*>(l_pAttr); return (l_pAttr != NULL); - + #undef TARG_FN } @@ -222,51 +222,69 @@ Target::Target() // Target::targetFFDC() //****************************************************************************** -char * Target::targetFFDC( uint32_t & o_size ) const +uint8_t * 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>() ); + AttributeTraits<ATTR_HUID>::Type attrHuid = getAttr<ATTR_HUID>(); + AttributeTraits<ATTR_CLASS>::Type attrClass = getAttr<ATTR_CLASS>(); + AttributeTraits<ATTR_TYPE>::Type attrType = getAttr<ATTR_TYPE>(); + AttributeTraits<ATTR_MODEL>::Type attrModel = getAttr<ATTR_MODEL>(); + uint32_t headerSize = sizeof(uint8_t) + sizeof(attrHuid) + + sizeof(attrClass) + sizeof(attrType) + + sizeof(attrModel); + + uint8_t pathPhysSize = 0; + AttributeTraits<ATTR_PHYS_PATH>::Type pathPhys; + if( tryGetAttr<ATTR_PHYS_PATH>(pathPhys) ) { + // entityPath is PATH_TYPE:4, NumberOfElements:4, [Element, Instance#] + pathPhysSize = sizeof(uint8_t) + (sizeof(pathPhys[0]) * pathPhys.size()); + } - l_pFFDC = static_cast<char*>( malloc( ++o_size ) ); - memcpy( l_pFFDC, l_buff, o_size ); + uint8_t pathAffSize = 0; + AttributeTraits<ATTR_AFFINITY_PATH>::Type pathAff; + if( tryGetAttr<ATTR_AFFINITY_PATH>(pathAff) ) { + // entityPath is PATH_TYPE:4, NumberOfElements:4, [Element, Instance#] + pathAffSize = sizeof(uint8_t) + (sizeof(pathAff[0]) * pathAff.size()); + } - l_ptr = getAttr<ATTR_PHYS_PATH>().toString(); - if (l_ptr) + uint8_t *pFFDC; + pFFDC = static_cast<uint8_t*>( malloc(headerSize + + pathPhysSize + pathAffSize)); + + // we'll send down a '0' then HUID CLASS TYPE and MODEL + uint32_t bSize = 0; // size of data in the buffer + *pFFDC = 0; + bSize++; + memcpy(pFFDC + bSize, &attrHuid, sizeof(attrHuid) ); + bSize += sizeof(attrHuid); + memcpy(pFFDC + bSize, &attrClass, sizeof(attrClass) ); + bSize += sizeof(attrClass); + memcpy(pFFDC + bSize, &attrType, sizeof(attrType) ); + bSize += sizeof(attrType); + memcpy(pFFDC + bSize, &attrModel, sizeof(attrModel) ); + bSize += sizeof(attrModel); + + if( pathPhysSize > 0) { - 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 ); + uint8_t attrEnum = ATTR_PHYS_PATH; + memcpy(pFFDC + bSize, &attrEnum, sizeof(attrEnum)); + bSize += sizeof(attrEnum); + memcpy(pFFDC + bSize, &pathPhys, pathPhysSize); + bSize += pathPhysSize; } - EntityPath l_entityPath; - if( tryGetAttr<ATTR_AFFINITY_PATH>(l_entityPath) ) + if( pathAffSize > 0) { - 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 ); - } + uint8_t attrEnum = ATTR_AFFINITY_PATH; + memcpy(pFFDC + bSize, &attrEnum, sizeof(attrEnum)); + bSize += sizeof(attrEnum); + memcpy(pFFDC + bSize, &pathAff, pathAffSize); + bSize += pathAffSize; } - return l_pFFDC; + o_size = bSize; + return pFFDC; #undef TARG_FN } |