summaryrefslogtreecommitdiffstats
path: root/src/import/chips/p9/procedures/hwp/memory/lib/utils/conversions.H
diff options
context:
space:
mode:
authorBrian Silver <bsilver@us.ibm.com>2016-10-05 10:47:42 -0500
committerDaniel M. Crowell <dcrowell@us.ibm.com>2016-10-07 00:46:48 -0400
commitce9e02bee2a6918d0917dec721e8f1ed3706591a (patch)
tree3eeb5cea80a97bab31c158ede1534bd6a4e4193b /src/import/chips/p9/procedures/hwp/memory/lib/utils/conversions.H
parent985a75fbd3ae20fe7976a6c77d75fddfafdd669a (diff)
downloadtalos-hostboot-ce9e02bee2a6918d0917dec721e8f1ed3706591a.tar.gz
talos-hostboot-ce9e02bee2a6918d0917dec721e8f1ed3706591a.zip
Add support for ATTR_MSS_VPD_MT_WINDAGE_RD_CTR
Update ps_to_cycles conversion for negative numbers Update fake_vpd to have correct value for windgage Change-Id: Idbb2a3b661ae06d7643f5d838a2a65b2d12248ba Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/30732 Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com> Reviewed-by: STEPHEN GLANCY <sglancy@us.ibm.com> Reviewed-by: Louis Stermole <stermole@us.ibm.com> Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com> Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/30748 Reviewed-by: Hostboot Team <hostboot@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/import/chips/p9/procedures/hwp/memory/lib/utils/conversions.H')
-rw-r--r--src/import/chips/p9/procedures/hwp/memory/lib/utils/conversions.H21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/import/chips/p9/procedures/hwp/memory/lib/utils/conversions.H b/src/import/chips/p9/procedures/hwp/memory/lib/utils/conversions.H
index c7a3589b7..9de5b3e8c 100644
--- a/src/import/chips/p9/procedures/hwp/memory/lib/utils/conversions.H
+++ b/src/import/chips/p9/procedures/hwp/memory/lib/utils/conversions.H
@@ -171,18 +171,21 @@ inline uint64_t cycles_to_simcycles( const uint64_t i_cycles )
///
/// @brief Return the number of cycles contained in a count of picoseconds
+/// @tparam T the target type from which to get the mt/s
+/// @tparam OT the output type, derrived from the parameters
/// @param[in] i_target target for the frequency attribute
/// @param[in] i_ps the number of picoseconds to convert
/// @return uint64_t, the number of cycles
///
-template< fapi2::TargetType T >
-inline uint64_t ps_to_cycles(const fapi2::Target<T>& i_target, const uint64_t i_ps)
+template< fapi2::TargetType T, typename OT >
+inline OT ps_to_cycles(const fapi2::Target<T>& i_target, const OT i_ps)
{
- // The frequency in mHZ
+ // The frequency in MT/s
uint64_t l_freq = 0;
- uint64_t l_divisor = 0;
- uint64_t l_quotient = 0;
- uint64_t l_remainder = 0;
+ OT l_divisor = 0;
+ OT l_quotient = 0;
+ OT l_remainder = 0;
+ OT l_rounder = (i_ps < 0) ? -1 : 1;
FAPI_TRY( mss::freq( find_target<fapi2::TARGET_TYPE_MCBIST>(i_target), l_freq) );
@@ -194,13 +197,13 @@ inline uint64_t ps_to_cycles(const fapi2::Target<T>& i_target, const uint64_t i_
// Hoping the compiler figures out how to do these together.
FAPI_TRY( freq_to_ps(l_freq, l_divisor) );
- l_quotient = i_ps / ((l_divisor == 0) ? 1 : l_divisor);
+ l_quotient = i_ps / ((l_divisor == 0) ? l_rounder : l_divisor);
l_remainder = i_ps % l_divisor;
// Make sure we add a cycle if there wasn't an even number of cycles in the input
- FAPI_INF("converting %llups to %llu cycles", i_ps, l_quotient + (l_remainder == 0 ? 0 : 1));
+ FAPI_INF("converting %dps to %d cycles", i_ps, l_quotient + (l_remainder == 0 ? 0 : l_rounder));
- return l_quotient + (l_remainder == 0 ? 0 : 1);
+ return l_quotient + (l_remainder == 0 ? 0 : l_rounder);
fapi_try_exit:
// We simply can't work if we can't get the frequency or
OpenPOWER on IntegriCloud