diff options
author | Mark Wenning <wenning@us.ibm.com> | 2011-10-20 11:17:06 -0500 |
---|---|---|
committer | Mark W. Wenning <wenning@us.ibm.com> | 2011-11-02 10:55:48 -0500 |
commit | 75a2f91534b9d3450ff450e63914bde9cb39514b (patch) | |
tree | debe069486911e560c819242a77ed6789234e9b0 /src | |
parent | b72ee9b1f333be7847d694bfa2c5fbafa2e4c487 (diff) | |
download | talos-hostboot-75a2f91534b9d3450ff450e63914bde9cb39514b.tar.gz talos-hostboot-75a2f91534b9d3450ff450e63914bde9cb39514b.zip |
RTC3964: x86 Support for UserDetails
- first commit
- errlparserbase and errluserparser
- need linker step for userdetails libs
- final merge
Change-Id: I32daae8de483616f20e66581f4e8f3de0dc98257
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/467
Tested-by: Jenkins Server
Reviewed-by: Monte K. Copeland <copelanm@us.ibm.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/include/usr/errl/errlreasoncodes.H | 6 | ||||
-rwxr-xr-x | src/include/usr/errl/errluserdetails.H | 1 | ||||
-rwxr-xr-x | src/include/usr/errl/parser/errlparserbase.H | 245 | ||||
-rwxr-xr-x | src/include/usr/errl/parser/errlusrparser.H | 105 | ||||
-rw-r--r-- | src/include/usr/hbotcompid.H | 17 | ||||
-rw-r--r-- | src/usr/cxxtest/cxxtestexec.C | 5 | ||||
-rw-r--r-- | src/usr/cxxtest/makefile | 2 | ||||
-rw-r--r-- | src/usr/errl/errlentry.C | 3 | ||||
-rw-r--r-- | src/usr/errl/parser/errlparser.C | 5 | ||||
-rw-r--r-- | src/usr/errl/parser/errlparserbase.C | 81 | ||||
-rwxr-xr-x | src/usr/errl/parser/errlusrparser.C | 185 | ||||
-rw-r--r-- | src/usr/errl/parser/makefile | 34 | ||||
-rw-r--r-- | src/usr/errl/test/errluserdetailtest.H | 248 | ||||
-rw-r--r-- | src/usr/parser.mk | 30 |
14 files changed, 863 insertions, 104 deletions
diff --git a/src/include/usr/errl/errlreasoncodes.H b/src/include/usr/errl/errlreasoncodes.H index 346f563c7..f5fe78f35 100644 --- a/src/include/usr/errl/errlreasoncodes.H +++ b/src/include/usr/errl/errlreasoncodes.H @@ -45,8 +45,10 @@ enum enum errlReasonCode { ERRL_FIRST_ERR = ERRL_COMP_ID | 0x01, - ERRL_ADDTOLOG_FAIL = ERRL_COMP_ID | 0x02, - ERRL_APPENDTOLOG_FAIL = ERRL_COMP_ID | 0x03, + ERRL_FILENAME_TEST = ERRL_COMP_ID | 0x02, + ERRL_ERRORMSG_TEST = ERRL_COMP_ID | 0x03, + ERRL_XMLTOKEN_TEST = ERRL_COMP_ID | 0x04, + //........ ERRL_LAST_ERR = ERRL_COMP_ID | 0xFF }; diff --git a/src/include/usr/errl/errluserdetails.H b/src/include/usr/errl/errluserdetails.H index af7e004d1..5ed8fe029 100755 --- a/src/include/usr/errl/errluserdetails.H +++ b/src/include/usr/errl/errluserdetails.H @@ -206,6 +206,7 @@ public: */ ErrlUserDetails() { + } /** diff --git a/src/include/usr/errl/parser/errlparserbase.H b/src/include/usr/errl/parser/errlparserbase.H new file mode 100755 index 000000000..f165f7514 --- /dev/null +++ b/src/include/usr/errl/parser/errlparserbase.H @@ -0,0 +1,245 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/include/usr/errl/parser/errlparserbase.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 ERRL_ERRLPARSERBASE_H +#define ERRL_ERRLPARSERBASE_H + +/** + * @file errlparserbase.H + * + * @brief Base class for parser routines + * + * pulled from fips740/ .. /src/errl/fsp/errlparser.H + * + * @note + * There are many more routines in fips code to print out specialty + * fields and such, these are not used presently and IMHO should be in + * their own file. + * Leave out for now. + * + */ + + +/*****************************************************************************/ +// I n c l u d e s +/*****************************************************************************/ +#include <stdint.h> +#include <stdlib.h> +#include <stdio.h> +#include <netinet/in.h> // network byte-swapping routines. +// Unavoidable include for va_list +#include <cstdarg> + +#include <errl/errltypes.H> + +/*****************************************************************************/ +// Typedefs +/*****************************************************************************/ +/** + * @struct BCD_time8_t + * + * pulled from fips740/ .. /src/rtim/fsp/rtim.H + */ +struct BCD_time8_t +{ + uint16_t year; + uint8_t month; + uint8_t day; + uint8_t hours; + uint8_t minutes; + uint8_t seconds; + uint8_t hundredths; +} __attribute__ ((packed)); + + + +/*****************************************************************************/ +// User Types +/*****************************************************************************/ +class ErrlParser +{ +public: + + + /** + * @brief Build an associated parser object + * + * Builds an associated parser object which is tied to the + * given stream. The net effect is the addition of some + * simple methods to standardize log output + * + * @param i_output + * Stream to be used for output, defaults to stdout + * + */ + ErrlParser( + FILE * i_output = stdout + ); + + + /** + * @brief Cleanup handler + * + * Currently no-op + * + */ + virtual ~ErrlParser(); + + + /** + * @brief Set Stream pointer + * + * Changes the output stream pointer which ultimately + * determines what OS device receives the data + * + * @param i_val + * Output stream + * + * @note The stream handle is not owned by this object + * and will therefore not be released automatically + * + */ + void setStream( FILE * i_val ) + { + iv_Stream = i_val; + } + + + /** + * @brief Display a standard parser message + * + * Displays the a message in the error log parser + * format of "Label: Desc" + * + * @param i_label + * Label for the message + * + * @param i_string + * Description string + * + */ + virtual void PrintString( + const char * i_label, + const char * i_string + ) = 0; + + + /** + * @brief Output a standard message for numeric data + * + * A message consisting of the label and a hex formatted + * number is forwarded to the PrintString interface + * + * @param i_label + * Left-hand label for the data + * + * @param i_fmt + * Numeric format used to parse the data value + * + * @param i_value + * Numberic value + * + * @note Current implementation templates the output + * to PrintString after generating a string + * of the proper type. + */ + virtual void PrintNumber( + const char * i_label, + const char * i_fmt, + uint32_t i_value + ); + + + /** + * @brief Classical Hex dump of data + * + * A 5 column output consisting of an offset, 4 hex words, + * and an ascii equivalent will be dumped in big endian + * mode + * + * @param i_data + * Pointer to data buffer + * + * @param i_len + * Length of data in bytes + * + */ + virtual void PrintHexDump( + const void * i_data, + uint32_t i_len + ) = 0; + + +protected: + /** + * @brief Load a message string. + * + * FSP allows this to reference a message file. This is pulled out + * here, perhaps can be added later if needed. + * + * @param i_MsgId + * Message Identifier ( see errllang.H ) + * + * @return Constant pointer to the message string + * + * @note The message is static and should not be modified by + * the caller. + * + */ + const char * LoadMsg( const char * i_MsgId ) const + { + return i_MsgId; + } + + + /** + * @brief endian switch a uint64 + * + * @param[in] i_value + * uint64_t value to be byteswapped + * + * @return byte-swapped uint64_t value + * + */ + uint64_t ntohll( uint64_t i ) const + { + uint64_t hi; + uint64_t lo; + uint32_t * pword = reinterpret_cast<uint32_t*>(&i); + + hi = ntohl( *pword ); + lo = ntohl( *(pword+1) ); + + return (hi<<32)|lo; + } + + + // Data + FILE * iv_Stream; ///< Associated stream + + +}; + + + + +#endif //ERRLPARSER_H diff --git a/src/include/usr/errl/parser/errlusrparser.H b/src/include/usr/errl/parser/errlusrparser.H new file mode 100755 index 000000000..7594321bc --- /dev/null +++ b/src/include/usr/errl/parser/errlusrparser.H @@ -0,0 +1,105 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/include/usr/errl/parser/errlusrparser.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 PARSER_ERRLUSRPARSER_H +#define PARSER_ERRLUSRPARSER_H + +/** + * @file errlusrparser.H + * + * @brief Console interface implementation for error log parser + * + * Concrete implementation of the parser interface specialization for + * the console. + * +*/ + + +/*****************************************************************************/ +// I n c l u d e s +/*****************************************************************************/ +#include <stdint.h> +#include <stdlib.h> +#include <stdio.h> + + +#include <errl/parser/errlparserbase.H> + +/*****************************************************************************/ +// User Types +/*****************************************************************************/ +class ErrlUsrParser : public ErrlParser +{ +public: + + + /** + * @brief Build an associated parser object + * + * Builds an associated parser object which is tied to the + * given stream. The net effect is the addition of some + * simple methods to standardize log output + * + * @param i_output + * Stream to be used for output + * + * @param i_parent + * A pointer to the parent object + * + * @note The parent could be null + * + */ + ErrlUsrParser( + FILE * i_output = stdout + ) + : ErrlParser( i_output ) + { + } + + + // String + void PrintString( + const char * i_label, + const char * i_string + ); + + + // Print a Number + void PrintNumber( + const char * i_label, + const char * i_fmt, + uint32_t i_value + ); + + + // Hex Dump + void PrintHexDump( + const void * i_data, + uint32_t i_len + ); + + +}; + + + +#endif //ERRLUSRPARSER_H diff --git a/src/include/usr/hbotcompid.H b/src/include/usr/hbotcompid.H index 8f1c6e382..bc742e230 100644 --- a/src/include/usr/hbotcompid.H +++ b/src/include/usr/hbotcompid.H @@ -54,13 +54,13 @@ const char MY_COMP_NAME[] = "myname"; /** @name ERRL * Error Logging component. - * + * * Oct 2011: Temporarily set ERRL component ID to the - * same as FSP ERRL in order to make the FSP x86 errl tool + * same as FSP ERRL in order to make the FSP x86 errl tool * format Hostboot error logs with traces. For user-defined * trace sections, that tools expects component 0x3100, - * section ID 0x0C, and version 1. - * + * section ID 0x0C, and version 1. + * * Requirement SW105241 is opened for fips8xx errl tool * to start becoming Hostboot aware. TODO When errl becomes * Hostboot aware, ERRL comp id can revert to 0x0100. Monte @@ -164,5 +164,14 @@ const compId_t FSISCOM_COMP_ID = 0x0D00; const char FSISCOM_COMP_NAME[] = "fsiscom"; //@} +// ---------------------------------------------------------- +// CXXTEST Unit Test, reserve compid near the end... +/** @name CXXTEST + * CxxTest component + */ +//@{ +const compId_t CXXTEST_COMP_ID = 0xFD00; +const char CXXTEST_COMP_NAME[] = "CxxTest"; +//@} #endif diff --git a/src/usr/cxxtest/cxxtestexec.C b/src/usr/cxxtest/cxxtestexec.C index 31c58824c..5023c7a5b 100644 --- a/src/usr/cxxtest/cxxtestexec.C +++ b/src/usr/cxxtest/cxxtestexec.C @@ -29,7 +29,7 @@ #include <sys/sync.h> #include <errl/errlentry.H> #include <errl/errlmanager.H> - +# #include <initservice/taskargs.H> #include <cxxtest/TestSuite.H> @@ -139,6 +139,9 @@ void _start(void *io_pArgs) TRACFCOMP( g_trac_cxxtest, " trace calls: %d", CxxTest::g_TraceCalls ); + // dump out an informational errorlog + assert(l_errl == NULL); + TASKARGS_WAIT_AND_ENDTASK(); } diff --git a/src/usr/cxxtest/makefile b/src/usr/cxxtest/makefile index c7ab1c1f6..979ae0bd4 100644 --- a/src/usr/cxxtest/makefile +++ b/src/usr/cxxtest/makefile @@ -24,7 +24,7 @@ ROOTPATH = ../../.. MODULE = cxxtest -SUBDIRS=test.d +SUBDIRS=test.d OBJS = TestSuite.o cxxtestexec.o diff --git a/src/usr/errl/errlentry.C b/src/usr/errl/errlentry.C index 902d43544..ee688dc86 100644 --- a/src/usr/errl/errlentry.C +++ b/src/usr/errl/errlentry.C @@ -132,7 +132,6 @@ void ErrlEntry::appendToFFDC(ErrlUD * i_pErrlUD, return; } - /////////////////////////////////////////////////////////////////////////////// // Return a Boolean indication of success. @@ -241,8 +240,6 @@ void ErrlEntry::setSubSys(const epubSubSystem_t i_subSys) return; } - - /////////////////////////////////////////////////////////////////////////////// // for use by ErrlManager void ErrlEntry::commit( compId_t i_committerComponent ) diff --git a/src/usr/errl/parser/errlparser.C b/src/usr/errl/parser/errlparser.C index ccf9bf915..9e733a701 100644 --- a/src/usr/errl/parser/errlparser.C +++ b/src/usr/errl/parser/errlparser.C @@ -62,12 +62,13 @@ #include <vector> using namespace std; - #include <errl/errltypes.H> #include <hbotcompid.H> +// userdetail +#include <errl/parser/errlusrparser.H> -// Include the file that was generated by scanforsrcs.pl +// this should be last, otherwise it will not find all the namespaces #include <hostBootSrcParse.H> diff --git a/src/usr/errl/parser/errlparserbase.C b/src/usr/errl/parser/errlparserbase.C new file mode 100644 index 000000000..5baf03e09 --- /dev/null +++ b/src/usr/errl/parser/errlparserbase.C @@ -0,0 +1,81 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/usr/errl/parser/errlparserbase.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 errlparsebase.C + * + * @brief <Brief Description of this file> + * + * <Detailed description of what this file does, functions it includes, + * etc,> +*/ + + +/*****************************************************************************/ +// I n c l u d e s +/*****************************************************************************/ +#include <errl/parser/errlparserbase.H> + + +///< Maximum displayable characters +static const int LINE_WIDTH = 78; + + + +/*****************************************************************************/ +// Constructor +/*****************************************************************************/ +ErrlParser::ErrlParser( + FILE * i_output +) +{ + +} + + +/*****************************************************************************/ +// Destructor +/*****************************************************************************/ +ErrlParser::~ErrlParser() +{ + +} + + +/*****************************************************************************/ +// Numeric Print +/*****************************************************************************/ +void ErrlParser::PrintNumber( + const char * i_label, + const char * i_fmt, + uint32_t i_value +) +{ + char l_tmp[LINE_WIDTH]; + + snprintf(l_tmp,LINE_WIDTH,i_fmt,i_value); + l_tmp[LINE_WIDTH-1] = 0; + + PrintString( i_label, l_tmp ); +} + + diff --git a/src/usr/errl/parser/errlusrparser.C b/src/usr/errl/parser/errlusrparser.C new file mode 100755 index 000000000..569b2202d --- /dev/null +++ b/src/usr/errl/parser/errlusrparser.C @@ -0,0 +1,185 @@ +// IBM_PROLOG_BEGIN_TAG +// This is an automatically generated prolog. +// +// $Source: src/usr/errl/parser/errlusrparser.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 errlusrparser.C + * + * @brief <Brief Description of this file> + * + * <Detailed description of what this file does, functions it includes, + * etc,> +*/ + +/*****************************************************************************/ +// I n c l u d e s +/*****************************************************************************/ +#include <cstring> +#include <ctype.h> +#include <cstdarg> + +#include <errl/parser/errlusrparser.H> + +/*****************************************************************************/ +// Constant string defines +/*****************************************************************************/ +const char * ERRL_MSG_UNKNOWN = "Unknown"; +const char * ERRL_MSG_BOOL_TRUE = "True"; +const char * ERRL_MSG_BOOL_FALSE = "False"; +const char * ERRL_MSG_STR_ENABLED = "Enabled"; +const char * ERRL_MSG_STR_DISABLED = "Disabled"; + + +/*****************************************************************************/ +// Send the label & return # of chars printed +/*****************************************************************************/ +static int PrintLabel( + FILE * i_stream, + const char * i_label + ) +{ + if ( ! i_label ) + { + i_label = ""; + } + + return fprintf(i_stream,"| %-25.25s: ",i_label); +} + + +/*****************************************************************************/ +// Regular string ( may be multiline ) +/*****************************************************************************/ +void ErrlUsrParser::PrintString( + const char * i_label, + const char * i_string + ) +{ + // Must make sure the string fits on the available width + int l_strlen = 0; + int l_printed = 0; + + + // Ensure String is valid + if ( i_string ) + { + l_strlen = strlen( i_string ); + } + + // Fake a blank string + if ( ! l_strlen ) + { + l_strlen = 1; + i_string = " "; + } + + // Print it out + while ( l_strlen > l_printed ) + { + // Leader ( label or blanks ) + PrintLabel( iv_Stream, i_label ); + + // label is only printed once + i_label = ""; + + l_printed += fprintf( + iv_Stream, + "%-50.50s", + i_string+l_printed + ); + + fprintf(iv_Stream,"|\n"); + } +} +/*****************************************************************************/ +// Numeric Print +/*****************************************************************************/ +void ErrlUsrParser::PrintNumber( + const char * i_label, + const char * i_fmt, + uint32_t i_value + ){ + ErrlParser::PrintNumber( i_label, i_fmt, i_value ); +} + + +/*****************************************************************************/ +// Hex Dump +/*****************************************************************************/ +void ErrlUsrParser::PrintHexDump( + const void * i_data, + uint32_t i_len + ) +{ + uint32_t i = 0 ; + uint32_t l_counter = 0; + uint32_t l_written; + uint8_t *l_data = (uint8_t*)i_data; + + while ( l_counter < i_len) + { + fprintf(iv_Stream,"| %08X ",l_counter); + + // Display 16 bytes in Hex with 2 spaces in between + l_written = 0; + for ( i = 0; i < 16 && l_counter < i_len; i++ ) + { + l_written += fprintf(iv_Stream,"%02X",l_data[l_counter++]); + + if ( ! ( l_counter % 4 ) ) + { + l_written += fprintf(iv_Stream," "); + } + } + + // Pad with spaces + fprintf(iv_Stream,"%-*c",43-l_written,' '); + + // Display ASCII -- fk1 + l_written = 0; + uint8_t l_char; + for ( ; i > 0 ; i-- ) + { + l_char = l_data[ l_counter-i ]; + + if ( isprint( l_char ) && + ( l_char != '&' ) && + ( l_char != '<' ) && + ( l_char != '>' ) + ) + { + l_written += fprintf( iv_Stream,"%c",l_char ); + } + else + { + l_written += fprintf( iv_Stream,"." ); + } + } + + // Pad with spaces -- fk1 + fprintf( iv_Stream,"%-*c|\n",19-l_written,' ' ); + + + + } +} + + diff --git a/src/usr/errl/parser/makefile b/src/usr/errl/parser/makefile index 8b91e14ab..41c5df796 100644 --- a/src/usr/errl/parser/makefile +++ b/src/usr/errl/parser/makefile @@ -21,17 +21,14 @@ # # IBM_PROLOG_END - # makefile for errlparser, # a 32-bit x86 linux binary suitable for running on GFW pool machines. - ROOTPATH=../../../.. -GENDIR = ${ROOTPATH}/obj/genfiles -IMGDIR = ${ROOTPATH}/img +include ${ROOTPATH}/src/usr/parser.mk -OBJDIR = ${ROOTPATH}/obj/modules/errlparser +OBJFILES = errlparserbase.o errlusrparser.o SRCPARSE_HEADER_TARGET = \ ${GENDIR}/hostBootSrcParse.H @@ -39,40 +36,47 @@ SRCPARSE_HEADER_TARGET = \ CC=i686-mcp6-g++ -m32 CFLAGS:=-g -O0 -I $(ROOTPATH)/src/include/usr -D PARSER - all: gen_pass code_pass gen_pass: code_pass: makeobjdir ${IMGDIR}/errlparser ${SRCPARSE_HEADER_TARGET} +## errlparserbase and errlusrparser +%.o : %.C + $(CC) -c $(CFLAGS) -o $@ $< + clean: rm -fr ${SRCPARSE_HEADER_TARGET} rm -fr ${OBJDIR}/errlparser.o rm -fr ${GENDIR}/errlparser rm -fr ${GENDIR}/comps.C - -beam: - + rm -fr ${OBJDIR}/*.o + rm -fr *.o makeobjdir: mkdir -p ${OBJDIR} -${GENDIR}/comps.C: $(ROOTPATH)/src/include/usr/hbotcompid.H +${GENDIR}/comps.C: ${ROOTPATH}/src/include/usr/hbotcompid.H grep "const compId_t [A-Z0-9]*_COMP_ID" $^ | \ grep -v MY_COMP_ID | \ sed 's/const compId_t \([A-Z0-9]*\)_COMP_ID[ =\t]*\(0[xX][0-9a-fA-F]*\).*/{ "\1", \2 },/' \ > $@ -${OBJDIR}/errlparser.o: errlparser.C $(ROOTPATH)/src/include/usr/errl/errltypes.H ${GENDIR}/comps.C \ - ${SRCPARSE_HEADER_TARGET} +${OBJDIR}/errlparser.o: errlparser.C ${ROOTPATH}/src/include/usr/errl/errltypes.H ${GENDIR}/comps.C ${SRCPARSE_HEADER_TARGET} $(CC) -c $(CFLAGS) -I${ROOTPATH}/obj/genfiles -o $@ $< -${IMGDIR}/errlparser: ${OBJDIR}/errlparser.o - $(CC) -o $@ $< +${IMGDIR}/errlparser: ${OBJDIR}/errlparser.o ${OBJFILES} ${UD_FILES} + $(CC) -o $@ $? + +## TODO add link step to link in UD_FILES ${SRCPARSE_HEADER_TARGET} : ./scanforsrcs.pl -b ${ROOTPATH} -o ${GENDIR} - +debug: + ls -l ${GENDIR} + ls -l ${OBJDIR} + ls -l ${IMGDIR} + ls -l ${UD_DIR} diff --git a/src/usr/errl/test/errluserdetailtest.H b/src/usr/errl/test/errluserdetailtest.H index 398192d23..9f8b93f62 100644 --- a/src/usr/errl/test/errluserdetailtest.H +++ b/src/usr/errl/test/errluserdetailtest.H @@ -26,27 +26,52 @@ /** * @file errluserdetailstest.H * - * @brief Test user data plugin for errorlog. + * @brief Test user data plugins for errorlog. * */ #include <cxxtest/TestSuite.H> #include <errl/errlentry.H> #include <errl/errluserdetails.H> +#include <errl/errlreasoncodes.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; + +enum +{ + UTIL_COMP_ID = 0x8A00, + +}; +// Subsection values, copied from FIPS. +enum +{ + UTIL_UDT_STREAM_PERC = 0x0001,///< Perc Data for Streams + UTIL_UDT_MEM_ALLOC = 0x0002,///< Memory Allocation Failure + UTIL_UDT_REG_KEYS = 0x0003,///< Registry key name, with data + UTIL_UDT_FILENAME = 0x0004,///< A null terminated filename + UTIL_UDT_FLOCK = 0x0005,///< An flock struct + UTIL_UDT_SEMAPHORE = 0x0006,///< A semaphore object + UTIL_UDT_LIBNAME = 0x0007,///< Name of the library + UTIL_UDT_REG_DATA = 0x0008,///< Payload data for UtilReg::write + UTIL_UDT_ERR_MSG = 0x0009,///< An error message string + UTIL_UDT_INOTIFY_PATH = 0x000a,///< The path name in error + UTIL_UDT_XML_TOKEN = 0x000b,///< The XML token in error + // + // dummy one for Stackdump + TEST_STACKDUMP_SUBSECT = 0x0055 // dummy subsection # for stackdump +}; /** * Declare a test UserDetails derived class to post a filename string to - * the errorlog + * the errorlog. + * These are canned routines that are handled by the errl tool. + * * This is just for test purposes, it will not show up in production code. + * The values for version and subsection should match the actual filename + * UD section parser routing in the errl tool - you should see it parse it + * correctly. */ class TestFilename : public ErrlUserDetails { @@ -54,9 +79,10 @@ public: TestFilename(const char *i_filename) { - iv_CompId = ERRL_COMP_ID; - iv_Version = TEST_FILENAME_VER; - iv_SubSection = TEST_FILENAME_SUBSECT; + + iv_CompId = UTIL_COMP_ID; + iv_Version = 1; + iv_SubSection = UTIL_UDT_FILENAME; // Store the string in the internal buffer char * l_pString = (char *)allocUsrBuf( strlen(i_filename)+1 ); @@ -76,56 +102,89 @@ private: 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. + * Declare a test UserDetails derived class to post an error message + * filename string to the errorlog + * These are canned routines that are handled by the errl tool. * - * This is just a test program, it will not be used in production code. - * 64-bit stack addrs will need other support + * This is just for test purposes, it will not show up in production code. + * The values for version and subsection should match the actual filename + * UD section parser routing in the errl tool - you should see it parse it + * correctly. */ -class TestStackDump : public ErrlUserDetails +class TestErrorMsg : public ErrlUserDetails { public: - - TestStackDump( const uint64_t i_numAddrs, const uint64_t * i_paddrs ) + TestErrorMsg(const char *i_filename) { - 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*) ) ); + iv_CompId = UTIL_COMP_ID; + iv_Version = 1; + iv_SubSection = UTIL_UDT_ERR_MSG; - l_pList[0] = i_numAddrs; - for (uint64_t i=0; i<i_numAddrs; i++ ) - { - l_pList[i+1] = i_paddrs[i]; - } + // Store the string in the internal buffer + char * l_pString = (char *)allocUsrBuf( strlen(i_filename)+1 ); + strcpy(l_pString, i_filename ); } /** * @brief Destructor * */ - virtual ~TestStackDump() {} + virtual ~TestErrorMsg() {} private: // Disabled - TestStackDump(const TestStackDump &); - TestStackDump & operator=(const TestStackDump &); + TestErrorMsg(const TestErrorMsg &); + TestErrorMsg & operator=(const TestErrorMsg &); }; +/** + * Declare a test UserDetails derived class to post an XML token in error + * to the errorlog + * These are canned routines that are handled by the errl tool. + * + * This is just for test purposes, it will not show up in production code. + * The values for version and subsection should match the actual filename + * UD section parser routing in the errl tool - you should see it parse it + * correctly. + */ +class TestXMLToken : public ErrlUserDetails +{ +public: + TestXMLToken(const char *i_filename) + { + iv_CompId = UTIL_COMP_ID; + iv_Version = 1; + iv_SubSection = UTIL_UDT_XML_TOKEN; -// + // Store the string in the internal buffer + char * l_pString = (char *)allocUsrBuf( strlen(i_filename)+1 ); + strcpy(l_pString, i_filename ); + } + + /** + * @brief Destructor + * + */ + virtual ~TestXMLToken() {} + +private: + + // Disabled + TestXMLToken(const TestXMLToken &); + TestXMLToken & operator=(const TestXMLToken &); +}; + + +// -------------------------------------------------------------------------- // begin actual test code.. -// +// -------------------------------------------------------------------------- class UtilErrlUsrDataTest: public CxxTest::TestSuite { public: @@ -139,13 +198,21 @@ public: errlHndl_t l_errl = NULL; TS_TRACE( "testFILENAME user data buffer for errorlog"); - + /*@ + * @errortype + * @severity ERRORLOG_SEV_INFORMATIONAL + * @moduleid ERRL_USERDETAILS_MODULE_ID + * @reasoncode ERRL_FILENAME_TEST + * @userdata1 <UNUSED> + * @userdata2 <UNUSED> + * @devdesc User Details unit test - post a filename user data section + */ l_errl = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_INFORMATIONAL, - TEST_MOD_ID, - ERRL_COMP_ID | 0x55, // compid/reasoncode - 0x1234567890, // user1 - 0x9876543210 ); // user2 + ERRL_USERDETAILS_MODULE_ID, + ERRL_FILENAME_TEST, // compid/reasoncode + 0x1234567890, // user1 + 0x9876543210 ); // user2 if( l_errl == NULL ) { TS_FAIL("Could not create errlog.\n"); @@ -153,16 +220,14 @@ public: } // create the filename userdata object - // - TestFilename l_FN_userdata( "foobar.txt" ); + TestFilename l_FN_userdata( "/path/to/myfile.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"; + const char testfnstr1[] = "addedfilename.txt"; l_FN_userdata.addToLog( l_errl, testfnstr1, sizeof(testfnstr1) ); - // // Add another string. // @@ -178,59 +243,90 @@ public: } /** - * @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. - * + * @test testErrorMsg - create a simple UD section in the errorlog + * that stores an error message */ - void testStackDump(void) + void testErrorMsg(void) { errlHndl_t l_errl = NULL; - uint64_t l_addrs[] = + + TS_TRACE( "testErrorMsg user data buffer for errorlog"); + /*@ + * @errortype + * @severity ERRORLOG_SEV_INFORMATIONAL + * @moduleid ERRL_USERDETAILS_MODULE_ID + * @reasoncode ERRL_ERRORMSG_TEST + * @userdata1 <UNUSED> + * @userdata2 <UNUSED> + * @devdesc User Details unit test - post an error message in a + * user data section + */ + l_errl = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_INFORMATIONAL, + ERRL_USERDETAILS_MODULE_ID, + ERRL_ERRORMSG_TEST, // compid/reasoncode + 0x1212121212, // user1 + 0x3434343434 ); // user2 + if( l_errl == NULL ) { - 0x01234567, - 0xDEADBEEF, - 0x5555aaaa, - 0x69696969, - 0x34920781, - 0xaaaa5555, - 0x68392090, - 0x95720856, - 0xabcdef01, - 0x12345670 - }; + TS_FAIL("Could not create errlog.\n"); + return; + } + + // create the filename userdata object + TestErrorMsg l_userdata( "The UserData library has failed to fail." ); - TS_TRACE( "testStackDump add Userdata Section ot errorlog"); + // add it to the log + l_userdata.addToLog( l_errl ); + // commit the errorlog + errlCommit(l_errl ); + } + + /** + * @test testXMLToken - create a simple UD section in the errorlog + * that stores the name of an xml token in error. + */ + void testXMLToken(void) + { + errlHndl_t l_errl = NULL; + + TS_TRACE( "testXMLToken user data buffer for errorlog"); + /*@ + * @errortype + * @severity ERRORLOG_SEV_INFORMATIONAL + * @moduleid ERRL_USERDETAILS_MODULE_ID + * @reasoncode ERRL_XMLTOKEN_TEST + * @userdata1 <UNUSED> + * @userdata2 <UNUSED> + * @devdesc User Details unit test - post an XML token in error as + * a user data section + */ l_errl = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_INFORMATIONAL, - TEST_MOD_ID, - ERRL_COMP_ID | 0x56, // compid/reasoncode - 0x0101010101, // user1 - 0x0202020202 ); // user2 + ERRL_USERDETAILS_MODULE_ID, + ERRL_XMLTOKEN_TEST, // compid/reasoncode + 0xa5a5a5a5a5, // user1 + 0xd2d2d2d2d2 ); // 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]) ); + // create the filename userdata object + TestXMLToken l_userdata( "HWAS_STATE" ); - TS_TRACE("run addToLog"); - l_stackDump.addToLog( l_errl ); + // add it to the log + l_userdata.addToLog( l_errl ); - errlCommit( l_errl ); + // commit the errorlog + errlCommit(l_errl ); } }; - - #endif diff --git a/src/usr/parser.mk b/src/usr/parser.mk new file mode 100644 index 000000000..4666d5fc6 --- /dev/null +++ b/src/usr/parser.mk @@ -0,0 +1,30 @@ +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: src/usr/parser.mk $ +# +# 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 +# Common file for x86 parser files + +GENDIR = ${ROOTPATH}/obj/genfiles +IMGDIR = ${ROOTPATH}/img +OBJDIR = ${ROOTPATH}/obj/modules/parser +UD_DIR = ${ROOTPATH}/obj/modules/userdetails + +## UD_FILES = ${UD_DIR}/*.o
\ No newline at end of file |