summaryrefslogtreecommitdiffstats
path: root/import/hwpf
diff options
context:
space:
mode:
authorMatt K. Light <mklight@us.ibm.com>2015-11-24 08:02:21 -0600
committerSantosh S. Puranik <santosh.puranik@in.ibm.com>2016-03-04 07:21:27 -0500
commit14afc569dec865dd3d80edd3c746bb70eb52c162 (patch)
treecaf4c4fd25862eb878b4075c8199ad2b0064b0fb /import/hwpf
parentdf4dfe25a37a44f2192614db236905f94842cb59 (diff)
downloadtalos-sbe-14afc569dec865dd3d80edd3c746bb70eb52c162.tar.gz
talos-sbe-14afc569dec865dd3d80edd3c746bb70eb52c162.zip
utility functions to convert between variable_buffer and ecmdDataBufferBase
Change-Id: I7b8f36f7b90238cd3beed7cdf847a3d003388c50 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/22299 Tested-by: Jenkins Server Reviewed-by: Richard J. Knight <rjknight@us.ibm.com> Reviewed-by: Thi N. Tran <thi@us.ibm.com> Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com> Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/21704 Reviewed-by: Santosh S. Puranik <santosh.puranik@in.ibm.com>
Diffstat (limited to 'import/hwpf')
-rw-r--r--import/hwpf/fapi2/include/variable_buffer_utils.H142
1 files changed, 142 insertions, 0 deletions
diff --git a/import/hwpf/fapi2/include/variable_buffer_utils.H b/import/hwpf/fapi2/include/variable_buffer_utils.H
new file mode 100644
index 00000000..53270f80
--- /dev/null
+++ b/import/hwpf/fapi2/include/variable_buffer_utils.H
@@ -0,0 +1,142 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: hwpf/fapi2/include/variable_buffer_utils.H $ */
+/* */
+/* IBM CONFIDENTIAL */
+/* */
+/* EKB Project */
+/* */
+/* COPYRIGHT 2015 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* The source code for this program is not published or otherwise */
+/* divested of its trade secrets, irrespective of what has been */
+/* deposited with the U.S. Copyright Office. */
+/* */
+/* IBM_PROLOG_END_TAG */
+
+#ifndef __FAPI2_VARIABLE_BUFFER_UTILS__
+#define __FAPI2_VARIABLE_BUFFER_UTILS__
+
+#include <inttypes.h>
+
+#include <ecmdDataBufferBase.H>
+
+#include <variable_buffer.H>
+#include <return_code_defs.H>
+#include <plat_trace.H>
+
+namespace fapi2
+{
+/** @name Variable buffer utility functions for platforms that support eCMD **/
+//@{
+
+/**
+ * @brief Copies contents of fapi2::variable_buffer to a ecmdDataBufferBase
+ * @param[in] i_src fapi::variable_buffer to copy from
+ * @param[out] o_dest ecmdDataBufferBase to copy to
+ * @return uint32_t return code zero if success
+ */
+inline uint32_t bufferCopy(ecmdDataBufferBase& o_dest, const fapi2::variable_buffer& i_src)
+{
+ uint32_t rc = 0;
+ uint32_t l_ecmdRc = 0;
+ uint32_t l_bitLength = i_src.getBitLength();
+ const uint32_t l_bitsPerWord = sizeof(uint32_t) * 8;
+ uint32_t l_wordLength = l_bitLength / l_bitsPerWord;
+ uint32_t l_currentWord = 0;
+ uint32_t l_extractData = 0;
+ fapi2::ReturnCodes l_copy_rc = fapi2::FAPI2_RC_SUCCESS;
+
+ l_ecmdRc = o_dest.setBitLength(l_bitLength);
+
+ if (l_ecmdRc)
+ {
+ FAPI_ERR("Error calling o_dest.setBitLength(%d) rc = 0x%08X\n",
+ l_bitLength, l_ecmdRc);
+ rc = l_ecmdRc;
+ }
+
+ while ((l_currentWord < l_wordLength) && (rc == 0))
+ {
+ l_copy_rc = i_src.extract(l_extractData, l_currentWord * l_bitsPerWord, l_bitsPerWord);
+
+ if (l_copy_rc != fapi2::FAPI2_RC_SUCCESS)
+ {
+ FAPI_ERR("Error calling i_src.extract(l_extractData, %d, %d) rc = 0x" UINT64_HEX16_FORMAT "\n",
+ l_currentWord * l_bitsPerWord, l_bitsPerWord, static_cast<uint64_t>(l_copy_rc));
+ rc = static_cast<uint64_t>(l_copy_rc);
+ break;
+ }
+
+ l_ecmdRc = o_dest.insert(l_extractData, l_currentWord * l_bitsPerWord, l_bitsPerWord, 0);
+
+ if (l_ecmdRc)
+ {
+ FAPI_ERR("Error calling o_dest.insert(%08X, %d, %d, 0) rc = 0x%08X\n",
+ l_extractData, l_currentWord * l_bitsPerWord, l_bitsPerWord, l_ecmdRc);
+ rc = l_ecmdRc;
+ break;
+ }
+
+ l_currentWord++;
+ }
+
+ if ((l_bitLength > (l_wordLength * l_bitsPerWord)) && (rc == 0))
+ {
+ uint32_t l_bitsRemaining = l_bitLength - (l_wordLength * l_bitsPerWord);
+ l_copy_rc = i_src.extract(l_extractData, l_wordLength * l_bitsPerWord, l_bitsRemaining);
+
+ if (l_copy_rc != fapi2::FAPI2_RC_SUCCESS)
+ {
+ FAPI_ERR("error calling i_src.extract(l_extractData, %d, %d) rc = 0x" UINT64_HEX16_FORMAT "\n",
+ l_wordLength * l_bitsPerWord, l_bitsRemaining, static_cast<uint64_t>(l_copy_rc));
+ rc = static_cast<uint64_t>(l_copy_rc);
+ }
+ else
+ {
+ l_ecmdRc = o_dest.insert(l_extractData, l_wordLength * l_bitsPerWord, l_bitsRemaining, 0);
+
+ if (l_ecmdRc)
+ {
+ FAPI_ERR("Error calling o_dest.insert(%08X, %d, %d, 0) rc = 0x%08X\n",
+ l_extractData, l_wordLength * l_bitsPerWord, l_bitsRemaining, l_ecmdRc);
+ rc = l_ecmdRc;
+ }
+ }
+ }
+
+ return rc;
+}
+
+/**
+ * @brief Copies contents of ecmdDataBufferBase to a fapi2::variable_buffer
+ * @param[in] i_src ecmdDataBufferBase to copy from
+ * @param[out] o_dest fapi::variable_buffer to copy to
+ * @return uint32_t return code zero if success
+ */
+inline uint32_t bufferCopy(fapi2::variable_buffer& o_dest, ecmdDataBufferBase& i_src)
+{
+ uint32_t rc = 0;
+ uint32_t* l_data = ecmdDataBufferBaseImplementationHelper::getDataPtr(&i_src);
+
+ if (l_data != NULL)
+ {
+ o_dest = fapi2::variable_buffer(l_data, i_src.getCapacity(), i_src.getBitLength());
+ }
+ else
+ {
+ FAPI_ERR("Error getting data pointer to ecmdDataBufferBase\n");
+ rc = 1;
+ }
+
+ return rc;
+}
+
+//@}
+
+} // namespace fapi2
+
+#endif /* __FAPI2_VARIABLE_BUFFER_UTILS__ */
OpenPOWER on IntegriCloud