From 1b30508467a64e4d89312fd6da3ab7bd825eb7d3 Mon Sep 17 00:00:00 2001 From: Santosh Puranik Date: Thu, 26 Nov 2015 01:46:26 -0600 Subject: Plat API to apply EQ/EC gards Change-Id: Ifd019f0dbad3f817e681669a31def5f41c03ed41 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/22345 Tested-by: Jenkins Server Reviewed-by: Sachin Gupta Reviewed-by: Gregory S. Still --- hwpf/include/fapi2_target.H | 6 ++--- hwpf/include/plat/plat_target_utils.H | 8 ++++-- hwpf/include/plat/target.H | 7 +++++ hwpf/src/plat/target.C | 51 ++++++++++++++++++++++++++++++++++- 4 files changed, 66 insertions(+), 6 deletions(-) (limited to 'hwpf') diff --git a/hwpf/include/fapi2_target.H b/hwpf/include/fapi2_target.H index d2eabf37..f8c458b2 100644 --- a/hwpf/include/fapi2_target.H +++ b/hwpf/include/fapi2_target.H @@ -278,9 +278,9 @@ namespace fapi2 /// @brief Set the target functional setting /// @return Bool whether functional /// - inline void setFunctional(void) + inline void setFunctional(const bool &i_state) { - this->iv_handle.fields.functional = 1; + this->iv_handle.fields.functional = (i_state) ? 1 : 0; return; } @@ -355,7 +355,7 @@ namespace fapi2 #endif } fields; // Union Constructor -// iv_handle(V i_value = 0):value(i_value) {} + iv_handle(V i_value = 0):value(i_value) {} } iv_handle; }; diff --git a/hwpf/include/plat/plat_target_utils.H b/hwpf/include/plat/plat_target_utils.H index e1e360c0..49f1af40 100644 --- a/hwpf/include/plat/plat_target_utils.H +++ b/hwpf/include/plat/plat_target_utils.H @@ -39,10 +39,14 @@ namespace fapi2 /// @brief Function to initialize the G_targets vector based on partial good /// attributes ReturnCode plat_TargetsInit(); - + + /// @brief Function to apply any gard records set (via + // ATTR_EQ_GARD/ATTR_EC_GARD) to mark corresponding targets non functional + ReturnCode plat_ApplyGards(); + /// @brief Function to initialize the G_targets vector based on partial good /// attributes Target plat_getChipTarget(); -} +} #endif diff --git a/hwpf/include/plat/target.H b/hwpf/include/plat/target.H index 2f1ec73d..db38d912 100644 --- a/hwpf/include/plat/target.H +++ b/hwpf/include/plat/target.H @@ -59,6 +59,13 @@ namespace fapi2 (K == TARGET_TYPE_EQ) ) != true, "TARGET_TYPE_CORE and TARGET_TYPE_EQ cannot be specified at the same time"); + // Already formed target handle? + if(static_cast(Value).fields.type != 0) + { + this->iv_handle.value = Value; + return; + } + this->iv_handle.value = 0; if(K & TARGET_TYPE_PROC_CHIP) { diff --git a/hwpf/src/plat/target.C b/hwpf/src/plat/target.C index 846fab64..41d48aaf 100644 --- a/hwpf/src/plat/target.C +++ b/hwpf/src/plat/target.C @@ -272,7 +272,7 @@ namespace fapi2 if (b_present) { i_chiplet_target.setPresent(); - i_chiplet_target.setFunctional(); + i_chiplet_target.setFunctional(true); } else { @@ -425,5 +425,54 @@ fapi_try_exit: return ((fapi2::Target)G_vec_targets.at(0)); } + /// @brief Function to apply any gard records set (via + // ATTR_EQ_GARD/ATTR_EC_GARD) to mark corresponding targets non functional + ReturnCode plat_ApplyGards() + { + uint8_t l_eqGards = 0; + uint32_t l_ecGards = 0; + static const uint32_t l_mask = 0x80000000; + fapi2::Target l_chip = plat_getChipTarget(); + + // Read the EQ and EC gard attributes from the chip target + FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_EQ_GARD, l_chip, l_eqGards)); + FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_EC_GARD, l_chip, l_ecGards)); + + FAPI_DBG("ATTR_EQ_GARD:: 0x%08x", l_eqGards); + FAPI_DBG("ATTR_EC_GARD:: 0x%08x", l_ecGards); + + // Normalize the values read from the attributes (they are right aligned) + l_eqGards <<= ((sizeof(l_eqGards) * 8) - EQ_TARGET_COUNT); + l_ecGards <<= ((sizeof(l_ecGards) * 8) - CORE_TARGET_COUNT); + + // Iterate over the bits in EQ and EC gards, if set, mark the + // corresponding target non-functional + // TODO: Need to mark corresponding EX targets non-functional when we + // start supporting EX targets in the global target vector + for(uint32_t l_idx = 0; l_idx < EQ_TARGET_COUNT; ++l_idx) + { + if((l_mask >> l_idx) & (((uint32_t)(l_eqGards)) << 24)) + { + FAPI_DBG("Making %d'th EQ non-functional", l_idx); + // EQ chiplet l_idx is to be marked non-functional + fapi2::Target l_target = G_vec_targets.at(l_idx + EQ_TARGET_OFFSET); + l_target.setFunctional(false); + G_vec_targets.at(l_idx + EQ_TARGET_OFFSET) = l_target.get(); + } + } + + for(uint32_t l_idx = 0; l_idx < CORE_TARGET_COUNT; ++l_idx) + { + if((l_mask >> l_idx) & (l_ecGards)) + { + // EC chiplet l_idx is to be marked non-functional + fapi2::Target l_target = G_vec_targets.at(l_idx + CORE_TARGET_OFFSET); + l_target.setFunctional(false); + G_vec_targets.at(l_idx + CORE_TARGET_OFFSET) = l_target.get(); + } + } +fapi_try_exit: + return fapi2::current_err; + } } // fapi2 -- cgit v1.2.1