diff options
author | Luis Fernandez <Luis.Fernandez@ibm.com> | 2019-04-22 14:27:12 -0500 |
---|---|---|
committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2019-05-09 16:32:36 -0500 |
commit | fe000f81b6492f77e783f72b408260d5346b9757 (patch) | |
tree | 553a97646b7152ef4b09810aad855277903287eb /src/include/usr/targeting | |
parent | d2da0774fa01e5bb89a717baf814e43f5f3fef0a (diff) | |
download | talos-hostboot-fe000f81b6492f77e783f72b408260d5346b9757.tar.gz talos-hostboot-fe000f81b6492f77e783f72b408260d5346b9757.zip |
Revisit attributes with array types.
Use std::array to set and get attributes' value that support array.
Change-Id: I9dc31bbca5ad0c56add353c6d4233296d2bb200a
RTC: 110583
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/76347
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Reviewed-by: Ilya Smirnov <ismirno@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/include/usr/targeting')
-rw-r--r-- | src/include/usr/targeting/common/target.H | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/src/include/usr/targeting/common/target.H b/src/include/usr/targeting/common/target.H index 08fcb3f76..bfb5e70c7 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 @@ -729,8 +825,10 @@ class Target 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 +963,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 +997,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 +1055,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 +1113,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. |