summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/fapi
diff options
context:
space:
mode:
authorMike Jones <mjjones@us.ibm.com>2011-08-12 11:03:30 -0500
committerNicholas E. Bofferding <bofferdn@us.ibm.com>2011-08-19 15:08:51 -0500
commit2935ed01dae82a91c1bb4c181fd36cc42b2efaf9 (patch)
treeedbde05a7cf666342b704b2eb069e6dfbcbd96c5 /src/usr/hwpf/fapi
parent02991f3ecb7356dc989148710e7ca40df0f7437c (diff)
downloadblackbird-hostboot-2935ed01dae82a91c1bb4c181fd36cc42b2efaf9.tar.gz
blackbird-hostboot-2935ed01dae82a91c1bb4c181fd36cc42b2efaf9.zip
HWPF Error Info Support
Change-Id: Ib060599a4b64e768cbc75184a050e851c0a39c4e Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/250 Tested-by: Jenkins Server Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com> Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com>
Diffstat (limited to 'src/usr/hwpf/fapi')
-rw-r--r--src/usr/hwpf/fapi/fapiErrorInfo.C141
-rw-r--r--src/usr/hwpf/fapi/fapiErrorInfoMem.C76
-rwxr-xr-xsrc/usr/hwpf/fapi/fapiParseErrorInfo.pl325
-rw-r--r--src/usr/hwpf/fapi/fapiReturnCode.C180
-rw-r--r--src/usr/hwpf/fapi/fapiReturnCodeDataRef.C80
-rw-r--r--src/usr/hwpf/fapi/makefile9
6 files changed, 709 insertions, 102 deletions
diff --git a/src/usr/hwpf/fapi/fapiErrorInfo.C b/src/usr/hwpf/fapi/fapiErrorInfo.C
new file mode 100644
index 000000000..a348138c8
--- /dev/null
+++ b/src/usr/hwpf/fapi/fapiErrorInfo.C
@@ -0,0 +1,141 @@
+/**
+ * @file fapiErrorInfo.C
+ *
+ * @brief Implements the Error Info structs and classes
+ */
+
+/*
+ * Change Log ******************************************************************
+ * Flag Defect/Feature User Date Description
+ * ------ -------------- ---------- ----------- ----------------------------
+ * mjjones 08/05/2011 Created
+ */
+
+#include <fapiErrorInfo.H>
+#include <string.h>
+
+namespace fapi
+{
+
+//******************************************************************************
+// ErrorInfoCallout Constructor
+//******************************************************************************
+ErrorInfoCallout::ErrorInfoCallout(const TargetType i_targetType,
+ const uint32_t i_targetPos,
+ const CalloutPriority i_priority)
+: iv_targetType(i_targetType),
+ iv_targetPos(i_targetPos),
+ iv_priority(i_priority)
+{
+
+}
+
+//******************************************************************************
+// ErrorInfoFfdc Constructor
+//******************************************************************************
+ErrorInfoFfdc::ErrorInfoFfdc(const TargetType i_targetType,
+ const uint32_t i_targetPos,
+ const FfdcHwpToken i_ffdcHwpToken)
+: iv_targetType(i_targetType),
+ iv_targetPos(i_targetPos),
+ iv_ffdcHwpToken(i_ffdcHwpToken)
+{
+
+}
+
+//******************************************************************************
+// ErrorInfoRecord Default Constructor
+//******************************************************************************
+ErrorInfoRecord::ErrorInfoRecord()
+: iv_rc(FAPI_RC_SUCCESS),
+ iv_pDescription(NULL)
+{
+
+}
+
+//******************************************************************************
+// ErrorInfoRecord Copy constructor
+//******************************************************************************
+ErrorInfoRecord::ErrorInfoRecord(const ErrorInfoRecord & i_right)
+: iv_rc(i_right.iv_rc),
+ iv_callouts(i_right.iv_callouts),
+ iv_ffdcs(i_right.iv_ffdcs),
+ iv_pDescription(NULL)
+{
+ // Perform deep copy of the description string
+ if (i_right.iv_pDescription)
+ {
+ iv_pDescription = new char[strlen(i_right.iv_pDescription) + 1];
+ strcpy(iv_pDescription, i_right.iv_pDescription);
+ }
+}
+
+//******************************************************************************
+// ErrorInfoRecord Destructor
+//******************************************************************************
+ErrorInfoRecord::~ErrorInfoRecord()
+{
+ delete [] iv_pDescription;
+}
+
+//******************************************************************************
+// ErrorInfoRecord Assignment operator
+//******************************************************************************
+ErrorInfoRecord & ErrorInfoRecord::operator=(const ErrorInfoRecord & i_right)
+{
+ // Test for self assignment
+ if (this != &i_right)
+ {
+ iv_rc = i_right.iv_rc;
+ iv_callouts = i_right.iv_callouts;
+ iv_ffdcs = i_right.iv_ffdcs;
+
+ // Perform deep copy of the description string
+ delete [] iv_pDescription;
+ iv_pDescription = NULL;
+
+ if (i_right.iv_pDescription)
+ {
+ iv_pDescription = new char[strlen(i_right.iv_pDescription) + 1];
+ strcpy(iv_pDescription, i_right.iv_pDescription);
+ }
+ }
+ return *this;
+}
+
+//******************************************************************************
+// ErrorInfoRecord setDescription function
+//******************************************************************************
+void ErrorInfoRecord::setDescription(const char * i_pDescription)
+{
+ delete [] iv_pDescription;
+ iv_pDescription = new char[strlen(i_pDescription) + 1];
+ strcpy(iv_pDescription, i_pDescription);
+}
+
+//******************************************************************************
+// ErrorInfoRecord getDescription function
+//******************************************************************************
+const char * ErrorInfoRecord::getDescription()
+{
+ return iv_pDescription;
+}
+
+
+//******************************************************************************
+// ErrorInfoRepository Default Constructor
+//******************************************************************************
+ErrorInfoRepository::ErrorInfoRepository()
+{
+ // Does nothing
+}
+
+//******************************************************************************
+// ErrorInfoRepository Destructor
+//******************************************************************************
+ErrorInfoRepository::~ErrorInfoRepository()
+{
+ // Does nothing
+}
+
+}
diff --git a/src/usr/hwpf/fapi/fapiErrorInfoMem.C b/src/usr/hwpf/fapi/fapiErrorInfoMem.C
new file mode 100644
index 000000000..0803eea96
--- /dev/null
+++ b/src/usr/hwpf/fapi/fapiErrorInfoMem.C
@@ -0,0 +1,76 @@
+/**
+ * @file fapiErrorInfoMem.C
+ *
+ * @brief Implements the ErrorInfoRepositoryMem class
+ */
+
+/*
+ * Change Log ******************************************************************
+ * Flag Defect/Feature User Date Description
+ * ------ -------------- ---------- ----------- ----------------------------
+ * mjjones 08/08/2011 Created
+ */
+
+#include <fapiErrorInfoMem.H>
+#include <fapiPlatTrace.H>
+
+namespace fapi
+{
+
+//******************************************************************************
+// ErrorInfoRepository Instance function
+//******************************************************************************
+ErrorInfoRepository& ErrorInfoRepository::Instance()
+{
+ // Use a static function variable. The ErrorInfoRepositoryMem singleton will
+ // be constructed on the first call to this function.
+ static ErrorInfoRepositoryMem instance;
+ return instance;
+}
+
+//******************************************************************************
+// ErrorInfoRepositoryMem Default Constructor
+//******************************************************************************
+ErrorInfoRepositoryMem::ErrorInfoRepositoryMem()
+{
+ // Initialize the repository with records
+ init();
+}
+
+//******************************************************************************
+// ErrorInfoRepositoryMem Destructor
+//******************************************************************************
+ErrorInfoRepositoryMem::~ErrorInfoRepositoryMem()
+{
+ // Does nothing
+}
+
+//******************************************************************************
+// ErrorInfoRepositoryMem find function
+//******************************************************************************
+ReturnCode ErrorInfoRepositoryMem::find(const uint32_t i_rc,
+ ErrorInfoRecord & o_record)
+{
+ // Iterate over vector of tables, until the correct one is found
+ ErrorInfoRecordItr_t l_it;
+
+ for (l_it = iv_errorInfoRecords.begin(); l_it != iv_errorInfoRecords.end();
+ ++l_it)
+ {
+ if ((*l_it).iv_rc == i_rc)
+ {
+ FAPI_INF("ErrorInfoRepositoryMem: Found record, rc: 0x%x", i_rc);
+ o_record = *l_it;
+ break;
+ }
+ }
+
+ if (l_it == iv_errorInfoRecords.end())
+ {
+ FAPI_ERR("ErrorInfoRepositoryMem: Not found record, rc: 0x%x", i_rc);
+ }
+
+ return FAPI_RC_SUCCESS;
+}
+
+}
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);
diff --git a/src/usr/hwpf/fapi/fapiReturnCode.C b/src/usr/hwpf/fapi/fapiReturnCode.C
index 1720f31c4..08cc04896 100644
--- a/src/usr/hwpf/fapi/fapiReturnCode.C
+++ b/src/usr/hwpf/fapi/fapiReturnCode.C
@@ -10,6 +10,8 @@
* ------ -------------- ---------- ----------- ----------------------------
* mjjones 04/13/2011 Created.
* mjjones 07/05/2011. Removed const from data
+ * mjjones 07/25/2011 Added support for FFDC and
+ * Error Target
*/
#include <fapiReturnCode.H>
@@ -22,7 +24,8 @@ namespace fapi
// Default Constructor
//******************************************************************************
ReturnCode::ReturnCode() :
- iv_rcValue(FAPI_RC_SUCCESS), iv_pDataRef(NULL)
+ iv_rcValue(FAPI_RC_SUCCESS), iv_pPlatDataRef(NULL), iv_pHwpFfdcRef(NULL),
+ iv_pErrTarget(NULL)
{
}
@@ -31,7 +34,8 @@ ReturnCode::ReturnCode() :
// Constructor
//******************************************************************************
ReturnCode::ReturnCode(const uint32_t i_rcValue) :
- iv_rcValue(i_rcValue), iv_pDataRef(NULL)
+ iv_rcValue(i_rcValue), iv_pPlatDataRef(NULL), iv_pHwpFfdcRef(NULL),
+ iv_pErrTarget(NULL)
{
}
@@ -40,15 +44,26 @@ ReturnCode::ReturnCode(const uint32_t i_rcValue) :
// Copy Constructor
//******************************************************************************
ReturnCode::ReturnCode(const ReturnCode & i_right) :
- iv_rcValue(i_right.iv_rcValue), iv_pDataRef(i_right.iv_pDataRef)
+ iv_rcValue(i_right.iv_rcValue), iv_pPlatDataRef(i_right.iv_pPlatDataRef),
+ iv_pHwpFfdcRef(i_right.iv_pHwpFfdcRef), iv_pErrTarget(NULL)
{
- // Note shallow copy (in initializer list) of iv_pDataRef pointer. Both
- // ReturnCodes now points to the same ReturnCodeDataRef
+ // Note shallow copy of data ref pointers. Both ReturnCodes now point to the
+ // same data
- if (iv_pDataRef)
+ // Increment the data ref counts and create a new copy of the error target
+ if (iv_pPlatDataRef)
{
- // Increase the ReturnCodeDataRef reference count
- (void) iv_pDataRef->incRefCount();
+ (void) iv_pPlatDataRef->incRefCount();
+ }
+
+ if (iv_pHwpFfdcRef)
+ {
+ (void) iv_pHwpFfdcRef->incRefCount();
+ }
+
+ if (i_right.iv_pErrTarget)
+ {
+ iv_pErrTarget = new Target(*i_right.iv_pErrTarget);
}
}
@@ -57,8 +72,10 @@ ReturnCode::ReturnCode(const ReturnCode & i_right) :
//******************************************************************************
ReturnCode::~ReturnCode()
{
- // Remove interest in any pointed to ReturnCodeDataRef
- (void) removeData();
+ // Remove interest in any data references and delete any Error Target
+ (void) removePlatData();
+ (void) removeHwpFfdc();
+ delete iv_pErrTarget;
}
//******************************************************************************
@@ -69,18 +86,31 @@ ReturnCode & ReturnCode::operator=(const ReturnCode & i_right)
// Test for self assignment
if (this != &i_right)
{
- // Remove interest in any pointed to ReturnCodeDataRef
- (void) removeData();
+ // Remove interest in any data references and delete any Error Target
+ (void) removePlatData();
+ (void) removeHwpFfdc();
+ delete iv_pErrTarget;
- // Copy instance variables. Note shallow copy of iv_pDataRef pointer.
- // Both ReturnCodes now points to the same ReturnCodeDataRef
+ // Copy instance variables. Note shallow copy of data ref pointers. Both
+ // ReturnCodes now point to the same data
iv_rcValue = i_right.iv_rcValue;
- iv_pDataRef = i_right.iv_pDataRef;
+ iv_pPlatDataRef = i_right.iv_pPlatDataRef;
+ iv_pHwpFfdcRef = i_right.iv_pHwpFfdcRef;
- if (iv_pDataRef)
+ // Increment the data ref counts and create a new copy of the error tgt
+ if (iv_pPlatDataRef)
{
- // Increase the ReturnCodeDataRef reference count
- (void) iv_pDataRef->incRefCount();
+ (void) iv_pPlatDataRef->incRefCount();
+ }
+
+ if (iv_pHwpFfdcRef)
+ {
+ (void) iv_pHwpFfdcRef->incRefCount();
+ }
+
+ if (i_right.iv_pErrTarget)
+ {
+ iv_pErrTarget = new Target(*i_right.iv_pErrTarget);
}
}
return *this;
@@ -112,50 +142,78 @@ ReturnCode::operator uint32_t() const
}
//******************************************************************************
-// getData function
+// getPlatData function
//******************************************************************************
-void * ReturnCode::getData() const
+void * ReturnCode::getPlatData() const
{
void * l_pData = NULL;
- if (iv_pDataRef)
+ if (iv_pPlatDataRef)
{
// Get the data
- l_pData = iv_pDataRef->getData();
+ l_pData = iv_pPlatDataRef->getData();
}
return l_pData;
}
//******************************************************************************
-// releaseData function
+// releasePlatData function
//******************************************************************************
-void * ReturnCode::releaseData()
+void * ReturnCode::releasePlatData()
{
void * l_pData = NULL;
- if (iv_pDataRef)
+ if (iv_pPlatDataRef)
{
// Release the data
- l_pData = iv_pDataRef->releaseData();
+ l_pData = iv_pPlatDataRef->releaseData();
- // Remove interest in pointed to ReturnCodeDataRef
- (void) removeData();
+ // Remove interest in ReturnCodePlatDataRef
+ (void) removePlatData();
}
return l_pData;
}
//******************************************************************************
-// setData function
+// setPlatData function
//******************************************************************************
-void ReturnCode::setData(void * i_pData)
+void ReturnCode::setPlatData(void * i_pData)
{
- // Remove interest in pointed to ReturnCodeDataRef
- (void) removeData();
+ // Remove interest in ReturnCodePlatDataRef
+ (void) removePlatData();
- // Create new ReturnCodeDataRef which points to the data
- iv_pDataRef = new ReturnCodeDataRef(i_pData);
+ // Create a new ReturnCodePlatDataRef which points to the data
+ iv_pPlatDataRef = new ReturnCodePlatDataRef(i_pData);
+}
+
+//******************************************************************************
+// getHwpFfdc function
+//******************************************************************************
+const void * ReturnCode::getHwpFfdc(uint32_t & o_size) const
+{
+ const void * l_pFfdc = NULL;
+
+ if (iv_pHwpFfdcRef)
+ {
+ // Get the HwpFfdc
+ l_pFfdc = iv_pHwpFfdcRef->getData(o_size);
+ }
+
+ return l_pFfdc;
+}
+
+//******************************************************************************
+// setHwpFfdc function
+//******************************************************************************
+void ReturnCode::setHwpFfdc(const void * i_pFfdc, const uint32_t i_size)
+{
+ // Remove interest in ReturnCodeHwpFfdcRef
+ (void) removeHwpFfdc();
+
+ // Create a new ReturnCodeHwpFfdcRef which contains the HwpFfdc
+ iv_pHwpFfdcRef = new ReturnCodeHwpFfdcRef(i_pFfdc, i_size);
}
//******************************************************************************
@@ -178,20 +236,58 @@ ReturnCode::returnCodeCreator ReturnCode::getCreator() const
}
//******************************************************************************
-// removeData function
+// setErrTarget function
+//******************************************************************************
+void ReturnCode::setErrTarget(const Target & i_target)
+{
+ if ((iv_rcValue != FAPI_RC_SUCCESS) && (iv_pErrTarget == NULL))
+ {
+ // Create a copy of the target
+ iv_pErrTarget = new Target(i_target);
+ }
+}
+
+//******************************************************************************
+// getErrTarget function
+//******************************************************************************
+Target * ReturnCode::getErrTarget() const
+{
+ return iv_pErrTarget;
+}
+
+//******************************************************************************
+// removePlatData function
+//******************************************************************************
+void ReturnCode::removePlatData()
+{
+ if (iv_pPlatDataRef)
+ {
+ // Decrement the ReturnCodePlatDataRef refcount
+ if (iv_pPlatDataRef->decRefCountCheckZero())
+ {
+ // Refcount decremented to zero. No other ReturnCode points to the
+ // ReturnCodePlatDataRef object, delete it
+ delete iv_pPlatDataRef;
+ }
+ iv_pPlatDataRef = NULL;
+ }
+}
+
+//******************************************************************************
+// removeHwpFfdc function
//******************************************************************************
-void ReturnCode::removeData()
+void ReturnCode::removeHwpFfdc()
{
- if (iv_pDataRef)
+ if (iv_pHwpFfdcRef)
{
- // Decrement the ReturnCodeDataRef refcount
- if (iv_pDataRef->decRefCountCheckZero())
+ // Decrement the ReturnCodeHwpFfdcRef refcount
+ if (iv_pHwpFfdcRef->decRefCountCheckZero())
{
// Refcount decremented to zero. No other ReturnCode points to the
- // ReturnCodeDataRef object, delete it
- delete iv_pDataRef;
+ // ReturnCodeHwpFfdcRef object, delete it
+ delete iv_pHwpFfdcRef;
}
- iv_pDataRef = NULL;
+ iv_pHwpFfdcRef = NULL;
}
}
diff --git a/src/usr/hwpf/fapi/fapiReturnCodeDataRef.C b/src/usr/hwpf/fapi/fapiReturnCodeDataRef.C
index 0682388ac..837fcc62e 100644
--- a/src/usr/hwpf/fapi/fapiReturnCodeDataRef.C
+++ b/src/usr/hwpf/fapi/fapiReturnCodeDataRef.C
@@ -12,8 +12,10 @@
* camvanng 05/31/2011 Added debug traces
* mjjones 06/30/2011 Added #include
* mjjones 07/05/2011 Removed const from data
+ * mjjones 07/25/2011 Added support for FFDC
*/
+#include <string.h>
#include <fapiReturnCodeDataRef.H>
#include <fapiUtil.H>
#include <fapiPlatTrace.H>
@@ -22,16 +24,16 @@ namespace fapi
{
//******************************************************************************
-// Constructor
+// ReturnCodeDataRef Constructor
//******************************************************************************
-ReturnCodeDataRef::ReturnCodeDataRef(void * i_pData) :
- iv_refCount(1), iv_pData(i_pData)
+ReturnCodeDataRef::ReturnCodeDataRef() :
+ iv_refCount(1)
{
}
//******************************************************************************
-// Destructor
+// ReturnCodeDataRef Destructor
//******************************************************************************
ReturnCodeDataRef::~ReturnCodeDataRef()
{
@@ -40,28 +42,25 @@ ReturnCodeDataRef::~ReturnCodeDataRef()
FAPI_ERR("ReturnCodeDataRef. Bug. Destruct with refcount");
fapiAssert(false);
}
- else
- {
- // Call platform implemented deleteData
- (void) deleteData();
- }
}
//******************************************************************************
-// incRefCount function
+// ReturnCodeDataRef incRefCount function
//******************************************************************************
void ReturnCodeDataRef::incRefCount()
{
- FAPI_DBG("ReturnCodeDataRef::incRefCount: iv_refCount = %i on entry", iv_refCount);
+ FAPI_DBG("ReturnCodeDataRef::incRefCount: iv_refCount = %d on entry",
+ iv_refCount);
iv_refCount++;
}
//******************************************************************************
-// decRefCountCheckZero function
+// ReturnCodeDataRef decRefCountCheckZero function
//******************************************************************************
bool ReturnCodeDataRef::decRefCountCheckZero()
{
- FAPI_DBG("ReturnCodeDataRef::decRefCountCheckZero: iv_refCount = %i on entry", iv_refCount);
+ FAPI_DBG("ReturnCodeDataRef::decRefCountCheckZero: iv_refCount = %d on "
+ "entry", iv_refCount);
if (iv_refCount == 0)
{
@@ -76,21 +75,68 @@ bool ReturnCodeDataRef::decRefCountCheckZero()
}
//******************************************************************************
-// getData function
+// ReturnCodePlatDataRef Constructor
//******************************************************************************
-void * ReturnCodeDataRef::getData() const
+ReturnCodePlatDataRef::ReturnCodePlatDataRef(void * i_pData) :
+ iv_pData(i_pData)
+{
+
+}
+
+//******************************************************************************
+// ReturnCodePlatDataRef Destructor
+//******************************************************************************
+ReturnCodePlatDataRef::~ReturnCodePlatDataRef()
+{
+ // Call platform implemented deleteData
+ (void) deleteData();
+}
+
+//******************************************************************************
+// ReturnCodePlatDataRef getData function
+//******************************************************************************
+void * ReturnCodePlatDataRef::getData() const
{
return iv_pData;
}
//******************************************************************************
-// releaseData function
+// ReturnCodePlatDataRef releaseData function
//******************************************************************************
-void * ReturnCodeDataRef::releaseData()
+void * ReturnCodePlatDataRef::releaseData()
{
void * l_pData = iv_pData;
iv_pData = NULL;
return l_pData;
}
+//******************************************************************************
+// ReturnCodeHwpFfdcRef Constructor
+//******************************************************************************
+ReturnCodeHwpFfdcRef::ReturnCodeHwpFfdcRef(const void * i_pFfdc,
+ const uint32_t i_size)
+: iv_size(i_size)
+{
+ iv_pFfdc = new uint8_t[i_size];
+ memcpy(iv_pFfdc, i_pFfdc, i_size);
+}
+
+//******************************************************************************
+// ReturnCodeHwpFfdcRef Destructor
+//******************************************************************************
+ReturnCodeHwpFfdcRef::~ReturnCodeHwpFfdcRef()
+{
+ delete [] iv_pFfdc;
+ iv_pFfdc = NULL;
+}
+
+//******************************************************************************
+// ReturnCodeHwpFfdcRef getData function
+//******************************************************************************
+const void * ReturnCodeHwpFfdcRef::getData(uint32_t & o_size) const
+{
+ o_size = iv_size;
+ return iv_pFfdc;
+}
+
}
diff --git a/src/usr/hwpf/fapi/makefile b/src/usr/hwpf/fapi/makefile
index 4e6e58995..8bc4e2def 100644
--- a/src/usr/hwpf/fapi/makefile
+++ b/src/usr/hwpf/fapi/makefile
@@ -4,9 +4,16 @@ MODULE = fapi
EXTRAINCDIR += ${ROOTPATH}/src/include/usr/ecmddatabuffer
EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/fapi
EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/plat
+EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/hwp
OBJS = fapiReturnCode.o \
fapiReturnCodeDataRef.o \
- fapiTarget.o
+ fapiTarget.o \
+ fapiErrorInfo.o \
+ fapiErrorInfoMem.o \
+ fapiErrorInfoMemInit.o \
+ fapiCollectFfdc.o
include ${ROOTPATH}/config.mk
+
+vpath %.C ${GENDIR}
OpenPOWER on IntegriCloud