diff options
author | crgeddes <crgeddes@us.ibm.com> | 2016-02-16 15:14:03 -0600 |
---|---|---|
committer | William G. Hoffa <wghoffa@us.ibm.com> | 2016-04-05 15:12:57 -0400 |
commit | e8fdc1c11a1ee3c9406b75ebb45b619371e60182 (patch) | |
tree | e4d6c6cc53cf2e122b92c790d7d9790aeed05700 /src/include/usr/fapi2 | |
parent | 6e0d21f16e8153125f8dbd2a8feb4ce56ff54e39 (diff) | |
download | talos-hostboot-e8fdc1c11a1ee3c9406b75ebb45b619371e60182.tar.gz talos-hostboot-e8fdc1c11a1ee3c9406b75ebb45b619371e60182.zip |
Add getOtherEnd to fapi2::Target
RTC:129517
Change-Id: I7270b194b609daf8e547313cf73a640e4adc48aa
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/21873
Tested-by: Jenkins Server
Tested-by: FSP CI Jenkins
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Reviewed-by: Thi N. Tran <thi@us.ibm.com>
Reviewed-by: Richard J. Knight <rjknight@us.ibm.com>
Reviewed-by: William G. Hoffa <wghoffa@us.ibm.com>
Diffstat (limited to 'src/include/usr/fapi2')
-rw-r--r-- | src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H | 5 | ||||
-rw-r--r-- | src/include/usr/fapi2/target.H | 149 |
2 files changed, 146 insertions, 8 deletions
diff --git a/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H b/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H index c737ca692..730e809f7 100644 --- a/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H +++ b/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H @@ -48,6 +48,8 @@ namespace fapi2 MOD_FAPI2_PLAT_GET_PARENT_TEST = 0x05, MOD_FAPI2_PLAT_GET_CHILDREN_TEST = 0x06, MOD_FAPI2_VERIFYCFAMACCESSTARGET = 0x07, + MOD_FAPI2_PLAT_GET_OTHER_END_TEST = 0x08, + MOD_FAPI2_PLAT_GET_OTHER_END = 0x09, }; /** @@ -90,6 +92,9 @@ namespace fapi2 RC_SBE_NO_PROC_FOUND = FAPI2_COMP_ID | 0x21, RC_INVALID_CHILD_COUNT = FAPI2_COMP_ID | 0x22, RC_UNIT_NO_PERV_FOUND = FAPI2_COMP_ID | 0x23, + RC_INCORRECT_OTHER_END = FAPI2_COMP_ID | 0x24, + RC_FOUND_TOO_MANY_PEERS = FAPI2_COMP_ID | 0x25, + RC_FOUND_NO_PEERS = FAPI2_COMP_ID | 0x26, // HWP generated errors RC_HWP_GENERATED_ERROR = HWPF_COMP_ID | 0x0f, diff --git a/src/include/usr/fapi2/target.H b/src/include/usr/fapi2/target.H index 5f21eb3b3..068fe2586 100644 --- a/src/include/usr/fapi2/target.H +++ b/src/include/usr/fapi2/target.H @@ -39,15 +39,27 @@ #include <stdio.h> #include <stdint.h> #include <vector> -#include <fapi2_target.H> #include <target_types.H> +#include <return_code_defs.H> +#include <fapi2_target.H> + +#include <hwpf_fapi2_reasoncodes.H> // HB platform support #include <fapiPlatTrace.H> #include <targeting/common/target.H> #include <targeting/common/commontargeting.H> +#include <targeting/common/targetservice.H> #include <targeting/common/utilFilter.H> +#include <targeting/common/predicates/predicatectm.H> +#include <targeting/common/predicates/predicateisfunctional.H> + +//@TODO RTC:150675 get error info from getOtherEnd fails +//#include <errl/errlentry.H> +//#include <errl/errlmanager.H> + + namespace PLAT_TARGET { @@ -716,10 +728,10 @@ FAPI_DBG(ENTER_MRK "getChildren. Type 0x%08x State:0x%08x", T, i_state); /// /// @brief Get the target at the other end of a bus - dimm included -/// @tparam T The type of the parent +/// @tparam T The type of the the other end /// @tparam K The type of target of which this is called /// @tparam V the type of the target's Value -/// @param[in] i_state The desired TargetState of the children +/// @param[in] i_state The desired TargetState of the other end /// @return Target<T> a target representing the thing on the other end /// @note Can be easily changed to a vector if needed /// @@ -728,11 +740,132 @@ template<TargetType T> inline Target<T> Target<K, V>::getOtherEnd(const TargetState i_state) const { - //@TODO RTC:129517 - // Implementation note: cast to a composite of - // bus types and the compiler will check if this is - // a good function at compile time - return Target<T>(); + fapi2::Target<T> l_target; + this->getOtherEnd<T>( l_target, i_state); + + return l_target; + +} + +/// +/// @brief Get the target at the other end of a bus +/// @tparam T The type of the target on the other end +/// @param[out] o_target A target representing the thing on the other end +/// @param[in] i_state The desired TargetState of the other end +/// @return FAPI2_RC_SUCCESS if OK, platforms will return a non-success +/// ReturnCode in the event of failure +/// @note o_target is only valid if return is FAPI2_RC_SUCCESS +/// +template<TargetType K, typename V> +template<TargetType T> +inline fapi2::ReturnCodes +Target<K, V>::getOtherEnd(fapi2::Target<T>& o_target, + const TargetState i_state) const +{ + ReturnCodes l_rc; +// errlHndl_t l_errl = NULL; + TARGETING::TargetHandleList l_peerTargetList; + TARGETING::TYPE requiredPeerType = fapi2::convertFapi2TypeToTargeting(T); + TARGETING::CLASS targetClass = TARGETING::CLASS_NA; + + //TODO RTC:148934 add static_asserts for correct types + switch(requiredPeerType) + { + case TARGETING::TYPE_XBUS : + targetClass = TARGETING::CLASS_UNIT; break; + case TARGETING::TYPE_OBUS : + targetClass = TARGETING::CLASS_UNIT; break; + case TARGETING::TYPE_DMI : + targetClass = TARGETING::CLASS_UNIT; break; + case TARGETING::TYPE_DIMM : + targetClass = TARGETING::CLASS_LOGICAL_CARD; break; + case TARGETING::TYPE_MEMBUF : + targetClass = TARGETING::CLASS_CHIP; break; + default: + break; + } + TARGETING::PredicateCTM l_peerFilter(targetClass); + + if(i_state == TARGET_STATE_FUNCTIONAL) + { + TARGETING::PredicateIsFunctional l_funcFilter; + TARGETING::PredicatePostfixExpr l_funcAndpeerFilter; + l_funcAndpeerFilter.push(&l_peerFilter).push(&l_funcFilter).And(); + getPeerTargets( l_peerTargetList, // list of targets on other end + static_cast<TARGETING::Target*>(this->get()),//To this target + NULL/*&l_peerFilter*/, // Don't need to filter peers + &l_funcAndpeerFilter);//filter results to be the right class & state + } + else if(i_state == TARGET_STATE_PRESENT) + { + TARGETING::PredicatePostfixExpr l_presAndpeerFilter; + l_presAndpeerFilter.push(&l_peerFilter); + + getPeerTargets( l_peerTargetList, // list of targets on other end + static_cast<TARGETING::Target*>(this->get()), //to this target + NULL, //No need to filter peers + &l_presAndpeerFilter);//filter results to be the right class & state + } + + fapi2::Target<T> fapi2_peerTarget = NULL; + + if(l_peerTargetList.size() == 0) + { + l_rc = FAPI2_RC_FALSE; + //@TODO RTC:150675 get error info from getOtherEnd fails +#if 0 + /*@ + * @errortype ERRORLOG::ERRL_SEV_UNRECOVERABLE + * @moduleid fapi2::MOD_FAPI2_PLAT_GET_OTHER_END + * @reasoncode fapi2::RC_FOUND_NO_PEERS + * @userdata1[0:31] Unused + * @userdata1[32:63] Unused + * @userdata2 Unused + * @devdesc Unable to resolve other end of xbus + */ + l_errl = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE, + fapi2::MOD_FAPI2_PLAT_GET_OTHER_END, + fapi2::RC_FOUND_NO_PEERS, + NULL, + NULL, + true/*SW Error*/); + errlCommit(l_errl,FAPI2_COMP_ID); + // Add the error log pointer as data to the ReturnCode + l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl)); +#endif + } + else if(l_peerTargetList.size() > 1) + { + l_rc = FAPI2_RC_FALSE; + //@TODO RTC:150675 get error info from getOtherEnd fails +#if 0 + /*@ + * @errortype ERRORLOG::ERRL_SEV_UNRECOVERABLE + * @moduleid fapi2::MOD_FAPI2_PLAT_GET_OTHER_END + * @reasoncode fapi2::RC_FOUND_TOO_MANY_PEERS + * @userdata1[0:31] Unused + * @userdata1[32:63] Unused + * @userdata2 Unused + * @devdesc Unable to resolve other end of xbus + */ + l_errl = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE, + fapi2::MOD_FAPI2_PLAT_GET_OTHER_END, + fapi2::RC_FOUND_TOO_MANY_PEERS, + NULL, + NULL, + true/*SW Error*/); + errlCommit(l_errl,FAPI2_COMP_ID); + // Add the error log pointer as data to the ReturnCode + l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_err)); +#endif + } + else + { + fapi2_peerTarget = fapi2::Target<T>(l_peerTargetList[0]); + } + o_target = fapi2_peerTarget; + + return l_rc; } |