diff options
Diffstat (limited to 'src/usr/errl/parser')
| -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 |
4 files changed, 288 insertions, 17 deletions
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} |

