diff options
author | Christian Geddes <crgeddes@us.ibm.com> | 2018-10-24 10:47:24 -0500 |
---|---|---|
committer | RAJA DAS <rajadas2@in.ibm.com> | 2019-07-25 03:48:27 -0500 |
commit | 5df3896af1ea3e70bbd0f25fce79e1a7f12ff0c4 (patch) | |
tree | 0eb9888c8a73c2f0cdd54f0f1910d657286849f3 /src/import/generic | |
parent | 2ce7e14314e8f8377e09b6b8efb6f085a3bd08d2 (diff) | |
download | talos-sbe-5df3896af1ea3e70bbd0f25fce79e1a7f12ff0c4.tar.gz talos-sbe-5df3896af1ea3e70bbd0f25fce79e1a7f12ff0c4.zip |
Add exp_i2c_scom driver that will be consumed by HB/SBE platforms
This commit adds a new exp_i2c_scom.H file which contains two
functions, i2c_get_scom and i2c_put_scom. These functions will
take in a fapi2 OCMB target, an address and a buffer that either
contains scom data to write or space for scom data to be written
to. The functions use the fapi2::puti2c / fapi2::geti2c interfaces
to perform the scoms.
Change-Id: Ifb83b88e71ca9804f378b7b8893683ddcbb5ba06
Original-Change-Id: I4de680e187258cbfc57dd71f698dc1fc8760cefb
RTC:196806
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/67949
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com>
Reviewed-by: Louis Stermole <stermole@us.ibm.com>
Reviewed-by: STEPHEN GLANCY <sglancy@us.ibm.com>
Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com>
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/80969
Reviewed-by: RAJA DAS <rajadas2@in.ibm.com>
Tested-by: RAJA DAS <rajadas2@in.ibm.com>
Diffstat (limited to 'src/import/generic')
-rw-r--r-- | src/import/generic/memory/lib/utils/endian_utils.H | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/src/import/generic/memory/lib/utils/endian_utils.H b/src/import/generic/memory/lib/utils/endian_utils.H new file mode 100644 index 00000000..446dcc86 --- /dev/null +++ b/src/import/generic/memory/lib/utils/endian_utils.H @@ -0,0 +1,149 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/import/generic/memory/lib/utils/endian_utils.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2018,2019 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ + +/// +/// @file endian_utils.H +/// @brief Util functions to help with endianess +/// + +// *HWP HWP Owner: Ben Gass <bgass@us.ibm.com> +// *HWP HWP Backup: Christian Geddes <crgeddes@us.ibm.com> +// *HWP Team: +// *HWP Level: 2 +// *HWP Consumed by: HB:FSP + +#ifndef _ENDIAN_UTILS_H_ +#define _ENDIAN_UTILS_H_ + +#include <cstdint> +#include <vector> +#include <generic/memory/lib/utils/shared/mss_generic_consts.H> + +namespace mss +{ + +/// +/// @brief Forces native data into LE order +/// @tparam T the data type to process +/// @param[in] i_input inputted data to process +/// @param[in,out] io_data vector to append data to +/// +template < typename T > +void forceLE(const T& i_input, std::vector<uint8_t>& io_data) +{ + // Temporary variable to process - we'll be doing bit shifts below + T l_temp = i_input; + + for(size_t i = 0; i < sizeof(i_input); i++) + { + // Grab the lowe rorder byte and add it to the back of the vector + const uint8_t l_byte = l_temp & 0xFF; + io_data.push_back(l_byte); + + // Shift higher byte value into lowest no matter existing endianness + l_temp >>= BITS_PER_BYTE; + } +} + +/// +/// @brief Forces native data into LE order for an array +/// @tparam T the data type to process +/// @param[in] i_input inputted data to process +/// @param[in] i_size size of the array +/// @param[in,out] io_data vector to append data to +/// +template < typename T > +inline void forceLEArray(const T* i_input, const uint64_t i_size, std::vector<uint8_t>& io_data) +{ + for(size_t i = 0; i < i_size; i++) + { + forceLE(i_input[i], io_data); + } +} + +/// +/// @brief Converts LE 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 readLE(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)); + 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; + } + + uint64_t l_idx = io_idx; + + o_data = 0; + + for(uint64_t i = 0; i < l_sz; i++) + { + l_idx--; + uint8_t v = i_input[l_idx]; + o_data <<= BITS_PER_BYTE; + o_data |= v; + } + + return true; +} + +/// +/// @brief Converts LE 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 readLEArray(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 = readLE(i_input, io_idx, o_data[i]); + } + + return l_passing; +} + +} + +#endif |