diff options
Diffstat (limited to 'src/import')
-rw-r--r-- | src/import/chips/p9/procedures/hwp/memory/lib/utils/c_str.C | 113 | ||||
-rw-r--r-- | src/import/chips/p9/procedures/hwp/memory/lib/utils/pos.C | 71 | ||||
-rw-r--r-- | src/import/generic/memory/lib/utils/c_str.C (renamed from src/import/chips/centaur/procedures/hwp/memory/lib/utils/position.C) | 37 | ||||
-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 |
6 files changed, 145 insertions, 197 deletions
diff --git a/src/import/chips/p9/procedures/hwp/memory/lib/utils/c_str.C b/src/import/chips/p9/procedures/hwp/memory/lib/utils/c_str.C deleted file mode 100644 index 7db26186a..000000000 --- a/src/import/chips/p9/procedures/hwp/memory/lib/utils/c_str.C +++ /dev/null @@ -1,113 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/import/chips/p9/procedures/hwp/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: Brian Silver <bsilver@us.ibm.com> -// *HWP HWP Backup: Andre Marin <aamarin@us.ibm.com> -// *HWP Team: Memory -// *HWP Level: 2 -// *HWP Consumed by: HB:FSP - -#include <fapi2.H> -#include <lib/mss_attribute_accessors.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 - - -template<> -const char* c_str( const fapi2::template Target<fapi2::TARGET_TYPE_DIMM>& i_target ) -{ - constexpr auto l_max_gen = 3; - constexpr auto l_max_type = 4; - static const char* l_map_gen_to_string[l_max_gen] = {"empty", "DDR3", "DDR4"}; - static const char* l_map_type_to_string[l_max_type] = {"empty", "RDIMM", "UDIMM", "LRDIMM"}; - char l_buffer[fapi2::MAX_ECMD_STRING_LEN]; - - uint8_t l_type = 0; - uint8_t l_gen = 0; - - uint8_t l_value[2][2]; - auto l_mca = i_target.getParent<TARGET_TYPE_MCA>(); - auto l_mcs = l_mca.getParent<TARGET_TYPE_MCS>(); - - 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 - if (FAPI_ATTR_GET(fapi2::ATTR_EFF_DIMM_TYPE, l_mcs, l_value) != 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_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; -} - -} diff --git a/src/import/chips/p9/procedures/hwp/memory/lib/utils/pos.C b/src/import/chips/p9/procedures/hwp/memory/lib/utils/pos.C deleted file mode 100644 index 238f22bfe..000000000 --- a/src/import/chips/p9/procedures/hwp/memory/lib/utils/pos.C +++ /dev/null @@ -1,71 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/import/chips/p9/procedures/hwp/memory/lib/utils/pos.C $ */ -/* */ -/* OpenPOWER HostBoot Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 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 */ - -#include <fapi2.H> -#include <generic/memory/lib/utils/pos.H> - -namespace mss -{ - -/// -/// @brief Return a DIMM's position from a fapi2 target -/// @param[in] i_target a target representing the target in question -/// @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) -{ - 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; - -} - -}// mss diff --git a/src/import/chips/centaur/procedures/hwp/memory/lib/utils/position.C b/src/import/generic/memory/lib/utils/c_str.C index 1f9e0978e..842290ce1 100644 --- a/src/import/chips/centaur/procedures/hwp/memory/lib/utils/position.C +++ b/src/import/generic/memory/lib/utils/c_str.C @@ -1,11 +1,11 @@ /* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ -/* $Source: src/import/chips/centaur/procedures/hwp/memory/lib/utils/position.C $ */ +/* $Source: src/import/generic/memory/lib/utils/c_str.C $ */ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2017 */ +/* Contributors Listed Below - COPYRIGHT 2015,2017 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -22,3 +22,36 @@ /* 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 |