diff options
Diffstat (limited to 'src/import')
-rw-r--r-- | src/import/hwpf/fapi2/include/error_info_defs.H | 6 | ||||
-rw-r--r-- | src/import/hwpf/fapi2/include/fapi2_hw_access.H | 78 | ||||
-rw-r--r-- | src/import/hwpf/fapi2/include/fapi2_i2c_access.H | 10 | ||||
-rw-r--r-- | src/import/hwpf/fapi2/include/fapi2_multicast.H | 171 | ||||
-rw-r--r-- | src/import/hwpf/fapi2/include/fapi2_target.H | 78 | ||||
-rw-r--r-- | src/import/hwpf/fapi2/include/fapi2_vpd_access.H | 4 | ||||
-rw-r--r-- | src/import/hwpf/fapi2/include/multicast_defs.H (renamed from src/import/hwpf/fapi2/include/fapi2_multicast_defs.H) | 14 | ||||
-rw-r--r-- | src/import/hwpf/fapi2/include/plat/hw_access.H | 74 | ||||
-rw-r--r-- | src/import/hwpf/fapi2/include/plat/target.H | 78 | ||||
-rw-r--r-- | src/import/hwpf/fapi2/include/utils.H | 6 |
10 files changed, 179 insertions, 340 deletions
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<fapi2::TargetType T, typename V> -inline uint16_t getErrorInfoFfdcSize(const fapi2::Target<T, V>&) +template<fapi2::TargetType T, MulticastType M, typename V> +inline uint16_t getErrorInfoFfdcSize(const fapi2::Target<T, M, V>&) { 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<K, V>& i_target, const uint64_t i_address, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getScom(const Target<K, M, V>& i_target, const uint64_t i_address, buffer<uint64_t>& o_data); /// @brief Writes a SCOM register on a chip. @@ -95,8 +95,8 @@ inline ReturnCode getScom(const Target<K, V>& 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<K, V>& i_target, const uint64_t i_address, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putScom(const Target<K, M, V>& i_target, const uint64_t i_address, const buffer<uint64_t> i_data); /// @brief Writes a SCOM register under mask on a chip @@ -106,8 +106,8 @@ inline ReturnCode putScom(const Target<K, V>& 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<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putScomUnderMask(const Target<K, M, V>& i_target, const uint64_t i_address, const buffer<uint64_t> i_data, const buffer<uint64_t> i_mask); @@ -119,8 +119,8 @@ inline ReturnCode putScomUnderMask(const Target<K, V>& 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<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getCfamRegister(const Target<K, M, V>& i_target, const uint32_t i_address, buffer<uint32_t>& o_data); @@ -131,8 +131,8 @@ inline ReturnCode getCfamRegister(const Target<K, V>& 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<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putCfamRegister(const Target<K, M, V>& i_target, const uint32_t i_address, const buffer<uint32_t> i_data); @@ -144,8 +144,8 @@ inline ReturnCode putCfamRegister(const Target<K, V>& 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<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode modifyCfamRegister(const Target<K, M, V>& i_target, const uint32_t i_address, const buffer<uint32_t> i_data, const ChipOpModifyMode i_modifyMode); @@ -156,8 +156,8 @@ inline ReturnCode modifyCfamRegister(const Target<K, V>& 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<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +ReturnCode putRing(const Target<K, M, V>& i_target, const RingId_t i_ringID, const RingMode i_ringMode = RING_MODE_HEADER_CHECK); @@ -170,8 +170,8 @@ ReturnCode putRing(const Target<K, V>& 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<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getRing(const Target<K, M, V>& 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<K, V>& 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<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode modifyRing(const Target<K, M, V>& 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<K, V>& 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<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getSpy(const Target<K, M, V>& i_target, const spyId_t i_spyId, variable_buffer& o_data); @@ -258,8 +258,8 @@ inline ReturnCode getSpy(const Target<K>& i_target, #define FAPI_GET_SPY(TARGET, ID, DATA) fapi2::getSpy(TARGET, #ID, DATA) -template< TargetType K, typename V > -inline ReturnCode getSpy(const Target<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getSpy(const Target<K, M, V>& i_target, const char* const i_spyId, variable_buffer& o_data); @@ -313,8 +313,8 @@ inline ReturnCode getSpy(const Target<K>& 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<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putSpy(const Target<K, M, V>& i_target, const spyId_t i_spyId, const variable_buffer& i_data); #endif @@ -323,19 +323,19 @@ inline ReturnCode putSpy(const Target<K, V>& i_target, #define FAPI_PUT_SPY(TARGET, ID, DATA) fapi2::putSpy(TARGET, #ID, DATA) -template< TargetType K, typename V > -inline ReturnCode putSpy(const Target<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putSpy(const Target<K, M, V>& i_target, const char* const i_spyId, const variable_buffer& i_data); -template<TargetType K, typename V > -inline ReturnCode putSpyWithCare(const Target<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putSpyWithCare(const Target<K, M, V>& 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<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putSpy(const Target<K, M, V>& i_target, const char* const i_spyId, const char* i_enum); #endif @@ -366,8 +366,8 @@ inline ReturnCode putSpy(const Target<K, V>& i_target, fapi2::putSpyImage(TARGET, FAPI_SPY_NAMES::ID.value, \ DATA1, DATA2) -template< TargetType K, typename V > -inline ReturnCode putSpyImage(const Target<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putSpyImage(const Target<K, M, V>& 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<K, V>& 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<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putSpyImage(const Target<K, M, V>& 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<K, V>& i_target, fapi2:getSpyImage(TARGET, FAPI_SPY_NAMES::ID.value, \ DATA1, DATA2) -template< TargetType K, typename V > -inline ReturnCode getSpyImage(const Target<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getSpyImage(const Target<K, M, V>& 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<K, V>& 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<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getSpyImage(const Target<K, M, V>& 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<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getI2c(const Target<K, M, V>& i_target, const size_t i_get_size, const std::vector<uint8_t>& i_data, std::vector<uint8_t>& o_data); @@ -87,8 +87,8 @@ inline ReturnCode getI2c(const Target<K, V>& 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<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putI2c(const Target<K, M, V>& i_target, const std::vector<uint8_t>& 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 <target.H> -#include <fapi2_multicast_defs.H> - -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<MulticastType M, MulticastGroup G, typename V = plat_target_handle_t > -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<M, G>(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<MulticastType O, MulticastGroup N> - Multicast(const Multicast<O, N> other) : - iv_handle(static_cast<V>(other)) - { - updateHandle<M, G>(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<MulticastType O, MulticastGroup N> - inline void updateHandle(V& value); - - V iv_handle; -}; - -// multicast from unicast -template<MulticastType M, MulticastGroup G, TargetType K, typename V> -inline Target<K, Multicast<M, G, V>> make_multicast(const Target<K, V>& t) -{ - return Target<K, Multicast<M, G, V>>(t.get()); -} - -// multicast from multicast -- changing type -template<MulticastType M, MulticastType N, MulticastGroup G, TargetType K, typename V> -inline Target<K, Multicast<M, G, V>> make_multicast(const Target<K, Multicast<N, G, V>>& t) -{ - return Target<K, Multicast<M, G, V>>(t.get()); -} - -// multicast from multicast -- changing type and group -template<MulticastType M, MulticastGroup O, MulticastType N, MulticastGroup G, TargetType K, typename V> -inline Target<K, Multicast<M, O, V>> make_multicast(const Target<K, Multicast<N, G, V>>& t) -{ - return Target<K, Multicast<M, O, V>>(t.get()); -} - -// unicast from multicast -template<MulticastType M, MulticastGroup G, TargetType K, typename V> -inline Target<K, V> make_unicast(const Target<K, Multicast<M, G, V>>& t) -{ - return Target<K, V>(t.get()); -} - -// test if a multicast target -template<MulticastType M, MulticastGroup G, TargetType K, typename V> -inline bool is_multicast(const Target<K, Multicast<M, G, V>>& t) -{ - const Multicast<M, G, V>& l_mref = t; - return l_mref.isMulticast(); -} - -// return false if testing a non-multicast target -template<TargetType K, typename V> -inline bool is_multicast(const Target<K, V>& t) -{ - return false; -} - -template<MulticastType M1, MulticastType M2> -constexpr bool is_same() -{ - return (M1 == M2); -} -} - -#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,6 +37,7 @@ #include <vector> #include <target_types.H> #include <target_states.H> +#include <multicast_defs.H> #include <plat_target.H> #include <return_code_defs.H> @@ -44,8 +45,18 @@ 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<TargetType K, MulticastType M, typename V> +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<fapi2::TARGET_TYPE_ABUS_ENDPOINT> E; /// takesProcOrMembuf( E ); /// @endcode -template<TargetType K, typename V = plat_target_handle_t> +template<TargetType K, MulticastType M = MULTICAST_OR, typename V = plat_target_handle_t> class Target { public: @@ -112,7 +123,9 @@ class Target /// that takes in a value as a param /// Target(): Target(V()) - {}; + { + plat_apply_target_limits<K, M, V>(); + }; /// /// @brief Create a Target, with a value @@ -124,7 +137,9 @@ class Target /// Target(const V& Value): iv_handle(Value) - {}; + { + plat_apply_target_limits<K, M, V>(); + }; /// @@ -203,7 +218,7 @@ class Target /// @return Target<T> a target representing the parent /// template< TargetType T > - inline Target<T, V> getParent(void) const; + inline Target<T, M, V> 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<Target<T, V> > + inline std::vector<Target<T, M, V> > getChildren(const TargetState i_state = TARGET_STATE_FUNCTIONAL) const; /// @@ -289,7 +304,7 @@ class Target /// children /// template< TargetType T> - inline std::vector<Target<T, V> > + inline std::vector<Target<T, M, V> > getChildren(const TargetFilter i_filter, const TargetState i_state = TARGET_STATE_FUNCTIONAL) const; @@ -305,7 +320,7 @@ class Target template<TargetType T> inline fapi2::ReturnCodes - getOtherEnd(Target<T, V>& o_target, const TargetState i_state = TARGET_STATE_FUNCTIONAL) const; + getOtherEnd(Target<T, M, V>& 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<O> to a Target<K> /// @tparam O the target type of the other /// - template<TargetType O, typename VO> - inline Target( const Target<O, VO>& Other ): - Target<K, V>(Other.get()) + template<TargetType O, MulticastType MO, typename VO> + inline Target( const Target<O, MO, VO>& Other ): + Target<K, M, V>(Other.get()) { + plat_apply_target_limits<K, M, V>(); + // 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<T, V>& i_target, char* i_buffer, size_t i_bsize); +template< TargetType T, MulticastType M, typename V > +inline void toString(const Target<T, M, V>& 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<T, V>& 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<T, V>* i_target, char* i_buffer, size_t i_bsize); +template< TargetType T, MulticastType M, typename V > +inline void toString(const Target<T, M, V>* 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<T, V>* i_target, char* i_buffer, size_t i_bsiz /// the desired target /// @return Target<T> the target requested /// -template<TargetType T, typename V = plat_target_handle_t> -inline Target<T, V> 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<Target<T,V>> a vector of present/functional -/// children -/// -template<TargetType T, typename V> -inline std::vector<Target<T, V>> getChildren() -{ - // For testing - return {Target<T, V>(), Target<T, V>()}; -} -#endif +template<TargetType T, MulticastType M = MULTICAST_OR, typename V = plat_target_handle_t> +inline Target<T, M, V> getTarget(uint64_t Ordinal); /// /// @brief Return the string interpretation of this target @@ -532,8 +531,8 @@ inline std::vector<Target<T, V>> getChildren() /// @post The contents of the buffer is replaced with the string /// representation of the target /// -template<TargetType T, typename V, typename B> -inline void toString(const Target<T, V>& i_target, B& i_buffer); +template<TargetType T, MulticastType M, typename V, typename B> +inline void toString(const Target<T, M, V>& 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<TARGET_TYPE_OCMB_CHIP> /// FAPI_TRY(getVPD( mcs, vpdInfo, blob )); /// blob now contains the VPD data for the MCS. /// -template<TargetType T, typename V> -ReturnCode getVPD(const Target<T, V>& i_target, +template<TargetType T, MulticastType M, typename V> +ReturnCode getVPD(const Target<T, M, V>& i_target, VPDInfo<T>& io_vpd_info, uint8_t* o_blob); diff --git a/src/import/hwpf/fapi2/include/fapi2_multicast_defs.H b/src/import/hwpf/fapi2/include/multicast_defs.H index 04ed978a..943625d7 100644 --- a/src/import/hwpf/fapi2/include/fapi2_multicast_defs.H +++ b/src/import/hwpf/fapi2/include/multicast_defs.H @@ -1,11 +1,11 @@ /* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ -/* $Source: src/import/hwpf/fapi2/include/fapi2_multicast_defs.H $ */ +/* $Source: src/import/hwpf/fapi2/include/multicast_defs.H $ */ /* */ /* OpenPOWER sbe Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2016 */ +/* Contributors Listed Below - COPYRIGHT 2016,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -29,11 +29,11 @@ namespace fapi2 { enum MulticastType { - MULTICAST_WRITE, - MULTICAST_READAND, - MULTICAST_READOR, - MULTICAST_READBITX, - MULTICAST_READCOMPARE, + // Code points picked according to PCB spec + MULTICAST_OR = 0, + MULTICAST_AND = 1, + MULTICAST_BITX = 2, + MULTICAST_COMPARE = 4, }; typedef uint32_t MulticastGroup; 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<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getScom(const Target<K, M, V>& i_target, const uint64_t i_address, buffer<uint64_t>& o_data) { @@ -124,8 +124,8 @@ inline ReturnCode getScom(const Target<K, V>& 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<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putScom(const Target<K, M, V>& i_target, const uint64_t i_address, const buffer<uint64_t> i_data) { @@ -145,8 +145,8 @@ inline ReturnCode putScom(const Target<K, V>& 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<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putScomUnderMask(const Target<K, M, V>& i_target, const uint64_t i_address, const buffer<uint64_t> i_data, const buffer<uint64_t> i_mask) @@ -170,8 +170,8 @@ inline ReturnCode putScomUnderMask(const Target<K, V>& 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<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getCfamRegister(const Target<K, M, V>& i_target, const uint32_t i_address, buffer<uint32_t>& o_data) { @@ -194,8 +194,8 @@ inline ReturnCode getCfamRegister(const Target<K, V>& 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<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putCfamRegister(const Target<K, M, V>& i_target, const uint32_t i_address, const buffer<uint32_t> i_data) { @@ -219,8 +219,8 @@ inline ReturnCode putCfamRegister(const Target<K, V>& 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<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode modifyCfamRegister(const Target<K, M, V>& i_target, const uint32_t i_address, const buffer<uint32_t> i_data, const fapi2::ChipOpModifyMode i_modifyMode) @@ -242,8 +242,8 @@ inline ReturnCode modifyCfamRegister(const Target<K, V>& 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<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +ReturnCode putRing(const Target<K, M, V>& i_target, const RingId_t i_ringID, const RingMode i_ringMode) { @@ -269,8 +269,8 @@ ReturnCode putRing(const Target<K, V>& 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<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getRing(const Target<K, M, V>& i_target, const scanRingId_t i_address, variable_buffer& o_data, const RingMode i_ringMode) @@ -297,8 +297,8 @@ inline ReturnCode getRing(const Target<K, V>& 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<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode modifyRing(const Target<K, M, V>& 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<K, V>& i_target, /// the quotes for the cronus environment /// #ifdef FAPI_SUPPORT_SPY_AS_ENUM -template< TargetType K, typename V > -inline ReturnCode getSpy(const Target<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getSpy(const Target<K, M, V>& i_target, const spyId_t i_spyId, variable_buffer& o_data) { @@ -384,8 +384,8 @@ inline ReturnCode getSpy(const Target<K>& i_target, } #endif #ifdef FAPI_SUPPORT_SPY_AS_STRING -template< TargetType K, typename V > -inline ReturnCode getSpy(const Target<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getSpy(const Target<K, M, V>& i_target, const char* const i_spyId, variable_buffer& o_data) { @@ -443,8 +443,8 @@ inline ReturnCode getSpy(const Target<K>& i_target, /// the quotes for the cronus environment /// #ifdef FAPI_SUPPORT_SPY_AS_ENUM -template< TargetType K, typename V > -inline ReturnCode putSpy(const Target<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putSpy(const Target<K, M, V>& i_target, const spyId_t i_spyId, const variable_buffer& i_data) { @@ -453,8 +453,8 @@ inline ReturnCode putSpy(const Target<K, V>& i_target, } #endif #ifdef FAPI_SUPPORT_SPY_AS_STRING -template< TargetType K, typename V > -inline ReturnCode putSpy(const Target<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putSpy(const Target<K, M, V>& i_target, const char* const i_spyId, const variable_buffer& i_data) { @@ -462,8 +462,8 @@ inline ReturnCode putSpy(const Target<K, V>& i_target, return ~FAPI2_RC_SUCCESS; } -template< TargetType K, typename V > -inline ReturnCode putSpy(const Target<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putSpy(const Target<K, M, V>& i_target, const char* const i_spyId, const char* i_enum) { @@ -492,8 +492,8 @@ inline ReturnCode putSpy(const Target<K, V>& 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<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putSpyImage(const Target<K, M, V>& 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<K, V>& i_target, } #endif #ifdef FAPI_SUPPORT_SPY_AS_STRING -template< TargetType K, typename V > -inline ReturnCode putSpyImage(const Target<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode putSpyImage(const Target<K, M, V>& 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<K, V>& 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<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getSpyImage(const Target<K, M, V>& 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<K, V>& i_target, } #endif #ifdef FAPI_SUPPORT_SPY_AS_STRING -template< TargetType K, typename V > -inline ReturnCode getSpyImage(const Target<K, V>& i_target, +template< TargetType K, MulticastType M, typename V > +inline ReturnCode getSpyImage(const Target<K, M, V>& 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 <plat_target.H> #include <fapi2_target.H> -#include <multicast.H> #include <stdio.h> namespace fapi2 { +template<TargetType K, MulticastType M, typename V> +static constexpr void plat_apply_target_limits(void) +{ + static_assert(!(K & TARGET_TYPE_MULTICAST), + "Multicast targets are not supported on this platform"); +} + +template<TargetType T, MulticastType M, typename V> +inline void Target<T, M, V>::mcUpdateHandle() {}; + /// /// @brief Assignment Operator. /// @param[in] i_right Reference to Target to assign from. /// @return Reference to 'this' Target /// -template<TargetType K, typename V> -Target<K, V>& Target<K, V>::operator=(const Target& i_right) +template<TargetType K, MulticastType M, typename V> +Target<K, M, V>& Target<K, M, V>::operator=(const Target& i_right) { iv_handle = i_right.iv_handle; return *this; @@ -57,8 +66,8 @@ Target<K, V>& Target<K, V>::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<TargetType K, typename V> -bool Target<K, V>::operator==(const Target& i_right) const +template<TargetType K, MulticastType M, typename V> +bool Target<K, M, V>::operator==(const Target& i_right) const { return i_right.iv_handle == iv_handle; } @@ -70,8 +79,8 @@ bool Target<K, V>::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<TargetType K, typename V> -bool Target<K, V>::operator!=(const Target& i_right) const +template<TargetType K, MulticastType M, typename V> +bool Target<K, M, V>::operator!=(const Target& i_right) const { return i_right.iv_handle != iv_handle; } @@ -83,8 +92,8 @@ bool Target<K, V>::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<TargetType K, typename V> -bool Target<K, V>::operator<(const Target& i_right) const +template<TargetType K, MulticastType M, typename V> +bool Target<K, M, V>::operator<(const Target& i_right) const { return i_right.iv_handle < iv_handle; } @@ -94,12 +103,12 @@ bool Target<K, V>::operator<(const Target& i_right) const /// @tparam T The type of the parent /// @return Target<T> a target representing the parent /// -template<TargetType K, typename V> +template<TargetType K, MulticastType M, typename V> template<TargetType T> -inline Target<T, V> Target<K, V>::getParent(void) const +inline Target<T, M, V> Target<K, M, V>::getParent(void) const { // For testing - return Target<T, V>(iv_handle); + return Target<T, M, V>(iv_handle); } /// @@ -111,15 +120,15 @@ inline Target<T, V> Target<K, V>::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<TargetType K, typename V> -template< TargetType T> -inline std::vector<Target<T, V> > -Target<K, V>::getChildren(const TargetState i_state) const +template<TargetType K, MulticastType M, typename V> +template<TargetType T> +inline std::vector<Target<T, M, V> > +Target<K, M, V>::getChildren(const TargetState i_state) const { // To keep the compiler quiet about unused variables static_cast<void>(i_state); // For testing - return {Target<T, V>(), Target<T, V>()}; + return {Target<T, M, V>(), Target<T, M, V>()}; } // Specialization of getChildren, filtered for pervasive targets. template<> @@ -146,16 +155,16 @@ Target<TARGET_TYPE_PERV>::getChildren(const TargetFilter i_filter, /// @note o_target is only valid if return is FAPI2_RC_SUCCESS /// -template<TargetType K, typename V> +template<TargetType K, MulticastType M, typename V> template<TargetType T> inline fapi2::ReturnCodes -Target<K, V>::getOtherEnd(Target<T, V>& o_target, - const TargetState i_state) const +Target<K, M, V>::getOtherEnd(Target<T, M, V>& o_target, + const TargetState i_state) const { // To keep the compiler quiet about unused variables static_cast<void>(i_state); - o_target = Target<T, V>(); + o_target = Target<T, M, V>(); return FAPI2_RC_SUCCESS; } @@ -165,9 +174,9 @@ Target<K, V>::getOtherEnd(Target<T, V>& o_target, /// @return true if target is functional, false if non-functional /// -template<TargetType K, typename V> +template<TargetType K, MulticastType M, typename V> inline bool -Target<K, V>::isFunctional(void) const +Target<K, M, V>::isFunctional(void) const { // Platform check if target is good // Could check ATTR_FUNCTIONAL or ATTR_PG_* @@ -181,9 +190,9 @@ Target<K, V>::isFunctional(void) const /// @note For logical targets such as the EX, the chiplet number of /// their immediate parent chiplet is returned /// -template<TargetType K, typename V> +template<TargetType K, MulticastType M, typename V> inline uint8_t -Target<K, V>::getChipletNumber(void) const +Target<K, M, V>::getChipletNumber(void) const { // Platform can return the chiplet number stored in it's Target handle return 0; @@ -199,11 +208,11 @@ Target<K, V>::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<T, V>& i_target, +template<TargetType T, MulticastType M, typename V > +inline void toString(const Target<T, M, V>& 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<T, V>& 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<T, V>* i_target, +template< TargetType T, MulticastType M, typename V > +inline void toString(const Target<T, M, V>* 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<T, V>* i_target, /// the desired target /// @return Target<T> the target requested /// -template<TargetType T, typename V> -inline Target<T, V> getTarget(uint64_t Ordinal) +template<TargetType T, MulticastType M, typename V> +inline Target<T, M, V> getTarget(uint64_t Ordinal) { // For testing - return Target<T, V>(Ordinal); + return Target<T, M, V>(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<TargetType T, typename V> -inline ReturnCode specialWakeup(const Target<T, V>& i_target, +template<TargetType T, MulticastType M, typename V> +inline ReturnCode specialWakeup(const Target<T, M, V>& i_target, const bool i_enable) { // enforce the allowed target types |