summaryrefslogtreecommitdiffstats
path: root/src/import
diff options
context:
space:
mode:
authorBen Gass <bgass@us.ibm.com>2019-02-21 19:37:38 -0500
committerRaja Das <rajadas2@in.ibm.com>2019-07-26 00:54:50 -0500
commit52715d66e492b1401e9a445d295f84e4edee2c41 (patch)
treeeb2458affa0d37e548fe432ce989c77fd1f06c51 /src/import
parent4ccbdb857a4e3cc29cc1baf491bc4b8f315f3f73 (diff)
downloadtalos-sbe-52715d66e492b1401e9a445d295f84e4edee2c41.tar.gz
talos-sbe-52715d66e492b1401e9a445d295f84e4edee2c41.zip
Update cmd/rsp endian handling in exp_inband
Data written/read from the command/response/data buffers is done so in transaction sizes of 4 or 8 bytes. The data in those transactions will be little endian byte order. The byte order of those transactions must be corrected to represent the data structures stored in the buffers correctly for extraction of field data. The fields themselves will be big endian byte ordering. This patch also adds two attributes: ATTR_MSS_OCMB_EXP_STRUCT_MMIO_ENDIAN_CTRL - Controls whether or not bytes read from and written two the buffer are swapped. The default is to swap the byte order. ATTR_MSS_OCMB_EXP_STRUCT_ENDIAN - Controls whether or not the bytes of buffer structure fields are little endian or not. The default is big endian. Change-Id: I0863607bac383d586d10025a6c490cae0e2ed38f Original-Change-Id: I734d25dea2a3e4a864a2d35df2576676cad27cfe Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/72314 Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com> Reviewed-by: Benjamin Gass <bgass@us.ibm.com> Reviewed-by: Louis Stermole <stermole@us.ibm.com> Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com>
Diffstat (limited to 'src/import')
-rw-r--r--src/import/chips/ocmb/explorer/procedures/hwp/memory/lib/shared/exp_consts.H1
-rw-r--r--src/import/generic/memory/lib/utils/endian_utils.H60
2 files changed, 61 insertions, 0 deletions
diff --git a/src/import/chips/ocmb/explorer/procedures/hwp/memory/lib/shared/exp_consts.H b/src/import/chips/ocmb/explorer/procedures/hwp/memory/lib/shared/exp_consts.H
index e6418ea2..01f4120c 100644
--- a/src/import/chips/ocmb/explorer/procedures/hwp/memory/lib/shared/exp_consts.H
+++ b/src/import/chips/ocmb/explorer/procedures/hwp/memory/lib/shared/exp_consts.H
@@ -90,6 +90,7 @@ enum ffdc_codes
EXP_I2C_SET_FIELD = 0x0001,
READ_HOST_FW_RESPONSE_STRUCT = 0x0003,
READ_SENSOR_CACHE_STRUCT = 0x0004,
+ READ_CRCT_ENDIAN = 0x0005,
SET_BYTE_ENABLES = 0x1041,
SET_NIBBLE_ENABLES = 0x1042,
diff --git a/src/import/generic/memory/lib/utils/endian_utils.H b/src/import/generic/memory/lib/utils/endian_utils.H
index 6675e553..cbaf4289 100644
--- a/src/import/generic/memory/lib/utils/endian_utils.H
+++ b/src/import/generic/memory/lib/utils/endian_utils.H
@@ -189,6 +189,66 @@ bool readLEArray(const std::vector<uint8_t>& i_input, const uint32_t i_size, uin
return l_passing;
}
+///
+/// @brief Converts BE data into native order
+/// @tparam T the data type to output to
+/// @param[in] i_input inputted data to process
+/// @param[in,out] io_idx current index
+/// @param[out] o_data data that has been converted into native endianness
+/// @return bool true if passing false if failing
+/// @note Real FFDC will be handled outside
+///
+template < typename T >
+bool readBE(const std::vector<uint8_t>& i_input, uint32_t& io_idx, T& o_data)
+{
+ const uint32_t l_sz = static_cast<uint32_t>(sizeof(o_data));
+ uint64_t l_idx = io_idx;
+ io_idx = l_sz + io_idx;
+
+ // Checks that our final index is within the data range
+ // Note: we decrement the index prior, so equal to is ok
+ if(io_idx > i_input.size())
+ {
+ return false;
+ }
+
+ o_data = 0;
+
+ for(uint64_t i = 0; i < l_sz; i++)
+ {
+ uint8_t v = i_input[l_idx];
+ o_data <<= BITS_PER_BYTE;
+ o_data |= v;
+ l_idx++;
+ }
+
+ return true;
+}
+
+///
+/// @brief Converts BE data into native order
+/// @tparam T the data type to output to
+/// @param[in] i_input inputted data to process
+/// @param[in] i_size size of the array
+/// @param[in,out] io_idx current index
+/// @param[out] o_data data that has been converted into native endianness
+/// @return bool true if passing false if failing
+/// @note Real FFDC will be handled outside
+///
+template < typename T >
+bool readBEArray(const std::vector<uint8_t>& i_input, const uint32_t i_size, uint32_t& io_idx, T* o_data)
+{
+ // Loop while the readLE is still passing and we haven't looped through the array's boundaries
+ bool l_passing = true;
+
+ for(uint32_t i = 0; i < i_size && l_passing; ++i)
+ {
+ l_passing = readBE(i_input, io_idx, o_data[i]);
+ }
+
+ return l_passing;
+}
+
}
#endif
OpenPOWER on IntegriCloud