summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/fapi/fapiParseErrorInfo.pl
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr/hwpf/fapi/fapiParseErrorInfo.pl')
-rwxr-xr-xsrc/usr/hwpf/fapi/fapiParseErrorInfo.pl325
1 files changed, 283 insertions, 42 deletions
diff --git a/src/usr/hwpf/fapi/fapiParseErrorInfo.pl b/src/usr/hwpf/fapi/fapiParseErrorInfo.pl
index 858059567..ca1aab051 100755
--- a/src/usr/hwpf/fapi/fapiParseErrorInfo.pl
+++ b/src/usr/hwpf/fapi/fapiParseErrorInfo.pl
@@ -1,14 +1,16 @@
#!/usr/bin/perl
#
-# Purpose: This perl script will parse HWP Error XML files,
-# pull out the error Return Codes and create a header file fapiHwpReturnCodes.H
-# containing an enumeration of them.
+# Purpose: This perl script will parse HWP Error XML files and create required
+# FAPI code. The FAPI files created are:
#
-# Author: CamVan Nguyen
-# Last Updated: 06/03/2011
+# 1/ fapiHwpReturnCodes.H - HwpReturnCode enumeration
+# FfdcHwpToken enumeration
+# 2/ fapiCollectFfdc.C - fapiCollectFfdc function implementation
+# 3/ fapiErrorInfoMemInit.C - ErrorInfoRepositoryMem::init
+# implementation
#
-# Version: 1.0
+# Author: CamVan Nguyen and Mike Jones
#
# Change Log **********************************************************
#
@@ -18,6 +20,7 @@
# mjjones 06/06/11 Minor updates for integration
# mjjones 06/10/11 Added "use strict;"
# mjjones 07/05/11 Take output dir as parameter
+# mjjones 08/08/11 Large update to create more code
#
# End Change Log ******************************************************
@@ -34,8 +37,8 @@ my $numArgs = $#ARGV + 1;
if ($numArgs < 2)
{
print ("Usage: fapiParseErrorInfo.pl <output dir> <filename1> <filename2> ...\n");
- print (" This perl script will parse HWP Error XML files and add an\n");
- print (" enumeration of return codes to a file called fapiHwpReturnCodes.H\n");
+ print (" This perl script will parse HWP Error XML files and create\n");
+ print (" required FAPI code\n");
exit(1);
}
@@ -49,27 +52,83 @@ my $xml = new XML::Simple (KeyAttr=>[]);
#use Data::Dumper;
#------------------------------------------------------------------------------
-# Open output file for writing
+# Open output files for writing
#------------------------------------------------------------------------------
-my $outputFile = $ARGV[0];
-$outputFile .= "/";
-$outputFile .= "fapiHwpReturnCodes.H";
-open(OUTFILE, ">", $outputFile);
+my $rcFile = $ARGV[0];
+$rcFile .= "/";
+$rcFile .= "fapiHwpReturnCodes.H";
+open(RCFILE, ">", $rcFile);
+
+my $ffFile = $ARGV[0];
+$ffFile .= "/";
+$ffFile .= "fapiCollectFfdc.C";
+open(FFFILE, ">", $ffFile);
+
+my $miFile = $ARGV[0];
+$miFile .= "/";
+$miFile .= "fapiErrorInfoMemInit.C";
+open(MIFILE, ">", $miFile);
+
+#------------------------------------------------------------------------------
+# Create arrays of FFDC HWPs and their data types
+#------------------------------------------------------------------------------
+my @ffdcHwps;
+my @ffdcHwpsData;
+
+#------------------------------------------------------------------------------
+# Print start of file information to fapiHwpReturnCodes.H
+#------------------------------------------------------------------------------
+print RCFILE "// fapiHwpReturnCodes.H\n";
+print RCFILE "// This file is generated by perl script fapiParseErrorInfo.pl\n\n";
+print RCFILE "#ifndef FAPIHWPRETURNCODES_H_\n";
+print RCFILE "#define FAPIHWPRETURNCODES_H_\n\n";
+print RCFILE "namespace fapi\n";
+print RCFILE "{\n\n";
+print RCFILE "/**\n";
+print RCFILE " * \@brief Enumeration of HWP return codes\n";
+print RCFILE " *\/\n";
+print RCFILE "enum HwpReturnCode\n";
+print RCFILE "{\n";
+print RCFILE " RC_SUCCESS,\n";
#------------------------------------------------------------------------------
-# Print Start of file information
+# Print start of file information to fapiCollectFfdc.C
#------------------------------------------------------------------------------
-print OUTFILE "// fapiHwpReturnCodes.H\n";
-print OUTFILE "// This file is generated by perl script fapiParseErrorInfo.pl\n\n";
-print OUTFILE "#ifndef FAPIHWPRETURNCODES_H_\n";
-print OUTFILE "#define FAPIHWPRETURNCODES_H_\n\n";
-print OUTFILE "namespace fapi\n";
-print OUTFILE "{\n\n";
-print OUTFILE "/**\n";
-print OUTFILE " * \@brief Enumeration of HWP return codes\n";
-print OUTFILE " *\/\n";
-print OUTFILE "enum HwpReturnCode\n";
-print OUTFILE "{\n";
+print FFFILE "// fapiCollectFfdc.C\n";
+print FFFILE "// This file is generated by perl script fapiParseErrorInfo.pl\n\n";
+print FFFILE "#include <stdint.h>\n";
+print FFFILE "#include <fapiFfdcHwpData.H>\n";
+print FFFILE "#include <fapiHwpExecutor.H>\n";
+print FFFILE "#include <fapiHwpReturnCodes.H>\n";
+print FFFILE "#include <fapiReturnCode.H>\n";
+print FFFILE "#include <string.h>\n\n";
+print FFFILE "namespace fapi\n";
+print FFFILE "{\n\n";
+print FFFILE "ReturnCode fapiCollectFfdc(const FfdcHwpToken i_token,\n";
+print FFFILE " const Target & i_target,\n";
+print FFFILE " uint8_t * & o_pFfdc,\n";
+print FFFILE " uint32_t & o_size)\n";
+print FFFILE "{\n";
+print FFFILE " ReturnCode l_rc;\n\n";
+print FFFILE " switch (i_token)\n";
+print FFFILE " {\n";
+
+#------------------------------------------------------------------------------
+# Print start of file information to fapiErrorInfoMemInit.C
+#------------------------------------------------------------------------------
+print MIFILE "// fapiErrorInfoMemInit.C\n";
+print MIFILE "// This file is generated by perl script fapiParseErrorInfo.pl\n\n";
+print MIFILE "#include <fapiErrorInfoMem.H>\n\n";
+print MIFILE "namespace fapi\n";
+print MIFILE "{\n\n";
+print MIFILE "void ErrorInfoRepositoryMem::init()\n";
+print MIFILE "{\n";
+
+#------------------------------------------------------------------------------
+# Element names
+#------------------------------------------------------------------------------
+my $ffdc = 'ffdc';
+my $callout = 'callout';
#------------------------------------------------------------------------------
# For each XML file
@@ -78,40 +137,222 @@ foreach my $argnum (1 .. $#ARGV)
{
my $infile = $ARGV[$argnum];
+ #--------------------------------------------------------------------------
+ # Read XML file. Note that there may be multiple ffdc and callout elements
+ # so use the ForceArray option with these to ensure that XML::Simple
+ # creates an array even for single elements of these types
+ #--------------------------------------------------------------------------
# read XML file
- my $errors = $xml->XMLin($infile);
+ my $errors = $xml->XMLin($infile, ForceArray => [$ffdc, $callout]);
- # Uncomment to get debug output of all attributes
+ # Uncomment to get debug output of all errors
#print "\nFile: ", $infile, "\n", Dumper($errors), "\n";
#--------------------------------------------------------------------------
- # For each Attribute
+ # For each Error
#--------------------------------------------------------------------------
foreach my $err (@{$errors->{hwpError}})
{
- #--------------------------------------------------------------------------
- # Print the return code
- #--------------------------------------------------------------------------
- if ($err->{id})
+ #----------------------------------------------------------------------
+ # Check that expected fields are present
+ #----------------------------------------------------------------------
+ if (! exists $err->{rc})
{
- print OUTFILE " ", $err->{id}, ",\n";
+ print ("fapiParseErrorInfo.pl ERROR. rc missing\n");
+ exit(1);
}
- else
+
+ if (! exists $err->{description})
{
- print ("fapiParseErrorInfo.pl ERROR. ID missing\n");
+ print ("fapiParseErrorInfo.pl ERROR. description missing\n");
exit(1);
}
- };
+
+ #----------------------------------------------------------------------
+ # Print the return code to fapiHwpReturnCodes.H
+ #----------------------------------------------------------------------
+ print RCFILE " $err->{rc},\n";
+
+ #----------------------------------------------------------------------
+ # Print the return code and description to fapiErrorInfoMemInit.C
+ #----------------------------------------------------------------------
+ print MIFILE " {\n";
+ print MIFILE " ErrorInfoRecord l_record;\n";
+ print MIFILE " l_record.iv_rc = $err->{rc};\n";
+ print MIFILE " l_record.setDescription(\"$err->{description}\");\n";
+
+ #----------------------------------------------------------------------
+ # For each Callout element
+ #----------------------------------------------------------------------
+ foreach my $callout (@{$err->{callout}})
+ {
+ #------------------------------------------------------------------
+ # Check that expected fields are present
+ #------------------------------------------------------------------
+ if (! exists $callout->{targetType})
+ {
+ print ("fapiParseErrorInfo.pl ERROR. targetType missing\n");
+ exit(1);
+ }
+
+ if (! exists $callout->{targetPos})
+ {
+ print ("fapiParseErrorInfo.pl ERROR. targetPos missing\n");
+ exit(1);
+ }
+
+ if (! exists $callout->{priority})
+ {
+ print ("fapiParseErrorInfo.pl ERROR. priority missing\n");
+ exit(1);
+ }
+
+ #------------------------------------------------------------------
+ # Print the Callout data to fapiErrorInfoMemInit.C
+ #------------------------------------------------------------------
+ print MIFILE " {\n";
+ print MIFILE " ErrorInfoCallout l_callout($callout->{targetType}, ";
+ print MIFILE "$callout->{targetPos}, $callout->{priority});\n";
+ print MIFILE " l_record.iv_callouts.push_back(l_callout);\n";
+ print MIFILE " }\n";
+ }
+
+ #----------------------------------------------------------------------
+ # For each FFDC element
+ #----------------------------------------------------------------------
+ foreach my $ffdc (@{$err->{ffdc}})
+ {
+ #------------------------------------------------------------------
+ # Check that expected fields are present
+ #------------------------------------------------------------------
+ if (! exists $ffdc->{targetType})
+ {
+ print ("fapiParseErrorInfo.pl ERROR. targetType missing\n");
+ exit(1);
+ }
+
+ if (! exists $ffdc->{targetPos})
+ {
+ print ("fapiParseErrorInfo.pl ERROR. targetPos missing\n");
+ exit(1);
+ }
+
+ if (! exists $ffdc->{ffdcHwp})
+ {
+ print ("fapiParseErrorInfo.pl ERROR. ffdcHwp missing\n");
+ exit(1);
+ }
+
+ if (! exists $ffdc->{ffdcHwpData})
+ {
+ print ("fapiParseErrorInfo.pl ERROR. ffdcHwpData missing\n");
+ exit(1);
+ }
+
+ #------------------------------------------------------------------
+ # Print the FFDC data to fapiErrorInfoMemInit.C
+ #------------------------------------------------------------------
+ print MIFILE " {\n";
+ print MIFILE " ErrorInfoFfdc l_ffdc($ffdc->{targetType}, ";
+ print MIFILE "$ffdc->{targetPos}, $ffdc->{ffdcHwp}Token);\n";
+ print MIFILE " l_record.iv_ffdcs.push_back(l_ffdc);\n";
+ print MIFILE " }\n";
+
+ #------------------------------------------------------------------
+ # Record the FFDC HWP and its data if not already recorded
+ #------------------------------------------------------------------
+ my $match = 0;
+
+ foreach my $ffdcHwp (@ffdcHwps)
+ {
+ if ($ffdcHwp eq $ffdc->{ffdcHwp})
+ {
+ $match = 1;
+ }
+ }
+
+ if (!($match))
+ {
+ push(@ffdcHwps, $ffdc->{ffdcHwp});
+ push(@ffdcHwpsData, $ffdc->{ffdcHwpData});
+ }
+ }
+
+ #----------------------------------------------------------------------
+ # Print the Error Information Record submit to fapiErrorInfoMemInit.C
+ #----------------------------------------------------------------------
+ print MIFILE " iv_errorInfoRecords.push_back(l_record);\n";
+ print MIFILE " }\n\n";
+ }
+}
+
+#------------------------------------------------------------------------------
+# Print end of HwpReturnCode enum to fapiHwpReturnCodes.H
+#------------------------------------------------------------------------------
+print RCFILE "};\n\n";
+
+#------------------------------------------------------------------------------
+# Print FfdcHwpToken enum to fapiHwpReturnCodes.H
+#------------------------------------------------------------------------------
+print RCFILE "/**\n";
+print RCFILE " * \@brief Enumeration of tokens representing FFDC HWPs\n";
+print RCFILE " *\/\n";
+print RCFILE "enum FfdcHwpToken\n";
+print RCFILE "{\n";
+
+foreach my $ffdcHwp (@ffdcHwps)
+{
+ print RCFILE " $ffdcHwp", "Token,\n";
}
+print RCFILE "};\n\n";
+
+#------------------------------------------------------------------------------
+# Print end of file information to fapiHwpReturnCodes.H
+#------------------------------------------------------------------------------
+print RCFILE "}\n\n";
+print RCFILE "#endif\n";
+
+#------------------------------------------------------------------------------
+# Print FFDC function calls to fapiCollectFfdc.C
+#------------------------------------------------------------------------------
+for (my $i = 0; $i < scalar(@ffdcHwps); $i++)
+{
+ print FFFILE " case $ffdcHwps[$i]Token:\n";
+ print FFFILE " {\n";
+ print FFFILE " $ffdcHwpsData[$i] l_ffdc;\n";
+ print FFFILE " FAPI_EXEC_HWP(l_rc, $ffdcHwps[$i], i_target, l_ffdc);\n\n";
+ print FFFILE " if (!l_rc)\n";
+ print FFFILE " {\n";
+ print FFFILE " o_pFfdc = new uint8_t[sizeof(l_ffdc)];\n";
+ print FFFILE " o_size = sizeof(l_ffdc);\n";
+ print FFFILE " memcpy(o_pFfdc, &l_ffdc, sizeof(l_ffdc));\n";
+ print FFFILE " }\n";
+ print FFFILE " }\n";
+ print FFFILE " break;\n";
+}
+
+print FFFILE " default:\n";
+print FFFILE " l_rc = FAPI_RC_FFDC_HWP_NOT_FOUND;\n";
+print FFFILE " break;\n";
+
+print FFFILE " }\n\n";
+print FFFILE " return l_rc;\n";
+print FFFILE "}\n\n";
+
+#------------------------------------------------------------------------------
+# Print end of file information to fapiCollectFfdc.C
+#------------------------------------------------------------------------------
+print FFFILE "}\n\n";
+
#------------------------------------------------------------------------------
-# Print End of file information
+# Print end of file information to fapiErrorInfoMemInit.C
#------------------------------------------------------------------------------
-print OUTFILE "};\n\n";
-print OUTFILE "}\n\n";
-print OUTFILE "#endif\n";
+print MIFILE "}\n\n}\n";
#------------------------------------------------------------------------------
-# Close output file
+# Close output files
#------------------------------------------------------------------------------
-close(OUTFILE);
+close(RCFILE);
+close(FFFILE);
+close(MIFILE);
OpenPOWER on IntegriCloud