diff options
author | Mike Jones <mjjones@us.ibm.com> | 2011-08-12 11:03:30 -0500 |
---|---|---|
committer | Nicholas E. Bofferding <bofferdn@us.ibm.com> | 2011-08-19 15:08:51 -0500 |
commit | 2935ed01dae82a91c1bb4c181fd36cc42b2efaf9 (patch) | |
tree | edbde05a7cf666342b704b2eb069e6dfbcbd96c5 /src/usr | |
parent | 02991f3ecb7356dc989148710e7ca40df0f7437c (diff) | |
download | talos-hostboot-2935ed01dae82a91c1bb4c181fd36cc42b2efaf9.tar.gz talos-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')
23 files changed, 2262 insertions, 735 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} diff --git a/src/usr/hwpf/hwp/fapiHwpErrorInfo.xml b/src/usr/hwpf/hwp/fapiHwpErrorInfo.xml index e4c5e68b1..ae503d2e0 100644 --- a/src/usr/hwpf/hwp/fapiHwpErrorInfo.xml +++ b/src/usr/hwpf/hwp/fapiHwpErrorInfo.xml @@ -4,12 +4,25 @@ <hwpErrors> <!-- *********************************************************************** --> <hwpError> - <id>RC_TEST_ERROR_A</id> - <description>Test Error A</description> + <rc>RC_TEST_ERROR_A</rc> + <description>Test Error A for a HWP operating on a PROC_CHIP</description> + <callout> + <!-- The callout is the PROC_CHIP itself --> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <targetPos>0</targetPos> + <priority>HIGH</priority> + </callout> + <ffdc> + <!-- FFDC needs to be collected from the PROC_CHIP itself --> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <targetPos>0</targetPos> + <ffdcHwp>hwpTestFfdc1</ffdcHwp> + <ffdcHwpData>TestFfdc1</ffdcHwpData> + </ffdc> </hwpError> <!-- *********************************************************************** --> <hwpError> - <id>RC_TEST_ERROR_B</id> + <rc>RC_TEST_ERROR_B</rc> <description>Test Error B</description> </hwpError> </hwpErrors> diff --git a/src/usr/hwpf/hwp/fapiTestHwp.C b/src/usr/hwpf/hwp/fapiTestHwp.C index 9190f9c07..5b835882d 100644 --- a/src/usr/hwpf/hwp/fapiTestHwp.C +++ b/src/usr/hwpf/hwp/fapiTestHwp.C @@ -12,6 +12,7 @@ * mjjones 06/02/2011 Use ecmdDataBufferBase * mjjones 06/28/2011 Removed attribute tests * andrewg 07/07/2011 Added test for hw team to fill in + * mjjones 08/10/2011 Removed clock HWP * */ @@ -21,63 +22,12 @@ extern "C" { //****************************************************************************** -// hwpIsP7ChipletClockOn function -//****************************************************************************** -fapi::ReturnCode hwpIsP7EM0ChipletClockOn(const fapi::Target & i_chip, - bool & o_clocksOn) -{ - // Ported from a combination of - // hwsvClockAlgP7.C : hwsvClockQueryOnP7 (main HWP) - // hwsvClockAlgP7.C : isChipletClockOn (sub function) - - // Attempt to call the attribute get/set functions for the test attributes - fapi::ReturnCode l_rc; - - // ----------------------------------------------------------------------- - // NOTE: @TODO - // There's no EM0 in P8. - // Must use core 3 clock status register to work in current VBU model - // ----------------------------------------------------------------------- - // Constants - const uint64_t EX_CLOCK_STATUS_MASK = 0xEEC0000000000000ULL; - const uint32_t EX3_CHIPLET_BASE_ADDR = 0x13000000; - const uint32_t CHIPLET_CLOCK_ON_SCOM_ADDR = 0x00030008; - - // Set caller's result to default - o_clocksOn = false; - - // Figure out the scom address and create a 64 bit data buffer - uint32_t l_addr = (EX3_CHIPLET_BASE_ADDR | CHIPLET_CLOCK_ON_SCOM_ADDR); - ecmdDataBufferBase l_data(64); - - // Perform a GetScom operation on the chip - l_rc = GetScom(i_chip, l_addr, l_data); - - if (l_rc != fapi::FAPI_RC_SUCCESS) - { - FAPI_ERR("hwpIsP8EX3ChipletClockOn: Error from GetScomChip"); - } - else - { - if (!(l_data.getDoubleWord(0) & EX_CLOCK_STATUS_MASK)) - { - FAPI_INF("hwpIsP8EX3ChipletClockOn: Clocks are on"); - o_clocksOn = true; - } - else - { - FAPI_INF("hwpIsP8EX3ChipletClockOn: Clocks are off"); - } - } - - return l_rc; -} - -//****************************************************************************** // hwpInitialTest function - Override with whatever you want here //****************************************************************************** fapi::ReturnCode hwpInitialTest(const fapi::Target & i_chip) { + FAPI_INF("Performing HWP: hwpInitialTest"); + fapi::ReturnCode l_rc; // Figure out the scom address and create a 64 bit data buffer @@ -94,8 +44,7 @@ fapi::ReturnCode hwpInitialTest(const fapi::Target & i_chip) } else { - FAPI_INF("hwpInitialTest: Data from SCOM:0x%X 0x%16X",l_data.getDoubleWord(0)); - + FAPI_INF("hwpInitialTest: Data from SCOM:0x%lld", l_data.getDoubleWord(0)); } return l_rc; diff --git a/src/usr/hwpf/hwp/fapiTestHwpAttr.C b/src/usr/hwpf/hwp/fapiTestHwpAttr.C index 493bec8de..54b9f130d 100755 --- a/src/usr/hwpf/hwp/fapiTestHwpAttr.C +++ b/src/usr/hwpf/hwp/fapiTestHwpAttr.C @@ -21,7 +21,7 @@ extern "C" //****************************************************************************** // hwpTestAttributes function //****************************************************************************** -fapi::ReturnCode hwpTestAttributes() +fapi::ReturnCode hwpTestAttributes(const fapi::Target & i_target) { // Attempt to call the attribute get/set functions for the test attributes fapi::ReturnCode l_rc; diff --git a/src/usr/hwpf/hwp/fapiTestHwpError.C b/src/usr/hwpf/hwp/fapiTestHwpError.C new file mode 100644 index 000000000..cb13b582f --- /dev/null +++ b/src/usr/hwpf/hwp/fapiTestHwpError.C @@ -0,0 +1,36 @@ +/** + * @file fapiTestHwpError.C + * + * @brief Implements a simple test Hardware Procedure that returns an error + */ + +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 08/08/2011 Created. + * + */ + +#include <fapiTestHwpError.H> + +extern "C" +{ + +//****************************************************************************** +// hwpTestError function +//****************************************************************************** +fapi::ReturnCode hwpTestError(const fapi::Target & i_target) +{ + FAPI_INF("Performing HWP: hwpTestError"); + + fapi::ReturnCode l_rc = fapi::RC_TEST_ERROR_A; + + // Add some local FFDC to the ReturnCode + uint32_t l_ffdc = 0x12345678; + l_rc.setHwpFfdc(reinterpret_cast<void *>(&l_ffdc), sizeof(uint32_t)); + + return l_rc; +} + +} // extern "C" diff --git a/src/usr/hwpf/hwp/fapiTestHwpFfdc.C b/src/usr/hwpf/hwp/fapiTestHwpFfdc.C new file mode 100644 index 000000000..5c9ffc7d5 --- /dev/null +++ b/src/usr/hwpf/hwp/fapiTestHwpFfdc.C @@ -0,0 +1,37 @@ +/** + * @file fapiTestHwpFfdc.C + * + * @brief Implements a simple test Hardware Procedure that collects FFDC data + */ + +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 08/08/2011 Created. + * + */ + +#include <fapiTestHwpFfdc.H> + +extern "C" +{ + +//****************************************************************************** +// hwpTestFfdc1 function +//****************************************************************************** +fapi::ReturnCode hwpTestFfdc1(const fapi::Target & i_target, + fapi::TestFfdc1 & o_ffdc) +{ + FAPI_INF("Performing FFDC HWP: hwpTestFfdc1"); + + // Just set data to output structure. A real FFDC HWP would do a hardware + // access to get FFDC + fapi::ReturnCode l_rc; + + o_ffdc.iv_data = 0x11223344; + + return l_rc; +} + +} // extern "C" diff --git a/src/usr/hwpf/hwp/makefile b/src/usr/hwpf/hwp/makefile index ef38aa8c9..bc8383579 100644 --- a/src/usr/hwpf/hwp/makefile +++ b/src/usr/hwpf/hwp/makefile @@ -6,6 +6,8 @@ EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/hwp EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/fapi EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/plat -OBJS = fapiTestHwp.o +OBJS = fapiTestHwp.o \ + fapiTestHwpError.o \ + fapiTestHwpFfdc.o include ${ROOTPATH}/config.mk diff --git a/src/usr/hwpf/makefile b/src/usr/hwpf/makefile index 55de95dc0..693422150 100644 --- a/src/usr/hwpf/makefile +++ b/src/usr/hwpf/makefile @@ -1,14 +1,21 @@ ROOTPATH = ../../.. MODULE = hwpf -GENFILES = fapiHwpReturnCodes.H fapiAttributeIds.H +GENFILES = gen_errfiles fapiAttributeIds.H SUBDIRS = fapi.d hwp.d plat.d test.d include ${ROOTPATH}/config.mk -${GENDIR}/fapiHwpReturnCodes.H : fapi/fapiParseErrorInfo.pl hwp/fapiHwpErrorInfo.xml - $< ${GENDIR} $(filter-out $<,$^) +# fapiParseErrorInfo.pl produces multiple output files. Use a dummy target to +# create a single rule to create all files so that the script is only run once +# (instead of once for each output file which could fail in a parallel build). +# The disadvantage is that the script is always run, even if there are no +# updates, but it is safe and there is no easy solution +${GENDIR}/gen_errfiles : fapi/fapiParseErrorInfo.pl hwp/fapiHwpErrorInfo.xml + $< ${GENDIR} $(filter-out $<,$^) +# fapiParseAttributeInfo.pl produces a single output file so a standard rule +# will work ${GENDIR}/fapiAttributeIds.H : fapi/fapiParseAttributeInfo.pl hwp/fapiHwpAttributeInfo.xml - $< ${GENDIR} $(filter-out $<,$^) + $< ${GENDIR} $(filter-out $<,$^) diff --git a/src/usr/hwpf/plat/fapiPlatHwAccess.C b/src/usr/hwpf/plat/fapiPlatHwAccess.C index d1058520c..0ca263589 100644 --- a/src/usr/hwpf/plat/fapiPlatHwAccess.C +++ b/src/usr/hwpf/plat/fapiPlatHwAccess.C @@ -42,7 +42,7 @@ fapi::ReturnCode GetScom(const fapi::Target& i_target, // Add the error log pointer as data to the ReturnCode FAPI_ERR("GetScom: HostBoot GetScom returns error"); l_rc = fapi::FAPI_RC_PLAT_ERR_SEE_DATA; - l_rc.setData(reinterpret_cast<void *> (l_err)); + l_rc.setPlatData(reinterpret_cast<void *> (l_err)); } else { @@ -79,7 +79,7 @@ fapi::ReturnCode PutScom(const fapi::Target& i_target, // Add the error log pointer as data to the ReturnCode FAPI_ERR("Putscom: HostBoot Putscom returns error"); l_rc = fapi::FAPI_RC_PLAT_ERR_SEE_DATA; - l_rc.setData(reinterpret_cast<void *> (l_err)); + l_rc.setPlatData(reinterpret_cast<void *> (l_err)); } FAPI_DBG(EXIT_MRK "PutScom"); diff --git a/src/usr/hwpf/plat/fapiPlatHwpInvoker.C b/src/usr/hwpf/plat/fapiPlatHwpInvoker.C index 44455a130..5bd13d0ce 100644 --- a/src/usr/hwpf/plat/fapiPlatHwpInvoker.C +++ b/src/usr/hwpf/plat/fapiPlatHwpInvoker.C @@ -5,48 +5,191 @@ */ #include <fapiPlatHwpInvoker.H> +#include <fapiHwpExecutor.H> #include <fapiReturnCode.H> #include <fapiPlatTrace.H> -#include <fapiTestHwp.H> +#include <fapiErrorInfo.H> +#include <fapiPlatReasonCodes.H> +#include <fapiCollectFfdc.H> +#include <errl/errlentry.H> namespace fapi { //****************************************************************************** -// rcToErrl function +// rcToErrl function. Converts an error fapi::ReturnCode into a errlHndl_t //****************************************************************************** errlHndl_t rcToErrl(ReturnCode i_rc) { errlHndl_t l_err = NULL; + // Find out which component of the HWPF created the error ReturnCode::returnCodeCreator l_creator = i_rc.getCreator(); if (l_creator == ReturnCode::CREATOR_PLAT) { - // Release the errlHndl_t - l_err = reinterpret_cast<errlHndl_t> (i_rc.releaseData()); + // PLAT error. Release the errlHndl_t + FAPI_ERR("rcToErrl: 0x%x is PLAT error", static_cast<uint32_t>(i_rc)); + l_err = reinterpret_cast<errlHndl_t> (i_rc.releasePlatData()); + } + else if (l_creator == ReturnCode::CREATOR_HWP) + { + // HWP Error. Create an error log + // TODO What should the severity be? Should it be in the error record + /*@ + * @errortype + * @moduleid MOD_RC_TO_ERRL + * @reasoncode RC_HWP_ERROR + * @userdata1 Return Code Value + * @devdesc Error from HWP + */ + l_err = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE, + MOD_RC_TO_ERRL, + RC_HWP_ERROR, + static_cast<uint32_t>(i_rc)); + + // Add any HWP FFDC stored in the ReturnCode to the error log + uint32_t l_sz = 0; + const void * l_pHwpFfdc = i_rc.getHwpFfdc(l_sz); + + if (l_sz) + { + // TODO Which comp id and section numbers should be used and how + // will FFDC be parsed? + FAPI_ERR("rcToErrl: Adding %d bytes of HWP FFDC to log", l_sz); + l_err->addFFDC(HWPF_COMP_ID, l_pHwpFfdc, l_sz); + } + + // Get the error info record from the Error Info Repository + ErrorInfoRecord l_record; + ErrorInfoRepository::Instance().find(i_rc, l_record); + + if (l_record.iv_rc == i_rc) + { + // Error Info Record found + const char * l_pDescription = l_record.getDescription(); + + if (l_pDescription) + { + FAPI_ERR("rcToErrl: HWP error record found for 0x%x: %s", + static_cast<uint32_t>(i_rc), l_pDescription); + } + else + { + FAPI_ERR("rcToErrl: HWP error record found for 0x%x: no " + "description", static_cast<uint32_t>(i_rc)); + } + + // Extract the Error Target (the Target of the failing HWP) + Target * l_pErrTarget = i_rc.getErrTarget(); + + if (l_pErrTarget == NULL) + { + FAPI_ERR("rcToErrl: HWP error record contains no error target"); + } + else + { + // TODO Iterate through callouts, adding each callout to the + // error log + + // Iterate through FFDC sections, collecting and adding FFDC to + // the error log + for(ErrorInfoRecord::ErrorInfoFfdcItr_t l_itr = + l_record.iv_ffdcs.begin(); + l_itr != l_record.iv_ffdcs.end(); ++l_itr) + { + // Get the FFDC HWP Token, this identifies the FFDC HWP to + // call to get FFDC + FfdcHwpToken l_token = (*l_itr).iv_ffdcHwpToken; + + // Figure out which target to collect FFDC from + Target * l_pFfdcTarget = NULL; + + if ((*l_itr).iv_targetType == l_pErrTarget->getType()) + { + // The target type to collect FFDC from is the same as + // the Error Target. Collect FFDC from the error target + l_pFfdcTarget = l_pErrTarget; + } + else + { + // The target type to collect FFDC from is different + // from the Error Target. Figure out the target to + // collect FFDC from using the record's iv_targetPos + // (relative to the Error Target) + // TODO + FAPI_ERR("rcToErrl: Collection of FFDC from non Error " + "Target TBD"); + } + + if (l_pFfdcTarget) + { + // Collect FFDC + uint8_t * l_pFfdc = NULL; + uint32_t l_size = 0; + + ReturnCode l_rc = fapiCollectFfdc(l_token, + *l_pFfdcTarget, + l_pFfdc, l_size); + + if (l_rc) + { + // Error collecting FFDC, just ignore + FAPI_ERR("rcToErrl: Error collecting FFDC. " + "Token: %d", l_token); + } + else + { + // Add FFDC to error log and delete + // TODO Which comp id and section numbers should be + // used and how will FFDC be parsed? + FAPI_ERR("rcToErrl: Adding %d bytes of FFDC to " + "log. Token: %d", l_size, l_token); + l_err->addFFDC(HWPF_COMP_ID, l_pFfdc, l_size); + delete [] l_pFfdc; + l_pFfdc = NULL; + } + } + } + } + } + else + { + // Error Info Record not found. Should not happen + FAPI_ERR("rcToErrl: HWP error record not found for 0x%x", + static_cast<uint32_t>(i_rc)); + } } else { - //@todo Figure out how to convert FAPI/HWP error to Host Boot error log + // FAPI error. + FAPI_ERR("rcToErrl: 0x%x is FAPI error", static_cast<uint32_t>(i_rc)); + /*@ + * @errortype + * @moduleid MOD_RC_TO_ERRL + * @reasoncode RC_FAPI_ERROR + * @userdata1 Return Code Value + * @devdesc FAPI Error + */ + l_err = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE, + MOD_RC_TO_ERRL, + RC_FAPI_ERROR, + static_cast<uint32_t>(i_rc)); } return l_err; } - //****************************************************************************** -// invokeHwpIsP7EM0ChipletClockOn function +// invokeHwpInitialTest function //****************************************************************************** -errlHndl_t invokeHwpIsP7EM0ChipletClockOn(TARGETING::Target* i_target, - bool & o_clocksOn) +errlHndl_t invokeHwpInitialTest(TARGETING::Target* i_target) { - - FAPI_DBG(ENTER_MRK "HostBootHwpIsP7EM0ChipletClockOn"); + FAPI_DBG(ENTER_MRK "invokeHwpInitialTest"); errlHndl_t l_err = NULL; - // Create a generic Target object + // Create a generic Target object Target l_target(TARGET_TYPE_PROC_CHIP, reinterpret_cast<void *> (i_target)); //@todo @@ -55,66 +198,53 @@ errlHndl_t invokeHwpIsP7EM0ChipletClockOn(TARGETING::Target* i_target, // Call the HWP executor macro ReturnCode l_rc; - FAPI_EXEC_HWP(l_rc, hwpIsP7EM0ChipletClockOn, l_target, o_clocksOn); + FAPI_EXEC_HWP(l_rc, hwpInitialTest, l_target); if (l_rc != FAPI_RC_SUCCESS) { - FAPI_ERR("hwpIsP7EM0ChipletClockOn: Error (0x%x) from " - "execHwpIsP7EM0ChipletClockOn", + FAPI_ERR("invokeHwpInitialTest: Error (0x%x) from " + "exechwpInitialTest", static_cast<uint32_t> (l_rc)); l_err = rcToErrl(l_rc); } else { - if (o_clocksOn) - { - FAPI_INF("hwpIsP7EM0ChipletClockOn: Clocks are on"); - } - else - { - FAPI_INF("hwpIsP7EM0ChipletClockOn: Clocks are off"); - } + FAPI_INF("Success in call to exechwpInitialTest"); } - FAPI_DBG(EXIT_MRK "HostBootHwpIsP7EM0ChipletClockOn"); + FAPI_DBG(EXIT_MRK "invokeHwpInitialTest"); return l_err; } //****************************************************************************** -// invokeHwpInitial function +// invokeHwpTestError function //****************************************************************************** -errlHndl_t invokeHwpInitialTest(TARGETING::Target* i_target) +errlHndl_t invokeHwpTestError(TARGETING::Target* i_target) { - - FAPI_DBG(ENTER_MRK "invokeHwpInitialTest"); + FAPI_DBG(ENTER_MRK "invokeHwpTestError"); errlHndl_t l_err = NULL; - // Create a generic Target object + // Create a generic Target object Target l_target(TARGET_TYPE_PROC_CHIP, reinterpret_cast<void *> (i_target)); - //@todo - // Double check to see if any locking is needed here. - // Lower XSCOM already has a mutex lock. - // Call the HWP executor macro ReturnCode l_rc; - FAPI_EXEC_HWP(l_rc, hwpInitialTest, l_target); + FAPI_EXEC_HWP(l_rc, hwpTestError, l_target); if (l_rc != FAPI_RC_SUCCESS) { - FAPI_ERR("invokeHwpInitialTest: Error (0x%x) from " - "exechwpInitialTest", + FAPI_INF("invokeHwpTestError: Expected error (0x%x) from HWP", static_cast<uint32_t> (l_rc)); l_err = rcToErrl(l_rc); } else { - FAPI_INF("Success in call to exechwpInitialTest"); + FAPI_ERR("Success from HWP"); } - FAPI_DBG(EXIT_MRK "invokeHwpInitialTest"); + FAPI_DBG(EXIT_MRK "invokeHwpTestError"); return l_err; } diff --git a/src/usr/hwpf/plat/fapiPlatReturnCodeDataRef.C b/src/usr/hwpf/plat/fapiPlatReturnCodeDataRef.C index 02e9caeb3..e7d1bce93 100644 --- a/src/usr/hwpf/plat/fapiPlatReturnCodeDataRef.C +++ b/src/usr/hwpf/plat/fapiPlatReturnCodeDataRef.C @@ -17,12 +17,13 @@ namespace fapi //****************************************************************************** // deleteData function //****************************************************************************** -void ReturnCodeDataRef::deleteData() +void ReturnCodePlatDataRef::deleteData() { - FAPI_DBG("ReturnCodeDataRef::deleteData"); + FAPI_DBG("ReturnCodePlatDataRef::deleteData"); // HostBoot platform uses iv_pData to point at an error log. delete (static_cast<errlHndl_t>(iv_pData)); + iv_pData = NULL; } } diff --git a/src/usr/hwpf/test/fapiRcTest.C b/src/usr/hwpf/test/fapiRcTest.C new file mode 100644 index 000000000..8be88bcc0 --- /dev/null +++ b/src/usr/hwpf/test/fapiRcTest.C @@ -0,0 +1,819 @@ +/** + * @file fapiTargetTest.C + * + * @brief Implements Target class unit test functions. + */ + +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 04/13/2011 Created. + * mjjones 07/26/2011 Added more tests + * + */ + +#include <fapi.H> + +namespace fapi +{ + +//****************************************************************************** +// rcTest1. Ensures that the ReturnCode default constructor works +//****************************************************************************** +uint32_t rcTest1() +{ + uint32_t l_result = 0; + + // Create ReturnCode using default constructor + ReturnCode l_rc; + + // Ensure that the embedded return code is success + if (l_rc != FAPI_RC_SUCCESS) + { + FAPI_ERR("rcTest1. Code is 0x%x, expected success", + static_cast<uint32_t>(l_rc)); + l_result = 1; + } + else + { + // Ensure that ok function works + if (l_rc.ok() == false) + { + FAPI_ERR("rcTest1. ok returned false"); + l_result = 2; + } + else + { + // Ensure that testing l_rc works + if (l_rc) + { + FAPI_ERR("rcTest1. testing rc returned true"); + l_result = 3; + } + } + } + + return l_result; +} + +//****************************************************************************** +// rcTest2. Ensures that the ReturnCode creator reflects the return code +//****************************************************************************** +uint32_t rcTest2() +{ + uint32_t l_result = 0; + + // Create ReturnCode using default constructor + ReturnCode l_rc; + + // Set the return code to a FAPI code + l_rc = FAPI_RC_FAPI_MASK | 0x05; + + // Ensure that the creator is FAPI + ReturnCode::returnCodeCreator l_creator = l_rc.getCreator(); + + if (l_creator != ReturnCode::CREATOR_FAPI) + { + FAPI_ERR("rcTest2. Creator is 0x%x, expected FAPI", l_creator); + l_result = 1; + } + else + { + // Set the return code to a PLAT code + l_rc = FAPI_RC_PLAT_ERR_SEE_DATA; + + // Ensure that the creator is PLAT + l_creator = l_rc.getCreator(); + + if (l_creator != ReturnCode::CREATOR_PLAT) + { + FAPI_ERR("rcTest2. Creator is 0x%x, expected PLAT", l_creator); + l_result = 2; + } + else + { + // Set the return code to a HWP code + l_rc = 5; + + // Ensure that the creator is HWP + l_creator = l_rc.getCreator(); + + if (l_creator != ReturnCode::CREATOR_HWP) + { + FAPI_ERR("rcTest2. Creator is 0x%x, expected HWP", l_creator); + l_result = 3; + } + } + } + + return l_result; +} + +//****************************************************************************** +// rcTest3. Ensures that the ReturnCode constructor works when specifying a +// return code +//****************************************************************************** +uint32_t rcTest3() +{ + uint32_t l_result = 0; + + // Create ReturnCode specifying a return code + uint32_t l_code = 4; + ReturnCode l_rc(l_code); + + // Ensure that the embedded return code is as expected + uint32_t l_codeCheck = l_rc; + + if (l_codeCheck != l_code) + { + FAPI_ERR("rcTest3. Code is 0x%x, expected 0x%x", l_codeCheck, + l_code); + l_result = 1; + } + else + { + // Ensure that ok function returns false + if (l_rc.ok()) + { + FAPI_ERR("rcTest3. ok returned true"); + l_result = 2; + } + else + { + // Ensure that testing l_rc works + if (!l_rc) + { + FAPI_ERR("rcTest3. testing rc returned false"); + l_result = 3; + } + } + } + + return l_result; +} + +//****************************************************************************** +// rcTest4. Ensures that the comparison operators work (comparing with another +// ReturnCode) +//****************************************************************************** +uint32_t rcTest4() +{ + uint32_t l_result = 0; + + // Create similar ReturnCodes + uint32_t l_code = 6; + uint32_t l_code2 = 7; + ReturnCode l_rc(l_code); + ReturnCode l_rc2(l_code); + + // Ensure that the equality comparison returns true + if (!(l_rc == l_rc2)) + { + FAPI_ERR("rcTest5. 1. Equality comparison false"); + l_result = 1; + } + else + { + // Ensure that the inequality comparison returns false + if (l_rc != l_rc2) + { + FAPI_ERR("rcTest5. 2. Inequality comparison true"); + l_result = 2; + } + else + { + // Change the code of l_rc2 + l_rc2 = l_code2; + + // Ensure that the equality comparison returns false + if (l_rc == l_rc2) + { + FAPI_ERR("rcTest5. 3. Equality comparison true"); + l_result = 3; + } + else + { + // Ensure that the inequality comparison returns true + if (!(l_rc != l_rc2)) + { + FAPI_ERR("rcTest5. 4. Inequality comparison false"); + l_result = 4; + } + } + } + } + + return l_result; +} + +//****************************************************************************** +// rcTest5. Ensures that the comparison operators work (comparing with a return +// code value) +//****************************************************************************** +uint32_t rcTest5() +{ + uint32_t l_result = 0; + + // Create a ReturnCode + uint32_t l_code = 6; + uint32_t l_code2 = 7; + ReturnCode l_rc(l_code); + + // Ensure that the equality comparison returns true when comparing to the + // same return code value + if (!(l_rc == l_code)) + { + FAPI_ERR("rcTest6. 1. Equality comparison false"); + l_result = 1; + } + else + { + // Ensure that the inequality comparison returns false when comparing to + // the same return code value + if (l_rc != l_code) + { + FAPI_ERR("rcTest6. 2. Inequality comparison true"); + l_result = 2; + } + else + { + // Ensure that the equality comparison returns false when comparing + // to a different return code value + if (l_rc == l_code2) + { + FAPI_ERR("rcTest6. 3. Equality comparison true"); + l_result = 3; + } + else + { + // Ensure that the inequality comparison returns true when + // comparing to a different return code value + if (!(l_rc != l_code2)) + { + FAPI_ERR("rcTest6. 4. Inequality comparison false"); + l_result = 4; + } + } + } + } + + return l_result; +} + +//****************************************************************************** +// rcTest6. Ensures that the getPlatData and releasePlatData functions work when +// there is no attached data +//****************************************************************************** +uint32_t rcTest6() +{ + uint32_t l_result = 0; + + // Create a ReturnCode + uint32_t l_code = 6; + ReturnCode l_rc(l_code); + + // Ensure that the getPlatData function returns NULL + void * l_pData = reinterpret_cast<void *> (0x12345678); + + l_pData = l_rc.getPlatData(); + + if (l_pData != NULL) + { + FAPI_ERR("rcTest7. getPlatData did not return NULL"); + l_result = 1; + } + else + { + // Ensure that the releasePlatData function returns NULL + l_pData = reinterpret_cast<void *> (0x12345678); + + l_pData = l_rc.releasePlatData(); + + if (l_pData != NULL) + { + FAPI_ERR("rcTest7. releasePlatData did not return NULL"); + l_result = 2; + } + } + + return l_result; +} + +//****************************************************************************** +// rcTest7. Ensures that the getPlatData function works when there is attached +// data +//****************************************************************************** +uint32_t rcTest7() +{ + uint32_t l_result = 0; + + // Create a ReturnCode + uint32_t l_code = 10; + ReturnCode l_rc(l_code); + + // Assign PlatData. Note that this should really be an errlHndl_t, because + // the FSP deleteData function will attempt to delete an error log, but this + // is just for test, the data will be released before the ReturnCode is + // destructed. + uint32_t l_myData = 6; + void * l_pMyData = reinterpret_cast<void *> (&l_myData); + (void) l_rc.setPlatData(l_pMyData); + + // Ensure that getPlatData retrieves the PlatData + void * l_pMyDataCheck = l_rc.getPlatData(); + + if (l_pMyDataCheck != l_pMyData) + { + FAPI_ERR("rcTest8. 1. getPlatData returned unexpected data ptr"); + l_result = 1; + } + else + { + // Ensure that getPlatData retrieves the PlatData again + l_pMyDataCheck = NULL; + l_pMyDataCheck = l_rc.getPlatData(); + + if (l_pMyDataCheck != l_pMyData) + { + FAPI_ERR("rcTest8. 2. getPlatData returned unexpected data ptr"); + l_result = 2; + } + } + + // Release the data to avoid ReturnCode from deleting in on destruction + l_pMyDataCheck = l_rc.releasePlatData(); + + return l_result; +} + +//****************************************************************************** +// rcTest8. Ensures that the releasePlatData function works when there is +// attached data +//****************************************************************************** +uint32_t rcTest8() +{ + uint32_t l_result = 0; + + // Create a ReturnCode + uint32_t l_code = 10; + ReturnCode l_rc(l_code); + + // Assign PlatData. Note that this should really be an errlHndl_t, because + // the FSP deleteData function will attempt to delete an error log, but this + // is just for test, the data will be released before the ReturnCode is + // destructed. + uint32_t l_myData = 6; + void * l_pMyData = reinterpret_cast<void *> (&l_myData); + (void) l_rc.setPlatData(l_pMyData); + + // Ensure that releasePlatData retrieves the PlatData + void * l_pMyDataCheck = l_rc.releasePlatData(); + + if (l_pMyDataCheck != l_pMyData) + { + FAPI_ERR("rcTest9. getPlatData returned unexpected data ptr"); + l_result = 1; + } + else + { + // Ensure that releasePlatData now returns NULL + l_pMyDataCheck = NULL; + l_pMyDataCheck = l_rc.releasePlatData(); + + if (l_pMyDataCheck != NULL) + { + FAPI_ERR("rcTest9. 2. getPlatData returned non NULL ptr"); + l_result = 2; + } + } + + return l_result; +} + +//****************************************************************************** +// rcTest9. Ensures that the copy constructor works when there is attached +// PlatData and that the getPlatData function works +//****************************************************************************** +uint32_t rcTest9() +{ + uint32_t l_result = 0; + + // Create a ReturnCode + uint32_t l_code = 10; + ReturnCode l_rc(l_code); + + // Assign PlatData. Note that this should really be an errlHndl_t, because + // the FSP deleteData function will attempt to delete an error log, but this + // is just for test, the data will be released before the ReturnCode is + // destructed. + uint32_t l_myData = 6; + void * l_pMyData = reinterpret_cast<void *> (&l_myData); + (void) l_rc.setPlatData(l_pMyData); + + // Create a ReturnCode using the copy constructor + ReturnCode l_rc2(l_rc); + + // Ensure that the two ReturnCodes are the same + if (l_rc != l_rc2) + { + FAPI_ERR("rcTest10. ReturnCodes differ"); + l_result = 1; + } + else + { + // Ensure that getPlatData retrieves the PlatData from l_rc + void * l_pMyDataCheck = l_rc.getPlatData(); + + if (l_pMyDataCheck != l_pMyData) + { + FAPI_ERR("rcTest10. 1. getPlatData returned unexpected data ptr"); + l_result = 2; + } + else + { + // Ensure that getPlatData retrieves the PlatData from l_rc2 + l_pMyDataCheck = NULL; + l_pMyDataCheck = l_rc2.getPlatData(); + + if (l_pMyDataCheck != l_pMyData) + { + FAPI_ERR("rcTest10. 2. getPlatData returned unexpected data ptr"); + l_result = 3; + } + } + } + + // Release the data to avoid ReturnCode from deleting in on destruction. + // This will release the data from both copies of the ReturnCode. + (void) l_rc.releasePlatData(); + + return l_result; +} + +//****************************************************************************** +// rcTest10. Ensures that the assignment operator works when there is attached +// PlatData and that the releasePlatData function works +//****************************************************************************** +uint32_t rcTest10() +{ + uint32_t l_result = 0; + + // Create a ReturnCode + uint32_t l_code = 10; + ReturnCode l_rc(l_code); + + // Assign PlatData. Note that this should really be an errlHndl_t, because + // the PLAT deleteData function will attempt to delete an error log, but + // this is just for test, the data will be released before the ReturnCode is + // destructed. + uint32_t l_myData = 6; + void * l_pMyData = reinterpret_cast<void *> (&l_myData); + (void) l_rc.setPlatData(l_pMyData); + + // Create a ReturnCode using the assignment operator + ReturnCode l_rc2; + l_rc2 = l_rc; + + // Ensure that the two ReturnCodes are the same + if (l_rc != l_rc2) + { + FAPI_ERR("rcTest11. ReturnCodes differ"); + l_result = 1; + } + else + { + // Ensure that releasePlatData retrieves the PlatData from l_rc + void * l_pMyDataCheck = l_rc.releasePlatData(); + + if (l_pMyDataCheck != l_pMyData) + { + FAPI_ERR("rcTest11. releasePlatData returned unexpected data ptr"); + l_result = 2; + } + else + { + // Ensure that releasePlatData retrieves NULL from l_rc2 + l_pMyDataCheck = NULL; + l_pMyDataCheck = l_rc2.releasePlatData(); + + if (l_pMyDataCheck != NULL) + { + FAPI_ERR("rcTest11. releasePlatData returned non NULL ptr"); + l_result = 3; + } + } + } + + return l_result; +} + +//****************************************************************************** +// rcTest11. Ensures that the getHwpFfdc functions works when there is no FFDC +//****************************************************************************** +uint32_t rcTest11() +{ + uint32_t l_result = 0; + + // Create a ReturnCode + uint32_t l_code = 6; + ReturnCode l_rc(l_code); + + // Ensure that the getHwpFfdc function returns NULL + const void * l_pFfdc = reinterpret_cast<const void *> (0x12345678); + + // Get FFDC pointer + uint32_t l_size = 0; + l_pFfdc = l_rc.getHwpFfdc(l_size); + + if (l_pFfdc != NULL) + { + FAPI_ERR("rcTest11. getHwpFfdc did not return NULL"); + l_result = 1; + } + + return l_result; +} + +//****************************************************************************** +// rcTest12. Ensures that the getHwpFfdc function works when there is FFDC +//****************************************************************************** +uint32_t rcTest12() +{ + uint32_t l_result = 0; + uint32_t l_code = 10; + + // Create a ReturnCode + ReturnCode l_rc(l_code); + + // Add HwpFfdc. + uint32_t l_myData[2] = {4, 5}; + void * l_pMyData = reinterpret_cast<void *> (l_myData); + (void) l_rc.setHwpFfdc(l_pMyData, sizeof(l_myData)); + + // Ensure that getHwpFfdc returns a pointer to the same data + uint32_t l_size = 0; + const uint32_t * l_pMyDataCheck = reinterpret_cast<const uint32_t *> + (l_rc.getHwpFfdc(l_size)); + + if (l_size != sizeof(l_myData)) + { + FAPI_ERR("rcTest12. getHwpFfdc returned bad size %d", l_size); + l_result = 1; + } + else if ((l_pMyDataCheck[0] != 4) || (l_pMyDataCheck[1] != 5)) + { + FAPI_ERR("rcTest12. getHwpFfdc returned bad data"); + l_result = 2; + } + + return l_result; +} + +//****************************************************************************** +// rcTest13. Ensures that the copy constructor works when there is FFDC and that +// the getHwpFfdc function works +//****************************************************************************** +uint32_t rcTest13() +{ + uint32_t l_result = 0; + uint32_t l_code = 10; + + // Create a ReturnCode + ReturnCode l_rc(l_code); + + // Add HwpFfdc. + uint32_t l_myData[2] = {4, 5}; + void * l_pMyData = reinterpret_cast<void *> (l_myData); + (void) l_rc.setHwpFfdc(l_pMyData, sizeof(l_myData)); + + // Create a ReturnCode using the copy constructor + ReturnCode l_rc2(l_rc); + + // Ensure that the two ReturnCodes are the same + if (l_rc != l_rc2) + { + FAPI_ERR("rcTest13. ReturnCodes differ"); + l_result = 1; + } + else + { + // Ensure that getHwpFfdc returns a pointer to the same data from l_rc + uint32_t l_size = 0; + const uint32_t * l_pMyDataCheck = reinterpret_cast<const uint32_t *> + (l_rc.getHwpFfdc(l_size)); + + if (l_size != sizeof(l_myData)) + { + FAPI_ERR("rcTest13. getHwpFfdc returned bad size %d", l_size); + l_result = 2; + } + else if ((l_pMyDataCheck[0] != 4) || (l_pMyDataCheck[1] != 5)) + { + FAPI_ERR("rcTest13. getHwpFfdc returned bad data"); + l_result = 3; + } + else + { + // Ensure that getHwpFfdc returns a pointer to the same data from + // l_rc2 + uint32_t l_size2 = 0; + const uint32_t * l_pMyDataCheck2 = reinterpret_cast<const uint32_t *> + (l_rc2.getHwpFfdc(l_size2)); + + if (l_size2 != sizeof(l_myData)) + { + FAPI_ERR("rcTest13. getHwpFfdc(2) returned bad size %d", + l_size2); + l_result = 4; + } + else if ((l_pMyDataCheck2[0] != 4) || (l_pMyDataCheck2[1] != 5)) + { + FAPI_ERR("rcTest13. getHwpFfdc(2) returned bad data"); + l_result = 5; + } + } + } + + return l_result; +} + +//****************************************************************************** +// rcTest14. Ensures that the assignment operator works when there is FFDC and +// that the getHwpFfdc function works +//****************************************************************************** +uint32_t rcTest14() +{ + uint32_t l_result = 0; + uint32_t l_code = 10; + + // Create a ReturnCode + ReturnCode l_rc(l_code); + + // Add HwpFfdc. + uint32_t l_myData[2] = {4, 5}; + void * l_pMyData = reinterpret_cast<void *> (l_myData); + (void) l_rc.setHwpFfdc(l_pMyData, sizeof(l_myData)); + + // Create a ReturnCode using the assignment operator + ReturnCode l_rc2; + l_rc2 = l_rc; + + // Ensure that the two ReturnCodes are the same + if (l_rc != l_rc2) + { + FAPI_ERR("rcTest14. ReturnCodes differ"); + l_result = 1; + } + else + { + // Ensure that getHwpFfdc returns a pointer to the same data from l_rc + uint32_t l_size = 0; + const uint32_t * l_pMyDataCheck = reinterpret_cast<const uint32_t *> + (l_rc.getHwpFfdc(l_size)); + + if (l_size != sizeof(l_myData)) + { + FAPI_ERR("rcTest14. getHwpFfdc returned bad size %d", l_size); + l_result = 2; + } + else if ((l_pMyDataCheck[0] != 4) || (l_pMyDataCheck[1] != 5)) + { + FAPI_ERR("rcTest14. getHwpFfdc returned bad data"); + l_result = 3; + } + else + { + // Ensure that getHwpFfdc returns a pointer to the same data from + // l_rc2 + uint32_t l_size2 = 0; + const uint32_t * l_pMyDataCheck2 = reinterpret_cast<const uint32_t *> + (l_rc2.getHwpFfdc(l_size2)); + + if (l_size2 != sizeof(l_myData)) + { + FAPI_ERR("rcTest14. getHwpFfdc(2) returned bad size %d", + l_size2); + l_result = 4; + } + else if ((l_pMyDataCheck2[0] != 4) || (l_pMyDataCheck2[1] != 5)) + { + FAPI_ERR("rcTest14. getHwpFfdc(2) returned bad data"); + l_result = 5; + } + } + } + + return l_result; +} + +//****************************************************************************** +// rcTest15. Ensures that the setErrTarget function works when there is no error +//****************************************************************************** +uint32_t rcTest15() +{ + uint32_t l_result = 0; + + // Create a ReturnCode + ReturnCode l_rc; + + // Create a Target + uint8_t l_handle = 7; + void * l_pHandle = reinterpret_cast<void *>(&l_handle); + Target l_target(TARGET_TYPE_DIMM, l_pHandle); + + // Set the error target + l_rc.setErrTarget(l_target); + + // Retreive the Error target (should be null because no error) + Target * l_pTarget = l_rc.getErrTarget(); + + if (l_pTarget != NULL) + { + FAPI_ERR("rcTest15. getErrTarget returned non-null pointer"); + l_result = 1; + } + + // Set the handle pointer to NULL to prevent any problem on destruction + l_target.set(NULL); + + return l_result; +} + +//****************************************************************************** +// rcTest16. Ensures that the setErrTarget function works when there is an error +//****************************************************************************** +uint32_t rcTest16() +{ + uint32_t l_result = 0; + + // Create a ReturnCode with an error + ReturnCode l_rc(8); + + // Create a Target + uint8_t l_handle = 7; + void * l_pHandle = reinterpret_cast<void *>(&l_handle); + Target l_target(TARGET_TYPE_DIMM, l_pHandle); + + // Set the error target + l_rc.setErrTarget(l_target); + + // Retreive the Error target + Target * l_pTarget = l_rc.getErrTarget(); + + if (*l_pTarget != l_target) + { + FAPI_ERR("rcTest16. getErrTarget returned bad target"); + l_result = 1; + } + + // Set the handle pointer to NULL to prevent any problem on destruction + l_target.set(NULL); + + return l_result; +} + +//****************************************************************************** +// rcTest17. Ensures that the setErrTarget function works when there is an error +// and an existing Target +//****************************************************************************** +uint32_t rcTest17() +{ + uint32_t l_result = 0; + + // Create a ReturnCode with an error + ReturnCode l_rc(8); + + // Create a Target + uint8_t l_handle = 7; + void * l_pHandle = reinterpret_cast<void *>(&l_handle); + Target l_target(TARGET_TYPE_DIMM, l_pHandle); + + // Create another Target + uint8_t l_handle2 = 8; + void * l_pHandle2 = reinterpret_cast<void *>(&l_handle2); + Target l_target2(TARGET_TYPE_DIMM, l_pHandle2); + + // Set the error target + l_rc.setErrTarget(l_target); + + // Attempt to set the error target again (should not be set because there is + // already an error target) + l_rc.setErrTarget(l_target2); + + // Retreive the Error target + Target * l_pTarget = l_rc.getErrTarget(); + + if (*l_pTarget != l_target) + { + FAPI_ERR("rcTest17. getErrTarget returned bad target"); + l_result = 1; + } + + // Set the handle pointer to NULL to prevent any problem on destruction + l_target.set(NULL); + + return l_result; +} + +} diff --git a/src/usr/hwpf/test/fapiTargetTest.C b/src/usr/hwpf/test/fapiTargetTest.C new file mode 100644 index 000000000..634a42222 --- /dev/null +++ b/src/usr/hwpf/test/fapiTargetTest.C @@ -0,0 +1,295 @@ +/** + * @file fapitargetTest.C + * + * @brief Implements Target class unit test functions. + */ + +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 04/13/2011 Created. + * + */ + +#include <fapi.H> + +namespace fapi +{ + +//****************************************************************************** +// targetTest1 +//****************************************************************************** +uint32_t targetTest1() +{ + uint32_t l_result = 0; + + // Create Target using default constructor + Target l_target; + + // Ensure that the handle pointer is NULL + void * l_pHandle = l_target.get(); + + if (l_pHandle != NULL) + { + FAPI_ERR("targetTest1. Handle is not NULL"); + l_result = 1; + } + else + { + // Ensure that the type is TARGET_TYPE_NONE + TargetType l_type = l_target.getType(); + + if (l_type != TARGET_TYPE_NONE) + { + FAPI_ERR("targetTest1. Type is 0x%x, expected NONE", l_type); + l_result = 2; + } + } + + return l_result; +} + +//****************************************************************************** +// targetTest2 +//****************************************************************************** +uint32_t targetTest2() +{ + uint32_t l_result = 0; + uint8_t l_handle = 7; + void * l_pHandle = reinterpret_cast<void *>(&l_handle); + + // Create Target + Target l_target(TARGET_TYPE_DIMM, l_pHandle); + + // Ensure that the handle pointer is as expected + void * l_pHandleCheck = l_target.get(); + + if (l_pHandleCheck != l_pHandle) + { + FAPI_ERR("targetTest2. Handle is not as expected"); + l_result = 1; + } + else + { + // Ensure that the type is TARGET_TYPE_DIMM + TargetType l_type = l_target.getType(); + + if (l_type != TARGET_TYPE_DIMM) + { + FAPI_ERR("targetTest2. Type is 0x%x, expected DIMM", l_type); + l_result = 2; + } + } + + // Set the handle pointer to NULL to prevent any problem on destruction + l_target.set(NULL); + + return l_result; +} + +//****************************************************************************** +// targetTest3 +//****************************************************************************** +uint32_t targetTest3() +{ + uint32_t l_result = 0; + + // Create Target using default constructor + Target l_target; + + // Set the handle + uint8_t l_handle = 7; + void * l_pHandle = reinterpret_cast<void *>(&l_handle); + l_target.set(l_pHandle); + + // Ensure that the handle pointer is as expected + void * l_pHandleCheck = l_target.get(); + + if (l_pHandleCheck != l_pHandle) + { + FAPI_ERR("targetTest3. Handle is not as expected"); + l_result = 1; + } + else + { + // Set the type + l_target.setType(TARGET_TYPE_DIMM); + + // Ensure that the type is TARGET_TYPE_DIMM + TargetType l_type = l_target.getType(); + + if (l_type != TARGET_TYPE_DIMM) + { + FAPI_ERR("targetTest3. Type is 0x%x, expected DIMM", l_type); + l_result = 2; + } + } + + return l_result; +} + +//****************************************************************************** +// targetTest4 +//****************************************************************************** +uint32_t targetTest4() +{ + uint32_t l_result = 0; + + // Create Target + uint8_t l_handle = 7; + void * l_pHandle = reinterpret_cast<void *>(&l_handle); + Target l_target(TARGET_TYPE_DIMM, l_pHandle); + + // Create Target using copy constructor + Target l_target2(l_target); + + // Ensure that the target types are the same + TargetType l_type = l_target.getType(); + TargetType l_type2 = l_target2.getType(); + + if (l_type != l_type2) + { + FAPI_ERR("targetTest4. Types are not the same (0x%x, 0x%x)", l_type, + l_type2); + l_result = 1; + } + else + { + // Ensure that the handles are the same + void * l_han1 = l_target.get(); + void * l_han2 = l_target2.get(); + + if (l_han1 != l_han2) + { + FAPI_ERR("targetTest4. Handles are not the same"); + l_result = 2; + } + } + + return l_result; +} + +//****************************************************************************** +// targetTest5 +//****************************************************************************** +uint32_t targetTest5() +{ + uint32_t l_result = 0; + + // Create Target + uint8_t l_handle = 7; + void * l_pHandle = reinterpret_cast<void *>(&l_handle); + Target l_target(TARGET_TYPE_DIMM, l_pHandle); + + // Create Target using assignment operator + Target l_target2; + l_target2 = l_target; + + // Ensure that the target types are the same + TargetType l_type = l_target.getType(); + TargetType l_type2 = l_target2.getType(); + + if (l_type != l_type2) + { + FAPI_ERR("targetTest5. Types are not the same (0x%x, 0x%x)", l_type, + l_type2); + l_result = 1; + } + else + { + // Ensure that the handles are the same + void * l_han1 = l_target.get(); + void * l_han2 = l_target2.get(); + + if (l_han1 != l_han2) + { + FAPI_ERR("targetTest5. Handles are not the same"); + l_result = 2; + } + } + + return l_result; +} + +//****************************************************************************** +// targetTest6 +//****************************************************************************** +uint32_t targetTest6() +{ + uint32_t l_result = 0; + + // Create similar Targets + uint8_t l_handle = 7; + void * l_pHandle = reinterpret_cast<void *>(&l_handle); + Target l_target(TARGET_TYPE_DIMM, l_pHandle); + Target l_target2(TARGET_TYPE_DIMM, l_pHandle); + + // Ensure that the equality comparison returns true + if (!(l_target == l_target2)) + { + FAPI_ERR("targetTest6. 1. Equality comparison false"); + l_result = 1; + } + else + { + // Ensure that the inequality comparison returns false + if (l_target != l_target2) + { + FAPI_ERR("targetTest6. 2. Inequality comparison true"); + l_result = 2; + } + else + { + // Change the target type of l_target2 + (void)l_target2.setType(TARGET_TYPE_PROC_CHIP); + + // Ensure that the equality comparison returns false + if (l_target == l_target2) + { + FAPI_ERR("targetTest6. 3. Equality comparison true"); + l_result = 3; + } + else + { + // Ensure that the inequality comparison returns true + if (!(l_target != l_target2)) + { + FAPI_ERR("targetTest6. 4. Inequality comparison false"); + l_result = 4; + } + else + { + // Reset the target type of l_target2 + (void)l_target2.setType(TARGET_TYPE_DIMM); + + // Change the handle of l_target + uint8_t l_handle2 = 7; + void * l_pHandle2 = reinterpret_cast<void *>(&l_handle2); + (void)l_target.set(l_pHandle2); + + // Ensure that the equality comparison returns false + if (l_target == l_target2) + { + FAPI_ERR("targetTest6. 5. Equality comparison true"); + l_result = 5; + } + else + { + // Ensure that the inequality comparison returns true + if (!(l_target != l_target2)) + { + FAPI_ERR("targetTest6. 6. Inequality comparison " + "false"); + l_result = 6; + } + } + } + } + } + } + + return l_result; +} + +} diff --git a/src/usr/hwpf/test/fapirctest.H b/src/usr/hwpf/test/fapirctest.H index 140882483..8f9c3a502 100644 --- a/src/usr/hwpf/test/fapirctest.H +++ b/src/usr/hwpf/test/fapirctest.H @@ -9,6 +9,7 @@ #include <cxxtest/TestSuite.H> #include <fapi.H> +#include "fapiRcTest.C" using namespace fapi; @@ -21,31 +22,12 @@ public: */ void testRc1(void) { - // Create ReturnCode using default constructor - ReturnCode l_rc; + uint32_t l_res = rcTest1(); - // Ensure that the embedded return code is success - if (l_rc != FAPI_RC_SUCCESS) + if (l_res != 0) { - TS_FAIL("testRc1. ReturnCode init is not FAPI_RC_SUCCESS"); + TS_FAIL("testRc1. Fail"); } - else - { - // Ensure that OK function works - if (l_rc.ok() == false) - { - TS_FAIL("testRc1. ok() returned false"); - } - else - { - // Ensure that testing l_rc works - if (l_rc) - { - TS_FAIL("testRc1. testing rc returned true"); - } - } - } - return; } @@ -54,47 +36,12 @@ public: */ void testRc2() { + uint32_t l_res = rcTest2(); - // Create ReturnCode using default constructor - ReturnCode l_rc; - - // Set the return code to a FAPI code - l_rc = FAPI_RC_FAPI_MASK | 0x05; - - // Ensure that the creator is FAPI - ReturnCode::returnCodeCreator l_creator = l_rc.getCreator(); - - if (l_creator != ReturnCode::CREATOR_FAPI) + if (l_res != 0) { - TS_FAIL("testRc2. Creator is not CREATOR_FAPI"); + TS_FAIL("testRc2. Fail"); } - else - { - // Set the return code to a PLAT code - l_rc = FAPI_RC_PLAT_ERR_SEE_DATA; - - // Ensure that the creator is PLAT - l_creator = l_rc.getCreator(); - - if (l_creator != ReturnCode::CREATOR_PLAT) - { - TS_FAIL("testRc2. Creator is not CREATOR_PLAT"); - } - else - { - l_rc = 5; - - // Ensure that the creator is HWP - l_creator = l_rc.getCreator(); - - if (l_creator != ReturnCode::CREATOR_HWP) - { - TS_FAIL("testRc2. Creator is not CREATOR_HWP"); - } - } - } - - return; } /** @@ -102,35 +49,12 @@ public: */ void testRc3() { - uint32_t l_code = 4; + uint32_t l_res = rcTest3(); - // Create ReturnCode specifying a return code - ReturnCode l_rc(l_code); - - // Ensure that the embedded return code is as expected - uint32_t l_codeCheck = l_rc; - - if (l_codeCheck != l_code) + if (l_res != 0) { - TS_FAIL("testRc3. Code is not set as desired"); + TS_FAIL("testRc3. Fail"); } - else - { - // Ensure that ok function returns false - if (l_rc.ok()) - { - TS_FAIL("testRc3. ok returned true"); - } - else - { - // Ensure that testing l_rc works - if (!l_rc) - { - TS_FAIL("testRc3. testing rc returned false"); - } - } - } - return; } @@ -139,46 +63,12 @@ public: */ void testRc4() { - uint32_t l_code = 6; - uint32_t l_code2 = 7; - - // Create similar ReturnCodes - ReturnCode l_rc(l_code); - ReturnCode l_rc2(l_code); + uint32_t l_res = rcTest4(); - // Ensure that the equality comparison returns true - if (!(l_rc == l_rc2)) + if (l_res != 0) { - TS_FAIL("testRc4. Equality comparison false"); + TS_FAIL("testRc4. Fail"); } - else - { - // Ensure that the inequality comparison returns false - if (l_rc != l_rc2) - { - TS_FAIL("testRc4.Inequality comparison true"); - } - else - { - // Change the code of l_rc2 - l_rc2 = l_code2; - - // Ensure that the equality comparison returns false - if (l_rc == l_rc2) - { - TS_FAIL("testRc4. Equality comparison true"); - } - else - { - // Ensure that the inequality comparison returns true - if (!(l_rc != l_rc2)) - { - TS_FAIL("testRc4. Inequality comparison false"); - } - } - } - } - return; } @@ -187,46 +77,12 @@ public: */ void testRc5() { - uint32_t l_code = 6; - uint32_t l_code2 = 7; + uint32_t l_res = rcTest5(); - // Create a ReturnCode - ReturnCode l_rc(l_code); - - // Ensure that the equality comparison returns true when comparing to the - // same return code value - if (!(l_rc == l_code)) - { - TS_FAIL("testRc5. 1. Equality comparison false"); - } - else + if (l_res != 0) { - // Ensure that the inequality comparison returns false when comparing to - // the same return code value - if (l_rc != l_code) - { - TS_FAIL("testRc5. 2. Inequality comparison true"); - } - else - { - // Ensure that the equality comparison returns false when comparing - // to a different return code value - if (l_rc == l_code2) - { - TS_FAIL("testRc5. 3. Equality comparison true"); - } - else - { - // Ensure that the inequality comparison returns true when - // comparing to a different return code value - if (!(l_rc != l_code2)) - { - TS_FAIL("testRc5. 4. Inequality comparison false"); - } - } - } + TS_FAIL("testRc5. Fail"); } - return; } @@ -235,32 +91,12 @@ public: */ void testRc6() { - uint32_t l_code = 6; - - // Create a ReturnCode - ReturnCode l_rc(l_code); - - // Ensure that the getData function returns NULL - void * l_pData = reinterpret_cast<void *> (0x12345678); + uint32_t l_res = rcTest6(); - l_pData = l_rc.getData(); - if (l_pData != NULL) + if (l_res != 0) { - TS_FAIL("testRc6. getData did not return NULL"); + TS_FAIL("testRc6. Fail"); } - else - { - // Ensure that the releaseData function returns NULL - l_pData = reinterpret_cast<void *> (0x12345678); - - l_pData = l_rc.releaseData(); - - if (l_pData != NULL) - { - TS_FAIL("testRc6. releaseData did not return NULL"); - } - } - return; } @@ -269,41 +105,12 @@ public: */ void testRc7() { - uint32_t l_code = 10; - - // Create a ReturnCode - ReturnCode l_rc(l_code); + uint32_t l_res = rcTest7(); - // Assign ReturnCodeData. Note that this should really be an errlHndl_t, - // because the FSP deleteData function will attempt to delete an error - // log, but this is just for test, the data will be released before the - // ReturnCode is destructed. - uint32_t l_myData = 6; - void * l_pMyData = reinterpret_cast<void *> (&l_myData); - (void) l_rc.setData(l_pMyData); - - // Ensure that getData retrieves the ReturnCodeData - void * l_pMyDataCheck = l_rc.getData(); - - if (l_pMyDataCheck != l_pMyData) - { - TS_FAIL("testRc7. getData returned unexpected data ptr"); - } - else + if (l_res != 0) { - // Ensure that getData retrieves the ReturnCodeData again - l_pMyDataCheck = NULL; - l_pMyDataCheck = l_rc.getData(); - - if (l_pMyDataCheck != l_pMyData) - { - TS_FAIL("testRc7. getData returned unexpected data ptr"); - } + TS_FAIL("testRc7. Fail"); } - - // Release the data to avoid ReturnCode from deleting in on destruction - l_pMyDataCheck = l_rc.releaseData(); - return; } @@ -312,150 +119,138 @@ public: */ void testRc8() { - uint32_t l_code = 10; + uint32_t l_res = rcTest8(); - // Create a ReturnCode - ReturnCode l_rc(l_code); - - // Assign ReturnCodeData. Note that this should really be an errlHndl_t, - // because the FSP deleteData function will attempt to delete an error - // log, but this is just for test, the data will be released before the - // ReturnCode is destructed. - uint32_t l_myData = 6; - void * l_pMyData = reinterpret_cast<void *> (&l_myData); - (void) l_rc.setData(l_pMyData); + if (l_res != 0) + { + TS_FAIL("testRc8. Fail"); + } + } - // Ensure that releaseData retrieves the ReturnCodeData - void * l_pMyDataCheck = l_rc.releaseData(); + /** + * @brief Test FAPI return codes #9 + */ + void testRc9() + { + uint32_t l_res = rcTest9(); - if (l_pMyDataCheck != l_pMyData) + if (l_res != 0) { - TS_FAIL("testRc8. getData returned unexpected data ptr"); + TS_FAIL("testRc9. Fail"); } - else + return; + } + + /** + * @brief Test FAPI return codes #10 + */ + void testRc10() + { + uint32_t l_res = rcTest10(); + + if (l_res != 0) { - // Ensure that releaseData now returns NULL - l_pMyDataCheck = NULL; - l_pMyDataCheck = l_rc.releaseData(); - - if (l_pMyDataCheck != NULL) - { - TS_FAIL("testRc8. getData returned non NULL ptr"); - } + TS_FAIL("testRc10. Fail"); } - return; } /** - * @brief Test FAPI return codes #9 + * @brief Test FAPI return codes #11 */ - void testRc9() + void testRc11(void) { - uint32_t l_code = 10; + uint32_t l_res = rcTest11(); - // Create a ReturnCode - ReturnCode l_rc(l_code); + if (l_res != 0) + { + TS_FAIL("testRc11. Fail"); + } + } - // Assign ReturnCodeData. Note that this should really be an errlHndl_t, - // because the FSP deleteData function will attempt to delete an error - // log, but this is just for test, the data will be released before the - // ReturnCode is destructed. - uint32_t l_myData = 6; - void * l_pMyData = reinterpret_cast<void *> (&l_myData); - (void) l_rc.setData(l_pMyData); - // Create a ReturnCode using the copy constructor - ReturnCode l_rc2(l_rc); + /** + * @brief Test FAPI return codes #12 + */ + void testRc12() + { + uint32_t l_res = rcTest12(); - // Ensure that the two ReturnCodes are the same - if (l_rc != l_rc2) - { - TS_FAIL("testRc9. ReturnCodes differ"); - } - else + if (l_res != 0) { - // Ensure that getData retrieves the ReturnCodeData from l_rc - void * l_pMyDataCheck = l_rc.getData(); - - if (l_pMyDataCheck != l_pMyData) - { - TS_FAIL("testRc9. getData returned unexpected data ptr (1)"); - } - else - { - // Ensure that getData retrieves the ReturnCodeData from l_rc2 - l_pMyDataCheck = NULL; - l_pMyDataCheck = l_rc2.getData(); - - if (l_pMyDataCheck != l_pMyData) - { - TS_FAIL("testRc9. getData returned unexpected data ptr (2)"); - } - } + TS_FAIL("testRc12. Fail"); } + } - // Release the data to avoid ReturnCode from deleting in on destruction. - // This will release the data from both copies of the ReturnCode. - (void) l_rc.releaseData(); + /** + * @brief Test FAPI return codes #13 + */ + void testRc13() + { + uint32_t l_res = rcTest13(); + if (l_res != 0) + { + TS_FAIL("testRc13. Fail"); + } return; } /** - * @brief Test FAPI return codes #10 + * @brief Test FAPI return codes #14 */ - void testRc10() + void testRc14() { - uint32_t l_code = 10; + uint32_t l_res = rcTest14(); - // Create a ReturnCode - ReturnCode l_rc(l_code); - - // Assign ReturnCodeData. Note that this should really be an errlHndl_t, - // because the FSP deleteData function will attempt to delete an error - // log, but this is just for test, the data will be released before the - // ReturnCode is destructed. - uint32_t l_myData = 6; - void * l_pMyData = reinterpret_cast<void *> (&l_myData); - (void) l_rc.setData(l_pMyData); + if (l_res != 0) + { + TS_FAIL("testRc14. Fail"); + } + return; + } - // Create a ReturnCode using the assignment operator - ReturnCode l_rc2; - l_rc2 = l_rc; + /** + * @brief Test FAPI return codes #15 + */ + void testRc15() + { + uint32_t l_res = rcTest15(); - // Ensure that the two ReturnCodes are the same - if (l_rc != l_rc2) + if (l_res != 0) { - TS_FAIL("testRc10. ReturnCodes differ"); + TS_FAIL("testRc15. Fail"); } - else + return; + } + + /** + * @brief Test FAPI return codes #16 + */ + void testRc16() + { + uint32_t l_res = rcTest16(); + + if (l_res != 0) { - // Ensure that releaseData retrieves the ReturnCodeData from l_rc - void * l_pMyDataCheck = l_rc.releaseData(); - - if (l_pMyDataCheck != l_pMyData) - { - TS_FAIL("testRc10. releaseData returned unexpected data ptr"); - } - else - { - // Ensure that releaseData retrieves NULL from l_rc2 - l_pMyDataCheck = NULL; - l_pMyDataCheck = l_rc2.releaseData(); - - if (l_pMyDataCheck != NULL) - { - TS_FAIL("testRc10. releaseData returned non NULL ptr"); - } - } + TS_FAIL("testRc16. Fail"); } - return; } + /** + * @brief Test FAPI return codes #17 + */ + void testRc17() + { + uint32_t l_res = rcTest17(); - + if (l_res != 0) + { + TS_FAIL("testRc17. Fail"); + } + return; + } }; #endif diff --git a/src/usr/hwpf/test/fapitargettest.H b/src/usr/hwpf/test/fapitargettest.H index 6cd8fd9b8..74f68bfc6 100644 --- a/src/usr/hwpf/test/fapitargettest.H +++ b/src/usr/hwpf/test/fapitargettest.H @@ -9,6 +9,7 @@ #include <cxxtest/TestSuite.H> #include <fapi.H> +#include "fapiTargetTest.C" using namespace fapi; @@ -21,27 +22,12 @@ public: */ void testTarget1() { - // Create Target using default constructor - Target l_target; + uint32_t l_res = targetTest1(); - // Ensure that the handle pointer is NULL - void * l_pHandle = l_target.get(); - - if (l_pHandle != NULL) - { - TS_FAIL("testTarget1. Handle is not NULL"); - } - else + if (l_res != 0) { - // Ensure that the type is TARGET_TYPE_NONE - TargetType l_type = l_target.getType(); - if (l_type != TARGET_TYPE_NONE) - { - TS_FAIL("testTarget1. Type is not TARGET_TYPE_NONE"); - } + TS_FAIL("testTarget1. Fail"); } - - return; } /** @@ -49,34 +35,12 @@ public: */ void testTarget2() { - uint8_t l_handle = 7; - void * l_pHandle = reinterpret_cast<void *>(&l_handle); - - // Create Target - Target l_target(TARGET_TYPE_DIMM, l_pHandle); + uint32_t l_res = targetTest2(); - // Ensure that the handle pointer is as expected - void * l_pHandleCheck = l_target.get(); - - if (l_pHandleCheck != l_pHandle) + if (l_res != 0) { - TS_FAIL("testTarget2. Handle is not as expected"); + TS_FAIL("testTarget2. Fail"); } - else - { - // Ensure that the type is TARGET_TYPE_DIMM - TargetType l_type = l_target.getType(); - - if (l_type != TARGET_TYPE_DIMM) - { - TS_FAIL("testTarget2. Type is not TARGET_TYPE_DIMM"); - } - } - - // Set the handle pointer to NULL to prevent any problem on destruction - l_target.set(NULL); - - return; } /** @@ -84,36 +48,12 @@ public: */ void testTarget3() { - // Create Target using default constructor - Target l_target; - - // Set the handle - uint8_t l_handle = 7; - void * l_pHandle = reinterpret_cast<void *>(&l_handle); - l_target.set(l_pHandle); - - // Ensure that the handle pointer is as expected - void * l_pHandleCheck = l_target.get(); + uint32_t l_res = targetTest3(); - if (l_pHandleCheck != l_pHandle) + if (l_res != 0) { - TS_FAIL("testTarget3. Handle is not as expected"); + TS_FAIL("testTarget3. Fail"); } - else - { - // Set the type - l_target.setType(TARGET_TYPE_DIMM); - - // Ensure that the type is TARGET_TYPE_DIMM - TargetType l_type = l_target.getType(); - - if (l_type != TARGET_TYPE_DIMM) - { - TS_FAIL("testTarget3. Type is not TARGET_TYPE_DIMM"); - } - } - - return; } /** @@ -121,35 +61,12 @@ public: */ void testTarget4() { - // Create Target - uint8_t l_handle = 7; - void * l_pHandle = reinterpret_cast<void *>(&l_handle); - Target l_target(TARGET_TYPE_DIMM, l_pHandle); - - // Create Target using copy constructor - Target l_target2(l_target); + uint32_t l_res = targetTest4(); - // Ensure that the target types are the same - TargetType l_type = l_target.getType(); - TargetType l_type2 = l_target2.getType(); - - if (l_type != l_type2) + if (l_res != 0) { - TS_FAIL("testTarget4. Types are not the same "); + TS_FAIL("testTarget4. Fail"); } - else - { - // Ensure that the handles are the same - void * l_han1 = l_target.get(); - void * l_han2 = l_target2.get(); - - if (l_han1 != l_han2) - { - TS_FAIL("testTarget4. Handles are not the same"); - } - } - - return; } /** @@ -157,36 +74,12 @@ public: */ void testTarget5() { - // Create Target - uint8_t l_handle = 7; - void * l_pHandle = reinterpret_cast<void *>(&l_handle); - Target l_target(TARGET_TYPE_DIMM, l_pHandle); + uint32_t l_res = targetTest5(); - // Create Target using assignment operator - Target l_target2; - l_target2 = l_target; - - // Ensure that the target types are the same - TargetType l_type = l_target.getType(); - TargetType l_type2 = l_target2.getType(); - - if (l_type != l_type2) - { - TS_FAIL("testTarget5. Types are not the same"); - } - else + if (l_res != 0) { - // Ensure that the handles are the same - void * l_han1 = l_target.get(); - void * l_han2 = l_target2.get(); - - if (l_han1 != l_han2) - { - TS_FAIL("testTarget5. Handles are not the same"); - } + TS_FAIL("testTarget5. Fail"); } - - return; } /** @@ -194,73 +87,13 @@ public: */ void testTarget6() { - // Create similar Targets - uint8_t l_handle = 7; - void * l_pHandle = reinterpret_cast<void *>(&l_handle); - Target l_target(TARGET_TYPE_DIMM, l_pHandle); - Target l_target2(TARGET_TYPE_DIMM, l_pHandle); + uint32_t l_res = targetTest6(); - // Ensure that the equality comparison returns true - if (!(l_target == l_target2)) + if (l_res != 0) { - TS_FAIL("testTarget6. 1. Equality comparison false"); + TS_FAIL("testTarget6. Fail"); } - else - { - // Ensure that the inequality comparison returns false - if (l_target != l_target2) - { - TS_FAIL("testTarget6. 2. Inequality comparison true"); - } - else - { - // Change the target type of l_target2 - (void)l_target2.setType(TARGET_TYPE_PROC_CHIP); - - // Ensure that the equality comparison returns false - if (l_target == l_target2) - { - TS_FAIL("testTarget6. 3. Equality comparison true"); - } - else - { - // Ensure that the inequality comparison returns true - if (!(l_target != l_target2)) - { - TS_FAIL("testTarget6. 4. Inequality comparison false"); - } - else - { - // Reset the target type of l_target2 - (void)l_target2.setType(TARGET_TYPE_DIMM); - - // Change the handle of l_target - uint8_t l_handle2 = 7; - void * l_pHandle2 = reinterpret_cast<void *>(&l_handle2); - (void)l_target.set(l_pHandle2); - - // Ensure that the equality comparison returns false - if (l_target == l_target2) - { - TS_FAIL("testTarget6. 5. Equality comparison true"); - } - else - { - // Ensure that the inequality comparison returns true - if (!(l_target != l_target2)) - { - TS_FAIL("testTarget6. 6. Inequality comparison " - "false"); - } - } - } - } - } - } - - return; } - }; #endif diff --git a/src/usr/hwpf/test/hwpftest.H b/src/usr/hwpf/test/hwpftest.H index 2bfd6734d..a4a1a12da 100644 --- a/src/usr/hwpf/test/hwpftest.H +++ b/src/usr/hwpf/test/hwpftest.H @@ -55,7 +55,7 @@ public: /** - * @brief Test HWPF: calling a procedure + * @brief Test HWPF: call a test procedure */ void testHwpf2() { @@ -65,43 +65,44 @@ public: // Set processor chip to the master TARGETING::Target* l_testTarget = MASTER_PROCESSOR_CHIP_TARGET_SENTINEL; - // Call the hardware procedure - bool l_clocksOn = false; - l_err = invokeHwpIsP7EM0ChipletClockOn(l_testTarget, l_clocksOn); + // Call the test hardware procedure + l_err = invokeHwpInitialTest(l_testTarget); if (l_err) { - TS_FAIL("testHwpf2: Unit Test failed. invokeHwpIsP7EM0ChipletClockOn failed. Error logged"); + TS_FAIL("testHwpf2: Unit Test failed. invokeHwpInitialTest failed. Error logged"); // Commit/delete error errlCommit(l_err); } else { - if (l_clocksOn) - { - TS_TRACE("testHwpf2: Success. Clocks are on"); - } - else - { - TS_TRACE("testHwpf2: Success. Clocks are off"); - } + TS_TRACE("testHwpf2: Unit test passed! invokeHwpInitialTest"); } + } - // Call test procedure too - l_err = invokeHwpInitialTest(l_testTarget); + /** + * @brief Test HWPF: call a test procedure that generates an error + */ + void testHwpf3() + { + // Call a test hardware procedure + errlHndl_t l_err = NULL; + + // Set processor chip to the master + TARGETING::Target* l_testTarget = MASTER_PROCESSOR_CHIP_TARGET_SENTINEL; + + // Call the procedure that generates an error to test out error handling + l_err = invokeHwpTestError(l_testTarget); if (l_err) { - TS_FAIL("testHwpf2: Unit Test failed. invokeHwpInitialTest failed. Error logged"); + TS_TRACE("testHwpf3: Unit Test passed. invokeHwpTestError failed. Error logged"); // Commit/delete error errlCommit(l_err); } else { - TS_TRACE("testHwpf2: Unit test passed! invokeHwpInitialTest"); + TS_FAIL("testHwpf3: Unit Test failed. invokeHwpTestError passed. Error logged"); } - - return; } - }; #endif diff --git a/src/usr/hwpf/test/makefile b/src/usr/hwpf/test/makefile index c32529276..1a210d08d 100644 --- a/src/usr/hwpf/test/makefile +++ b/src/usr/hwpf/test/makefile @@ -3,6 +3,7 @@ ROOTPATH = ../../../.. 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 MODULE = testhwpf TESTS = *.H diff --git a/src/usr/isteps/makefile b/src/usr/isteps/makefile index f2d7b1560..ac20fbc08 100644 --- a/src/usr/isteps/makefile +++ b/src/usr/isteps/makefile @@ -3,6 +3,7 @@ ROOTPATH = ../../.. 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 MODULE = isteps |