From 9cb883e5647c2e02d07fa49d93ea9dbbfd4443d6 Mon Sep 17 00:00:00 2001 From: Santosh Puranik Date: Wed, 7 Dec 2016 03:19:35 -0600 Subject: Specialization of getParent for compound targets Change-Id: I14f9a99a4f645d9560a96503fc3941abc18c3c04 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/33516 Tested-by: Jenkins Server Tested-by: FSP CI Jenkins Reviewed-by: Santosh S. Puranik --- src/hwpf/include/plat/plat_target.H | 8 ++++++++ src/hwpf/include/plat/target.H | 39 +++++++++++++++++++++++++------------ src/hwpf/src/plat/target.C | 35 +++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 12 deletions(-) (limited to 'src/hwpf') diff --git a/src/hwpf/include/plat/plat_target.H b/src/hwpf/include/plat/plat_target.H index 14df2ab8..45a213a5 100644 --- a/src/hwpf/include/plat/plat_target.H +++ b/src/hwpf/include/plat/plat_target.H @@ -169,6 +169,14 @@ namespace fapi2 fields.present = true; } + /// + /// @brief Get this target's parent + /// + /// @param [in] The fapi2 type of the requested parent + /// @return Plat target handle to the parent target + /// + plat_target_handle getParent(const TargetType i_parentType) const; + /// /// @brief Get this target's children /// diff --git a/src/hwpf/include/plat/target.H b/src/hwpf/include/plat/target.H index c7baef55..a204a08c 100644 --- a/src/hwpf/include/plat/target.H +++ b/src/hwpf/include/plat/target.H @@ -178,14 +178,13 @@ namespace fapi2 template inline Target Target::getParent(void) const { - static_assert((((K == TARGET_TYPE_EQ) || - (K == TARGET_TYPE_CORE) || - (K == TARGET_TYPE_MCBIST) || - (K == TARGET_TYPE_PERV) || - (K == TARGET_TYPE_EX) || - (K == TARGET_TYPE_PROC_CHIP) || - (K == (TARGET_TYPE_PROC_CHIP | TARGET_TYPE_EQ)) || - (K == (TARGET_TYPE_PROC_CHIP | TARGET_TYPE_CORE)) || + constexpr TargetType TARGET_TYPE_PROC_CHILDREN = + TARGET_TYPE_EQ | TARGET_TYPE_PERV | TARGET_TYPE_EX | + TARGET_TYPE_MCBIST | TARGET_TYPE_CORE | + TARGET_TYPE_MCS | TARGET_TYPE_PROC_CHIP; + + static_assert((( + ((K & TARGET_TYPE_PROC_CHILDREN) != TARGET_TYPE_NONE) || (K == TARGET_TYPE_ALL)) && ((T == TARGET_TYPE_EQ) || (T == TARGET_TYPE_EX) || @@ -199,10 +198,9 @@ namespace fapi2 "Invalid parent for EQ target, must be PERV or " "PROC_CHIP"); - static_assert(!((K == TARGET_TYPE_ALL) && - (T != TARGET_TYPE_PROC_CHIP)), - "Invalid parent for ALL target, must be " - "PROC_CHIP"); + static_assert(!((T == TARGET_TYPE_PROC_CHIP) && + ((K & TARGET_TYPE_PROC_CHILDREN) == TARGET_TYPE_NONE)), + "Parent proc chip invalid for this target type"); static_assert(!((K == TARGET_TYPE_MCBIST) && (T != TARGET_TYPE_PERV) && @@ -252,6 +250,23 @@ namespace fapi2 } } + /// + /// @brief Get this target's immediate parent - specialization for compound + // target (PROC_CHIP | CORE | EX) + /// @tparam T The type of the parent + /// @return Target a target representing the parent + /// + template<> + template + Target + Target::getParent(void) const + { + static_assert(((T == TARGET_TYPE_PROC_CHIP) || (T == TARGET_TYPE_EQ)), + "Wrong parent target type"); + return static_cast(get()).getParent(T); + } + /// @brief Get this target's children - handles EQ/EX/EC conversions /// @tparam K The type of parent /// @tparam V The plat target handle type diff --git a/src/hwpf/src/plat/target.C b/src/hwpf/src/plat/target.C index 301e8534..dbf8413b 100644 --- a/src/hwpf/src/plat/target.C +++ b/src/hwpf/src/plat/target.C @@ -162,6 +162,41 @@ namespace fapi2 return l_targetType; } + plat_target_handle_t plat_target_handle_t::getParent( + const TargetType i_parentType) const + { + plat_target_handle_t l_handle; + switch(i_parentType) + { + case TARGET_TYPE_PROC_CHIP: + l_handle = G_vec_targets[CHIP_TARGET_OFFSET]; + break; + case TARGET_TYPE_PERV: + assert(fields.type & PPE_TARGET_TYPE_PERV); + l_handle = *this; + break; + case TARGET_TYPE_EX: + assert(fields.type & PPE_TARGET_TYPE_CORE); + l_handle = G_vec_targets + [(fields.type_target_num / EX_PER_QUAD) + EX_TARGET_OFFSET]; + break; + case TARGET_TYPE_EQ: + assert(fields.type & + (PPE_TARGET_TYPE_EX | PPE_TARGET_TYPE_CORE)); + { + uint32_t l_perQuad = (fields.type & PPE_TARGET_TYPE_EX) ? + EX_PER_QUAD : CORES_PER_QUAD; + l_handle = G_vec_targets + [(fields.type_target_num / l_perQuad) + + EX_TARGET_OFFSET]; + } + break; + default: + assert(false); + } + return l_handle; + } + void plat_target_handle_t::getChildren(const TargetType i_parentType, const TargetType i_childType, const plat_target_type_t i_platType, -- cgit v1.2.1