From b9b668e5916e3310eacb95496cc0792d819b25f0 Mon Sep 17 00:00:00 2001 From: Joachim Fenkes Date: Wed, 5 Dec 2018 16:47:55 +0100 Subject: FAPI2: Multicast API 1/2: Platform-breaking changes The Target gains a new template parameter, M, that specifies the multicast type. This is propagated through all affected header files. A new target type is introduced, TARGET_TYPE_MULTICAST, and platform specific assertions put in place to prevent users from creating such targets before the platform supports it. Target also grows a new inline function for updating MC targets. Platforms not supporting MC can provide a dummy implementation. The example platform code in fapi2/include/plat/plat_target.H is updated with minimal example code for platform implementers. Change-Id: Ia0990f26890dc5c719caca608cd134a4964a3acf Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/69456 Tested-by: Jenkins Server Tested-by: HWSV CI Tested-by: FSP CI Jenkins Reviewed-by: Matt K. Light Tested-by: PPE CI Tested-by: Hostboot CI Reviewed-by: Daniel M. Crowell Reviewed-by: RAJA DAS Reviewed-by: Jennifer A. Stofer Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/70866 Reviewed-by: Sachin Gupta --- src/hwpf/hw_access.H | 78 +++++----- src/hwpf/multicast.H | 54 ------- src/hwpf/plat_target.H | 10 +- src/hwpf/target.H | 92 +++++------ src/import/hwpf/fapi2/include/error_info_defs.H | 6 +- src/import/hwpf/fapi2/include/fapi2_hw_access.H | 78 +++++----- src/import/hwpf/fapi2/include/fapi2_i2c_access.H | 10 +- src/import/hwpf/fapi2/include/fapi2_multicast.H | 171 --------------------- .../hwpf/fapi2/include/fapi2_multicast_defs.H | 42 ----- src/import/hwpf/fapi2/include/fapi2_target.H | 78 +++++----- src/import/hwpf/fapi2/include/fapi2_vpd_access.H | 4 +- src/import/hwpf/fapi2/include/multicast_defs.H | 42 +++++ src/import/hwpf/fapi2/include/plat/hw_access.H | 74 ++++----- src/import/hwpf/fapi2/include/plat/target.H | 78 ++++++---- src/import/hwpf/fapi2/include/utils.H | 6 +- 15 files changed, 303 insertions(+), 520 deletions(-) delete mode 100644 src/hwpf/multicast.H delete mode 100644 src/import/hwpf/fapi2/include/fapi2_multicast.H delete mode 100644 src/import/hwpf/fapi2/include/fapi2_multicast_defs.H create mode 100644 src/import/hwpf/fapi2/include/multicast_defs.H diff --git a/src/hwpf/hw_access.H b/src/hwpf/hw_access.H index ab17a763..d00304e4 100644 --- a/src/hwpf/hw_access.H +++ b/src/hwpf/hw_access.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER sbe Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2017 */ +/* Contributors Listed Below - COPYRIGHT 2012,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -105,9 +105,9 @@ namespace fapi2 /// @param[in] i_address SCOM register address to read from. /// @param[out] o_data Buffer that holds data read from HW target. /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K, typename V > + template< TargetType K, MulticastType M, typename V > __attribute__((always_inline)) - inline ReturnCode getScom(const Target& i_target, const uint64_t i_address, + inline ReturnCode getScom(const Target& i_target, const uint64_t i_address, buffer& o_data) { fapi2::ReturnCode l_rc; @@ -125,9 +125,9 @@ namespace fapi2 /// @param[in] i_address SCOM register address to write to. /// @param[in] i_data Buffer that holds data to write into address. /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K, typename V > + template< TargetType K, MulticastType M, typename V > __attribute__((always_inline)) - inline ReturnCode putScom(const Target& i_target, const uint64_t i_address, + inline ReturnCode putScom(const Target& i_target, const uint64_t i_address, const buffer i_data) { fapi2::ReturnCode l_rc; @@ -146,8 +146,8 @@ namespace fapi2 /// @param[in] i_data Buffer that holds data to be modified. /// @param[in] i_modifyMode The modify mode (or/and/xor). /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K, typename V > - inline ReturnCode modifyScom(const Target& i_target, + template< TargetType K, MulticastType M, typename V > + inline ReturnCode modifyScom(const Target& i_target, const uint64_t i_address, const buffer i_data, const ChipOpModifyMode i_modifyMode) @@ -196,8 +196,8 @@ __fapi2exit__: /// @param[in] i_data Buffer that holds data to write into address. /// @param[in] i_mask Buffer that holds the mask value. /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K, typename V > - inline ReturnCode putScomUnderMask( const Target& i_target, + template< TargetType K, MulticastType M, typename V > + inline ReturnCode putScomUnderMask( const Target& i_target, const uint64_t i_address, const buffer i_data, const buffer i_mask) @@ -214,8 +214,8 @@ __fapi2exit__: /// @param[in] i_address CFAM register address to read from. /// @param[out] o_data Buffer that holds data read from HW target. /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K, typename V > - inline ReturnCode getCfamRegister(const Target& i_target, + template< TargetType K, MulticastType M, typename V > + inline ReturnCode getCfamRegister(const Target& i_target, const uint32_t i_address, buffer& o_data) { @@ -234,8 +234,8 @@ __fapi2exit__: /// @param[in] i_address CFAM register address to write to. /// @param[in] i_data Buffer that holds data to write into address. /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K, typename V > - inline ReturnCode putCfamRegister(const Target& i_target, + template< TargetType K, MulticastType M, typename V > + inline ReturnCode putCfamRegister(const Target& i_target, const uint32_t i_address, buffer& i_data) { @@ -255,8 +255,8 @@ __fapi2exit__: /// @param[in] i_data Buffer that holds data to be modified. /// @param[in] i_modifyMode The modify mode (or/and/xor). /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K, typename V > - inline ReturnCode modifyCfamRegister(const Target& i_target, + template< TargetType K, MulticastType M, typename V > + inline ReturnCode modifyCfamRegister(const Target& i_target, const uint32_t i_address, const buffer& i_data, const ChipOpModifyMode i_modifyMode) @@ -277,8 +277,8 @@ __fapi2exit__: /// @param[in] i_ringID Ring ID that will identify the Ring in the image. /// @param[in] i_ringMode Ring operation mode. /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K, typename V > - inline ReturnCode putRing(const Target& i_target, + template< TargetType K, MulticastType M, typename V > + inline ReturnCode putRing(const Target& i_target, const RingId_t i_ringID, const RingMode i_ringMode = RING_MODE_HEADER_CHECK) { @@ -299,8 +299,8 @@ __fapi2exit__: /// @param[out] o_data Buffer that holds data read from HW target. /// @param[in] i_ringMode Ring operation mode. /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K, typename V > - inline ReturnCode getRing(const Target& i_target, + template< TargetType K, MulticastType M, typename V > + inline ReturnCode getRing(const Target& i_target, const scanRingId_t i_address, variable_buffer& o_data, const RingMode i_ringMode = 0) @@ -329,8 +329,8 @@ __fapi2exit__: /// @param[in] i_modifyMode The modify mode (or/and/xor) /// @param[in] i_ringMode Ring operation mode. /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K, typename V > - inline ReturnCode modifyRing(const Target& i_target, + template< TargetType K, MulticastType M, typename V > + inline ReturnCode modifyRing(const Target& i_target, const scanRingId_t i_address, variable_buffer& i_data, const ChipOpModifyMode i_modifyMode, @@ -382,8 +382,8 @@ __fapi2exit__: /// SCOM_BULK_WRITE_MODE operations are not supported due to /// hardware limitations. /// - template< TargetType K, typename V > - fapi2::ReturnCode multiScom (const Target& i_target, + template< TargetType K, MulticastType M, typename V > + fapi2::ReturnCode multiScom (const Target& i_target, MultiScom& io_multiScomObj) { } @@ -436,8 +436,8 @@ __fapi2exit__: /// the quotes for the cronus environment /// #ifdef FAPI_SUPPORT_SPY_AS_ENUM - template< TargetType K, typename V > - inline ReturnCode getSpy(const Target& i_target, + template< TargetType K, MulticastType M, typename V > + inline ReturnCode getSpy(const Target& i_target, const spyId_t i_spyId, variable_buffer& o_data) { @@ -446,8 +446,8 @@ __fapi2exit__: } #endif #ifdef FAPI_SUPPORT_SPY_AS_STRING - template< TargetType K, typename V > - inline ReturnCode getSpy(const Target& i_target, + template< TargetType K, MulticastType M, typename V > + inline ReturnCode getSpy(const Target& i_target, const char * const i_spyId, variable_buffer& o_data) { @@ -495,8 +495,8 @@ __fapi2exit__: /// the quotes for the cronus environment /// #ifdef FAPI_SUPPORT_SPY_AS_ENUM - template< TargetType K, typename V > - inline ReturnCode putSpy(const Target& i_target, + template< TargetType K, MulticastType M, typename V > + inline ReturnCode putSpy(const Target& i_target, const spyId_t i_spyId, variable_buffer& i_data) { @@ -505,8 +505,8 @@ __fapi2exit__: } #endif #ifdef FAPI_SUPPORT_SPY_AS_STRING - template< TargetType K, typename V > - inline ReturnCode putSpy(const Target& i_target, + template< TargetType K, MulticastType M, typename V > + inline ReturnCode putSpy(const Target& i_target, const char* const i_spyId, variable_buffer& i_data) { @@ -535,8 +535,8 @@ __fapi2exit__: /// See fapiPutSpy for details on spy id specifics. /// #ifdef FAPI_SUPPORT_SPY_AS_ENUM - template< TargetType K, typename V > - inline ReturnCode putSpyImage(const Target& i_target, + template< TargetType K, MulticastType M, typename V > + inline ReturnCode putSpyImage(const Target& i_target, const spyId_t i_spyId, const variable_buffer& i_data, variable_buffer& o_imageData) @@ -546,8 +546,8 @@ __fapi2exit__: } #endif #ifdef FAPI_SUPPORT_SPY_AS_STRING - template< TargetType K, typename V > - inline ReturnCode putSpyImage(const Target& i_target, + template< TargetType K, MulticastType M, typename V > + inline ReturnCode putSpyImage(const Target& i_target, const char* const i_spyId, const variable_buffer& i_data, variable_buffer& o_imageData) @@ -574,8 +574,8 @@ __fapi2exit__: /// See fapiPutSpy for details on spy id specifics. /// #ifdef FAPI_SUPPORT_SPY_AS_ENUM - template< TargetType K, typename V > - inline ReturnCode getSpyImage(const Target& i_target, + template< TargetType K, MulticastType M, typename V > + inline ReturnCode getSpyImage(const Target& i_target, const spyId_t i_spyId, variable_buffer& o_data, const variable_buffer& i_imageData) @@ -585,8 +585,8 @@ __fapi2exit__: } #endif #ifdef FAPI_SUPPORT_SPY_AS_STRING - template< TargetType K, typename V > - inline ReturnCode getSpyImage(const Target& i_target, + template< TargetType K, MulticastType M, typename V > + inline ReturnCode getSpyImage(const Target& i_target, const char * const i_spyId, variable_buffer& o_data, const variable_buffer& i_imageData) diff --git a/src/hwpf/multicast.H b/src/hwpf/multicast.H deleted file mode 100644 index 8ec0c4a7..00000000 --- a/src/hwpf/multicast.H +++ /dev/null @@ -1,54 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/hwpf/multicast.H $ */ -/* */ -/* OpenPOWER sbe Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2016,2017 */ -/* */ -/* */ -/* 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 __FAPI2_MULTICAST__ -#define __FAPI2_MULTICAST__ - -#include - -namespace fapi2 -{ - -template -template -inline void Multicast::updateHandle(V& i_value) -{ - // Update handle only if multicast bit is set in handle, else we leave the - // handle unchanged. This enables the same procedure to work with both - // multicast and unicast targets - if(i_value.fields.is_multicast) - { - // Update the handle to reflect the new multicast type and group - i_value.fields.chiplet_num = (0x40) | (O << 3) | N; - } -} - -template -inline bool Multicast::isMulticast() const -{ - return iv_handle.fields.is_multicast; -} - -} - -#endif diff --git a/src/hwpf/plat_target.H b/src/hwpf/plat_target.H index 1d32dbb8..8606ffa1 100644 --- a/src/hwpf/plat_target.H +++ b/src/hwpf/plat_target.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER sbe Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015,2017 */ +/* Contributors Listed Below - COPYRIGHT 2015,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -53,6 +54,13 @@ static const uint8_t PCI0_CHIPLET = 0x0D; // namespace fapi2 { + template + static constexpr void plat_apply_target_limits(void) + { + static_assert(!(K & TARGET_TYPE_MULTICAST), + "Multicast targets are not supported on this platform"); + } + typedef enum plat_target_type { PPE_TARGET_TYPE_NONE = 0x00, diff --git a/src/hwpf/target.H b/src/hwpf/target.H index 09f5793d..5b746f0e 100644 --- a/src/hwpf/target.H +++ b/src/hwpf/target.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER sbe Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2017 */ +/* Contributors Listed Below - COPYRIGHT 2012,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -149,8 +148,8 @@ namespace fapi2 /// @param[in] i_right Reference to Target to assign from. /// @return Reference to 'this' Target /// - template - Target& Target::operator=(const Target& i_right) + template + Target& Target::operator=(const Target& i_right) { this->iv_handle.value = i_right.iv_handle.value; return *this; @@ -162,8 +161,8 @@ namespace fapi2 /// @note Platforms need to define this so that the physical /// targets are determined to be equivilent rather than just the handles /// - template - bool Target::operator==(const Target& i_right) const + template + bool Target::operator==(const Target& i_right) const { if (this->iv_handle.value == i_right.iv_handle.value) return true; @@ -178,8 +177,8 @@ namespace fapi2 /// @note Platforms need to define this so that the physical /// targets are determined to be equivilent rather than just the handles /// - template - bool Target::operator!=(const Target& i_right) const + template + bool Target::operator!=(const Target& i_right) const { if (this->iv_handle.value != i_right.iv_handle.value) return true; @@ -190,11 +189,11 @@ namespace fapi2 /// /// @brief Get this target's immediate parent /// @tparam T The type of the parent - /// @return Target a target representing the parent + /// @return Target a target representing the parent /// - template + template template - inline Target Target::getParent(void) const + inline Target Target::getParent(void) const { constexpr TargetType TARGET_TYPE_PROC_CHILDREN = TARGET_TYPE_EQ | TARGET_TYPE_PERV | TARGET_TYPE_EX | @@ -273,23 +272,11 @@ namespace fapi2 { return static_cast(G_vec_targets[(static_cast(get()).getTargetInstance() / CORES_PER_EX) + EX_TARGET_OFFSET]); } - } - - /// - /// @brief Get this target's immediate parent - specialization for compound - // target (PROC_CHIP | CORE | EX) - /// @tparam T The type of the parent - /// @return Target a target representing the parent - /// - template<> - template - Target - Target::getParent(void) const - { - static_assert(((T == TARGET_TYPE_PROC_CHIP) || (T == TARGET_TYPE_EQ)), - "Wrong parent target type"); - return static_cast(get()).getParent(T); + constexpr TargetType TARGET_TYPE_CORE_OR_EX = TARGET_TYPE_CORE | TARGET_TYPE_EX; + if((TARGET_TYPE_EQ == T) && ((K & (TARGET_TYPE_CORE_OR_EX)) != TARGET_TYPE_NONE)) + { + return get().getParent(T); + } } /// @brief Get this target's children - handles EQ/EX/EC conversions @@ -297,19 +284,19 @@ namespace fapi2 /// @tparam V The plat target handle type /// @tparam T The type of child /// @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 are returned in order, ex child[0] is /// std::vector[0] - template + template template - std::vector> - Target::getChildren(const TargetState i_state) const + std::vector> + Target::getChildren(const TargetState i_state) const { constexpr TargetType L = static_cast(K & ~(TARGET_TYPE_PROC_CHIP)); constexpr plat_target_type_t P = fapiTargetTypeToPlatTargetType(); - static_assert(sizeof(Target) == sizeof(plat_target_handle_t), + static_assert(sizeof(Target) == sizeof(plat_target_handle_t), "Sizes of plat target and FAPI target must match"); static_assert(((L == TARGET_TYPE_EQ) || (L == TARGET_TYPE_EX) || (K == TARGET_TYPE_PROC_CHIP)), @@ -329,19 +316,19 @@ namespace fapi2 "improper child of fapi2::TARGET_TYPE_EX"); - std::vector > l_children; + std::vector > l_children; static_cast(get()).getChildren(K, T, P, i_state, reinterpret_cast&>(l_children)); return l_children; } // Specialization of getChildren, filtered for the chip target - template + template template - std::vector > - Target::getChildren(const TargetFilter i_filter, + std::vector > + Target::getChildren(const TargetFilter i_filter, const TargetState i_state) const { - static_assert(sizeof(Target) == sizeof(plat_target_handle_t), + static_assert(sizeof(Target) == sizeof(plat_target_handle_t), "Sizes of plat target and FAPI target must match"); static_assert((K == TARGET_TYPE_PROC_CHIP), "Parent target must be the proc chip"); @@ -361,9 +348,9 @@ namespace fapi2 /// @brief Is the target functional? /// @return true if target is functional, false if non-functional /// - template + template inline bool - Target::isFunctional(void) const + Target::isFunctional(void) const { return static_cast(get()).getFunctional(); } @@ -372,9 +359,9 @@ namespace fapi2 /// @brief Returns the chiplet number for this Target /// @return The chiplet number /// - template + template inline uint8_t - Target::getChipletNumber(void) const + Target::getChipletNumber(void) const { return static_cast(iv_handle).fields.chiplet_num; } @@ -389,8 +376,8 @@ namespace fapi2 /// @post The contents of the buffer is replaced with the string /// representation of the target /// - template< TargetType T, typename V > - inline void toString(const Target& i_target, char* i_buffer, size_t i_bsize) + template< TargetType T, MulticastType M, 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); } @@ -399,15 +386,15 @@ namespace fapi2 /// @brief Return the string interpretation of this target /// @tparam T The type of the target /// @tparam B The type of the buffer - /// @param[in] A pointer to the Target + /// @param[in] 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, typename V > - inline void toString(const Target* i_target, char* i_buffer, size_t i_bsize) + template< TargetType T, MulticastType M, 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); } @@ -417,14 +404,17 @@ namespace fapi2 /// @tparam T The type of the target /// @param[in] Ordinal representing the ordinal number of /// the desired target - /// @return Target the target requested + /// @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); } + + template + inline void Target::mcUpdateHandle() {}; } #endif diff --git a/src/import/hwpf/fapi2/include/error_info_defs.H b/src/import/hwpf/fapi2/include/error_info_defs.H index c9ff6fc6..7871c99b 100644 --- a/src/import/hwpf/fapi2/include/error_info_defs.H +++ b/src/import/hwpf/fapi2/include/error_info_defs.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER sbe Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015,2018 */ +/* Contributors Listed Below - COPYRIGHT 2015,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -393,8 +393,8 @@ inline uint16_t getErrorInfoFfdcSize(const T*) /// /// @brief Get FFDC Size specialization for fapi2::Target /// -template -inline uint16_t getErrorInfoFfdcSize(const fapi2::Target&) +template +inline uint16_t getErrorInfoFfdcSize(const fapi2::Target&) { return EI_FFDC_SIZE_TARGET; } diff --git a/src/import/hwpf/fapi2/include/fapi2_hw_access.H b/src/import/hwpf/fapi2/include/fapi2_hw_access.H index ee415f3b..9cb5b983 100644 --- a/src/import/hwpf/fapi2/include/fapi2_hw_access.H +++ b/src/import/hwpf/fapi2/include/fapi2_hw_access.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER sbe Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015,2018 */ +/* Contributors Listed Below - COPYRIGHT 2015,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -85,8 +85,8 @@ inline OpModes getOpMode(void); /// @param[in] i_address SCOM register address to read from. /// @param[out] o_data Buffer that holds data read from HW target. /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. -template< TargetType K, typename V > -inline ReturnCode getScom(const Target& i_target, const uint64_t i_address, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getScom(const Target& i_target, const uint64_t i_address, buffer& o_data); /// @brief Writes a SCOM register on a chip. @@ -95,8 +95,8 @@ inline ReturnCode getScom(const Target& i_target, const uint64_t i_address /// @param[in] i_address SCOM register address to write to. /// @param[in] i_data Buffer that holds data to write into address. /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. -template< TargetType K, typename V > -inline ReturnCode putScom(const Target& i_target, const uint64_t i_address, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putScom(const Target& i_target, const uint64_t i_address, const buffer i_data); /// @brief Writes a SCOM register under mask on a chip @@ -106,8 +106,8 @@ inline ReturnCode putScom(const Target& i_target, const uint64_t i_address /// @param[in] i_data Buffer that holds data to write into address. /// @param[in] i_mask Buffer that holds the mask value. /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. -template< TargetType K, typename V > -inline ReturnCode putScomUnderMask(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putScomUnderMask(const Target& i_target, const uint64_t i_address, const buffer i_data, const buffer i_mask); @@ -119,8 +119,8 @@ inline ReturnCode putScomUnderMask(const Target& i_target, /// @param[in] i_address CFAM register address to read from. /// @param[out] o_data Buffer that holds data read from HW target. /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. -template< TargetType K, typename V > -inline ReturnCode getCfamRegister(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getCfamRegister(const Target& i_target, const uint32_t i_address, buffer& o_data); @@ -131,8 +131,8 @@ inline ReturnCode getCfamRegister(const Target& i_target, /// @param[in] i_address CFAM register address to write to. /// @param[in] i_data Buffer that holds data to write into address. /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. -template< TargetType K, typename V > -inline ReturnCode putCfamRegister(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putCfamRegister(const Target& i_target, const uint32_t i_address, const buffer i_data); @@ -144,8 +144,8 @@ inline ReturnCode putCfamRegister(const Target& i_target, /// @param[in] i_data Buffer that holds data to be modified. /// @param[in] i_modifyMode The modify mode (or/and/xor). /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. -template< TargetType K, typename V > -inline ReturnCode modifyCfamRegister(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode modifyCfamRegister(const Target& i_target, const uint32_t i_address, const buffer i_data, const ChipOpModifyMode i_modifyMode); @@ -156,8 +156,8 @@ inline ReturnCode modifyCfamRegister(const Target& i_target, /// @param[in] i_ringID Ring ID that will identify the Ring in the image. /// @param[in] i_ringMode Ring operation mode. /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. -template< TargetType K, typename V > -ReturnCode putRing(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +ReturnCode putRing(const Target& i_target, const RingId_t i_ringID, const RingMode i_ringMode = RING_MODE_HEADER_CHECK); @@ -170,8 +170,8 @@ ReturnCode putRing(const Target& i_target, /// @param[out] o_data Buffer that holds data read from HW target. /// @param[in] i_ringMode Ring operation mode. /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. -template< TargetType K, typename V > -inline ReturnCode getRing(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getRing(const Target& i_target, const scanRingId_t i_address, variable_buffer& o_data, const RingMode i_ringMode = RING_MODE_HEADER_CHECK); @@ -185,8 +185,8 @@ inline ReturnCode getRing(const Target& i_target, /// @param[in] i_modifyMode The modify mode (or/and/xor) /// @param[in] i_ringMode Ring operation mode. /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. -template< TargetType K, typename V > -inline ReturnCode modifyRing(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode modifyRing(const Target& i_target, const scanRingId_t i_address, const variable_buffer& i_data, const ChipOpModifyMode i_modifyMode, @@ -242,8 +242,8 @@ inline ReturnCode modifyRing(const Target& i_target, #define FAPI_GET_SPY(TARGET, ID, DATA) fapi2::getSpy(TARGET, FAPI_SPY_NAMES::ID.value, DATA) -template< TargetType K, typename V > -inline ReturnCode getSpy(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getSpy(const Target& i_target, const spyId_t i_spyId, variable_buffer& o_data); @@ -258,8 +258,8 @@ inline ReturnCode getSpy(const Target& i_target, #define FAPI_GET_SPY(TARGET, ID, DATA) fapi2::getSpy(TARGET, #ID, DATA) -template< TargetType K, typename V > -inline ReturnCode getSpy(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getSpy(const Target& i_target, const char* const i_spyId, variable_buffer& o_data); @@ -313,8 +313,8 @@ inline ReturnCode getSpy(const Target& i_target, #define FAPI_PUT_SPY(TARGET, ID, DATA) fapi2::putSpy(TARGET, FAPI_SPY_NAMES::ID.value, DATA) -template< TargetType K, typename V > -inline ReturnCode putSpy(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putSpy(const Target& i_target, const spyId_t i_spyId, const variable_buffer& i_data); #endif @@ -323,19 +323,19 @@ inline ReturnCode putSpy(const Target& i_target, #define FAPI_PUT_SPY(TARGET, ID, DATA) fapi2::putSpy(TARGET, #ID, DATA) -template< TargetType K, typename V > -inline ReturnCode putSpy(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putSpy(const Target& i_target, const char* const i_spyId, const variable_buffer& i_data); -template -inline ReturnCode putSpyWithCare(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putSpyWithCare(const Target& i_target, const char* const i_spyId, const variable_buffer& i_data, const variable_buffer& i_care); -template< TargetType K, typename V > -inline ReturnCode putSpy(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putSpy(const Target& i_target, const char* const i_spyId, const char* i_enum); #endif @@ -366,8 +366,8 @@ inline ReturnCode putSpy(const Target& i_target, fapi2::putSpyImage(TARGET, FAPI_SPY_NAMES::ID.value, \ DATA1, DATA2) -template< TargetType K, typename V > -inline ReturnCode putSpyImage(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putSpyImage(const Target& i_target, const spyId_t i_spyId, const variable_buffer& i_data, variable_buffer& o_imageData); @@ -378,8 +378,8 @@ inline ReturnCode putSpyImage(const Target& i_target, #define FAPI_PUT_SPY_IMAGE(TARGET, ID, DATA1, DATA2) \ fapi2::putSpyImage(TARGET, #ID, DATA1,DATA2) -template< TargetType K, typename V > -inline ReturnCode putSpyImage(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putSpyImage(const Target& i_target, const char* const i_spyId, const variable_buffer& i_data, variable_buffer& o_imageData); @@ -408,8 +408,8 @@ inline ReturnCode putSpyImage(const Target& i_target, fapi2:getSpyImage(TARGET, FAPI_SPY_NAMES::ID.value, \ DATA1, DATA2) -template< TargetType K, typename V > -inline ReturnCode getSpyImage(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getSpyImage(const Target& i_target, const spyId_t i_spyId, variable_buffer& o_data, const variable_buffer& i_imageData); @@ -420,8 +420,8 @@ inline ReturnCode getSpyImage(const Target& i_target, #define FAPI_GET_SPY_IMAGE(TARGET, ID, DATA1, DATA2) \ fapi2::getSpyImage(TARGET, #ID, DATA1,DATA2) -template< TargetType K, typename V > -inline ReturnCode getSpyImage(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getSpyImage(const Target& i_target, const char* const i_spyId, variable_buffer& o_data, const variable_buffer& i_imageData); diff --git a/src/import/hwpf/fapi2/include/fapi2_i2c_access.H b/src/import/hwpf/fapi2/include/fapi2_i2c_access.H index 20d04b9e..a4f0eebe 100644 --- a/src/import/hwpf/fapi2/include/fapi2_i2c_access.H +++ b/src/import/hwpf/fapi2/include/fapi2_i2c_access.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER sbe Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2018 */ +/* Contributors Listed Below - COPYRIGHT 2018,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -66,8 +66,8 @@ namespace fapi2 /// before the read. /// @param[out] o_data Buffer that holds data read from HW target. /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. -template< TargetType K, typename V > -inline ReturnCode getI2c(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getI2c(const Target& i_target, const size_t i_get_size, const std::vector& i_data, std::vector& o_data); @@ -87,8 +87,8 @@ inline ReturnCode getI2c(const Target& i_target, /// @param[in] i_target HW target to operate on. /// @param[in] i_data Buffer that holds data to write to the HW target. /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. -template< TargetType K, typename V > -inline ReturnCode putI2c(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putI2c(const Target& i_target, const std::vector& i_data); }; diff --git a/src/import/hwpf/fapi2/include/fapi2_multicast.H b/src/import/hwpf/fapi2/include/fapi2_multicast.H deleted file mode 100644 index 531b7561..00000000 --- a/src/import/hwpf/fapi2/include/fapi2_multicast.H +++ /dev/null @@ -1,171 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/import/hwpf/fapi2/include/fapi2_multicast.H $ */ -/* */ -/* OpenPOWER sbe Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2016,2017 */ -/* [+] 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 fapi2_multicast.H -/// @brief Common definitions for fapi2 multicast target value wrapper class -/// - -#ifndef __FAPI2_COMMON_MULTICAST__ -#define __FAPI2_COMMON_MULTICAST__ - -#include -#include - -namespace fapi2 -{ - -/// -/// @brief Class representing a FAPI2 Multicast target value wrapper -/// @tparam M the type of multicast operation -/// @tparam G the type of multicast group -/// @tparam V the type of the target's Value this class is wrapping -/// @remark This wrapper class defines how a handle will behave by -/// type and group if internal to the handle mulitcast operation -/// is enabled. If the handle used is not multicast enabled most -/// function of this class will be ignored. -/// -template -class Multicast -{ - public: - /// - /// @brief Delagate default constructor to constructor - /// that takes in a value as a param - /// - Multicast() : Multicast(V()) {} - - /// - /// @brief Create a Multicast value with a target value - /// @param[in] value the value (i.e., specific element this - /// target represents, or pointer) - /// @note Platforms can will update the handle value with - /// information on the multicast type and group - /// - Multicast(const V& value) : iv_handle(value) - { - updateHandle(iv_handle); - } - - /// - /// @brief Create a Multicast value from another Multicast value - /// @param[in] other the value - /// @note Platforms can will update the handle value with - /// information on the multicast type and group - /// - template - Multicast(const Multicast other) : - iv_handle(static_cast(other)) - { - updateHandle(iv_handle); - } - - /// - /// @brief Get the handle as a V - /// @return V The Multicast wrapper's internal handle, or value - /// - inline operator V() const - { - return iv_handle; - } - - /// - /// @brief Get the handle as a V - /// @return V The Multicast wrapper's internal handle, or value - /// - inline V& operator()() const - { - return iv_handle; - } - - /// - /// @brief Has the handle been enabled for multicast operation - /// @return Return true if multicast, false otherwise - /// - inline bool isMulticast() const; - - private: - /// - /// @brief update the handle with group and type given - /// @tparam O the type of multicast operation - /// @tparam N the type of multicast group - /// @param[in] Value the value/handle - /// - template - inline void updateHandle(V& value); - - V iv_handle; -}; - -// multicast from unicast -template -inline Target> make_multicast(const Target& t) -{ - return Target>(t.get()); -} - -// multicast from multicast -- changing type -template -inline Target> make_multicast(const Target>& t) -{ - return Target>(t.get()); -} - -// multicast from multicast -- changing type and group -template -inline Target> make_multicast(const Target>& t) -{ - return Target>(t.get()); -} - -// unicast from multicast -template -inline Target make_unicast(const Target>& t) -{ - return Target(t.get()); -} - -// test if a multicast target -template -inline bool is_multicast(const Target>& t) -{ - const Multicast& l_mref = t; - return l_mref.isMulticast(); -} - -// return false if testing a non-multicast target -template -inline bool is_multicast(const Target& t) -{ - return false; -} - -template -constexpr bool is_same() -{ - return (M1 == M2); -} -} - -#endif diff --git a/src/import/hwpf/fapi2/include/fapi2_multicast_defs.H b/src/import/hwpf/fapi2/include/fapi2_multicast_defs.H deleted file mode 100644 index 04ed978a..00000000 --- a/src/import/hwpf/fapi2/include/fapi2_multicast_defs.H +++ /dev/null @@ -1,42 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/import/hwpf/fapi2/include/fapi2_multicast_defs.H $ */ -/* */ -/* OpenPOWER sbe Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2016 */ -/* [+] 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 __FAPI2_COMMON_MULTICAST_DEFS__ -#define __FAPI2_COMMON_MULTICAST_DEFS__ - -namespace fapi2 -{ -enum MulticastType -{ - MULTICAST_WRITE, - MULTICAST_READAND, - MULTICAST_READOR, - MULTICAST_READBITX, - MULTICAST_READCOMPARE, -}; - -typedef uint32_t MulticastGroup; -} - -#endif diff --git a/src/import/hwpf/fapi2/include/fapi2_target.H b/src/import/hwpf/fapi2/include/fapi2_target.H index 6f2c6793..4d9f6963 100644 --- a/src/import/hwpf/fapi2/include/fapi2_target.H +++ b/src/import/hwpf/fapi2/include/fapi2_target.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER sbe Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015,2016 */ +/* Contributors Listed Below - COPYRIGHT 2015,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -37,15 +37,26 @@ #include #include #include +#include #include #include namespace fapi2 { +/// +/// @brief Apply any platform specific static assertions to target construction +/// @tparam K the type of target to be constructed +/// @tparam M the multicast type of the target to be constructed +/// @tparam V the value type of the target to be constructed +/// +template +static constexpr void plat_apply_target_limits(void); + /// /// @brief Class representing a FAPI2 Target /// @tparam K the type (Kind) of target +/// @tparam M the type of multicast operation if it's a multicast target /// @tparam V the type of the target's Value /// @remark TargetLite targets are uint64_t, Targets /// are uintptr_t (void*). @@ -102,7 +113,7 @@ namespace fapi2 /// fapi2::Target E; /// takesProcOrMembuf( E ); /// @endcode -template +template class Target { public: @@ -112,7 +123,9 @@ class Target /// that takes in a value as a param /// Target(): Target(V()) - {}; + { + plat_apply_target_limits(); + }; /// /// @brief Create a Target, with a value @@ -124,7 +137,9 @@ class Target /// Target(const V& Value): iv_handle(Value) - {}; + { + plat_apply_target_limits(); + }; /// @@ -203,7 +218,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? @@ -277,7 +292,7 @@ class Target /// 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; /// @@ -289,7 +304,7 @@ class Target /// children /// template< TargetType T> - inline std::vector > + inline std::vector > getChildren(const TargetFilter i_filter, const TargetState i_state = TARGET_STATE_FUNCTIONAL) const; @@ -305,7 +320,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? @@ -329,10 +344,12 @@ class Target /// @brief Copy from a Target to a Target /// @tparam O the target type of the other /// - template - inline Target( const Target& Other ): - Target(Other.get()) + template + inline Target( const Target& Other ): + Target(Other.get()) { + plat_apply_target_limits(); + // In case of recursion depth failure, use -ftemplate-depth= static_assert( (K & O) != 0, "unable to cast Target, no shared types"); @@ -347,6 +364,8 @@ class Target static const TargetType iv_type = K; V iv_handle; + /// @brief if iv_handle is a multicast target, update its multicast type to M + inline void mcUpdateHandle(); }; // EX threads map to CORE threads: @@ -475,8 +494,8 @@ inline uint8_t thread_bitset_f2n(const uint8_t i_ordinal, const uint8_t i_thread /// @post The contents of the buffer is replaced with the string /// representation of the target /// -template< TargetType T, typename V > -inline void toString(const Target& i_target, char* i_buffer, size_t i_bsize); +template< TargetType T, MulticastType M, typename V > +inline void toString(const Target& i_target, char* i_buffer, size_t i_bsize); /// /// @brief Return the string interpretation of this target @@ -489,8 +508,8 @@ inline void toString(const Target& i_target, char* i_buffer, size_t i_bsiz /// @post The contents of the buffer is replaced with the string /// representation of the target /// -template< TargetType T, typename V > -inline void toString(const Target* i_target, char* i_buffer, size_t i_bsize); +template< TargetType T, MulticastType M, 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 @@ -499,28 +518,8 @@ inline void toString(const Target* i_target, char* i_buffer, size_t i_bsiz /// the desired target /// @return Target the target requested /// -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 -// Target::getChildren(). And if I'm going to change it -// I really want to see if we need it. I'm still not -// clear on whether we're alloing this traversal or not. -#if 0 -/// -/// @brief Get the base target's children -/// @tparam T The type of the target -/// @return std::vector> a vector of present/functional -/// children -/// -template -inline std::vector> getChildren() -{ - // For testing - return {Target(), Target()}; -} -#endif +template +inline Target getTarget(uint64_t Ordinal); /// /// @brief Return the string interpretation of this target @@ -532,8 +531,8 @@ inline std::vector> getChildren() /// @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. @@ -546,6 +545,7 @@ inline constexpr bool is_same(void) { return (K & T) != 0; } + } #endif diff --git a/src/import/hwpf/fapi2/include/fapi2_vpd_access.H b/src/import/hwpf/fapi2/include/fapi2_vpd_access.H index d71a2195..514acbc5 100644 --- a/src/import/hwpf/fapi2/include/fapi2_vpd_access.H +++ b/src/import/hwpf/fapi2/include/fapi2_vpd_access.H @@ -145,8 +145,8 @@ class VPDInfo /// FAPI_TRY(getVPD( mcs, vpdInfo, blob )); /// blob now contains the VPD data for the MCS. /// -template -ReturnCode getVPD(const Target& i_target, +template +ReturnCode getVPD(const Target& i_target, VPDInfo& io_vpd_info, uint8_t* o_blob); diff --git a/src/import/hwpf/fapi2/include/multicast_defs.H b/src/import/hwpf/fapi2/include/multicast_defs.H new file mode 100644 index 00000000..943625d7 --- /dev/null +++ b/src/import/hwpf/fapi2/include/multicast_defs.H @@ -0,0 +1,42 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/import/hwpf/fapi2/include/multicast_defs.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2016,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 */ +#ifndef __FAPI2_COMMON_MULTICAST_DEFS__ +#define __FAPI2_COMMON_MULTICAST_DEFS__ + +namespace fapi2 +{ +enum MulticastType +{ + // Code points picked according to PCB spec + MULTICAST_OR = 0, + MULTICAST_AND = 1, + MULTICAST_BITX = 2, + MULTICAST_COMPARE = 4, +}; + +typedef uint32_t MulticastGroup; +} + +#endif diff --git a/src/import/hwpf/fapi2/include/plat/hw_access.H b/src/import/hwpf/fapi2/include/plat/hw_access.H index bd202809..cf945fd9 100644 --- a/src/import/hwpf/fapi2/include/plat/hw_access.H +++ b/src/import/hwpf/fapi2/include/plat/hw_access.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER sbe Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015,2017 */ +/* Contributors Listed Below - COPYRIGHT 2015,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -102,8 +102,8 @@ inline OpModes getOpMode(void) /// @param[out] o_data Buffer that holds data read from HW target. /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. /// -template< TargetType K, typename V > -inline ReturnCode getScom(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getScom(const Target& i_target, const uint64_t i_address, buffer& o_data) { @@ -124,8 +124,8 @@ inline ReturnCode getScom(const Target& i_target, /// @param[in] i_address SCOM register address to write to. /// @param[in] i_data Buffer that holds data to write into address. /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. -template< TargetType K, typename V > -inline ReturnCode putScom(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putScom(const Target& i_target, const uint64_t i_address, const buffer i_data) { @@ -145,8 +145,8 @@ inline ReturnCode putScom(const Target& i_target, /// @param[in] i_data Buffer that holds data to write into address. /// @param[in] i_mask Buffer that holds the mask value. /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. -template< TargetType K, typename V > -inline ReturnCode putScomUnderMask(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putScomUnderMask(const Target& i_target, const uint64_t i_address, const buffer i_data, const buffer i_mask) @@ -170,8 +170,8 @@ inline ReturnCode putScomUnderMask(const Target& i_target, /// @param[out] o_data 32-bit buffer that holds data read from HW target. /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. /// -template< TargetType K, typename V > -inline ReturnCode getCfamRegister(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getCfamRegister(const Target& i_target, const uint32_t i_address, buffer& o_data) { @@ -194,8 +194,8 @@ inline ReturnCode getCfamRegister(const Target& i_target, /// @param[out] i_data 32-bit buffer that holds data to write into address. /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. /// -template< TargetType K, typename V > -inline ReturnCode putCfamRegister(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putCfamRegister(const Target& i_target, const uint32_t i_address, const buffer i_data) { @@ -219,8 +219,8 @@ inline ReturnCode putCfamRegister(const Target& i_target, /// @param[in] i_modifyMode The modify mode (or/and/xor). /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. /// -template< TargetType K, typename V > -inline ReturnCode modifyCfamRegister(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode modifyCfamRegister(const Target& i_target, const uint32_t i_address, const buffer i_data, const fapi2::ChipOpModifyMode i_modifyMode) @@ -242,8 +242,8 @@ inline ReturnCode modifyCfamRegister(const Target& i_target, /// @param[in] i_ringID Ring ID that will identify the Ring in the image. /// @param[in] i_ringMode Ring operation mode. /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. -template< TargetType K, typename V > -ReturnCode putRing(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +ReturnCode putRing(const Target& i_target, const RingId_t i_ringID, const RingMode i_ringMode) { @@ -269,8 +269,8 @@ ReturnCode putRing(const Target& i_target, /// @param[in] i_ringMode Ring operation mode. /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. /// -template< TargetType K, typename V > -inline ReturnCode getRing(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getRing(const Target& i_target, const scanRingId_t i_address, variable_buffer& o_data, const RingMode i_ringMode) @@ -297,8 +297,8 @@ inline ReturnCode getRing(const Target& i_target, /// @param[in] i_modifyMode The modify mode (or/and/xor) /// @param[in] i_ringMode Ring operation mode. /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. -template< TargetType K, typename V > -inline ReturnCode modifyRing(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode modifyRing(const Target& i_target, const scanRingId_t i_address, const variable_buffer& i_data, const ChipOpModifyMode i_modifyMode, @@ -364,8 +364,8 @@ inline ReturnCode modifyRing(const Target& i_target, /// the quotes for the cronus environment /// #ifdef FAPI_SUPPORT_SPY_AS_ENUM -template< TargetType K, typename V > -inline ReturnCode getSpy(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getSpy(const Target& i_target, const spyId_t i_spyId, variable_buffer& o_data) { @@ -384,8 +384,8 @@ inline ReturnCode getSpy(const Target& i_target, } #endif #ifdef FAPI_SUPPORT_SPY_AS_STRING -template< TargetType K, typename V > -inline ReturnCode getSpy(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getSpy(const Target& i_target, const char* const i_spyId, variable_buffer& o_data) { @@ -443,8 +443,8 @@ inline ReturnCode getSpy(const Target& i_target, /// the quotes for the cronus environment /// #ifdef FAPI_SUPPORT_SPY_AS_ENUM -template< TargetType K, typename V > -inline ReturnCode putSpy(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putSpy(const Target& i_target, const spyId_t i_spyId, const variable_buffer& i_data) { @@ -453,8 +453,8 @@ inline ReturnCode putSpy(const Target& i_target, } #endif #ifdef FAPI_SUPPORT_SPY_AS_STRING -template< TargetType K, typename V > -inline ReturnCode putSpy(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putSpy(const Target& i_target, const char* const i_spyId, const variable_buffer& i_data) { @@ -462,8 +462,8 @@ inline ReturnCode putSpy(const Target& i_target, return ~FAPI2_RC_SUCCESS; } -template< TargetType K, typename V > -inline ReturnCode putSpy(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putSpy(const Target& i_target, const char* const i_spyId, const char* i_enum) { @@ -492,8 +492,8 @@ inline ReturnCode putSpy(const Target& i_target, /// See fapiPutSpy for details on spy id specifics. /// #ifdef FAPI_SUPPORT_SPY_AS_ENUM -template< TargetType K, typename V > -inline ReturnCode putSpyImage(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putSpyImage(const Target& i_target, const spyId_t i_spyId, const variable_buffer& i_data, variable_buffer& o_imageData) @@ -503,8 +503,8 @@ inline ReturnCode putSpyImage(const Target& i_target, } #endif #ifdef FAPI_SUPPORT_SPY_AS_STRING -template< TargetType K, typename V > -inline ReturnCode putSpyImage(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putSpyImage(const Target& i_target, const char* const i_spyId, const variable_buffer& i_data, variable_buffer& o_imageData) @@ -531,8 +531,8 @@ inline ReturnCode putSpyImage(const Target& i_target, /// See fapiPutSpy for details on spy id specifics. /// #ifdef FAPI_SUPPORT_SPY_AS_ENUM -template< TargetType K, typename V > -inline ReturnCode getSpyImage(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getSpyImage(const Target& i_target, const spyId_t i_spyId, variable_buffer& o_data, const variable_buffer& i_imageData) @@ -542,8 +542,8 @@ inline ReturnCode getSpyImage(const Target& i_target, } #endif #ifdef FAPI_SUPPORT_SPY_AS_STRING -template< TargetType K, typename V > -inline ReturnCode getSpyImage(const Target& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getSpyImage(const Target& i_target, const char* const i_spyId, variable_buffer& o_data, const variable_buffer& i_imageData) diff --git a/src/import/hwpf/fapi2/include/plat/target.H b/src/import/hwpf/fapi2/include/plat/target.H index 2604b980..62e57f8d 100644 --- a/src/import/hwpf/fapi2/include/plat/target.H +++ b/src/import/hwpf/fapi2/include/plat/target.H @@ -32,19 +32,28 @@ #include #include -#include #include namespace fapi2 { +template +static constexpr void plat_apply_target_limits(void) +{ + static_assert(!(K & TARGET_TYPE_MULTICAST), + "Multicast targets are not supported on this platform"); +} + +template +inline void Target::mcUpdateHandle() {}; + /// /// @brief Assignment Operator. /// @param[in] i_right Reference to Target to assign from. /// @return Reference to 'this' Target /// -template -Target& Target::operator=(const Target& i_right) +template +Target& Target::operator=(const Target& i_right) { iv_handle = i_right.iv_handle; return *this; @@ -57,8 +66,8 @@ Target& Target::operator=(const Target& i_right) /// @note Platforms need to define this so that the physical /// targets are determined to be equivilent rather than just the handles /// -template -bool Target::operator==(const Target& i_right) const +template +bool Target::operator==(const Target& i_right) const { return i_right.iv_handle == iv_handle; } @@ -70,8 +79,8 @@ bool Target::operator==(const Target& i_right) const /// @note Platforms need to define this so that the physical /// targets are determined to be equivilent rather than just the handles /// -template -bool Target::operator!=(const Target& i_right) const +template +bool Target::operator!=(const Target& i_right) const { return i_right.iv_handle != iv_handle; } @@ -83,8 +92,8 @@ bool Target::operator!=(const Target& i_right) const /// @note Platforms need to define this so that the physical /// targets are determined to be less than rather than just the handles /// -template -bool Target::operator<(const Target& i_right) const +template +bool Target::operator<(const Target& i_right) const { return i_right.iv_handle < iv_handle; } @@ -94,12 +103,12 @@ bool Target::operator<(const Target& i_right) const /// @tparam T The type of the parent /// @return Target a target representing the parent /// -template +template template -inline Target Target::getParent(void) const +inline Target Target::getParent(void) const { // For testing - return Target(iv_handle); + return Target(iv_handle); } /// @@ -111,15 +120,15 @@ inline Target Target::getParent(void) const /// @warning The children of EX's (cores) are expected to be returned /// in order. That is, core 0 is std::vector[0]. /// -template -template< TargetType T> -inline std::vector > -Target::getChildren(const TargetState i_state) const +template +template +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<> @@ -146,16 +155,16 @@ Target::getChildren(const TargetFilter i_filter, /// @note o_target is only valid if return is FAPI2_RC_SUCCESS /// -template +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; } @@ -165,9 +174,9 @@ Target::getOtherEnd(Target& o_target, /// @return true if target is functional, false if non-functional /// -template +template inline bool -Target::isFunctional(void) const +Target::isFunctional(void) const { // Platform check if target is good // Could check ATTR_FUNCTIONAL or ATTR_PG_* @@ -181,9 +190,9 @@ Target::isFunctional(void) const /// @note For logical targets such as the EX, the chiplet number of /// their immediate parent chiplet is returned /// -template +template inline uint8_t -Target::getChipletNumber(void) const +Target::getChipletNumber(void) const { // Platform can return the chiplet number stored in it's Target handle return 0; @@ -199,11 +208,11 @@ Target::getChipletNumber(void) const /// @post The contents of the buffer is replaced with the string /// representation of the target /// -template< TargetType T, typename V > -inline void toString(const Target& i_target, +template +inline void toString(const Target& i_target, char* i_buffer, size_t i_bsize) { - snprintf(i_buffer, i_bsize, "Target 0x%lX/0x%.16lX", i_target.get(), T); + snprintf(i_buffer, i_bsize, "Target 0x%lX/0x%.16lX/0x%X", i_target.get(), T, M); } /// @@ -217,11 +226,11 @@ inline void toString(const Target& i_target, /// @post The contents of the buffer is replaced with the string /// representation of the target /// -template< TargetType T, typename V > -inline void toString(const Target* i_target, +template< TargetType T, MulticastType M, 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); + toString(*i_target, i_buffer, i_bsize); } /// @@ -231,12 +240,13 @@ inline void toString(const Target* i_target, /// 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); } + } #endif diff --git a/src/import/hwpf/fapi2/include/utils.H b/src/import/hwpf/fapi2/include/utils.H index c45e410c..5fb1beed 100644 --- a/src/import/hwpf/fapi2/include/utils.H +++ b/src/import/hwpf/fapi2/include/utils.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER sbe Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015,2018 */ +/* Contributors Listed Below - COPYRIGHT 2015,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -102,8 +102,8 @@ void endian_swap(T& io_input) /// @return ReturnCode. FAPI2_RC_SUCCESS on success, else platform specified error. /// /// -template -inline ReturnCode specialWakeup(const Target& i_target, +template +inline ReturnCode specialWakeup(const Target& i_target, const bool i_enable) { // enforce the allowed target types -- cgit v1.2.1