summaryrefslogtreecommitdiffstats
path: root/src/usr/errl
diff options
context:
space:
mode:
authorMark Wenning <wenning@us.ibm.com>2011-09-30 15:09:57 -0500
committerMark W. Wenning <wenning@us.ibm.com>2011-11-01 10:58:00 -0500
commit14cd4e689a68a7440309090d0a6f82d25f8b6984 (patch)
tree92210b10941c76565af27bc9a5b68502b89daac4 /src/usr/errl
parentbeb8da45e9ad11796185bfb99f47fce35a090f9e (diff)
downloadtalos-hostboot-14cd4e689a68a7440309090d0a6f82d25f8b6984.tar.gz
talos-hostboot-14cd4e689a68a7440309090d0a6f82d25f8b6984.zip
RTC3964: ErrorLog User Data Parser
- created - add unittest for FILENAME - add unittest for StackTrace - still need to handle x86 (mini-errl) side - post-review changes - Monte's suggestions - Thi's suggestions - remove appendToLog() - combine with addToLog() - fix merge error - fsi was in both BASE and EXTENDED Change-Id: I863aae9f75aad5d576e839a9ef3099af6943982b Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/429 Tested-by: Jenkins Server Reviewed-by: Mark W. Wenning <wenning@us.ibm.com>
Diffstat (limited to 'src/usr/errl')
-rw-r--r--src/usr/errl/errlentry.C16
-rw-r--r--src/usr/errl/errluserdetails.C150
-rw-r--r--src/usr/errl/makefile3
-rw-r--r--src/usr/errl/test/errltest.H8
-rw-r--r--src/usr/errl/test/errluserdetailtest.H236
5 files changed, 400 insertions, 13 deletions
diff --git a/src/usr/errl/errlentry.C b/src/usr/errl/errlentry.C
index fc171fbfc..902d43544 100644
--- a/src/usr/errl/errlentry.C
+++ b/src/usr/errl/errlentry.C
@@ -38,6 +38,7 @@
#include <trace/interface.H>
#include <arch/ppc.H>
+
namespace ERRORLOG
{
@@ -60,6 +61,7 @@ ErrlEntry::ErrlEntry(const errlSeverity_t i_sev,
iv_termState(TERM_STATE_UNKNOWN)
{
+
}
@@ -131,8 +133,6 @@ void ErrlEntry::appendToFFDC(ErrlUD * i_pErrlUD,
}
-
-
///////////////////////////////////////////////////////////////////////////////
// Return a Boolean indication of success.
@@ -143,8 +143,8 @@ bool ErrlEntry::collectTrace(const char i_name[], const uint32_t i_max)
do
{
// By passing nil arguments, obtain the size of the buffer.
- uint64_t l_cbFull = TRACE::Trace::getTheInstance().getBuffer( i_name,
- NULL,
+ uint64_t l_cbFull = TRACE::Trace::getTheInstance().getBuffer( i_name,
+ NULL,
0 );
if( 0 == l_cbFull )
{
@@ -153,14 +153,14 @@ bool ErrlEntry::collectTrace(const char i_name[], const uint32_t i_max)
break;
}
- if( 0 == i_max )
+ if( 0 == i_max )
{
// Full trace buffer desired. Allocate the buffer.
char l_traceBuffer[ l_cbFull ];
// Get the data into the buffer.
- TRACE::Trace::getTheInstance().getBuffer( i_name,
- l_traceBuffer,
+ TRACE::Trace::getTheInstance().getBuffer( i_name,
+ l_traceBuffer,
l_cbFull );
// Save the trace buffer as a UD section on this.
@@ -170,7 +170,7 @@ bool ErrlEntry::collectTrace(const char i_name[], const uint32_t i_max)
ERRL_UDV_DEFAULT_VER_1,
ERRL_UDT_TRACE );
- // Add the trace section to the vector of sections
+ // Add the trace section to the vector of sections
// for this error log.
iv_SectionVector.push_back( l_udSection );
diff --git a/src/usr/errl/errluserdetails.C b/src/usr/errl/errluserdetails.C
new file mode 100644
index 000000000..2ee87f49a
--- /dev/null
+++ b/src/usr/errl/errluserdetails.C
@@ -0,0 +1,150 @@
+// IBM_PROLOG_BEGIN_TAG
+// This is an automatically generated prolog.
+//
+// $Source: src/usr/errl/errluserdetails.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
+/**
+ * @file errluserdetails.C
+ *
+ * @brief Implementation for ErrlUsrDetails
+ *
+ * 2011-09-28 mww Forked from /esw/fips740/Builds/b0824a_1135.740/src/util/fsp
+ *
+*/
+
+
+/******************************************************************************/
+// I n c l u d e s
+/*****************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h> // memcpy
+
+#include <hbotcompid.H>
+#include <errl/errlentry.H>
+#include <errl/errlmanager.H>
+#include <errl/errlreasoncodes.H>
+
+#include <errl/errluserdetails.H>
+
+#include "errlsctn.H"
+#include <errl/errlud.H> // ErrlFFDC
+
+
+namespace ERRORLOG
+{
+
+/*****************************************************************************/
+// ErrlUserDetails default constructor
+/*****************************************************************************/
+ErrlUserDetails::ErrlUserDetails()
+: iv_CompId(ERRL_COMP_ID),
+ iv_Version(0),
+ iv_SubSection(0),
+ iv_pErrlFFDC(NULL),
+ iv_pBuffer(NULL),
+ iv_BufLen(0)
+{
+}
+
+/*****************************************************************************/
+// ErrlUserDetails Destructor
+/*****************************************************************************/
+ErrlUserDetails::~ErrlUserDetails()
+{
+ if (iv_pBuffer)
+ {
+ delete [] iv_pBuffer;
+ iv_pBuffer = NULL;
+ }
+
+}
+
+
+/*****************************************************************************/
+// ErrlUserDetails add/appendToLog
+/*****************************************************************************/
+void ErrlUserDetails::addToLog(
+ errlHndl_t i_errl,
+ const void *i_paddBuf,
+ const uint32_t i_addBufLen )
+{
+
+ assert( i_errl != NULL );
+
+ if ( iv_pErrlFFDC == NULL )
+ {
+ // first time through, do an addFFDC() and save the returned handle
+ iv_pErrlFFDC = i_errl->addFFDC(
+ iv_CompId,
+ iv_pBuffer,
+ iv_BufLen,
+ iv_Version,
+ iv_SubSection );
+
+ // assert if fails to addFFDC
+ assert( iv_pErrlFFDC != NULL );
+ }
+
+ // if there is a buffer/len , append it to the existing FFDC.
+ if ( ( i_paddBuf != NULL ) && ( i_addBufLen > 0 ) )
+ {
+ i_errl->appendToFFDC(
+ iv_pErrlFFDC,
+ i_paddBuf,
+ i_addBufLen );
+ }
+}
+
+
+/*****************************************************************************/
+// ErrlUserDetails allocUsrBuf
+/*****************************************************************************/
+uint8_t * ErrlUserDetails::allocUsrBuf(const uint32_t i_size)
+{
+ uint8_t * pNewBuffer = new uint8_t[i_size];
+ if (iv_pBuffer)
+ {
+ if (iv_BufLen <= i_size)
+ {
+ memcpy(pNewBuffer, iv_pBuffer, iv_BufLen);
+ }
+ else
+ {
+ memcpy(pNewBuffer, iv_pBuffer, i_size);
+ }
+ delete [] iv_pBuffer;
+ }
+
+ iv_pBuffer = pNewBuffer;
+ iv_BufLen = i_size;
+
+ return (iv_pBuffer);
+}
+
+/*****************************************************************************/
+// ErrlUserDetails getUsrBufSize
+/*****************************************************************************/
+uint32_t ErrlUserDetails::getUsrBufSize() const
+{
+ return iv_BufLen;
+}
+
+} // end namespace
diff --git a/src/usr/errl/makefile b/src/usr/errl/makefile
index 924f34623..1a219ccb3 100644
--- a/src/usr/errl/makefile
+++ b/src/usr/errl/makefile
@@ -23,7 +23,8 @@
ROOTPATH = ../../..
MODULE = errl
-OBJS = errlentry.o errlmanager.o errlsctn.o errlsctnhdr.o errlprvt.o errluh.o errlud.o errlsrc.o
+OBJS = errlentry.o errlmanager.o errlsctn.o errlsctnhdr.o errlprvt.o errluh.o \
+ errlud.o errlsrc.o errluserdetails.o
SUBDIRS = test.d parser.d
diff --git a/src/usr/errl/test/errltest.H b/src/usr/errl/test/errltest.H
index c2808b32c..aab205414 100644
--- a/src/usr/errl/test/errltest.H
+++ b/src/usr/errl/test/errltest.H
@@ -73,9 +73,9 @@ public:
// 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
+ uint8_t l_8bit_2 = TEST_USR_8BIT_2; // 0x93
uint32_t l_32bit_1 = TEST_USR_32BIT_1; // 0x80000001
- uint64_t l_userData1 =
+ 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
@@ -114,14 +114,14 @@ public:
TS_FAIL("testErrl1: addFFDC() output NULL pointer");
}
- pch = "george washington";
+ pch = "george washington";
pffdc = l_err->addFFDC( DEVFW_COMP_ID, pch, strlen( pch ), 3, 4 );
if ( NULL == pffdc )
{
TS_FAIL("testErrl1: addFFDC() output NULL pointer");
}
- pch = "dwight eisenhour";
+ pch = "dwight eisenhour";
pffdc = l_err->addFFDC( SCOM_COMP_ID, pch, strlen( pch ), 5, 6 );
if ( NULL == pffdc )
{
diff --git a/src/usr/errl/test/errluserdetailtest.H b/src/usr/errl/test/errluserdetailtest.H
new file mode 100644
index 000000000..398192d23
--- /dev/null
+++ b/src/usr/errl/test/errluserdetailtest.H
@@ -0,0 +1,236 @@
+// IBM_PROLOG_BEGIN_TAG
+// This is an automatically generated prolog.
+//
+// $Source: src/usr/errl/test/errluserdetailtest.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
+#ifndef __TEST_ERRLUSERDETAILSTEST_H
+#define __TEST_USERUSERDETAILSTEST_H
+
+/**
+ * @file errluserdetailstest.H
+ *
+ * @brief Test user data plugin for errorlog.
+ *
+ */
+
+#include <cxxtest/TestSuite.H>
+#include <errl/errlentry.H>
+#include <errl/errluserdetails.H>
+
+using namespace ERRORLOG;
+
+// dummy version and subsection values.
+const errlver_t TEST_FILENAME_VER = 1;
+const errlsubsec_t TEST_FILENAME_SUBSECT = 4;
+const errlver_t TEST_STACKDUMP_VER = 2;
+const errlsubsec_t TEST_STACKDUMP_SUBSECT = 5;
+
+
+/**
+ * Declare a test UserDetails derived class to post a filename string to
+ * the errorlog
+ * This is just for test purposes, it will not show up in production code.
+ */
+class TestFilename : public ErrlUserDetails
+{
+public:
+
+ TestFilename(const char *i_filename)
+ {
+ iv_CompId = ERRL_COMP_ID;
+ iv_Version = TEST_FILENAME_VER;
+ iv_SubSection = TEST_FILENAME_SUBSECT;
+
+ // Store the string in the internal buffer
+ char * l_pString = (char *)allocUsrBuf( strlen(i_filename)+1 );
+ strcpy(l_pString, i_filename );
+ }
+
+ /**
+ * @brief Destructor
+ *
+ */
+ virtual ~TestFilename() {}
+
+private:
+
+ // Disabled
+ TestFilename(const TestFilename &);
+ TestFilename & operator=(const TestFilename &);
+};
+
+/**
+ * Declare a test User Details "StackDump" class to store an array of (32-bit)
+ * Stack Addresses. the first 32-bit number will be the number of following
+ * Stack Addresses.
+ *
+ * This is just a test program, it will not be used in production code.
+ * 64-bit stack addrs will need other support
+ */
+class TestStackDump : public ErrlUserDetails
+{
+public:
+
+
+ TestStackDump( const uint64_t i_numAddrs, const uint64_t * i_paddrs )
+ {
+
+ iv_CompId = ERRL_COMP_ID;
+ iv_Version = TEST_STACKDUMP_VER;
+ iv_SubSection = TEST_STACKDUMP_SUBSECT;
+
+ // allocUsrBuf returns a buffer of uint8_t
+ uint64_t *l_pList =
+ reinterpret_cast<uint64_t *>( allocUsrBuf( (i_numAddrs+1)*sizeof(void*) ) );
+
+ l_pList[0] = i_numAddrs;
+ for (uint64_t i=0; i<i_numAddrs; i++ )
+ {
+ l_pList[i+1] = i_paddrs[i];
+ }
+ }
+
+ /**
+ * @brief Destructor
+ *
+ */
+ virtual ~TestStackDump() {}
+
+private:
+
+ // Disabled
+ TestStackDump(const TestStackDump &);
+ TestStackDump & operator=(const TestStackDump &);
+};
+
+
+
+
+//
+// begin actual test code..
+//
+class UtilErrlUsrDataTest: public CxxTest::TestSuite
+{
+public:
+
+ /**
+ * @test testFILENAME - create a simple UD section in the errorlog that
+ * stores a filename string
+ */
+ void testFILENAME(void)
+ {
+ errlHndl_t l_errl = NULL;
+
+ TS_TRACE( "testFILENAME user data buffer for errorlog");
+
+ l_errl = new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_INFORMATIONAL,
+ TEST_MOD_ID,
+ ERRL_COMP_ID | 0x55, // compid/reasoncode
+ 0x1234567890, // user1
+ 0x9876543210 ); // user2
+ if( l_errl == NULL )
+ {
+ TS_FAIL("Could not create errlog.\n");
+ return;
+ }
+
+ // create the filename userdata object
+ //
+ TestFilename l_FN_userdata( "foobar.txt" );
+
+ // Add filename user data block to errorlog. this should add
+ // the original constructor string, and the second string passed
+ // in here.
+ const char testfnstr1[] = "secondfilename.txt";
+ l_FN_userdata.addToLog( l_errl, testfnstr1, sizeof(testfnstr1) );
+
+
+ //
+ // Add another string.
+ //
+ const char testfnstr2[] = "thirdfilename.txt";
+ l_FN_userdata.addToLog( l_errl, testfnstr2, sizeof(testfnstr2) );
+
+ // commit the errorlog
+ errlCommit(l_errl );
+
+ // Maybe do some stuff here to find the committed errorlog back and
+ // see if it is still correct? Later.
+
+ }
+
+ /**
+ * @test testStackDump - dump a User Data section of a stackdump.
+ *
+ * first 32-bit entry is the # of following 32-bit addresses, followed
+ * by the list of addresses.
+ *
+ */
+ void testStackDump(void)
+ {
+ errlHndl_t l_errl = NULL;
+ uint64_t l_addrs[] =
+ {
+ 0x01234567,
+ 0xDEADBEEF,
+ 0x5555aaaa,
+ 0x69696969,
+ 0x34920781,
+ 0xaaaa5555,
+ 0x68392090,
+ 0x95720856,
+ 0xabcdef01,
+ 0x12345670
+ };
+
+ TS_TRACE( "testStackDump add Userdata Section ot errorlog");
+
+
+ l_errl = new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_INFORMATIONAL,
+ TEST_MOD_ID,
+ ERRL_COMP_ID | 0x56, // compid/reasoncode
+ 0x0101010101, // user1
+ 0x0202020202 ); // user2
+ if( l_errl == NULL )
+ {
+ TS_FAIL("Could not create errlog.\n");
+ return;
+ }
+
+ TS_TRACE("Create Stackdump object. ");
+ TestStackDump l_stackDump(
+ (sizeof(l_addrs)/sizeof(uint64_t)),
+ &(l_addrs[0]) );
+
+ TS_TRACE("run addToLog");
+ l_stackDump.addToLog( l_errl );
+
+ errlCommit( l_errl );
+
+ }
+
+};
+
+
+
+#endif
+
OpenPOWER on IntegriCloud