From bb97d2b25e75b478db3963758afaddeeb65ed74b Mon Sep 17 00:00:00 2001 From: Patrick Williams Date: Fri, 18 Mar 2016 14:16:41 -0500 Subject: Ensure fapi2::Target honors platform value type. The fapi2::Target template is as follows: template In many places the code was using the default V type instead of preserving the type of the template. As an example: Target getParent(void) const; // old vs Target getParent(void) const; // new With the old variant, a Target is converted to a Target by the getParent() function instead of maintaining the V type. Added associated ecmd release ver-14-4-2-ekbonly for testing Change-Id: Ie613d658c59f5f6d3ce7be95f3b1e816b52582e0 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/22247 Tested-by: Jenkins Server Tested-by: PPE CI Tested-by: Hostboot CI Reviewed-by: Santosh S. Puranik Reviewed-by: Brian R. Silver Reviewed-by: Jennifer A. Stofer Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/27035 Reviewed-by: Sachin Gupta --- import/hwpf/fapi2/include/fapi2_target.H | 48 ++++++++++++++++---------------- import/hwpf/fapi2/include/plat/target.H | 29 ++++++++++--------- 2 files changed, 40 insertions(+), 37 deletions(-) (limited to 'import/hwpf') diff --git a/import/hwpf/fapi2/include/fapi2_target.H b/import/hwpf/fapi2/include/fapi2_target.H index 231e5ad9..db61b30e 100644 --- a/import/hwpf/fapi2/include/fapi2_target.H +++ b/import/hwpf/fapi2/include/fapi2_target.H @@ -114,7 +114,7 @@ class Target /// single uint64_t in value which represents all the information /// they might need. value( K | V ), for example /// - Target(V Value): + Target(const V& Value): iv_handle(Value) {}; @@ -195,7 +195,7 @@ class Target /// @return Target a target representing the parent /// template< TargetType T > - inline Target getParent(void) const; + inline Target getParent(void) const; /// /// @brief Is this target a chip? @@ -263,13 +263,13 @@ class Target /// @brief Get this target's children /// @tparam T The type of the parent /// @param[in] i_state The desired TargetState of the children - /// @return std::vector > a vector of present/functional + /// @return std::vector> a vector of present/functional /// children /// @warning The children of EX's (cores) are expected to be returned /// in order. That is, core 0 is std::vector[0]. /// template< TargetType T> - inline std::vector > + inline std::vector > getChildren(const TargetState i_state = TARGET_STATE_FUNCTIONAL) const; /// @@ -277,11 +277,11 @@ class Target /// @tparam T The type of the parent /// @param[in] i_filter The desired chiplet filter /// @param[in] i_state The desired TargetState of the children - /// @return std::vector > a vector of present/functional + /// @return std::vector> a vector of present/functional /// children /// template< TargetType T> - inline std::vector > + inline std::vector > getChildren(const TargetFilter i_filter, const TargetState i_state = TARGET_STATE_FUNCTIONAL) const; @@ -297,7 +297,7 @@ class Target template inline fapi2::ReturnCodes - getOtherEnd(Target& o_target, const TargetState i_state = TARGET_STATE_FUNCTIONAL) const; + getOtherEnd(Target& o_target, const TargetState i_state = TARGET_STATE_FUNCTIONAL) const; /// /// @brief Is the target functional? @@ -321,8 +321,8 @@ class Target /// @brief Copy from a Target to a Target /// @tparam O the target type of the other /// - template - inline Target( const Target& Other ): + template + inline Target( const Target& Other ): Target(Other.get()) { // In case of recursion depth failure, use -ftemplate-depth= @@ -460,29 +460,29 @@ inline uint8_t thread_bitset_f2n(const uint8_t i_ordinal, const uint8_t i_thread /// /// @brief Return the string interpretation of this target /// @tparam T The type of the target -/// @param[in] i_target Target +/// @param[in] i_target Target /// @param[in] i_buffer buffer to write in to /// @param[in] i_bsize size of the buffer /// @return void /// @post The contents of the buffer is replaced with the string /// representation of the target /// -template< TargetType T > -inline void toString(const Target& i_target, char* i_buffer, size_t i_bsize); +template< TargetType T, typename V > +inline void toString(const Target& i_target, char* i_buffer, size_t i_bsize); /// /// @brief Return the string interpretation of this target /// @tparam T The type of the target /// @tparam B The type of the buffer -/// @param[in] i_target A pointer to the Target +/// @param[in] i_target A pointer to the Target /// @param[in] i_buffer buffer to write in to /// @param[in] i_bsize size of the buffer /// @return void /// @post The contents of the buffer is replaced with the string /// representation of the target /// -template< TargetType T > -inline void toString(const Target* i_target, char* i_buffer, size_t i_bsize); +template< TargetType T, typename V > +inline void toString(const Target* i_target, char* i_buffer, size_t i_bsize); /// /// @brief Get an enumerated target of a specific type @@ -491,8 +491,8 @@ inline void toString(const Target* i_target, char* i_buffer, size_t i_bsize); /// the desired target /// @return Target the target requested /// -template -inline Target getTarget(uint64_t Ordinal); +template +inline Target getTarget(uint64_t Ordinal); // Why has the been removed? For starters, the API name // is probably wrong as it's already been confused with @@ -503,14 +503,14 @@ inline Target getTarget(uint64_t Ordinal); /// /// @brief Get the base target's children /// @tparam T The type of the target -/// @return std::vector > a vector of present/functional +/// @return std::vector> a vector of present/functional /// children /// -template -inline std::vector > getChildren() +template +inline std::vector> getChildren() { // For testing - return {Target(), Target()}; + return {Target(), Target()}; } #endif @@ -518,14 +518,14 @@ inline std::vector > getChildren() /// @brief Return the string interpretation of this target /// @tparam T The type of the target /// @tparam B The type of the buffer -/// @param[in] i_target Target +/// @param[in] i_target Target /// @param[in] i_buffer buffer /// @return void /// @post The contents of the buffer is replaced with the string /// representation of the target /// -template -inline void toString(const Target& i_target, B& i_buffer); +template +inline void toString(const Target& i_target, B& i_buffer); /// /// @brief Check if the target is of a type, or in a type subset. diff --git a/import/hwpf/fapi2/include/plat/target.H b/import/hwpf/fapi2/include/plat/target.H index ffc88e41..e09bdb70 100644 --- a/import/hwpf/fapi2/include/plat/target.H +++ b/import/hwpf/fapi2/include/plat/target.H @@ -89,10 +89,10 @@ bool Target::operator<(const Target& i_right) const /// template template -inline Target Target::getParent(void) const +inline Target Target::getParent(void) const { // For testing - return Target(iv_handle); + return Target(iv_handle); } /// @@ -106,13 +106,13 @@ inline Target Target::getParent(void) const /// template template< TargetType T> -inline std::vector > +inline std::vector > Target::getChildren(const TargetState i_state) const { // To keep the compiler quiet about unused variables static_cast(i_state); // For testing - return {Target(), Target()}; + return {Target(), Target()}; } // Specialization of getChildren, filtered for pervasive targets. template<> @@ -142,12 +142,13 @@ Target::getChildren(const TargetFilter i_filter, template template inline fapi2::ReturnCodes -Target::getOtherEnd(Target& o_target, const TargetState i_state) const +Target::getOtherEnd(Target& o_target, + const TargetState i_state) const { // To keep the compiler quiet about unused variables static_cast(i_state); - o_target = Target(); + o_target = Target(); return FAPI2_RC_SUCCESS; } @@ -191,8 +192,9 @@ Target::getChipletNumber(void) const /// @post The contents of the buffer is replaced with the string /// representation of the target /// -template< TargetType T > -inline void toString(const Target& i_target, char* i_buffer, size_t i_bsize) +template< TargetType T, typename V > +inline void toString(const Target& i_target, + char* i_buffer, size_t i_bsize) { snprintf(i_buffer, i_bsize, "Target 0x%lx/0x%x", i_target.get(), T); } @@ -208,8 +210,9 @@ inline void toString(const Target& i_target, char* i_buffer, size_t i_bsize) /// @post The contents of the buffer is replaced with the string /// representation of the target /// -template< TargetType T > -inline void toString(const Target* i_target, char* i_buffer, size_t i_bsize) +template< TargetType T, typename V > +inline void toString(const Target* i_target, + char* i_buffer, size_t i_bsize) { snprintf(i_buffer, i_bsize, "Target 0x%lx/0x%x", i_target->get(), T); } @@ -221,11 +224,11 @@ inline void toString(const Target* i_target, char* i_buffer, size_t i_bsize) /// the desired target /// @return Target the target requested /// -template -inline Target getTarget(uint64_t Ordinal) +template +inline Target getTarget(uint64_t Ordinal) { // For testing - return Target(Ordinal); + return Target(Ordinal); } } -- cgit v1.2.1