diff options
author | Mike Jones <mjjones@us.ibm.com> | 2013-01-22 09:41:25 -0600 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2013-02-08 16:49:45 -0600 |
commit | caf328ccd931de4ce4e4d285d1a4e5ddd151abb5 (patch) | |
tree | 650c28362fef4b7fd3d8e727d2b13e25f119434b /src/usr/errl | |
parent | 7c50ac8fa046052334326fd4f3c8447cb0c9514d (diff) | |
download | blackbird-hostboot-caf328ccd931de4ce4e4d285d1a4e5ddd151abb5.tar.gz blackbird-hostboot-caf328ccd931de4ce4e4d285d1a4e5ddd151abb5.zip |
ERRL: Create Hostboot error log SRC/UD parser and deliver to FSP bld
A new script called genErrlParsers will scan the Hostboot code for
error log tags and create a SRC parser for each component. The
script will also scan the Hostboot code for plugin directories
containing User Detail Data parsers and will create a makefile
that is used by the FSP to build each component's SRC/UD parser.
Change-Id: I7113f6cd8069447a1caaa199aff199b663d59072
RTC: 47518
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/2975
Tested-by: Jenkins Server
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/errl')
28 files changed, 2231 insertions, 1226 deletions
diff --git a/src/usr/errl/errlentry.C b/src/usr/errl/errlentry.C index 374277df4..a48fa4db7 100644 --- a/src/usr/errl/errlentry.C +++ b/src/usr/errl/errlentry.C @@ -5,7 +5,7 @@ /* */ /* IBM CONFIDENTIAL */ /* */ -/* COPYRIGHT International Business Machines Corp. 2011,2012 */ +/* COPYRIGHT International Business Machines Corp. 2011,2013 */ /* */ /* p1 */ /* */ @@ -37,6 +37,7 @@ #include <errl/errlmanager.H> #include <errl/errludbacktrace.H> #include <errl/errludcallout.H> +#include <errl/errlreasoncodes.H> #include <trace/interface.H> #include <arch/ppc.H> #include <hwas/common/hwasCallout.H> @@ -305,9 +306,9 @@ void ErrlEntry::commit( compId_t i_committerComponent ) it++ ) { // if this is a CALLOUT - if ((HBERRL_COMP_ID == (*it)->iv_header.iv_compId) && + if ((ERRL_COMP_ID == (*it)->iv_header.iv_compId) && (1 == (*it)->iv_header.iv_ver) && - (HBERRL_UDT_CALLOUT == (*it)->iv_header.iv_sst)) + (ERRL_UDT_CALLOUT == (*it)->iv_header.iv_sst)) { // call HWAS to have this processed (*pFn)(plid(),(*it)->iv_pData, (*it)->iv_Size); diff --git a/src/usr/errl/errlud.C b/src/usr/errl/errlud.C index 0a442781b..09be2bacf 100644 --- a/src/usr/errl/errlud.C +++ b/src/usr/errl/errlud.C @@ -1,25 +1,25 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: src/usr/errl/errlud.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/errlud.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 errlud.C * @@ -145,6 +145,13 @@ uint64_t ErrlUD::flatten( void * o_pBuffer, const uint64_t i_cbBuffer ) // Followed by the user data memcpy( pBuffer, iv_pData, iv_Size ); + pBuffer += iv_Size; + + // Buffer is rounded up to the nearst 4-byte boundary, pad with zeroes + for (uint64_t i = l_cb + iv_Size; i < l_cbFlat; i++) + { + *pBuffer++ = 0; + } // return how many bytes were flattened l_rc = l_cbFlat; diff --git a/src/usr/errl/errludbacktrace.C b/src/usr/errl/errludbacktrace.C index 407af55de..73afc9db2 100644 --- a/src/usr/errl/errludbacktrace.C +++ b/src/usr/errl/errludbacktrace.C @@ -1,31 +1,32 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: src/usr/errl/errludbacktrace.C $ -// -// IBM CONFIDENTIAL -// -// COPYRIGHT International Business Machines Corp. 2012 -// -// 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/errludbacktrace.C $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2012,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 errludbacktrace.C * * @brief Implementation of ErrlUserDetailsBackTrace */ #include <errl/errludbacktrace.H> +#include <errl/errlreasoncodes.H> #include <errl/backtrace.H> namespace ERRORLOG @@ -45,9 +46,9 @@ ErrlUserDetailsBackTrace::ErrlUserDetailsBackTrace() memcpy(l_pBuf, &l_bt[0], l_size); // Set up ErrlUserDetails instance variables - iv_CompId = HBERRL_COMP_ID; + iv_CompId = ERRL_COMP_ID; iv_Version = 1; - iv_SubSection = HBERRL_UDT_BACKTRACE; + iv_SubSection = ERRL_UDT_BACKTRACE; } } diff --git a/src/usr/errl/errludcallout.C b/src/usr/errl/errludcallout.C index aa6b61204..3fa43078e 100644 --- a/src/usr/errl/errludcallout.C +++ b/src/usr/errl/errludcallout.C @@ -1,26 +1,25 @@ -/* IBM_PROLOG_BEGIN_TAG - * This is an automatically generated prolog. - * - * $Source: src/usr/errl/errludcallout.C $ - * - * IBM CONFIDENTIAL - * - * COPYRIGHT International Business Machines Corp. 2012 - * - * 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_TAG - */ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/errl/errludcallout.C $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2012,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 errludcallout.C * @@ -28,7 +27,7 @@ */ #include <sys/task.h> #include <errl/errludcallout.H> - +#include <errl/errlreasoncodes.H> #include <targeting/common/targetservice.H> #include <targeting/common/util.H> #include <targeting/common/trace.H> @@ -50,9 +49,9 @@ ErrlUserDetailsCallout::ErrlUserDetailsCallout( TRACDCOMP(g_trac_errl, "HWCallout entry"); // Set up ErrlUserDetails instance variables - iv_CompId = HBERRL_COMP_ID; + iv_CompId = ERRL_COMP_ID; iv_Version = 1; - iv_SubSection = HBERRL_UDT_CALLOUT; + iv_SubSection = ERRL_UDT_CALLOUT; //iv_merge = false; // use the default of false @@ -81,9 +80,9 @@ ErrlUserDetailsCallout::ErrlUserDetailsCallout( TRACDCOMP(g_trac_errl, "Procedure Callout"); // Set up ErrlUserDetails instance variables - iv_CompId = HBERRL_COMP_ID; + iv_CompId = ERRL_COMP_ID; iv_Version = 1; - iv_SubSection = HBERRL_UDT_CALLOUT; + iv_SubSection = ERRL_UDT_CALLOUT; //iv_merge = false; // use the default of false diff --git a/src/usr/errl/errludlogregister.C b/src/usr/errl/errludlogregister.C index a16c291f8..722b3680a 100644 --- a/src/usr/errl/errludlogregister.C +++ b/src/usr/errl/errludlogregister.C @@ -1,33 +1,32 @@ -/* IBM_PROLOG_BEGIN_TAG - * This is an automatically generated prolog. - * - * $Source: src/usr/errl/errludlogregister.C $ - * - * IBM CONFIDENTIAL - * - * COPYRIGHT International Business Machines Corp. 2012 - * - * 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_TAG - */ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/errl/errludlogregister.C $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2012,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 errludlogregister.C * * @brief Implementation of ErrlUserDetailsLogRegister */ #include <errl/errludlogregister.H> - +#include <errl/errlreasoncodes.H> #include <targeting/common/targetservice.H> #include <targeting/common/util.H> #include <targeting/common/trace.H> @@ -45,9 +44,9 @@ extern TARG_TD_t g_trac_errl; void ErrlUserDetailsLogRegister::setStateLogHUID() { // Set up ErrlUserDetails instance variables - iv_CompId = HBERRL_COMP_ID; + iv_CompId = ERRL_COMP_ID; iv_Version = 1; - iv_SubSection = HBERRL_UDT_LOGREGISTER; + iv_SubSection = ERRL_UDT_LOGREGISTER; // override the default of false. iv_merge = true; diff --git a/src/usr/errl/errludstring.C b/src/usr/errl/errludstring.C index 3b1158926..c9617d99b 100644 --- a/src/usr/errl/errludstring.C +++ b/src/usr/errl/errludstring.C @@ -1,31 +1,32 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: src/usr/errl/errludstring.C $ -// -// IBM CONFIDENTIAL -// -// COPYRIGHT International Business Machines Corp. 2012 -// -// 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/errludstring.C $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2012,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 errludstring.C * * @brief Implementation of ErrlUserDetailsString */ #include <errl/errludstring.H> +#include <errl/errlreasoncodes.H> #include <string.h> namespace ERRORLOG @@ -39,9 +40,9 @@ ErrlUserDetailsString::ErrlUserDetailsString(const char * i_pString) strcpy(l_pBuf, i_pString); // Set up ErrlUserDetails instance variables - iv_CompId = HBERRL_COMP_ID; + iv_CompId = ERRL_COMP_ID; iv_Version = 1; - iv_SubSection = HBERRL_UDT_STRING; + iv_SubSection = ERRL_UDT_STRING; // override the default of false. iv_merge = true; diff --git a/src/usr/errl/errludtarget.C b/src/usr/errl/errludtarget.C index dd8109417..4d36f5e7a 100644 --- a/src/usr/errl/errludtarget.C +++ b/src/usr/errl/errludtarget.C @@ -1,31 +1,32 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: src/usr/errl/errludtarget.C $ -// -// IBM CONFIDENTIAL -// -// COPYRIGHT International Business Machines Corp. 2012 -// -// 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/errludtarget.C $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2012,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 errludtarget.C * * @brief Implementation of ErrlUserDetailsTarget */ #include <errl/errludtarget.H> +#include <errl/errlreasoncodes.H> #include <targeting/common/target.H> #include <targeting/common/targetservice.H> #include <targeting/common/trace.H> @@ -38,9 +39,9 @@ ErrlUserDetailsTarget::ErrlUserDetailsTarget( const TARGETING::Target * i_pTarget) { // Set up ErrlUserDetails instance variables - iv_CompId = HBERRL_COMP_ID; + iv_CompId = ERRL_COMP_ID; iv_Version = 1; - iv_SubSection = HBERRL_UDT_TARGET; + iv_SubSection = ERRL_UDT_TARGET; // override the default of false. //iv_merge = true; diff --git a/src/usr/errl/errluserdetails.C b/src/usr/errl/errluserdetails.C index 044e6771b..c9110e386 100644 --- a/src/usr/errl/errluserdetails.C +++ b/src/usr/errl/errluserdetails.C @@ -1,25 +1,25 @@ -// 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 +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/errl/errluserdetails.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 errluserdetails.C * @@ -37,7 +37,7 @@ namespace ERRORLOG // ErrlUserDetails default constructor /*****************************************************************************/ ErrlUserDetails::ErrlUserDetails() -: iv_CompId(HBERRL_COMP_ID), +: iv_CompId(ERRL_COMP_ID), iv_Version(0), iv_SubSection(0), iv_merge(false), diff --git a/src/usr/errl/parser/genErrlParsers.pl b/src/usr/errl/parser/genErrlParsers.pl new file mode 100755 index 000000000..33ddabbdc --- /dev/null +++ b/src/usr/errl/parser/genErrlParsers.pl @@ -0,0 +1,898 @@ +#!/usr/bin/perl +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: src/usr/errl/parser/genErrlParsers.pl $ +# +# 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 + +# Purpose: Generates files needed to parse SRC and User Detail Data from +# Hostboot error logs. The files are delivered to the FSP and built there +# +# It scans the hostboot source code for the doxygen like error log tags and +# generates a C file for each component containing a function called by the FSP +# errl tool to parse the error log SRC, for example: +# - hbfwSrcParse1.C (For parsing errlogs generated by comp-id 0x01) +# - hbfwSrcParse2.C +# - hbfwSrcParse3.C +# It generates a file that contains IDs needed by the Hostboot User Detail Data +# parsers +# - hbfwUdIds.H +# It generates a makefile that builds the Hostboot SRC/UserDetailData parsers +# - makefile + +use strict; +use Time::localtime; + +#------------------------------------------------------------------------------ +# Process Arguments +#------------------------------------------------------------------------------ +my $DEBUG = 0; +my $base = "."; +my $outputDir = "."; + +while( $ARGV = shift ) +{ + if( $ARGV =~ m/-b/ ) + { + $base = shift; + } + elsif( $ARGV =~ m/-o/i ) + { + $outputDir = shift; + } + elsif( $ARGV =~ m/-d/i ) + { + $DEBUG = 1; + } + else + { + usage(); + } +} + +#------------------------------------------------------------------------------ +# Global variables +#------------------------------------------------------------------------------ +my $compIdFile = $base."/src/include/usr/hbotcompid.H"; +my $compPath = $base."/src/usr"; +my $compIncPath = $base."/src/include/usr"; +my $genFilesPath = $base."/obj/genfiles"; + +#------------------------------------------------------------------------------ +# Call subroutines to populate the following arrays: +# - @reasonCodeFiles (The list of files to parse through for reason codes) +# - @filesToParse (The list of files to parse through for SRC tags) +# - @pluginDirsToParse (the list of plugin directories containing User Detail +# Data parsers) +#------------------------------------------------------------------------------ +my @reasonCodeFiles; +my @filesToParse; +my @pluginDirsToParse; +getReasonCodeFiles($compIncPath); +getFilesToParse($compPath); +getFilesToParse($compIncPath); +getFilesToParse($genFilesPath); +getPluginDirsToParse($compPath); + +if ($DEBUG) +{ + print("---> ReasonCode files to process\n"); + foreach my $file(@reasonCodeFiles) + { + print("RC File: $file\n"); + } +} + +if ($DEBUG) +{ + print("---> Files to parse for error log tags\n"); + foreach my $file(@filesToParse) + { + print("File to Parse: $file\n"); + } +} + +if ($DEBUG) +{ + print("---> Directories to parse for user detail data\n"); + foreach my $dir(@pluginDirsToParse) + { + print("Plugin Directory to Parse: $dir\n"); + } +} + +#------------------------------------------------------------------------------ +# Process the compIdFile, recording all of the component ID values +#------------------------------------------------------------------------------ +my %compIdToValueHash; + +open(COMP_ID_FILE, $compIdFile) or die("Cannot open: $compIdFile: $!"); + +while (my $line = <COMP_ID_FILE>) +{ + # An example of the component ID line is: + # const compId_t DEVFW_COMP_ID = 0x0200; + if ($line =~ /^const compId_t (\w+) = 0x([\dA-Fa-f]+)00/) + { + my $compId = $1; + my $compValue = $2; + + # Strip off any leading zeroes from the component value + $compValue =~ s/^0//g; + + $compIdToValueHash{$compId} = $compValue; + } +} + +close(COMP_ID_FILE); + +if ($DEBUG) +{ + print("---> Component ID values\n"); + foreach my $key (keys %compIdToValueHash) + { + print ("CompId: $key = $compIdToValueHash{$key},\n"); + } +} + +#------------------------------------------------------------------------------ +# Process the reasonCodeFiles, recording all of the module ids, reason codes +# and user detail data sections in hashes: The module ids and reason codes +# can be duplicated across components and so the namespace is also stored. +# Example hashes: +# +# %modIdToValueHash = ( +# 'PNOR' => { 'MOD_PNORDD_ERASEFLASH' => '1A', +# 'MOD_PNORDD_READFLASH' => '12'}, +# 'IBSCOM' => { 'IBSCOM_GET_TARG_VIRT_ADDR' => '03', +# 'IBSCOM_SANITY_CHECK' => '02'} +# ); +# +# %rcToValueHash = ( +# 'PNOR' => { 'RC_UNSUPPORTED_OPERATION' => '0607', +# 'RC_STARTUP_FAIL' => '0605'}, +# 'IBSCOM' => { 'IBSCOM_INVALID_CONFIG' => '1C03', +# 'IBSCOM_INVALID_OP_TYPE' => '1C02'} +# ); +# +# %udIdToValueHash = ( +# 'HWPF_UDT_HWP_RCVALUE' => '0x01', +# 'ERRL_UDT_CALLOUT' => '0x07' +# ); +#------------------------------------------------------------------------------ +my %modIdToValueHash; +my %rcToValueHash; +my %udIdToValueHash; + +foreach my $file (@reasonCodeFiles) +{ + open(RC_FILE, $file) or die("Cannot open: $file: $!"); + my $namespace = "NO_NS"; + my $processing = 0; + my $processingModIds = 1; + my $processingRcs = 2; + my $processingUds = 3; + my $compId = ""; + + while (my $line = <RC_FILE>) + { + if ($line =~ /^\s*namespace\s+(\w+)/) + { + if ($namespace ne "NO_NS") + { + print ("$0: Multiple namespaces in '$file'\n"); + exit(1); + } + $namespace = $1; + + # Check for common code files where the reason codes do not contain + # component IDs. Expand this hash as needed to add more components + my %namespaceToCompHash = ( + "HWAS" => "HWAS_COMP_ID"); + + if (exists $namespaceToCompHash{$namespace}) + { + # Reason codes do not contain component IDs + $compId = $namespaceToCompHash{$namespace}; + } + else + { + # Reason codes contain component IDs + $compId = ""; + } + + next; + } + elsif ($line =~ /enum.+ModuleId/i) + { + $processing = $processingModIds; + next; + } + elsif ($line =~ /enum.+ReasonCode/i) + { + $processing = $processingRcs; + next; + } + elsif ($line =~ /enum.+UserDetail/i) + { + $processing = $processingUds; + next; + } + elsif ($line =~ /}/) + { + $processing = 0; + next; + } + + if ($processing == $processingModIds) + { + # Example: "MOD_PNORRP_WAITFORMESSAGE = 0x01" + if ($line =~ /(\w+)\s+=\s+0x([\dA-Fa-f]+)/) + { + $modIdToValueHash{$namespace}->{$1} = $2; + } + } + elsif ($processing == $processingRcs) + { + if ($compId ne "") + { + # Reason code line does not contain Component ID + # Example: "RC_TARGET_NOT_DECONFIGURABLE = 0x01," + if ($line =~ /(\w+)\s+=\s+0x([\dA-Fa-f]+)/) + { + if (! exists $compIdToValueHash{$compId}) + { + print ("$0: Could not find CompID '$compId'\n"); + exit(1); + } + $rcToValueHash{$namespace}->{$1} = + $compIdToValueHash{$compId} . $2; + } + } + else + { + # Reason code line contains Component ID + # Example: "RC_INVALID_MESSAGE_TYPE = PNOR_COMP_ID | 0x01" + if ($line =~ /(\w+)\s+=\s+(\w+)\s+\|\s+0x([\dA-Fa-f]+)/) + { + if (! exists $compIdToValueHash{$2}) + { + print ("$0: Could not find CompID '$2'\n"); + exit(1); + } + $rcToValueHash{$namespace}->{$1} = + $compIdToValueHash{$2} . $3; + } + } + } + elsif ($processing == $processingUds) + { + # Example: "HWPF_UDT_HWP_RCVALUE = 0x01," + if ($line =~ /(\w+)\s+=\s+(0x[\dA-Fa-f]+)/) + { + my $udId = $1; + my $udValue = $2; + + if (exists($udIdToValueHash{$udId})) + { + print ("$0: duplicate user data section in '$file'\n"); + print ("$0: section is '$udId'\n"); + exit(1); + } + + $udIdToValueHash{$udId} = $udValue; + } + } + } + + close(RC_FILE); +} + +if ($DEBUG) +{ + print("---> ModuleId values\n"); + foreach my $namespaceKey (keys %modIdToValueHash) + { + foreach my $modIdKey (keys %{$modIdToValueHash{$namespaceKey}}) + { + print ("$namespaceKey:$modIdKey:$modIdToValueHash{$namespaceKey}->{$modIdKey}\n"); + } + } + + print("---> ReasonCode values\n"); + foreach my $namespaceKey (keys %rcToValueHash) + { + foreach my $rcKey (keys %{$rcToValueHash{$namespaceKey}}) + { + print ("$namespaceKey:$rcKey:$rcToValueHash{$namespaceKey}->{$rcKey}\n"); + } + } + + print("---> User Detail Data Section values\n"); + foreach my $udKey (keys %udIdToValueHash) + { + print ("$udKey:$udIdToValueHash{$udKey}\n"); + } +} + +#------------------------------------------------------------------------------ +# Generate the FSP hbfwUdIds.H file that contains the set of Hostboot component +# IDs and user detail data IDs. This is used by the user data parsers +#------------------------------------------------------------------------------ +my $outputFileName = $outputDir . "/hbfwUdIds.H"; +open(OFILE, ">", $outputFileName) or die("Cannot open: $outputFileName: $!"); + +print OFILE "// Automatically generated by Hostboot's $0\n"; +print OFILE "// Do not modify this file in the FSP tree, it is provided by\n"; +print OFILE "// Hostboot and will be overwritten\n"; +print OFILE "//\n\n"; +print OFILE "\#ifndef HBFWUDIDS_H\n"; +print OFILE "\#define HBFWUDIDS_H\n\n"; +print OFILE "// Hostboot component IDs\n"; +print OFILE "namespace hbfw\n"; +print OFILE "{\n"; +print OFILE " enum\n"; +print OFILE " {\n"; +foreach my $key (keys %compIdToValueHash) +{ + print OFILE " $key = 0x$compIdToValueHash{$key}00,\n"; +} +print OFILE " };\n"; +print OFILE "}\n\n"; +print OFILE "// Hostboot User Detail Data IDs\n"; +print OFILE "enum\n"; +print OFILE "{\n"; +foreach my $udKey (keys %udIdToValueHash) +{ + print OFILE " $udKey = $udIdToValueHash{$udKey},\n"; +} +print OFILE "};\n\n"; +print OFILE "#endif\n"; + +close(OFILE); + +#------------------------------------------------------------------------------ +# Process the code files, looking for error log tags, save the parsing for each +# in a hash indexed by the component value +#------------------------------------------------------------------------------ +my %compValueToParseHash; +my %rcModValuesUsed; + +foreach my $file (@filesToParse) +{ + open(PARSE_FILE, $file) or die("Cannot open: $file: $!"); + my @namespaces; + push(@namespaces, "NO_NS"); + + #------------------------------------------------------------------------- + # Example Tag: + # /*@ + # * @errortype + # * @reasoncode I2C_INVALID_OP_TYPE + # * @severity ERRL_SEV_UNRECOVERABLE + # * @moduleid I2C_PERFORM_OP + # * @userdata1 i_opType + # * @userdata2 addr + # * @devdesc Invalid Operation type. + # */ + # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + while (my $line = <PARSE_FILE>) + { + if ($line =~ /namespace\s+(\w+)/) + { + # Found a namespace, record it to be used when searching for + # moduleid and reasoncode values + push(@namespaces, $1); + next; + } + + if ($line =~ /\/\*\@/) + { + # Found the start of an error log tag + my $modId = ""; + my $modIdValue = ""; + my $rc = ""; + my $rcValue = ""; + my @userData; + my $desc = ""; + + # Read the entire error log tag into an array + my @tag; + + while ($line = <PARSE_FILE>) + { + if ($line =~ /\*\//) + { + # Found the end of an error log tag + last; + } + push(@tag, $line); + } + + # Process the error log tag + my $numLines = scalar (@tag); + + for (my $lineNum = 0; $lineNum < $numLines; $lineNum++) + { + $line = $tag[$lineNum]; + + if ($line =~ /\@moduleid\s+(\S+)/i) + { + # Found a moduleid, find out the value + $modId = $1; + + if ($modId =~ /(\w+)::(\w+)/) + { + # The namespace was provided + if ((exists $modIdToValueHash{$1}) && + (exists ${modIdToValueHash{$1}->{$2}})) + { + $modIdValue = ${modIdToValueHash{$1}->{$2}}; + } + } + else + { + # The namespace was not provided, look through all + # namespaces mentioned in the file + foreach my $namespace(@namespaces) + { + if ((exists $modIdToValueHash{$namespace}) && + (exists ${modIdToValueHash{$namespace}->{$modId}})) + { + $modIdValue = ${modIdToValueHash{$namespace}->{$modId}}; + last; + } + } + } + + if ($modIdValue eq "") + { + print ("$0: Error finding moduleid value for '$file:$line'\n"); + exit(1); + } + } + elsif ($line =~ /\@reasoncode\s+(\S+)/i) + { + # Found a reasoncode, figure out the value + $rc = $1; + + if ($rc =~ /(\w+)::(\w+)/) + { + # The namespace was provided + if ((exists $rcToValueHash{$1}) && + (exists ${rcToValueHash{$1}->{$2}})) + { + $rcValue = ${rcToValueHash{$1}->{$2}}; + } + } + else + { + # The namespace was not provided, look through all + # namespaces mentioned in the file + foreach my $namespace(@namespaces) + { + if ((exists $rcToValueHash{$namespace}) && + (exists ${rcToValueHash{$namespace}->{$rc}})) + { + $rcValue = ${rcToValueHash{$namespace}->{$rc}}; + last; + } + } + } + + if ($rcValue eq "") + { + print ("$0: Error finding reasoncode value for '$file:$line'\n"); + exit(1); + } + } + elsif ($line =~ /\@(userdata\S+)\s+(\S+.*)/i) + { + # Found user data, strip out any double-quotes and trailing + # whitespace + my $udDesc = $1; + my $udText = $2; + $udText =~ s/\"//g; + $udText =~ s/\s+$//; + + # Look for follow-on lines + for ($lineNum++; $lineNum < $numLines; $lineNum++) + { + $line = $tag[$lineNum]; + + if ($line =~ /\@/) + { + # Found the next element, rewind + $lineNum--; + last; + } + + # Continuation of user data, strip out any double-quotes + # and leading / trailing whitespace + $line =~ s/^.+\*\s+//; + $line =~ s/\"//g; + $line =~ s/\s+$//; + + if ($line ne "") + { + $udText = $udText . " " . $line; + } + } + + my $udString = "\"$udDesc\", \"$udText\""; + push(@userData, $udString); + } + elsif ($line =~ /\@devdesc\s+(\S+.*)/i) + { + # Found a description, strip out any double-quotes and + # trailing whitespace + $desc = $1; + $desc =~ s/\"//g; + $desc =~ s/\s+$//; + + # Look for follow-on lines + for ($lineNum++; $lineNum < $numLines; $lineNum++) + { + $line = $tag[$lineNum]; + + if ($line =~ /\@/) + { + # Found the next element, rewind + $lineNum--; + last; + } + + # Continuation of description, strip out any double- + # quotes and leading / trailing whitespace + $line =~ s/^.+\*\s+//; + $line =~ s/\"//g; + $line =~ s/\s+$//; + + if ($line ne "") + { + $desc = $desc . " " . $line; + } + } + } + } + + # Check that the required fields were found + if ($modId eq "") + { + print ("$0: moduleid missing from error log tag in '$file'\n"); + print ("$0: reasoncode is '$rc'\n"); + exit(1); + } + + if ($rc eq "") + { + print ("$0: reasoncode missing from error log tag in '$file'\n"); + print ("$0: moduleid is '$modId'\n"); + exit(1); + } + + if ($desc eq "") + { + print ("$0: description missing from error log tag in '$file'\n"); + print ("$0: moduleid is '$modId', reasoncode is '$rc'\n"); + exit(1); + } + + # Create the combined returncode/moduleid value that the parser looks for and + # ensure that it is not a duplicate of one already found + my $rcModValue = $rcValue . $modIdValue; + + if (exists($rcModValuesUsed{$rcModValue})) + { + print ("$0: duplicate moduleid/reasoncode error log tag in '$file'\n"); + print ("$0: moduleid is '$modId', reasoncode is '$rc'\n"); + exit(1); + } + + $rcModValuesUsed{$rcModValue} = 1; + + # Create the parser code for this error + my $parserCode = " case 0x$rcModValue:\n" + . " i_parser.PrintString(\"devdesc\", \"$desc\");\n" + . " i_parser.PrintString(\"moduleid\", \"$modId\");\n" + . " i_parser.PrintString(\"reasoncode\", \"$rc\");\n"; + foreach my $udString(@userData) + { + $parserCode .= " i_parser.PrintString($udString);\n"; + } + $parserCode .= " break;\n\n"; + + # The component value is the first two characters of the 4 character rc + my $compValue = $rcValue; + $compValue =~ s/..$//; + + # Add the parser code to compValueToParseHash + $compValueToParseHash{$compValue} .= $parserCode; + } + } + + close(PARSE_FILE); +} + +#------------------------------------------------------------------------------ +# For each component value, print a file containing the parse code +#------------------------------------------------------------------------------ +my $timestamp = ctime(); +my $imageId = getImageId(); + +foreach my $compValue (keys %compValueToParseHash) +{ + my $outputFileName = $outputDir . "/hbfwSrcParse$compValue.C"; + open(OFILE, ">", $outputFileName) or die("Cannot open: $outputFileName: $!"); + + print OFILE "/*\n"; + print OFILE " * Automatically generated by Hostboot's $0\n"; + print OFILE " * Do not modify this file in the FSP tree, it is provided by\n"; + print OFILE " * Hostboot and will be overwritten\n"; + print OFILE " *\n"; + print OFILE " * TimeStamp: $timestamp\n"; + print OFILE " * Image Id: $imageId\n"; + print OFILE " *\n"; + print OFILE " */\n\n"; + print OFILE "#include <errlplugins.H>\n"; + print OFILE "#include <errlusrparser.H>\n"; + print OFILE "#include <srcisrc.H>\n\n"; + print OFILE "static bool SrcDataParse(ErrlUsrParser & i_parser,\n"; + print OFILE " const SrciSrc & i_src)\n"; + print OFILE "{\n"; + print OFILE " uint32_t l_error = (i_src.reasonCode() << 8) + i_src.moduleId();\n"; + print OFILE " bool l_success = true;\n\n"; + print OFILE " switch(l_error)\n"; + print OFILE " {\n"; + print OFILE $compValueToParseHash{$compValue}; + print OFILE " default:\n"; + print OFILE " l_success = false;\n"; + print OFILE " break;\n"; + print OFILE " };\n"; + print OFILE " return l_success;\n"; + print OFILE "}\n\n"; + print OFILE "static errl::SrcPlugin g_SrcPlugin(0x$compValue"; + print OFILE "00, SrcDataParse);\n"; + + close(OFILE); +} + +#------------------------------------------------------------------------------ +# Figure out the user detail data files to compile for each component +#------------------------------------------------------------------------------ +my %compValToUdFilesHash; + +foreach my $dir(@pluginDirsToParse) +{ + my $ofiles = ""; + my $compId = ""; + my $compVal = 0; + + # Open the directory and read all entries (files) skipping any beginning + # with "." + my @dirEntries; + opendir(DH, $dir) or die("Cannot open $dir directory"); + @dirEntries = grep { !/^\./ } readdir(DH); + closedir(DH); + + # The plugin directory must contain a <COMP_ID>_Parse.C file which contains + # the user detail data parser for that component + foreach my $file(@dirEntries) + { + if ($file =~ /^(.+).C$/) + { + # Found a C file add it to the files to compile list + $ofiles .= "$1\.o "; + + if ($file =~ /^(.+COMP_ID)_Parse.C$/) + { + # Found the main Parse.C file for a component + $compId = $1; + } + } + } + + if ($compId eq "") + { + print ("$0: Could not find CompID Parser file in $dir\n"); + exit(1); + } + + # Find the component ID value + if (! exists $compIdToValueHash{"$compId"}) + { + print ("$0: Could not find CompID $compId while processing $dir\n"); + exit(1); + } + $compVal = $compIdToValueHash{$compId}; + + $compValToUdFilesHash{$compVal} = $ofiles; +} + +#------------------------------------------------------------------------------ +# Generate the FSP makefile that builds the Hostboot error log parsers +#------------------------------------------------------------------------------ +$outputFileName = $outputDir . "/makefile"; +open(OFILE, ">", $outputFileName) or die("Cannot open: $outputFileName: $!"); + +print OFILE "\# Automatically generated by Hostboot's $0\n"; +print OFILE "\# Do not modify this file in the FSP tree, it is provided by\n"; +print OFILE "\# Hostboot and will be overwritten\n"; +print OFILE "\#\n"; +print OFILE "CFLAGS += -DPARSER\n\n"; + +print OFILE "\#-------------------------------------------------------------\n"; +print OFILE "\# SRC Parsers\n"; +print OFILE "\#-------------------------------------------------------------\n"; +foreach my $compValue (keys %compValueToParseHash) +{ + print OFILE "libB-$compValue" . "00.so_OFILES = hbfwSrcParse$compValue.o\n"; + print OFILE "libB-$compValue" . "00.so_EXTRA_LIBS = libbase.so\n\n"; +} + +print OFILE "\#-------------------------------------------------------------\n"; +print OFILE "\# User Detail Data Parsers\n"; +print OFILE "\#-------------------------------------------------------------\n"; +foreach my $compValue (keys %compValToUdFilesHash) +{ + print OFILE "libB-$compValue" . "00.so_OFILES += $compValToUdFilesHash{$compValue}\n\n"; +} + +print OFILE "\#-------------------------------------------------------------\n"; +print OFILE "\# Shared library for each component\n"; +print OFILE "\#-------------------------------------------------------------\n"; +print OFILE "SHARED_LIBRARIES = "; + +foreach my $compValue (keys %compValueToParseHash) +{ + print OFILE "libB-$compValue" . "00.so "; +} + +print OFILE "\n\n.include<\${RULES_MK}>\n"; + +close(OFILE); + +#------------------------------------------------------------------------------ +# Subroutine that prints the usage +#------------------------------------------------------------------------------ +sub usage +{ + print "Usage: $0 <-b base> <-d> <-o output dir>\"\n"; + print "\n"; + print "-b: Base directory containing Hostboot src directory (default is pwd)\n"; + print "-o: Output directory where files are created (default is pwd)\n"; + print "-d Enable Debug messages.\n"; + print "\n\n"; + exit 1; +} + +#------------------------------------------------------------------------------ +# Subroutine that updates @reasonCodeFiles +#------------------------------------------------------------------------------ +sub getReasonCodeFiles +{ + # Open the input directory and read all entries (files/directories) + # Skipping any beginning with "." + my $inputDir = @_[0]; + my @dirEntries; + opendir(DH, $inputDir) or die("Cannot open $inputDir directory"); + @dirEntries = grep { !/^\./ } readdir(DH); + closedir(DH); + + foreach my $dirEntry (@dirEntries) + { + my $dirEntryPath = "$inputDir/$dirEntry"; + + if (-d $dirEntryPath) + { + # Recursively call this function + getReasonCodeFiles($dirEntryPath); + } + elsif(($dirEntry =~ /reasoncodes/i) || + ($dirEntry =~ /service_codes/i) || + ($dirEntry =~ /examplerc/i)) + { + # Found reason-codes file + push(@reasonCodeFiles, $dirEntryPath); + } + } +} + +#------------------------------------------------------------------------------ +# Subroutine that updates @filesToParse +#------------------------------------------------------------------------------ +sub getFilesToParse +{ + # Open the input directory and read all entries (files/directories) + # Skipping any beginning with "." + my $inputDir = @_[0]; + my @dirEntries; + opendir(DH, $inputDir) or die("Cannot open $inputDir directory"); + @dirEntries = grep { !/^\./ } readdir(DH); + closedir(DH); + + foreach my $dirEntry (@dirEntries) + { + my $dirEntryPath = "$inputDir/$dirEntry"; + + if (-d $dirEntryPath) + { + # Recursively call this function + getFilesToParse($dirEntryPath); + } + elsif($dirEntry =~ /\.[H|C]$/) + { + # Found file to parse + push(@filesToParse, $dirEntryPath); + } + } +} + +#------------------------------------------------------------------------------ +# Subroutine that updates @pluginDirsToParse +#------------------------------------------------------------------------------ +sub getPluginDirsToParse +{ + # Open the input directory and read all entries (files/directories) + # Skipping any beginning with "." + my $inputDir = @_[0]; + my @dirEntries; + opendir(DH, $inputDir) or die("Cannot open $inputDir directory"); + @dirEntries = grep { !/^\./ } readdir(DH); + closedir(DH); + + foreach my $dirEntry (@dirEntries) + { + my $dirEntryPath = "$inputDir/$dirEntry"; + + if (-d $dirEntryPath) + { + if ($dirEntryPath =~ /plugins/) + { + # Found plugins directory + push(@pluginDirsToParse, $dirEntryPath); + } + else + { + # Recursively call this function + getPluginDirsToParse($dirEntryPath); + } + } + } +} + +#------------------------------------------------------------------------------ +# Subroutine that gets the Image ID +#------------------------------------------------------------------------------ +sub getImageId +{ + my $imageId = `git describe --dirty || echo Unknown-Image \`git rev-parse --short HEAD\``; + chomp $imageId; + + if (($imageId =~ m/Unknown-Image/) || # Couldn't find git describe tag. + ($imageId =~ m/dirty/) || # Find 'dirty' commit. + ($imageId =~ m/^.{15}-[1-9]+/)) # Found commits after a tag. + { + $imageId = $imageId."/".$ENV{"USER"}; + } + + return $imageId; +} + diff --git a/src/usr/errl/parser/makefile b/src/usr/errl/parser/makefile index e0307c629..69451597a 100644 --- a/src/usr/errl/parser/makefile +++ b/src/usr/errl/parser/makefile @@ -1,25 +1,25 @@ -# IBM_PROLOG_BEGIN_TAG -# This is an automatically generated prolog. +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. # -# $Source: src/usr/errl/parser/makefile $ +# $Source: src/usr/errl/parser/makefile $ # -# IBM CONFIDENTIAL +# IBM CONFIDENTIAL # -# COPYRIGHT International Business Machines Corp. 2011 +# COPYRIGHT International Business Machines Corp. 2011,2013 # -# p1 +# p1 # -# Object Code Only (OCO) source materials -# Licensed Internal Code Source Materials -# IBM HostBoot Licensed Internal Code +# 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. +# 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 +# Origin: 30 # -# IBM_PROLOG_END +# IBM_PROLOG_END_TAG # makefile for errlparser a 32-bit x86 linux binary # to extract the PEL of an error log and @@ -28,10 +28,9 @@ # "Pretty printing" of those error logs is the # function of FipS 'errl' and its plugins, not this program. # -# This makefile runs 'scanforsrc.pl' which generates -# hostBootSrcParse.H, a file that hostboot plugins will include. - - +# This makefile runs 'genErrlParsers' which generates +# the Hostboot SRC parsers and the makefile to build the +# Hostboot SRC and User Detail Data parsers ROOTPATH=../../../.. @@ -40,18 +39,18 @@ IMGDIR = ${ROOTPATH}/img OBJDIR = ${ROOTPATH}/obj/modules/errl/parser -SRCPARSE_HEADER_TARGET = \ - ${GENDIR}/hostBootSrcParse.H - +ERRLPARSE_TARGETS = \ + ${GENDIR}/plugins/hbfwUdIds.H \ + ${GENDIR}/plugins/makefile CC=i686-mcp6-g++ -m32 CFLAGS:=-g -O0 -I $(ROOTPATH)/src/include/usr -I ${GENDIR} all: gen_pass code_pass -gen_pass: mkdirs ${GENDIR}/comps.C +gen_pass: mkdirs ${GENDIR}/comps.C ${ERRLPARSE_TARGETS} -code_pass: ${SRCPARSE_HEADER_TARGET} ${IMGDIR}/errlparser +code_pass: ${IMGDIR}/errlparser # errlparserbase and errlusrparser are plugins stuff, not errlparser. # OBJFILES = ${OBJDIR}/errlparserbase.o ${OBJDIR}/errlusrparser.o @@ -62,9 +61,9 @@ mkdirs: mkdir -p ${OBJDIR} mkdir -p ${GENDIR} -# Parse for error log tags in the Hostboot code, and generate hostBootSrcParse.H -${SRCPARSE_HEADER_TARGET} :: - ./scanforsrcs.pl -b ${ROOTPATH} -o ${GENDIR} +# Generate error log parser code +${ERRLPARSE_TARGETS} :: + ./genErrlParsers.pl -b ${ROOTPATH} -o ${GENDIR}/plugins ${GENDIR}/comps.C: ${ROOTPATH}/src/include/usr/hbotcompid.H grep "const compId_t [A-Z0-9]*_COMP_ID" $^ | \ @@ -72,7 +71,7 @@ ${GENDIR}/comps.C: ${ROOTPATH}/src/include/usr/hbotcompid.H 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/hberrltypes.H ${GENDIR}/comps.C ${SRCPARSE_HEADER_TARGET} +${OBJDIR}/errlparser.o: errlparser.C ${ROOTPATH}/src/include/usr/errl/hberrltypes.H ${GENDIR}/comps.C $(CC) -c $(CFLAGS) -o $@ $< @@ -80,7 +79,8 @@ ${IMGDIR}/errlparser: ${OBJDIR}/errlparser.o $(CC) -o $@ $< clean: - rm -f ${SRCPARSE_HEADER_TARGET} + rm -f ${ERRLPARSE_TARGETS} + rm -f ${GENDIR}/plugins/hbfwSrcParse*.C rm -f ${GENDIR}/comps.C rm -f ${IMGDIR}/errlparser rm -fr ${OBJDIR} diff --git a/src/usr/errl/parser/scanforsrcs.pl b/src/usr/errl/parser/scanforsrcs.pl deleted file mode 100755 index ebed31b65..000000000 --- a/src/usr/errl/parser/scanforsrcs.pl +++ /dev/null @@ -1,781 +0,0 @@ -#!/usr/bin/perl -# IBM_PROLOG_BEGIN_TAG -# This is an automatically generated prolog. -# -# $Source: src/usr/errl/parser/scanforsrcs.pl $ -# -# 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 -# -# Purpose: Scan the hostboot source code to extract the doxygen like tags -# and generate a header file for the error log parser to include. -# - -use strict; -use File::Find (); -use Time::localtime; -use File::Path; - -# Vairables -my $DEBUG = 0; -my $component = "VOID"; -my $sandBase = $ENV{HOSTBOOTROOT}; - -my $arg; -my %Comps; -my $wordn = "userdata1"; -my $wordnd = 1; -my $NA = 1; -my $fh; - -my $argOutput = ""; -my $output = ""; - -# Arrays -my @compHeaders; -my %namespaceList; -my @reasonCodeFiles; - -while( $ARGV = shift ) -{ - if( $ARGV =~ m/-b/ ) - { - $sandBase = shift; - } - elsif( $ARGV =~ m/-o/i ) - { - $argOutput = shift; - } - elsif( $ARGV =~ m/-h/i ) - { - usage(); - } - elsif( $ARGV =~ m/-d/i ) - { - $DEBUG = 1; - } - else - { - usage(); - } -} - -# Variables depending on input parameters -if( $argOutput eq "" ) -{ - $output = "$sandBase/obj/genfiles"; -} -else -{ - $output = $argOutput; -} -my $comp_id = "$sandBase/src/include/usr/hbotcompid.H"; - -# Setup all the different paths that need to be searched -my $sourcebasePath = $sandBase."/src/usr"; -my $includePath = $sandBase."/src/include/usr"; -my $genfilesPath = $sandBase."/obj/genfiles"; - -# Get the listing of components -opendir my( $dir ), $sourcebasePath or die "Couldn't open directory $sourcebasePath, $!"; -my @components = readdir $dir; -closedir $dir; - -my %sourcebase; -my %sourcebaseInc; -my %sourcebaseGenfiles; - -my @fileList; - -################################################################ -# Debug Printing -################################################################ -debugMsg( "Comp id file: $comp_id" ); -debugMsg( "Source Base Path: $sourcebasePath" ); -debugMsg( "Sandbox Base Dir: $sandBase" ); -debugMsg( "Output Dir: $output" ); -################################################################ - -foreach( @components ) -{ - # Both src/usr directories as well as src/include/usr directories - # are done here to make sure they line up with the same "component" - # generated files will be done after this loop under the "genfiles" - # component name. - $component = $_; - debugMsg( "Component: $component" ); - - # Print components for debug. - my $compDir = "$sourcebasePath/$component"; - debugMsg( "Component Dir: $compDir" ); - - # Skip files and dirs . and .. - if( -d "$compDir" ) - { - if( ($component eq ".") || - ($component eq ".." ) || - ($component eq "example" ) ) - { - debugMsg( "exiting..." ); - next; - } - } - else - { - debugMsg( "exiting-->" ); - next; - } - - # Check to be sure the main src directory is available - if( -e "$compDir" ) - { - # Get a list of files to be scanned - %sourcebase = getFiles( $compDir ); - } - else - { - # Exit since the path of the user code wasn't found. - die( "\nERROR! Path ($compDir) does not exist. Cannot run!\n" ); - } - - # Get the associated component include files - my $incCompDir = "$includePath/$component"; - debugMsg( "Include Path: $incCompDir" ); - - # Skip files and dirs . and .. - if( -d "$incCompDir" ) - { - # Do nothing, we want the directories - } - else - { - debugMsg( "exiting-->" ); - next; - } - - # if include dir exists, get the files - if( -e "$incCompDir" ) - { - # Add the include files - %sourcebaseInc = getFiles( $incCompDir ); - } - else - { - # Exit since the path of the user code wasn't found. - die( "\nERROR! Path ($incCompDir) does not exist. Cannot run!\n" ); - } - - # Put each file on list to be scanned - foreach( values %sourcebase ) - { - push( @fileList, $_ ); - debugMsg( "File: $_" ); - - # Delete hash entry - delete $sourcebase{$_}; - } - - # Put each file on list to be scanned - foreach( values %sourcebaseInc ) - { - push( @fileList, $_ ); - debugMsg( "File (include): $_" ); - - # Delete hash entry - delete $sourcebaseInc{$_}; - } - - foreach( @fileList ) - { - debugMsg( "Calling extractTags for file: $_" ); - extractTags( $_, $component ); - } - - # Clear the file list so we don't reuse them - @fileList = (); -} - -# Scan the generated files and add to file list -if( -e $genfilesPath ) -{ - %sourcebaseGenfiles = getFiles( $genfilesPath ); - foreach( values %sourcebaseGenfiles ) - { - push( @fileList, $_ ); - debugMsg( "File (genfiles): $_" ); - delete $sourcebaseGenfiles{$_}; - } - - foreach( @fileList ) - { - debugMsg( "Calling extractTags for file: $_" ); - extractTags( $_, "genfiles" ); - } -} -else -{ - die( "\nERROR! Path($genfilesPath) does not exist. Cannot continue!\n" ); -} - -# Get the file open -$fh = openHeaderFile(); - -# Start writing the main header file that will be included by errlparser.C -startMainHeaderFile( $fh ); - -my $found_dup = 0; - -# Write each case statement for printing -foreach my $key (sort(keys(%Comps))) -{ - writePrintStatement( $fh, $key, \@{$Comps{$key}} ); -} -if($found_dup > 0) -{ - die( "ERROR! Duplicate hash found!\n" ); -} - -# Finish writing the header -finishMainHeaderFile( $fh ); - -exit 0; - -#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -# End of Main program -#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -################################################################################ -# -# Print the Usage message -# -################################################################################ - -sub usage -{ - print "Usage: $0 < -b base > <-d> < -o output dir >\"\n"; - print "\n"; - print "-b: base directory ( default is pwd )\n"; - print "-o: Used as the output directory where header file is dropped\n"; - print "-d Enable Debug messages.\n"; - print "-h Display usage message.\n"; - print "\n\n"; - exit 1; -} - - -################################################################################ -# -# Print debug messages if $DEBUG is enabled. -# -################################################################################ - -sub debugMsg -{ - my ($msg) = @_; - if( $DEBUG ) - { - print "DEBUG: $msg\n"; - } -} - - -################################################################################ -# -# Extracts each tag and description from each entry for the given file. -# -################################################################################ - -sub extractTags -{ - my $data; - my ($file, $comp) = @_; - debugMsg( "extractTags: Component: $comp" ); - local *FH; - - debugMsg( "Processing: $file" ); - - open(FH, "$file") or die("Cannot open: $file: $!"); - read(FH, $data, -s FH) or die("Error reading $file: $!"); - close FH; - - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - # Capture everything from opening '/*@' to end of tags '*/' - # - # Example: - # /*@ - # * @errortype - # * @reasoncode I2C_INVALID_OP_TYPE - # * @severity ERRL_SEV_UNRECOVERABLE - # * @moduleid I2C_PERFORM_OP - # * @userdata1 i_opType - # * @userdata2 addr - # * @devdesc Invalid Operation type. - # */ - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - while ($data =~ /\/\*\@((.|\n)+?)\*\//mgo ) - { - debugMsg( "Found New Error Tag!" ); - - my $text = $1; - debugMsg( "Text1: $text" ); - my %hash = $text =~ /\@(\S+)(?:\s+|\.+)\b(.+?)$/gm; - my $tmp; - my $tmpKey; - - foreach my $key (sort keys %hash) - { - $tmpKey = AddSlashes( $key ); - debugMsg( "Key: $tmpKey" ); - # Extract multi-line string - $text =~ /\@$tmpKey(?:\s+|\.+)(.+?)(?:\@|$).*/s; - debugMsg( "Text3: $text" ); - $tmp = $1; - debugMsg( "Tmp: $tmp" ); - $tmp =~ s/\s*\*\s*/ \n/gm; - debugMsg( "Tmp again: $tmp" ); - $tmp = stripWhitespace( $tmp ); - debugMsg( "Tmp trimmed: $tmp" ); - $hash{$key} = $tmp; - debugMsg( "Assigning '$key' = '$tmp'" ); - } - - push @{$Comps{$comp}}, \%hash; - } -} - - -################################################################################ -# -# getFiles - find *.H or *.C files -# This recursively searches the input directory passed in for all C/H files. -# -################################################################################ - -sub getFiles -{ - my ($l_input_dir) = @_; - my @dir_entry; - my %l_input_files; - local *DH; - - debugMsg( "Getting Files for dir: $l_input_dir" ); - - # Open the directory and read all entry names. - opendir(DH, $l_input_dir) or die("Cannot open $l_input_dir: $!"); - # skip the dots - @dir_entry = grep { !/^\./ } readdir(DH); - closedir(DH); - while (@dir_entry) - { - my $l_entry = shift(@dir_entry); - my $full_path = "$l_input_dir/$l_entry"; - - debugMsg( "getFiles: Full Path: $full_path" ); - - if ($l_entry =~ /\.[H|C]$/) - { - $l_input_files{$l_entry} = $full_path; - debugMsg( "getFiles: Adding file: $full_path" ); - } - elsif (-d $full_path) - { - # recursive here - my %local_hash = getFiles($full_path); - my @keys = keys(%local_hash); - - foreach(@keys) - { - $l_input_files{$_} = $local_hash{$_}; - } - } - } - return(%l_input_files); -} - - -################################################################################ -# -# Add escape characters to strings -# -################################################################################ - -sub AddSlashes -{ - my ($text) = @_; - ## Make sure to do the backslash first! - $text =~ s/\\/\\\\/g; - $text =~ s/'/\\'/g; - $text =~ s/"/\\"/g; - $text =~ s/\\0/\\\\0/g; - - $text =~ s/\[/\\[/g; - $text =~ s/\]/\\]/g; - return $text; -} - - -################################################################################ -# -# Strip whitespace from beginning/end of string -# -################################################################################ - -sub stripWhitespace -{ - my ($text) = @_; - - $text =~ s/^\s+//; # strip leading spaces - $text =~ s/\s+$//; # strip trailing spaces - - return $text; -} - -################################################################################ -# -# Look for the components reasoncode file and include it -# -################################################################################ - -sub includeReasonCodes -{ - my ( $fh,$incPath,$level ) = @_; - - debugMsg( "includeReasonCodes incpath: $incPath" ); - debugMsg( "includeReasonCodes level: $level" ); - - my @incDirs = glob( $incPath ); - my $incFileName = ""; - - foreach my $file( @incDirs ) - { - debugMsg( "includeReasonCodes file: $file" ); - my @allDirs = split( '/', $file ); - - if( $file =~ m/reasoncodes/i ) - { - for( my $count = 0; $count < $level; $count++ ) - { - my $tmpTxt = pop @allDirs; - - if( $incFileName ne "" ) - { - $incFileName = $tmpTxt . "/$incFileName"; - } - else - { - $incFileName = $tmpTxt; - } - } - debugMsg( "ReasonCode file: $file" ); - debugMsg( "Include string: $incFileName" ); - - print $fh "#include <$incFileName>\n"; - - # Find the namespace of the reason codes - findNameSpace( $file ); - - # Clear out incFileName, in case there are 2 reason code files - # in the same directory - $incFileName = ""; - } - elsif( -d $file ) - { - debugMsg( "includeReasonCodes recursion" ); - # Recursion is done here. - includeReasonCodes( $fh, $file."/*", ($level+1) ); - } - } -} - - -################################################################################ -# -# Build the main header file that errlparser.C will use to include all of -# the generated header files. -# -################################################################################ - -sub startMainHeaderFile -{ - my ($fh) = @_; - my $timestamp = ctime(); - my $imageId = getImageId(); - - print $fh <<EOF; -/* - * Automatically generated by src/usr/errl/parser/scanforsrcs.pl - * - * TimeStamp: $timestamp - * Image Id: $imageId - * -*/ - - -/*****************************************************************************/ -// I n c l u d e s -/*****************************************************************************/ -EOF - - # Add the includes - start in src/include/usr - my $startDir = $sandBase."/src/include/usr/*"; - includeReasonCodes( $fh, $startDir, 1 ); - - # Also include reason codes from generated files - $startDir = $sandBase."/obj/genfiles"; - includeReasonCodes( $fh, $startDir, 0 ); - - print $fh <<EOF; - - -/*****************************************************************************/ -// N a m e s p a c e s -/*****************************************************************************/ -EOF - - foreach( values %namespaceList ) - { - my $namespace = $_; - print $fh "using namespace $namespace;\n" - } - - print $fh <<EOF; - - -static void printErrorTags ( ErrlUsrParser & i_parser, - uint64_t i_src, - uint64_t i_modId ) -{ - uint64_t error = (i_src << 8) | i_modId; - - switch( error ) - { -EOF -} - - -################################################################################ -# -# Finish writing main header file -# -################################################################################ - -sub finishMainHeaderFile -{ - my ($fh) = @_; - - print $fh <<EOF; - - default: - uint32_t src = i_src & 0xFFFFFFFF; - uint32_t modId = i_modId & 0xFFFFFFFF; - printf( "\\nThere was not a valid Errorlog tag found for the given error combination!\\n" ); - printf( " Reason: 0x%04x, Module Id: 0x%02x\\n\\n", src, modId ); - break; - - }; -} -EOF -} - - -################################################################################ -# -# Open generated header file -# -################################################################################ - -sub openHeaderFile -{ - my $filename = "$output/hostBootSrcParse.H"; - my $fh; - - if (! -e $output) - { - debugMsg( "Creating directory $output" ); - eval { mkpath($output) }; - - if ($@) - { - die("Couldn't create $output: $@"); - } - } - - if (-e $filename) - { - chmod(0777, $filename); - } - - open($fh, ">$filename") or die("Cannot open $filename: $!"); - return $fh; -} - - -################################################################################ -# -# Write the print statements to the header -# -################################################################################ - -sub writePrintStatement -{ - my ($fh, $compName, $aref) = @_; - my $wordstart = "userdata1"; - my $modId; - my $reasonCode; - my $caseValue; - my $line; - - my %caseHash = (); - - foreach my $href ( @$aref ) - { - # Get the ModId and Reasoncode tags - foreach my $tag ( sort keys %$href ) - { - $href->{$tag} =~ s/\"/\\\"/g; - my @lines = split /^/, $href->{$tag}; - - if( scalar( @lines ) > 1 ) - { - foreach $line( @lines ) - { - $line =~ s/\n//g; - } - } - else - { - $line = $href->{$tag}; - $line =~ s/\n//g; - } - - $line = stripWhitespace( $line ); - if( "moduleid" eq $tag ) - { - $modId = $line; - } - elsif( "reasoncode" eq $tag ) - { - $reasonCode = $line; - } - } - debugMsg( "Comp Name: $compName" ); - debugMsg( "Module Id: $modId" ); - debugMsg( "Reason Code: $reasonCode" ); - - # If we've got a duplicate Module Id/Reason code go, on to the - # next one. We can't have duplicates, so if we do we set found_dup - # so that we can die after this loop - if( exists $caseHash{ $modId.$reasonCode } ) - { - debugMsg( "Hash exists, skip subsequent." ); - - # Print a error message - print "\n#################################################################\n"; - print " ERROR - Duplicate hash found for:\n"; - print " component $compName\n"; - print " module id $modId\n"; - print " reason code $reasonCode\n"; - print "#################################################################\n"; - $found_dup = 1; - next; - } - else - { - $caseHash{ $modId.$reasonCode } = 1; - } - - - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - # - # This check will be used to exclude module Ids which aren't set - # in stone... I think they should be, but ... - # So, as more oddities show up, this will need to be modified - # to accomodate. - # - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - if( ($modId =~ /see/i) && - ($modId =~ /task/i) ) - { - # Move to the next loop if this tag is invalid. - debugMsg( "Invalid Mod Id: $modId" ); - next; - } - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - - print $fh " case \(\($reasonCode \<\< 8\) \| $modId\) \:\n"; - - foreach my $tag ( sort keys %$href ) - { - $href->{$tag} =~ s/\"/\\\"/g; - my $line = $href->{$tag}; - $line =~ s/\n//g; - print $fh " i_parser.PrintString( \"$tag\" \, \"$line\" )\;\n"; - } - print $fh " break;\n\n"; - } -} - - -################################################################################ -# -# find the namespace of the file. -# -################################################################################ - -sub findNameSpace -{ - my ( $file ) = @_; - my $data; - open(FH, "$file") or die("Cannot open: $file: $!"); - read(FH, $data, -s FH) or die("Error reading $file: $!"); - close FH; - - # get the namespace - my $namespace = "VOID"; - while( $data =~ /^namespace(.+?\n)/gm ) - { - $namespace = $1; - $namespace =~ s/\;+$//; # strip trailing semicolon - $namespace =~ s/\{+$//; # strip opening bracket - $namespace = stripWhitespace( $namespace ); - $namespaceList{$namespace} = $namespace; - } - debugMsg( "Namespace: $namespace" ); - debugMsg( " from File: $file" ); -} - - -################################################################################ -# -# Get the Image id -# -################################################################################ -sub getImageId -{ - my $imageId = `git describe --dirty || echo Unknown-Image \`git rev-parse --short HEAD\``; - chomp $imageId; - - if (($imageId =~ m/Unknown-Image/) || # Couldn't find git describe tag. - ($imageId =~ m/dirty/) || # Find 'dirty' commit. - ($imageId =~ m/^.{15}-[1-9]+/)) # Found commits after a tag. - { - $imageId = $imageId."/".$ENV{"USER"}; - } - - return $imageId; -} diff --git a/src/usr/errl/plugins/ERRL_COMP_ID_Parse.C b/src/usr/errl/plugins/ERRL_COMP_ID_Parse.C new file mode 100644 index 000000000..1e916b014 --- /dev/null +++ b/src/usr/errl/plugins/ERRL_COMP_ID_Parse.C @@ -0,0 +1,34 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/errl/plugins/HBERRL_COMP_ID_Parse.C $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2012,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 ERRL_COMP_ID_Parse.C + * + * Creates the ERRL User Detail Data Parser + */ +#include "errludparser.H" +#include "errludparserfactoryerrl.H" + +ERRL_MAKE_UD_PARSER(ERRORLOG::ErrlUserDetailsParserFactoryErrl, + hbfw::ERRL_COMP_ID) + diff --git a/src/usr/errl/plugins/errlParse.C b/src/usr/errl/plugins/errlParse.C deleted file mode 100644 index daefc640c..000000000 --- a/src/usr/errl/plugins/errlParse.C +++ /dev/null @@ -1,67 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG - * This is an automatically generated prolog. - * - * $Source: src/usr/errl/plugins/errlParse.C $ - * - * IBM CONFIDENTIAL - * - * COPYRIGHT International Business Machines Corp. 2012 - * - * 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_TAG - */ -/** - * @file initsvcParse.C - * - * errl user detail data and src parser - */ - -//------------------------------------------------------------------------------ -// User detail data parser -//------------------------------------------------------------------------------ -#include "symbols.H" -#include <errl/errludparser.H> -#include <errl/errludparserfactoryerrl.H> -ERRL_MAKE_UD_PARSER(ERRORLOG::ErrlUserDetailsParserFactoryErrl, HBERRL_COMP_ID) - -//------------------------------------------------------------------------------ -// Src parser (call code generated by scanforsrc.pl) -//------------------------------------------------------------------------------ - -// FSP include -#include <srcisrc.H> - -// Hostboot include -#include <hostBootSrcParse.H> - -static bool hbSrcParse( ErrlUsrParser & i_parser, const SrciSrc & i_src ) -{ - uint32_t src = 0; - - sscanf( i_src.getAsciiString(), "%X", &src ); - - // Call this function in obj/genfiles/hostBootSrcParse.H (a script-generated - // file) which serves for any Hostboot component. This will cause - // the FSP errl tool to add the tagged information to the primary SRC - // section of the error log. For example, the developer description - // (devdesc) tag and associated info as well as the other tags describing - // the userdata1 and userdata2 words. - printErrorTags( i_parser, (src & 0xFFFF), i_src.moduleId() ); - - return false; -} - -// Create an instance of SrcPlugin by type (instead of the usual component). -static errl::SrcPlugin g_SrcPlugin( HBERRL_COMP_ID, hbSrcParse ); - diff --git a/src/usr/errl/plugins/errludbacktrace.H b/src/usr/errl/plugins/errludbacktrace.H new file mode 100644 index 000000000..ad60e9c3e --- /dev/null +++ b/src/usr/errl/plugins/errludbacktrace.H @@ -0,0 +1,150 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/errl/plugins/errludbacktrace.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2012,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 ERRL_UDBACKTRACE_H +#define ERRL_UDBACKTRACE_H + +/** + * @file errludbacktrace.H + * + * Defines the ErrlUserDetailsParserBackTrace class that parses backtrace FFDC + * user detail in an error log + */ + +#include "errluserdetails.H" +#include "symbols.H" +#include <vector> + +namespace ERRORLOG +{ + +/** + * @class ErrlUserDetailsParserBackTrace + * + * Parses backtrace user detail in an error log + */ +class ErrlUserDetailsParserBackTrace : public ErrlUserDetailsParser +{ +public: + /** + * @brief Constructor + */ + ErrlUserDetailsParserBackTrace() {} + + /** + * @brief Destructor + */ + virtual ~ErrlUserDetailsParserBackTrace() {} + + /** + * @brief Parses backtrace user detail data from an error log + * + * @param i_version Version of the data + * @param i_parse ErrlUsrParser object for outputting information + * @param i_pBuffer Pointer to buffer containing detail data + * @param i_buflen Length of the buffer + */ + virtual void parse(errlver_t i_version, + ErrlUsrParser & i_parser, + void * i_pBuffer, + const uint32_t i_buflen) const + { + // This buffer contains a number of 64-bit frame pointers. + + // A character vector for storing a backtrace entry and the space + // required for the header (frame number and address (with some padding + // for safety)) and the symbol name. This vector is resized if a longer + // symbol name is encountered. + const uint8_t BACKTRACE_ENTRY_HEADER_SIZE = 32; + const uint8_t BACKTRACE_ENTRY_SYMBOL_SIZE = 64; + std::vector<char> l_traceEntry(BACKTRACE_ENTRY_HEADER_SIZE + + BACKTRACE_ENTRY_SYMBOL_SIZE); + + // Initialize l_the symbol table. + const char * l_pSymFile = "hbicore.syms"; + hbSymbolTable symTab; + int readRC = symTab.readSymbols( l_pSymFile ); + if( readRC ) + { + i_parser.PrintString( "Symbols not found", l_pSymFile ); + // symTab.nearestSymbol() will return NULL because of this. + // Carry on. + } + + const char * l_pErrlEntry = "ErrlEntry::ErrlEntry"; + const char * l_pLabel = "Backtrace"; + + // loop thru the buffer which is an array of 64-bit addresses + uint64_t * p64 = static_cast<uint64_t *>(i_pBuffer); + int l_count = i_buflen / sizeof( uint64_t ); + for( int i = 0; i < l_count; i++ ) + { + // endian convert the stack address + uint64_t l_addr = ntohll(*p64); + + // get nearest symbol + const char * l_pSymbol = symTab.nearestSymbol( l_addr ); + + if( l_pSymbol ) + { + if( strstr( l_pSymbol, l_pErrlEntry )) + { + // hackish, makes for better looking output + // it's in every backtrace (jan2012) + l_pSymbol = l_pErrlEntry; + } + + uint16_t l_traceSize = + (BACKTRACE_ENTRY_HEADER_SIZE + strlen(l_pSymbol) + 1); + + if (l_traceEntry.size() < l_traceSize) + { + l_traceEntry.resize(l_traceSize); + } + sprintf(&(l_traceEntry[0]), + "#%2d %016llX %s", i, l_addr, l_pSymbol); + } + else + { + sprintf(&(l_traceEntry[0]),"#%2d %016llX", i, l_addr); + } + i_parser.PrintString( l_pLabel, &(l_traceEntry[0]) ); + + // next stack address in the buffer + p64++; + + // don't print the label for subsequent backtraces + l_pLabel = ""; + } + } + +private: + // Disabled + ErrlUserDetailsParserBackTrace(const ErrlUserDetailsParserBackTrace &); + ErrlUserDetailsParserBackTrace & operator=( + const ErrlUserDetailsParserBackTrace &); +}; + +} + +#endif + diff --git a/src/usr/errl/plugins/errludcallout.H b/src/usr/errl/plugins/errludcallout.H new file mode 100644 index 000000000..3346c6487 --- /dev/null +++ b/src/usr/errl/plugins/errludcallout.H @@ -0,0 +1,83 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/errl/plugins/errludcallout.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2012,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 ERRL_UDCALLOU_H +#define ERRL_UDCALLOU_H + +/** + * @file errludcallout.H + * + * Defines the ErrlUserDetailsParserCallout class that parses + * callout user detail in an error log + */ + +#include "errluserdetails.H" + +namespace ERRORLOG +{ + +/** + * @class ErrlUserDetailsCallout + * + * Parses Callout user detail in an error log + */ +class ErrlUserDetailsParserCallout : public ErrlUserDetailsParser +{ +public: + /** + * @brief Constructor + */ + ErrlUserDetailsParserCallout() {} + + /** + * @brief Destructor + */ + virtual ~ErrlUserDetailsParserCallout() {} + + /** + * @brief Parses callout user detail data from an error log + * + * @param i_version Version of the data + * @param i_parse ErrlUsrParser object for outputting information + * @param i_pBuffer Pointer to buffer containing detail data + * @param i_buflen Length of the buffer + */ + virtual void parse(errlver_t i_version, + ErrlUsrParser & i_parser, + void * i_pBuffer, + const uint32_t i_buflen) const + { + // TODO fix when parser fixed + // RTC 41707 + } + +private: + // Disabled + ErrlUserDetailsParserCallout(const ErrlUserDetailsParserCallout &); + ErrlUserDetailsParserCallout & operator=( + const ErrlUserDetailsParserCallout &); +}; + +} + +#endif + diff --git a/src/usr/errl/plugins/errludlogregister.H b/src/usr/errl/plugins/errludlogregister.H new file mode 100644 index 000000000..f7f19ae2d --- /dev/null +++ b/src/usr/errl/plugins/errludlogregister.H @@ -0,0 +1,83 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/errl/plugins/errludlogregister.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2012,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 ERRL_UDLOGREGISTER_H +#define ERRL_UDLOGREGISTER_H + +/** + * @file errludlogregister.H + * + * Defines the ErrlUserDetailsParserLogRegister class that parses register FFDC + * user detail in an error log + */ + +#include "errluserdetails.H" + +namespace ERRORLOG +{ + +/** + * @class ErrlUserDetailsLogRegister + * + * Parses LogRegister user detail in an error log + */ +class ErrlUserDetailsParserLogRegister : public ErrlUserDetailsParser +{ +public: + /** + * @brief Constructor + */ + ErrlUserDetailsParserLogRegister() {} + + /** + * @brief Destructor + */ + virtual ~ErrlUserDetailsParserLogRegister() {} + + /** + * @brief Parses register user detail data from an error log + * + * @param i_version Version of the data + * @param i_parse ErrlUsrParser object for outputting information + * @param i_pBuffer Pointer to buffer containing detail data + * @param i_buflen Length of the buffer + */ + virtual void parse(errlver_t i_version, + ErrlUsrParser & i_parser, + void * i_pBuffer, + const uint32_t i_buflen) const + { + // TODO fix when parser if fix + // RTC 41707 + } + +private: + // Disabled + ErrlUserDetailsParserLogRegister(const ErrlUserDetailsParserLogRegister &); + ErrlUserDetailsParserLogRegister & operator=( + const ErrlUserDetailsParserLogRegister &); +}; + +} + +#endif + diff --git a/src/usr/errl/plugins/errludparser.H b/src/usr/errl/plugins/errludparser.H new file mode 100755 index 000000000..c3b1f95a8 --- /dev/null +++ b/src/usr/errl/plugins/errludparser.H @@ -0,0 +1,89 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/errl/plugins/errludparser.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2012,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 ERRL_UDPARSER_H +#define ERRL_UDPARSER_H + +/** + * @file errludparser.H + * + * To create a function that errl calls to parse user detail data, a + * component's plugin/<comp>Parse.C file should include this file and call the + * ERRL_MAKE_UD_PARSER macro + */ + +#include <netinet/in.h> + +/** + * @brief Endian swap a uint64_t. This is not provided by in.h + */ +inline uint64_t ntohll( uint64_t i ) +#if __BYTE_ORDER == __LITTLE_ENDIAN +{ + // CONTEXT_x86_nfp + 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; +} +#elif __BYTE_ORDER == __BIG_ENDIAN +{ + // CONTEXT_ppc (or maybe CONTEXT_aix_nfp) + return i; +} +#else +#error Unexpected endian context. +#endif + +// FSP includes +#include <errlplugins.H> +#include <errlusrparser.H> +#include "hbfwUdIds.H" + +/** + * @brief Macro that generates a function and plugin object to parse a + * component's error log user detail data + */ +#define ERRL_MAKE_UD_PARSER(FACTORY, COMPID) \ +static bool myDataParse(\ + ErrlUsrParser& i_parser, void* i_buffer, uint32_t i_buflen,\ + errlver_t i_ver, errlsubsec_t i_sst)\ +{\ + bool l_rc = false;\ + FACTORY l_factory;\ + ERRORLOG::ErrlUserDetailsParser * l_pParser =\ + l_factory.createParser(i_sst);\ + if (l_pParser)\ + {\ + l_rc = true;\ + l_pParser->parse(i_ver, i_parser, i_buffer, i_buflen);\ + }\ + return l_rc;\ +}\ +static errl::DataPlugin g_DataPlugin(COMPID, myDataParse); + +#endif + diff --git a/src/usr/errl/plugins/errludparserfactory.H b/src/usr/errl/plugins/errludparserfactory.H new file mode 100755 index 000000000..50df87623 --- /dev/null +++ b/src/usr/errl/plugins/errludparserfactory.H @@ -0,0 +1,130 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/errl/plugins/errludparserfactory.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2012,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 ERRL_UDPARSERFACTORY_H +#define ERRL_UDPARSERFACTORY_H + +/** + * @file errludparserfactory.H + * + * Defines the ErrlUserDetailsParserFactory base class + */ +#include "errluserdetails.H" +#include <map> + +namespace ERRORLOG +{ + +/** + * @class ErrlUserDetailsParserFactory + * + * This is a factory that produces ErrlUserDetailsParser objects. If a component + * creates user detail data then it should derive a class from this and register + * all of its ErrlUserDetailsParser classes with it. The parse file in the + * plugins directory can then call the factory to create parser objects to parse + * any user detail data. + */ +class ErrlUserDetailsParserFactory +{ +public: + /** + * @brief Constructor + */ + ErrlUserDetailsParserFactory() + { + } + + /** + * @brief Destructor + */ + ~ErrlUserDetailsParserFactory() + { + } + + /** + * @brief Register a class derived from ErrlUserDetailsParser with the + * factory that can parse user detail data with the specified + * subsection. + * + * @param i_subSection The user detail data subsection that is parsed by + * class T + */ + template<typename T> + void registerParser(const errlsubsec_t i_subSection) + { + iv_createObjectMap[i_subSection] = &(createParserObject<T>); + } + + /** + * @brief Create an object of type ErrlUserDetailsParser that can parse + * user detail data with the specified subsection. The returned + * pointer will be polymorphic and will actually point to a type + * derived from ErrlUserDetailsParser. + * + * @param i_subSection The user detail data subsection to parse + * + * @return ErrlUserDetailsParser * + * Pointer to a ErrlUserDetailsParser object. Null if there is no + * parser registered for the specified subsection. The user must delete + * the object after use. + */ + ErrlUserDetailsParser * createParser(const errlsubsec_t i_subSection) + { + std::map<errlsubsec_t, createParserObject_t>::const_iterator itr = + iv_createObjectMap.find(i_subSection); + + if (itr != iv_createObjectMap.end()) + { + // Call the object creator function (createParserObject) + return((itr->second)()); + } + return NULL; + } + +private: + /** + * @brief Creates a ErrlUserDetailsParser of the specified derived type + * + * @return ErrlUserDetailsParser * Pointer to newly created object + */ + template<typename T> + static ErrlUserDetailsParser * createParserObject() + { + return new T(); + } + + // Function pointer type of createParserObject + typedef ErrlUserDetailsParser *(*createParserObject_t)(); + + // Map of subsections and their createobject function + std::map<errlsubsec_t, createParserObject_t> iv_createObjectMap; + + // Disabled + ErrlUserDetailsParserFactory(const ErrlUserDetailsParserFactory &); + ErrlUserDetailsParserFactory & operator=( + const ErrlUserDetailsParserFactory &); +}; + +} + +#endif + diff --git a/src/usr/errl/plugins/errludparserfactoryerrl.H b/src/usr/errl/plugins/errludparserfactoryerrl.H new file mode 100644 index 000000000..5fffc1a98 --- /dev/null +++ b/src/usr/errl/plugins/errludparserfactoryerrl.H @@ -0,0 +1,76 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/errl/plugins/errludparserfactoryerrl.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2012,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 ERRL_UDPARSERFACTORYERRL_H +#define ERRL_UDPARSERFACTORYERRL_H + +/** + * @file errludparserfactoryerrl.H + * + * Defines the errlUserDetailsParserFactoryErrl.H class +*/ +#include "errludparserfactory.H" +#include "errludstring.H" +#include "errludtarget.H" +#include "errludbacktrace.H" +#include "errludattribute.H" +#include "errludlogregister.H" +#include "errludcallout.H" + +namespace ERRORLOG +{ + +/** + * @class ErrlUserDetailsParserFactoryErrl + * + * This factory produces ErrlUserDetailsParser objects to parse the specified + * ERRL user detail data. + */ +class ErrlUserDetailsParserFactoryErrl : public ErrlUserDetailsParserFactory +{ +public: + + /** + * @brief Constructor + */ + ErrlUserDetailsParserFactoryErrl() + { + registerParser<ErrlUserDetailsParserString>(ERRL_UDT_STRING); + registerParser<ErrlUserDetailsParserTarget>(ERRL_UDT_TARGET); + registerParser<ErrlUserDetailsParserBackTrace>(ERRL_UDT_BACKTRACE); + registerParser<ErrlUserDetailsParserAttribute>(ERRL_UDT_ATTRIBUTE); + registerParser<ErrlUserDetailsParserLogRegister>(ERRL_UDT_LOGREGISTER); + registerParser<ErrlUserDetailsParserCallout>(ERRL_UDT_CALLOUT); + } + +private: + + // Disabled + ErrlUserDetailsParserFactoryErrl(const ErrlUserDetailsParserFactoryErrl &); + ErrlUserDetailsParserFactoryErrl & operator=( + const ErrlUserDetailsParserFactoryErrl &); +}; + +} + +#endif + diff --git a/src/usr/errl/plugins/errludstring.H b/src/usr/errl/plugins/errludstring.H new file mode 100644 index 000000000..f12281c16 --- /dev/null +++ b/src/usr/errl/plugins/errludstring.H @@ -0,0 +1,83 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/errl/plugins/errludstring.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2012,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 ERRL_UDSTRING_H +#define ERRL_UDSTRING_H + +/** + * @file errludstring.H + * + * Defines the ErrlUserDetailsParserString class that parser string FFDC + * user detail in an error log + */ + +#include "errluserdetails.H" +#include <string.h> + +namespace ERRORLOG +{ + +/** + * @class ErrlUserDetailsString + * + * Parses String user detail in an error log + */ +class ErrlUserDetailsParserString : public ErrlUserDetailsParser +{ +public: + /** + * @brief Constructor + */ + ErrlUserDetailsParserString() {} + + /** + * @brief Destructor + */ + virtual ~ErrlUserDetailsParserString() {} + + /** + * @brief Parses string user detail data from an error log + * + * @param i_version Version of the data + * @param i_parse ErrlUsrParser object for outputting information + * @param i_pBuffer Pointer to buffer containing detail data + * @param i_buflen Length of the buffer + */ + virtual void parse(errlver_t i_version, + ErrlUsrParser & i_parser, + void * i_pBuffer, + const uint32_t i_buflen) const + { + i_parser.PrintString("String data", static_cast<char *>(i_pBuffer)); + } + +private: + // Disabled + ErrlUserDetailsParserString(const ErrlUserDetailsParserString &); + ErrlUserDetailsParserString & operator=( + const ErrlUserDetailsParserString &); +}; + +} + +#endif + diff --git a/src/usr/errl/plugins/errludtarget.H b/src/usr/errl/plugins/errludtarget.H new file mode 100644 index 000000000..61a4d8cf9 --- /dev/null +++ b/src/usr/errl/plugins/errludtarget.H @@ -0,0 +1,251 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/errl/plugins/errludtarget.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2012,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 ERRL_UDTARGET_H +#define ERRL_UDTARGET_H + +/** + * @file errludTarget.H + * + * Defines the ErrlUserDetailsParserTarget class that parses Target FFDC + * user detail in an error log + */ + +#include "errluserdetails.H" +#include <string.h> + +namespace ERRORLOG +{ + +/** + * @class ErrlUserDetailsParserTarget + * + * Parses Target FFDC user detail in an error log + */ +class ErrlUserDetailsParserTarget : public ErrlUserDetailsParser +{ +public: + /** + * @brief Constructor + */ + ErrlUserDetailsParserTarget() {} + + /** + * @brief Destructor + */ + virtual ~ErrlUserDetailsParserTarget() {} + + /** + * @brief Parses Target user detail data from an error log + * + * @param i_version Version of the data + * @param i_parse ErrlUsrParser object for outputting information + * @param i_pBuffer Pointer to buffer containing detail data + * @param i_buflen Length of the buffer + */ + virtual void parse(errlver_t i_version, + ErrlUsrParser & i_parser, + void * i_pBuffer, + const uint32_t i_buflen) const + { + i_parser.PrintString("Target data", NULL); + const char *attrData; + uint32_t i = 0; + + // errlog data + uint8_t *l_ptr = static_cast<uint8_t *>(i_pBuffer); + + // TODO: needs to be updated to handle merged records + + if (*l_ptr == 1) // special - master + { + i_parser.PrintString(NULL, "MASTER_PROCESSOR_CHIP_TARGET_SENTINEL"); + } + else + { + l_ptr += sizeof(uint8_t); // past the marker + + // first 4 are always the same + if (i_buflen >= sizeof(uint32_t) + 3 * sizeof(uint8_t)) + { + char sHuid[12]; + sprintf(sHuid, "0x%x",*((uint32_t *)l_ptr)); + i_parser.PrintString("ATTR_HUID", sHuid); + i += sizeof(uint32_t); + l_ptr += sizeof(uint32_t); + + // CLASS + switch (*l_ptr) { + case 0x00: { attrData = "CLASS_NA"; break; } + case 0x01: { attrData = "CLASS_CARD"; break; } + case 0x02: { attrData = "CLASS_ENC"; break; } + case 0x03: { attrData = "CLASS_CHIP"; break; } + case 0x04: { attrData = "CLASS_UNIT"; break; } + case 0x05: { attrData = "CLASS_DEV"; break; } + case 0x06: { attrData = "CLASS_SYS"; break; } + case 0x07: { attrData = "CLASS_LOGICAL_CARD"; break; } + case 0x08: { attrData = "CLASS_MAX"; break; } + default: { attrData = "UNKNOWN CLASS"; break; } + } // switch + i_parser.PrintString("ATTR_CLASS", attrData); + i ++; + l_ptr ++; + + // TYPE + switch (*l_ptr) { + // TODO: RTC 50828: make these build-time dynamic based + // on values in obj/genfiles/attributeenums.H + case 0x00: { attrData = "TYPE_NA"; break; } + case 0x01: { attrData = "TYPE_SYS"; break; } + case 0x02: { attrData = "TYPE_NODE"; break; } + case 0x03: { attrData = "TYPE_DIMM"; break; } + case 0x04: { attrData = "TYPE_MEMBUF"; break; } + case 0x05: { attrData = "TYPE_PROC"; break; } + case 0x06: { attrData = "TYPE_EX"; break; } + case 0x07: { attrData = "TYPE_CORE"; break; } + case 0x08: { attrData = "TYPE_L2"; break; } + case 0x09: { attrData = "TYPE_L3"; break; } + case 0x0A: { attrData = "TYPE_L4"; break; } + case 0x0B: { attrData = "TYPE_MCS"; break; } + case 0x0C: { attrData = "TYPE_MBS"; break; } + case 0x0D: { attrData = "TYPE_MBA"; break; } + case 0x0E: { attrData = "TYPE_XBUS"; break; } + case 0x0F: { attrData = "TYPE_ABUS"; break; } + case 0x10: { attrData = "TYPE_PCI"; break; } + case 0x11: { attrData = "TYPE_DPSS"; break; } + case 0x12: { attrData = "TYPE_APSS"; break; } + case 0x13: { attrData = "TYPE_OCC"; break; } + case 0x14: { attrData = "TYPE_PSI"; break; } + case 0x15: { attrData = "TYPE_FSP"; break; } + case 0x16: { attrData = "TYPE_PNOR"; break; } + case 0x17: { attrData = "TYPE_LAST_IN_RANGE"; break; } + default: { attrData = "UNKNOWN TYPE"; break; } + } // switch + i_parser.PrintString("ATTR_TYPE", attrData); + i++; + l_ptr++; + + // MODEL + switch (*l_ptr) { + // TODO: RTC 50828: make these build-time dynamic based + // on values in obj/genfiles/attributeenums.H + case 0x00: { attrData = "MODEL_NA"; break; } + case 0x10: { attrData = "MODEL_RESERVED"; break; } + case 0x11: { attrData = "MODEL_VENICE"; break; } + case 0x12: { attrData = "MODEL_MURANO"; break; } + case 0x30: { attrData = "MODEL_CENTAUR"; break; } + case 0x50: { attrData = "MODEL_JEDEC"; break; } + case 0x51: { attrData = "MODEL_CDIMM"; break; } + case 0x70: { attrData = "MODEL_POWER8"; break; } + default: { attrData = "UNKNOWN MODEL"; break; } + } // switch + i_parser.PrintString("ATTR_MODEL", attrData); + i++; + l_ptr++; + } + +// TODO RTC 50828 The following for loop hangs +#if 0 + for (; i < i_buflen; ) + { + if ((*l_ptr == 0x15) || // ATTR_PHYS_PATH + (*l_ptr == 0x16)) // ATTR_AFFINITY_PATH + { + l_ptr++; + const char *pathString; + char outString[128]; + // from targeting/common/entitypath.[CH] + // entityPath is PATH_TYPE:4, NumberOfElements:4, + // [Element, Instance#] + // PATH_TYPE + const uint8_t pathTypeLength = *((uint8_t *)l_ptr); + l_ptr++; + const uint8_t pathType = (pathTypeLength & 0xF0) >> 4; + switch (pathType) { + case 0x01: pathString = "Logical:"; break; + case 0x02: pathString = "Physical:"; break; + case 0x03: pathString = "Device:"; break; + case 0x04: pathString = "Power:"; break; + default: pathString = "Unknown:"; break; + } + uint32_t dataSize = sprintf(outString, "%s",pathString); + const uint8_t pathSize = (pathTypeLength & 0x0F); + uint8_t *lElementInstance = ((uint8_t *)l_ptr); + l_ptr += pathSize * sizeof(uint8_t); + for (uint32_t j=0;j<pathSize;j += 2) { + switch (lElementInstance[j]) { + // TODO: RTC 50828: make these build-time dynamic based + // on values in obj/genfiles/attributeenums.H + case 0x01: pathString = "/Sys"; break; + case 0x02: pathString = "/Node"; break; + case 0x03: pathString = "/DIMM"; break; + case 0x04: pathString = "/Membuf"; break; + case 0x05: pathString = "/Proc"; break; + case 0x06: pathString = "/EX"; break; + case 0x07: pathString = "/Core"; break; + case 0x08: pathString = "/L2"; break; + case 0x09: pathString = "/L3"; break; + case 0x0A: pathString = "/L4"; break; + case 0x0B: pathString = "/MCS"; break; + case 0x0C: pathString = "/MBS"; break; + case 0x0D: pathString = "/MBA"; break; + case 0x0E: pathString = "/XBUS"; break; + case 0x0F: pathString = "/ABUS"; break; + case 0x10: pathString = "/PCI"; break; + case 0x11: pathString = "/DPSS"; break; + case 0x12: pathString = "/APSS"; break; + case 0x13: pathString = "/OCC"; break; + case 0x14: pathString = "/PSI"; break; + case 0x15: pathString = "/FSP"; break; + case 0x16: pathString = "/PNOR"; break; + default: pathString = "/Unknown"; break; + } // switch + // copy next part in, overwritting previous terminator + dataSize += sprintf(outString + dataSize, + "%s%d", pathString, + lElementInstance[j+1]); + } // for + if (*l_ptr == 0x15) // ATTR_PHYS_PATH + { + i_parser.PrintString("ATTR_PHYS_PATH", outString); + } + else + { + i_parser.PrintString("ATTR_AFFINITY_PATH", outString); + } + } + } // for +#endif + } + } // parse() + +private: + // Disabled + ErrlUserDetailsParserTarget(const ErrlUserDetailsParserTarget &); + ErrlUserDetailsParserTarget & operator=( + const ErrlUserDetailsParserTarget &); +}; + +} + +#endif + diff --git a/src/usr/errl/plugins/errluserdetails.H b/src/usr/errl/plugins/errluserdetails.H new file mode 100755 index 000000000..12efbc28b --- /dev/null +++ b/src/usr/errl/plugins/errluserdetails.H @@ -0,0 +1,103 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/errl/plugins/errluserdetails.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 ERRL_ERRLUSERDETAILS_H +#define ERRL_ERRLUSERDETAILS_H + +/** + * @file errluserdetails.H + * + * Defines the ErrlUserDetailsParser base class + * + * For each class derived from ErrlUserDetails used to create user detail data, + * derive a class from ErrlUserDetailsParser to parse user detail data + */ +#include <stdint.h> + +namespace ERRORLOG +{ + +/** + * + * @class ErrlUserDetailsParser + * + * This is an abstract base class that defines how user detail error log data + * should be parsed. For every different format of user detail data, a + * component should create a class that derives from this class. + */ +class ErrlUserDetailsParser +{ +public: + + /** + * @brief Constructor + * + */ + ErrlUserDetailsParser() + { + } + + /** + * @brief Destructor + * + */ + virtual ~ErrlUserDetailsParser() + { + } + + /** + * @brief Parses user detail data from an error log + * + * Parses the supplied user detail data and outputs info to i_parser. This + * is a pure virtual function that must be overridden by a concrete derived + * class that is specific to a particular component, version and subsection + * + * @param i_version + * Version of the data + * + * @param i_parse + * ErrlUsrParser object for outputting information + * + * @param i_pBuffer + * Pointer to buffer containing detail data + * + * @param i_buflen + * Length of the buffer + * + * @return None + * + */ + virtual void parse(errlver_t i_version, + ErrlUsrParser & i_parser, + void * i_pBuffer, + const uint32_t i_buflen) const = 0; + +private: + + // Disabled + ErrlUserDetailsParser(const ErrlUserDetailsParser &); + ErrlUserDetailsParser & operator=(const ErrlUserDetailsParser &); +}; + +} +#endif + diff --git a/src/usr/errl/plugins/fips.mk b/src/usr/errl/plugins/fips.mk deleted file mode 100644 index 1db670df3..000000000 --- a/src/usr/errl/plugins/fips.mk +++ /dev/null @@ -1,45 +0,0 @@ -# IBM_PROLOG_BEGIN_TAG -# This is an automatically generated prolog. -# -# $Source: src/usr/errl/plugins/fips.mk $ -# -# IBM CONFIDENTIAL -# -# COPYRIGHT International Business Machines Corp. 2012 -# -# 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 - -# This is a FipS makefile. The 'hb errlparser' step will copy it -# to a FipS build tree and assign a value for HBCOMPS as it is copied. - - -.if ( $(CONTEXT) == "x86.nfp" || $(CONTEXT) == "ppc" ) - -EXPINC_SUBDIRS = $(HBCOMPS) -EXPLIB_SUBDIRS = $(HBCOMPS) -OBJECTS_SUBDIRS = $(HBCOMPS) -SUBDIRS = $(HBCOMPS) -EXPSHLIB_SUBDIRS = $(HBCOMPS) - -.elif ( $(CONTEXT) == "aix.nfp" ) - -EXPINC_SUBDIRS = -EXPLIB_SUBDIRS = -OBJECTS_SUBDIRS = -SUBDIRS = -EXPSHLIB_SUBDIRS = -.endif - -.include <${RULES_MK}> diff --git a/src/usr/errl/plugins/makefile b/src/usr/errl/plugins/makefile deleted file mode 100644 index 8bb94fb91..000000000 --- a/src/usr/errl/plugins/makefile +++ /dev/null @@ -1,56 +0,0 @@ -# IBM_PROLOG_BEGIN_TAG -# This is an automatically generated prolog. -# -# $Source: src/usr/errl/plugins/errl/makefile $ -# -# IBM CONFIDENTIAL -# -# COPYRIGHT International Business Machines Corp. 2012 -# -# 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 - - -# This is a FipS makefile. This file and C sources will be built -# in a FipS tree. - -# All Hostboot plugins/makefile should .include ../plugins.mk -.include "../plugins.mk" - - -ERRL_PLUGIN = libB-0100 -ERRL_OBJS = errlParse.o symbols.o - - -CFLAGS += -O0 - -.if ( $(CONTEXT) == "x86.nfp" ) - -LIBRARIES = ${ERRL_PLUGIN}.a -EXPLIBS = ${ERRL_PLUGIN}.a -${ERRL_PLUGIN}.a_OFILES = ${ERRL_OBJS} - -.else - -BUILD_SHARED_OBJS = -SHARED_LIBRARIES EXPSHLIBS = ${ERRL_PLUGIN}.so -${ERRL_PLUGIN}.so_EXTRA_LIBS = libbase.so - -${ERRL_PLUGIN}.so_SHLDFLAGS += ${SHLDFLAGS} -Wl,-soname,${.TARGET} - -${ERRL_PLUGIN}.so_OFILES = ${ERRL_OBJS} - -.endif - -.include <${RULES_MK}> diff --git a/src/usr/errl/plugins/plugins.mk b/src/usr/errl/plugins/plugins.mk deleted file mode 100644 index fd1d90b2a..000000000 --- a/src/usr/errl/plugins/plugins.mk +++ /dev/null @@ -1,35 +0,0 @@ -# IBM_PROLOG_BEGIN_TAG -# This is an automatically generated prolog. -# -# $Source: src/usr/errl/plugins/plugins.mk $ -# -# IBM CONFIDENTIAL -# -# COPYRIGHT International Business Machines Corp. 2012 -# -# 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 - -# This is a FipS makefile. It will be copied to the directory above -# the directories for Hostboot components that build an errl plugin. - -# Hostboot plugin makefiles should include this makefile with -# .include "../plugins.mk" -# in order to set CFLAGS. Eventually, there may be other global -# settings common to all Hostboot makefiles. This makefile -# provides a common place for such changes. - - -CFLAGS += -DERRL_TOOLS -DPARSER -I${HOSTBOOTROOT}/obj/genfiles -I${HOSTBOOTROOT}/src/include/usr - diff --git a/src/usr/errl/test/errlReportTest.H b/src/usr/errl/test/errlReportTest.H index 2114a77ce..fc8fc289e 100644 --- a/src/usr/errl/test/errlReportTest.H +++ b/src/usr/errl/test/errlReportTest.H @@ -5,7 +5,7 @@ /* */ /* IBM CONFIDENTIAL */ /* */ -/* COPYRIGHT International Business Machines Corp. 2011,2012 */ +/* COPYRIGHT International Business Machines Corp. 2011,2013 */ /* */ /* p1 */ /* */ @@ -68,8 +68,8 @@ public: // Create an error log l_err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_INFORMATIONAL, - HBERRL_TEST_MOD_ID, - HBERRL_TEST_REASON_CODE, + ERRL_TEST_MOD_ID, + ERRL_TEST_REASON_CODE, l_userData1, l_userData2); if (l_err == NULL) @@ -106,8 +106,8 @@ public: // Create an error log l_err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_INFORMATIONAL, - HBERRL_TEST_MOD_ID, - HBERRL_TEST_REASON_CODE, + ERRL_TEST_MOD_ID, + ERRL_TEST_REASON_CODE, l_loopi, l_loopi); if (l_err == NULL) @@ -144,8 +144,8 @@ public: // Create an error log l_err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE, - HBERRL_TEST_MOD_ID, - HBERRL_TEST_REASON_CODE, + ERRL_TEST_MOD_ID, + ERRL_TEST_REASON_CODE, l_userData1, l_userData2); if (l_err == NULL) @@ -179,8 +179,8 @@ public: // Create an error log l_err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_CRITICAL_SYS_TERM, - HBERRL_TEST_MOD_ID, - HBERRL_TEST_REASON_CODE, + ERRL_TEST_MOD_ID, + ERRL_TEST_REASON_CODE, l_userData1, l_userData2); if (l_err == NULL) @@ -213,8 +213,8 @@ public: // Create an error log errlHndl_t l_err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE, - HBERRL_TEST_MOD_ID, - HBERRL_TEST_REASON_CODE, + ERRL_TEST_MOD_ID, + ERRL_TEST_REASON_CODE, l_userData1, l_userData2); @@ -251,7 +251,7 @@ public: } // Add null data. - pffdc = l_err->addFFDC( HBERRL_COMP_ID, NULL, 0, 9, 10 ); + pffdc = l_err->addFFDC( ERRL_COMP_ID, NULL, 0, 9, 10 ); if ( NULL != pffdc ) { TS_FAIL(" addFFDC() returned non null"); diff --git a/src/usr/errl/test/errltest.H b/src/usr/errl/test/errltest.H index ccec16892..598d29b01 100644 --- a/src/usr/errl/test/errltest.H +++ b/src/usr/errl/test/errltest.H @@ -5,7 +5,7 @@ /* */ /* IBM CONFIDENTIAL */ /* */ -/* COPYRIGHT International Business Machines Corp. 2011,2012 */ +/* COPYRIGHT International Business Machines Corp. 2011,2013 */ /* */ /* p1 */ /* */ @@ -103,9 +103,9 @@ public: { /*@ * @errortype - * @reasoncode HBERRL_TEST_REASON_CODE + * @reasoncode ERRL_TEST_REASON_CODE * @severity ERRORLOG::ERRL_SEV_INFORMATIONAL - * @moduleid HBERRL_TEST_MOD_ID + * @moduleid ERRL_TEST_MOD_ID * @devdesc Errl test. Error with non-decoded string * and lots of trace buffers. */ @@ -113,8 +113,8 @@ public: // Create an error log errlHndl_t l_err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_INFORMATIONAL, - HBERRL_TEST_MOD_ID, - HBERRL_TEST_REASON_CODE, + ERRL_TEST_MOD_ID, + ERRL_TEST_REASON_CODE, l_userData1, l_userData2); @@ -206,7 +206,7 @@ public: // Add null data. - pffdc = l_err->addFFDC( HBERRL_COMP_ID, NULL, 0, 9, 10 ); + pffdc = l_err->addFFDC( ERRL_COMP_ID, NULL, 0, 9, 10 ); if ( NULL != pffdc ) { TS_FAIL("testErrl1: addFFDC() returned non null"); @@ -220,7 +220,7 @@ public: break; } - if (l_err->reasonCode() != HBERRL_TEST_REASON_CODE) + if (l_err->reasonCode() != ERRL_TEST_REASON_CODE) { TS_FAIL("testErrl1: createErrlLog() returns incorrect reason code!"); break; @@ -287,8 +287,8 @@ public: // Create an error log errlHndl_t l_err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE, - HBERRL_TEST_MOD_ID, - HBERRL_TEST_REASON_CODE, + ERRL_TEST_MOD_ID, + ERRL_TEST_REASON_CODE, l_userData1, l_userData2); @@ -399,8 +399,8 @@ public: // Create an error log errlHndl_t errl = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE, - HBERRL_TEST_MOD_ID, - HBERRL_TEST_REASON_CODE); + ERRL_TEST_MOD_ID, + ERRL_TEST_REASON_CODE); // test the different callout types TS_TRACE( "test callout pProc %p", *pProc); diff --git a/src/usr/errl/test/errluserdetailtest.H b/src/usr/errl/test/errluserdetailtest.H index 2899bb0cd..825ff5e49 100644 --- a/src/usr/errl/test/errluserdetailtest.H +++ b/src/usr/errl/test/errluserdetailtest.H @@ -5,7 +5,7 @@ /* */ /* IBM CONFIDENTIAL */ /* */ -/* COPYRIGHT International Business Machines Corp. 2011,2012 */ +/* COPYRIGHT International Business Machines Corp. 2011,2013 */ /* */ /* p1 */ /* */ @@ -67,16 +67,16 @@ public: /*@ * @errortype * @severity ERRORLOG_SEV_INFORMATIONAL - * @moduleid HBERRL_USERDATA_TEST_MOD_ID - * @reasoncode HBERRL_TEST_STRING_UD + * @moduleid ERRL_USERDATA_TEST_MOD_ID + * @reasoncode ERRL_TEST_STRING_UD * @userdata1 Test data 1 * @userdata2 Test data 2 * @devdesc User Details unit test - create string user detail data */ errl = new ErrlEntry( ERRL_SEV_INFORMATIONAL, - HBERRL_USERDATA_TEST_MOD_ID, - HBERRL_TEST_STRING_UD, + ERRL_USERDATA_TEST_MOD_ID, + ERRL_TEST_STRING_UD, 0x1234567890, // user1 0x9876543210 ); // user2 @@ -105,16 +105,16 @@ public: /*@ * @errortype * @severity ERRORLOG_SEV_INFORMATIONAL - * @moduleid HBERRL_USERDATA_TEST_MOD_ID - * @reasoncode HBERRL_TEST_ATTRIBUTE_UD + * @moduleid ERRL_USERDATA_TEST_MOD_ID + * @reasoncode ERRL_TEST_ATTRIBUTE_UD * @userdata1 Test data 1 * @userdata2 Test data 2 * @devdesc User Details unit test - create string user detail data */ errl = new ErrlEntry( ERRL_SEV_INFORMATIONAL, - HBERRL_USERDATA_TEST_MOD_ID, - HBERRL_TEST_ATTRIBUTE_UD, + ERRL_USERDATA_TEST_MOD_ID, + ERRL_TEST_ATTRIBUTE_UD, 0x0001002300450067, 0x008900AB00CD00EF); @@ -264,16 +264,16 @@ public: /*@ * @errortype * @severity ERRORLOG_SEV_INFORMATIONAL - * @moduleid HBERRL_USERDATA_TEST_MOD_ID - * @reasoncode HBERRL_TEST_LOGREGISTER_UD + * @moduleid ERRL_USERDATA_TEST_MOD_ID + * @reasoncode ERRL_TEST_LOGREGISTER_UD * @userdata1 Test data 1 * @userdata2 Test data 2 * @devdesc User Details unit test - create log register user detail data */ errl = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_INFORMATIONAL, - HBERRL_USERDATA_TEST_MOD_ID, - HBERRL_TEST_LOGREGISTER_UD, + ERRL_USERDATA_TEST_MOD_ID, + ERRL_TEST_LOGREGISTER_UD, 0x008900AB00CD00EF, // user1 0x0001002300450067 ); // user2 @@ -507,16 +507,16 @@ public: /*@ * @errortype * @severity ERRORLOG_SEV_INFORMATIONAL - * @moduleid HBERRL_USERDATA_TEST_MOD_ID - * @reasoncode HBERRL_TEST_CALLOUT_UD + * @moduleid ERRL_USERDATA_TEST_MOD_ID + * @reasoncode ERRL_TEST_CALLOUT_UD * @userdata1 Test data 1 * @userdata2 Test data 2 * @devdesc User Details unit test - create callout user detail data */ errl = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_INFORMATIONAL, - HBERRL_USERDATA_TEST_MOD_ID, - HBERRL_TEST_CALLOUT_UD, + ERRL_USERDATA_TEST_MOD_ID, + ERRL_TEST_CALLOUT_UD, 0x0001002300450067, // user1 0x008900AB00CD00EF ); // user2 |