diff options
Diffstat (limited to 'src/include/usr/targeting/common')
| -rw-r--r-- | src/include/usr/targeting/common/iterators/iterators.H | 45 | ||||
| -rw-r--r-- | src/include/usr/targeting/common/iterators/rawtargetiterator.H | 140 | ||||
| -rw-r--r-- | src/include/usr/targeting/common/iterators/targetiterator.H | 3 | ||||
| -rw-r--r-- | src/include/usr/targeting/common/target.H | 21 | ||||
| -rw-r--r-- | src/include/usr/targeting/common/targetservice.H | 373 | ||||
| -rw-r--r-- | src/include/usr/targeting/common/util.H | 18 |
6 files changed, 530 insertions, 70 deletions
diff --git a/src/include/usr/targeting/common/iterators/iterators.H b/src/include/usr/targeting/common/iterators/iterators.H index 5339b33dd..85742c63c 100644 --- a/src/include/usr/targeting/common/iterators/iterators.H +++ b/src/include/usr/targeting/common/iterators/iterators.H @@ -1,25 +1,25 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: src/include/usr/targeting/common/iterators/iterators.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 +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/targeting/common/iterators/iterators.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_ITERATORS_H #define __TARGETING_COMMON_ITERATORS_H @@ -31,6 +31,7 @@ */ #include <targeting/common/iterators/targetiterator.H> +#include <targeting/common/iterators/rawtargetiterator.H> #include <targeting/common/iterators/rangefilter.H> // please keep up to date... diff --git a/src/include/usr/targeting/common/iterators/rawtargetiterator.H b/src/include/usr/targeting/common/iterators/rawtargetiterator.H new file mode 100644 index 000000000..f7e9f192e --- /dev/null +++ b/src/include/usr/targeting/common/iterators/rawtargetiterator.H @@ -0,0 +1,140 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/targeting/common/iterators/rawtargetiterator.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 __RAW_TARGETING_COMMON_TARGETITERATOR_H +#define __RAW_TARGETING_COMMON_TARGETITERATOR_H + +/** + * @file targeting/common/iterators/rawtargetiterator.H + * + * @brief Interface describing rawiterator/const rawiterator used to iterate + * through all target service targets + */ + +//****************************************************************************** +// Includes +//****************************************************************************** + +// STD +#include <stddef.h> + +// Other Host Boot Components +#include <builtins.h> + +// Targeting Component +#include <targeting/common/iterators/targetiterator.H> + +//****************************************************************************** +// Macros +//****************************************************************************** + +#undef TARG_NAMESPACE +#undef TARG_CLASS +#undef TARG_FUNC + +//****************************************************************************** +// Interface +//****************************************************************************** + +namespace TARGETING +{ + +#define TARG_NAMESPACE "TARGETING::" + +#define TARG_CLASS "_TargetRawIterator<T>::" + +class Target; + +/** + * @brief Class which iterates through targets managed by the target service. + * Provides "Target*" and "const Target*" versions via templates + */ +template<typename T> +class _TargetRawIterator : public _TargetIterator<T> +{ + public: + + /** + * @brief Maps type of iterated element to common alias (Target* or + * const Target*) + */ + typedef T iterator; + typedef T value_type; + + /** + * @brief Create an iterator to a (const/non-const) target handle. + * Defaults to end() + */ + ALWAYS_INLINE + _TargetRawIterator() + : iv_pCurrent(NULL) + { + } + + /** + * @brief Create an iterator to a (const/non-const) target handle + * + * @param[in] i_pTarget Target handle (pointer or const pointer + * depending on flavor) the iterator should reference + */ + ALWAYS_INLINE + explicit _TargetRawIterator(T i_pTarget) + : iv_pCurrent(i_pTarget) + { + } + + /** + * @brief Destroy an iterator to a (const/non-const) target handle + * + * @note Iterator does not own any resources to destroy + */ + ALWAYS_INLINE + ~_TargetRawIterator() + { + } + + + private: + + /** + * @brief Advance the iterator to point to the next item maintained by + * the target service (or end() if end of list) + */ + void advance(); + + T iv_pCurrent; // Pointer to current target +}; + +/** + * @brief Type aliases to simplify user code + */ +typedef _TargetRawIterator<Target*> TargetRawIterator; +typedef _TargetRawIterator<const Target*> ConstTargetRawIterator; + +#undef TARG_CLASS +#undef TARG_NAMESPACE + +} // End namespace TARGETING + +#endif // __RAW_TARGETING_COMMON_TARGETITERATOR_H + diff --git a/src/include/usr/targeting/common/iterators/targetiterator.H b/src/include/usr/targeting/common/iterators/targetiterator.H index 8b3463f70..65e80b8b5 100644 --- a/src/include/usr/targeting/common/iterators/targetiterator.H +++ b/src/include/usr/targeting/common/iterators/targetiterator.H @@ -95,6 +95,9 @@ class _TargetIterator * * @param[in] i_pTarget Target handle (pointer or const pointer * depending on flavor) the iterator should reference + * + * @note User should not assign a hidden system target to the iterator, + * as it does not support hidden targets */ ALWAYS_INLINE inline explicit _TargetIterator(T i_pTarget) diff --git a/src/include/usr/targeting/common/target.H b/src/include/usr/targeting/common/target.H index f3f9be002..ffeecd340 100644 --- a/src/include/usr/targeting/common/target.H +++ b/src/include/usr/targeting/common/target.H @@ -557,16 +557,17 @@ class Target static AttributeTank cv_overrideTank; static AttributeTank cv_syncTank; - friend class PnorBuilderService; - - // Friend functions to allow FAPI Attribute code to directly call - // _tryGetAttr and _trySetAttr for code size optimization - friend fapi::ReturnCode fapi::platAttrSvc::getTargetingAttr( - const fapi::Target *, TARGETING::ATTRIBUTE_ID, const uint32_t, - void *); - friend fapi::ReturnCode fapi::platAttrSvc::setTargetingAttr( - const fapi::Target *, TARGETING::ATTRIBUTE_ID, const uint32_t, - void *); + friend class PnorBuilderService; + friend class TargetCloner; + + // Friend functions to allow FAPI Attribute code to directly call + // _tryGetAttr and _trySetAttr for code size optimization + friend fapi::ReturnCode fapi::platAttrSvc::getTargetingAttr( + const fapi::Target *, TARGETING::ATTRIBUTE_ID, const uint32_t, + void *); + friend fapi::ReturnCode fapi::platAttrSvc::setTargetingAttr( + const fapi::Target *, TARGETING::ATTRIBUTE_ID, const uint32_t, + void *); /* * @brief allow targetattrbulksync access to the target class store. diff --git a/src/include/usr/targeting/common/targetservice.H b/src/include/usr/targeting/common/targetservice.H index 416aeff5d..6dd2cd2f0 100644 --- a/src/include/usr/targeting/common/targetservice.H +++ b/src/include/usr/targeting/common/targetservice.H @@ -44,9 +44,11 @@ // This component #include <targeting/common/attributes.H> +#include <attributetraits.H> #include <targeting/common/iterators/iterators.H> #include <targeting/common/predicates/predicates.H> #include <targeting/adapters/types.H> +#include <targeting/common/error.H> #include <pnortargeting.H> //****************************************************************************** @@ -61,6 +63,24 @@ namespace TARGETING { class TargetService; + /* + * @brief - typedef for node Id + */ + typedef uint8_t NODE_ID; + + /* Node 0 */ + static const NODE_ID NODE0 = 0x00; + + /* Invalid Node Id - to initialize struct variable*/ + static const NODE_ID INVALID_NODE = 0xFF; + + /* Invalid Section Id - to initialize struct variable */ + static const uint8_t INVALID_SECTIONID = 0xFF; + + // Special "not found" fabric node ID is the data type with all bits set + static const ATTR_FABRIC_NODE_ID_type FABRIC_NODE_ID_NOT_FOUND = + INVALID_NODE; + /** * @brief Struct specifying different parameters required for section data * update on the sectionId/NodePtr. @@ -71,6 +91,7 @@ namespace TARGETING * * Struct element details - * sectionId - Section Id + * nodeId - Node Id * pageNumber - PageNumber for the section. * padBytes - PadBytes to fill in 2 extra bytes * dataPtr - Data Ptr @@ -80,11 +101,21 @@ namespace TARGETING struct sectionRefData { - uint8_t sectionId; - uint8_t pageNumber; - uint8_t padBytes[2]; + sectionRefData() : + sectionId(0x00), + nodeId(INVALID_NODE), + pageNumber(0), + dataPtr(NULL), + pNodeTarget(NULL) + { + } + + uint8_t sectionId; + uint8_t nodeId; + uint8_t pageNumber; + uint8_t padBytes; uint8_t* dataPtr; - Target* pNodeTarget; + Target* pNodeTarget; }; @@ -178,15 +209,22 @@ class TargetService /** * @brief Initializes the target service * + * @par Detailed Description: * Initializes the target service, including determining maximum number - * of targets, setting up the target pool, etc. Should be called - * once PNOR is accessible can be mapped + * of targets, setting up the target pool, etc. for each node in the + * system blueprint local to the subsystem. Should be called once PNOR + * is accessible and can be mapped + * + * @param[in] i_maxNodes, max number of nodes to initialize within the + * targetservice. * * @pre N/A * - * @post Target service fully initialized with all possible targets + * @post Target service initialized with all possible targets. User + * would need to call targetservice().initDefaultMasterNode to make + * targetservice fully initialized and ready to be used. */ - void init(); + void init(const size_t i_maxNodes = 1); /** * @brief Returns whether target service has initialized or not @@ -204,48 +242,90 @@ class TargetService /** * @brief Map iterator types to common aliases */ - typedef TargetIterator iterator; - typedef ConstTargetIterator const_iterator; + typedef TargetIterator iterator; + typedef ConstTargetIterator const_iterator; + typedef TargetRawIterator rawiterator; + typedef ConstTargetRawIterator const_rawiterator; /** * @brief Return iterator which points to first target service target * (or end() if none) - * + * * @return Iterator pointing to first target service target */ iterator begin(); - + + /** + * @brief Return rawiterator which points to first target service + * target (or end() if none) + * + * @return RawIterator pointing to first target service target + */ + rawiterator raw_begin(); + /** * @brief Return iterator to const which points to first target service * target (or end() if none) - * + * * @return Iterator to const pointing to first target service target - */ + */ const_iterator begin() const; /** + * @brief Return rawiterator to const which points to first target + * service target (or end() if none) + * + * @return RawIterator to const pointing to first target service target + */ + const_rawiterator raw_begin() const; + + /** * @brief Return iterator which points to the "past the end of the * list" target maintained by the target service - * + * * @return Iterator pointing to the "past the end of the list" target * maintained by the target service */ iterator end(); - + + /** + * @brief Return rawiterator which points to the "past the end of the + * list" target maintained by the target service + * + * @return RawIterator pointing to the "past the end of the list" + * target maintained by the target service + */ + rawiterator raw_end(); + /** * @brief Return iterator to const which points to the "past the end of * the list" target maintained by the target service - * + * * @return Iterator to const pointing to the "past the end of the list" * target maintained by the target service */ const_iterator end() const; /** + * @brief Return rawiterator to const which points to the "past the end + * of the list" target maintained by the target service + * + * @return RawIterator to const pointing to the "past the end of the + * list" target maintained by the target service + */ + const_rawiterator raw_end() const; + + /** * @brief Allow iterator access to the target service's target store */ - friend class _TargetIterator<Target*>; - friend class _TargetIterator<const Target*>; + friend class _TargetIterator<Target*>; + friend class _TargetIterator<const Target*>; + + /** + * @brief Allow rawiterator access to the target service's target store + */ + friend class _TargetRawIterator<Target*>; + friend class _TargetRawIterator<const Target*>; /** * @brief Returns the top level physical target @@ -323,18 +403,56 @@ class TargetService * * @param[out] o_masterProcChipTarget Target handle referring to the * current master processor chip (the one connected to PNOR) - * @param[in] i_node Node that this master resides on (default - * is 0) + * @param[in] i_pNodeTarget + * Handle to the node target to search for the acting master + * processor. If NULL, HB will search whatever node it's + * running on, and FSP will search the physical drawer containing + * the lowest ordered fabric node ID. * + * @pre Target Service must be initialized + * + * @post Master processor chip target returned or NULL is returned if + * targetservice is not yet initialized or user passed an invalid node + * target to get the master proc handle + */ + void masterProcChipTargetHandle( + Target*& o_masterProcChipTargetHandle, + const Target* i_pNodeTarget = NULL) const; + + /** + * @brief Returns the master processor chip target handle + * + * Returns the master processor chip target handle for the given (or + * defaulted) node. On nodes without an alternate master, + * it returns a handle to the only master, if found (NULL otherwise). + * On nodes with multiple potential + * masters, it returns a target handle to the acting master (NULL + * otherwise). If targeting information is not yet accessible (very + * early in the host boot IPL), the returned target handle will be a + * sentinel value representing the master (whichever it may be) * - * @pre None + * @param[out] o_masterProcChipTarget + * Target handle of acting master processor chip for the given + * node (the one connected to PNOR) + * @param[in] i_pNodeTarget + * Target handle of node to search. If NULL, HB will search + * whatver node it's running on, andFSP will search the physical + * drawer containing the lowest orderd fabric node ID * - * @post Master processor chip targets returned or a dummy value + * @pre Target Service must be initialized + * + * @post Master processor chip target returned or a dummy value * representing the acting master processor chip if the targeting * information is not yet initialized + * + * @return Error log handle indicating the status of the request + * + * @retval NULL Success, Master Proc handle is returned to the user + * @retval !NULL Failure, Failed to find the Master Proc Handle & NULL + * is returned to user */ - void masterProcChipTargetHandle( - Target*& o_masterProcChipTargetHandle, - uint8_t i_node = 0) const; + errlHndl_t queryMasterProcChipTargetHandle( + Target*& o_masterProcChipTargetHandle, + const Target* i_pNodeTarget = NULL) const; /** * @brief Returns whether the specified entity path attribute exists @@ -391,10 +509,10 @@ class TargetService * @param[in] i_recursionLevel Whether to return candidate targets * immediately associated to the specified target or recursively * associated to it. - * @param[in] i_pPredicate Pointer to a predicate to be evaluated + * @param[in] i_pPredicate Pointer to a predicate to be evaluated * against each candidate target (as determined by the source * target, type, and recursion level parameters). If the predicate - * returns true, the target will be added to the result list. A + * returns true, the target will be added to the result list. A * value of NULL acts as a predicate that always returns true. * * @pre N/A @@ -423,7 +541,7 @@ class TargetService * This is the top level interface, would basically call the lower * level attribute resource provider interface. The lower level * interface would fetch each vector element and update each section - * with corresponding data from the offset specified. + * with corresponding data from the offset specified. * * @param[in] i_pages, vector of sectionRefData struct * @@ -450,6 +568,7 @@ class TargetService * * @param[out] o_pages, vector of sectionRefData struct * @param[in] i_sectionId, section type + * @param[in] i_nodeId, node Id * * @pre N/A * @@ -461,11 +580,167 @@ class TargetService */ void readSectionData(std::vector<sectionRefData>& o_pages, - const SECTION_TYPE i_sectionId); + const SECTION_TYPE i_sectionId, + const NODE_ID i_nodeId = NODE0); + + /** + * @brief Get the Next initialized node in the Target Service + * This is to support the iterator + * + * It takes the present node id as input and computes the next + * incremental caller-visible node available in the system and + * return it to the user + * + * @param[in] i_nodeId, present node Id + * + * @return returns uint8_t as next node + * + * @retval success case, Node Id, returns the next incremental + * initialized caller-visible node available + * @retval, Failure case, invalid node, if the present node is the + * last initialized caller-visible node available in incremental + * order or user passed an invalid nodeId + */ + NODE_ID getNextInitializedNode(const NODE_ID i_node) const; + + /** + * @brief Get the Next caller-visible Target Handle in incremental + * order. This is to support the iterator. + * + * It is take a target handle as input and compute the next incremental + * available caller-visible target handle in the system and return it + * to the user. + * + * @param[in] i_pTarget, non-NULL Target Handle + * + * @return Target Handle + * + * @retval Target*, returns the next incremental caller-visible + * Target Handle + * @retval NULL, if the target handle passed is the last visible + * target handle available in incremental order in the target service. + */ + Target* getNextTarget(const Target* i_pTarget) const; + + /** + * @brief Sets the isMasterNode Attribute to the Node Target handle + * Passed and takes care of syncing master node's system target handle + * with non-master system target handles. + * + * @par Detailed Description + * It takes the node target handle as input which is required to set as + * master node and sets the isMasterNode Attribute associated to true + * and also unset the isMasterNode associated with all current master + * node target handle. Along with this it also takes care of syncing + * master node's system target attributes with non-master node system + * target's attribute in the system. + * + * @param[in] i_pTarget, Non-Null Node Target handle + * + * @return error handle is return + * @retval Success case, NULL is returned means the master node set and + * sync is successful + * @return, Failure case, !NULL error handle is returned means the + * master node couldn't be set as desired. + */ + errlHndl_t setMasterNode(const Target* i_pTarget); + + /** + * @brief this gives the information whether a system target is + * master-node's system target or non-master-node's system target + * + * It is takes system target handle as input and checks whether the + * system target is from master-node target tree or non-master node + * target tree. + * + * @param[in] i_pTarget, Non-Null System Target handle + * + * @return true, means the system target passed is a non-master node's + * system target. + * @return false, means the system target passed is a master node's + * system target. + */ + bool isNonMasterNodeSystemTarget(const Target* i_pTarget) const; + + /* + * @brief give the total number of nodes in the targeting service + * for which node level binaries have been initialized . + * + * @return total number of nodes in the targeting model initiailized. + */ + uint8_t getNumInitializedNodes() const; + + /** + * @brief set the default Master Node and release the intialize flag + * for targetservice + * + * @par Detailed Description: + * Searches for previous instance of master node, else sets the default + * node (i.e. first initialized node) as master node. And then releases + * the initialized flag of targetservice, Intializing targetservice + * fully + * + * @pre targetservice().init() should have been called before this. + * + * @post Target servicei is fully initialized along with a default + * master node. + */ + + void initDefaultMasterNode(); + + /** + * @brief Returns the Node Target handle of the Master node in the + * system. + * + * @par Detailed Description: + * Returns the Node Target handle of the Master node in the system. + * Caller must check for NULL Target handle + * + * @param[out] o_masterNodeTarget node target handle of the master node + * in the system + * + * @pre TargetService must be initialized. + * + * @post Returns the node target handle of the master node. User + * will always get a valid target else targetservice will assert. + * + * @return void + */ + void getMasterNodeTarget(Target*& o_masterNodeTarget) const; + private: /** + * @brief Structure, Node information specific + */ + struct NodeSpecificInfo + { + + NodeSpecificInfo() : + nodeId(INVALID_NODE), + initialized(false), + isMasterNode(false), + targets(NULL), + maxTargets(0), + pPnor(NULL) + { + } + + NODE_ID nodeId; ///< Node Id for the binary file + bool initialized; ///< Is service initialized or not + bool isMasterNode; ///< Is this the master node + Target (*targets)[]; ///< Pointer to array of target objects + uint32_t maxTargets; ///< Maximum # target objects in the array + const void* pPnor; ///< Pointer to the PNOR targeting section + }; + + /** + * @brief Node Specific information container + */ + typedef std::vector< NodeSpecificInfo > NodeInfo_t; + + /** * @brief Enum specifying which direction to traverse associations * between targets * @@ -506,17 +781,36 @@ class TargetService typedef std::vector< AssociationAttrMap > AssociationMappings_t; /** + * @brief Returns the first Target from the first initialized node + * from the pool of targets. + * + * param[out] o_firstTargetPtr First Target handle + * + * @pre Target service must be initialized + * + * @post Target Service returns the first Target from the first + * initialized node. + * + * @returns void + */ + void _getFirstTargetForIterators (Target*& o_firstTargetPtr) const; + + /** * @brief Configures the pool of targets * * This function computes the maximum number of targets possible based * on the PNOR (or override) image, and updates the target service to * point to the start of the target array, wherever it may reside * + * @param[in] i_nodeInfoContainer, struct to contain all node + * specific information of the type NodeSpecificInfo. May refer to + * structure definition + * * @pre Target service must not be initialized * * @post Target service target pool configured for access */ - void _configureTargetPool(); + void _configureTargetPool(NodeSpecificInfo& i_nodeInfoContainer); /** * @brief Computes the maximum number of targets, caches the value @@ -525,14 +819,17 @@ class TargetService * Computes the maximum number of targets possible based on the PNOR * (or override) image and returns it to the caller * + * @param[in/out] io_nodeInfoContainer, struct to contain all node + * specific information of the type NodeSpecificInfo. May refer to + * structure definition + * * @pre Target service must not already be initialized * - * @post Target service updated with maximum target count. Count also - * returned to caller + * @post Target service updated with maximum target count in + * nodeContainer. * - * @return uint32_t indicating the maximum number of targets possible */ - uint32_t _maxTargets(); + void _maxTargets(NodeSpecificInfo & io_nodeInfoContainer); /** * @brief Returns handles to the targets associated to the @@ -608,11 +905,11 @@ class TargetService // Instance variables bool iv_initialized; ///< Is service initialized or not - Target (*iv_targets)[]; ///< Pointer to array of target objects - uint32_t iv_maxTargets; ///< Maximum # target objects in the array - const void* iv_pPnor; ///< Pointer to the PNOR targeting section + AssociationMappings_t iv_associationMappings; ///< Association map + NodeInfo_t iv_nodeInfo; + // Disable copy constructor / assignment operator TargetService( diff --git a/src/include/usr/targeting/common/util.H b/src/include/usr/targeting/common/util.H index d1e2cff0f..bb11c70f6 100644 --- a/src/include/usr/targeting/common/util.H +++ b/src/include/usr/targeting/common/util.H @@ -54,6 +54,24 @@ class Target; #define TARG_ADDR_TRANSLATION_REQUIRED (1) #endif +namespace PLAT +{ + +/** + * @brief PLAT::PROPERTIES namespace contains constants that control platform + * specific behaviors + */ +namespace PROPERTIES +{ +#ifdef __HOSTBOOT_MODULE + static const bool MULTINODE_AWARE = false; +#else + static const bool MULTINODE_AWARE = true; +#endif +} + +} + /** * @brief Checks to see if we are running in a hardware simulation * environment, i.e. VPO/VBU (not Simics) |

