diff options
author | Stephen Glancy <sglancy@us.ibm.com> | 2018-09-13 14:05:32 -0500 |
---|---|---|
committer | Christian R. Geddes <crgeddes@us.ibm.com> | 2018-09-27 09:44:14 -0500 |
commit | 99d8a2ec0d3f4e83b1089f7358a8d930dddf2bee (patch) | |
tree | f6f52a8423c0b8f31979b2a476f3292a2f514f87 /src/import/generic | |
parent | 0fb82ef1a41044a7dce49adee8215e8fbf448d0e (diff) | |
download | talos-hostboot-99d8a2ec0d3f4e83b1089f7358a8d930dddf2bee.tar.gz talos-hostboot-99d8a2ec0d3f4e83b1089f7358a8d930dddf2bee.zip |
Adds insert function space helpers for LRDIMM
Change-Id: I2ad35dc3d1a72606b7a0ce72ad407fe7ce10e0c2
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/66086
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: HWSV CI <hwsv-ci+hostboot@us.ibm.com>
Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com>
Reviewed-by: ANDRE A. MARIN <aamarin@us.ibm.com>
Reviewed-by: Louis Stermole <stermole@us.ibm.com>
Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com>
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/66097
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com>
Diffstat (limited to 'src/import/generic')
-rw-r--r-- | src/import/generic/memory/lib/utils/buffer_ops.H | 56 |
1 files changed, 50 insertions, 6 deletions
diff --git a/src/import/generic/memory/lib/utils/buffer_ops.H b/src/import/generic/memory/lib/utils/buffer_ops.H index f6599d644..31e7f11a2 100644 --- a/src/import/generic/memory/lib/utils/buffer_ops.H +++ b/src/import/generic/memory/lib/utils/buffer_ops.H @@ -37,6 +37,7 @@ #define _BUFFER_OPS_H_ #include <fapi2.H> +#include <generic/memory/lib/utils/mss_buffer_utils.H> namespace mss { @@ -109,25 +110,68 @@ static inline void reverse( T& io_buffer ) /// @tparam SB source buffer type /// @tparam DB destination buffer type /// @param[in] i_source source buffer - these bits will be decremented -/// @param[out] o_destination destination buffer - these bits will be incremented +/// @param[in,out] io_destination destination buffer - these bits will be incremented /// @return reference to the destination /// template<uint64_t DS, uint64_t L, uint64_t SS, typename SB, typename DB> -inline fapi2::buffer<DB>& swizzle( const fapi2::buffer<SB>& i_source, fapi2::buffer<DB>& o_destination ) +inline fapi2::buffer<DB>& swizzle( const fapi2::buffer<SB>& i_source, fapi2::buffer<DB>& io_destination ) { - // Reverse the destination, and then mangle the start bits to get things to line up + // Steps for the swizzle + // 1) Reverse the destination buffer + // 2) compute the source buffer start + + // 1) Reverse the destination buffer fapi2::buffer<SB> l_tmp(i_source); reverse(l_tmp); - o_destination.template insert < DS, L, (sizeof(SB) * 8) - (SS + 1) > (SB(l_tmp)); + // 2) compute the source buffer start + // For the swizzle, we need to know where the source buffer's data starts at + // The data is right justified, so we want to get the data's length and subtract out the whole data length + // We subtract out an additonal 1 to account for bits being from 0 to N-1 + constexpr auto l_source_data_start = get_bit_length<SB>() - (SS + 1); + io_destination.template insert < DS, L, l_source_data_start > (SB(l_tmp)); #ifdef SWIZZLE_TRACE // s: source, r: reverse, d: destination, ds: distination start, l: length, ss: source start FAPI_DBG("swizzle s: 0x%016llx, r: 0x%016llx, d: 0x%016llx, ds: %d, l: %d, ss: %d", - i_source, l_tmp, o_destination, DS, L, (sizeof(SB) * 8) - (SS + 1)); + i_source, l_tmp, io_destination, DS, L, l_source_data_start); #endif - return o_destination; + return io_destination; +} + +/// +/// @brief Swizzle bits between two fapi2 buffers, and insert from source to destination +/// @tparam SB source buffer type +/// @tparam DB destination buffer type +/// @tparam i_destination_start the start bit in the destination buffer - swizzle will count up from here +/// @tparam i_length how many bits to swizzle +/// @tparam i_source_start the start bit in the source buffer - swizzle will count down from here +/// @param[in] i_source source buffer - these bits will be decremented +/// @param[in,out] io_destination destination buffer - these bits will be incremented +/// @return fapi2::ReturnCode SUCCESS iff the code is successful +/// +template<typename SB, typename DB> +inline fapi2::ReturnCode swizzle( const uint64_t i_destination_start, + const uint64_t i_length, + const uint64_t i_source_start, + const fapi2::buffer<SB>& i_source, + fapi2::buffer<DB>& io_destination ) +{ + // Steps for the swizzle + // 1) Reverse the destination buffer + // 2) compute the source buffer start + + // 1) Reverse the destination buffer + fapi2::buffer<SB> l_tmp(i_source); + reverse(l_tmp); + + // 2) compute the source buffer start + // For the swizzle, we need to know where the source buffer's data starts at + // The data is right justified, so we want to get the data's length and subtract out the whole data length + // We subtract out an additonal 1 to account for bits being from 0 to N-1 + const auto l_source_data_start = get_bit_length<SB>() - (i_source_start + 1); + return io_destination.insert(SB(l_tmp), i_destination_start, i_length, l_source_data_start); } } // ns mss |