diff options
| author | Andre Marin <aamarin@us.ibm.com> | 2017-06-11 21:32:04 -0500 |
|---|---|---|
| committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2017-08-18 10:52:03 -0400 |
| commit | d4c08be2b76339d60f098968bfe05f5a34a19c0b (patch) | |
| tree | 7172f0d5dd28238121bafd489be0618c46258b1c /src/import/generic/memory/lib | |
| parent | a6109ca9369683e80c2d3e20bd3e1435c594b25f (diff) | |
| download | blackbird-hostboot-d4c08be2b76339d60f098968bfe05f5a34a19c0b.tar.gz blackbird-hostboot-d4c08be2b76339d60f098968bfe05f5a34a19c0b.zip | |
Fix duplicate symbol error when linking mss and cen libs
Change-Id: I010b7fb2a7efbc5e9d2ec20206e82723514b631c
Original-Change-Id: Ib643f56d66f844d9ac59a86712622ed9f7453703
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/41662
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com>
Reviewed-by: Thi N. Tran <thi@us.ibm.com>
Reviewed-by: JACOB L. HARVEY <jlharvey@us.ibm.com>
Reviewed-by: STEPHEN GLANCY <sglancy@us.ibm.com>
Reviewed-by: Richard J. Knight <rjknight@us.ibm.com>
Reviewed-by: Louis Stermole <stermole@us.ibm.com>
Reviewed-by: LUCAS W. MULKEY <lwmulkey@us.ibm.com>
Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com>
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/44371
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Tested-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/import/generic/memory/lib')
| -rw-r--r-- | src/import/generic/memory/lib/utils/c_str.C | 57 | ||||
| -rw-r--r-- | src/import/generic/memory/lib/utils/c_str.H | 63 | ||||
| -rw-r--r-- | src/import/generic/memory/lib/utils/index.H | 19 | ||||
| -rw-r--r-- | src/import/generic/memory/lib/utils/pos.H | 39 |
4 files changed, 167 insertions, 11 deletions
diff --git a/src/import/generic/memory/lib/utils/c_str.C b/src/import/generic/memory/lib/utils/c_str.C new file mode 100644 index 000000000..842290ce1 --- /dev/null +++ b/src/import/generic/memory/lib/utils/c_str.C @@ -0,0 +1,57 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/import/generic/memory/lib/utils/c_str.C $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2015,2017 */ +/* [+] 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 c_str.C +/// @brief Storage for the C-string name of a thing +/// +// *HWP HWP Owner: Andre Marin <aamarin@us.ibm.com> +// *HWP HWP Backup: Jacob Harvey <jlharvey@us.ibm.com> +// *HWP Team: Memory +// *HWP Level: 2 +// *HWP Consumed by: HB:FSP + +#include <fapi2.H> +#include <generic/memory/lib/utils/c_str.H> + +using fapi2::TARGET_TYPE_MCBIST; +using fapi2::TARGET_TYPE_MCA; +using fapi2::TARGET_TYPE_MCS; +using fapi2::TARGET_TYPE_DIMM; + +using fapi2::FAPI2_RC_SUCCESS; + +namespace mss +{ + +// Thread local storage for the string we're going to create. +//TODO RTC:153924 Remove the else case when issue is resolved +#ifndef PLAT_NO_THREAD_LOCAL_STORAGE + thread_local char c_str_storage[fapi2::MAX_ECMD_STRING_LEN]; +#else + char c_str_storage[fapi2::MAX_ECMD_STRING_LEN]; +#endif + +} diff --git a/src/import/generic/memory/lib/utils/c_str.H b/src/import/generic/memory/lib/utils/c_str.H index 3795de2c5..a67744a84 100644 --- a/src/import/generic/memory/lib/utils/c_str.H +++ b/src/import/generic/memory/lib/utils/c_str.H @@ -27,8 +27,8 @@ /// @file c_str.H /// @brief Function to return the C-string name of a thing /// -// *HWP HWP Owner: Brian Silver <bsilver@us.ibm.com> -// *HWP HWP Backup: Andre Marin <aamarin@us.ibm.com> +// *HWP HWP Owner: Andre Marin <aamarin@us.ibm.com> +// *HWP HWP Backup: Jacob Harvey <jlharvey@us.ibm.com> // *HWP Team: Memory // *HWP Level: 2 // *HWP Consumed by: HB:FSP @@ -37,6 +37,7 @@ #define _MSS_C_STR_H_ #include <fapi2.H> +#include <generic/memory/lib/utils/index.H> namespace mss { @@ -65,14 +66,68 @@ const char* c_str( const T& i_input ); /// @return const char * /// template< fapi2::TargetType T > -const char* c_str( const fapi2::template Target<T>& i_target ) +inline const char* c_str( const fapi2::template Target<T>& i_target ) { fapi2::toString( i_target, c_str_storage, fapi2::MAX_ECMD_STRING_LEN ); return c_str_storage; } template<> -const char* c_str( const fapi2::template Target<fapi2::TARGET_TYPE_DIMM>& i_target ); +inline const char* c_str( const fapi2::template Target<fapi2::TARGET_TYPE_DIMM>& i_target ) +{ + const auto l_mca = i_target.getParent<fapi2::TARGET_TYPE_MCA>(); + const auto l_mcs = l_mca.getParent<fapi2::TARGET_TYPE_MCS>(); + + constexpr auto l_max_gen = 3; + constexpr auto l_max_type = 4; + const char* const l_map_gen_to_string[l_max_gen] = {"empty", "DDR3", "DDR4"}; + const char* const l_map_type_to_string[l_max_type] = {"empty", "RDIMM", "UDIMM", "LRDIMM"}; + + uint8_t l_type = 0; + uint8_t l_gen = 0; + char l_buffer[fapi2::MAX_ECMD_STRING_LEN] = {}; + + fapi2::toString( i_target, c_str_storage, fapi2::MAX_ECMD_STRING_LEN ); + + // Had to unroll FAPI_TRY so that fapi2::current_err doesn't get overwritten, causes errors + // when calling c_str inside of a function that returns fapi2::ReturnCode + constexpr size_t PORTS_PER_MCS = 2; + constexpr size_t MAX_DIMM_PER_PORT = 2; + uint8_t l_value[PORTS_PER_MCS][MAX_DIMM_PER_PORT] = {}; + + if (FAPI_ATTR_GET(fapi2::ATTR_EFF_DIMM_TYPE, l_mcs, l_value) != fapi2::FAPI2_RC_SUCCESS) + { + goto fapi_try_exit; + } + + l_type = l_value[mss::index(l_mca)][mss::index(i_target)]; + + if (l_type >= l_max_type) + { + goto fapi_try_exit; + } + + // Had to unroll FAPI_TRY so that fapi2::current_err doesn't get overwritten, causes errors + // when calling c_str inside of a function that returns fapi2::ReturnCode + if (FAPI_ATTR_GET(fapi2::ATTR_EFF_DRAM_GEN, l_mcs, l_value) != fapi2::FAPI2_RC_SUCCESS) + { + goto fapi_try_exit; + } + + l_gen = l_value[mss::index(l_mca)][mss::index(i_target)]; + + if (l_gen >= l_max_gen) + { + goto fapi_try_exit; + } + + snprintf(l_buffer, fapi2::MAX_ECMD_STRING_LEN, " %s (%s)", l_map_type_to_string[l_type], l_map_gen_to_string[l_gen]); + return strncat( c_str_storage, l_buffer, fapi2::MAX_ECMD_STRING_LEN - strlen(c_str_storage) ); + +fapi_try_exit: + // Probably the best we're going to do ... + return c_str_storage; +} } #endif diff --git a/src/import/generic/memory/lib/utils/index.H b/src/import/generic/memory/lib/utils/index.H index 6fefed17d..6c213c5ec 100644 --- a/src/import/generic/memory/lib/utils/index.H +++ b/src/import/generic/memory/lib/utils/index.H @@ -61,13 +61,18 @@ namespace mss /// /// @brief Return an attribute array index from a fapi2 target -/// @tparam T the fapi2::TargetType -/// @param[in] i_target a DIMM target representing the DIMM in question +/// @tparam T the fapi2::TargetType - derived +/// @param[in] i_target a fapi2 target /// @return size_t the attribute array index. /// template< fapi2::TargetType T > inline size_t index(const fapi2::Target<T>& i_target); +/// +/// @brief Return an attribute array index from a DIMM target +/// @param[in] i_target a DIMM target representing the DIMM in question +/// @return size_t the attribute array index. +/// template<> inline size_t index(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target) { @@ -75,6 +80,11 @@ inline size_t index(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target) return mss::pos(i_target) % TT::DIMMS_PER_PORT; } +/// +///@brief Return an attribute array index from a MCA target +/// @param[in] i_target a MCA target representing the MCA in question +/// @return size_t the attribute array index. +/// template<> inline size_t index(const fapi2::Target<fapi2::TARGET_TYPE_MCA>& i_target) { @@ -82,6 +92,11 @@ inline size_t index(const fapi2::Target<fapi2::TARGET_TYPE_MCA>& i_target) return mss::pos(i_target) % TT::PORTS_PER_MCS; } +/// +/// @brief Return an attribute array index from a MCS target +/// @param[in] i_target a MCS target representing the MCS in question +/// @return size_t the attribute array index. +/// template<> inline size_t index(const fapi2::Target<fapi2::TARGET_TYPE_MCS>& i_target) { diff --git a/src/import/generic/memory/lib/utils/pos.H b/src/import/generic/memory/lib/utils/pos.H index e85e1b9ea..a308ba7c6 100644 --- a/src/import/generic/memory/lib/utils/pos.H +++ b/src/import/generic/memory/lib/utils/pos.H @@ -27,8 +27,8 @@ /// @file pos.H /// @brief Tools to return target's position from a fapi2 target /// -// *HWP HWP Owner: Brian Silver <bsilver@us.ibm.com> -// *HWP HWP Backup: Andre Marin <aamarin@us.ibm.com> +// *HWP HWP Owner: Andre Marin <aamarin@us.ibm.com> +// *HWP HWP Backup: Jacob Harvey <jlharvey@us.ibm.com> // *HWP Team: Memory // *HWP Level: 2 // *HWP Consumed by: HB:FSP @@ -110,7 +110,7 @@ namespace mss /// @return The position relative to the chip /// template< fapi2::TargetType T, typename TT = posTraits<T> > -typename TT::pos_type pos(const fapi2::Target<T>& i_target) +inline typename TT::pos_type pos(const fapi2::Target<T>& i_target) { typename TT::pos_type l_pos = 0; @@ -162,8 +162,37 @@ fapi_try_exit: /// @return The position relative to the chip /// template<> -posTraits<fapi2::TARGET_TYPE_DIMM>::pos_type -pos(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target); +inline posTraits<fapi2::TARGET_TYPE_DIMM>::pos_type +pos(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target) +{ + typedef posTraits<fapi2::TARGET_TYPE_DIMM> TT; + + // Proc 0 is DIMM 0-15, proc 2 is 64-79 - 64 is the stride between processors + constexpr uint64_t DIMM_STRIDE_PER_PROC = 64; + constexpr uint64_t TOTAL_DIMM = TT::MC_PER_MODULE * TT::MCS_PER_MC * TT::PORTS_PER_MCS * TT::DIMMS_PER_PORT; + + TT::pos_type l_pos = 0; + + // Using fapi2 rather than mss::find as this is pretty low level stuff. + const auto l_proc_pos = + mss::template pos(i_target.getParent<fapi2::TARGET_TYPE_MCA>().getParent<fapi2::TARGET_TYPE_PROC_CHIP>()); + + if (FAPI_ATTR_GET(fapi2::ATTR_FAPI_POS, i_target, l_pos) != fapi2::FAPI2_RC_SUCCESS) + { + goto fapi_try_exit; + } + + // To get the FAPI_POS to the equivilent of ATTR_POS, we need to normalize the fapi_pos value + // to the processor (stride across which ever processor we're on) and then add in the delta + // per processor as ATTR_POS isn't processor relative (delta is the total dimm on a processor) + return ((l_pos - (l_proc_pos * DIMM_STRIDE_PER_PROC)) % TOTAL_DIMM) + (TOTAL_DIMM * l_proc_pos); + +fapi_try_exit: + // If we can't get our position, we're in other trouble + FAPI_ERR("can't get our fapi position"); + fapi2::Assert(false); + return 0; +} /// /// @brief Return a target's relative position from a fapi2 target |

