diff options
author | Andre Marin <aamarin@us.ibm.com> | 2018-08-10 08:29:49 -0500 |
---|---|---|
committer | Christian R. Geddes <crgeddes@us.ibm.com> | 2018-08-28 10:29:16 -0500 |
commit | 4b6dde2ad7d0cd03f905031ea2355a02a1992d39 (patch) | |
tree | 170ead8bf1202a6c7a6b5184faa0f005bac3d861 /src/import/generic | |
parent | 814860ea37f68c1d6637c4262d1d44ce31b04222 (diff) | |
download | talos-hostboot-4b6dde2ad7d0cd03f905031ea2355a02a1992d39.tar.gz talos-hostboot-4b6dde2ad7d0cd03f905031ea2355a02a1992d39.zip |
Implement exp_check_for_ready
Change-Id: I11e80e70c411ec0f5a1891e078b669f176658c34
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/61972
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: Louis Stermole <stermole@us.ibm.com>
Reviewed-by: RYAN P. KING <rpking@us.ibm.com>
Reviewed-by: ANDRE A. MARIN <aamarin@us.ibm.com>
Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com>
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/64831
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: FSP CI Jenkins <fsp-CI-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/poll.H | 67 | ||||
-rw-r--r-- | src/import/generic/memory/lib/utils/shared/mss_generic_consts.H | 57 |
2 files changed, 94 insertions, 30 deletions
diff --git a/src/import/generic/memory/lib/utils/poll.H b/src/import/generic/memory/lib/utils/poll.H index 061e462ae..4097a3104 100644 --- a/src/import/generic/memory/lib/utils/poll.H +++ b/src/import/generic/memory/lib/utils/poll.H @@ -39,7 +39,7 @@ #include <fapi2.H> #include <generic/memory/lib/utils/scom.H> -#include <lib/shared/mss_const.H> +#include <generic/memory/lib/utils/shared/mss_generic_consts.H> namespace mss { @@ -132,15 +132,15 @@ struct poll_parameters }; /// -/// @brief Poll a scom, return whether the poll croteria were met or not -/// @tparam T, the fapi2::TargetType -/// @tparam L, a lambda representing the completion criteria - returns true -/// @tparam P, the fapi2::TargetType of the target in the probe vector +/// @brief Poll a scom, return whether the poll criteria were met or not +/// @tparam T the fapi2::TargetType +/// @tparam L a lambda representing the completion criteria - returns true +/// @tparam P the fapi2::TargetType of the target in the probe vector /// iff the poll criteria have been met (and the polling can stop) -/// @param[in] i_target, target for the getScom -/// @param[in] i_addr, the address for the scom -/// @param[in] i_params, a poll_parameters structure -/// @param[in] i_fn, the function to call to check the poll criteria +/// @param[in] i_target target for the getScom +/// @param[in] i_addr the address for the scom +/// @param[in] i_params a poll_parameters structure +/// @param[in] i_fn the function to call to check the poll criteria /// [](const size_t poll_remaining, const fapi2::buffer<uint64_t>& stat_reg) -> bool /// { /// return true; @@ -198,5 +198,54 @@ fapi_try_exit: return false; } +/// +/// @brief A generic poll that return whether the poll criteria were met +/// @tparam T the fapi2::TargetType +/// @tparam L a lambda representing the completion criteria - returns true +/// @param[in] i_target target for the getScom +/// @param[in] i_params a poll_parameters structure +/// @param[in] i_fn the function to call to check the poll criteria +/// [capture_by_value]() -> bool +/// { +/// return true; +/// } +/// @return bool, true iff poll criteria was met before the number of iterations +/// ran out. +/// @warning If you want to handle a failure as an error, you need to wrap +/// the call to poll() in a FAPI_ASSERT. FAPI_TRY is *not* the right mechanism +/// as poll() does not return a fapi2::ReturnCode +/// +template< fapi2::TargetType T, typename L > +inline bool poll(const fapi2::Target<T>& i_target, + const poll_parameters i_params, + L i_fn) +{ + FAPI_DBG("%s polling initial delay %luns(%lusc) poll %luns(%lusc) %lu iters", + mss::c_str(i_target), i_params.iv_initial_delay, i_params.iv_initial_sim_delay, + i_params.iv_delay, i_params.iv_sim_delay, i_params.iv_poll_count); + + // We know to wait this long before polling + FAPI_TRY( fapi2::delay(i_params.iv_initial_delay, i_params.iv_initial_sim_delay) ); + + for ( size_t l_poll_limit = i_params.iv_poll_count; l_poll_limit > 0; --l_poll_limit ) + { + if (i_fn()) + { + FAPI_DBG("%s polling finished. %d iterations remaining" , mss::c_str(i_target), l_poll_limit); + return true; + } + + FAPI_TRY( fapi2::delay(i_params.iv_delay, i_params.iv_sim_delay) ); + } + + // If we're here, we ran out of poll iterations + FAPI_INF("%s WARNING: Timeout on polling", mss::c_str(i_target)); + return false; + +fapi_try_exit: + FAPI_ERR("mss::poll() hit an error in fapi2::delay"); + return false; +} + } #endif diff --git a/src/import/generic/memory/lib/utils/shared/mss_generic_consts.H b/src/import/generic/memory/lib/utils/shared/mss_generic_consts.H index ac7b104bd..1710a6181 100644 --- a/src/import/generic/memory/lib/utils/shared/mss_generic_consts.H +++ b/src/import/generic/memory/lib/utils/shared/mss_generic_consts.H @@ -43,6 +43,42 @@ namespace mss { /// +/// @brief Common constants +/// +enum common_consts +{ + DEFAULT_POLL_LIMIT = 50, ///< the number of poll attempts in the event we can't calculate another +}; + +/// +/// @brief Common timings +/// +enum common_timings +{ + DELAY_1NS = 1, + DELAY_10NS = 10 , ///< general purpose 10 ns delay for HW mode + DELAY_100NS = 100, ///< general purpose 100 ns delay for HW mode + DELAY_1US = 1000, ///< general purpose 1 usec delay for HW mode + DELAY_10US = 10000, ///< general purpose 1 usec delay for HW mode + DELAY_100US = 100000, ///< general purpose 100 usec delay for HW mode + DELAY_1MS = 1000000, ///< general purpose 1 ms delay for HW mode +}; + +/// +/// @brief Common conversions +/// +enum conversions +{ + CONVERT_PS_IN_A_NS = 1000, ///< 1000 pico in an nano + CONVERT_PS_IN_A_US = 1000000, ///< 1000000 picos in a micro + MHZ_TO_KHZ = 1000, + SEC_IN_HOUR = 60 * 60, ///< seconds in an hour, used for scrub times + NIBBLES_PER_BYTE = 2, + BITS_PER_NIBBLE = 4, + BITS_PER_BYTE = 8, +}; + +/// /// @brief FFDC generic codes /// enum generic_ffdc_codes @@ -191,27 +227,6 @@ enum guard_band : uint16_t }// spd -enum conversions -{ - NIBBLES_PER_BYTE = 2, - BITS_PER_NIBBLE = 4, - BITS_PER_BYTE = 8, - - CONVERT_PS_IN_A_NS = 1000, ///< 1000 pico in an nano - CONVERT_PS_IN_A_US = 1000000, ///< 1000000 picos in a micro - - DELAY_1NS = 1, - DELAY_10NS = 10 , ///< general purpose 10 ns delay for HW mode - DELAY_100NS = 100, ///< general purpose 100 ns delay for HW mode - DELAY_1US = 1000, ///< general purpose 1 usec delay for HW mode - DELAY_10US = 10000, ///< general purpose 1 usec delay for HW mode - DELAY_100US = 100000, ///< general purpose 100 usec delay for HW mode - DELAY_1MS = 1000000, ///< general purpose 1 ms delay for HW mode - - MHZ_TO_KHZ = 1000, - SEC_IN_HOUR = 60 * 60, ///< seconds in an hour, used for scrub times -}; - }// mss #endif |