diff options
Diffstat (limited to 'src/import/generic/memory/lib/utils')
-rw-r--r-- | src/import/generic/memory/lib/utils/buffer_ops.H | 28 | ||||
-rw-r--r-- | src/import/generic/memory/lib/utils/mcbist/gen_mss_mcbist_address.H | 18 |
2 files changed, 45 insertions, 1 deletions
diff --git a/src/import/generic/memory/lib/utils/buffer_ops.H b/src/import/generic/memory/lib/utils/buffer_ops.H index 31e7f11a2..42b02b5d1 100644 --- a/src/import/generic/memory/lib/utils/buffer_ops.H +++ b/src/import/generic/memory/lib/utils/buffer_ops.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015,2018 */ +/* Contributors Listed Below - COPYRIGHT 2015,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -103,6 +103,32 @@ static inline void reverse( T& io_buffer ) } /// +/// @brief Reverse a given bit range of a buffer +/// @tparam S start bit +/// @tparam L length of bits to reverse +/// @tparam T buffer type +/// @param[in] io_buffer +/// +template<uint64_t S, uint64_t L, typename T> +static inline void reverse_range(fapi2::buffer<T>& io_buffer) +{ + const auto target_length = fapi2::parameterTraits<T>::bit_length(); + + static_assert(S < target_length, + "reverse_range(): Start is out of bounds"); + + static_assert((S + L) <= target_length, + "reverse_range(): (Start + Len) is out of bounds"); + + fapi2::buffer<T> l_tmp; + + io_buffer.template extractToRight<S, L>(l_tmp); + + l_tmp.reverse(); + io_buffer.template insert<S, L>(l_tmp); +} + +/// /// @brief Swizzle bits between two fapi2 buffers, and insert from source to destination /// @tparam DS the start bit in the destination buffer - swizzle will count up from here /// @tparam L how many bits to swizzle diff --git a/src/import/generic/memory/lib/utils/mcbist/gen_mss_mcbist_address.H b/src/import/generic/memory/lib/utils/mcbist/gen_mss_mcbist_address.H index b42c0e39b..37e35c48d 100644 --- a/src/import/generic/memory/lib/utils/mcbist/gen_mss_mcbist_address.H +++ b/src/import/generic/memory/lib/utils/mcbist/gen_mss_mcbist_address.H @@ -99,6 +99,15 @@ class address } /// + /// @brief Construct an address from the provided buffer + /// @param[in] i_address fapi2::buffer address + /// + address(const fapi2::buffer<uint64_t>& i_address): + iv_address(i_address) + { + } + + /// /// @brief Conversion operator to uint64_t /// @warn Right-aligns the address /// @@ -412,6 +421,15 @@ class address return get_field<BANK_GROUP>(); } + /// + /// @brief Get the buffer object for bit operations + /// @return fapi2::buffer<uint64_t>& + /// + inline fapi2::buffer<uint64_t> get_address_buffer() const + { + return iv_address; + } + private: // We use a fapi2 buffer as it has static compile-time support fapi2::buffer<uint64_t> iv_address; |