diff options
Diffstat (limited to 'src/include/usr/targeting')
-rw-r--r-- | src/include/usr/targeting/common/attributeTank.H | 429 | ||||
-rw-r--r-- | src/include/usr/targeting/common/hbrt_target.H | 45 | ||||
-rw-r--r-- | src/include/usr/targeting/common/target.H | 174 | ||||
-rw-r--r-- | src/include/usr/targeting/common/targetUtil.H | 154 | ||||
-rw-r--r-- | src/include/usr/targeting/common/trace.H | 3 | ||||
-rw-r--r-- | src/include/usr/targeting/common/util.H | 9 | ||||
-rw-r--r-- | src/include/usr/targeting/runtime/rt_targeting.H | 89 |
7 files changed, 832 insertions, 71 deletions
diff --git a/src/include/usr/targeting/common/attributeTank.H b/src/include/usr/targeting/common/attributeTank.H index a3f9afeab..1a4c5a4ce 100644 --- a/src/include/usr/targeting/common/attributeTank.H +++ b/src/include/usr/targeting/common/attributeTank.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2013,2017 */ +/* Contributors Listed Below - COPYRIGHT 2013,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -34,13 +34,12 @@ #include <stdint.h> #include <list> #include <vector> +#include <attributeenums.H> // TARGETING::ATTRIBUTE_ID #ifndef STANDALONE_COMPILE #include <targeting/adapters/mutexadapter.H> #include <targeting/common/error.H> namespace TARGETING { - - /** * @class AttributeTank * @@ -146,6 +145,328 @@ namespace AttributeTank #ifndef STANDALONE_COMPILE /** + * @struct Attribute + * + * This structure defines a single attribute. + */ + struct Attribute + { + /** + * @brief Constructor + */ + Attribute() + : iv_hdr(), + iv_pVal(NULL) + { + } + + /** + * @brief Destructor. Frees memory + */ + ~Attribute() + { + delete[] iv_pVal; + iv_pVal = NULL; + } + + /** + * @brief Set the Attribute ID + */ + void setId(const uint32_t i_attrId) + { + iv_hdr.iv_attrId = i_attrId; + } + + /** + * @brief Set the Attribute Target Type + */ + void setTargetType(const uint32_t i_targetType) + { + iv_hdr.iv_targetType = i_targetType; + } + + /** + * @brief Set the Attribute Position + */ + void setPosition(const uint16_t i_pos) + { + iv_hdr.iv_pos = i_pos; + } + + /** + * @brief Set the Attribute Unit Position + */ + void setUnitPosition(const uint8_t i_unitPos) + { + iv_hdr.iv_unitPos = i_unitPos; + } + + /** + * @brief Set the Attribute Node + */ + void setNode(const uint8_t i_node) + { + iv_hdr.iv_node = i_node; + } + + /** + * @brief Set the Attribute Flags + */ + void setFlags(const uint8_t i_flags) + { + iv_hdr.iv_flags = i_flags; + } + + /** + * @brief Get the size of all the Attribute's data members, + * aggregated together + * + * return Aggregated size of the Attribute's data members + */ + uint32_t getSize() const + { + return (sizeof(iv_hdr) + iv_hdr.iv_valSize); + } + + /** + * @brief Get a constant reference to the Attribute Header. + * Returning a reference for fast retrieval. + * + * @note Caller should not attempt to modify contents of the + * Attribute Header. Use appropriate Attribute set methods + * + * return A constant reference to the Attribute Header + */ + const AttributeHeader & getHeader() const + { + return iv_hdr; + } + + /** + * @brief Set the Attribute Value to a copy of the given buffer + * + * @pre Passing in nonsensical parameters will produce unpredictable + * results, ie passing in a null buffer with size > 0 + * + * @note Passing in a null buffer with size 0 will clear the value + * + * @param[in] i_buffer The buffer that contains the value to + * be copied + * @param[in] i_bufferSize Size of the given buffer + * + * return The size of the data that was copied + */ + uint32_t setValue(const void * const i_buffer, + const uint32_t i_bufferSize) + + { + // Reuse storage when possible + if (i_bufferSize != iv_hdr.iv_valSize) + { + // Clean up current Attribute Value + delete []iv_pVal; + iv_pVal = NULL; + + // Set size and allocate memory space + iv_hdr.iv_valSize = i_bufferSize; + if (iv_hdr.iv_valSize) + { + iv_pVal = new uint8_t[iv_hdr.iv_valSize]; + } + } + + // Make a copy of the data. Passing in a size of 0 + // or NULL turns this call to no-op + memcpy(iv_pVal, i_buffer, iv_hdr.iv_valSize); + + return iv_hdr.iv_valSize; + } + + /** + * @brief Get a constant pointer to the Attribute Value. + * Returning a constant pointer for fast retrieval. + * + * @note Caller should not attempt to modify the contents nor + * delete the pointer, use method setValue if + * need be. + * + * return A constant pointer to the Attribute Value + */ + const void* getValue() const + { + return iv_pVal; + } + + /** + * @brief Return a copy of the Attribute Value into caller's bufffer + * + * @param[in] i_buffer The buffer to copy Attribute Value into + * @param[in] i_bufferSize Size of the given buffer + * + * return The size of the Attribute Value that was copied + * or 0 if unable to copy the Attribute Value - buffer + * size to small will cause this + */ + uint32_t cloneValue(void* const o_buffer, + const uint32_t i_bufferSize) const + { + // Return the size of the cloned data + uint32_t l_attributeValueSize(0); + + // Is the buffer large enough to contain the Attribute Value? + if (i_bufferSize >= iv_hdr.iv_valSize) + { + // Buffer is large enough to contain the Attribute Value - + // copy the Attribute Value to given buffer + memcpy(o_buffer, iv_pVal, iv_hdr.iv_valSize); + + // Return the size of the cloned data + l_attributeValueSize = iv_hdr.iv_valSize; + } + + return l_attributeValueSize; + } + + /** + * @brief Serialize the Attribute, if the buffer given is large + * enough to contain the Attribute's data members + * + * @param[out] o_buffer The buffer to contain the serialized + * data members + * @param[in] i_bufferSize Size of the given buffer + * + * return 0 if buffer is to small to contain the data members; + * otherwise the aggregated size of the Attribute's data + * members copied + */ + uint32_t serialize(void* const o_buffer, + const uint32_t i_bufferSize) const + { + // Return the size of the serialized data + uint32_t l_attributeSize(0); + + // If buffer size greater than or equal to the size of the + // Attribute's data members aggregated together then + // copy the data members to buffer + if (i_bufferSize >= getSize()) + { + // Get an Attribute handle to buffer for easy access + uint8_t* l_attribute = static_cast<uint8_t*>(o_buffer); + + // Copy the Attribute Header + memcpy(l_attribute, &iv_hdr, sizeof(iv_hdr)); + l_attribute += sizeof(iv_hdr); + + // Copy the Attribute Value + memcpy(l_attribute, iv_pVal, iv_hdr.iv_valSize); + + // Return the size of the serialized data + l_attributeSize = sizeof(iv_hdr) + iv_hdr.iv_valSize; + } + + return l_attributeSize; + } + + /** + * @brief Deserialize the buffer, if the buffer given is at least + * the same size as an Attribute + * + * @param[out] i_buffer The buffer to deserialize + * @param[in] i_bufferSize Size of the given buffer + * + * @post If the buffer is large enough to populate the Attribute, then + * the Attribute will be populated, with it's own copy of the + * data. If the buffer is too small, then the Attribute is + * untouched. + * + * return 0 if buffer is to small to populate an Attribute; + * otherwise the aggregated size of the Attribute's data + * members deserialized + */ + uint32_t deserialize(const void* const i_buffer, + const uint32_t i_bufferSize) + { + // Return the size of the Attribute + uint32_t l_attributeSize(0); + + // Get an Attribute handle to buffer for easy access + const Attribute* const l_attribute = + reinterpret_cast<const Attribute* const>(i_buffer); + + // Get the minimum size needed to check for values + uint32_t l_attributeHeaderSize(sizeof(iv_hdr)); + + // Make sure the buffer is not just large enough to inspect the + // Attribute Header but large enough to read Values if they exist + // Need to make sure size is at minimum threshold before calling + // getSize(), because getSize assumes the data is there to read + if ( (i_bufferSize >= l_attributeHeaderSize) && + (i_bufferSize >= (l_attribute->getSize())) ) + { + // Get an uint8_t handle to buffer for easy access + const uint8_t* l_attributeData = + reinterpret_cast<const uint8_t*>(i_buffer); + + // Copy header data + memcpy(&iv_hdr, l_attributeData, l_attributeHeaderSize); + + // Free iv_pVal data, if it currently has data, and set to NULL + delete []iv_pVal; // OK to delete a NULL ptr + iv_pVal = NULL; + + // Populate values if they exist + uint32_t l_valueSize = iv_hdr.iv_valSize; + if (l_valueSize) + { + // Copy the Attribute Value + iv_pVal = new uint8_t[l_valueSize]; + l_attributeData += l_attributeHeaderSize; + memcpy(iv_pVal, l_attributeData, l_valueSize); + } + + // Return the size of the Attribute + l_attributeSize = getSize(); + } + + return l_attributeSize; + } + + + /** + * @brief Assignment operator defined + */ + Attribute& operator=(const Attribute& rhs) + { + // check for self-assignment + if (&rhs != this) + { + // Deep copy the attribute value + setValue(rhs.iv_pVal, rhs.iv_hdr.iv_valSize); + // Copy the Attribute header + iv_hdr = rhs.iv_hdr; + } + + return *this; + } + + /** + * @brief Copy constructor defined + */ + Attribute(const Attribute& rhs) + : iv_hdr(), + iv_pVal(NULL) + { + // Call the assignment operator to do the work + *this = rhs; + } + + // Private data + private: + AttributeHeader iv_hdr; + uint8_t * iv_pVal; // Pointer to attribute value + }; + + /** * @struct AttributeSerializedChunk * * This structure defines a chunk of memory for containing serialized @@ -183,7 +504,7 @@ namespace AttributeTank /** * @brief Destructor. Deletes all Attributes */ - virtual ~AttributeTank(); + ~AttributeTank(); /** * @brief Checks if the platform has enabled synchronization @@ -209,9 +530,8 @@ namespace AttributeTank * specific node (i_node) * @param[in] i_node See i_nodeFilter */ - virtual void clearAllAttributes( - const NodeFilter i_nodeFilter = NODE_FILTER_NONE, - const uint8_t i_node = ATTR_NODE_NA); + void clearAllAttributes(const NodeFilter i_nodeFilter = NODE_FILTER_NONE, + const uint8_t i_node = ATTR_NODE_NA); /** * @brief Clear any non-const attribute for a specified ID and Target @@ -225,11 +545,11 @@ namespace AttributeTank * @param[in] i_unitPos Target Unit Position * @param[in] i_node Target Node */ - virtual void clearNonConstAttribute(const uint32_t i_attrId, - const uint32_t i_targetType, - const uint16_t i_pos, - const uint8_t i_unitPos, - const uint8_t i_node); + void clearNonConstAttribute(const uint32_t i_attrId, + const uint32_t i_targetType, + const uint16_t i_pos, + const uint8_t i_unitPos, + const uint8_t i_node); /** * @brief Set an Attribute @@ -251,14 +571,14 @@ namespace AttributeTank * @param[in] i_valSize Size of attribute value in bytes * @param[in] i_pVal Pointer to attribute value */ - virtual void setAttribute(const uint32_t i_attrId, - const uint32_t i_targetType, - const uint16_t i_pos, - const uint8_t i_unitPos, - const uint8_t i_node, - const uint8_t i_flags, - const uint32_t i_valSize, - const void * i_pVal); + void setAttribute(const uint32_t i_attrId, + const uint32_t i_targetType, + const uint16_t i_pos, + const uint8_t i_unitPos, + const uint8_t i_node, + const uint8_t i_flags, + const uint32_t i_valSize, + const void * i_pVal); /** * @brief Get a copy of an Attribute @@ -266,21 +586,24 @@ namespace AttributeTank * This is called on an OverrideAttributeTank to query/get an Attribute * Override when an attribute is got * + * @note Caller's responsibility to ensure the passed in buffer + * is large enough to contain the Attribute Value. + * * @param[in] i_attrId Attribute ID * @param[in] i_targetType Target Type attribute is for * @param[in] i_pos Target Position * @param[in] i_unitPos Target Unit Position * @param[in] i_node Target Node - * @param[out] o_pVal Pointer to attribute value + * @param[out] o_pVal Pointer to a copy of the attribute value * * return true if attribute exists and a copy was written to o_pVal */ - virtual bool getAttribute(const uint32_t i_attrId, - const uint32_t i_targetType, - const uint16_t i_pos, - const uint8_t i_unitPos, - const uint8_t i_node, - void * o_pVal) const; + bool getAttribute(const uint32_t i_attrId, + const uint32_t i_targetType, + const uint16_t i_pos, + const uint8_t i_unitPos, + const uint8_t i_node, + void * o_pVal) const; /** * @brief Serialize all Attributes into newly allocated memory chunks @@ -310,7 +633,7 @@ namespace AttributeTank * specific node (i_node) * @param[in] i_node See i_nodeFilter */ - virtual void serializeAttributes( + void serializeAttributes( const AllocType i_allocType, const uint32_t i_chunkSize, std::vector<AttributeSerializedChunk> & o_attributes, @@ -327,8 +650,7 @@ namespace AttributeTank * @param[in] i_attributes Reference to AttributeSerializedChunk containing * attributes. */ - virtual void deserializeAttributes( - const AttributeSerializedChunk & i_attributes); + void deserializeAttributes(const AttributeSerializedChunk & i_attributes); /** @@ -344,9 +666,8 @@ namespace AttributeTank * * @param[in] i_echoAttributes Select whether or not to echo the attributes */ - virtual void deserializeAttributes( - const AttributeSerializedChunk & i_attributes, - bool i_echoAttributes ); + void deserializeAttributes(const AttributeSerializedChunk & i_attributes, + bool i_echoAttributes ); /** @@ -359,7 +680,7 @@ namespace AttributeTank * * return true if any attributes exist */ - virtual bool attributesExist() const { return iv_attributesExist; } + bool attributesExist() const { return iv_attributesExist; } /** * @brief Check if an attribute exists in the tank @@ -374,7 +695,7 @@ namespace AttributeTank * * return true if any attributes exist */ - virtual bool attributeExists(const uint32_t i_attrId) const; + bool attributeExists(const uint32_t i_attrId) const; /** * @brief This function writes attributes in an AttributeTank to targeting @@ -392,32 +713,25 @@ namespace AttributeTank */ size_t size() const; -private: - // Copy constructor and assignment operator disabled - AttributeTank(const AttributeTank & i_right); - AttributeTank & operator=(const AttributeTank & i_right); - /** - * @struct Attribute + * @brief Return a copy of all attributes in the tank * - * This structure defines a single attribute. + * @param[out] List of all attributes in this tank + * @return n/a */ - struct Attribute - { - /** - * @brief Constructor - */ - Attribute(); + void getAllAttributes( std::list<Attribute *>& o_attributes ) const; - /** - * @brief Destructor. Frees memory - */ - ~Attribute(); + /** + * @brief Return a string description of the given tank layer + * + * @return String representation of layer + */ + static const char* layerToString( TankLayer i_layer ); - // Public data - AttributeHeader iv_hdr; - uint8_t * iv_pVal; // Pointer to attribute value - }; +private: + // Copy constructor and assignment operator disabled + AttributeTank(const AttributeTank & i_right); + AttributeTank & operator=(const AttributeTank & i_right); // The attributes // Note: A possible performance boost could be to store the elements in a @@ -429,7 +743,8 @@ private: // Lock for thread safety (class provided by platform) mutable TARG_MUTEX_TYPE iv_mutex; -}; + +}; // end AttributeTank #endif //STANDALONE_COMPILE diff --git a/src/include/usr/targeting/common/hbrt_target.H b/src/include/usr/targeting/common/hbrt_target.H new file mode 100644 index 000000000..1a6989bf4 --- /dev/null +++ b/src/include/usr/targeting/common/hbrt_target.H @@ -0,0 +1,45 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/targeting/common/hbrt_target.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2019,2020 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +#ifndef __HBRT_TARGET_H +#define __HBRT_TARGET_H + +#include <errl/errlentry.H> + +namespace TARGETING +{ + typedef uint64_t rtChipId_t; + /** + * @brief Convert a TARGETING::Target to an unit ID that can be used + * in calls to the runtime host + * @param[in] The HB TARGETING::Target + * @param[out] Sapphire target id + * @return an error handle on error + */ + errlHndl_t getRtTarget(const TARGETING::Target* i_target, + rtChipId_t &o_targetId); + +} + +#endif
\ No newline at end of file diff --git a/src/include/usr/targeting/common/target.H b/src/include/usr/targeting/common/target.H index 08fcb3f76..3e7eb82e7 100644 --- a/src/include/usr/targeting/common/target.H +++ b/src/include/usr/targeting/common/target.H @@ -47,6 +47,9 @@ #include <targeting/common/util.H> #include <targeting/common/pointer.H> #include <vector> +#ifdef __HOSTBOOT_MODULE +#include <array> +#endif // This component #include <targeting/common/attributes.H> @@ -181,6 +184,34 @@ class Target template<const ATTRIBUTE_ID A> bool tryGetAttrNotSynced( typename AttributeTraits<A>::Type& o_attrValue) const; + + /** + * @brief Try to get the target's specified std::array attribute value + * + * A special tryGetAttr function for getting the attribute values + * of the attributes which support std::array. + * It returns false (with invalid o_attrValue) if the specified + * attribute does not exist for the associated target, true (with a + * valid o_attrValue) otherwise. + * + * @param[out] o_attrValue Value of the attribute + * + * @pre Target service must be initialized + * + * @post See "return" + * + * @return bool indicating whether the specified attribute was returned + * or not + * + * @retval true Attribute returned in o_attrValue + * @retval false Attribute not found; o_attValue not valid + */ +#ifdef __HOSTBOOT_MODULE + template<const ATTRIBUTE_ID A> + bool tryGetAttr( + typename AttributeTraits<A>::TypeStdArr& o_attrValue) const; +#endif + /** * @brief Get the target's specified attribute value * @@ -250,6 +281,26 @@ class Target const char* getAttrAsString() const; /** + * @brief For targets whose attribute value type is an array, return + * the array in std::array form. + * + * @pre Target service must be initialized + * + * @post Target's specified attribute value returned as a std::array, + * or assert called if specified attribute doesn't exist for the + * associated target or type is not an array + * + * @return std::array + * + * @retval Content and dimension varies, see xml file where the + * attribute's type is set + */ +#ifdef __HOSTBOOT_MODULE + template<const ATTRIBUTE_ID A> + typename AttributeTraits<A>::TypeStdArr getAttrAsStdArr() const; +#endif + + /** * @brief Tries to set the target's specified attribute value * * Attempts to set the target's specified attribute value. It @@ -298,6 +349,34 @@ class Target typename AttributeTraits<A>::Type const& i_attrValue); /** + * + * @brief Tries to set the target's specified std::array attribute value + * + * A special trySetAttr function for setting the attribute values + * of the attributes which support std::array. + * It returns false if the specified attribute does not exist for the + * associated target, true otherwise. + * + * @param[in] i_attrValue Value of the attribute + * + * @pre Target service must be initialized + * + * @post Target's attribute value updated (if it exists), and caller + * notified whether the update occurred or not. + * + * @return bool indicating whether the specified attribute was updated + * or not + * + * @retval true Attribute updated + * @retval false Attribute not updated + */ +#ifdef __HOSTBOOT_MODULE + template<const ATTRIBUTE_ID A> + bool trySetAttr( + typename AttributeTraits<A>::TypeStdArr const& i_attrValue); +#endif + + /** * @brief Returns pointer to a mutex attribute associated with the * target * @@ -361,6 +440,23 @@ class Target void setAttr(typename AttributeTraits<A>::Type const& i_attrValue); /** + * @brief For targets whose attribute value type is an array, set value + * from a std::array of any dimension + * + * @param[in] i_attrValue Value of the attribute + * + * @pre Target service must be initialized + * + * @post Target's attribute value updated if it exists and if it + * suppports TypeStdArr type, otherwise routine asserts + */ +#ifdef __HOSTBOOT_MODULE + template<const ATTRIBUTE_ID A> + void setAttrFromStdArr(typename AttributeTraits<A>::TypeStdArr const& + i_attrValue); +#endif + + /** * @brief Perform FFDC for the target instance * * @param[out] io_size @@ -488,7 +584,16 @@ class Target return _trySetAttr(i_attr, i_size, i_pAttrData); } - + /** + * @brief Returns the target's type as used in a Targeting attribute + * tank. + * + * This target type is associated with an attribute in an attribute + * tank and helps identify which target(s) the attribute belongs to + * + * @return uint32_t The target type + */ + uint32_t getAttrTankTargetType() const; private: // Private helper interfaces @@ -713,24 +818,15 @@ class Target mutex_t*& o_pMutex) const; /** - * @brief Returns the target's type as used in a Targeting attribute - * tank. - * - * This target type is associated with an attribute in an attribute - * tank and helps identify which target(s) the attribute belongs to - * - * @return uint32_t The target type - */ - uint32_t getAttrTankTargetType() const; - - /** * @brief enumeration of assert reasons */ enum TargAssertReason { SET_ATTR, + SET_ATTR_FROM_STD_ARR, GET_ATTR, GET_ATTR_AS_STRING, + GET_ATTR_AS_STD_ARRAY, GET_HB_MUTEX_ATTR, GET_ATTR_TANK_TARGET_POS_DATA, GET_ATTR_TANK_TARGET_POS_DATA_ATTR, @@ -865,6 +961,19 @@ bool Target::tryGetAttr(typename AttributeTraits<A>::Type& o_attrValue) const return _tryGetAttr(A,sizeof(o_attrValue),&o_attrValue); } +#ifdef __HOSTBOOT_MODULE +template<const ATTRIBUTE_ID A> +bool Target::tryGetAttr( + typename AttributeTraits<A>::TypeStdArr& o_attrValue) const +{ + if(AttributeTraits<A>::readable == AttributeTraits<A>::readable) { } + if(AttributeTraits<A>::notHbMutex == AttributeTraits<A>::notHbMutex) { } + if(AttributeTraits<A>::fspAccessible == AttributeTraits<A>::fspAccessible) + { } + return _tryGetAttr(A, sizeof(o_attrValue), &o_attrValue); +} +#endif + template<const ATTRIBUTE_ID A> bool Target::trySetAttr(typename AttributeTraits<A>::Type const& i_attrValue) { @@ -886,6 +995,17 @@ bool Target::trySetAttrNotSynced( return _trySetAttr(A,sizeof(i_attrValue),&i_attrValue); } +#ifdef __HOSTBOOT_MODULE +template<const ATTRIBUTE_ID A> +bool Target::trySetAttr(typename AttributeTraits<A>::TypeStdArr + const& i_attrValue) +{ + if(AttributeTraits<A>::writeable == AttributeTraits<A>::writeable) { } + if(AttributeTraits<A>::notHbMutex == AttributeTraits<A>::notHbMutex) { } + return _trySetAttr(A,sizeof(i_attrValue),&i_attrValue); +} +#endif + template<const ATTRIBUTE_ID A> typename AttributeTraits<A>::Type Target::getAttr() const { @@ -933,6 +1053,19 @@ void Target::setAttr(typename AttributeTraits<A>::Type const& i_attrValue) } } +#ifdef __HOSTBOOT_MODULE +template<const ATTRIBUTE_ID A> +void Target::setAttrFromStdArr(typename AttributeTraits<A>::TypeStdArr const& + i_attrValue) +{ + bool l_wrote = trySetAttr<A>(i_attrValue); + if (unlikely(!l_wrote)) + { + targAssert(SET_ATTR_FROM_STD_ARR, A); + } +} +#endif + template<const ATTRIBUTE_ID A> mutex_t* Target::getHbMutexAttr() const { @@ -978,6 +1111,23 @@ const char* Target::getAttrAsString() const return attrToString<A>(l_attrValue); } +#ifdef __HOSTBOOT_MODULE +template<const ATTRIBUTE_ID A> +typename AttributeTraits<A>::TypeStdArr Target::getAttrAsStdArr() const +{ + typename AttributeTraits<A>::TypeStdArr l_stdArr; + + bool l_read = tryGetAttr<A>(l_stdArr); + + if (unlikely(!l_read)) + { + targAssert(GET_ATTR_AS_STD_ARRAY, A); + } + + return l_stdArr; +} +#endif + // Function to set various frequency related attributes /** * @brief - sets various attributes directly related to the nest frequency. diff --git a/src/include/usr/targeting/common/targetUtil.H b/src/include/usr/targeting/common/targetUtil.H new file mode 100644 index 000000000..86a49c8b0 --- /dev/null +++ b/src/include/usr/targeting/common/targetUtil.H @@ -0,0 +1,154 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/targeting/common/targetUtil.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2013,2019 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ + +/** + * @file + * + * @brief Defines templates methods that require the use of the + * class Target and struct Attribute. Having the methods + * in this file helps with circular dependencies issue. + */ + +#ifndef __TARGETING_COMMON_TARGET_UTIL_H +#define __TARGETING_COMMON_TARGET_UTIL_H + +#include <stdint.h> // int16_t, uint8_t +#include <attributeenums.H> // TARGETING::ATTRIBUTE_ID +#include <targeting/common/target.H> // Target +#include <targeting/common/attributeTank.H> // AttributeTank::Attribute + +#ifndef STANDALONE_COMPILE + +namespace TARGETING +{ +/** + * @brief Returns the target handle's attribute associated with the given + * simple type attribute ID. + * + * @param[in] i_target The target to retrieve the attribute data from + * @param[out] o_attribute The attribute data, for the given attribute ID, + * if found + * + * @pre i_target must be a valid target + * + * @return Attribute data for given attribute ID, if found, else + * outgoing attribute will not touched + * + * @retval true is successful in locating the attribute ID, false otherwise + */ +template<const ATTRIBUTE_ID A> +bool makeAttribute(TargetHandle_t i_target, + AttributeTank::Attribute& o_attribute) +{ + // Set up the return value to true ... hoping for the best + bool retVal(true); + + do + { + // Some needed variables and their defaults + uint16_t l_positon(TARGETING::AttributeTank::ATTR_POS_NA); + uint8_t l_unitPositon(AttributeTank::ATTR_UNIT_POS_NA), + l_node(AttributeTank::ATTR_NODE_NA); + + // Get the target's position data + i_target->getAttrTankTargetPosData(l_positon, l_unitPositon, l_node); + + // Get the target's type and the target's attribute data + auto l_targetType = i_target->getAttrTankTargetType(); + auto l_attributeData = i_target->getAttr<A>(); + + // Populate the outgoing Attribute with the data retrieved above + o_attribute.setId(A); + o_attribute.setTargetType(l_targetType); + o_attribute.setPosition(l_positon); + o_attribute.setUnitPosition(l_unitPositon); + o_attribute.setNode(l_node); + o_attribute.setValue(&l_attributeData, sizeof(l_attributeData)); + } while (0); + + return retVal; +}; // end makeAttribute + +/** + * @brief Returns the target handle's attribute associated with the given + * complex type attribute ID. + * + * @param[in] i_target The target to retrieve the attribute data from + * @param[out] o_attribute The attribute data, for the given attribute ID, + * if found + * + * @pre i_target must be a valid target + * + * @return Attribute data for given attribute ID, if found, else + * outgoing attribute will not touched + * + * @retval true is successful in locating the attribute ID, false otherwise + */ +template<const ATTRIBUTE_ID A> +bool makeAttributeStdArr(TargetHandle_t i_target, + AttributeTank::Attribute& o_attribute) +{ + // Set up the return value to true ... hoping for the best + bool retVal(true); + + // Variable to hold the complex type, when found + typename AttributeTraits<A>::TypeStdArr l_attributeValue; + + do + { + // Some needed variables and their defaults + uint16_t l_positon(TARGETING::AttributeTank::ATTR_POS_NA); + uint8_t l_unitPositon(AttributeTank::ATTR_UNIT_POS_NA), + l_node(AttributeTank::ATTR_NODE_NA); + + // Get the target's position data + i_target->getAttrTankTargetPosData(l_positon, l_unitPositon, l_node); + + // Get the target's type and the target's attribute data + auto l_targetType = i_target->getAttrTankTargetType(); + bool l_found = i_target->tryGetAttr<A>(l_attributeValue); + if (!l_found) + { + retVal = false; + break; + } + + // Populate the outgoing Attribute with the data retrieved above + o_attribute.setId(A); + o_attribute.setTargetType(l_targetType); + o_attribute.setPosition(l_positon); + o_attribute.setUnitPosition(l_unitPositon); + o_attribute.setNode(l_node); + o_attribute.setValue(&l_attributeValue, sizeof(l_attributeValue)); + } while (0); + + return retVal; +}; // end makeAttributeStdArr + +}; // end namespace TARGETING + +#endif // end STANDALONE_COMPILE + +#endif // end __TARGETING_COMMON_TARGET_UTIL_H diff --git a/src/include/usr/targeting/common/trace.H b/src/include/usr/targeting/common/trace.H index bf42dd625..4376b56d7 100644 --- a/src/include/usr/targeting/common/trace.H +++ b/src/include/usr/targeting/common/trace.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2014 */ +/* Contributors Listed Below - COPYRIGHT 2012,2019 */ /* [+] Google Inc. */ /* [+] International Business Machines Corp. */ /* */ @@ -41,7 +41,6 @@ // Other includes #include <targeting/adapters/traceadapter.H> #ifdef __HOSTBOOT_MODULE -#include <config.h> #endif #define TARG_LOC TARG_NAMESPACE TARG_CLASS TARG_FN ": " diff --git a/src/include/usr/targeting/common/util.H b/src/include/usr/targeting/common/util.H index 6f0fcb307..ba41445c1 100644 --- a/src/include/usr/targeting/common/util.H +++ b/src/include/usr/targeting/common/util.H @@ -102,6 +102,15 @@ namespace UTIL P9N23_P9C13_NATIVE_MODE_MINIMUM = 0x04, P9N23_P9C13_NATIVE_SMF_RUGBY_FAVOR_SECURITY = 0x04, P9N23_P9C13_NATIVE_SMF_RUGBY_FAVOR_PERFORMANCE = 0x05, + + // Axone modes (same as DD2.3 native mode) + P9A_RUGBY_FAVOR_SECURITY = 0x04, + P9A_RUGBY_FAVOR_PERFORMANCE = 0x05, + // The _LOWER numbered values are equivalent to the higher + // values but they exist to maintain compatibility with + // Nimbus DD2.3 settings. + P9A_RUGBY_FAVOR_SECURITY_LOWER = 0x00, + P9A_RUGBY_FAVOR_PERFORMANCE_LOWER = 0x01, } Risk_level; } diff --git a/src/include/usr/targeting/runtime/rt_targeting.H b/src/include/usr/targeting/runtime/rt_targeting.H new file mode 100644 index 000000000..c94b871a9 --- /dev/null +++ b/src/include/usr/targeting/runtime/rt_targeting.H @@ -0,0 +1,89 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/targeting/runtime/rt_targeting.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2014,2020 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +#ifndef __RT_TARGETING_H +#define __RT_TARGETING_H + +#include <errl/errlentry.H> +#include <targeting/common/hbrt_target.H> + +namespace TARGETING +{ + class Target; +} + +namespace RT_TARG +{ + + enum + { + MEMBUF_ID_SHIFT = 4, //!< CHIPID for MEMBUF is '<procid>MMMM'b + MEMBUF_ID_MASK = 0x0000000F, //!< valid position bits for MEMBUF + }; + + + + /** + * @brief Convert a runtime chip_id (target) into a TARGETING::Target + * @param[in] The rt chipId + * @param[out] The TARGETING::Target pointer + * @return error log handle on error else NULL + */ + errlHndl_t getHbTarget(TARGETING::rtChipId_t i_rt_chip_id, + TARGETING::Target *& o_target); + + /** + * @brief Save/Restore attribute values from current Reserved Memory data + * into new LID Structure data + * @param[in] Pointer to current Reserved Memory targeting binary data + * @param[in/out] Pointer to new LID Structure targeting binary data + * @param[in] Instance, ie, Node ID + * @return nullptr on success, else error log + */ + errlHndl_t saveRestoreAttrs(void *i_rsvdMemPtr, + void *io_lidStructPtr, + uint8_t i_instance); + + /** + * @brief Validate LID Structure against Reserved Memory. Check that the + * TargetingHeader eyecatchers are valid, that the TargetingHeader number of + * sections match, and that the types and sizes of each TargetingSection + * match. + * @param[in] Pointer to new LID Structure targeting binary data + * @param[in] Pointer to current Reserved Memory targeting binary data + * @param[out] Total size of all sections in the new lid + * @return nullptr on success, else error log + */ + errlHndl_t validateData(void *i_lidStructPtr, + void *i_rsvdMemPtr, + size_t& o_lidTotalSize); + + /** + * @brief Apply ATTR_TMP overrides to be available for run time + */ + void applyTempOverrides( ); + +}; + +#endif |