diff options
author | Greg Still <stillgs@us.ibm.com> | 2015-10-13 20:54:36 -0500 |
---|---|---|
committer | Martin Peschke <mpeschke@de.ibm.com> | 2015-10-21 07:20:47 -0500 |
commit | 82fc55596dd107514bc3dea1b8be3c23b653c76a (patch) | |
tree | 7375f72411c9ff16775d145ce7ea727fbde46806 /importtemp | |
parent | 43aaa85b59ba06dce6e0f7063234235384e31135 (diff) | |
download | talos-sbe-82fc55596dd107514bc3dea1b8be3c23b653c76a.tar.gz talos-sbe-82fc55596dd107514bc3dea1b8be3c23b653c76a.zip |
Rearrange PPE FAPI2 directory structure to be more in-line with HWPF
- Move files into new structure
- Delete old, obsolete files and directories
- Pre-import mirror of HWPF into importtemp
- No additional function
Change-Id: Iadad6eb05349f807acea362ec77d7f58273878b5
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/21150
Tested-by: Jenkins Server
Reviewed-by: Santosh S. Puranik <santosh.puranik@in.ibm.com>
Reviewed-by: Sachin Gupta <sgupta2m@in.ibm.com>
Reviewed-by: Martin Peschke <mpeschke@de.ibm.com>
Diffstat (limited to 'importtemp')
23 files changed, 3163 insertions, 2158 deletions
diff --git a/importtemp/fapi2/include/buffer.H b/importtemp/fapi2/include/buffer.H index d8ad212a..154ed4b2 100644 --- a/importtemp/fapi2/include/buffer.H +++ b/importtemp/fapi2/include/buffer.H @@ -1,25 +1,19 @@ /* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ -/* $Source: $ */ +/* $Source: hwpf/fapi2/include/buffer.H $ */ /* */ -/* OpenPOWER HostBoot Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2012,2014 */ -/* [+] International Business Machines Corp. */ +/* IBM CONFIDENTIAL */ /* */ +/* EKB Project */ /* */ -/* 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 */ +/* COPYRIGHT 2012,2015 */ +/* [+] International Business Machines Corp. */ /* */ -/* 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. */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ /* */ /* IBM_PROLOG_END_TAG */ /** @@ -36,11 +30,11 @@ namespace fapi2 { - /// @brief Class representing a FAPI buffer<T> - /// @tparam T, the integral type of the buffer (uint16_t, uint64_t, etc.) - template <typename T, typename TT = bufferTraits<T> > - class buffer - { +/// @brief Class representing a FAPI buffer<T> +/// @tparam T, the integral type of the buffer (uint16_t, uint64_t, etc.) +template <typename T, typename TT = bufferTraits<T> > +class buffer +{ public: /// Shortcut typedef to get to our traits class typedef typename TT::bits_type bits_type; @@ -52,40 +46,54 @@ namespace fapi2 /// inline buffer(T i_value = 0): iv_data(i_value) - { - } + { + } ~buffer(void) = default; #if !defined(DOXYGEN) && defined(FAPI2_DEBUG) /// @brief Print the contents of the buffer to stdout inline void print(void) const - { TT::print(iv_data); } + { + TT::print(iv_data); + } #endif /// /// @brief Get the contents of the buffer /// @return The contents of the buffer /// - inline operator T() const { return iv_data; } + inline operator T() const + { + return iv_data; + } /// /// @brief Get the contents of the buffer /// @return The contents of the buffer /// - inline operator T&() { return iv_data; } + inline operator T& () + { + return iv_data; + } /// /// @brief Get the contents of the buffer /// @return The contents of the buffer /// - inline T& operator()(void) { return iv_data; } + inline T& operator()(void) + { + return iv_data; + } /// /// @brief Get the contents of the buffer /// @return Reference to the contents of the buffer /// - inline const T& operator()(void) const { return iv_data; } + inline const T& operator()(void) const + { + return iv_data; + } /// @name Buffer Manipulation Functions ///@{ @@ -110,7 +118,7 @@ namespace fapi2 static const bits_type bits_in_value = parameterTraits<OT>::bit_length(); const bits_type bit_length = TT::bit_length(iv_data); - if (i_offset + bits_in_value >= bit_length) + if (i_offset + bits_in_value > bit_length) { return FAPI2_RC_OVERFLOW; } @@ -118,11 +126,14 @@ namespace fapi2 // Create mask if part of this byte is not in the valid part of the buffer, // Shift it left by the amount of unused bits, // Clear the unused bits - if (((i_offset + 1) == length) && (bit_length % bits_in_value)) { - i_value &= parameterTraits<OT>::mask() << ((bits_in_value * length) - bit_length); + if (((i_offset + 1) == length) && (bit_length % bits_in_value)) + { + i_value &= parameterTraits<OT>::mask() << ((bits_in_value * length) - + bit_length); } - parameterTraits<OT>::template write_element<typename TT::unit_type>(TT::get_address(iv_data), i_value, i_offset); + parameterTraits<OT>::template write_element<typename TT::unit_type> + (TT::get_address(iv_data), i_value, i_offset); return FAPI2_RC_SUCCESS; } @@ -134,7 +145,9 @@ namespace fapi2 /// @return Length in bits /// inline constexpr uint32_t getBitLength(void) const - { return TT::bit_length(iv_data); } + { + return TT::bit_length(iv_data); + } /// /// @brief Return the length of the buffer in OT units @@ -159,7 +172,7 @@ namespace fapi2 /// @note Example: fapi2::buffer<uint64_t>().setBit<3>(); /// template< bits_type B, bits_type C = 1 > - inline buffer& setBit(void) + inline buffer & setBit(void) { static_assert((B >= 0) && ((B + C - 1) < TT::bits_per_unit()), "failed range check"); @@ -167,7 +180,8 @@ namespace fapi2 // This would be a candidate for a fast_mask (see variable_buffer) but // we'd need tables for all the integral types which maybe we need to // do ... - iv_data |= (T(~0) >> (TT::bits_per_unit() - C)) << (TT::bits_per_unit() - B - C); + iv_data |= (T(~0) >> (TT::bits_per_unit() - C)) << (TT::bits_per_unit() - B - + C); return *this; } @@ -178,14 +192,16 @@ namespace fapi2 /// @note 0 is left-most /// @return FAPI2_RC_SUCCESS if OK /// - inline fapi2::ReturnCode setBit(const bits_type& i_bit, const bits_type& i_count = 1) + inline fapi2::ReturnCode setBit(const bits_type& i_bit, + const bits_type& i_count = 1) { if ((i_count + i_bit - 1) >= TT::bits_per_unit()) { return FAPI2_RC_INVALID_PARAMETER; } - iv_data |= (T(~0) >> (TT::bits_per_unit() - i_count)) << (TT::bits_per_unit() - i_bit - i_count); + iv_data |= (T(~0) >> (TT::bits_per_unit() - i_count)) << + (TT::bits_per_unit() - i_bit - i_count); return FAPI2_RC_SUCCESS; } @@ -200,10 +216,10 @@ namespace fapi2 /// the case we can add a function parameter version. /// template< bits_type B, bits_type C = 1> - inline buffer& clearBit(void) + inline buffer & clearBit(void) { static_assert((B >= 0) && - ((B + C - 1)< TT::bits_per_unit()), "failed range check"); + ((B + C - 1) < TT::bits_per_unit()), "failed range check"); iv_data &= buffer<T>().setBit<B, C>().invert(); return *this; @@ -216,7 +232,8 @@ namespace fapi2 /// @note 0 is left-most /// @return FAPI2_RC_SUCCESS if OK /// - inline fapi2::ReturnCode clearBit(const bits_type& i_bit, const bits_type& i_count = 1) + inline fapi2::ReturnCode clearBit(const bits_type& i_bit, + const bits_type& i_count = 1) { if ((i_count + i_bit - 1) >= TT::bits_per_unit()) { @@ -245,10 +262,10 @@ namespace fapi2 /// the case we can add a function parameter version. /// template< bits_type B, bits_type C = 1 > - inline buffer& writeBit(const bool i_value) + inline buffer & writeBit(const bool i_value) { static_assert((B >= 0) && - ((B + C - 1)< TT::bits_per_unit()), "failed range check"); + ((B + C - 1) < TT::bits_per_unit()), "failed range check"); (i_value == 0) ? clearBit<B, C>() : setBit<B, C>(); return *this; @@ -265,7 +282,7 @@ namespace fapi2 /// the case we can add a function parameter version. /// template< bits_type B, bits_type C = 1 > - inline buffer& flipBit(void) + inline buffer & flipBit(void) { static_assert((B >= 0) && ((B + C - 1) < TT::bits_per_unit()), "failed range check"); @@ -282,9 +299,9 @@ namespace fapi2 /// template< bits_type B, bits_type C = 1> inline bool getBit(void) const - { - return buffer<T>().setBit<B, C>() & iv_data; - } + { + return buffer<T>().setBit<B, C>() & iv_data; + } /// /// @brief Set and entire buffer to X's @@ -294,25 +311,31 @@ namespace fapi2 /// template< uint8_t X > inline buffer& flush(void) - { - static_assert( (X == 1) || (X == 0), "bad argument to flush" ); - (0 == X) ? TT::clear(iv_data) : TT::set(iv_data); - return *this; - } + { + static_assert( (X == 1) || (X == 0), "bad argument to flush" ); + (0 == X) ? TT::clear(iv_data) : TT::set(iv_data); + return *this; + } /// /// @brief Invert entire buffer /// @return buffer_base&, Useful for method chaining /// inline buffer& invert(void) - { TT::invert(iv_data); return *this; } + { + TT::invert(iv_data); + return *this; + } /// /// @brief Bit reverse entire buffer /// @return buffer_base&, Useful for method chaining /// inline buffer& reverse(void) - { TT::reverse(iv_data); return *this; } + { + TT::reverse(iv_data); + return *this; + } ///@} @@ -324,7 +347,10 @@ namespace fapi2 /// @brief Get a pointer to the buffer bits /// @return Pointer to the buffer itself /// - inline T* pointer(void) { return &iv_data; } + inline T* pointer(void) + { + return &iv_data; + } // Note: Many (all?) of these are not needed and the compiler complains // as the cast to T yields a better operator. There are here mainly for @@ -425,7 +451,7 @@ namespace fapi2 /// @return buffer& Useful for method chaining /// template<bits_type TS, bits_type L, bits_type SS = 0, typename OT> - inline buffer& insert(const OT i_datain) + inline buffer & insert(const OT i_datain) { const bits_type target_length = parameterTraits<T>::bit_length(); const bits_type source_length = parameterTraits<OT>::bit_length(); @@ -444,15 +470,19 @@ namespace fapi2 uint64_t source = static_cast<uint64_t>(i_datain); const uint64_t target = static_cast<uint64_t>(iv_data); - const bits_type source_start = parameterTraits<uint64_t>::bit_length() - (source_length - SS); - const bits_type target_start = parameterTraits<uint64_t>::bit_length() - (target_length - TS); + const bits_type source_start = parameterTraits<uint64_t>::bit_length() - + (source_length - SS); + const bits_type target_start = parameterTraits<uint64_t>::bit_length() - + (target_length - TS); // Get mask value for Target buffer // Note: Need "& 0UL" because bit shift left for Target buffer doesn't roll off - uint64_t mask = ((~0UL << (parameterTraits<uint64_t>::bit_length() - L)) & ~0UL) >> target_start; + uint64_t mask = ((~0UL << (parameterTraits<uint64_t>::bit_length() - L)) & ~0UL) + >> target_start; // Align the source to the target. Make things signed so we know which way to shift. int32_t shift = source_start - target_start; + if (shift > 0) { source <<= shift; @@ -514,15 +544,19 @@ namespace fapi2 uint64_t source = static_cast<uint64_t>(i_datain); const uint64_t target = static_cast<uint64_t>(iv_data); - const bits_type source_start = parameterTraits<uint64_t>::bit_length() - (source_length - i_sourceStart); - const bits_type target_start = parameterTraits<uint64_t>::bit_length() - (target_length - i_targetStart); + const bits_type source_start = parameterTraits<uint64_t>::bit_length() - + (source_length - i_sourceStart); + const bits_type target_start = parameterTraits<uint64_t>::bit_length() - + (target_length - i_targetStart); // Get mask value for Target buffer // Note: Need "& 0UL" because bit shift left for Target buffer doesn't roll off - uint64_t mask = ((~0UL << (parameterTraits<uint64_t>::bit_length() - i_len)) & ~0UL) >> target_start; + uint64_t mask = ((~0UL << (parameterTraits<uint64_t>::bit_length() - i_len)) & + ~0UL) >> target_start; // Align the source to the target. Make things signed so we know which way to shift. int32_t shift = source_start - target_start; + if (shift > 0) { source <<= shift; @@ -558,7 +592,7 @@ namespace fapi2 static_assert((TS + L) <= parameterTraits<T>::bit_length(), "InsertFromRight(): (Target Start + Len) is out of bounds"); - this->insert<TS, L, parameterTraits<OT>::bit_length() - L>(i_datain); + this->insert < TS, L, parameterTraits<OT>::bit_length() - L > (i_datain); return *this; } @@ -573,7 +607,8 @@ namespace fapi2 /// @note Data is assumed to be aligned on the word boundary of L /// template<typename OT> - fapi2::ReturnCode insertFromRight(const OT i_datain, const bits_type i_targetStart, + fapi2::ReturnCode insertFromRight(const OT i_datain, + const bits_type i_targetStart, const bits_type i_len) { // Error if input data don't make sense @@ -595,7 +630,28 @@ namespace fapi2 return FAPI2_RC_INVALID_PARAMETER; } - return this->insert(i_datain, i_targetStart, i_len, parameterTraits<OT>::bit_length() - i_len); + return this->insert(i_datain, i_targetStart, i_len, + parameterTraits<OT>::bit_length() - i_len); + } + + /// + /// @brief Copy data from this buffer into an OT + /// @tparam SS Start bit in source + /// @tparam L Length of bits to insert + /// @tparam TS Start bit to insert into (target start) + /// @tparam OT the type of the outgoing (target) + /// @param[out] o_out OT to copy into - data is placed left aligned + /// @return const buffer& Useful for method chaining + /// + template<bits_type SS, bits_type L, bits_type TS = 0, typename OT> + inline const buffer & extract(OT& o_out) const + { + // Extraction is just an insert into o_out + + buffer<OT> out(o_out); + out.insert<TS, L, SS>(iv_data); + o_out = out; + return *this; } /// @@ -608,7 +664,7 @@ namespace fapi2 /// @return buffer& Useful for method chaining /// template<bits_type SS, bits_type L, bits_type TS = 0, typename OT> - inline buffer& extract(OT& o_out) + inline buffer & extract(OT& o_out) { // Extraction is just an insert into o_out @@ -629,12 +685,14 @@ namespace fapi2 /// template<typename OT> fapi2::ReturnCode extract(OT& o_out, const bits_type i_sourceStart, - const bits_type i_len, const bits_type i_targetStart = 0) + const bits_type i_len, const bits_type i_targetStart = 0) const { // Extraction is just an insert into o_out buffer<OT> out(o_out); - if (out.insert(iv_data, i_targetStart, i_len, i_sourceStart) != FAPI2_RC_SUCCESS) + + if (out.insert(iv_data, i_targetStart, i_len, + i_sourceStart) != FAPI2_RC_SUCCESS) { return FAPI2_RC_INVALID_PARAMETER; } @@ -649,12 +707,27 @@ namespace fapi2 /// @tparam L Length of bits to extract /// @tparam OT the type of the outgoing (target) /// @param[out] o_out OT to copy into - data is placed right aligned + /// @return const buffer& Useful for method chaining + /// + template<bits_type SS, bits_type L, typename OT> + inline const buffer& extractToRight(OT& o_out) const + { + extract < SS, L, parameterTraits<OT>::bit_length() - L > (o_out); + return *this; + } + + /// + /// @brief Copy data from this buffer into an OT and right justify + /// @tparam SS Start bit to insert into (source start) + /// @tparam L Length of bits to extract + /// @tparam OT the type of the outgoing (target) + /// @param[out] o_out OT to copy into - data is placed right aligned /// @return buffer& Useful for method chaining /// template<bits_type SS, bits_type L, typename OT> inline buffer& extractToRight(OT& o_out) { - extract<SS, L, parameterTraits<OT>::bit_length() - L>(o_out); + extract < SS, L, parameterTraits<OT>::bit_length() - L > (o_out); return *this; } @@ -668,9 +741,10 @@ namespace fapi2 /// template<typename OT> fapi2::ReturnCode extractToRight(OT& o_out, const bits_type i_sourceStart, - const bits_type i_len) + const bits_type i_len) const { - return extract(o_out, i_sourceStart, i_len, parameterTraits<OT>::bit_length() - i_len); + return extract(o_out, i_sourceStart, i_len, + parameterTraits<OT>::bit_length() - i_len); } ///@} @@ -678,7 +752,7 @@ namespace fapi2 private: /// The contents of the buffer T iv_data; - }; +}; } #endif diff --git a/importtemp/fapi2/include/error_info_defs.H b/importtemp/fapi2/include/error_info_defs.H index e0f4a898..31fc3429 100644 --- a/importtemp/fapi2/include/error_info_defs.H +++ b/importtemp/fapi2/include/error_info_defs.H @@ -33,9 +33,9 @@ #include <stdint.h> #include <target.H> -//#include <variable_buffer.H> +#include <variable_buffer.H> -//#include <iostream> +#include <iostream> namespace fapi2 { @@ -230,8 +230,6 @@ namespace fapi2 return EI_FFDC_SIZE_TARGET; } - // Comment out this code temporarily for compilation -#if 0 /// /// @brief Get FFDC Size specialization for variable buffers /// @@ -242,7 +240,6 @@ namespace fapi2 return std::min(static_cast<uint32_t>(EI_FFDC_MAX_SIZE), i_thing.getLength<uint8_t>()); } -#endif }; diff --git a/importtemp/fapi2/include/fapi2.H b/importtemp/fapi2/include/fapi2.H index 4e7121fd..4dcfbfa2 100644 --- a/importtemp/fapi2/include/fapi2.H +++ b/importtemp/fapi2/include/fapi2.H @@ -35,7 +35,9 @@ #include <error_scope.H> #include <set_sbe_error.H> // Generated file -#include <hwp_executor.H> +#include <fapi2_hwp_executor.H> +#include <fapi2_attribute_service.H> +#include <fapi2_chip_ec_feature.H> #include <mvpd_access.H> diff --git a/importtemp/fapi2/include/fapi2_chip_ec_feature.H b/importtemp/fapi2/include/fapi2_chip_ec_feature.H index 2398b5da..856cb6a7 100644 --- a/importtemp/fapi2/include/fapi2_chip_ec_feature.H +++ b/importtemp/fapi2/include/fapi2_chip_ec_feature.H @@ -1,3 +1,21 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: hwpf/fapi2/include/fapi2_chip_ec_feature.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* EKB Project */ +/* */ +/* COPYRIGHT 2015 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ +/* */ +/* IBM_PROLOG_END_TAG */ /// /// @file src/include/usr/hwpf/fapi2/fapi2_chip_ec_feature.H /// @@ -15,6 +33,7 @@ #include <stdint.h> #include <target.H> #include <return_code.H> +#include <attribute_ids.H> namespace fapi2 { @@ -33,7 +52,7 @@ namespace fapi2 template< TargetType K > ReturnCode queryChipEcFeature(AttributeId i_id, const Target<K>& i_target, - uint8_t & o_hasFeature); + uint8_t& o_hasFeature); } #endif diff --git a/importtemp/fapi2/include/fapi2_hw_access.H b/importtemp/fapi2/include/fapi2_hw_access.H index fca775b1..fe310df7 100644 --- a/importtemp/fapi2/include/fapi2_hw_access.H +++ b/importtemp/fapi2/include/fapi2_hw_access.H @@ -1,25 +1,19 @@ /* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ -/* $Source: $ */ +/* $Source: hwpf/fapi2/include/fapi2_hw_access.H $ */ /* */ -/* OpenPOWER HostBoot Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2012,2014 */ -/* [+] International Business Machines Corp. */ +/* IBM CONFIDENTIAL */ /* */ +/* EKB Project */ /* */ -/* 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 */ +/* COPYRIGHT 2012,2015 */ +/* [+] International Business Machines Corp. */ /* */ -/* 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. */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ /* */ /* IBM_PROLOG_END_TAG */ /// @@ -32,8 +26,8 @@ #define _FAPI2_COMMON_HWACCESS_H_ #ifdef FAPI_SUPPORT_SPY_AS_ENUM -#include <spy_ids.H> -typedef uint64_t spyId_t; + #include <spy_ids.H> + typedef uint64_t spyId_t; #endif #include <stdint.h> @@ -42,7 +36,7 @@ typedef uint64_t spyId_t; // variable_buffer isn't supported on PPE #ifndef __PPE__ -#include <variable_buffer.H> + #include <variable_buffer.H> #endif #include <return_code.H> @@ -51,357 +45,362 @@ typedef uint64_t spyId_t; #include <plat_hw_access.H> #ifdef FAPI_SUPPORT_MULTI_SCOM -#include <multi_scom.H> + #include <multi_scom.H> #endif namespace fapi2 { - //-------------------------------------------------------------------------- - // PIB Error Functions - //-------------------------------------------------------------------------- - - /// @brief Sets the PIB error mask - platform dependant - /// @param[in] i_mask The new error mask - inline void setPIBErrorMask(uint8_t i_mask); - - /// @brief Gets the PIB error mask - platform dependant - /// @return uint8_t The current PIB error mask - inline uint8_t getPIBErrorMask(void); - - //-------------------------------------------------------------------------- - // Operational Mode Error Functions - //-------------------------------------------------------------------------- - - /// @brief Sets the operational mode - /// @param[in] i_mode The new mode - inline void setOpMode(const OpModes i_mode); - - /// @brief Gets the operational mode - /// @return the operational mode - inline OpModes getOpMode(void); - - //-------------------------------------------------------------------------- - // HW Communication Functions - //-------------------------------------------------------------------------- - - /// @brief Reads a SCOM register from a chip. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target HW target to operate on. - /// @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 > - inline ReturnCode getScom(const Target<K>& i_target, const uint64_t i_address, - buffer<uint64_t>& o_data); - - /// @brief Writes a SCOM register on a chip. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target HW target to operate on. - /// @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 > - inline ReturnCode putScom(const Target<K>& i_target, const uint64_t i_address, - const buffer<uint64_t> i_data); - - /// @brief Writes a SCOM register under mask on a chip - /// @tparam K template parameter, passed in target. - /// @param[in] i_target HW target to operate on. - /// @param[in] i_address SCOM register address to write to. - /// @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 > - inline ReturnCode putScomUnderMask(const Target<K>& i_target, - const uint64_t i_address, - const buffer<uint64_t> i_data, - const buffer<uint64_t> i_mask); - - /// @brief Reads a CFAM register from a chip. - /// CFAM register is 32-bit wide. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target HW target to operate on. - /// @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 > - inline ReturnCode getCfamRegister(const Target<K>& i_target, - const uint32_t i_address, - buffer<uint32_t>& o_data); - - /// @brief Writes a CFAM register on a chip. - /// CFAM register is 32-bit wide. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target HW target to operate on. - /// @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 > - inline ReturnCode putCfamRegister(const Target<K>& i_target, - const uint32_t i_address, - const buffer<uint32_t> i_data); - - /// @brief Read-modify-write a CFAM register on a chip. - /// CFAM register is 32-bit wide. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target HW target to operate on. - /// @param[in] i_address CFAM register address to modify. - /// @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 > - inline ReturnCode modifyCfamRegister(const Target<K>& i_target, - const uint32_t i_address, - const buffer<uint32_t> i_data, - const ChipOpModifyMode i_modifyMode); - - // variable_buffer isn't supported on PPE +//-------------------------------------------------------------------------- +// PIB Error Functions +//-------------------------------------------------------------------------- + +/// @brief Sets the PIB error mask - platform dependant +/// @param[in] i_mask The new error mask +inline void setPIBErrorMask(uint8_t i_mask); + +/// @brief Gets the PIB error mask - platform dependant +/// @return uint8_t The current PIB error mask +inline uint8_t getPIBErrorMask(void); + +//-------------------------------------------------------------------------- +// Operational Mode Error Functions +//-------------------------------------------------------------------------- + +/// @brief Sets the operational mode +/// @param[in] i_mode The new mode +inline void setOpMode(const OpModes i_mode); + +/// @brief Gets the operational mode +/// @return the operational mode +inline OpModes getOpMode(void); + +//-------------------------------------------------------------------------- +// HW Communication Functions +//-------------------------------------------------------------------------- + +/// @brief Reads a SCOM register from a chip. +/// @tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @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 > +inline ReturnCode getScom(const Target<K>& i_target, const uint64_t i_address, + buffer<uint64_t>& o_data); + +/// @brief Writes a SCOM register on a chip. +/// @tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @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 > +inline ReturnCode putScom(const Target<K>& i_target, const uint64_t i_address, + const buffer<uint64_t> i_data); + +/// @brief Writes a SCOM register under mask on a chip +/// @tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @param[in] i_address SCOM register address to write to. +/// @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 > +inline ReturnCode putScomUnderMask(const Target<K>& i_target, + const uint64_t i_address, + const buffer<uint64_t> i_data, + const buffer<uint64_t> i_mask); + +/// @brief Reads a CFAM register from a chip. +/// CFAM register is 32-bit wide. +/// @tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @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 > +inline ReturnCode getCfamRegister(const Target<K>& i_target, + const uint32_t i_address, + buffer<uint32_t>& o_data); + +/// @brief Writes a CFAM register on a chip. +/// CFAM register is 32-bit wide. +/// @tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @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 > +inline ReturnCode putCfamRegister(const Target<K>& i_target, + const uint32_t i_address, + const buffer<uint32_t> i_data); + +/// @brief Read-modify-write a CFAM register on a chip. +/// CFAM register is 32-bit wide. +/// @tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @param[in] i_address CFAM register address to modify. +/// @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 > +inline ReturnCode modifyCfamRegister(const Target<K>& i_target, + const uint32_t i_address, + const buffer<uint32_t> i_data, + const ChipOpModifyMode i_modifyMode); + +// variable_buffer isn't supported on PPE #ifndef __PPE__ - /// @brief Reads a ring from a chip. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target Target to operate on. - /// @param[in] i_address Ring address to read from. - /// @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 > - inline ReturnCode getRing(const Target<K>& i_target, - const scanRingId_t i_address, - variable_buffer& o_data, - const RingMode i_ringMode = 0); - - /// @brief Writes a ring to a chip. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target Target to operate on. - /// @param[in] i_address Ring address to write to. - /// @param[in] i_data Buffer that contains RS4 compressed ring data - /// to write into address - /// @param[in] i_ringMode Ring operation mode. - /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K > - inline ReturnCode putRing(const Target<K>& i_target, - const scanRingId_t i_address, - const variable_buffer& i_data, - const RingMode i_ringMode = 0); - - - /// @brief Read-modify-write a ring on a chip. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target Target to operate on. - /// @param[in] i_address Ring address to modify. - /// @param[in] i_data Buffer that contains RS4 compressed ring data - /// to be modified. - /// @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 > - inline ReturnCode modifyRing(const Target<K>& i_target, - const scanRingId_t i_address, - const variable_buffer& i_data, - const ChipOpModifyMode i_modifyMode, - const RingMode i_ringMode = 0); +/// @brief Reads a ring from a chip. +/// @tparam K template parameter, passed in target. +/// @param[in] i_target Target to operate on. +/// @param[in] i_address Ring address to read from. +/// @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 > +inline ReturnCode getRing(const Target<K>& i_target, + const scanRingId_t i_address, + variable_buffer& o_data, + const RingMode i_ringMode = 0); + +/// @brief Writes a ring to a chip. +/// @tparam K template parameter, passed in target. +/// @param[in] i_target Target to operate on. +/// @param[in] i_address Ring address to write to. +/// @param[in] i_data Buffer that contains RS4 compressed ring data +/// to write into address +/// @param[in] i_ringMode Ring operation mode. +/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +template< TargetType K > +inline ReturnCode putRing(const Target<K>& i_target, + const scanRingId_t i_address, + const variable_buffer& i_data, + const RingMode i_ringMode = 0); + + +/// @brief Read-modify-write a ring on a chip. +/// @tparam K template parameter, passed in target. +/// @param[in] i_target Target to operate on. +/// @param[in] i_address Ring address to modify. +/// @param[in] i_data Buffer that contains RS4 compressed ring data +/// to be modified. +/// @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 > +inline ReturnCode modifyRing(const Target<K>& i_target, + const scanRingId_t i_address, + const variable_buffer& i_data, + const ChipOpModifyMode i_modifyMode, + const RingMode i_ringMode = 0); #endif #ifdef FAPI_SUPPORT_MULTI_SCOM - /// @brief Performs a multiple SCOM operation - /// This interface performs multiple SCOM operations on a chip in the - /// order specified by the input MultiScom object. - /// See fapiMultiScom.H for details of how to populate the MultiScom - /// object with SCOM operations. - /// - /// @tparam K template parameter, passed in target. - /// @param[in] i_target Target to operate on. - /// @param[in,out] io_multiScomObj Reference to a MultiScom object, - /// pre-populated with SingleScomInfo entries - /// to perform multiple SCOMs on input target - /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - /// - /// @note This is a synchronous interface and would return after all the - /// SCOM operations are completed or on the first failed operation - /// - /// @note SCOMs will be performed in the order they were added to the - /// input MultiScom object - /// - /// @note In case of errors, the platform code is responsible to collect - /// and add all the required error info and FFDC into the error data - /// for debugging - /// - /// @note If the SCOM operations added are specific to a processor chip, - /// then the FSI Shift Engine configured in scatter-gather DMA mode - /// extension would be used to execute the SCOM operations in a - /// performance optimize mode. In this mode, the special - /// SCOM_BULK_READ_MODE and SCOM_BULK_WRITE_MODE operations are - /// supported that allow a large bulk of SCOM access (in multiple of - /// 64 bits) for targets that support auto-increment. The - /// SCOM_WRITE_UNDER_MASK operation is not supported in this mode - /// - /// @note If the SCOM operations added are specific to a memory buffer - /// chip, then the regular SCOM engine is used to execute the SCOM - /// operations. SCOM_WRITE_UNDER_MASK operation is supported in - /// this mode, but the special SCOM_BULK_READ_MODE and - /// SCOM_BULK_WRITE_MODE operations are not supported due to - /// hardware limitations. - /// - template< TargetType K > - fapi2::ReturnCode multiScom (const Target<K>& i_target, - MultiScom& io_multiScomObj); +/// @brief Performs a multiple SCOM operation +/// This interface performs multiple SCOM operations on a chip in the +/// order specified by the input MultiScom object. +/// See fapiMultiScom.H for details of how to populate the MultiScom +/// object with SCOM operations. +/// +/// @tparam K template parameter, passed in target. +/// @param[in] i_target Target to operate on. +/// @param[in,out] io_multiScomObj Reference to a MultiScom object, +/// pre-populated with SingleScomInfo entries +/// to perform multiple SCOMs on input target +/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +/// @note This is a synchronous interface and would return after all the +/// SCOM operations are completed or on the first failed operation +/// +/// @note SCOMs will be performed in the order they were added to the +/// input MultiScom object +/// +/// @note In case of errors, the platform code is responsible to collect +/// and add all the required error info and FFDC into the error data +/// for debugging +/// +/// @note If the SCOM operations added are specific to a processor chip, +/// then the FSI Shift Engine configured in scatter-gather DMA mode +/// extension would be used to execute the SCOM operations in a +/// performance optimize mode. In this mode, the special +/// SCOM_BULK_READ_MODE and SCOM_BULK_WRITE_MODE operations are +/// supported that allow a large bulk of SCOM access (in multiple of +/// 64 bits) for targets that support auto-increment. The +/// SCOM_WRITE_UNDER_MASK operation is not supported in this mode +/// +/// @note If the SCOM operations added are specific to a memory buffer +/// chip, then the regular SCOM engine is used to execute the SCOM +/// operations. SCOM_WRITE_UNDER_MASK operation is supported in +/// this mode, but the special SCOM_BULK_READ_MODE and +/// SCOM_BULK_WRITE_MODE operations are not supported due to +/// hardware limitations. +/// +template< TargetType K > +fapi2::ReturnCode multiScom (const Target<K>& i_target, + MultiScom& io_multiScomObj); #endif - // -------------------------------------------------------------------------- - // NOTE: - // Implement platform Spy access functions if platform supports them. - // -------------------------------------------------------------------------- +// -------------------------------------------------------------------------- +// NOTE: +// Implement platform Spy access functions if platform supports them. +// -------------------------------------------------------------------------- - // variable_buffer isn't supported on PPE +// variable_buffer isn't supported on PPE #ifndef __PPE__ - /// @brief Reads a spy from a chip. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target Target to operate on. - /// @param[in] i_spyId Id of the spy whose data to be read. - /// @param[out] o_data Buffer that holds data read from HW target. - /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - /// - /// @note: The string version is only supported for cronus. - /// - /// The fapi design to support both FSP and cronus use of get and - /// put spy functions is dependant on the SPY names being expanded - /// to resemble a valid C identifier. This design places some - /// restrictions on the SPY names which can be used. - /// - /// 1. if the spy name contains a # procedure writers should replace - /// it with an __P__ for example - - /// - /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS - /// becomes - /// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS - /// - /// 2. if the spy name has a number following a "." it must have an - /// underscore prepended to the number. - /// - /// EH.TPCHIP.2KX100_ARY_CLK_EDGES_DLY - /// becomes - /// EH.TPCHIP._2KX100_ARY_CLK_EDGES_DLY - /// - /// Example SPY name: - /// The hardware procedure should call the function like: - /// - /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS - /// - /// fapi2::ReturnCode rc = fapiGetSpy( targ, - /// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS, data ); - /// - /// @note The ID is not in quotes the fapi code will handle adding - /// the quotes for the cronus environment +/// @brief Reads a spy from a chip. +/// @tparam K template parameter, passed in target. +/// @param[in] i_target Target to operate on. +/// @param[in] i_spyId Id of the spy whose data to be read. +/// @param[out] o_data Buffer that holds data read from HW target. +/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +/// @note: The string version is only supported for cronus. +/// +/// The fapi design to support both FSP and cronus use of get and +/// put spy functions is dependant on the SPY names being expanded +/// to resemble a valid C identifier. This design places some +/// restrictions on the SPY names which can be used. +/// +/// 1. if the spy name contains a # procedure writers should replace +/// it with an __P__ for example - +/// +/// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS +/// becomes +/// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS +/// +/// 2. if the spy name has a number following a "." it must have an +/// underscore prepended to the number. +/// +/// EH.TPCHIP.2KX100_ARY_CLK_EDGES_DLY +/// becomes +/// EH.TPCHIP._2KX100_ARY_CLK_EDGES_DLY +/// +/// Example SPY name: +/// The hardware procedure should call the function like: +/// +/// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS +/// +/// fapi2::ReturnCode rc = fapiGetSpy( targ, +/// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS, data ); +/// +/// @note The ID is not in quotes the fapi code will handle adding +/// the quotes for the cronus environment #if defined(FAPI_SUPPORT_SPY_AS_ENUM) || defined(DOXYGEN) #define FAPI_GET_SPY(TARGET, ID, DATA) fapi2::getSpy(TARGET, FAPI_SPY_NAMES::ID.value, DATA) - template< TargetType K > - inline ReturnCode getSpy(const Target<K>& i_target, - const spyId_t i_spyId, - variable_buffer& o_data); +template< TargetType K > +inline ReturnCode getSpy(const Target<K>& i_target, + const spyId_t i_spyId, + variable_buffer& o_data); #endif #if defined(FAPI_SUPPORT_SPY_AS_STRING) || defined(DOXYGEN) #define FAPI_GET_SPY(TARGET, ID, DATA) fapi2::getSpy(TARGET, #ID, DATA) - template< TargetType K > - inline ReturnCode getSpy(const Target<K>& i_target, - const char * const i_spyId, - variable_buffer& o_data); +template< TargetType K > +inline ReturnCode getSpy(const Target<K>& i_target, + const char* const i_spyId, + variable_buffer& o_data); #endif - /// @brief Writes a spy on a chip. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target Target to operate on. - /// @param[in] i_spyId Id of the spy to write data to. - /// @param[out] i_data Buffer that holds data to write into spy. - /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - /// - /// @note: The string version is only supported for cronus. - /// - /// The fapi design to support both FSP and cronus use of get and - /// put spy functions is dependent on the SPY names being expanded - /// to resemble a valid C identifier. This design places some - /// restrictions on the SPY names which can be used. - /// - /// 1. if the spy name contains a # procedure writers should replace - /// is with an __P__ for example - - /// - /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS - /// becomes - /// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS - /// - /// 2. if the spy name has a number following a "." it must have an - /// underscore prepended to the number. - /// - /// EH.TPCHIP.2KX100_ARY_CLK_EDGES_DLY - /// becomes - /// EH.TPCHIP._2KX100_ARY_CLK_EDGES_DLY - /// - /// Example SPY name: - /// The hardware procedure should call the function like: - /// - /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS - /// - /// fapi2::ReturnCode rc = fapiPutSpy( targ, - /// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS, data ); - /// - /// @note The ID is not in quotes the fapi code will handle adding - /// the quotes for the cronus environment - /// +/// @brief Writes a spy on a chip. +/// @tparam K template parameter, passed in target. +/// @param[in] i_target Target to operate on. +/// @param[in] i_spyId Id of the spy to write data to. +/// @param[out] i_data Buffer that holds data to write into spy. +/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +/// @note: The string version is only supported for cronus. +/// +/// The fapi design to support both FSP and cronus use of get and +/// put spy functions is dependent on the SPY names being expanded +/// to resemble a valid C identifier. This design places some +/// restrictions on the SPY names which can be used. +/// +/// 1. if the spy name contains a # procedure writers should replace +/// is with an __P__ for example - +/// +/// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS +/// becomes +/// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS +/// +/// 2. if the spy name has a number following a "." it must have an +/// underscore prepended to the number. +/// +/// EH.TPCHIP.2KX100_ARY_CLK_EDGES_DLY +/// becomes +/// EH.TPCHIP._2KX100_ARY_CLK_EDGES_DLY +/// +/// Example SPY name: +/// The hardware procedure should call the function like: +/// +/// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS +/// +/// fapi2::ReturnCode rc = fapiPutSpy( targ, +/// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS, data ); +/// +/// @note The ID is not in quotes the fapi code will handle adding +/// the quotes for the cronus environment +/// #if defined(FAPI_SUPPORT_SPY_AS_ENUM) || defined(DOXYGEN) #define FAPI_PUT_SPY(TARGET, ID, DATA) fapi2::putSpy(TARGET, FAPI_SPY_NAMES::ID.value, DATA) - template< TargetType K > - inline ReturnCode putSpy(const Target<K>& i_target, - const spyId_t i_spyId, - variable_buffer& i_data); +template< TargetType K > +inline ReturnCode putSpy(const Target<K>& i_target, + const spyId_t i_spyId, + const variable_buffer& i_data); #endif #if defined(FAPI_SUPPORT_SPY_AS_STRING) || defined(DOXYGEN) #define FAPI_PUT_SPY(TARGET, ID, DATA) fapi2::putSpy(TARGET, #ID, DATA) - template< TargetType K > - inline ReturnCode putSpy(const Target<K>& i_target, - const char* const i_spyId, - variable_buffer& i_data); +template< TargetType K > +inline ReturnCode putSpy(const Target<K>& i_target, + const char* const i_spyId, + const variable_buffer& i_data); + +template< TargetType K > +inline ReturnCode putSpy(const Target<K>& i_target, + const char* const i_spyId, + const char* i_enum); #endif - /// @brief Writes spy data into a buffer holding ring data image - /// This API is used by L2/L3 repair to put column repair data - /// into a ring buffer image. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target Target to operate on. - /// @param[in] i_spyId Id of the spy. - /// @param[in] i_data Buffer that holds spy data to write into ring - /// image. - /// @param[out] o_data Buffer that holds updated ring image. - /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - /// - /// @note: The string version is only supported for cronus. - /// - /// The fapi design to support both FSP and cronus use of get and - /// put spy functions is dependent on the SPY names being expanded - /// to resemble a valid C identifier. This design places some - /// restrictions on the SPY names which can be used. - /// - /// See fapiPutSpy for details on spy id specifics. - /// +/// @brief Writes spy data into a buffer holding ring data image +/// This API is used by L2/L3 repair to put column repair data +/// into a ring buffer image. +/// @tparam K template parameter, passed in target. +/// @param[in] i_target Target to operate on. +/// @param[in] i_spyId Id of the spy. +/// @param[in] i_data Buffer that holds spy data to write into ring +/// image. +/// @param[out] o_data Buffer that holds updated ring image. +/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +/// @note: The string version is only supported for cronus. +/// +/// The fapi design to support both FSP and cronus use of get and +/// put spy functions is dependent on the SPY names being expanded +/// to resemble a valid C identifier. This design places some +/// restrictions on the SPY names which can be used. +/// +/// See fapiPutSpy for details on spy id specifics. +/// #if defined(FAPI_SUPPORT_SPY_AS_ENUM) || defined(DOXYGEN) #define FAPI_PUT_SPY_IMAGE(TARGET, ID, DATA1, DATA2) \ fapi2::putSpyImage(TARGET, FAPI_SPY_NAMES::ID.value, \ DATA1, DATA2) - template< TargetType K > - inline ReturnCode putSpyImage(const Target<K>& i_target, - const spyId_t i_spyId, - const variable_buffer& i_data, - variable_buffer& o_imageData); +template< TargetType K > +inline ReturnCode putSpyImage(const Target<K>& i_target, + const spyId_t i_spyId, + const variable_buffer& i_data, + variable_buffer& o_imageData); #endif #if defined(FAPI_SUPPORT_SPY_AS_STRING) || defined(DOXYGEN) @@ -409,41 +408,41 @@ namespace fapi2 #define FAPI_PUT_SPY_IMAGE(TARGET, ID, DATA1, DATA2) \ fapi2::putSpyImage(TARGET, #ID, DATA1,DATA2) - template< TargetType K > - inline ReturnCode putSpyImage(const Target<K>& i_target, - const char* const i_spyId, - const variable_buffer& i_data, - variable_buffer& o_imageData); +template< TargetType K > +inline ReturnCode putSpyImage(const Target<K>& i_target, + const char* const i_spyId, + const variable_buffer& i_data, + variable_buffer& o_imageData); #endif - /// @brief Reads spy data from a ring image buffer - /// @param[in] i_target Target to operate on - /// @param[in] i_spyId The spy's id - /// @param[out] o_data Buffer that holds data read from ring image. - /// @param[in] i_imageData Buffer that holds ring image to read data - /// from. - /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - /// - /// @note: The string version is only supported for cronus. - /// - /// The fapi design to support both FSP and cronus use of get and - /// put spy functions is dependent on the SPY names being expanded - /// to resemble a valid C identifier. This design places some - /// restrictions on the SPY names which can be used. - /// - /// See fapiPutSpy for details on spy id specifics. - /// +/// @brief Reads spy data from a ring image buffer +/// @param[in] i_target Target to operate on +/// @param[in] i_spyId The spy's id +/// @param[out] o_data Buffer that holds data read from ring image. +/// @param[in] i_imageData Buffer that holds ring image to read data +/// from. +/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +/// @note: The string version is only supported for cronus. +/// +/// The fapi design to support both FSP and cronus use of get and +/// put spy functions is dependent on the SPY names being expanded +/// to resemble a valid C identifier. This design places some +/// restrictions on the SPY names which can be used. +/// +/// See fapiPutSpy for details on spy id specifics. +/// #if defined(FAPI_SUPPORT_SPY_AS_ENUM) || defined(DOXYGEN) #define FAPI_GET_SPY_IMAGE(TARGET, ID, DATA1, DATA2) \ fapi2:getSpyImage(TARGET, FAPI_SPY_NAMES::ID.value, \ DATA1, DATA2) - template< TargetType K > - inline ReturnCode getSpyImage(const Target<K>& i_target, - const spyId_t i_spyId, - variable_buffer& o_data, - const variable_buffer& i_imageData); +template< TargetType K > +inline ReturnCode getSpyImage(const Target<K>& i_target, + const spyId_t i_spyId, + variable_buffer& o_data, + const variable_buffer& i_imageData); #endif #if defined(FAPI_SUPPORT_SPY_AS_STRING) || defined(DOXYGEN) @@ -451,11 +450,11 @@ namespace fapi2 #define FAPI_GET_SPY_IMAGE(TARGET, ID, DATA1, DATA2) \ fapi2::getSpyImage(TARGET, #ID, DATA1,DATA2) - template< TargetType K > - inline ReturnCode getSpyImage(const Target<K>& i_target, - const char * const i_spyId, - variable_buffer& o_data, - const variable_buffer& i_imageData); +template< TargetType K > +inline ReturnCode getSpyImage(const Target<K>& i_target, + const char* const i_spyId, + variable_buffer& o_data, + const variable_buffer& i_imageData); #endif #endif // PPE diff --git a/importtemp/fapi2/include/fapi2_target.H b/importtemp/fapi2/include/fapi2_target.H index b479fca7..ad22fe7d 100644 --- a/importtemp/fapi2/include/fapi2_target.H +++ b/importtemp/fapi2/include/fapi2_target.H @@ -1,3 +1,21 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: hwpf/fapi2/include/fapi2_target.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* EKB Project */ +/* */ +/* COPYRIGHT 2015 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ +/* */ +/* IBM_PROLOG_END_TAG */ /// /// @file fapi2_target.H /// @brief Common definitions for fapi2 targets @@ -7,6 +25,7 @@ #define __FAPI2_COMMON_TARGET__ #include <stdint.h> +#include <stdlib.h> #include <vector> #include <target_types.H> #include <target_states.H> @@ -14,68 +33,68 @@ namespace fapi2 { - /// - /// @brief Class representing a FAPI2 Target - /// @tparam K the type (Kind) of target - /// @tparam V the type of the target's Value - /// @remark TargetLite targets are uint64_t, Targets - /// are uintptr_t (void*). - /// - /// Assuming there are representations of a processor, - /// a membuf and a system here are some examples: - /// @code - /// #define PROCESSOR_CHIP_A 0xFFFF0000 - /// #define MEMBUF_CHIP_B 0x0000FFFF - /// #define SYSTEM_C 0x0000AAAA - /// @endcode - /// - /// * To define a target: - /// @code - /// fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> A(PROCESSOR_CHIP_A); - /// fapi2::Target<fapi2::TARGET_TYPE_SYSTEM> C(SYSTEM_C); - /// fapi2::Target<fapi2::TARGET_TYPE_MEMBUF_CHIP> B(MEMBUF_CHIP_B); - /// @endcode - /// - /// * Functions which take composite target types - /// @code - /// void takesProcOrMembuf( - /// const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP | - /// fapi2::TARGET_TYPE_MEMBUF_CHIP>& V ); - /// - /// void takesAny(const fapi2::Target<fapi2::TARGET_TYPE_ALL>& V ); - /// - /// @endcode - /// - /// * Traversing the target "tree" - /// @code - /// fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> A(PROCESSOR_CHIP_A); - /// - /// // Get A's parent - /// A.getParent<fapi2::TARGET_TYPE_SYSTEM>(); - /// - /// // Get the 0x53'd core - /// fapi2::getTarget<fapi2::TARGET_TYPE_CORE>(0x53); - /// - /// // Get all *my* present/functional children which are cores - /// A.getChildren<fapi2::TARGET_TYPE_CORE>(); - /// - /// // Get all of the the cores relative to my base target - /// fapi2::getChildren<fapi2::TARGET_TYPE_CORE>(); - /// @endcode - /// - /// * Invalid casts - /// @code - /// // Can't cast to a specialized target - /// fapi2::Target<fapi2::TARGET_TYPE_NONE> D(MEMBUF_CHIP_B); - /// takesProcOrMembuf( D ); - /// - /// // Not one of the shared types - /// fapi2::Target<fapi2::TARGET_TYPE_ABUS_ENDPOINT> E; - /// takesProcOrMembuf( E ); - /// @endcode - template<TargetType K, typename V = plat_target_handle_t> - class Target - { +/// +/// @brief Class representing a FAPI2 Target +/// @tparam K the type (Kind) of target +/// @tparam V the type of the target's Value +/// @remark TargetLite targets are uint64_t, Targets +/// are uintptr_t (void*). +/// +/// Assuming there are representations of a processor, +/// a membuf and a system here are some examples: +/// @code +/// #define PROCESSOR_CHIP_A 0xFFFF0000 +/// #define MEMBUF_CHIP_B 0x0000FFFF +/// #define SYSTEM_C 0x0000AAAA +/// @endcode +/// +/// * To define a target: +/// @code +/// fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> A(PROCESSOR_CHIP_A); +/// fapi2::Target<fapi2::TARGET_TYPE_SYSTEM> C(SYSTEM_C); +/// fapi2::Target<fapi2::TARGET_TYPE_MEMBUF_CHIP> B(MEMBUF_CHIP_B); +/// @endcode +/// +/// * Functions which take composite target types +/// @code +/// void takesProcOrMembuf( +/// const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP | +/// fapi2::TARGET_TYPE_MEMBUF_CHIP>& V ); +/// +/// void takesAny(const fapi2::Target<fapi2::TARGET_TYPE_ALL>& V ); +/// +/// @endcode +/// +/// * Traversing the target "tree" +/// @code +/// fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> A(PROCESSOR_CHIP_A); +/// +/// // Get A's parent +/// A.getParent<fapi2::TARGET_TYPE_SYSTEM>(); +/// +/// // Get the 0x53'd core +/// fapi2::getTarget<fapi2::TARGET_TYPE_CORE>(0x53); +/// +/// // Get all *my* present/functional children which are cores +/// A.getChildren<fapi2::TARGET_TYPE_CORE>(); +/// +/// // Get all of the the cores relative to my base target +/// fapi2::getChildren<fapi2::TARGET_TYPE_CORE>(); +/// @endcode +/// +/// * Invalid casts +/// @code +/// // Can't cast to a specialized target +/// fapi2::Target<fapi2::TARGET_TYPE_NONE> D(MEMBUF_CHIP_B); +/// takesProcOrMembuf( D ); +/// +/// // Not one of the shared types +/// fapi2::Target<fapi2::TARGET_TYPE_ABUS_ENDPOINT> E; +/// takesProcOrMembuf( E ); +/// @endcode +template<TargetType K, typename V = plat_target_handle_t> +class Target +{ public: /// @@ -120,25 +139,36 @@ namespace fapi2 /// @return V The target's handle, or value /// V get(void) const - { return iv_handle; } + { + return iv_handle; + } /// /// @brief Get the handle as a V /// @return V The target's handle, or value /// - inline operator V() const { return iv_handle; } + inline operator V() const + { + return iv_handle; + } /// /// @brief Get a target's value /// @return V The target's handle, or value /// - inline V& operator()(void) { return iv_handle; } + inline V& operator()(void) + { + return iv_handle; + } /// /// @brief Get the target type /// @return The type of target represented by this target /// - inline TargetType getType(void) const { return iv_type; } + inline TargetType getType(void) const + { + return iv_type; + } /// /// @brief Get this target's immediate parent @@ -154,8 +184,8 @@ namespace fapi2 /// inline constexpr bool isChip(void) const { - return ( (K == TARGET_TYPE_PROC_CHIP) || - (K == TARGET_TYPE_MEMBUF_CHIP) ); + return ( (K == TARGET_TYPE_PROC_CHIP) || + (K == TARGET_TYPE_MEMBUF_CHIP) ); } /// @@ -164,25 +194,25 @@ namespace fapi2 /// inline constexpr bool isChiplet(void) const { - return ( (K == TARGET_TYPE_EX) || - (K == TARGET_TYPE_MBA) || - (K == TARGET_TYPE_MCS) || - (K == TARGET_TYPE_XBUS) || - (K == TARGET_TYPE_ABUS) || - (K == TARGET_TYPE_L4) || - (K == TARGET_TYPE_CORE) || - (K == TARGET_TYPE_EQ) || - (K == TARGET_TYPE_MCA) || - (K == TARGET_TYPE_MCBIST) || - (K == TARGET_TYPE_MI) || - (K == TARGET_TYPE_DMI) || - (K == TARGET_TYPE_OBUS) || - (K == TARGET_TYPE_NV) || - (K == TARGET_TYPE_SBE) || - (K == TARGET_TYPE_PPE) || - (K == TARGET_TYPE_PERV) || - (K == TARGET_TYPE_PEC) || - (K == TARGET_TYPE_PHB) ); + return ( (K == TARGET_TYPE_EX) || + (K == TARGET_TYPE_MBA) || + (K == TARGET_TYPE_MCS) || + (K == TARGET_TYPE_XBUS) || + (K == TARGET_TYPE_ABUS) || + (K == TARGET_TYPE_L4) || + (K == TARGET_TYPE_CORE) || + (K == TARGET_TYPE_EQ) || + (K == TARGET_TYPE_MCA) || + (K == TARGET_TYPE_MCBIST) || + (K == TARGET_TYPE_MI) || + (K == TARGET_TYPE_DMI) || + (K == TARGET_TYPE_OBUS) || + (K == TARGET_TYPE_NV) || + (K == TARGET_TYPE_SBE) || + (K == TARGET_TYPE_PPE) || + (K == TARGET_TYPE_PERV) || + (K == TARGET_TYPE_PEC) || + (K == TARGET_TYPE_PHB) ); } /// @@ -231,201 +261,205 @@ namespace fapi2 static const TargetType iv_type = K; V iv_handle; - }; +}; - // EX threads map to CORE threads: - // t0 / t2 / t4 / t6 fused = t0 / t1 / t2 / t3 normal (c0) - // t1 / t3 / t5 / t7 fused = t0 / t1 / t2 / t3 normal (c1) - // So when splitting the EX, we need to map from EX threads - // to CORE threads. - - /// - /// @brief Given a normal core thread id, translate this to - /// a fused core thread id. (normal to fused) - /// @param[in] the ordinal number of the normal core this thread belongs to - /// @param[in] a normal core thread id - 0, ..., 3 - /// @return the fused core thread id - /// - inline uint8_t thread_id_n2f(const uint8_t i_ordinal, const uint8_t i_thread_id) - { - return (i_thread_id << 1) | i_ordinal; - } +// EX threads map to CORE threads: +// t0 / t2 / t4 / t6 fused = t0 / t1 / t2 / t3 normal (c0) +// t1 / t3 / t5 / t7 fused = t0 / t1 / t2 / t3 normal (c1) +// So when splitting the EX, we need to map from EX threads +// to CORE threads. + +/// +/// @brief Given a normal core thread id, translate this to +/// a fused core thread id. (normal to fused) +/// @param[in] the ordinal number of the normal core this thread belongs to +/// @param[in] a normal core thread id - 0, ..., 3 +/// @return the fused core thread id +/// +inline uint8_t thread_id_n2f(const uint8_t i_ordinal, const uint8_t i_thread_id) +{ + return (i_thread_id << 1) | i_ordinal; +} + +/// +/// @brief Given a fused core thread id, translate this to +/// a normal core thread id. (fused to normal) +/// @param[in] a fused core thread id - 0, ..., 7 +/// @return the normal core thread id +/// +inline uint8_t thread_id_f2n(const uint8_t i_thread_id) +{ + return i_thread_id >> 1; +} + +/// +/// @brief Given a normal core thread id, translate this to a +/// normal core bitset. +/// @param[in] a normal core thread id - 0, ..., 3 +/// @return the normal core bitset +/// @note to got from a fused core id to a normal core bitset, +/// translate from a fused core thread id first. +/// +inline uint8_t thread_id2bitset(const uint8_t i_thread_id) +{ + // 0xff means "set all bits" + static const uint8_t all_threads = 0xff; + static const uint8_t all_normal_threads_bitset = 0x0f; - /// - /// @brief Given a fused core thread id, translate this to - /// a normal core thread id. (fused to normal) - /// @param[in] a fused core thread id - 0, ..., 7 - /// @return the normal core thread id - /// - inline uint8_t thread_id_f2n(const uint8_t i_thread_id) + if (i_thread_id == all_threads) { - return i_thread_id >> 1; + return all_normal_threads_bitset; } - /// - /// @brief Given a normal core thread id, translate this to a - /// normal core bitset. - /// @param[in] a normal core thread id - 0, ..., 3 - /// @return the normal core bitset - /// @note to got from a fused core id to a normal core bitset, - /// translate from a fused core thread id first. - /// - inline uint8_t thread_id2bitset(const uint8_t i_thread_id) + // A thread_id is really just bit index. + return (1 << (4 - i_thread_id - 1)); +} + +/// +/// @brief Given a bitset of normal core thread ids, translate this to +/// a bit mask of fused core thread id. (normal to fused) +/// @param[in] the ordinal number of the normal core this thread belongs to +/// @param[in] a normal core thread bitset - b0000, ..., b1111 +/// @return the corresponding fused core bitset +/// +inline uint8_t thread_bitset_n2f(const uint8_t i_ordinal, const uint8_t i_threads) +{ + // Since we only have 4 bits I think this is better than a shift-type solution + // for interleaving bits + static uint8_t core_map[] = { - // 0xff means "set all bits" - static const uint8_t all_threads = 0xff; - static const uint8_t all_normal_threads_bitset = 0x0f; + 0b00000000, // b0000 + 0b00000010, // b0001 + 0b00001000, // b0010 + 0b00001010, // b0011 + 0b00100000, // b0100 + 0b00100010, // b0101 + 0b00101000, // b0110 + 0b00101010, // b0111 + 0b10000000, // b1000 + 0b10000010, // b1001 + 0b10001000, // b1010 + 0b10001010, // b1011 + 0b10100000, // b1100 + 0b10100010, // b1101 + 0b10101000, // b1110 + 0b10101010, // b1111 + }; - if (i_thread_id == all_threads) - { - return all_normal_threads_bitset; - } + return core_map[i_threads] >> i_ordinal; +} - // A thread_id is really just bit index. - return (1 << (4 - i_thread_id - 1)); - } +/// +/// @brief Given a fused core thread bitset, translate this to +/// a normal core thread bitset. (fused to normal) +/// @param[in] the ordinal number of the normal core this thread belongs to +/// @param[in] a fused core thread bitset - b00000000, ..., b11111111 +/// @return the corresponding normal core bitset +/// +inline uint8_t thread_bitset_f2n(const uint8_t i_ordinal, const uint8_t i_threads) +{ + uint8_t normal_set = 0; + + // core 0 is the left-most bit in the pair + uint8_t pair_mask = (i_ordinal == 0) ? 0x2 : 0x1; - /// - /// @brief Given a bitset of normal core thread ids, translate this to - /// a bit mask of fused core thread id. (normal to fused) - /// @param[in] the ordinal number of the normal core this thread belongs to - /// @param[in] a normal core thread bitset - b0000, ..., b1111 - /// @return the corresponding fused core bitset - /// - inline uint8_t thread_bitset_n2f(const uint8_t i_ordinal, const uint8_t i_threads) + // For each bit which can be set in the normal core bit_set ... + for( auto i = 0; i <= 3; ++i ) { - // Since we only have 4 bits I think this is better than a shift-type solution - // for interleaving bits - static uint8_t core_map[] = { - 0b00000000, // b0000 - 0b00000010, // b0001 - 0b00001000, // b0010 - 0b00001010, // b0011 - 0b00100000, // b0100 - 0b00100010, // b0101 - 0b00101000, // b0110 - 0b00101010, // b0111 - 0b10000000, // b1000 - 0b10000010, // b1001 - 0b10001000, // b1010 - 0b10001010, // b1011 - 0b10100000, // b1100 - 0b10100010, // b1101 - 0b10101000, // b1110 - 0b10101010, // b1111 - }; - - return core_map[i_threads] >> i_ordinal; + // ... grab the two fused bits which represent it ... + // ... and mask off the bit in the pair which represents this normal core ... + // (the << 1 shifts the masks over as we walk the pairs of bits) + uint8_t bits = (((3 << (i << 1)) & i_threads) & (pair_mask << (i << 1))); + + // ... if either bit is set, set the corresponding bit in + // the normal core bitset. + normal_set |= (bits != 0) << i; } - /// - /// @brief Given a fused core thread bitset, translate this to - /// a normal core thread bitset. (fused to normal) - /// @param[in] the ordinal number of the normal core this thread belongs to - /// @param[in] a fused core thread bitset - b00000000, ..., b11111111 - /// @return the corresponding normal core bitset - /// - inline uint8_t thread_bitset_f2n(const uint8_t i_ordinal, const uint8_t i_threads) - { - uint8_t normal_set = 0; + return normal_set; +} - // core 0 is the left-most bit in the pair - uint8_t pair_mask = (i_ordinal == 0) ? 0x2 : 0x1; +/// +/// @brief Return the string interpretation of this target +/// @tparam T The type of the target +/// @param[in] i_target Target<T> +/// @param[in] i_buffer buffer to write in to +/// @param[in] i_bsize size of the buffer +/// @return void +/// @post The contents of the buffer is replaced with the string +/// representation of the target +/// +template< TargetType T > +inline void toString(const Target<T>& i_target, char* i_buffer, size_t i_bsize); - // For each bit which can be set in the normal core bit_set ... - for( auto i = 0; i <= 3; ++i ) - { - // ... grab the two fused bits which represent it ... - // ... and mask off the bit in the pair which represents this normal core ... - // (the << 1 shifts the masks over as we walk the pairs of bits) - uint8_t bits = (((3 << (i << 1)) & i_threads) & (pair_mask << (i << 1))); - - // ... if either bit is set, set the corresponding bit in - // the normal core bitset. - normal_set |= (bits != 0) << i; - } - return normal_set; - } +/// +/// @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<T> +/// @param[in] i_buffer buffer to write in to +/// @param[in] i_bsize size of the buffer +/// @return void +/// @post The contents of the buffer is replaced with the string +/// representation of the target +/// +template< TargetType T > +inline void toString(const Target<T>* i_target, char* i_buffer, size_t i_bsize); - /// - /// @brief Return the string interpretation of this target - /// @tparam T The type of the target - /// @param[in] i_target Target<T> - /// @param[in] i_buffer buffer to write in to - /// @param[in] i_bsize size of the buffer - /// @return void - /// @post The contents of the buffer is replaced with the string - /// representation of the target - /// - template< TargetType T > - inline void toString(const Target<T>& i_target, char* i_buffer, size_t i_bsize); - - /// - /// @brief Return the string interpretation of this target - /// @tparam T The type of the target - /// @tparam B The type of the buffer - /// @param[in] A pointer to the Target<T> - /// @param[in] i_buffer buffer to write in to - /// @param[in] i_bsize size of the buffer - /// @return void - /// @post The contents of the buffer is replaced with the string - /// representation of the target - /// - template< TargetType T > - inline void toString(const Target<T>* i_target, char* i_buffer, size_t i_bsize); - - /// - /// @brief Get an enumerated target of a specific type - /// @tparam T The type of the target - /// @param[in] Ordinal representing the ordinal number of - /// the desired target - /// @return Target<T> the target requested - /// - template<TargetType T> - inline Target<T> 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. +/// +/// @brief Get an enumerated target of a specific type +/// @tparam T The type of the target +/// @param[in] Ordinal representing the ordinal number of +/// the desired target +/// @return Target<T> the target requested +/// +template<TargetType T> +inline Target<T> 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> > a vector of present/functional - /// children - /// - template<TargetType T> - inline std::vector<Target<T> > getChildren() - { - // For testing - return {Target<T>(), Target<T>()}; - } +/// +/// @brief Get the base target's children +/// @tparam T The type of the target +/// @return std::vector<Target<T> > a vector of present/functional +/// children +/// +template<TargetType T> +inline std::vector<Target<T> > getChildren() +{ + // For testing + return {Target<T>(), Target<T>()}; +} #endif - /// - /// @brief Return the string interpretation of this target - /// @tparam T The type of the target - /// @tparam B The type of the buffer - /// @param[in] i_target Target<T> - /// @param[in] i_buffer buffer - /// @return void - /// @post The contents of the buffer is replaced with the string - /// representation of the target - /// - template<TargetType T, typename B> - inline void toString(const Target<T>& i_target, B& i_buffer); - - /// - /// @brief Check if the target is of a type, or in a type subset. - /// @tparam K the TargetType to check - /// @tparam T TargetType or TargetType composite to check against - /// @return True, iff K is a proper T - /// - template< TargetType K, TargetType T > - inline constexpr bool is_same(void) - { return (K & T) != 0; } +/// +/// @brief Return the string interpretation of this target +/// @tparam T The type of the target +/// @tparam B The type of the buffer +/// @param[in] i_target Target<T> +/// @param[in] i_buffer buffer +/// @return void +/// @post The contents of the buffer is replaced with the string +/// representation of the target +/// +template<TargetType T, typename B> +inline void toString(const Target<T>& i_target, B& i_buffer); + +/// +/// @brief Check if the target is of a type, or in a type subset. +/// @tparam K the TargetType to check +/// @tparam T TargetType or TargetType composite to check against +/// @return True, iff K is a proper T +/// +template< TargetType K, TargetType T > +inline constexpr bool is_same(void) +{ + return (K & T) != 0; +} } diff --git a/importtemp/fapi2/include/hw_access.H b/importtemp/fapi2/include/hw_access.H deleted file mode 100644 index d1c2ad28..00000000 --- a/importtemp/fapi2/include/hw_access.H +++ /dev/null @@ -1,582 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: $ */ -/* */ -/* OpenPOWER HostBoot Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2012,2014 */ -/* [+] 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 hw_access.H -/// -/// @brief Hardware access functions that needs to be specialized for -/// platform implementation. -/// - -#ifndef _FAPI2_HWACCESS_H_ -#define _FAPI2_HWACCESS_H_ - - // variable_buffer isn't supported on PPE -#ifndef __PPE__ -#include <variable_buffer.H> -#endif - -#include <plat_hw_access.H> -#include <fapi2_hw_access.H> - -namespace fapi2 -{ - //-------------------------------------------------------------------------- - // PIB Error Functions - //-------------------------------------------------------------------------- - - /// @brief Sets the PIB error mask - platform dependant - /// @param[in] i_mask The new error mask - // note: this can be moved to a C file if desired - inline void setPIBErrorMask(uint8_t i_mask) - { - // Keeps the compiler from complaining about the unused i_mask - static_cast<void>(i_mask); - - return; - } - - /// @brief Gets the PIB error mask - platform dependant - /// @return uint8_t The current PIB error mask - // note: this can be moved to a C file if desired - inline uint8_t getPIBErrorMask(void) - { - return 0; - } - - //-------------------------------------------------------------------------- - // Operational Mode Error Functions - //-------------------------------------------------------------------------- - - /// @brief Sets the operational mode - /// @param[in] i_mode The new mode - // note: this can be moved to a C file if desired - inline void setOpMode(const OpModes i_mode) - { - // Keeps the compiler from complaining about the unused i_mode - static_cast<void>(i_mode); - - // No-op for now. Should set thread-local operational mode - return; - } - - /// @brief Gets the operational mode - /// @return the operational mode - // note: this can be moved to a C file if desired - inline OpModes getOpMode(void) - { - // No-op for now. Should read thread-local operational mode - return NORMAL; - } - - //------------------------------------------------------------------------------ - // HW Communication Functions to be implemented at the platform layer. - //------------------------------------------------------------------------------ - - /// - /// @brief Platform-level implementation of getScom() - /// @Tparam K template parameter, passed in target. - /// @param[in] i_target HW target to operate on. - /// @param[in] i_address SCOM register address to read from. - /// @param[out] o_date Buffer that holds data read from HW target. - /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - /// - template< TargetType K > - inline ReturnCode getScom(const Target<K>& i_target, - const uint64_t i_address, - buffer<uint64_t>& o_data) - { - o_data = 0x0000FEEDFACE0000; - std::cout << std::hex << " getScom " - << "target: {" << i_target.getType() << "," - << uint64_t(i_target) << "}; " - << "address: " << i_address << "; " - << "output data: " << uint64_t(o_data) - << std::dec << std::endl; - - return FAPI2_RC_SUCCESS; - } - - /// @brief Platform-level implementation of putScom() - /// @Tparam K template parameter, passed in target. - /// @param[in] i_target HW target to operate on. - /// @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 > - inline ReturnCode putScom(const Target<K>& i_target, - const uint64_t i_address, - const buffer<uint64_t> i_data) - { - std::cout << std::hex << " putScom " - << "target: {" << i_target.getType() << "," - << uint64_t(i_target) << "}; " - << "address: " << i_address << "; " - << "input data: " << uint64_t(i_data) - << std::dec << std::endl; - return FAPI2_RC_SUCCESS; - } - - /// @brief Platform-level implementation of putScomUnderMask() - /// @tparam K template parameter, passed in target. - /// @param[in] i_target HW target to operate on. - /// @param[in] i_address SCOM register address to write to. - /// @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 > - inline ReturnCode putScomUnderMask(const Target<K>& i_target, - const uint64_t i_address, - const buffer<uint64_t> i_data, - const buffer<uint64_t> i_mask) - { - std::cout << std::hex << " putScomUnderMask " - << "target: {" << i_target.getType() << "," - << uint64_t(i_target) << "}; " - << "address: " << i_address << "; " - << "input data: " << uint64_t(i_data) << "; " - << "input mask: " << uint64_t(i_mask) - << std::dec << std::endl; - return FAPI2_RC_SUCCESS; - } - - /// - /// @brief Platform-level implementation called by getCfamRegister() - /// Hardware procedures writers will not call this function. - /// @Tparam K template parameter, passed in target. - /// @param[in] i_target HW target to operate on. - /// @param[in] i_address CFAM address to read from. - /// @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 > - inline ReturnCode getCfamRegister(const Target<K>& i_target, - const uint32_t i_address, - buffer<uint32_t>& o_data) - { - o_data = 0xFEED0CFA; - std::cout << std::hex << " getCfamRegister " - << "target: {" << i_target.getType() << "," - << uint64_t(i_target) << "}; " - << "address: " << i_address << "; " - << "output data: " << uint32_t(o_data) - << std::dec << std::endl; - return FAPI2_RC_SUCCESS; - } - - /// - /// @brief Platform-level implementation of putCfamRegister() - /// Hardware procedures writers will not call this function. - /// @Tparam K template parameter, passed in target. - /// @param[in] i_target HW target to operate on. - /// @param[in] i_address CFAM address to write to. - /// @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 > - inline ReturnCode putCfamRegister(const Target<K>& i_target, - const uint32_t i_address, - const buffer<uint32_t> i_data) - { - std::cout << std::hex << " putCfamRegister " - << "target: {" << i_target.getType() << "," - << uint64_t(i_target) << "}; " - << "address: " << i_address << "; " - << "input data: " << uint32_t(i_data) - << std::dec << std::endl; - return FAPI2_RC_SUCCESS; - } - - - /// - /// @brief Platform-level implementation of modifyCfamRegister() - /// Hardware procedures writers will not call this function. - /// @Tparam K template parameter, passed in target. - /// @param[in] i_target HW target to operate on. - /// @param[in] i_address CFAM register address to modify. - /// @param[out] i_data 32-bit buffer that holds data to modify. - /// @param[in] i_modifyMode The modify mode (or/and/xor). - /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - /// - template< TargetType K > - inline ReturnCode modifyCfamRegister(const Target<K>& i_target, - const uint32_t i_address, - const buffer<uint32_t> i_data, - const fapi2::ChipOpModifyMode i_modifyMode) - { - std::cout << std::hex << " modifyCfamRegister " - << "target: {" << i_target.getType() << "," - << uint64_t(i_target) << "}; " - << "address: " << i_address << "; " - << "input modifying data: " << uint32_t(i_data) << "; " - << "input ChipOpModifyMode: " << i_modifyMode - << std::dec << std::endl; - return FAPI2_RC_SUCCESS; - } - - // variable_buffer isn't supported on PPE -#ifndef __PPE__ - /// - /// @brief Platform-level implementation of getRing() - /// Hardware procedures writers will not call this function. - /// @Tparam K template parameter, passed in target. - /// @param[in] i_target HW target to operate on. - /// @param[in] i_address Ring address to read from. - /// @param[out] o_data Buffer that holds ring 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 > - inline ReturnCode getRing(const Target<K>& i_target, - const scanRingId_t i_address, - variable_buffer& o_data, - const RingMode i_ringMode) - { - o_data.setBit(0); - o_data.setBit(3); - std::cout << std::hex << " getRing " - << "target: {" << i_target.getType() << "," - << uint64_t(i_target) << "}; " - << "ring address: " << i_address << "; " - << "ring mode: " << i_ringMode << "; " - << "first element of output data: " << o_data()[0] - << std::endl; - - return FAPI2_RC_SUCCESS; - } - - /// @brief Platform-level implementation of putRing() - /// Hardware procedures writers will not call this function. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target Target to operate on. - /// @param[in] i_address Ring address to write to. - /// @param[in] i_data Buffer that contains RS4 compressed ring data - /// to write into address - /// @param[in] i_ringMode Ring operation mode. - /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K > - inline ReturnCode putRing(const Target<K>& i_target, - const scanRingId_t i_address, - const variable_buffer& i_data, - const RingMode i_ringMode) - { - std::cout << std::hex << " putRing " - << "target: {" << i_target.getType() << "," - << uint64_t(i_target) << "}; " - << "address: " << i_address << "; " - << "ring mode: " << i_ringMode << "; " - << "first element of the input data: " << i_data()[0] - << std::endl; - - return FAPI2_RC_SUCCESS; - } - - /// @brief Platform-level implementation of modifyRing() - /// @tparam K template parameter, passed in target. - /// @param[in] i_target Target to operate on. - /// @param[in] i_address Ring address to modify. - /// @param[in] i_data Buffer that contains RS4 compressed ring data - /// to be modified. - /// @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 > - inline ReturnCode modifyRing(const Target<K>& i_target, - const scanRingId_t i_address, - const variable_buffer& i_data, - const ChipOpModifyMode i_modifyMode, - const RingMode i_ringMode) - { - std::cout << std::hex << " modifyRing " - << "target: {" << i_target.getType() << "," - << uint64_t(i_target) << "}; " - << "address: " << i_address << "; " - << "input ChipOpModifyMode: " << i_modifyMode << "; " - << "ring mode: " << i_ringMode << "; " - << "first element of the input data: " << i_data()[0] - << std::endl; - - return FAPI2_RC_SUCCESS; - } -#endif - -#ifdef FAPI_SUPPORT_MULTI_SCOM - /// @brief Performs a multiple SCOM operation - /// This interface performs multiple SCOM operations on a chip in the - /// order specified by the input MultiScom object. - /// See fapiMultiScom.H for details of how to populate the MultiScom - /// object with SCOM operations. - /// - /// @tparam K template parameter, passed in target. - /// @param[in] i_target Target to operate on. - /// @param[in,out] io_multiScomObj Reference to a MultiScom object, - /// pre-populated with SingleScomInfo entries - /// to perform multiple SCOMs on input target - /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - /// - /// @note This is a synchronous interface and would return after all the - /// SCOM operations are completed or on the first failed operation - /// - /// @note SCOMs will be performed in the order they were added to the - /// input MultiScom object - /// - /// @note In case of errors, the platform code is responsible to collect - /// and add all the required error info and FFDC into the error data - /// for debugging - /// - /// @note If the SCOM operations added are specific to a processor chip, - /// then the FSI Shift Engine configured in scatter-gather DMA mode - /// extension would be used to execute the SCOM operations in a - /// performance optimize mode. In this mode, the special - /// SCOM_BULK_READ_MODE and SCOM_BULK_WRITE_MODE operations are - /// supported that allow a large bulk of SCOM access (in multiple of - /// 64 bits) for targets that support auto-increment. The - /// SCOM_WRITE_UNDER_MASK operation is not supported in this mode - /// - /// @note If the SCOM operations added are specific to a memory buffer - /// chip, then the regular SCOM engine is used to execute the SCOM - /// operations. SCOM_WRITE_UNDER_MASK operation is supported in - /// this mode, but the special SCOM_BULK_READ_MODE and - /// SCOM_BULK_WRITE_MODE operations are not supported due to - /// hardware limitations. - /// - template< TargetType K > - fapi2::ReturnCode multiScom (const Target<K>& i_target, - MultiScom& io_multiScomObj) - { - } -#endif - - // -------------------------------------------------------------------------- - // NOTE: - // Implement platform Spy access functions if platform supports them. - // -------------------------------------------------------------------------- - - // variable_buffer isn't supported on PPE -#ifndef __PPE__ - /// @brief Reads a spy from a chip. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target Target to operate on. - /// @param[in] i_spyId Id of the spy whose data to be read. - /// @param[out] o_data Buffer that holds data read from HW target. - /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - /// - /// @note: The string version is only supported for cronus. - /// - /// The fapi design to support both FSP and cronus use of get and - /// put spy functions is dependant on the SPY names being expanded - /// to resemble a valid C identifier. This design places some - /// restrictions on the SPY names which can be used. - /// - /// 1. if the spy name contains a # procedure writers should replace - /// it with an __P__ for example - - /// - /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS - /// becomes - /// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS - /// - /// 2. if the spy name has a number following a "." it must have an - /// underscore prepended to the number. - /// - /// EH.TPCHIP.2KX100_ARY_CLK_EDGES_DLY - /// becomes - /// EH.TPCHIP._2KX100_ARY_CLK_EDGES_DLY - /// - /// Example SPY name: - /// The hardware procedure should call the function like: - /// - /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS - /// - /// fapi2::ReturnCode rc = fapiGetSpy( targ, - /// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS, data ); - /// - /// @note The ID is not in quotes the fapi code will handle adding - /// the quotes for the cronus environment - /// -#ifdef FAPI_SUPPORT_SPY_AS_ENUM - template< TargetType K > - inline ReturnCode getSpy(const Target<K>& i_target, - const spyId_t i_spyId, - variable_buffer& o_data) - { - static_assert(K == 0, "implement getSpy (string)"); - return ~FAPI2_RC_SUCCESS; - } -#endif -#ifdef FAPI_SUPPORT_SPY_AS_STRING - template< TargetType K > - inline ReturnCode getSpy(const Target<K>& i_target, - const char * const i_spyId, - variable_buffer& o_data) - { - static_assert(K == 0, "implement getSpy (string)"); - return ~FAPI2_RC_SUCCESS; - } -#endif - /// @brief Writes a spy on a chip. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target Target to operate on. - /// @param[in] i_spyId Id of the spy to write data to. - /// @param[out] i_data Buffer that holds data to write into spy. - /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - /// - /// @note: The string version is only supported for cronus. - /// - /// The fapi design to support both FSP and cronus use of get and - /// put spy functions is dependent on the SPY names being expanded - /// to resemble a valid C identifier. This design places some - /// restrictions on the SPY names which can be used. - /// - /// 1. if the spy name contains a # procedure writers should replace - /// is with an __P__ for example - - /// - /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS - /// becomes - /// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS - /// - /// 2. if the spy name has a number following a "." it must have an - /// underscore prepended to the number. - /// - /// EH.TPCHIP.2KX100_ARY_CLK_EDGES_DLY - /// becomes - /// EH.TPCHIP._2KX100_ARY_CLK_EDGES_DLY - /// - /// Example SPY name: - /// The hardware procedure should call the function like: - /// - /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS - /// - /// fapi2::ReturnCode rc = fapiPutSpy( targ, - /// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS, data ); - /// - /// @note The ID is not in quotes the fapi code will handle adding - /// the quotes for the cronus environment - /// -#ifdef FAPI_SUPPORT_SPY_AS_ENUM - template< TargetType K > - inline ReturnCode putSpy(const Target<K>& i_target, - const spyId_t i_spyId, - variable_buffer& i_data) - { - static_assert(K == 0, "implement putSpy (enum)"); - return ~FAPI2_RC_SUCCESS; - } -#endif -#ifdef FAPI_SUPPORT_SPY_AS_STRING - template< TargetType K > - inline ReturnCode putSpy(const Target<K>& i_target, - const char* const i_spyId, - variable_buffer& i_data) - { - static_assert(K == 0, "implement putSpy (string)"); - return ~FAPI2_RC_SUCCESS; - } -#endif - /// @brief Writes spy data into a buffer holding ring data image - /// This API is used by L2/L3 repair to put column repair data - /// into a ring buffer image. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target Target to operate on. - /// @param[in] i_spyId Id of the spy. - /// @param[in] i_data Buffer that holds spy data to write into ring - /// image. - /// @param[out] o_data Buffer that holds updated ring image. - /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - /// - /// @note: The string version is only supported for cronus. - /// - /// The fapi design to support both FSP and cronus use of get and - /// put spy functions is dependent on the SPY names being expanded - /// to resemble a valid C identifier. This design places some - /// restrictions on the SPY names which can be used. - /// - /// See fapiPutSpy for details on spy id specifics. - /// -#ifdef FAPI_SUPPORT_SPY_AS_ENUM - template< TargetType K > - inline ReturnCode putSpyImage(const Target<K>& i_target, - const spyId_t i_spyId, - const variable_buffer& i_data, - variable_buffer& o_imageData) - { - static_assert(K == 0, "implement putSpyImage (enum)"); - return ~FAPI2_RC_SUCCESS; - } -#endif -#ifdef FAPI_SUPPORT_SPY_AS_STRING - template< TargetType K > - inline ReturnCode putSpyImage(const Target<K>& i_target, - const char* const i_spyId, - const variable_buffer& i_data, - variable_buffer& o_imageData) - { - static_assert(K == 0, "implement putSpyImage (string)"); - return ~FAPI2_RC_SUCCESS; - } -#endif - /// @brief Reads spy data from a ring image buffer - /// @param[in] i_target Target to operate on - /// @param[in] i_spyId The spy's id - /// @param[out] o_data Buffer that holds data read from ring image. - /// @param[in] i_imageData Buffer that holds ring image to read data - /// from. - /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - /// - /// @note: The string version is only supported for cronus. - /// - /// The fapi design to support both FSP and cronus use of get and - /// put spy functions is dependent on the SPY names being expanded - /// to resemble a valid C identifier. This design places some - /// restrictions on the SPY names which can be used. - /// - /// See fapiPutSpy for details on spy id specifics. - /// -#ifdef FAPI_SUPPORT_SPY_AS_ENUM - template< TargetType K > - inline ReturnCode getSpyImage(const Target<K>& i_target, - const spyId_t i_spyId, - variable_buffer& o_data, - const variable_buffer& i_imageData) - { - static_assert(K == 0, "implement getSpyImage (enum)"); - return ~FAPI2_RC_SUCCESS; - } -#endif -#ifdef FAPI_SUPPORT_SPY_AS_STRING - template< TargetType K > - inline ReturnCode getSpyImage(const Target<K>& i_target, - const char * const i_spyId, - variable_buffer& o_data, - const variable_buffer& i_imageData) - { - static_assert(K == 0, "implement getSpyImage (string)"); - return ~FAPI2_RC_SUCCESS; - } -#endif - -#endif // PPE - -}; - -#endif // _FAPI2_HWACCESS_H_ diff --git a/importtemp/fapi2/include/mvpd_access.H b/importtemp/fapi2/include/mvpd_access.H index 8288d8b8..51d7cedb 100644 --- a/importtemp/fapi2/include/mvpd_access.H +++ b/importtemp/fapi2/include/mvpd_access.H @@ -29,88 +29,10 @@ #include <stdint.h> #include <return_code.H> #include <target.H> +#include <mvpd_access_defs.H> namespace fapi2 { -enum MvpdRecord -{ - MVPD_RECORD_CRP0 = 0x00, - MVPD_RECORD_CP00 = 0x01, - MVPD_RECORD_VINI = 0x02, - MVPD_RECORD_LRP0 = 0x03, - MVPD_RECORD_LRP1 = 0x04, - MVPD_RECORD_LRP2 = 0x05, - MVPD_RECORD_LRP3 = 0x06, - MVPD_RECORD_LRP4 = 0x07, - MVPD_RECORD_LRP5 = 0x08, - MVPD_RECORD_LRP6 = 0x09, - MVPD_RECORD_LRP7 = 0x0a, - MVPD_RECORD_LRP8 = 0x0b, - MVPD_RECORD_LRP9 = 0x0c, - MVPD_RECORD_LRPA = 0x0d, - MVPD_RECORD_LRPB = 0x0e, - MVPD_RECORD_LRPC = 0x0f, - MVPD_RECORD_LRPD = 0x10, - MVPD_RECORD_LRPE = 0x11, - MVPD_RECORD_LWP0 = 0x12, - MVPD_RECORD_LWP1 = 0x13, - MVPD_RECORD_LWP2 = 0x14, - MVPD_RECORD_LWP3 = 0x15, - MVPD_RECORD_LWP4 = 0x16, - MVPD_RECORD_LWP5 = 0x17, - MVPD_RECORD_LWP6 = 0x18, - MVPD_RECORD_LWP7 = 0x19, - MVPD_RECORD_LWP8 = 0x1a, - MVPD_RECORD_LWP9 = 0x1b, - MVPD_RECORD_LWPA = 0x1c, - MVPD_RECORD_LWPB = 0x1d, - MVPD_RECORD_LWPC = 0x1e, - MVPD_RECORD_LWPD = 0x1f, - MVPD_RECORD_LWPE = 0x20, - MVPD_RECORD_VWML = 0x21, - MVPD_RECORD_MER0 = 0x22, -}; - -enum MvpdKeyword -{ - MVPD_KEYWORD_VD = 0x00, - MVPD_KEYWORD_ED = 0x01, - MVPD_KEYWORD_TE = 0x02, - MVPD_KEYWORD_DD = 0x03, - MVPD_KEYWORD_PDP = 0x04, - MVPD_KEYWORD_ST = 0x05, - MVPD_KEYWORD_DN = 0x06, - MVPD_KEYWORD_PG = 0x07, - MVPD_KEYWORD_PK = 0x08, - MVPD_KEYWORD_PDR = 0x09, - MVPD_KEYWORD_PDV = 0x0a, - MVPD_KEYWORD_PDH = 0x0b, - MVPD_KEYWORD_SB = 0x0c, - MVPD_KEYWORD_DR = 0x0d, - MVPD_KEYWORD_VZ = 0x0e, - MVPD_KEYWORD_CC = 0x0f, - MVPD_KEYWORD_CE = 0x10, - MVPD_KEYWORD_FN = 0x11, - MVPD_KEYWORD_PN = 0x12, - MVPD_KEYWORD_SN = 0x13, - MVPD_KEYWORD_PR = 0x14, - MVPD_KEYWORD_HE = 0x15, - MVPD_KEYWORD_CT = 0x16, - MVPD_KEYWORD_HW = 0x17, - MVPD_KEYWORD_PDM = 0x18, - MVPD_KEYWORD_IN = 0x19, - MVPD_KEYWORD_PD2 = 0x1a, - MVPD_KEYWORD_PD3 = 0x1b, - MVPD_KEYWORD_OC = 0x1c, - MVPD_KEYWORD_FO = 0x1d, - MVPD_KEYWORD_PDI = 0x1e, - MVPD_KEYWORD_PDG = 0x1f, - MVPD_KEYWORD_MK = 0x20, - MVPD_KEYWORD_PB = 0x21, - MVPD_KEYWORD_CH = 0x22, - MVPD_KEYWORD_IQ = 0x23, -}; - /// /// @brief Get Module VPD field. /// @@ -132,9 +54,9 @@ enum MvpdKeyword /// ReturnCode getMvpdField(const MvpdRecord i_record, const MvpdKeyword i_keyword, - const Target<TARGET_TYPE_PROC_CHIP> &i_target, - uint8_t * const i_pBuffer, - uint32_t &io_fieldSize); + const Target<TARGET_TYPE_PROC_CHIP>& i_target, + uint8_t* const i_pBuffer, + uint32_t& io_fieldSize); /// /// @brief Set Module VPD field. @@ -151,8 +73,8 @@ ReturnCode getMvpdField(const MvpdRecord i_record, /// ReturnCode setMvpdField(const MvpdRecord i_record, const MvpdKeyword i_keyword, - const Target<TARGET_TYPE_PROC_CHIP> &i_target, - const uint8_t * const i_pBuffer, + const Target<TARGET_TYPE_PROC_CHIP>& i_target, + const uint8_t* const i_pBuffer, const uint32_t i_fieldSize); } diff --git a/importtemp/fapi2/include/mvpd_access_defs.H b/importtemp/fapi2/include/mvpd_access_defs.H new file mode 100644 index 00000000..0e0a5ee3 --- /dev/null +++ b/importtemp/fapi2/include/mvpd_access_defs.H @@ -0,0 +1,111 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: hwpf/fapi2/include/mvpd_access_defs.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* EKB Project */ +/* */ +/* COPYRIGHT 2015 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ +/* */ +/* IBM_PROLOG_END_TAG */ + +/// +/// @file mvpd_access_defs.H +/// +/// @brief Defines the Module VPD Records and Keywords +/// + +#ifndef _FAPI2_MVPDACCESS_DEFS_H_ +#define _FAPI2_MVPDACCESS_DEFS_H_ + +namespace fapi2 +{ +enum MvpdRecord +{ + MVPD_RECORD_CRP0 = 0x00, + MVPD_RECORD_CP00 = 0x01, + MVPD_RECORD_VINI = 0x02, + MVPD_RECORD_LRP0 = 0x03, + MVPD_RECORD_LRP1 = 0x04, + MVPD_RECORD_LRP2 = 0x05, + MVPD_RECORD_LRP3 = 0x06, + MVPD_RECORD_LRP4 = 0x07, + MVPD_RECORD_LRP5 = 0x08, + MVPD_RECORD_LRP6 = 0x09, + MVPD_RECORD_LRP7 = 0x0a, + MVPD_RECORD_LRP8 = 0x0b, + MVPD_RECORD_LRP9 = 0x0c, + MVPD_RECORD_LRPA = 0x0d, + MVPD_RECORD_LRPB = 0x0e, + MVPD_RECORD_LRPC = 0x0f, + MVPD_RECORD_LRPD = 0x10, + MVPD_RECORD_LRPE = 0x11, + MVPD_RECORD_LWP0 = 0x12, + MVPD_RECORD_LWP1 = 0x13, + MVPD_RECORD_LWP2 = 0x14, + MVPD_RECORD_LWP3 = 0x15, + MVPD_RECORD_LWP4 = 0x16, + MVPD_RECORD_LWP5 = 0x17, + MVPD_RECORD_LWP6 = 0x18, + MVPD_RECORD_LWP7 = 0x19, + MVPD_RECORD_LWP8 = 0x1a, + MVPD_RECORD_LWP9 = 0x1b, + MVPD_RECORD_LWPA = 0x1c, + MVPD_RECORD_LWPB = 0x1d, + MVPD_RECORD_LWPC = 0x1e, + MVPD_RECORD_LWPD = 0x1f, + MVPD_RECORD_LWPE = 0x20, + MVPD_RECORD_VWML = 0x21, + MVPD_RECORD_MER0 = 0x22, +}; + +enum MvpdKeyword +{ + MVPD_KEYWORD_VD = 0x00, + MVPD_KEYWORD_ED = 0x01, + MVPD_KEYWORD_TE = 0x02, + MVPD_KEYWORD_DD = 0x03, + MVPD_KEYWORD_PDP = 0x04, + MVPD_KEYWORD_ST = 0x05, + MVPD_KEYWORD_DN = 0x06, + MVPD_KEYWORD_PG = 0x07, + MVPD_KEYWORD_PK = 0x08, + MVPD_KEYWORD_PDR = 0x09, + MVPD_KEYWORD_PDV = 0x0a, + MVPD_KEYWORD_PDH = 0x0b, + MVPD_KEYWORD_SB = 0x0c, + MVPD_KEYWORD_DR = 0x0d, + MVPD_KEYWORD_VZ = 0x0e, + MVPD_KEYWORD_CC = 0x0f, + MVPD_KEYWORD_CE = 0x10, + MVPD_KEYWORD_FN = 0x11, + MVPD_KEYWORD_PN = 0x12, + MVPD_KEYWORD_SN = 0x13, + MVPD_KEYWORD_PR = 0x14, + MVPD_KEYWORD_HE = 0x15, + MVPD_KEYWORD_CT = 0x16, + MVPD_KEYWORD_HW = 0x17, + MVPD_KEYWORD_PDM = 0x18, + MVPD_KEYWORD_IN = 0x19, + MVPD_KEYWORD_PD2 = 0x1a, + MVPD_KEYWORD_PD3 = 0x1b, + MVPD_KEYWORD_OC = 0x1c, + MVPD_KEYWORD_FO = 0x1d, + MVPD_KEYWORD_PDI = 0x1e, + MVPD_KEYWORD_PDG = 0x1f, + MVPD_KEYWORD_MK = 0x20, + MVPD_KEYWORD_PB = 0x21, + MVPD_KEYWORD_CH = 0x22, + MVPD_KEYWORD_IQ = 0x23, +}; +} + +#endif diff --git a/importtemp/fapi2/include/plat/hw_access.H b/importtemp/fapi2/include/plat/hw_access.H new file mode 100644 index 00000000..d86dce17 --- /dev/null +++ b/importtemp/fapi2/include/plat/hw_access.H @@ -0,0 +1,605 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: hwpf/fapi2/include/plat/hw_access.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* EKB Project */ +/* */ +/* COPYRIGHT 2012,2015 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ +/* */ +/* IBM_PROLOG_END_TAG */ + +/// @file hw_access.H +/// +/// @brief Hardware access functions that needs to be specialized for +/// platform implementation. +/// + +#ifndef _FAPI2_HWACCESS_H_ +#define _FAPI2_HWACCESS_H_ + +// variable_buffer isn't supported on PPE +#ifndef __PPE__ + #include <variable_buffer.H> +#endif + +#include <plat_hw_access.H> +#include <fapi2_hw_access.H> + +//@TODO remove with RTC: 133089 +#ifdef TEMPORARY_FOR_INITFILE + #include <SpyInterface.H> +#endif +namespace fapi2 +{ +//-------------------------------------------------------------------------- +// PIB Error Functions +//-------------------------------------------------------------------------- + +/// @brief Sets the PIB error mask - platform dependant +/// @param[in] i_mask The new error mask +// note: this can be moved to a C file if desired +inline void setPIBErrorMask(uint8_t i_mask) +{ + // Keeps the compiler from complaining about the unused i_mask + static_cast<void>(i_mask); + + return; +} + +/// @brief Gets the PIB error mask - platform dependant +/// @return uint8_t The current PIB error mask +// note: this can be moved to a C file if desired +inline uint8_t getPIBErrorMask(void) +{ + return 0; +} + +//-------------------------------------------------------------------------- +// Operational Mode Error Functions +//-------------------------------------------------------------------------- + +/// @brief Sets the operational mode +/// @param[in] i_mode The new mode +// note: this can be moved to a C file if desired +inline void setOpMode(const OpModes i_mode) +{ + // Keeps the compiler from complaining about the unused i_mode + static_cast<void>(i_mode); + + // No-op for now. Should set thread-local operational mode + return; +} + +/// @brief Gets the operational mode +/// @return the operational mode +// note: this can be moved to a C file if desired +inline OpModes getOpMode(void) +{ + // No-op for now. Should read thread-local operational mode + return NORMAL; +} + +//------------------------------------------------------------------------------ +// HW Communication Functions to be implemented at the platform layer. +//------------------------------------------------------------------------------ + +/// +/// @brief Platform-level implementation of getScom() +/// @Tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @param[in] i_address SCOM register address to read from. +/// @param[out] o_date Buffer that holds data read from HW target. +/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +template< TargetType K > +inline ReturnCode getScom(const Target<K>& i_target, + const uint64_t i_address, + buffer<uint64_t>& o_data) +{ + o_data = 0x0000FEEDFACE0000; + std::cout << std::hex << " getScom " + << "target: {" << i_target.getType() << "," + << uint64_t(i_target) << "}; " + << "address: " << i_address << "; " + << "output data: " << uint64_t(o_data) + << std::dec << std::endl; + + return FAPI2_RC_SUCCESS; +} + +/// @brief Platform-level implementation of putScom() +/// @Tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @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 > +inline ReturnCode putScom(const Target<K>& i_target, + const uint64_t i_address, + const buffer<uint64_t> i_data) +{ + std::cout << std::hex << " putScom " + << "target: {" << i_target.getType() << "," + << uint64_t(i_target) << "}; " + << "address: " << i_address << "; " + << "input data: " << uint64_t(i_data) + << std::dec << std::endl; + return FAPI2_RC_SUCCESS; +} + +/// @brief Platform-level implementation of putScomUnderMask() +/// @tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @param[in] i_address SCOM register address to write to. +/// @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 > +inline ReturnCode putScomUnderMask(const Target<K>& i_target, + const uint64_t i_address, + const buffer<uint64_t> i_data, + const buffer<uint64_t> i_mask) +{ + std::cout << std::hex << " putScomUnderMask " + << "target: {" << i_target.getType() << "," + << uint64_t(i_target) << "}; " + << "address: " << i_address << "; " + << "input data: " << uint64_t(i_data) << "; " + << "input mask: " << uint64_t(i_mask) + << std::dec << std::endl; + return FAPI2_RC_SUCCESS; +} + +/// +/// @brief Platform-level implementation called by getCfamRegister() +/// Hardware procedures writers will not call this function. +/// @Tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @param[in] i_address CFAM address to read from. +/// @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 > +inline ReturnCode getCfamRegister(const Target<K>& i_target, + const uint32_t i_address, + buffer<uint32_t>& o_data) +{ + o_data = 0xFEED0CFA; + std::cout << std::hex << " getCfamRegister " + << "target: {" << i_target.getType() << "," + << uint64_t(i_target) << "}; " + << "address: " << i_address << "; " + << "output data: " << uint32_t(o_data) + << std::dec << std::endl; + return FAPI2_RC_SUCCESS; +} + +/// +/// @brief Platform-level implementation of putCfamRegister() +/// Hardware procedures writers will not call this function. +/// @Tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @param[in] i_address CFAM address to write to. +/// @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 > +inline ReturnCode putCfamRegister(const Target<K>& i_target, + const uint32_t i_address, + const buffer<uint32_t> i_data) +{ + std::cout << std::hex << " putCfamRegister " + << "target: {" << i_target.getType() << "," + << uint64_t(i_target) << "}; " + << "address: " << i_address << "; " + << "input data: " << uint32_t(i_data) + << std::dec << std::endl; + return FAPI2_RC_SUCCESS; +} + + +/// +/// @brief Platform-level implementation of modifyCfamRegister() +/// Hardware procedures writers will not call this function. +/// @Tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @param[in] i_address CFAM register address to modify. +/// @param[out] i_data 32-bit buffer that holds data to modify. +/// @param[in] i_modifyMode The modify mode (or/and/xor). +/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +template< TargetType K > +inline ReturnCode modifyCfamRegister(const Target<K>& i_target, + const uint32_t i_address, + const buffer<uint32_t> i_data, + const fapi2::ChipOpModifyMode i_modifyMode) +{ + std::cout << std::hex << " modifyCfamRegister " + << "target: {" << i_target.getType() << "," + << uint64_t(i_target) << "}; " + << "address: " << i_address << "; " + << "input modifying data: " << uint32_t(i_data) << "; " + << "input ChipOpModifyMode: " << i_modifyMode + << std::dec << std::endl; + return FAPI2_RC_SUCCESS; +} + +// variable_buffer isn't supported on PPE +#ifndef __PPE__ +/// +/// @brief Platform-level implementation of getRing() +/// Hardware procedures writers will not call this function. +/// @Tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @param[in] i_address Ring address to read from. +/// @param[out] o_data Buffer that holds ring 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 > +inline ReturnCode getRing(const Target<K>& i_target, + const scanRingId_t i_address, + variable_buffer& o_data, + const RingMode i_ringMode) +{ + o_data.setBit(0); + o_data.setBit(3); + std::cout << std::hex << " getRing " + << "target: {" << i_target.getType() << "," + << uint64_t(i_target) << "}; " + << "ring address: " << i_address << "; " + << "ring mode: " << i_ringMode << "; " + << "first element of output data: " << o_data()[0] + << std::endl; + + return FAPI2_RC_SUCCESS; +} + +/// @brief Platform-level implementation of putRing() +/// Hardware procedures writers will not call this function. +/// @tparam K template parameter, passed in target. +/// @param[in] i_target Target to operate on. +/// @param[in] i_address Ring address to write to. +/// @param[in] i_data Buffer that contains RS4 compressed ring data +/// to write into address +/// @param[in] i_ringMode Ring operation mode. +/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +template< TargetType K > +inline ReturnCode putRing(const Target<K>& i_target, + const scanRingId_t i_address, + const variable_buffer& i_data, + const RingMode i_ringMode) +{ + std::cout << std::hex << " putRing " + << "target: {" << i_target.getType() << "," + << uint64_t(i_target) << "}; " + << "address: " << i_address << "; " + << "ring mode: " << i_ringMode << "; " + << "first element of the input data: " << i_data()[0] + << std::endl; + + return FAPI2_RC_SUCCESS; +} + +/// @brief Platform-level implementation of modifyRing() +/// @tparam K template parameter, passed in target. +/// @param[in] i_target Target to operate on. +/// @param[in] i_address Ring address to modify. +/// @param[in] i_data Buffer that contains RS4 compressed ring data +/// to be modified. +/// @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 > +inline ReturnCode modifyRing(const Target<K>& i_target, + const scanRingId_t i_address, + const variable_buffer& i_data, + const ChipOpModifyMode i_modifyMode, + const RingMode i_ringMode) +{ + std::cout << std::hex << " modifyRing " + << "target: {" << i_target.getType() << "," + << uint64_t(i_target) << "}; " + << "address: " << i_address << "; " + << "input ChipOpModifyMode: " << i_modifyMode << "; " + << "ring mode: " << i_ringMode << "; " + << "first element of the input data: " << i_data()[0] + << std::endl; + + return FAPI2_RC_SUCCESS; +} +#endif + +#ifdef FAPI_SUPPORT_MULTI_SCOM +/// @brief Performs a multiple SCOM operation +/// This interface performs multiple SCOM operations on a chip in the +/// order specified by the input MultiScom object. +/// See fapiMultiScom.H for details of how to populate the MultiScom +/// object with SCOM operations. +/// +/// @tparam K template parameter, passed in target. +/// @param[in] i_target Target to operate on. +/// @param[in,out] io_multiScomObj Reference to a MultiScom object, +/// pre-populated with SingleScomInfo entries +/// to perform multiple SCOMs on input target +/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +/// @note This is a synchronous interface and would return after all the +/// SCOM operations are completed or on the first failed operation +/// +/// @note SCOMs will be performed in the order they were added to the +/// input MultiScom object +/// +/// @note In case of errors, the platform code is responsible to collect +/// and add all the required error info and FFDC into the error data +/// for debugging +/// +/// @note If the SCOM operations added are specific to a processor chip, +/// then the FSI Shift Engine configured in scatter-gather DMA mode +/// extension would be used to execute the SCOM operations in a +/// performance optimize mode. In this mode, the special +/// SCOM_BULK_READ_MODE and SCOM_BULK_WRITE_MODE operations are +/// supported that allow a large bulk of SCOM access (in multiple of +/// 64 bits) for targets that support auto-increment. The +/// SCOM_WRITE_UNDER_MASK operation is not supported in this mode +/// +/// @note If the SCOM operations added are specific to a memory buffer +/// chip, then the regular SCOM engine is used to execute the SCOM +/// operations. SCOM_WRITE_UNDER_MASK operation is supported in +/// this mode, but the special SCOM_BULK_READ_MODE and +/// SCOM_BULK_WRITE_MODE operations are not supported due to +/// hardware limitations. +/// +template< TargetType K > +fapi2::ReturnCode multiScom (const Target<K>& i_target, + MultiScom& io_multiScomObj) +{ +} +#endif + +// -------------------------------------------------------------------------- +// NOTE: +// Implement platform Spy access functions if platform supports them. +// -------------------------------------------------------------------------- + +// variable_buffer isn't supported on PPE +#ifndef __PPE__ +/// @brief Reads a spy from a chip. +/// @tparam K template parameter, passed in target. +/// @param[in] i_target Target to operate on. +/// @param[in] i_spyId Id of the spy whose data to be read. +/// @param[out] o_data Buffer that holds data read from HW target. +/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +/// @note: The string version is only supported for cronus. +/// +/// The fapi design to support both FSP and cronus use of get and +/// put spy functions is dependant on the SPY names being expanded +/// to resemble a valid C identifier. This design places some +/// restrictions on the SPY names which can be used. +/// +/// 1. if the spy name contains a # procedure writers should replace +/// it with an __P__ for example - +/// +/// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS +/// becomes +/// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS +/// +/// 2. if the spy name has a number following a "." it must have an +/// underscore prepended to the number. +/// +/// EH.TPCHIP.2KX100_ARY_CLK_EDGES_DLY +/// becomes +/// EH.TPCHIP._2KX100_ARY_CLK_EDGES_DLY +/// +/// Example SPY name: +/// The hardware procedure should call the function like: +/// +/// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS +/// +/// fapi2::ReturnCode rc = fapiGetSpy( targ, +/// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS, data ); +/// +/// @note The ID is not in quotes the fapi code will handle adding +/// the quotes for the cronus environment +/// +#ifdef FAPI_SUPPORT_SPY_AS_ENUM +template< TargetType K > +inline ReturnCode getSpy(const Target<K>& i_target, + const spyId_t i_spyId, + variable_buffer& o_data) +{ + static_assert(K == 0, "implement getSpy (enum)"); + return ~FAPI2_RC_SUCCESS; +} +#endif +#ifdef FAPI_SUPPORT_SPY_AS_STRING +template< TargetType K > +inline ReturnCode getSpy(const Target<K>& i_target, + const char* const i_spyId, + variable_buffer& o_data) +{ + static_assert(K == 0, "implement getSpy (string)"); + return ~FAPI2_RC_SUCCESS; +} +#endif +/// @brief Writes a spy on a chip. +/// @tparam K template parameter, passed in target. +/// @param[in] i_target Target to operate on. +/// @param[in] i_spyId Id of the spy to write data to. +/// @param[out] i_data Buffer that holds data to write into spy. +/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +/// @note: The string version is only supported for cronus. +/// +/// The fapi design to support both FSP and cronus use of get and +/// put spy functions is dependent on the SPY names being expanded +/// to resemble a valid C identifier. This design places some +/// restrictions on the SPY names which can be used. +/// +/// 1. if the spy name contains a # procedure writers should replace +/// is with an __P__ for example - +/// +/// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS +/// becomes +/// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS +/// +/// 2. if the spy name has a number following a "." it must have an +/// underscore prepended to the number. +/// +/// EH.TPCHIP.2KX100_ARY_CLK_EDGES_DLY +/// becomes +/// EH.TPCHIP._2KX100_ARY_CLK_EDGES_DLY +/// +/// Example SPY name: +/// The hardware procedure should call the function like: +/// +/// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS +/// +/// fapi2::ReturnCode rc = fapiPutSpy( targ, +/// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS, data ); +/// +/// @note The ID is not in quotes the fapi code will handle adding +/// the quotes for the cronus environment +/// +#ifdef FAPI_SUPPORT_SPY_AS_ENUM +template< TargetType K > +inline ReturnCode putSpy(const Target<K>& i_target, + const spyId_t i_spyId, + const variable_buffer& i_data) +{ + static_assert(K == 0, "implement putSpy (enum)"); + return ~FAPI2_RC_SUCCESS; +} +#endif +#ifdef FAPI_SUPPORT_SPY_AS_STRING +template< TargetType K > +inline ReturnCode putSpy(const Target<K>& i_target, + const char* const i_spyId, + const variable_buffer& i_data) +{ +//@TODO remove with RTC: 133089 +#ifdef TEMPORARY_FOR_INITFILE + uint32_t l_chipId = strtol(getenv("CHIPID"), NULL, 16); + uint32_t l_chipEc = strtol(getenv("CHIPEC"), NULL, 16); + + return (SPY::PutSpy(l_chipId, l_chipEc, i_spyId, i_data )); +#else + static_assert(K == 0, "implement putSpy (string)"); + return ~FAPI2_RC_SUCCESS; +#endif +} + +template< TargetType K > +inline ReturnCode putSpy(const Target<K>& i_target, + const char* const i_spyId, + const char* i_enum) +{ +//@TODO remove with RTC: 133089 +#ifdef TEMPORARY_FOR_INITFILE + uint32_t l_chipId = strtol(getenv("CHIPID"), NULL, 16); + uint32_t l_chipEc = strtol(getenv("CHIPEC"), NULL, 16); + + return (SPY::PutSpy(l_chipId, l_chipEc, i_spyId, i_enum )); +#else + static_assert(K == 0, "implement putSpy (string)"); + return ~FAPI2_RC_SUCCESS; +#endif +} +#endif +/// @brief Writes spy data into a buffer holding ring data image +/// This API is used by L2/L3 repair to put column repair data +/// into a ring buffer image. +/// @tparam K template parameter, passed in target. +/// @param[in] i_target Target to operate on. +/// @param[in] i_spyId Id of the spy. +/// @param[in] i_data Buffer that holds spy data to write into ring +/// image. +/// @param[out] o_data Buffer that holds updated ring image. +/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +/// @note: The string version is only supported for cronus. +/// +/// The fapi design to support both FSP and cronus use of get and +/// put spy functions is dependent on the SPY names being expanded +/// to resemble a valid C identifier. This design places some +/// restrictions on the SPY names which can be used. +/// +/// See fapiPutSpy for details on spy id specifics. +/// +#ifdef FAPI_SUPPORT_SPY_AS_ENUM +template< TargetType K > +inline ReturnCode putSpyImage(const Target<K>& i_target, + const spyId_t i_spyId, + const variable_buffer& i_data, + variable_buffer& o_imageData) +{ + static_assert(K == 0, "implement putSpyImage (enum)"); + return ~FAPI2_RC_SUCCESS; +} +#endif +#ifdef FAPI_SUPPORT_SPY_AS_STRING +template< TargetType K > +inline ReturnCode putSpyImage(const Target<K>& i_target, + const char* const i_spyId, + const variable_buffer& i_data, + variable_buffer& o_imageData) +{ + static_assert(K == 0, "implement putSpyImage (string)"); + return ~FAPI2_RC_SUCCESS; +} +#endif +/// @brief Reads spy data from a ring image buffer +/// @param[in] i_target Target to operate on +/// @param[in] i_spyId The spy's id +/// @param[out] o_data Buffer that holds data read from ring image. +/// @param[in] i_imageData Buffer that holds ring image to read data +/// from. +/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +/// @note: The string version is only supported for cronus. +/// +/// The fapi design to support both FSP and cronus use of get and +/// put spy functions is dependent on the SPY names being expanded +/// to resemble a valid C identifier. This design places some +/// restrictions on the SPY names which can be used. +/// +/// See fapiPutSpy for details on spy id specifics. +/// +#ifdef FAPI_SUPPORT_SPY_AS_ENUM +template< TargetType K > +inline ReturnCode getSpyImage(const Target<K>& i_target, + const spyId_t i_spyId, + variable_buffer& o_data, + const variable_buffer& i_imageData) +{ + static_assert(K == 0, "implement getSpyImage (enum)"); + return ~FAPI2_RC_SUCCESS; +} +#endif +#ifdef FAPI_SUPPORT_SPY_AS_STRING +template< TargetType K > +inline ReturnCode getSpyImage(const Target<K>& i_target, + const char* const i_spyId, + variable_buffer& o_data, + const variable_buffer& i_imageData) +{ + static_assert(K == 0, "implement getSpyImage (string)"); + return ~FAPI2_RC_SUCCESS; +} +#endif + +#endif // PPE + +}; + +#endif // _FAPI2_HWACCESS_H_ diff --git a/importtemp/fapi2/include/plat_error_scope.H b/importtemp/fapi2/include/plat/plat_error_scope.H index ff4421dd..d2b22fbc 100644 --- a/importtemp/fapi2/include/plat_error_scope.H +++ b/importtemp/fapi2/include/plat/plat_error_scope.H @@ -1,25 +1,19 @@ /* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ -/* $Source: $ */ +/* $Source: hwpf/fapi2/include/plat/plat_error_scope.H $ */ /* */ -/* OpenPOWER HostBoot Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2012,2014 */ -/* [+] International Business Machines Corp. */ +/* IBM CONFIDENTIAL */ /* */ +/* EKB Project */ /* */ -/* 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 */ +/* COPYRIGHT 2012,2015 */ +/* [+] International Business Machines Corp. */ /* */ -/* 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. */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ /* */ /* IBM_PROLOG_END_TAG */ /** diff --git a/importtemp/fapi2/include/plat_hw_access.H b/importtemp/fapi2/include/plat/plat_hw_access.H index 208ed759..9a9ad5e4 100644 --- a/importtemp/fapi2/include/plat_hw_access.H +++ b/importtemp/fapi2/include/plat/plat_hw_access.H @@ -1,25 +1,19 @@ /* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ -/* $Source: $ */ +/* $Source: hwpf/fapi2/include/plat/plat_hw_access.H $ */ /* */ -/* OpenPOWER HostBoot Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2012,2014 */ -/* [+] International Business Machines Corp. */ +/* IBM CONFIDENTIAL */ /* */ +/* EKB Project */ /* */ -/* 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 */ +/* COPYRIGHT 2012,2015 */ +/* [+] International Business Machines Corp. */ /* */ -/* 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. */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ /* */ /* IBM_PROLOG_END_TAG */ diff --git a/importtemp/fapi2/include/plat/plat_target.H b/importtemp/fapi2/include/plat/plat_target.H new file mode 100644 index 00000000..3e28c1da --- /dev/null +++ b/importtemp/fapi2/include/plat/plat_target.H @@ -0,0 +1,39 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: hwpf/fapi2/include/plat_target.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* EKB Project */ +/* */ +/* COPYRIGHT 2012,2015 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ +/* */ +/* IBM_PROLOG_END_TAG */ +/** + * @file plat_target.H + * @brief platform definitions for fapi2 targets + */ + +#ifndef __FAPI2_PLAT_TARGET__ +#define __FAPI2_PLAT_TARGET__ + +#include <stdint.h> + +// +// Define what a platform handle looks like. For Hostboot, +// for example, this might be a void*. For the SBE, this +// will be a uint64_t ... +// +namespace fapi2 +{ +typedef uint64_t plat_target_handle_t; +} + +#endif diff --git a/importtemp/fapi2/include/plat_trace.H b/importtemp/fapi2/include/plat/plat_trace.H index 9104e767..c7e1b693 100644 --- a/importtemp/fapi2/include/plat_trace.H +++ b/importtemp/fapi2/include/plat/plat_trace.H @@ -1,25 +1,19 @@ /* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ -/* $Source: $ */ +/* $Source: hwpf/fapi2/include/plat/plat_trace.H $ */ /* */ -/* OpenPOWER HostBoot Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2011,2015 */ -/* [+] International Business Machines Corp. */ +/* IBM CONFIDENTIAL */ /* */ +/* EKB Project */ /* */ -/* 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 */ +/* COPYRIGHT 2011,2015 */ +/* [+] International Business Machines Corp. */ /* */ -/* 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. */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ /* */ /* IBM_PROLOG_END_TAG */ /** @@ -42,7 +36,7 @@ // To prevent problems with Cronus and the fapi1 definitions. namespace fapi2 { - static const uint32_t MAX_ECMD_STRING_LEN = 64; +static const uint32_t MAX_ECMD_STRING_LEN = 64; }; // Information traces (go into fast trace buffer that can wrap often) diff --git a/importtemp/fapi2/include/plat/target.H b/importtemp/fapi2/include/plat/target.H new file mode 100644 index 00000000..a7275224 --- /dev/null +++ b/importtemp/fapi2/include/plat/target.H @@ -0,0 +1,172 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: hwpf/fapi2/include/plat/target.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* EKB Project */ +/* */ +/* COPYRIGHT 2012,2015 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ +/* */ +/* IBM_PROLOG_END_TAG */ +/** + * @file target.H + * @brief platform specializations for fapi2 targets + */ + +#ifndef __FAPI2_TARGET__ +#define __FAPI2_TARGET__ + +#include <plat_target.H> +#include <fapi2_target.H> +#include <stdio.h> + +namespace fapi2 +{ + +/// +/// @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) +{ + iv_handle = i_right.iv_handle; + return *this; +} + +/// +/// @brief Equality Comparison Operator +/// @param[in] i_right Reference to Target to compare. +/// @return bool. True if equal. +/// @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 +{ + return i_right.iv_handle == iv_handle; +} + +/// +/// @brief Inquality Comparison Operator +/// @param[in] i_right Reference to Target to compare. +/// @return bool. True if not equal. +/// @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 +{ + return i_right.iv_handle != iv_handle; +} + +/// +/// @brief Get this target's immediate parent +/// @tparam T The type of the parent +/// @return Target<T> a target representing the parent +/// +template<TargetType K, typename V> +template<TargetType T> +inline Target<T> Target<K, V>::getParent(void) const +{ + // For testing + return Target<T>(iv_handle); +} + +/// +/// @brief Get this target's children +/// @tparam T The type of the parent +/// @param[in] i_state The desired TargetState of the children +/// @return std::vector<Target<T> > a vector of present/functional +/// children +/// @warning The children of EX's (cores) are expected to be returned +/// in order. That is, core 0 is std::vector[0]. +/// +template<TargetType K, typename V> +template< TargetType T> +inline std::vector<Target<T> > +Target<K, 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>(), Target<T>()}; +} + +/// +/// @brief Get the target at the other end of a bus - dimm included +/// @tparam T The type of the parent +/// @param[in] i_state The desired TargetState of the children +/// @return Target<T> a target representing the thing on the other end +/// @note Can be easily changed to a vector if needed +/// +template<TargetType K, typename V> +template<TargetType T> +inline Target<T> +Target<K, V>::getOtherEnd(const TargetState i_state) const +{ + // Implementation note: cast to a composite of + // bus types and the compiler will check if this is + // a good function at compile time + return Target<T>(); +} + + +/// +/// @brief Return the string interpretation of this target +/// @tparam T The type of the target +/// @param[in] i_target Target<T> +/// @param[in] i_buffer buffer to write in to +/// @param[in] i_bsize size of the buffer +/// @return void +/// @post The contents of the buffer is replaced with the string +/// representation of the target +/// +template< TargetType T > +inline void toString(const Target<T>& i_target, char* i_buffer, size_t i_bsize) +{ + snprintf(i_buffer, i_bsize, "Target 0x%lx/0x%x", i_target.get(), T); +} + +/// +/// @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<T> +/// @param[in] i_buffer buffer to write in to +/// @param[in] i_bsize size of the buffer +/// @return void +/// @post The contents of the buffer is replaced with the string +/// representation of the target +/// +template< TargetType T > +inline void toString(const Target<T>* i_target, char* i_buffer, size_t i_bsize) +{ + snprintf(i_buffer, i_bsize, "Target 0x%lx/0x%x", i_target->get(), T); +} + +/// +/// @brief Get an enumerated target of a specific type +/// @tparam T The type of the target +/// @param[in] Ordinal representing the ordinal number of +/// the desired target +/// @return Target<T> the target requested +/// +template<TargetType T> +inline Target<T> getTarget(uint64_t Ordinal) +{ + // For testing + return Target<T>(Ordinal); +} +} + +#endif diff --git a/importtemp/fapi2/include/target.H b/importtemp/fapi2/include/target.H deleted file mode 100644 index 1cd14451..00000000 --- a/importtemp/fapi2/include/target.H +++ /dev/null @@ -1,171 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: $ */ -/* */ -/* OpenPOWER HostBoot Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2012,2014 */ -/* [+] 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 target.H - * @brief platform specializations for fapi2 targets - */ - -#ifndef __FAPI2_TARGET__ -#define __FAPI2_TARGET__ - -#include <plat_target.H> -#include <fapi2_target.H> -#include <stdio.h> - -namespace fapi2 -{ - - /// - /// @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) - { iv_handle = i_right.iv_handle; return *this; } - - /// - /// @brief Equality Comparison Operator - /// @param[in] i_right Reference to Target to compare. - /// @return bool. True if equal. - /// @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 - { return i_right.iv_handle == iv_handle; } - - /// - /// @brief Inquality Comparison Operator - /// @param[in] i_right Reference to Target to compare. - /// @return bool. True if not equal. - /// @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 - { return i_right.iv_handle != iv_handle; } - - /// - /// @brief Get this target's immediate parent - /// @tparam T The type of the parent - /// @return Target<T> a target representing the parent - /// - template<TargetType K, typename V> - template<TargetType T> - inline Target<T> Target<K, V>::getParent(void) const - { - // For testing - return Target<T>(iv_handle); - } - - /// - /// @brief Get this target's children - /// @tparam T The type of the parent - /// @param[in] i_state The desired TargetState of the children - /// @return std::vector<Target<T> > a vector of present/functional - /// children - /// @warning The children of EX's (cores) are expected to be returned - /// in order. That is, core 0 is std::vector[0]. - /// - template<TargetType K, typename V> - template< TargetType T> - inline std::vector<Target<T> > - Target<K, 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>(), Target<T>()}; - } - - /// - /// @brief Get the target at the other end of a bus - dimm included - /// @tparam T The type of the parent - /// @param[in] i_state The desired TargetState of the children - /// @return Target<T> a target representing the thing on the other end - /// @note Can be easily changed to a vector if needed - /// - template<TargetType K, typename V> - template<TargetType T> - inline Target<T> - Target<K, V>::getOtherEnd(const TargetState i_state) const - { - // Implementation note: cast to a composite of - // bus types and the compiler will check if this is - // a good function at compile time - return Target<T>(); - } - - - /// - /// @brief Return the string interpretation of this target - /// @tparam T The type of the target - /// @param[in] i_target Target<T> - /// @param[in] i_buffer buffer to write in to - /// @param[in] i_bsize size of the buffer - /// @return void - /// @post The contents of the buffer is replaced with the string - /// representation of the target - /// - template< TargetType T > - inline void toString(const Target<T>& i_target, char* i_buffer, size_t i_bsize) - { - snprintf(i_buffer, i_bsize, "Target 0x%lx/0x%x", i_target.get(), T); - } - - /// - /// @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<T> - /// @param[in] i_buffer buffer to write in to - /// @param[in] i_bsize size of the buffer - /// @return void - /// @post The contents of the buffer is replaced with the string - /// representation of the target - /// - template< TargetType T > - inline void toString(const Target<T>* i_target, char* i_buffer, size_t i_bsize) - { - snprintf(i_buffer, i_bsize, "Target 0x%lx/0x%x", i_target->get(), T); - } - - /// - /// @brief Get an enumerated target of a specific type - /// @tparam T The type of the target - /// @param[in] Ordinal representing the ordinal number of - /// the desired target - /// @return Target<T> the target requested - /// - template<TargetType T> - inline Target<T> getTarget(uint64_t Ordinal) - { - // For testing - return Target<T>(Ordinal); - } -} - -#endif diff --git a/importtemp/fapi2/include/target_types.H b/importtemp/fapi2/include/target_types.H index 7fd959f5..d75d5e45 100644 --- a/importtemp/fapi2/include/target_types.H +++ b/importtemp/fapi2/include/target_types.H @@ -1,3 +1,21 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: hwpf/fapi2/include/target_types.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* EKB Project */ +/* */ +/* COPYRIGHT 2015 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ +/* */ +/* IBM_PROLOG_END_TAG */ /** * @file target_types.H * @brief definitions for fapi2 target types @@ -5,77 +23,79 @@ #ifndef __FAPI2_TARGET_TYPES__ #define __FAPI2_TARGET_TYPES__ - +#include <stdint.h> /// FAPI namespace namespace fapi2 { - /// - /// @enum fapi::TargetType - /// @brief Types, kinds, of targets - /// @note TYPE_NONE is used to represent empty/NULL targets in lists - /// or tables. TYPE_ALL is used to pass targets to methods which - /// can act generally on any type of target - /// +/// +/// @enum fapi::TargetType +/// @brief Types, kinds, of targets +/// @note TYPE_NONE is used to represent empty/NULL targets in lists +/// or tables. TYPE_ALL is used to pass targets to methods which +/// can act generally on any type of target +/// - /// Target Kind - enum TargetType - { - TARGET_TYPE_NONE = 0x00000000, ///< No type - TARGET_TYPE_SYSTEM = 0x00000001, ///< System type - TARGET_TYPE_DIMM = 0x00000002, ///< DIMM type - TARGET_TYPE_PROC_CHIP = 0x00000004, ///< Processor type - TARGET_TYPE_MEMBUF_CHIP = 0x00000008, ///< Membuf type - TARGET_TYPE_EX = 0x00000010, ///< EX - 2x Core, L2, L3 - can be deconfigured - TARGET_TYPE_MBA = 0x00000020, ///< MBA type - TARGET_TYPE_MCS = 0x00000040, ///< MCS type - TARGET_TYPE_XBUS = 0x00000080, ///< XBUS type - TARGET_TYPE_ABUS = 0x00000100, ///< ABUS type - TARGET_TYPE_L4 = 0x00000200, ///< L4 type - TARGET_TYPE_CORE = 0x00000400, ///< Core - 4x threads(?) - can be deconfigured - TARGET_TYPE_EQ = 0x00000800, ///< EQ - 4x core, 2x L2, 2x L3 - can be deconfigured - TARGET_TYPE_MCA = 0x00001000, ///< MCA type - TARGET_TYPE_MCBIST = 0x00002000, ///< MCBIST type - TARGET_TYPE_MI = 0x00004000, ///< MI Memory Interface (Cumulus) - TARGET_TYPE_CAPP = 0x00008000, ///< CAPP target - TARGET_TYPE_DMI = 0x00010000, ///< DMI type - TARGET_TYPE_OBUS = 0x00020000, ///< OBUS type - TARGET_TYPE_NV = 0x00040000, ///< NV bus type - TARGET_TYPE_SBE = 0x00080000, ///< SBE type - TARGET_TYPE_PPE = 0x00100000, ///< PPE type - TARGET_TYPE_PERV = 0x00200000, ///< Pervasive type - TARGET_TYPE_PEC = 0x00400000, ///< PEC type - TARGET_TYPE_PHB = 0x00800000, ///< PHB type +/// Target Kind +enum TargetType +{ + TARGET_TYPE_NONE = 0x00000000, ///< No type + TARGET_TYPE_SYSTEM = 0x00000001, ///< System type + TARGET_TYPE_DIMM = 0x00000002, ///< DIMM type + TARGET_TYPE_PROC_CHIP = 0x00000004, ///< Processor type + TARGET_TYPE_MEMBUF_CHIP = 0x00000008, ///< Membuf type + TARGET_TYPE_EX = 0x00000010, ///< EX - 2x Core, L2, L3 - can be deconfigured + TARGET_TYPE_MBA = 0x00000020, ///< MBA type + TARGET_TYPE_MCS = 0x00000040, ///< MCS type + TARGET_TYPE_XBUS = 0x00000080, ///< XBUS type + TARGET_TYPE_ABUS = 0x00000100, ///< ABUS type + TARGET_TYPE_L4 = 0x00000200, ///< L4 type + TARGET_TYPE_CORE = 0x00000400, ///< Core - 4x threads(?) - can be deconfigured + TARGET_TYPE_EQ = 0x00000800, ///< EQ - 4x core, 2x L2, 2x L3 - can be deconfigured + TARGET_TYPE_MCA = 0x00001000, ///< MCA type + TARGET_TYPE_MCBIST = 0x00002000, ///< MCBIST type + TARGET_TYPE_MI = 0x00004000, ///< MI Memory Interface (Cumulus) + TARGET_TYPE_CAPP = 0x00008000, ///< CAPP target + TARGET_TYPE_DMI = 0x00010000, ///< DMI type + TARGET_TYPE_OBUS = 0x00020000, ///< OBUS type + TARGET_TYPE_NV = 0x00040000, ///< NV bus type + TARGET_TYPE_SBE = 0x00080000, ///< SBE type + TARGET_TYPE_PPE = 0x00100000, ///< PPE type + TARGET_TYPE_PERV = 0x00200000, ///< Pervasive type + TARGET_TYPE_PEC = 0x00400000, ///< PEC type + TARGET_TYPE_PHB = 0x00800000, ///< PHB type - TARGET_TYPE_ALL = 0xFFFFFFFF, ///< Any/All types + TARGET_TYPE_ALL = 0xFFFFFFFF, ///< Any/All types - // Mappings to target types found in the error xml files - TARGET_TYPE_EX_CHIPLET = TARGET_TYPE_EX, - TARGET_TYPE_MBA_CHIPLET = TARGET_TYPE_MBA, - TARGET_TYPE_MCS_CHIPLET = TARGET_TYPE_MCS, - TARGET_TYPE_XBUS_ENDPOINT = TARGET_TYPE_XBUS, - TARGET_TYPE_ABUS_ENDPOINT = TARGET_TYPE_ABUS, - }; + // Mappings to target types found in the error xml files + TARGET_TYPE_EX_CHIPLET = TARGET_TYPE_EX, + TARGET_TYPE_MBA_CHIPLET = TARGET_TYPE_MBA, + TARGET_TYPE_MCS_CHIPLET = TARGET_TYPE_MCS, + TARGET_TYPE_XBUS_ENDPOINT = TARGET_TYPE_XBUS, + TARGET_TYPE_ABUS_ENDPOINT = TARGET_TYPE_ABUS, +}; - /// @cond - constexpr TargetType operator|(TargetType x, TargetType y) - { - return static_cast<TargetType>(static_cast<int>(x) | - static_cast<int>(y)); - } +/// @cond +constexpr TargetType operator|(TargetType x, TargetType y) +{ + return static_cast<TargetType>(static_cast<int>(x) | + static_cast<int>(y)); +} - template<uint64_t V> - class bitCount { +template<uint64_t V> +class bitCount +{ public: // Don't use enums, too hard to compare - static const uint8_t count = bitCount<(V >> 1)>::count + (V & 1); - }; + static const uint8_t count = bitCount < (V >> 1) >::count + (V & 1); +}; - template<> - class bitCount<0> { +template<> +class bitCount<0> +{ public: static const uint8_t count = 0; - }; - /// @endcond +}; +/// @endcond } diff --git a/importtemp/fapi2/include/variable_buffer.H b/importtemp/fapi2/include/variable_buffer.H index b1739be9..f8700f66 100644 --- a/importtemp/fapi2/include/variable_buffer.H +++ b/importtemp/fapi2/include/variable_buffer.H @@ -1,25 +1,19 @@ /* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ -/* $Source: $ */ +/* $Source: hwpf/fapi2/include/variable_buffer.H $ */ /* */ -/* OpenPOWER HostBoot Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2012,2014 */ -/* [+] International Business Machines Corp. */ +/* IBM CONFIDENTIAL */ /* */ +/* EKB Project */ /* */ -/* 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 */ +/* COPYRIGHT 2012,2015 */ +/* [+] International Business Machines Corp. */ /* */ -/* 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. */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ /* */ /* IBM_PROLOG_END_TAG */ /** @@ -37,141 +31,143 @@ namespace fapi2 { - /// @brief Get a 32 bit mask quickly - // This is one of the main reasons we static_assert in the ctor's - // to ensure the unit_type is 32 bits. - inline uint32_t fast_mask32(int32_t i_pos, int32_t i_len) - { - // generates an arbitrary 32-bit mask using two operations, not too shabby - - static const uint32_t l_mask32[] = { - 0x00000000, - 0x80000000, 0xC0000000, 0xE0000000, 0xF0000000, - 0xF8000000, 0xFC000000, 0xFE000000, 0xFF000000, - 0xFF800000, 0xFFC00000, 0xFFE00000, 0xFFF00000, - 0xFFF80000, 0xFFFC0000, 0xFFFE0000, 0xFFFF0000, - 0xFFFF8000, 0xFFFFC000, 0xFFFFE000, 0xFFFFF000, - 0xFFFFF800, 0xFFFFFC00, 0xFFFFFE00, 0xFFFFFF00, - 0xFFFFFF80, 0xFFFFFFC0, 0xFFFFFFE0, 0xFFFFFFF0, - 0xFFFFFFF8, 0xFFFFFFFC, 0xFFFFFFFE, 0xFFFFFFFF, - }; - return l_mask32[i_len] >> i_pos; - } +/// @brief Get a 32 bit mask quickly +// This is one of the main reasons we static_assert in the ctor's +// to ensure the unit_type is 32 bits. +inline uint32_t fast_mask32(int32_t i_pos, int32_t i_len) +{ + // generates an arbitrary 32-bit mask using two operations, not too shabby - // - // General set a series of bits in the buffer. - // - - /// - /// @cond - /// @brief Internal bit inserting method. - /// @tparam unit_type The type of a unit of the arrays - /// @tparam bits_type The type of the bit counting values - /// @param[in] i_source The incoming data - /// @param[in] i_source_length The length in bits of the incoming data - /// @param[in] i_target The outgoing data - /// @param[in] i_target_length The length in bits of the outgoing data - /// @param[in] i_source_start_bit The starting bit location in the - /// incoming data - /// @param[in] i_target_start_bit The starting bit position in this - /// @param[in] i_length The length, in bits, the user wants copied. - /// - template<typename unit_type, typename bits_type, typename output_type> - inline fapi2::ReturnCodes _insert(const unit_type* i_source, - bits_type i_source_length, - output_type* i_target, - bits_type i_target_length, - bits_type i_source_start_bit, - bits_type i_target_start_bit, - bits_type i_length) + static const uint32_t l_mask32[] = { - const bits_type bits_per_input_unit = parameterTraits<unit_type>::bit_length(); - const bits_type bits_per_output_unit =parameterTraits<output_type>::bit_length(); + 0x00000000, + 0x80000000, 0xC0000000, 0xE0000000, 0xF0000000, + 0xF8000000, 0xFC000000, 0xFE000000, 0xFF000000, + 0xFF800000, 0xFFC00000, 0xFFE00000, 0xFFF00000, + 0xFFF80000, 0xFFFC0000, 0xFFFE0000, 0xFFFF0000, + 0xFFFF8000, 0xFFFFC000, 0xFFFFE000, 0xFFFFF000, + 0xFFFFF800, 0xFFFFFC00, 0xFFFFFE00, 0xFFFFFF00, + 0xFFFFFF80, 0xFFFFFFC0, 0xFFFFFFE0, 0xFFFFFFF0, + 0xFFFFFFF8, 0xFFFFFFFC, 0xFFFFFFFE, 0xFFFFFFFF, + }; + return l_mask32[i_len] >> i_pos; +} - // targetStart is defaulted to the sizeof(target) - (sizeof(source) - i_source_start_bit) - // which makes this act like insert from right - if (i_target_start_bit == static_cast<bits_type>(~0)) - { - i_target_start_bit = (i_target_length - (i_source_length - i_source_start_bit)); - } +// +// General set a series of bits in the buffer. +// + +/// +/// @cond +/// @brief Internal bit inserting method. +/// @tparam unit_type The type of a unit of the arrays +/// @tparam bits_type The type of the bit counting values +/// @param[in] i_source The incoming data +/// @param[in] i_source_length The length in bits of the incoming data +/// @param[in] i_target The outgoing data +/// @param[in] i_target_length The length in bits of the outgoing data +/// @param[in] i_source_start_bit The starting bit location in the +/// incoming data +/// @param[in] i_target_start_bit The starting bit position in this +/// @param[in] i_length The length, in bits, the user wants copied. +/// +template<typename unit_type, typename bits_type, typename output_type> +inline fapi2::ReturnCodes _insert(const unit_type* i_source, + bits_type i_source_length, + output_type* i_target, + bits_type i_target_length, + bits_type i_source_start_bit, + bits_type i_target_start_bit, + bits_type i_length) +{ + const bits_type bits_per_input_unit = parameterTraits<unit_type>::bit_length(); + const bits_type bits_per_output_unit = parameterTraits<output_type>::bit_length(); - // len defaults to (sizeof(OT) * 8) - i_source_start_bit - if (i_length == static_cast<bits_type>(~0)) - { - i_length = i_source_length - i_source_start_bit; - } + // targetStart is defaulted to the sizeof(target) - (sizeof(source) - i_source_start_bit) + // which makes this act like insert from right + if (i_target_start_bit == static_cast<bits_type>(~0)) + { + i_target_start_bit = (i_target_length - (i_source_length - i_source_start_bit)); + } - // Check for overflow - if ((i_length + i_target_start_bit > i_target_length) || - (i_length + i_source_start_bit > i_source_length)) - { - return fapi2::FAPI2_RC_OVERFLOW; - } + // len defaults to (sizeof(OT) * 8) - i_source_start_bit + if (i_length == static_cast<bits_type>(~0)) + { + i_length = i_source_length - i_source_start_bit; + } - do - { - const bits_type src_idx = i_source_start_bit / bits_per_input_unit; - const bits_type trg_idx = i_target_start_bit / bits_per_output_unit; + // Check for overflow + if ((i_length + i_target_start_bit > i_target_length) || + (i_length + i_source_start_bit > i_source_length)) + { + return fapi2::FAPI2_RC_OVERFLOW; + } - // "slop" = unaligned bits - const bits_type src_slop = i_source_start_bit % bits_per_input_unit; - const bits_type trg_slop = i_target_start_bit % bits_per_output_unit; + do + { + const bits_type src_idx = i_source_start_bit / bits_per_input_unit; + const bits_type trg_idx = i_target_start_bit / bits_per_output_unit; - // "cnt" = largest number of bits to be moved each pass - bits_type cnt = std::min(i_length, bits_per_input_unit); - cnt = std::min(cnt, bits_per_input_unit - src_slop); - cnt = std::min(cnt, bits_per_output_unit - trg_slop); + // "slop" = unaligned bits + const bits_type src_slop = i_source_start_bit % bits_per_input_unit; + const bits_type trg_slop = i_target_start_bit % bits_per_output_unit; - // generate the source mask only once - bits_type mask = fast_mask32(src_slop, cnt); + // "cnt" = largest number of bits to be moved each pass + bits_type cnt = std::min(i_length, bits_per_input_unit); + cnt = std::min(cnt, bits_per_input_unit - src_slop); + cnt = std::min(cnt, bits_per_output_unit - trg_slop); - // read the source bits only once - bits_type src_bits = i_source[src_idx] & mask; + // generate the source mask only once + bits_type mask = fast_mask32(src_slop, cnt); - // "shift" = amount of shifting needed for target alignment - int32_t shift = trg_slop - src_slop; + // read the source bits only once + bits_type src_bits = i_source[src_idx] & mask; - if (shift < 0) - { - src_bits <<= -shift; - mask <<= -shift; - } - else - { - src_bits >>= shift; - mask >>= shift; - } + // "shift" = amount of shifting needed for target alignment + int32_t shift = trg_slop - src_slop; - // clear source '0' bits in the target - i_target[trg_idx] &= ~mask; + if (shift < 0) + { + src_bits <<= -shift; + mask <<= -shift; + } + else + { + src_bits >>= shift; + mask >>= shift; + } - // set source '1' bits in the target - i_target[trg_idx] |= src_bits; + // clear source '0' bits in the target + i_target[trg_idx] &= ~mask; - i_source_start_bit += cnt; - i_target_start_bit += cnt; + // set source '1' bits in the target + i_target[trg_idx] |= src_bits; - i_length -= cnt; + i_source_start_bit += cnt; + i_target_start_bit += cnt; - } while (0 < i_length); + i_length -= cnt; - return fapi2::FAPI2_RC_SUCCESS; } - /// @endcond - - /// @brief Class representing a FAPI variable_buffer. - /// @remark Variable buffers are buffers which can be variable in length - /// (and "odd sized.") These best represent the FAPI 1.X ecmdDataBuffer, - /// however they are implemented using the same template techniques - /// as the new fapi::buffer. - /// @note Variable buffers are not (presently) declared as std::bitset - /// as bitsets' size is fixed at runtime. It is not clear if this is - /// acceptable for variable_buffers at this time. - /// @note Variable buffers are implemented as a std::vecor of uint32_t - /// as this keeps simple compatibility with ecmdDataBuffers. Cronus (at - //least) need to interwork the two. - class variable_buffer - { + while (0 < i_length); + + return fapi2::FAPI2_RC_SUCCESS; +} +/// @endcond + +/// @brief Class representing a FAPI variable_buffer. +/// @remark Variable buffers are buffers which can be variable in length +/// (and "odd sized.") These best represent the FAPI 1.X ecmdDataBuffer, +/// however they are implemented using the same template techniques +/// as the new fapi::buffer. +/// @note Variable buffers are not (presently) declared as std::bitset +/// as bitsets' size is fixed at runtime. It is not clear if this is +/// acceptable for variable_buffers at this time. +/// @note Variable buffers are implemented as a std::vecor of uint32_t +/// as this keeps simple compatibility with ecmdDataBuffers. Cronus (at +//least) need to interwork the two. +class variable_buffer +{ public: @@ -187,10 +183,10 @@ namespace fapi2 inline variable_buffer(bits_type i_value = 0): iv_data(_vector_size(i_value)), iv_perceived_bit_length(i_value) - { - static_assert(std::is_same<unit_type, uint32_t>::value, - "code currently needs unit_type to be a unit32_t"); - } + { + static_assert(std::is_same<unit_type, uint32_t>::value, + "code currently needs unit_type to be a unit32_t"); + } /// /// @brief Variable buffer list constructor @@ -200,31 +196,31 @@ namespace fapi2 inline variable_buffer(const std::initializer_list<unit_type>& i_value): iv_data(i_value), iv_perceived_bit_length(i_value.size() * sizeof(unit_type) * 8) - { - static_assert(std::is_same<unit_type, uint32_t>::value, - "code currently needs unit_type to be a unit32_t"); - } + { + static_assert(std::is_same<unit_type, uint32_t>::value, + "code currently needs unit_type to be a unit32_t"); + } /// /// @brief Variable buffer copy constructor /// @param[in] i_buffer the buffer to copy from /// inline variable_buffer(const variable_buffer& i_buffer) - { - iv_perceived_bit_length = i_buffer.iv_perceived_bit_length; - iv_data = i_buffer.iv_data; - } + { + iv_perceived_bit_length = i_buffer.iv_perceived_bit_length; + iv_data = i_buffer.iv_data; + } /// /// @brief Variable buffer move constructor /// @param[in] i_buffer the buffer to move /// inline variable_buffer(variable_buffer&& i_buffer) - { - iv_perceived_bit_length = i_buffer.iv_perceived_bit_length; - i_buffer.iv_perceived_bit_length = 0; - iv_data = std::move(i_buffer.iv_data); - } + { + iv_perceived_bit_length = i_buffer.iv_perceived_bit_length; + i_buffer.iv_perceived_bit_length = 0; + iv_data = std::move(i_buffer.iv_data); + } /// /// @brief Variable buffer array constructor @@ -240,44 +236,58 @@ namespace fapi2 inline variable_buffer(const uint32_t* i_value, const uint32_t i_length, const uint32_t i_bit_length): iv_perceived_bit_length(i_bit_length) - { - static_assert(std::is_same<unit_type, uint32_t>::value, - "code currently needs unit_type to be a unit32_t"); + { + static_assert(std::is_same<unit_type, uint32_t>::value, + "code currently needs unit_type to be a unit32_t"); - // Copy the array in to our vector. - iv_data.insert(iv_data.end(), i_value, &i_value[i_length]); - } + // Copy the array in to our vector. + iv_data.insert(iv_data.end(), i_value, &i_value[i_length]); + } #if !defined(DOXYGEN) && defined(FAPI2_DEBUG) /// @brief Print the contents of the buffer to stdout inline void print(void) const - { bufferTraits<bits_container>::print(iv_data); } + { + bufferTraits<bits_container>::print(iv_data); + } #endif /// /// @brief Get the contents of the buffer /// @return The contents of the buffer /// - inline operator bits_container() const { return iv_data; } + inline operator bits_container() const + { + return iv_data; + } /// /// @brief Get the contents of the buffer /// @return The contents of the buffer /// - inline operator bits_container&() { return iv_data; } + inline operator bits_container& () + { + return iv_data; + } /// /// @brief Get the contents of the buffer /// @return The contents of the buffer /// - inline bits_container& operator()(void) { return iv_data; } + inline bits_container& operator()(void) + { + return iv_data; + } /// /// @brief Get the contents of the buffer /// @return Reference to the contents of the buffer /// - inline const bits_container& operator()(void) const { return iv_data; } + inline const bits_container& operator()(void) const + { + return iv_data; + } /// @name Buffer Manipulation Functions ///@{ @@ -300,7 +310,7 @@ namespace fapi2 static const bits_type bits_in_value = parameterTraits<OT>::bit_length(); const bits_type bit_length = bufferTraits<bits_container>::bit_length(iv_data); - if ((i_offset + bits_in_value) >= iv_perceived_bit_length) + if ((i_offset + bits_in_value) > iv_perceived_bit_length) { return FAPI2_RC_OVERFLOW; } @@ -308,11 +318,13 @@ namespace fapi2 // Create mask if part of this byte is not in the valid part of the buffer, // Shift it left by the amount of unused bits, // Clear the unused bits (doesn't use fastmask as OT isn't always 32 bits) - if (((i_offset + 1) == length) && (bit_length % bits_in_value)) { + if (((i_offset + 1) == length) && (bit_length % bits_in_value)) + { i_value &= parameterTraits<OT>::mask() << ((bits_in_value * length) - bit_length); } - parameterTraits<OT>::template write_element<unit_type>(bufferTraits<bits_container>::get_address(iv_data), i_value, i_offset); + parameterTraits<OT>::template write_element<unit_type>(bufferTraits<bits_container>::get_address(iv_data), i_value, + i_offset); return FAPI2_RC_SUCCESS; } @@ -335,7 +347,9 @@ namespace fapi2 /// @return Length in bits /// inline uint32_t getBitLength(void) const - { return iv_perceived_bit_length; } + { + return iv_perceived_bit_length; + } /// /// @brief Return the length of the buffer in OT units @@ -362,24 +376,24 @@ namespace fapi2 { ReturnCodes rc; - // make sure we stay within our container + // make sure we stay within our container assert((L > 0) && ((SB + L) <= this->iv_perceived_bit_length) ); uint32_t mask = 0; // last bit to check - bits_type EB = SB + L -1; + bits_type EB = SB + L - 1; // index where first bit to check is located - bits_type start_index = SB/bits_per_unit; + bits_type start_index = SB / bits_per_unit; // index where last bit is located - bits_type end_index = EB/bits_per_unit; + bits_type end_index = EB / bits_per_unit; if( start_index == end_index ) { // normalize our SB to be within a unit - bits_type TempSB = SB - (start_index*bits_per_unit); + bits_type TempSB = SB - (start_index * bits_per_unit); // grab a mask from SB for L number of bits. mask = fast_mask32(TempSB, L); @@ -406,10 +420,10 @@ namespace fapi2 { // now check the bits in the previous index up to the next index. // normalize our SB to be within a unit - TempSB = SB - (start_index*bits_per_unit); + TempSB = SB - (start_index * bits_per_unit); // get a mask for the new SB location to the end of this unit. - mask = fast_mask32(TempSB, L-TempL); + mask = fast_mask32(TempSB, L - TempL); // merge theses bits with the others. iv_data[start_index] |= mask; @@ -430,9 +444,9 @@ namespace fapi2 /// compile time so this can be templated only. If that is not /// the case we can add a function parameter version. /// - inline fapi2::ReturnCodes clearBit(bits_type SB, bits_type L = 0) + inline fapi2::ReturnCodes clearBit(bits_type SB, bits_type L = 1) { - ReturnCodes rc = invert().setBit(SB,L); + ReturnCodes rc = invert().setBit(SB, L); invert(); @@ -465,7 +479,7 @@ namespace fapi2 { const bits_type index = B / bits_per_unit; const unit_type mask = unit_type(1) << - ((bits_per_unit - 1) - (B - (index * bits_per_unit))); + ((bits_per_unit - 1) - (B - (index * bits_per_unit))); return iv_data[index] & mask; } @@ -489,15 +503,15 @@ namespace fapi2 bits_type EB = SB + L - 1; // index where first bit to check is located - bits_type start_index = SB/bits_per_unit; + bits_type start_index = SB / bits_per_unit; // index where last bit is located - bits_type end_index = EB/bits_per_unit; + bits_type end_index = EB / bits_per_unit; if( start_index == end_index ) { // normalize our SB to be within a unit - bits_type TempSB = SB - (start_index*bits_per_unit); + bits_type TempSB = SB - (start_index * bits_per_unit); // grab a mask from SB for L number of bits. mask = fast_mask32(TempSB, L); @@ -521,10 +535,10 @@ namespace fapi2 // now check the bits in the previous index up to the next index. // normalize our SB to be within a unit - TempSB = SB - (start_index*bits_per_unit); + TempSB = SB - (start_index * bits_per_unit); // get a mask for the new SB location to the end of this unit. - mask = fast_mask32(TempSB, L-TempL); + mask = fast_mask32(TempSB, L - TempL); // test these bits against the others.. is_set &= @@ -542,11 +556,11 @@ namespace fapi2 /// test, defaults to 1 /// @return true if bit is clear - false if bit is set /// - inline bool isBitClear( bits_type SB, bits_type L =1 ) const + inline bool isBitClear( bits_type SB, bits_type L = 1 ) const { variable_buffer l_buf = *this; - return l_buf.invert().isBitSet(SB,L); + return l_buf.invert().isBitSet(SB, L); } /// @@ -570,18 +584,21 @@ namespace fapi2 /// template< uint8_t X > inline variable_buffer& flush(void) - { - static_assert( (X == 1) || (X == 0), "bad argument to flush" ); - (0 == X) ? bufferTraits<bits_container>::clear(iv_data) : bufferTraits<bits_container>::set(iv_data); - return *this; - } + { + static_assert( (X == 1) || (X == 0), "bad argument to flush" ); + (0 == X) ? bufferTraits<bits_container>::clear(iv_data) : bufferTraits<bits_container>::set(iv_data); + return *this; + } /// /// @brief Invert entire buffer /// @return variable_buffer&, Useful for method chaining /// inline variable_buffer& invert(void) - { bufferTraits<bits_container>::invert(iv_data); return *this; } + { + bufferTraits<bits_container>::invert(iv_data); + return *this; + } ///@} @@ -615,52 +632,52 @@ namespace fapi2 /// destroyed and no copy will be made (moved) /// inline variable_buffer& operator=(variable_buffer&& other) - { - iv_perceived_bit_length = other.iv_perceived_bit_length; - other.iv_perceived_bit_length = 0; - iv_data = std::move(other.iv_data); - return *this; - } + { + iv_perceived_bit_length = other.iv_perceived_bit_length; + other.iv_perceived_bit_length = 0; + iv_data = std::move(other.iv_data); + return *this; + } /// /// @brief operator=() /// inline variable_buffer& operator=(const variable_buffer& other) - { - iv_perceived_bit_length = other.iv_perceived_bit_length; - iv_data = other.iv_data; - return *this; - } + { + iv_perceived_bit_length = other.iv_perceived_bit_length; + iv_data = other.iv_data; + return *this; + } /// /// @brief operator>>() /// inline variable_buffer& operator>>(bits_type i_shiftnum) - { - // This is just a right shift from the begining of the buffer - // Why void? Well, there's no place to return the return - // code and in reality the only problem which can arise - // is the offset is out of bounds. But since we're hard-wiring it - // to 0, it can't be out of bounds. So there's no real problem - // which can arise here. - static_cast<void>(shiftRight(i_shiftnum)); - return *this; - } + { + // This is just a right shift from the begining of the buffer + // Why void? Well, there's no place to return the return + // code and in reality the only problem which can arise + // is the offset is out of bounds. But since we're hard-wiring it + // to 0, it can't be out of bounds. So there's no real problem + // which can arise here. + static_cast<void>(shiftRight(i_shiftnum)); + return *this; + } /// /// @brief operator<<() /// inline variable_buffer& operator<<(bits_type i_shiftnum) - { - // This is just a left shift from the end of the buffer - // Why void? Well, there's no place to return the return - // code and in reality the only problem which can arise - // is the offset is out of bounds. But since we're hard-wiring it - // to 0, it can't be out of bounds. So there's no real problem - // which can arise here. - static_cast<void>(shiftLeft(i_shiftnum)); - return *this; - } + { + // This is just a left shift from the end of the buffer + // Why void? Well, there's no place to return the return + // code and in reality the only problem which can arise + // is the offset is out of bounds. But since we're hard-wiring it + // to 0, it can't be out of bounds. So there's no real problem + // which can arise here. + static_cast<void>(shiftLeft(i_shiftnum)); + return *this; + } /// @@ -668,34 +685,35 @@ namespace fapi2 /// @param[in] A variable_buffer to append to this /// inline variable_buffer& operator+(const variable_buffer& rhs) - { - iv_perceived_bit_length += rhs.iv_perceived_bit_length; - iv_data.insert(iv_data.end(), rhs.iv_data.begin(), rhs.iv_data.end()); - return *this; - } + { + iv_perceived_bit_length += rhs.iv_perceived_bit_length; + iv_data.insert(iv_data.end(), rhs.iv_data.begin(), rhs.iv_data.end()); + return *this; + } /// /// @brief operator+() /// @param[in] A number of bits to add to this buffer /// inline variable_buffer& operator+(const bits_type& rhs) + { + if (rhs != 0) { - if (rhs != 0) - { - iv_perceived_bit_length += rhs; - iv_data.resize(_vector_size(iv_perceived_bit_length)); - } - return *this; + iv_perceived_bit_length += rhs; + iv_data.resize(_vector_size(iv_perceived_bit_length)); } + return *this; + } + /// /// @brief resize() /// @param[in] Desired resulting size of the buffer, in bits /// inline variable_buffer& resize(const bits_type& rhs) - { - return operator+(rhs - iv_perceived_bit_length); - } + { + return operator+(rhs - iv_perceived_bit_length); + } /// /// @brief operator+=() @@ -743,13 +761,18 @@ namespace fapi2 /// @brief Get a pointer to the buffer bits /// @return Pointer to the buffer itself /// - inline unit_type* pointer(void) { return &(iv_data[0]); } + inline unit_type* pointer(void) + { + return &(iv_data[0]); + } /// /// @brief operator!=() /// inline bool operator!=(const variable_buffer& rhs) const - { return ! operator==(rhs); } + { + return ! operator==(rhs); + } /// /// @brief operator==() @@ -763,7 +786,7 @@ namespace fapi2 } return (iv_data == rhs.iv_data) && - (iv_perceived_bit_length == rhs.iv_perceived_bit_length); + (iv_perceived_bit_length == rhs.iv_perceived_bit_length); } /// @@ -776,20 +799,20 @@ namespace fapi2 /// template<typename OT> inline fapi2::ReturnCodes insert(const OT& i_data, - bits_type i_targetStart = 0, - bits_type i_len = ~0, - bits_type i_sourceStart = 0) - { - // _insert likes 32-bit sources. So lets make our source 32 bits. - uint32_t l_source = static_cast<uint32_t>(i_data); - bits_type l_sourceStart = i_sourceStart + - parameterTraits<uint32_t>::bit_length() - - parameterTraits<OT>::bit_length(); - - return _insert(&l_source, parameterTraits<uint32_t>::bit_length(), - &(iv_data[0]), getBitLength(), - l_sourceStart, i_targetStart, i_len); - } + bits_type i_targetStart = 0, + bits_type i_len = ~0, + bits_type i_sourceStart = 0) + { + // _insert likes 32-bit sources. So lets make our source 32 bits. + uint32_t l_source = static_cast<uint32_t>(i_data); + bits_type l_sourceStart = i_sourceStart + + parameterTraits<uint32_t>::bit_length() - + parameterTraits<OT>::bit_length(); + + return _insert(&l_source, parameterTraits<uint32_t>::bit_length(), + &(iv_data[0]), getBitLength(), + l_sourceStart, i_targetStart, i_len); + } /// /// @brief Copy in a right aligned (decimal) element @@ -803,12 +826,12 @@ namespace fapi2 /// template<typename OT> inline fapi2::ReturnCodes insertFromRight(const OT& i_data, - bits_type i_targetStart = 0, - bits_type i_len = ~0) - { - return _insertFromRight(i_data, parameterTraits<OT>::bit_length(), - i_targetStart, i_len); - } + bits_type i_targetStart = 0, + bits_type i_len = ~0) + { + return _insertFromRight(i_data, parameterTraits<OT>::bit_length(), + i_targetStart, i_len); + } /// /// @brief Copy data from this buffer into an OT @@ -824,40 +847,41 @@ namespace fapi2 // Generic extract. Extract is an insert with the arguments reversed. template< typename OT > inline fapi2::ReturnCodes extract(OT& o_out, - bits_type i_start = 0, - bits_type i_len = ~0) const + bits_type i_start = 0, + bits_type i_len = ~0) const + { + // If thy didn't pass an i_len, assume they want all the data + // which will fit. + if (i_len == static_cast<bits_type>(~0)) { - // If thy didn't pass an i_len, assume they want all the data - // which will fit. - if (i_len == static_cast<bits_type>(~0)) - { - i_len = std::min(getBitLength(), - parameterTraits<OT>::bit_length()); - } + i_len = std::min(getBitLength(), + parameterTraits<OT>::bit_length()); + } - if (i_len > getBitLength()) - { - return FAPI2_RC_INVALID_PARAMETER; - } + if (i_len > getBitLength()) + { + return FAPI2_RC_INVALID_PARAMETER; + } - // _insert likes 32-bit targets. So lets make our target 32 bits. - uint32_t l_data = static_cast<uint32_t>(o_out); + // _insert likes 32-bit targets. So lets make our target 32 bits. + uint32_t l_data = static_cast<uint32_t>(o_out); - ReturnCodes rc; - if ((rc = _insert((container_unit*)&iv_data[0], getBitLength(), - &l_data, - parameterTraits<uint32_t>::bit_length(), - i_start, 0U, i_len)) != FAPI2_RC_SUCCESS) - { - return rc; - } + ReturnCodes rc; - // Shift back to the original bit width. - o_out = l_data >> (parameterTraits<uint32_t>::bit_length() - - parameterTraits<OT>::bit_length()); - return FAPI2_RC_SUCCESS; + if ((rc = _insert((container_unit*)&iv_data[0], getBitLength(), + &l_data, + parameterTraits<uint32_t>::bit_length(), + i_start, 0U, i_len)) != FAPI2_RC_SUCCESS) + { + return rc; } + // Shift back to the original bit width. + o_out = l_data >> (parameterTraits<uint32_t>::bit_length() - + parameterTraits<OT>::bit_length()); + return FAPI2_RC_SUCCESS; + } + /// /// @brief Copy data from this buffer into an OT and right justify /// @tparam OT the type of the outgoing data @@ -869,38 +893,39 @@ namespace fapi2 // Extract is an insert with the arguments reversed. template< typename OT > inline fapi2::ReturnCodes extractToRight(OT& o_out, - bits_type i_start = 0, - bits_type i_len = ~0) const + bits_type i_start = 0, + bits_type i_len = ~0) const + { + // If thy didn't pass an i_len, assume they want all the data + // which will fit. + if ((i_len == static_cast<bits_type>(~0)) || + (i_len > parameterTraits<OT>::bit_length())) { - // If thy didn't pass an i_len, assume they want all the data - // which will fit. - if ((i_len == static_cast<bits_type>(~0)) || - (i_len > parameterTraits<OT>::bit_length())) - { - i_len = std::min(getBitLength(), - parameterTraits<OT>::bit_length()); - } + i_len = std::min(getBitLength(), + parameterTraits<OT>::bit_length()); + } - // _insert likes 32-bit targets. So lets make our target 32 bits. - uint32_t l_data = static_cast<uint32_t>(o_out); - - ReturnCodes rc; - if ((rc = _insert( - reinterpret_cast<const container_unit*>(&iv_data[0]), - getBitLength(), - &l_data, - parameterTraits<uint32_t>::bit_length(), - i_start, - parameterTraits<uint32_t>::bit_length() - - i_len, i_len)) != FAPI2_RC_SUCCESS) - { - return rc; - } + // _insert likes 32-bit targets. So lets make our target 32 bits. + uint32_t l_data = static_cast<uint32_t>(o_out); - o_out = l_data; - return FAPI2_RC_SUCCESS; + ReturnCodes rc; + + if ((rc = _insert( + reinterpret_cast<const container_unit*>(&iv_data[0]), + getBitLength(), + &l_data, + parameterTraits<uint32_t>::bit_length(), + i_start, + parameterTraits<uint32_t>::bit_length() - + i_len, i_len)) != FAPI2_RC_SUCCESS) + { + return rc; } + o_out = l_data; + return FAPI2_RC_SUCCESS; + } + ///@} private: @@ -914,22 +939,22 @@ namespace fapi2 /// @return The size in units. /// inline bits_type _vector_size(const bits_type& bits_size) + { + // If we fit in one unit, we allocate one unit. + if (bits_size < parameterTraits<unit_type>::bit_length()) { - // If we fit in one unit, we allocate one unit. - if (bits_size < parameterTraits<unit_type>::bit_length()) - { - return 1; - } + return 1; + } - // Otherwise, the number of units is calculates - add one if - // we cross the unit boundary. - else - { - bits_type my_size = bits_type(bits_size / 8 / sizeof(unit_type)); - my_size += (bits_size % parameterTraits<unit_type>::bit_length() == 0) ? 0 : 1; - return my_size; - } + // Otherwise, the number of units is calculates - add one if + // we cross the unit boundary. + else + { + bits_type my_size = bits_type(bits_size / 8 / sizeof(unit_type)); + my_size += (bits_size % parameterTraits<unit_type>::bit_length() == 0) ? 0 : 1; + return my_size; } + } ///@endcond /// The contents of the buffer @@ -948,9 +973,9 @@ namespace fapi2 /// template<typename OT> inline fapi2::ReturnCodes _insertFromRight(const OT& i_data, - bits_type i_data_length, - bits_type i_targetStart, - bits_type i_len) + bits_type i_data_length, + bits_type i_targetStart, + bits_type i_len) { // If they didn't pass in a length, assume they want all the i_data // which will fit. @@ -966,233 +991,241 @@ namespace fapi2 return insert(i_data, i_targetStart, i_len, i_data_length - i_len); } - }; - - // If the source is 64-bits, treat that as 2x32 - template<> - inline fapi2::ReturnCodes variable_buffer::insert(const uint64_t& i_source, - bits_type i_targetStart, - bits_type i_len, - bits_type i_sourceStart) - { - // _insert wants 32 bit chunks, so lets turn our uint64_t into a - // uint32_t array (of 64 bits in length). Looks like a 64 bit - // variable_buffer. - uint32_t l_source[2] = - {static_cast<uint32_t>((i_source & 0xFFFFFFFF00000000) >> 32), - static_cast<uint32_t>((i_source & 0x00000000FFFFFFFF))}; - - return _insert(l_source, parameterTraits<uint64_t>::bit_length(), - &(iv_data[0]), getBitLength(), - i_sourceStart, i_targetStart, i_len); - } +}; - // Insert another variable_bufer - template<> - inline fapi2::ReturnCodes variable_buffer::insert( - const variable_buffer& i_data, +// If the source is 64-bits, treat that as 2x32 +template<> +inline fapi2::ReturnCodes variable_buffer::insert(const uint64_t& i_source, bits_type i_targetStart, bits_type i_len, bits_type i_sourceStart) +{ + // _insert wants 32 bit chunks, so lets turn our uint64_t into a + // uint32_t array (of 64 bits in length). Looks like a 64 bit + // variable_buffer. + uint32_t l_source[2] = { - return _insert(reinterpret_cast<const unit_type*>(&(i_data()[0])), - i_data.getBitLength(), - &(iv_data[0]), getBitLength(), - i_sourceStart, i_targetStart, i_len); - } + static_cast<uint32_t>((i_source & 0xFFFFFFFF00000000) >> 32), + static_cast<uint32_t>((i_source & 0x00000000FFFFFFFF)) + }; - // variable_buffer insert from right - template<> - inline fapi2::ReturnCodes variable_buffer::insertFromRight( - const variable_buffer& i_data, - bits_type i_targetStart, - bits_type i_len) + return _insert(l_source, parameterTraits<uint64_t>::bit_length(), + &(iv_data[0]), getBitLength(), + i_sourceStart, i_targetStart, i_len); +} + +// Insert another variable_bufer +template<> +inline fapi2::ReturnCodes variable_buffer::insert( + const variable_buffer& i_data, + bits_type i_targetStart, + bits_type i_len, + bits_type i_sourceStart) +{ + return _insert(reinterpret_cast<const unit_type*>(&(i_data()[0])), + i_data.getBitLength(), + &(iv_data[0]), getBitLength(), + i_sourceStart, i_targetStart, i_len); +} + +// variable_buffer insert from right +template<> +inline fapi2::ReturnCodes variable_buffer::insertFromRight( + const variable_buffer& i_data, + bits_type i_targetStart, + bits_type i_len) +{ + const bits_type bit_length_of_source = i_data.getBitLength(); + return _insertFromRight(i_data, bit_length_of_source, + i_targetStart, i_len); +} + +template<> +inline fapi2::ReturnCodes variable_buffer::extract( + uint64_t& i_data, + bits_type i_start, + bits_type i_len) const +{ + // If thy didn't pass an i_len, assume they want all the data + // which will fit. + if ((i_len == static_cast<bits_type>(~0)) || + (i_len > parameterTraits<uint64_t>::bit_length())) { - const bits_type bit_length_of_source = i_data.getBitLength(); - return _insertFromRight(i_data, bit_length_of_source, - i_targetStart, i_len); + i_len = std::min(getBitLength(), + parameterTraits<uint64_t>::bit_length()); } - template<> - inline fapi2::ReturnCodes variable_buffer::extract( - uint64_t& i_data, - bits_type i_start, - bits_type i_len) const + // _insert wants 32 bit chunks, so lets turn our uint64_t into a + // uint32_t array (of 64 bits in length). Looks like a 64 bit + // variable_buffer. + uint32_t l_data[2] = { - // If thy didn't pass an i_len, assume they want all the data - // which will fit. - if ((i_len == static_cast<bits_type>(~0)) || - (i_len > parameterTraits<uint64_t>::bit_length())) - { - i_len = std::min(getBitLength(), - parameterTraits<uint64_t>::bit_length()); - } - - // _insert wants 32 bit chunks, so lets turn our uint64_t into a - // uint32_t array (of 64 bits in length). Looks like a 64 bit - // variable_buffer. - uint32_t l_data[2] = - {static_cast<uint32_t>((i_data & 0xFFFFFFFF00000000) >> 32), - static_cast<uint32_t>((i_data & 0x00000000FFFFFFFF))}; - - ReturnCodes rc; - if ((rc = _insert((container_unit*)&iv_data[0], getBitLength(), - l_data, parameterTraits<uint64_t>::bit_length(), - i_start, 0U, i_len)) != FAPI2_RC_SUCCESS) - { - return rc; - } + static_cast<uint32_t>((i_data & 0xFFFFFFFF00000000) >> 32), + static_cast<uint32_t>((i_data & 0x00000000FFFFFFFF)) + }; - i_data = static_cast<uint64_t>(l_data[0]) << 32; - i_data |= l_data[1]; + ReturnCodes rc; - return FAPI2_RC_SUCCESS; + if ((rc = _insert((container_unit*)&iv_data[0], getBitLength(), + l_data, parameterTraits<uint64_t>::bit_length(), + i_start, 0U, i_len)) != FAPI2_RC_SUCCESS) + { + return rc; } - // Extract in to another variable_bufer - template<> - inline fapi2::ReturnCodes variable_buffer::extract( - variable_buffer& i_data, - bits_type i_start, - bits_type i_len) const - { - // If thy didn't pass an i_len, assume they want all the data - // which will fit. - if (i_len == static_cast<bits_type>(~0)) - { - i_len = i_data.getBitLength(); - } + i_data = static_cast<uint64_t>(l_data[0]) << 32; + i_data |= l_data[1]; - return _insert(reinterpret_cast<const container_unit*>( - &iv_data[0]), - getBitLength(), - &(i_data()[0]), i_data.getBitLength(), - i_start, 0U, i_len); - } + return FAPI2_RC_SUCCESS; +} - template<> - inline fapi2::ReturnCodes variable_buffer::extractToRight( - uint64_t& i_data, - bits_type i_start, - bits_type i_len) const +// Extract in to another variable_bufer +template<> +inline fapi2::ReturnCodes variable_buffer::extract( + variable_buffer& i_data, + bits_type i_start, + bits_type i_len) const +{ + // If thy didn't pass an i_len, assume they want all the data + // which will fit. + if (i_len == static_cast<bits_type>(~0)) { - // If thy didn't pass an i_len, assume they want all the data - // which will fit. - if ((i_len == static_cast<bits_type>(~0)) || - (i_len > parameterTraits<uint64_t>::bit_length())) - { - i_len = std::min(getBitLength(), - parameterTraits<uint64_t>::bit_length()); - } - - // _insert wants 32 bit chunks, so lets turn our uint64_t into a - // uint32_t array (of 64 bits in length). - uint32_t l_data[2] = - {static_cast<uint32_t>((i_data & 0xFFFFFFFF00000000) >> 32), - static_cast<uint32_t>((i_data & 0x00000000FFFFFFFF))}; - - ReturnCodes rc; - if ((rc = _insert( - reinterpret_cast<const container_unit*>(&iv_data[0]), - getBitLength(), - l_data, parameterTraits<uint64_t>::bit_length(), - i_start, - parameterTraits<uint64_t>::bit_length() - i_len, i_len)) - != FAPI2_RC_SUCCESS) - { - return rc; - } + i_len = i_data.getBitLength(); + } - i_data = static_cast<uint64_t>(l_data[0]) << 32; - i_data |= l_data[1]; + return _insert(reinterpret_cast<const container_unit*>( + &iv_data[0]), + getBitLength(), + &(i_data()[0]), i_data.getBitLength(), + i_start, 0U, i_len); +} - return FAPI2_RC_SUCCESS; +template<> +inline fapi2::ReturnCodes variable_buffer::extractToRight( + uint64_t& i_data, + bits_type i_start, + bits_type i_len) const +{ + // If thy didn't pass an i_len, assume they want all the data + // which will fit. + if ((i_len == static_cast<bits_type>(~0)) || + (i_len > parameterTraits<uint64_t>::bit_length())) + { + i_len = std::min(getBitLength(), + parameterTraits<uint64_t>::bit_length()); } - inline fapi2::ReturnCodes variable_buffer::shiftLeft( - bits_type i_shiftNum, - bits_type i_offset) + // _insert wants 32 bit chunks, so lets turn our uint64_t into a + // uint32_t array (of 64 bits in length). + uint32_t l_data[2] = { - if (i_offset == 0) - { - return FAPI2_RC_SUCCESS; - } + static_cast<uint32_t>((i_data & 0xFFFFFFFF00000000) >> 32), + static_cast<uint32_t>((i_data & 0x00000000FFFFFFFF)) + }; - if (i_offset == static_cast<bits_type>(~0)) - { - i_offset = getBitLength(); - } + ReturnCodes rc; - else if (i_offset > getBitLength()) - { - return FAPI2_RC_INVALID_PARAMETER; - } + if ((rc = _insert( + reinterpret_cast<const container_unit*>(&iv_data[0]), + getBitLength(), + l_data, parameterTraits<uint64_t>::bit_length(), + i_start, + parameterTraits<uint64_t>::bit_length() - i_len, i_len)) + != FAPI2_RC_SUCCESS) + { + return rc; + } - /* To shift the data, extact the piece being shifted and then re-insert it at the new location */ - variable_buffer shiftData(i_offset); - ReturnCodes rc; + i_data = static_cast<uint64_t>(l_data[0]) << 32; + i_data |= l_data[1]; - // Get the hunk of data - if ((rc = extract(shiftData, 0, i_offset)) != FAPI2_RC_SUCCESS) - { - return rc; - } + return FAPI2_RC_SUCCESS; +} - // Clear the hole that was opened - if ((rc = clearBit((i_offset - i_shiftNum), i_shiftNum)) != FAPI2_RC_SUCCESS) - { - return rc; - } +inline fapi2::ReturnCodes variable_buffer::shiftLeft( + bits_type i_shiftNum, + bits_type i_offset) +{ + if (i_offset == 0) + { + return FAPI2_RC_SUCCESS; + } + + if (i_offset == static_cast<bits_type>(~0)) + { + i_offset = getBitLength(); + } - // Stick the data back in - rc = insert(shiftData, 0, (shiftData.getBitLength() - i_shiftNum), i_shiftNum); + else if (i_offset > getBitLength()) + { + return FAPI2_RC_INVALID_PARAMETER; + } + /* To shift the data, extact the piece being shifted and then re-insert it at the new location */ + variable_buffer shiftData(i_offset); + ReturnCodes rc; + + // Get the hunk of data + if ((rc = extract(shiftData, 0, i_offset)) != FAPI2_RC_SUCCESS) + { return rc; } - inline fapi2::ReturnCodes variable_buffer::shiftRight( - bits_type i_shiftNum, - bits_type i_offset) + // Clear the hole that was opened + if ((rc = clearBit((i_offset - i_shiftNum), i_shiftNum)) != FAPI2_RC_SUCCESS) { - if (i_offset == getBitLength()) - { - return FAPI2_RC_SUCCESS; - } + return rc; + } - if (i_offset > getBitLength()) - { - return FAPI2_RC_INVALID_PARAMETER; - } + // Stick the data back in + rc = insert(shiftData, 0, (shiftData.getBitLength() - i_shiftNum), i_shiftNum); - /* To shift the data, extact the piece being shifted and then re-insert it at the new location */ - variable_buffer shiftData(getBitLength() - i_offset); - ReturnCodes rc; + return rc; +} - // Get the hunk of data - if ((rc = extract(shiftData, i_offset, getBitLength() - i_offset)) != FAPI2_RC_SUCCESS) - { - return rc; - } +inline fapi2::ReturnCodes variable_buffer::shiftRight( + bits_type i_shiftNum, + bits_type i_offset) +{ + if (i_offset == getBitLength()) + { + return FAPI2_RC_SUCCESS; + } - // Clear the hole that was opened - if ((rc = clearBit(i_offset, i_shiftNum)) != FAPI2_RC_SUCCESS) - { - return rc; - } + if (i_offset > getBitLength()) + { + return FAPI2_RC_INVALID_PARAMETER; + } - // Stick the data back in - rc = insert(shiftData, (i_offset + i_shiftNum), (shiftData.getBitLength() - i_shiftNum)); + /* To shift the data, extact the piece being shifted and then re-insert it at the new location */ + variable_buffer shiftData(getBitLength() - i_offset); + ReturnCodes rc; + // Get the hunk of data + if ((rc = extract(shiftData, i_offset, getBitLength() - i_offset)) != FAPI2_RC_SUCCESS) + { return rc; } - template< typename OT> - inline OT variable_buffer::get(const bits_type i_offset) + // Clear the hole that was opened + if ((rc = clearBit(i_offset, i_shiftNum)) != FAPI2_RC_SUCCESS) { - // Get is just an extract. - OT l_tmp; - extract(l_tmp, parameterTraits<OT>::bit_length() * i_offset, parameterTraits<OT>::bit_length()); - return l_tmp; + return rc; } + + // Stick the data back in + rc = insert(shiftData, (i_offset + i_shiftNum), (shiftData.getBitLength() - i_shiftNum)); + + return rc; +} + +template< typename OT> +inline OT variable_buffer::get(const bits_type i_offset) +{ + // Get is just an extract. + OT l_tmp; + extract(l_tmp, parameterTraits<OT>::bit_length() * i_offset, parameterTraits<OT>::bit_length()); + return l_tmp; +} } #endif diff --git a/importtemp/fapi2/src/array.C b/importtemp/fapi2/src/array.C new file mode 100644 index 00000000..99a57bde --- /dev/null +++ b/importtemp/fapi2/src/array.C @@ -0,0 +1,131 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2012,2014 */ +/* [+] 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 array.C + * @brief fapi2 arrays + */ + +#include <stdint.h> +#include <array.H> + +namespace fapi2 +{ + /// @brief Create an array + array::array(const uint32_t i_size, element_type* i_data): + iv_size(i_size), + iv_data(i_data) + { + assert(iv_size <= size_limit); + if (iv_data == nullptr) + { + iv_data = new element_type[iv_size](); + iv_size |= delete_bit; + } + // If the caller passed in a pointer, leave it be. Don't + // initialize it or anything. That will allow a placement + // operation where generic memory can use fapi2::array + // methods without much overhead. + } + + /// @brief Destroy an array + array::~array(void) + { + if ((iv_size & delete_bit) != 0) + { + delete[] iv_data; + } + } + + /// @brief operator[] + array::element_type& array::operator[](const uint32_t i_index) + { + assert(i_index < size()); + return iv_data[i_index]; + } + + /// @brief operator=() + array& array::operator=(const array& i_other) + { + // Check to make sure it'll fit. + assert(i_other.size() <= size()); + + // Our new size will be the other's size. + // Save of whether we should delete our iv_data ... + uint64_t l_our_delete_state = iv_size | delete_bit; + + // ... our new size is the size (minus the delete state) of i_other + iv_size = i_other.size(); + + // ... do the copy ... + memcpy(iv_data, i_other.iv_data, iv_size * sizeof(element_type)); + + // ... and record our old delete state. + iv_size |= l_our_delete_state; + + return *this; + } + + /// @brief move operator=() + array& array::operator=(array&& i_other) + { + iv_size = i_other.iv_size; + + // Make sure to clear the delete bit in the other. We + // don't want our memory to be deleted. + i_other.iv_size = i_other.size(); + + iv_data = std::move(i_other.iv_data); + return *this; + } + + /// @brief operator==() + bool array::operator==(const array& i_other) + { + // If they're not the same size, they're not the same + if (size() != i_other.size()) + { + return false; + } + + // If they're the same size and point to the same memory, they're the same. + if (iv_data == i_other.iv_data) + { + return true; + } + + auto oitr = i_other.begin(); + auto iter = begin(); + + for(; iter != end(); ++iter, ++oitr) + { + if (*iter != *oitr) + { + return false; + } + } + + return true; + } +} diff --git a/importtemp/fapi2/src/error_info.C b/importtemp/fapi2/src/error_info.C new file mode 100644 index 00000000..e533b35e --- /dev/null +++ b/importtemp/fapi2/src/error_info.C @@ -0,0 +1,394 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2011,2014 */ +/* */ +/* 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 error_info.C + * @brief Implements the error information classes + */ + +#include <stdint.h> +#include <string.h> +#include <plat_trace.H> +#include <error_info.H> +#include <buffer.H> + +namespace fapi2 +{ + /// + /// @brief Constructor + /// + /// @param[in] i_ffdcId FFDC Identifier (used to decode FFDC) + /// @param[in] i_pFfdc Pointer to the FFDC to copy + /// @param[in] i_size Size of the FFDC to copy + /// + ErrorInfoFfdc::ErrorInfoFfdc(const uint32_t i_ffdcId, + const void* i_pFfdc, + const uint32_t i_size): + iv_ffdcId(i_ffdcId), + iv_size(i_size) + { + iv_pFfdc = std::shared_ptr<uint8_t>(new uint8_t[i_size]()); + + // If they passed us a NULL pointer they want to fill + // in the data themselves later. + if (i_pFfdc != nullptr) + { + memcpy(iv_pFfdc.get(), i_pFfdc, i_size); + } + } + + /// + /// @brief Constructor. + /// + /// @param[in] i_hw Hardware to callout + /// @param[in] i_calloutPriority Priority of callout + /// @param[in] i_refTarget Reference to reference target + /// + ErrorInfoHwCallout::ErrorInfoHwCallout( + const HwCallouts::HwCallout i_hw, + const CalloutPriorities::CalloutPriority i_calloutPriority, + const Target<TARGET_TYPE_ALL> & i_refTarget): + iv_hw(i_hw), + iv_calloutPriority(i_calloutPriority), + iv_refTarget(i_refTarget) + {} + + /// + /// @brief Constructor. + /// + /// @param[in] i_procedure Procedure to callout + /// @param[in] i_calloutPriority Priority of callout + /// + ErrorInfoProcedureCallout::ErrorInfoProcedureCallout( + const ProcedureCallouts::ProcedureCallout i_procedure, + const CalloutPriorities::CalloutPriority i_calloutPriority): + iv_procedure(i_procedure), + iv_calloutPriority(i_calloutPriority) + {} + + /// + /// @brief Constructor. + /// + /// @param[in] i_target1 Reference to target on one end of the bus + /// @param[in] i_target2 Reference to target on other end of the bus + /// @param[in] i_calloutPriority Priority of callout + /// + ErrorInfoBusCallout::ErrorInfoBusCallout( + const Target<TARGET_TYPE_ALL> & i_target1, + const Target<TARGET_TYPE_ALL> & i_target2, + const CalloutPriorities::CalloutPriority i_calloutPriority): + iv_target1(i_target1), + iv_target2(i_target2), + iv_calloutPriority(i_calloutPriority) + {} + + /// + /// @brief Constructor. + /// + /// @param[in] i_target Reference to the target to c/d/g + /// @param[in] i_callout True if Target should be called out + /// @param[in] i_deconfigure True if Target should be deconfigured + /// @param[in] i_gard True if Target should be GARDed + /// @param[in] i_priority The priority of any callout + /// + ErrorInfoCDG::ErrorInfoCDG( + const Target<TARGET_TYPE_ALL> & i_target, + const bool i_callout, + const bool i_deconfigure, + const bool i_gard, + const CalloutPriorities::CalloutPriority i_priority): + iv_target(i_target), + iv_callout(i_callout), + iv_calloutPriority(i_priority), + iv_deconfigure(i_deconfigure), + iv_gard(i_gard) + {} + + /// + /// @brief Constructor. + /// + /// @param[in] i_parent Reference to the parent target + /// @oaram[in] i_childType Child target type to c/d/g + /// @param[in] i_callout True if Target should be called out + /// @param[in] i_deconfigure True if Target should be deconfigured + /// @param[in] i_gard True if Target should be GARDed + /// @param[in] i_priority The priority of any callout + /// @param[in] i_childPort Child Port + /// For DIMM children, the MBA port number + /// @param[in] i_childNum Child Number + /// For DIMM children, the dimm socket number + /// For Chip children, the chip position + /// For Chiplet children, the chiplet unit pos + /// + ErrorInfoChildrenCDG::ErrorInfoChildrenCDG( + const Target<TARGET_TYPE_ALL> & i_parentChip, + const TargetType i_childType, + const bool i_callout, + const bool i_deconfigure, + const bool i_gard, + const CalloutPriorities::CalloutPriority i_priority, + const uint8_t i_childPort, const uint8_t i_childNum): + iv_parent(i_parentChip), + iv_childType(i_childType), + iv_callout(i_callout), + iv_calloutPriority(i_priority), + iv_deconfigure(i_deconfigure), + iv_gard(i_gard), + iv_childPort(i_childPort), + iv_childNumber(i_childNum) + {} + + /// + /// @brief Constructor. + /// + /// @param[in] i_trace + /// + ErrorInfoCollectTrace::ErrorInfoCollectTrace( + CollectTraces::CollectTrace i_traceId): + iv_eiTraceId(i_traceId) + {} + + + /// + /// @brief Collect target, buffer or generic FFDC information to this ffdc + /// object + /// @param[in] A pointer to the error info we're collecting + /// @param[in] A pointer to the objects + /// @return void + /// + void ErrorInfoEntryFfdc::addErrorInfo(std::shared_ptr<ErrorInfo> i_info, + const void* const* i_objects) const + { + switch(iv_ffdcSize) + { + + case EI_FFDC_SIZE_TARGET: + { + Target<TARGET_TYPE_ALL> object = + *(static_cast<const Target<TARGET_TYPE_ALL>*> + (i_objects[iv_ffdcObjIndex])); + + // Allocate an ErrorInfoFfdc but don't copy anything in to it. + // We can copy the target string once if we copy directly into + // the error info + ErrorInfoFfdc* e = + new ErrorInfoFfdc(iv_ffdcId, nullptr, MAX_ECMD_STRING_LEN); + + toString(object, static_cast<char*>(e->getData()), + MAX_ECMD_STRING_LEN); + i_info->iv_ffdcs.push_back(std::shared_ptr<ErrorInfoFfdc>(e)); + + FAPI_DBG("addErrorInfo: Adding target ffdc id: 0x%x %s", + iv_ffdcId, static_cast<char*>(e->getData())); + } + break; + + default: + i_info->iv_ffdcs.push_back(std::shared_ptr<ErrorInfoFfdc>( + new ErrorInfoFfdc( + iv_ffdcId, + i_objects[iv_ffdcObjIndex], + iv_ffdcSize))); + FAPI_DBG("addErrorInfo: Adding ffdc id 0x%x size: %d", + iv_ffdcId, iv_ffdcSize); + break; + + }; + + return; + } + + /// + /// @brief Collect h/w callout FFDC information to this ffdc + /// object + /// @param[in] A pointer to the error info we're collecting + /// @param[in] A pointer to the objects + /// @return void + /// + void ErrorInfoEntryHwCallout::addErrorInfo(std::shared_ptr<ErrorInfo> i_info, + const void* const* i_object) const + { + // If the index is 0xFF, we use an empty target. Otherwise the + // target is taken from the object arrary with the given index. + const fapi2::Target<TARGET_TYPE_ALL> target = + iv_refObjIndex == 0xFF ? + fapi2::Target<TARGET_TYPE_ALL>() : + *(static_cast<const fapi2::Target<TARGET_TYPE_ALL>*> + (i_object[iv_refObjIndex])); + + ErrorInfoHwCallout* ei = new ErrorInfoHwCallout( + static_cast<HwCallouts::HwCallout>(iv_hw), + static_cast<CalloutPriorities::CalloutPriority>(iv_calloutPriority), + target); + + FAPI_DBG("addErrorInfo: Adding hw callout target: 0x%lx hw: %d, pri: %d", + ei->iv_refTarget.get(), ei->iv_hw, ei->iv_calloutPriority); + + i_info->iv_hwCallouts.push_back(std::shared_ptr<ErrorInfoHwCallout>(ei)); + } + + /// + /// @brief Collect proc callout FFDC information to this ffdc + /// object + /// @param[in] A pointer to the error info we're collecting + /// @param[in] A pointer to the objects + /// @return void + /// + void ErrorInfoEntryProcCallout::addErrorInfo( + std::shared_ptr<ErrorInfo> i_info, + const void* const* ) const + { + ErrorInfoProcedureCallout* ei = new ErrorInfoProcedureCallout( + static_cast<ProcedureCallouts::ProcedureCallout>(iv_procedure), + static_cast<CalloutPriorities::CalloutPriority>(iv_calloutPriority)); + + // Add the ErrorInfo + FAPI_DBG("addErrorInfo: Adding proc callout, proc: %d, pri: %d", + ei->iv_procedure, ei->iv_calloutPriority); + + i_info->iv_procedureCallouts.push_back( + std::shared_ptr<ErrorInfoProcedureCallout>(ei)); + } + + /// + /// @brief Collect bus callout FFDC information to this ffdc + /// object + /// @param[in] A pointer to the error info we're collecting + /// @param[in] A pointer to the objects + /// @return void + /// + void ErrorInfoEntryBusCallout::addErrorInfo( + std::shared_ptr<ErrorInfo> i_info, + const void* const* i_object) const + { + // We need to add a procedure callout as well as a bus callout + ErrorInfoEntryProcCallout(ProcedureCallouts::BUS_CALLOUT, + iv_calloutPriority).addErrorInfo(i_info, + i_object); + + // Now add our bus callout, but drop the priority by one. + ErrorInfoBusCallout* ei = new ErrorInfoBusCallout( + // First target + *(static_cast<const fapi2::Target<TARGET_TYPE_ALL>*> + (i_object[iv_endpoint1ObjIndex])), + + // Second target + *(static_cast<const fapi2::Target<TARGET_TYPE_ALL>*> + (i_object[iv_endpoint2ObjIndex])), + + // Priority, one lower. + (iv_calloutPriority == CalloutPriorities::HIGH) ? + CalloutPriorities::MEDIUM : CalloutPriorities::LOW); + + FAPI_DBG("addErrorInfo: Adding bus callout t1: 0x%lx t2: 0x%lx, pri: %d", + ei->iv_target1.get(), ei->iv_target2.get(), + ei->iv_calloutPriority); + + i_info->iv_busCallouts.push_back( + std::shared_ptr<ErrorInfoBusCallout>(ei)); + } + + /// + /// @brief Collect h/w target cdg FFDC information to this ffdc + /// object + /// @param[in] A pointer to the error info we're collecting + /// @param[in] A pointer to the objects + /// @return void + /// + void ErrorInfoEntryTargetCDG::addErrorInfo( + std::shared_ptr<ErrorInfo> i_info, + const void* const* i_object) const + { + ErrorInfoCDG* ei = new + ErrorInfoCDG( + *(static_cast<const fapi2::Target<TARGET_TYPE_ALL>*> + (i_object[iv_targetObjIndex])), + iv_callout, + iv_deconfigure, + iv_gard, + static_cast<CalloutPriorities::CalloutPriority> + (iv_calloutPriority) + ); + + FAPI_DBG("addErrorInfo: Adding target 0x%lx cdg (%d:%d:%d), pri: %d", + ei->iv_target.get(), + ei->iv_callout, ei->iv_deconfigure, + ei->iv_gard, ei->iv_calloutPriority); + + // Add the ErrorInfo + i_info->iv_CDGs.push_back(std::shared_ptr<ErrorInfoCDG>(ei)); + } + + /// + /// @brief Collect h/w children cdg FFDC information to this ffdc + /// object + /// @param[in] A pointer to the error info we're collecting + /// @param[in] A pointer to the objects + /// @return void + /// + void ErrorInfoEntryChildrenCDG::addErrorInfo( + std::shared_ptr<ErrorInfo> i_info, + const void* const* i_object) const + { + ErrorInfoChildrenCDG* ei = new ErrorInfoChildrenCDG( + *(static_cast<const fapi2::Target<TARGET_TYPE_ALL>*> + (i_object[iv_parentObjIndex])), + static_cast<fapi2::TargetType>(iv_childType), + iv_callout, + iv_deconfigure, + iv_gard, + static_cast<CalloutPriorities::CalloutPriority> + (iv_calloutPriority), + iv_childPort, + iv_childNumber); + + FAPI_DBG("addErrorInfo: Adding children cdg (%d:%d:%d), type:" + " 0x%08x, pri: %d", + ei->iv_callout, ei->iv_deconfigure, ei->iv_gard, + ei->iv_childType, ei->iv_calloutPriority); + + // Add the ErrorInfo + i_info->iv_childrenCDGs.push_back( + std::shared_ptr<ErrorInfoChildrenCDG>(ei)); + } + + /// + /// @brief Collect trace information to this ffdc + /// object + /// @param[in] A pointer to the error info we're collecting + /// @param[in] A pointer to the objects + /// @return void + /// + void ErrorInfoEntryCollectTrace::addErrorInfo( + std::shared_ptr<ErrorInfo> i_info, + const void* const* ) const + { + ErrorInfoCollectTrace* ei = new ErrorInfoCollectTrace( + static_cast<CollectTraces::CollectTrace>(iv_eieTraceId)); + + FAPI_DBG("addErrorInfo: Adding trace: 0x%x", ei->iv_eiTraceId); + + // Add the ErrorInfo + i_info->iv_traces.push_back(std::shared_ptr<ErrorInfoCollectTrace>(ei)); + } + +}; diff --git a/importtemp/fapi2/src/fapi2.mk b/importtemp/fapi2/src/fapi2.mk new file mode 100644 index 00000000..0cb91dfb --- /dev/null +++ b/importtemp/fapi2/src/fapi2.mk @@ -0,0 +1,59 @@ +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: hwpf/fapi2/src/fapi2.mk $ +# +# IBM CONFIDENTIAL +# +# EKB Project +# +# COPYRIGHT 2015 +# [+] International Business Machines Corp. +# +# +# The source code for this program is not published or otherwise +# divested of its trade secrets, irrespective of what has been +# deposited with the U.S. Copyright Office. +# +# IBM_PROLOG_END_TAG + +# +# Makefile to build the FAPI2 libraries. +# + + +# Add common and generated parts to object list. +FAPI2_MODULE_OBJS += array.o +FAPI2_MODULE_OBJS += error_info.o +FAPI2_MODULE_OBJS += ffdc.o +FAPI2_MODULE_OBJS += fapi2_attribute_service.o +#TODO RTC 134733: Can't find the basic XML for attributes, so +# fapi2_chip_ec_feature.C doesn't compile. +#FAPI2_MODULE_OBJS += fapi2_chip_ec_feature.o +FAPI2_MODULE_OBJS += collect_reg_ffdc.o + +# Define common source and include paths. +define FAPI2_MODULE_INCLUDES +$(call ADD_MODULE_SRCDIR,$(1),$(GENPATH)) +$(call ADD_MODULE_INCDIR,$(1),$(FAPI2_PATH)/include) +$(call ADD_MODULE_INCDIR,$(1),$(FAPI2_PLAT_INCLUDE)) +endef + +# Build real FAPI2 library that uses Cronus platform. +MODULE = fapi2 +OBJS += $(FAPI2_MODULE_OBJS) +$(eval $(call FAPI2_MODULE_INCLUDES,$(MODULE))) +lib$(MODULE)_EXTRALIBS += $(FAPI2_REQUIRED_LIBS) +lib$(MODULE)_LDFLAGS += -ldl +$(call BUILD_MODULE) + +# Build test FAPI2 library that uses the reference platform. +# To do this, we just add the extra 'plat' directories to the srcdir / incdir +# before the Cronus platform directories. +MODULE = fapi2_reference +OBJS += $(FAPI2_MODULE_OBJS) +OBJS += plat_utils.o +$(call ADD_MODULE_SRCDIR,fapi2_reference,$(FAPI2_PATH)/src/plat) +$(call ADD_MODULE_INCDIR,fapi2_reference,$(FAPI2_PATH)/include/plat) +$(eval $(call FAPI2_MODULE_INCLUDES,$(MODULE))) +$(call BUILD_MODULE) diff --git a/importtemp/fapi2/include/plat_target.H b/importtemp/fapi2/src/ffdc.C index 86c70465..efe922ea 100644 --- a/importtemp/fapi2/include/plat_target.H +++ b/importtemp/fapi2/src/ffdc.C @@ -5,9 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2014 */ -/* [+] International Business Machines Corp. */ -/* */ +/* COPYRIGHT International Business Machines Corp. 2011,2014 */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ /* you may not use this file except in compliance with the License. */ @@ -23,21 +21,37 @@ /* */ /* IBM_PROLOG_END_TAG */ /** - * @file plat_target.H - * @brief platform definitions for fapi2 targets + * @file ffdc.C + * @brief Implements the FirstFailureData class */ -#ifndef __FAPI2_PLAT_TARGET__ -#define __FAPI2_PLAT_TARGET__ +#include <plat_trace.H> +#include <ffdc.H> +#include <error_info.H> -// -// Define what a platform handle looks like. For Hostboot, -// for example, this might be a void*. For the SBE, this -// will be a uint64_t ... -// namespace fapi2 { - typedef uint64_t plat_target_handle_t; -} -#endif + /// + /// @brief Add error information to this ffdc object + /// @param[in] A pointer to a list of objects + /// @param[in] A pointer to the list of entries + /// @param[in] The count of how many entries there are + /// @return void + /// + template<> + void FirstFailureData<ReturnCode>::addErrorInfo( + const void* const* i_pObjects, + const ErrorInfoEntry* i_pEntries, + const uint8_t i_count) + { + FAPI_DBG("%d entries", i_count); + for (uint32_t i = 0; i < i_count; i++) + { + i_pEntries[i].addErrorInfo(iv_info, i_pObjects); + } + } + + + +}; diff --git a/importtemp/fapi2/src/plat/plat_utils.C b/importtemp/fapi2/src/plat/plat_utils.C new file mode 100644 index 00000000..a5061e1b --- /dev/null +++ b/importtemp/fapi2/src/plat/plat_utils.C @@ -0,0 +1,151 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: hwpf/fapi2/src/plat_utils.C $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* EKB Project */ +/* */ +/* COPYRIGHT 2011,2015 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ +/* */ +/* IBM_PROLOG_END_TAG */ +/** + * @file plat_utils.C + * @brief Implements fapi2 common utilities + */ + +#include <stdint.h> +#include <plat_trace.H> +#include <return_code.H> +#include <error_info.H> +#include <assert.h> + +namespace fapi2 +{ +/// +/// @brief Log an error. +/// +void logError( + fapi2::ReturnCode& io_rc, + fapi2::errlSeverity_t i_sev = fapi2::FAPI2_ERRL_SEV_UNRECOVERABLE, + bool i_unitTestError = false ) +{ + // To keep the compiler from complaing about i_sevbeing unused. + static_cast<void>(i_sev); + static_cast<void>(i_unitTestError); + + FAPI_DBG("logging 0x%lx.", uint64_t(io_rc)); + + // Iterate over the vectors and output what is in them. + const ErrorInfo* ei = io_rc.getErrorInfo(); + + FAPI_DBG("ffdcs: %lu", ei->iv_ffdcs.size()); + + for( auto i = ei->iv_ffdcs.begin(); i != ei->iv_ffdcs.end(); ++i ) + { + uint32_t sz; + (*i)->getData(sz); + FAPI_DBG("\tid: 0x%x size %d", (*i)->getFfdcId(), sz); + } + + FAPI_DBG("hwCallouts: %lu", ei->iv_hwCallouts.size()); + + for( auto i = ei->iv_hwCallouts.begin(); i != ei->iv_hwCallouts.end(); + ++i ) + { + FAPI_DBG("\thw: %d pri %d target: 0x%lx", + (*i)->iv_hw, (*i)->iv_calloutPriority, + (*i)->iv_refTarget.get()); + } + + FAPI_DBG("procedureCallouts: %lu", ei->iv_procedureCallouts.size()); + + for( auto i = ei->iv_procedureCallouts.begin(); + i != ei->iv_procedureCallouts.end(); ++i ) + { + FAPI_DBG("\tprocedure: %d pri %d", + (*i)->iv_procedure, (*i)->iv_calloutPriority); + } + + FAPI_DBG("busCallouts: %lu", ei->iv_busCallouts.size()); + + for( auto i = ei->iv_busCallouts.begin(); i != ei->iv_busCallouts.end(); + ++i ) + { + FAPI_DBG("\tbus: t1: 0x%lx t2: 0x%lx pri: %d", + (*i)->iv_target1.get(), (*i)->iv_target2.get(), + (*i)->iv_calloutPriority); + } + + + FAPI_DBG("cdgs: %lu", ei->iv_CDGs.size()); + + for( auto i = ei->iv_CDGs.begin(); i != ei->iv_CDGs.end(); ++i ) + { + FAPI_DBG("\ttarget: 0x%lx co: %d dc: %d gard: %d pri: %d", + (*i)->iv_target.get(), + (*i)->iv_callout, + (*i)->iv_deconfigure, + (*i)->iv_gard, + (*i)->iv_calloutPriority); + + } + + FAPI_DBG("childrenCDGs: %lu", ei->iv_childrenCDGs.size()); + + for( auto i = ei->iv_childrenCDGs.begin(); + i != ei->iv_childrenCDGs.end(); ++i ) + { + FAPI_DBG("\tchildren: parent 0x%lx co: %d dc: %d gard: %d pri: %d", + (*i)->iv_parent.get(), + (*i)->iv_callout, + (*i)->iv_deconfigure, + (*i)->iv_gard, + (*i)->iv_calloutPriority); + } + + FAPI_DBG("traces: %lu", ei->iv_traces.size()); + + for( auto i = ei->iv_traces.begin(); i != ei->iv_traces.end(); ++i ) + { + FAPI_DBG("\ttraces: 0x%x", (*i)->iv_eiTraceId); + } + + // Release the ffdc information now that we're done with it. + io_rc.forgetData(); + +} + +/// +/// @brief Delay this thread. +/// +ReturnCode delay(uint64_t i_nanoSeconds, uint64_t i_simCycles, bool i_fixed) +{ + // void statements to keep the compiler from complaining + // about unused variables. + static_cast<void>(i_nanoSeconds); + static_cast<void>(i_simCycles); + static_cast<void>(i_fixed); + + // replace with platform specific implementation + return FAPI2_RC_SUCCESS; +} + +/// +/// @brief Assert a condition, and halt +/// +/// @param[in] a boolean representing the assertion +/// +void Assert(bool i_expression) +{ + assert(i_expression); +} + +} |