summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCamVan Nguyen <ctnguyen@us.ibm.com>2011-09-06 17:11:53 -0500
committerCAMVAN T. NGUYEN <ctnguyen@us.ibm.com>2011-09-07 19:13:37 -0500
commit1a9fe61084b58fe8e56e92c5983704751b3bf536 (patch)
tree1feebb9c10b84caf412bf1d97b01043dc2a4c0d6 /src
parent6dd3a0514d3754d607be5689bf07a04d3cc8f483 (diff)
downloadtalos-hostboot-1a9fe61084b58fe8e56e92c5983704751b3bf536.tar.gz
talos-hostboot-1a9fe61084b58fe8e56e92c5983704751b3bf536.zip
Added fapiLogError() function.
Added function template for setHwpFfdc(). Change-Id: Iba9aab22aba57556e025a3848fa4565e3eea6265 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/325 Tested-by: Jenkins Server Reviewed-by: MIKE J. JONES <mjjones@us.ibm.com> Reviewed-by: Andrew J. Geissler <andrewg@us.ibm.com>
Diffstat (limited to 'src')
-rw-r--r--src/include/usr/hwpf/fapi/fapiReturnCode.H17
-rw-r--r--src/include/usr/hwpf/fapi/fapiUtil.H24
-rw-r--r--src/usr/hwpf/fapi/fapiReturnCode.C16
-rw-r--r--src/usr/hwpf/hwp/fapiTestHwpError.C38
-rw-r--r--src/usr/hwpf/plat/fapiPlatUtil.C21
5 files changed, 116 insertions, 0 deletions
diff --git a/src/include/usr/hwpf/fapi/fapiReturnCode.H b/src/include/usr/hwpf/fapi/fapiReturnCode.H
index 7f9a6ff32..fb218e560 100644
--- a/src/include/usr/hwpf/fapi/fapiReturnCode.H
+++ b/src/include/usr/hwpf/fapi/fapiReturnCode.H
@@ -34,6 +34,8 @@
* mjjones 07/05/2011 Removed const from data
* mjjones 07/25/2011 Added support for FFDC and
* Error Target
+ * camvanng 09/06/2011 Added function template for
+ * setHwpFfdc
*/
#ifndef FAPIRETURNCODE_H_
@@ -209,6 +211,21 @@ public:
void setHwpFfdc(const void * i_pFfdc, const uint32_t i_size);
/**
+ * @brief Stores a copy of the provided HwpFfdc
+ *
+ * param[in] i_data FFDC data, which can be any type
+ *
+ * Example usage:
+ * uint32_t l_data = 0x12345678;
+ * fapi::ReturnCode l_rc;
+ * l_rc.setHwpFfdc(l_data);
+ */
+ template<class T> void setHwpFfdc(const T & i_data)
+ {
+ setHwpFfdc(&i_data, sizeof(T));
+ }
+
+ /**
* @brief Gets the creator of the return code
*
* @return ReturnCodeCreator
diff --git a/src/include/usr/hwpf/fapi/fapiUtil.H b/src/include/usr/hwpf/fapi/fapiUtil.H
index ad0c7a364..ad1532699 100644
--- a/src/include/usr/hwpf/fapi/fapiUtil.H
+++ b/src/include/usr/hwpf/fapi/fapiUtil.H
@@ -34,6 +34,7 @@
* camvanng 05/31/2011 Removed fapiOutputx macros
* mjjones 06/30/2011 Removed #include
* mjjones 07/05/2011 Removed rogue tab
+ * camvanng 09/06/2011 Added fapiLogError
*
*/
@@ -85,6 +86,29 @@ void fapiAssert(bool i_expression);
fapi::ReturnCode delay( uint64_t i_nanoSeconds, uint64_t i_simCycles );
+/**
+ * @brief Log an error.
+ *
+ * This function can be called by HWP to log an error.
+ *
+ * @note Implemented by platform code
+ *
+ * @param[io] Reference to ReturnCode (Any references to data and error
+ * target are removed and rc value is set to success after
+ * function ends.)
+ *
+ * Example usage:
+ * fapi::ReturnCode l_rc;
+ * FAPI_EXEC_HWP(l_rc, function1, i_target);
+ * if (!l_rc)
+ * {
+ * fapiLogError(l_rc);
+ * }
+ *
+ * FAPI_EXEC_HWP(l_rc, function2, i_target)
+ * return rc;
+ */
+void fapiLogError(ReturnCode & io_rc);
}
diff --git a/src/usr/hwpf/fapi/fapiReturnCode.C b/src/usr/hwpf/fapi/fapiReturnCode.C
index 09fead999..06064704d 100644
--- a/src/usr/hwpf/fapi/fapiReturnCode.C
+++ b/src/usr/hwpf/fapi/fapiReturnCode.C
@@ -34,6 +34,10 @@
* mjjones 07/05/2011. Removed const from data
* mjjones 07/25/2011 Added support for FFDC and
* Error Target
+ * camvanng 09/06/2011 Clear Plat Data, Hwp FFDC data,
+ * and Error Target if
+ * FAPI_RC_SUCCESS is assigned to
+ * ReturnCode
*/
#include <fapiReturnCode.H>
@@ -98,6 +102,7 @@ ReturnCode::~ReturnCode()
(void) removePlatData();
(void) removeHwpFfdc();
delete iv_pErrTarget;
+ iv_pErrTarget = NULL;
}
//******************************************************************************
@@ -112,6 +117,7 @@ ReturnCode & ReturnCode::operator=(const ReturnCode & i_right)
(void) removePlatData();
(void) removeHwpFfdc();
delete iv_pErrTarget;
+ iv_pErrTarget = NULL;
// Copy instance variables. Note shallow copy of data ref pointers. Both
// ReturnCodes now point to the same data
@@ -144,6 +150,16 @@ ReturnCode & ReturnCode::operator=(const ReturnCode & i_right)
ReturnCode & ReturnCode::operator=(const uint32_t i_rcValue)
{
iv_rcValue = i_rcValue;
+
+ if (ok())
+ {
+ // Remove interest in any data references and delete any Error Target
+ (void) removePlatData();
+ (void) removeHwpFfdc();
+ delete iv_pErrTarget;
+ iv_pErrTarget = NULL;
+ }
+
return *this;
}
diff --git a/src/usr/hwpf/hwp/fapiTestHwpError.C b/src/usr/hwpf/hwp/fapiTestHwpError.C
index 6b5c3adaf..d1d7e5e5c 100644
--- a/src/usr/hwpf/hwp/fapiTestHwpError.C
+++ b/src/usr/hwpf/hwp/fapiTestHwpError.C
@@ -31,6 +31,8 @@
* Flag Defect/Feature User Date Description
* ------ -------------- ---------- ----------- ----------------------------
* mjjones 08/08/2011 Created.
+ * camvanng 09/06/2011 Added code to test
+ * fapiLogError
*
*/
@@ -50,6 +52,42 @@ fapi::ReturnCode hwpTestError(const fapi::Target & i_target)
// Add some local FFDC to the ReturnCode
uint32_t l_ffdc = 0x12345678;
+ l_rc.setHwpFfdc(l_ffdc);
+
+ // Log the error
+ fapiLogError(l_rc);
+
+ // Check that the return code is set to success and any data or Error
+ // Target references are cleared
+ if (!l_rc.ok())
+ {
+ FAPI_ERR("Performing HWP: hwpTestError: rc is 0x%x, " \
+ "expected success", static_cast<uint32_t>(l_rc));
+ }
+
+ if (l_rc.getErrTarget() != NULL)
+ {
+ FAPI_ERR("Performing HWP: hwpTestError: getErrTarget " \
+ "returned non-null pointer");
+ }
+
+ if (l_rc.getPlatData() != NULL)
+ {
+ FAPI_ERR("Performing HWP: hwpTestError: getPlatData " \
+ "returned non-null pointer");
+ }
+
+ uint32_t l_size = 0;
+ if (l_rc.getHwpFfdc(l_size) != NULL)
+ {
+ FAPI_ERR("Performing HWP: hwpTestError: getHwpFFDC " \
+ "returned non-null pointer");
+ }
+
+ // Reset the return code
+ l_rc = fapi::RC_TEST_ERROR_A;
+
+ // Add some local FFDC to the ReturnCode
l_rc.setHwpFfdc(reinterpret_cast<void *>(&l_ffdc), sizeof(uint32_t));
return l_rc;
diff --git a/src/usr/hwpf/plat/fapiPlatUtil.C b/src/usr/hwpf/plat/fapiPlatUtil.C
index cb9da2f77..b0f3d79c3 100644
--- a/src/usr/hwpf/plat/fapiPlatUtil.C
+++ b/src/usr/hwpf/plat/fapiPlatUtil.C
@@ -32,6 +32,8 @@
#include <fapi.H>
#include <trace/interface.H>
#include <sys/time.h>
+#include <errl/errlmanager.H>
+#include <fapiPlatHwpInvoker.H>
//******************************************************************************
@@ -85,6 +87,25 @@ fapi::ReturnCode delay( uint64_t i_nanoSeconds, uint64_t i_simCycles )
return fapi::FAPI_RC_SUCCESS;
}
+//******************************************************************************
+// fapiLogError
+//******************************************************************************
+void fapiLogError(ReturnCode & io_rc)
+{
+ errlHndl_t l_pError = NULL;
+
+ FAPI_ERR("fapiLogError: logging error");
+
+ // Convert the return code to an error log.
+ // This will set the return code to FAPI_RC_SUCCESS and clear any PLAT Data,
+ // HWP FFDC data, and Error Target associated with it.
+ l_pError = fapiRcToErrl(io_rc);
+
+ // Commit the error log. This will delete the error log and set the handle
+ // to NULL.
+ errlCommit(l_pError);
+}
+
OpenPOWER on IntegriCloud