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/memory/lib/utils/poll.H | |
| parent | 814860ea37f68c1d6637c4262d1d44ce31b04222 (diff) | |
| download | blackbird-hostboot-4b6dde2ad7d0cd03f905031ea2355a02a1992d39.tar.gz blackbird-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/memory/lib/utils/poll.H')
| -rw-r--r-- | src/import/generic/memory/lib/utils/poll.H | 67 |
1 files changed, 58 insertions, 9 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 |

