diff options
author | Nick Bofferding <bofferdn@us.ibm.com> | 2013-03-29 00:01:56 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2013-03-29 13:41:30 -0500 |
commit | 467ae10a804451a843409e6b94a3c0108c083939 (patch) | |
tree | e9ccf6beda47303d5df79553bb5c402365431557 /src | |
parent | 192f986571b47f2f3d34556eebd089d9ad55b456 (diff) | |
download | talos-hostboot-467ae10a804451a843409e6b94a3c0108c083939.tar.gz talos-hostboot-467ae10a804451a843409e6b94a3c0108c083939.zip |
Support generic PEER_TARGET navigation
- Updated attribute compiler to lay down FSP specific PEER_TARGETS
- Added common predicate to filter targets with specific value for attribute
- Added generic PEER_TARGET navigation facility to filter utilities
- Added support for platform specific attribute accessor specialization
- Added target function to return target based on HUID
Change-Id: I190087ee7fb24e80185bc955bd994ee14512a704
RTC: 41735
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/3796
Reviewed-by: Brian H. Horton <brianh@linux.ibm.com>
Tested-by: Jenkins Server
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/include/usr/targeting/adapters/targetadapter.H | 36 | ||||
-rw-r--r-- | src/include/usr/targeting/common/predicates/predicateattrval.H | 165 | ||||
-rw-r--r-- | src/include/usr/targeting/common/predicates/predicates.H | 46 | ||||
-rw-r--r-- | src/include/usr/targeting/common/target.H | 66 | ||||
-rw-r--r-- | src/include/usr/targeting/common/utilFilter.H | 52 | ||||
-rw-r--r-- | src/usr/targeting/common/target.C | 27 | ||||
-rw-r--r-- | src/usr/targeting/common/utilFilter.C | 147 | ||||
-rwxr-xr-x | src/usr/targeting/common/xmltohb/xmltohb.pl | 85 |
8 files changed, 567 insertions, 57 deletions
diff --git a/src/include/usr/targeting/adapters/targetadapter.H b/src/include/usr/targeting/adapters/targetadapter.H new file mode 100644 index 000000000..7068fc1c2 --- /dev/null +++ b/src/include/usr/targeting/adapters/targetadapter.H @@ -0,0 +1,36 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/targeting/adapters/targetadapter.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2013 */ +/* */ +/* p1 */ +/* */ +/* Object Code Only (OCO) source materials */ +/* Licensed Internal Code Source Materials */ +/* IBM HostBoot Licensed Internal Code */ +/* */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ +/* */ +/* Origin: 30 */ +/* */ +/* IBM_PROLOG_END_TAG */ + +/** + * @file targeting/adapters/targetadapter.H + * + * @brief Provides platform specific attribute accessor template + * specializations. + * + * @warning Must only be included by target.H + * + * @note The contents of this file are inserted inline into middle of + * target.H and purposefully omit include guards. Only change this + * file unless you know what you are doing! + */ + diff --git a/src/include/usr/targeting/common/predicates/predicateattrval.H b/src/include/usr/targeting/common/predicates/predicateattrval.H new file mode 100644 index 000000000..7d62ea5ea --- /dev/null +++ b/src/include/usr/targeting/common/predicates/predicateattrval.H @@ -0,0 +1,165 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/targeting/common/predicates/predicateattrval.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2013 */ +/* */ +/* p1 */ +/* */ +/* Object Code Only (OCO) source materials */ +/* Licensed Internal Code Source Materials */ +/* IBM HostBoot Licensed Internal Code */ +/* */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ +/* */ +/* Origin: 30 */ +/* */ +/* IBM_PROLOG_END_TAG */ + +#ifndef __TARGETING_COMMON_PREDICATEATTRVAL_H +#define __TARGETING_COMMON_PREDICATEATTRVAL_H + +/** + * @file targeting/common/predicates/predicateattrval.H + * + * @brief Interface and implementation for a predicate which filters a target + * based on whether it possesses a given attribute, and if so, the + * attribute's value + */ + +//****************************************************************************** +// Includes +//****************************************************************************** + +// STD + +// Other Host Boot Components + +// Targeting Component +#include <targeting/common/target.H> +#include <targeting/common/attributes.H> +#include <targeting/common/predicates/predicatebase.H> + +//****************************************************************************** +// Interface and implementation +//****************************************************************************** + +namespace TARGETING +{ + +#define TARG_NAMESPACE "TARGETING::" +#define TARG_CLASS "PredicateAttrVal::" + +class Target; + +/** + * @brief Templated predicate class which filters a target based on whether it + * possesses a given attribute, and if so, the attribute's value + */ +template<const ATTRIBUTE_ID A> +class PredicateAttrVal : public PredicateBase +{ + public: + + /** + * @brief Constructor which configures the predicate to filter targets + * based on the existence of the attribute type given by the "A" + * template parameter, and the input criteria + * + * @param[in] i_value + * Assuming the target being filtered has the attribute given by + * the "A" template parameter, the value of that attribute + * that will cause the predicate to register a match. If the + * i_invertSearch parameter is the non-default value of true, + * the predicate registers a match when the value of the + * attribute != i_value + * @param[in] i_invertSearch + * Assuming the attribute is present, this determines what check + * needs to be performed on i_value. + * If false (default), the predicate registers a match when the + * attribute's value is i_value; If false, the predicate registers + * a match when the attribute's value is != i_value + */ + PredicateAttrVal( + const typename AttributeTraits<A>::Type& i_value, + const bool i_invertSearch = false) + : iv_value(i_value), iv_invertSearch(i_invertSearch) + { + } + + /** + * @brief Destroys the attribute value predicate + */ + virtual ~PredicateAttrVal() + { + } + + /** + * @brief Returns whether target has an attribute, given by template + * parameter "A", whose value matches the filter's configured + * criteria + * + * @par Detailed Description: + * Returns whether target has an attribute, given by template + * parameter "A", whose value matches the filter's configured + * value. Note that the target must have the "A" attribute, + * otherwise the predicate will always return false. + * Assuming the target has the "A" attribute, if the attribute's + * value matches and the search is not inverted, the predicate + * returns true. If the attribute's value does not match but the + * search is inverted, the predicate also returns true. + * Otherwise, the predicate returns false. See + * PredicateBase class for parameter/return description. + * + * @param[in] i_pTarget + * Target handle pointing to the target to compare to. Must + * not be NULL. + * + * @return bool indicating whether the target matches or not + */ + virtual bool operator()( + const Target* i_pTarget) const + { + typename AttributeTraits<A>::Type actual; // not set intentionally + bool l_match = i_pTarget->tryGetAttr<A>(actual); + if(iv_invertSearch == true) + { + l_match = (l_match && !(iv_value == actual)); + } + else + { + l_match = (l_match && (iv_value == actual)); + } + return l_match; + } + + private: + + /** + * @brief Value of attribute to compare for each target filter is + * applied to + */ + typename AttributeTraits<A>::Type iv_value; + + // Whether to look for attribute whose value matches iv_value (false) or + // an attribute whose value does not match iv_value (true) for target + // being filtered + bool iv_invertSearch; + + /** + * @brief Disable copy/assignment operators + */ + TARG_DISABLE_COPY_AND_ASSIGNMENT_OPERATORS(PredicateAttrVal); +}; + +#undef TARG_CLASS +#undef TARG_NAMESPACE + +} // End namespace TARGETING + +#endif // __TARGETING_COMMON_PREDICATEATTRVAL_H diff --git a/src/include/usr/targeting/common/predicates/predicates.H b/src/include/usr/targeting/common/predicates/predicates.H index e0dbdf248..85b75d1f9 100644 --- a/src/include/usr/targeting/common/predicates/predicates.H +++ b/src/include/usr/targeting/common/predicates/predicates.H @@ -1,26 +1,25 @@ -/* IBM_PROLOG_BEGIN_TAG - * This is an automatically generated prolog. - * - * $Source: src/include/usr/targeting/common/predicates/predicates.H $ - * - * IBM CONFIDENTIAL - * - * COPYRIGHT International Business Machines Corp. 2012 - * - * p1 - * - * Object Code Only (OCO) source materials - * Licensed Internal Code Source Materials - * IBM HostBoot Licensed Internal Code - * - * The source code for this program is not published or other- - * wise divested of its trade secrets, irrespective of what has - * been deposited with the U.S. Copyright Office. - * - * Origin: 30 - * - * IBM_PROLOG_END_TAG - */ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/targeting/common/predicates/predicates.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2012,2013 */ +/* */ +/* p1 */ +/* */ +/* Object Code Only (OCO) source materials */ +/* Licensed Internal Code Source Materials */ +/* IBM HostBoot Licensed Internal Code */ +/* */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ +/* */ +/* Origin: 30 */ +/* */ +/* IBM_PROLOG_END_TAG */ #ifndef __TARGETING_COMMON_PREDICATES_H #define __TARGETING_COMMON_PREDICATES_H @@ -35,6 +34,7 @@ #include <targeting/common/predicates/predicateisfunctional.H> #include <targeting/common/predicates/predicatehwas.H> #include <targeting/common/predicates/predicatepostfixexpr.H> +#include <targeting/common/predicates/predicateattrval.H> // please keep up to date... diff --git a/src/include/usr/targeting/common/target.H b/src/include/usr/targeting/common/target.H index bd37b8a01..a3dbc8041 100644 --- a/src/include/usr/targeting/common/target.H +++ b/src/include/usr/targeting/common/target.H @@ -1,25 +1,25 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: src/include/usr/targeting/target.H $ -// -// IBM CONFIDENTIAL -// -// COPYRIGHT International Business Machines Corp. 2011 -// -// p1 -// -// Object Code Only (OCO) source materials -// Licensed Internal Code Source Materials -// IBM HostBoot Licensed Internal Code -// -// The source code for this program is not published or other- -// wise divested of its trade secrets, irrespective of what has -// been deposited with the U.S. Copyright Office. -// -// Origin: 30 -// -// IBM_PROLOG_END +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/targeting/common/target.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2011,2013 */ +/* */ +/* p1 */ +/* */ +/* Object Code Only (OCO) source materials */ +/* Licensed Internal Code Source Materials */ +/* IBM HostBoot Licensed Internal Code */ +/* */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ +/* */ +/* Origin: 30 */ +/* */ +/* IBM_PROLOG_END_TAG */ #ifndef __TARGETING_COMMON_TARGET_H #define __TARGETING_COMMON_TARGET_H @@ -251,6 +251,24 @@ class Target */ uint8_t * targetFFDC( uint32_t & o_size ) const; + /** + * @brief Returns the target handle referencing a target whose HUID + * matches the caller supplied value + * + * @param[in] i_huid HUID of target to find + * + * @pre Target service must be initialized + * + * @return Target handle referencing a target whose HUID matches the + * caller supplied value + * + * @retval !NULL Target handle referencing a target whose HUID matches + * the caller supplied value. + * @retval NULL No target found whose HUID matches the caller supplied + * value. + */ + Target* getTargetFromHuid(const ATTR_HUID_type i_huid) const; + private: // Private helper interfaces /** @@ -440,6 +458,10 @@ const char* Target::getAttrAsString() const return attrToString<A>(l_attrValue); } +// WARNING: The following #include imports any platform specific template +// specializations for getAttr and tryGetAttr +#include <targeting/adapters/targetadapter.H> + } // End namespace TARGETING #endif // __TARGETING_COMMON_TARGET_H diff --git a/src/include/usr/targeting/common/utilFilter.H b/src/include/usr/targeting/common/utilFilter.H index cd0acfaab..aa69a92c0 100644 --- a/src/include/usr/targeting/common/utilFilter.H +++ b/src/include/usr/targeting/common/utilFilter.H @@ -148,6 +148,58 @@ void getAllLogicalCards( TARGETING::TargetHandleList & o_vector, TYPE i_cardType, bool i_functional = true ); +/** + * @brief Returns the list of targets which is an immediate peer of the source + * target provided by the user. + * + * @par Detailed Description: + * + * Two types of filter provided here as argument - + * a. i_pPeerFilter, constrain the search only to follow PEER_TARGET links for + * leaf targets (of the source target, inclusive) that meet the filter + * criteria. Omitting the filter crosses all leaf targets of the source + * (inclusive) that have PEER_TARGET attributes + * b. i_pResultFilter, constrains the result targets returned, such that after + * crossing a peer link, only the first target ['if any'] matching the + * filter criteria [(searching upwards in the chain of physical parent + * targets)] is returned. Omitting the filter has the side effect of + * returning the target immediately on the other end of a peer link + * + * Filter usage guidelines - + * 1. If source target given by the user suports PEER TARGET Attribute & + * i_pPeerFilter is also provided then a Target list will be prepared by + * going inwards from the source target including the source target. + * If the source target doesn't support PEER Target Attribute & filter is + * provided then list will be prepared by going inwards from the source + * target excluding the source target. + * 2. If i_pResultFilter is NULL, then a Peer Target list which includes all + * Peer Targets of the source target list mentioned above in step 1, will + * be prepared and returned to the user. If i_pResultFilter is not NULL, + * then the filter will applied on the parent chain of all peer target + * found from the step 1 list above (inclusive), that matches the criteria + * + * @param[out] o_peerTargets List of target handles that match the specified + * criteria. This will be cleared in case not already done. + * @param[in] i_pSrcTarget Target from which to search for other targets + * @param[in] i_pPeerFilter to be applied on the target & target leafs that + * has PEER Target Attribute, as provided by user. + * i_pPeerFilter Pointer to a predicate to be evaluated against each + * candidate target (as determined by the source target, type, and + * recursion level parameters). + * @param[in] i_pResultFilter to be applied on self and the Parent chain of + * Peer Targets of the source target & target leaf provided by user + * or evaluated on the basis of the i_pPeerFilter given by user. + * i_pResultFilter Pointer to a predicate to be evaluated against + * each candidate target (as determined by the source target, type, + * and recursion level parameters). + * + * @return N/A + */ +void getPeerTargets( + TARGETING::TargetHandleList& o_peerTargets, + const Target* i_pSrcTarget, + const PredicateBase* i_pPeerFilter = NULL, + const PredicateBase* i_pResultFilter = NULL); } diff --git a/src/usr/targeting/common/target.C b/src/usr/targeting/common/target.C index 60134d156..6e92e53fc 100644 --- a/src/usr/targeting/common/target.C +++ b/src/usr/targeting/common/target.C @@ -41,6 +41,7 @@ #include <targeting/attrrp.H> #include <targeting/common/util.H> #include <targeting/common/trace.H> +#include <targeting/common/predicates/predicateattrval.H> namespace TARGETING { @@ -310,6 +311,32 @@ uint8_t * Target::targetFFDC( uint32_t & o_size ) const #undef TARG_FN } +//****************************************************************************** +// Target::getTargetFromHuid() +//****************************************************************************** + +Target* Target::getTargetFromHuid( + const ATTR_HUID_type i_huid) const +{ + #define TARG_FN "getTargetFromHuid" + Target* l_pTarget = NULL; + + TARGETING::PredicateAttrVal<TARGETING::ATTR_HUID> huidMatches(i_huid); + + TARGETING::TargetRangeFilter targetsWithMatchingHuid( + TARGETING::targetService().begin(), + TARGETING::targetService().end(), + &huidMatches); + if(targetsWithMatchingHuid) + { + // Exactly one target will match the HUID, if any + l_pTarget = *targetsWithMatchingHuid; + } + + return l_pTarget; + #undef TARG_FN +} + #undef TARG_CLASS #undef TARG_NAMESPACE diff --git a/src/usr/targeting/common/utilFilter.C b/src/usr/targeting/common/utilFilter.C index 24e2fc620..d981b6051 100644 --- a/src/usr/targeting/common/utilFilter.C +++ b/src/usr/targeting/common/utilFilter.C @@ -30,6 +30,7 @@ #include <targeting/common/iterators/rangefilter.H> #include <targeting/common/predicates/predicateisfunctional.H> #include <targeting/common/predicates/predicatepostfixexpr.H> +#include <targeting/common/predicates/predicateattrval.H> /** * Miscellaneous Filter Utility Functions @@ -179,24 +180,30 @@ void getAffinityTargets ( TARGETING::TargetHandleList& o_vector, } -void getChildAffinityTargets ( TARGETING::TargetHandleList& o_vector, - const Target * i_target, CLASS i_class, TYPE i_type, - bool i_functional ) +void getChildAffinityTargets( + TARGETING::TargetHandleList& o_vector, + const Target* i_target, + CLASS i_class, + TYPE i_type, + bool i_functional) { getAffinityTargets (o_vector, i_target, i_class, i_type, - TARGETING::TargetService::CHILD_BY_AFFINITY, - i_functional); + TARGETING::TargetService::CHILD_BY_AFFINITY, + i_functional); } -void getParentAffinityTargets ( TARGETING::TargetHandleList& o_vector, - const Target * i_target, CLASS i_class, TYPE i_type, - bool i_functional ) +void getParentAffinityTargets( + TARGETING::TargetHandleList& o_vector, + const Target* i_target, + CLASS i_class, + TYPE i_type, + bool i_functional ) { getAffinityTargets (o_vector, i_target, i_class, i_type, - TARGETING::TargetService::PARENT_BY_AFFINITY, - i_functional); + TARGETING::TargetService::PARENT_BY_AFFINITY, + i_functional); } const Target * getParentChip( const Target * i_pChiplet ) @@ -227,5 +234,125 @@ const Target * getParentChip( const Target * i_pChiplet ) return l_pChip; } +void getPeerTargets( + TARGETING::TargetHandleList& o_peerTargetList, + const Target* i_pSrcTarget, + const PredicateBase* i_pPeerFilter, + const PredicateBase* i_pResultFilter) +{ + #define TARG_FN "getPeerTargets" + TARG_ENTER(); + Target* l_pPeerTarget = NULL; + + if(i_pSrcTarget == NULL) + { + TARG_ASSERT("User tried to call getPeerTargets using NULL Target" + " Handle"); + } + + // Clear the list + o_peerTargetList.clear(); + do + { + // List to maintain all child targets which are found by get associated + // from the Src target with i_pPeerFilter predicate + TARGETING::TargetHandleList l_pSrcTarget_list; + + // Create input master predicate here by taking in the i_pPeerFilter + TARGETING::PredicatePostfixExpr l_superPredicate; + TARGETING::PredicateAttrVal<TARGETING::ATTR_PEER_TARGET> + l_notNullPeerExist(NULL, true); + l_superPredicate.push(&l_notNullPeerExist); + if(i_pPeerFilter) + { + l_superPredicate.push(i_pPeerFilter).And(); + } + + // Check if the i_srcTarget is the leaf node + if(i_pSrcTarget->tryGetAttr<TARGETING::ATTR_PEER_TARGET>(l_pPeerTarget)) + { + if(l_superPredicate(i_pSrcTarget)) + { + // Exactly one Peer Target to Cross + // Put this to input target list + l_pSrcTarget_list.push_back( + const_cast<TARGETING::Target*>(i_pSrcTarget)); + } + else + { + TARG_INF("Input Target provided doesn't have a valid Peer " + "Target Attribute, Returning Empty List"); + break; + } + } + // Not a leaf node, find out all leaf node with valid PEER Target + else + { + (void) TARGETING::targetService().getAssociated( + l_pSrcTarget_list, + i_pSrcTarget, + TARGETING::TargetService::CHILD, + TARGETING::TargetService::ALL, + &l_superPredicate); + } + + // Now we have a list of input targets on which we have to find the peer + // Check if we have a result predicate filter to apply + if(i_pResultFilter == NULL) + { + // Simply get the Peer Target for all Src target in the list and + // return + for(TARGETING::TargetHandleList::const_iterator pTargetIt + = l_pSrcTarget_list.begin(); + pTargetIt != l_pSrcTarget_list.end(); + ++pTargetIt) + { + TARGETING::Target* l_pPeerTgt = + (*pTargetIt)->getAttr<TARGETING::ATTR_PEER_TARGET>(); + o_peerTargetList.push_back(l_pPeerTgt); + } + break; + } + // Result predicate filter is not NULL, we need to apply this predicate + // on each of the PEER Target found on the input target list + else + { + for(TARGETING::TargetHandleList::const_iterator pTargetIt + = l_pSrcTarget_list.begin(); + pTargetIt != l_pSrcTarget_list.end(); + ++pTargetIt) + { + TARGETING::TargetHandleList l_peerTarget_list; + TARGETING::Target* l_pPeerTgt = + (*pTargetIt)->getAttr<TARGETING::ATTR_PEER_TARGET>(); + + // Check whether this target matches the filter criteria + // or we have to look for ALL Parents matching the criteria. + if((*i_pResultFilter)(l_pPeerTgt)) + { + o_peerTargetList.push_back(l_pPeerTgt); + } + else + { + (void) TARGETING::targetService().getAssociated( + l_peerTarget_list, + l_pPeerTgt, + TARGETING::TargetService::PARENT, + TARGETING::TargetService::ALL, + i_pResultFilter); + if(!l_peerTarget_list.empty()) + { + // Insert the first one only. + o_peerTargetList.push_back( + l_peerTarget_list.front()); + } + } + } + } + } while(0); + + TARG_EXIT(); + #undef TARG_FN +} }; // end namespace diff --git a/src/usr/targeting/common/xmltohb/xmltohb.pl b/src/usr/targeting/common/xmltohb/xmltohb.pl index eb9a39625..89d7af58f 100755 --- a/src/usr/targeting/common/xmltohb/xmltohb.pl +++ b/src/usr/targeting/common/xmltohb/xmltohb.pl @@ -114,6 +114,7 @@ if($cfgVerbose) # Initialize some globals ################################################################################ +use constant INVALID_HUID=>0xffffffff; my $xml = new XML::Simple (KeyAttr=>[]); # Until full machine parseable workbook parsing splits out all the input files, @@ -135,7 +136,14 @@ validateAttributes($attributes); validateTargetInstances($attributes); validateTargetTypes($attributes); validateTargetTypesExtension($attributes); -handleTgtPtrAttributes(\$attributes, \%Target_t); +if($cfgIncludeFspAttributes) +{ + handleTgtPtrAttributesFsp(\$attributes, \%Target_t); +} +else +{ + handleTgtPtrAttributesHb(\$attributes, \%Target_t); +} # Open the output files and write them if( !($cfgSrcOutputDir =~ "none") ) @@ -427,10 +435,42 @@ sub validateTargetInstances{ } ################################################################################ +# Convert Target_t PHYS_PATH into Peer target's HUID - FSP Specific +################################################################################ + +sub handleTgtPtrAttributesFsp +{ + my($attributes) = @_; + + # replace PEER_TARGET attribute<PHYS_PATH> value with PEER's HUID + foreach my $targetInstance (@{${$attributes}->{targetInstance}}) + { + foreach my $attr (@{$targetInstance->{attribute}}) + { + if (exists $attr->{default}) + { + if( ($attr->{default} ne "NULL") + && ($attr->{id} eq "PEER_TARGET")) + { + my $peerHUID = getPeerHuid(${$attributes}, + $attr->{default}); + if($peerHUID == INVALID_HUID) + { + fatal("HUID for Peer Target not found"); + } + $attr->{default} = (hex($peerHUID) << 32); + $attr->{default} = sprintf("0x%X",$attr->{default}); + } + } + } + } +} + +################################################################################ # Convert PHYS_PATH into index for Target_t attribute's value ################################################################################ -sub handleTgtPtrAttributes{ +sub handleTgtPtrAttributesHb{ my($attributes, $Target_t) = @_; my $aId = 0; @@ -482,6 +522,47 @@ sub handleTgtPtrAttributes{ } } +sub getPeerHuid +{ + my($attributes, $peerPhysPath) = @_; + + my $peerHUID = INVALID_HUID; + my $found = 0; + foreach my $targetInstance (@{$attributes->{targetInstance}}) + { + foreach my $attr (@{$targetInstance->{attribute}}) + { + if ($attr->{id} eq "PHYS_PATH") + { + if ($attr->{default} eq $peerPhysPath) + { + # $attr->{id} for HUID might have been lost in the iteration + # Need to repeat iteration + foreach my $attr1 (@{$targetInstance->{attribute}}) + { + if ($attr1->{id} eq "HUID") + { + $peerHUID = $attr1->{default}; + $found = 1; + last; + } + } + if($found) + { + last; + } + } + } + } + if($found) + { + last; + } + } + + return $peerHUID; +} + sub SOURCE_FILE_GENERATION_FUNCTIONS { } ################################################################################ |