diff options
Diffstat (limited to 'hwpf/plat')
38 files changed, 0 insertions, 6928 deletions
diff --git a/hwpf/plat/.empty b/hwpf/plat/.empty deleted file mode 100755 index e69de29b..00000000 --- a/hwpf/plat/.empty +++ /dev/null diff --git a/hwpf/plat/include/array.H b/hwpf/plat/include/array.H deleted file mode 100644 index 1b976f2b..00000000 --- a/hwpf/plat/include/array.H +++ /dev/null @@ -1,174 +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 array.H - * @brief definitions for fapi2 arrays - */ - -#ifndef __FAPI2_ARRAY__ -#define __FAPI2_ARRAY__ - -#include <stdint.h> -#include <utility> -#include <assert.h> -#include <string.h> - -namespace fapi2 -{ - /// - /// @brief Class representing a FAPI2 array - /// FAPI2 arrays are defined to be very lightweight but support - /// c++ container operations (iterators, bounds checking, assignment, etc.) - /// To avoid the code-bloat associated with std::vector templates, - /// fapi2::array is presently limited to 64-bit elements. - /// - /// To construct an array, you can either pass in an existing chunk - /// of memory, or let the container allocate memory for you: - /// fapi2::array foo(3, &PIB_MEM_BLOCK); - /// creates an array 3 x uit64_t in size, located at &PIB_MEM_BLOCK. - /// The memory pointed to by the address passed in is untouched - /// during creation. This allows for a light-weight overlay on top - /// of existing memory. It also means you need to initialize the space - /// yourself. - /// fapi2_array foo(3); - /// creates an array 3 x uint64_t in size, and that memory will be - /// allocated by the constructor and initiaized to 0's. - /// - /// - class array - { - public: - - typedef uint64_t element_type; - typedef element_type* iterator; - typedef const element_type* const_iterator; - - /// - /// @brief Create an array - /// @param[in] the size of the array - /// @param[in] a pointer to memory of appropriate size - /// defaults to nullptr which causes the platform to - /// allocate memory of size * element_type - /// @warning fapi2::arrays, like arrays, can not be re-sized after - /// creation. - /// - array(const uint32_t i_size, element_type* i_data = nullptr); - - /// - /// @brief Destroy an array - /// - ~array(void); - - /// - /// @brief operator[] - /// @param[in] the index of the element - /// @return a reference to the element in question. - /// @note array[0] = 0 works as well as foo = array[0] - /// - element_type& operator[](const uint32_t i_index); - - /// - /// @brief operator=() - /// @param[in] the other array - /// @return a reference to this, after the assignement - /// - array& operator=(const array& i_other); - - /// - /// @brief move operator=() - /// @note To use: new_array = std::move(old_array). old_array will be - /// destroyed and no copy will be made (moved) - /// - array& operator=(array&& i_other); - - /// - /// @brief operator==() - /// - bool operator==(const array& i_other); - - /// - /// @brief operator!=() - /// - __attribute__ ((always_inline)) - bool operator!=(const array& i_other) - { return ! operator==(i_other); } - - /// - /// @brief Return an iterator the to beginning of the array - /// @return An iterator to the beginning of the array - /// - __attribute__ ((always_inline)) - iterator begin(void) - { return iv_data; } - - /// - /// @brief Return an iterator the to end of the array - /// @return An iterator to the end of the array - /// - __attribute__ ((always_inline)) - iterator end(void) - { return iv_data + size(); } - - /// - /// @brief Return a const_iterator the to beginning of the array - /// @return A const_iterator to the beginning of the array - /// - __attribute__ ((always_inline)) - const_iterator begin(void) const - { return iv_data; } - - /// - /// @brief Return a const_iterator the to end of the array - /// @return A const_iterator to the end the array - /// - __attribute__ ((always_inline)) - const_iterator end(void) const - { return iv_data + size(); } - - private: - - enum - { - // Bit in iv_size representing whether we delete in the dtor - delete_bit = 0x80000000, - - // The resulting size limit - size_limit = 0x7FFFFFFF, - }; - - __attribute__ ((always_inline)) - uint32_t size(void) - { return (iv_size & ~delete_bit); } - - __attribute__ ((always_inline)) - uint32_t size(void) const - { return (iv_size & ~delete_bit); } - - uint32_t iv_size; - element_type* iv_data; - }; -} - -#endif diff --git a/hwpf/plat/include/buffer.H b/hwpf/plat/include/buffer.H deleted file mode 100644 index 62e7e7cf..00000000 --- a/hwpf/plat/include/buffer.H +++ /dev/null @@ -1,764 +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 buffer.H - * @brief definitions for fapi2 variable integral buffers - */ - -#ifndef __FAPI2_INTEGRAL_BUFFER__ -#define __FAPI2_INTEGRAL_BUFFER__ - -#include <buffer_parameters.H> -#include <buffer_traits.H> -#include <return_code.H> - -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 -{ - public: - /// Shortcut typedef to get to our traits class - typedef typename TT::bits_type bits_type; - - /// - /// @brief Integral buffer assignment constructor - /// @param[in] i_value initial value of the buffer - /// Meaningless for variable types and thus protected. - /// - 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); - } - #endif - - /// - /// @brief Get the contents of the buffer - /// @return The contents of the buffer - /// - 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; - } - - /// - /// @brief Get the contents of the buffer - /// @return The contents of the buffer - /// - 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; - } - - /// @name Buffer Manipulation Functions - ///@{ - - /// - /// @brief Set an OT of data in buffer - /// @param[in] i_value sizeof(OT) bits of data - /// @param[in] i_offset Start OT (start word, for example) in buffer - /// - defaults to 0 (will by default write the left most element) - /// @return FAPI2_RC_SUCCESS on success, FAPI2_RC_OVERFLOW otherwise - /// @note This is is only available for integral types. To set a - /// variable_buffer into a variable_buffer, use insert() - /// - template< typename OT> - inline fapi2::ReturnCode set(OT i_value, const bits_type i_offset = 0) - { - // Compile time check to make sure OT is integral - static_assert( std::is_integral<OT>::value, - "Input must be an integral type" ); - - const uint32_t length = TT:: template size<OT>(iv_data); - 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) - { - return FAPI2_RC_OVERFLOW; - } - - // 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); - } - - parameterTraits<OT>::template write_element<typename TT::unit_type> - (TT::get_address(iv_data), i_value, i_offset); - return FAPI2_RC_SUCCESS; - } - - /// @name Bit/Word Manipulation Functions - ///@{ - - /// - /// @brief Return the length of the buffer in bits - /// @return Length in bits - /// - inline constexpr uint32_t getBitLength(void) const - { - return TT::bit_length(iv_data); - } - - /// - /// @brief Return the length of the buffer in OT units - /// @return Length in OT units rounded up - /// @tparam OT the type to get the length of. For example, if one - /// wanted the length in double words, OT would be uint64_t - /// (getLength<uint64_t>().) Similarly, to get the length in words, - /// getLength<uin32_t>(). - /// - template< typename OT > - inline constexpr uint32_t getLength(void) const - { - return TT::template size<OT>(iv_data); - } - - /// - /// @brief Templated setBit for integral types - /// @tparam B the bit number to set. - /// @tparam C the count of bits to set, defaults to 1 - /// @return buffer& Useful for method chaining - /// @note 0 is left-most - /// @note Example: fapi2::buffer<uint64_t>().setBit<3>(); - /// - template< bits_type B, bits_type C = 1 > - inline buffer& setBit(void) - { - static_assert((B >= 0) && - ((B + C - 1) < TT::bits_per_unit()), "failed range check"); - - // 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); - return *this; - } - - /// - /// @brief Set a bit in the buffer - /// @param[in] i_bit the bit number to set. - /// @param[in] i_count the count of bits to set, defaults to 1 - /// @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) - { - 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); - - return FAPI2_RC_SUCCESS; - } - - /// - /// @brief Clear a bit in buffer - /// @tparam B Bit in buffer to clear. - /// @tparam C the count of bits to clear, defaults to 1 - /// @return buffer& Useful for method chaining - /// @note Asserting that all the parameters are known at - /// compile time so this can be templated only. If that is not - /// the case we can add a function parameter version. - /// - template< bits_type B, bits_type C = 1> - inline buffer& clearBit(void) - { - static_assert((B >= 0) && - ((B + C - 1)< TT::bits_per_unit()), "failed range check"); - - iv_data &= buffer<T>().setBit<B, C>().invert(); - return *this; - } - - /// - /// @brief Clear a bit in the buffer - /// @param[in] i_bit the bit number to clear. - /// @param[in] i_count the count of bits to clear, defaults to 1 - /// @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) - { - if ((i_count + i_bit - 1) >= TT::bits_per_unit()) - { - return FAPI2_RC_INVALID_PARAMETER; - } - - fapi2::buffer<T> l_scratch; - - if (l_scratch.setBit(i_bit, i_count) != FAPI2_RC_SUCCESS) - { - return FAPI2_RC_INVALID_PARAMETER; - } - - iv_data &= l_scratch.invert(); - - return FAPI2_RC_SUCCESS; - } - - /// - /// @brief Write a bit in buffer to a given value - /// @tparam B Bit in buffer to write - /// @tparam C the count of bits to write, defaults to 1 - /// @return buffer& Useful for method chaining - /// @note Asserting that all the parameters are known at - /// compile time so this can be templated only. If that is not - /// the case we can add a function parameter version. - /// - template< bits_type B, bits_type C = 1 > - inline buffer& writeBit(const bool i_value) - { - static_assert((B >= 0) && - ((B + C - 1)< TT::bits_per_unit()), "failed range check"); - - (i_value == 0) ? clearBit<B, C>() : setBit<B, C>(); - return *this; - } - - - /// - /// @brief Invert bit - /// @tparam B Bit in buffer to invert. - /// @tparam C the count of bits to flip, defaults to 1 - /// @return buffer& Useful for method chaining - /// @note Asserting that all the parameters are known at - /// compile time so this can be templated only. If that is not - /// the case we can add a function parameter version. - /// - template< bits_type B, bits_type C = 1 > - inline buffer& flipBit(void) - { - static_assert((B >= 0) && - ((B + C - 1) < TT::bits_per_unit()), "failed range check"); - - iv_data ^= buffer<T>().setBit<B, C>(); - return *this; - } - - /// - /// @brief Get the value of a bit in the buffer - /// @tparam B Bit in buffer to get. - /// @tparam C the count of bits to get, defaults to 1 - /// @return true if *any* bit is on, false if *every* bit is off - /// - template< bits_type B, bits_type C = 1> - inline bool getBit(void) const - { - return buffer<T>().setBit<B, C>() & iv_data; - } - - /// - /// @brief Set and entire buffer to X's - /// @tparam X {0,1} depending if you want to clear (0) - /// or fill (1) a buffer - /// @return buffer_base&, Useful for method chaining - /// - 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; - } - - /// - /// @brief Invert entire buffer - /// @return buffer_base&, Useful for method chaining - /// - inline buffer& invert(void) - { - 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; - } - - - ///@} - - /// @name Buffer Manipulation Functions - ///@{ - - /// - /// @brief Get a pointer to the buffer bits - /// @return Pointer to the buffer itself - /// - 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 - // documenation purposes. - - /// - /// @brief operator>>() - /// - #ifdef DOXYGEN - inline buffer<T>& operator>>(bits_type i_shiftnum); - #endif - - /// - /// @brief operator<<() - /// - #ifdef DOXYGEN - inline buffer<T>& operator<<(bits_type i_shiftnum); - #endif - - /// - /// @brief operator+() - /// - #ifdef DOXYGEN - inline buffer<T>& operator+(const T& rhs); - #endif - - /// - /// @brief operator+=() - /// - #ifdef DOXYGEN - inline buffer<T>& operator+=(const T& rhs); - #endif - - /// - /// @brief operator|=() - /// - #ifdef DOXYGEN - inline buffer<T>& operator|=(const T& rhs); - #endif - - /// - /// @brief operator&=() - /// - #ifdef DOXYGEN - inline buffer<T>& operator&=(const T& rhs); - #endif - - /// - /// @brief operator|() - /// - #ifdef DOXYGEN - inline buffer<T>& operator|(const T& rhs); - #endif - - /// - /// @brief operator&() - /// - #ifdef DOXYGEN - inline buffer<T>& operator&(const T& rhs); - #endif - - /// - /// @brief operator^=() - /// - #ifdef DOXYGEN - inline buffer<T>& operator^=(const T& rhs); - #endif - - /// - /// @brief operator~() - /// - #ifdef DOXYGEN - inline buffer<T>& operator~(const T& rhs) const; - #endif - - /// - /// @brief operator==() - /// - #ifdef DOXYGEN - inline bool operator==(const T& rhs) const; - #endif - - /// - /// @brief operator!=() - /// - #ifdef DOXYGEN - inline bool operator!=(const T& rhs) const; - #endif - - /// - /// @brief Copy part of a OT into the DataBuffer - /// @tparam TS Start bit to insert into (target start) - /// @tparam L Length of bits to insert - /// @tparam SS Start bit in source - defaults to bit 0 - /// @tparam OT the type of the incoming (origin) data - /// @param[in] i_datain OT value to copy into DataBuffer - /// - data is taken left aligned - /// @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) - { - const bits_type target_length = parameterTraits<T>::bit_length(); - const bits_type source_length = parameterTraits<OT>::bit_length(); - - // Error if input data don't make sense - static_assert((TS + L) <= target_length, - "insert(): (Target Start + Len) is out of bounds"); - static_assert((SS + L) <= source_length, - "insert(): (Source Start + Len) is out of bounds"); - static_assert(TS < target_length, - "insert(): Target Start is out of bounds"); - static_assert(SS < source_length, - "insert(): Source Start is out of bounds"); - - // Normalize the input to 2 64 bit integers and adjust the starts accordingly - 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); - - // 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; - - // 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; - } - else - { - shift = target_start - source_start; - source >>= shift; - } - - iv_data = ((target & ~mask) | (source & mask)); - return *this; - } - - /// - /// @brief Copy part of a OT into the DataBuffer - /// @tparam OT the type of the incoming (origin) data - /// @param[in] i_datain OT value to copy into DataBuffer - /// - data is taken left aligned - /// @param[in] Start bit to insert into (target start) - /// @param[in] Length of bits to insert - /// @param[in] Start bit in source - defaults to bit 0 - - /// @return FAPI2_RC_SUCCESS if successful - /// - template<typename OT> - fapi2::ReturnCode insert(const OT i_datain, const bits_type i_targetStart, - const bits_type i_len, const bits_type i_sourceStart = 0) - { - const bits_type target_length = parameterTraits<T>::bit_length(); - const bits_type source_length = parameterTraits<OT>::bit_length(); - - // Error if input data don't make sense - if ((i_targetStart + i_len) > target_length) - { - FAPI_ERR("insert(): (Target Start + Len) is out of bounds"); - return FAPI2_RC_INVALID_PARAMETER; - } - - if ((i_sourceStart + i_len) > source_length) - { - FAPI_ERR("insert(): (Source Start + Len) is out of bounds"); - return FAPI2_RC_INVALID_PARAMETER; - } - - if (i_targetStart >= target_length) - { - FAPI_ERR("insert(): Target Start is out of bounds"); - return FAPI2_RC_INVALID_PARAMETER; - } - - if (i_sourceStart >= source_length) - { - FAPI_ERR("insert(): Source Start is out of bounds"); - return FAPI2_RC_INVALID_PARAMETER; - } - - // Normalize the input to 2 64 bit integers and adjust the starts accordingly - 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); - - // 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; - - // 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; - } - else - { - shift = target_start - source_start; - source >>= shift; - } - - iv_data = ((target & ~mask) | (source & mask)); - return FAPI2_RC_SUCCESS; - } - - /// - /// @brief Copy in a right aligned value - /// @tparam SB Start bit to insert into - /// @tparam L Length of bits to insert - /// @tparam OT the type of the incoming (origin) data - /// @param[in] i_datain OT value to copy into DataBuffer - /// - data is taken right aligned - /// @return buffer& Useful for method chaining - /// @note Data is assumed to be aligned on the word boundary of L - /// - template<bits_type TS, bits_type L, typename OT> - inline buffer& insertFromRight(const OT i_datain) - { - // Error if input data don't make sense - static_assert(L <= parameterTraits<OT>::bit_length(), - "insertFromRight(): Len > input buffer"); - static_assert(TS < parameterTraits<T>::bit_length(), - "insertFromRight(): Target Start is out of bounds"); - 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); - return *this; - } - - /// - /// @brief Copy in a right aligned value - /// @tparam OT the type of the incoming (origin) data - /// @param[in] i_datain OT value to copy into DataBuffer - /// - data is taken right aligned - /// @param[in] Start bit to insert into - /// @param[in] Length of bits to insert - /// @return FAPi2_RC_SUCCESS if no error - /// @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, - const bits_type i_len) - { - // Error if input data don't make sense - if ((i_targetStart + i_len) > parameterTraits<T>::bit_length()) - { - FAPI_ERR("insertFromRight(): (Target Start + Len) is out of bounds"); - return FAPI2_RC_INVALID_PARAMETER; - } - - if (i_targetStart >= parameterTraits<T>::bit_length()) - { - FAPI_ERR("insertFromRight(): Target Start is out of bounds"); - return FAPI2_RC_INVALID_PARAMETER; - } - - if (i_len > parameterTraits<OT>::bit_length()) - { - FAPI_ERR("insertFromRight(): Len > input buffer"); - return FAPI2_RC_INVALID_PARAMETER; - } - - 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; - } - - /// - /// @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 buffer& Useful for method chaining - /// - template<bits_type SS, bits_type L, bits_type TS = 0, typename OT> - inline buffer& extract(OT& o_out) - { - // 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; - } - - /// - /// @brief Copy data from this buffer into an OT - /// @tparam OT the type of the outgoing (target) - /// @param[out] o_out OT to copy into - data is placed left aligned - /// @param[in] Start bit in source - /// @param[in] Length of bits to extract - /// @param[in] Start bit to insert into (target start) - /// @return FAPI2_RC_SUCCESS if ok - /// - 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 - { - // 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) - { - return FAPI2_RC_INVALID_PARAMETER; - } - - o_out = out; - return FAPI2_RC_SUCCESS; - } - - /// - /// @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 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); - return *this; - } - - /// - /// @brief Copy data from this buffer into an OT and right justify - /// @tparam OT the type of the outgoing (target) - /// @param[out] o_out OT to copy into - data is placed right aligned - /// @param[in] Start bit to insert into (source start) - /// @param[in] Length of bits to insert - /// @return FAPI2_RC_SUCCESS if ok - /// - template<typename OT> - fapi2::ReturnCode extractToRight(OT& o_out, const bits_type i_sourceStart, - const bits_type i_len) const - { - return extract(o_out, i_sourceStart, i_len, - parameterTraits<OT>::bit_length() - i_len); - } - - ///@} - - private: - /// The contents of the buffer - T iv_data; -}; -} - -#endif diff --git a/hwpf/plat/include/buffer_base.H b/hwpf/plat/include/buffer_base.H deleted file mode 100755 index a6e8c4ad..00000000 --- a/hwpf/plat/include/buffer_base.H +++ /dev/null @@ -1,331 +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 buffer_base.H - * @brief definitions for fapi2 buffer base class - */ - -#ifndef __FAPI2_BUFFER_BASE__ -#define __FAPI2_BUFFER_BASE__ - -#include <stdint.h> -#include <initializer_list> -#include <error_scope.H> -#include <buffer_parameters.H> -#include <buffer_traits.H> -#include <return_code.H> - -namespace fapi2 -{ - /// @brief Base class for buffers and variable buffers - /// @tparam T is the type of iv_data (std::vector, etc) - /// @tparam TT is the template trait, defaults to the trait for T - /// - /// Buffers can be of two styles; buffers made from an integral type and - /// buffers made from a container. Integral type buffers, while limited - /// in size, can be tightly controlled via the compiler by using c++ - /// templates. - /// - /// C++ templates allow for very explicit control, but yield a - /// syntax different than the FAPI 1.x functional interface. For example, - /// a fapi2::buffer is defined as having a type: - /// @code - /// fapi2::buffer<uint64_t> new_buffer; - /// @endcode - /// defines a buffer with exactly 64 bits, and can be manipulated by the - /// compiler as a single intrgral value. These implementations result - /// in concise instruction streams, and a platform may choose to implement - /// all or some or none of the integral buffer types. - /// - /// Buffers which have containers as their underlying implementation - /// are found in the class fapi2::variable_buffer. variable_buffer is little - /// more than - /// @code - /// fapi2::buffer<fapi2::bits_container> - /// @endcode - /// where bits_container is the typedef of the underlying container (a - /// vector of uint32_t, for example) - /// - /// Examples:<br> - /// - /// * Simple uint64_t buffer - /// @code - /// const uint32_t x = 2; - /// - /// // this data buffer will contain data in a uint64_t type - /// fapi2::buffer<uint64_t> data; - /// - /// // Set using the template and a constant - /// data.setBit<x>(); - /// - /// // Set using the template and a value - /// data.setBit<3>(); - /// - /// // Set using the function interface, and a value - /// data.setBit(1); - /// - /// // compiler gets smart. - /// // movabs $0x7000000000000000,%rsi - /// @endcode - /// - /// * variable_buffer, same thing - /// @code - /// - /// const uint32_t x = 2; - /// - /// // Note: only 15 bits long - /// fapi2::variable_buffer data(15); - /// - /// - /// data.setBit(x); - /// data.setBit(3); - /// data.setBit(1); - /// @endcode - /// - /// * method chaining - /// Buffers support method chaining. So, rather than - /// this - /// @code - /// buffer<T> mask; - /// mask.setBit<B>(); - /// mask.invert(); - /// my_buffer &= mask; - /// @endcode - /// You can do - /// @code - /// my_buffer &= buffer<T>().setBit<B>.invert(); - /// @endcode - /// - /// * buffer operations - /// @code - /// - /// // An 8 bit buffer, initialized with a value - /// fapi2::buffer<uint8_t> eight_bits = 0xAA; - /// fapi2::buffer<uint8_t> another_eight; - /// fapi2::buffer<uint16_t> sixteen_bits; - /// - /// // You can't assign an 8 bit buffer to a 16 bit buffer. - /// sixteen_bits = eight_bits; ERROR - /// - /// // But you can assign buffers of the same type - /// another_eight = eight_bits; - /// - /// // You can assign constants (or other known values) directly: - /// sixteen_bits = 0xAABB; - /// @endcode - /// - /// * Variable buffer operations - /// - /// @code - /// fapi2::variable_buffer data(16); - /// - /// // Very large buffers can be initialized rather than set bit by bit. - /// const fapi2::variable_buffer bit_settings_known( - /// {0xFFFF0000, 0xAABBF0F0, - /// 0xFFFF0000, 0xAABBF0F0, - /// 0xFFFF0000, 0xAABBF0F0,}); - /// - /// // Assignment will expand or shrink the size automatically. - /// data = bit_settings_known; - /// - /// // You can assign directly to the buffer: - /// fapi2::variable_buffer other_bits; - /// const fapi2::container_unit x = 0xFF00AA55; - /// other_bits = {x, 0xDEADBEEF}; - /// @endcode - /// - template <typename T, typename TT = bufferTraits<T> > - class buffer_base - { - - public: - - /// Shortcut typedef to get to our traits class - typedef typename TT::bits_type bits_type; - /// Shortcut typedef to get to our traits class - typedef typename TT::unit_type unit_type; - - /// - /// @brief Default constructor - /// @note iv_data will get the "default" construction, which is - /// correct - 0 for integral types, an empty container for the others. - /// - buffer_base(void): - iv_data() - {} - - virtual ~buffer_base(void) - {} - -#ifndef DOXYGEN - /// @brief Print the contents of the buffer to stdout - inline void print(void) const - { 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; } - - /// - /// @brief Get the contents of the buffer - /// @return The contents of the buffer - /// - 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; } - - /// - /// @brief Get the contents of the buffer - /// @return Reference to the contents of the buffer - /// - inline const T& operator()(void) const { return iv_data; } - - /// - /// @brief Get a pointer to the buffer bits - /// @return Pointer to the buffer itself - /// - inline T* pointer(void) { return &iv_data; } - - /// @name Buffer Manipulation Functions - ///@{ - - /// - /// @brief Set an OT of data in buffer - /// @param[in] i_value sizeof(OT) bits of data - /// @param[in] i_offset Start OT (start word, for example) in buffer - /// - defaults to 0 (will by default write the left most element) - /// @return FAPI2_RC_SUCCESS on success, FAPI2_RC_OVERFLOW otherwise - /// @note This is is only available for integral types. To set a - /// variable_buffer into a variable_buffer, use insert() - /// - template< typename OT> - inline fapi2::ReturnCode set(OT i_value, const bits_type i_offset = 0) - { - // Compile time check to make sure OT isn't a variable buffer - static_assert( !std::is_same<bits_container, OT>::value, - "Can't use a variable_buffer as input to set()" ); - - // - // There's a gotcha in here. size<OT>() returns the size in the buffer - // in OT units *rounded up*. This is the actual size of the buffer, not - // the perceived size of a variable_buffer. This should be OK however, - // as what we're trying to prevent is overflow, which this should do. - // - const uint32_t length = TT:: template size<OT>(iv_data); - static const bits_type bits_in_value = parameterTraits<OT>::bit_length; - const bits_type bit_length = TT::bit_length(iv_data); - - if (i_offset >= length) - { - return FAPI2_RC_OVERFLOW; - } - - // 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); - } - - parameterTraits<OT>::template write_element<unit_type>(TT::get_address(iv_data), i_value, i_offset); - return FAPI2_RC_SUCCESS; - } - - /// - /// @brief Set and entire buffer to X's - /// @tparam X {0,1} depending if you want to clear (0) - /// or fill (1) a buffer - /// - template< uint8_t X > - inline void flush(void) - { - static_assert( (X == 1) || (X == 0), "bad argument to flush" ); - (0 == X) ? TT::clear(iv_data) : TT::set(iv_data); - } - - /// - /// @brief Invert entire buffer - /// @return buffer_base&, Useful for method chaining - /// - inline buffer_base& invert(void) - { TT::invert(iv_data); return *this; } - - /// - /// @brief Bit reverse entire buffer - /// @return buffer_base&, Useful for method chaining - /// - inline buffer_base& reverse(void) - { TT::reverse(iv_data); return *this; } - - //@} - protected: - - /// - /// @brief Variable buffer constructor - /// @param[in] i_value number of *bits* (sizeof(container_units) * 8) - /// needed. Meaningless for integral types and thus protected. - /// - buffer_base(bits_type i_value); - - /// - /// @brief Variable buffer construct from a list - /// @param[in] i_value an initializer list to initialize the container. - /// Meaningless for integral types and thus protected - /// - buffer_base(std::initializer_list<unit_type> i_value); - - /// - /// @brief Clear the buffer - /// - inline void clear(void) - { TT::clear(iv_data); } - - /// The contents of the buffer - T iv_data; - }; - - template <typename T, typename TT> - inline buffer_base<T, TT>::buffer_base(bits_type i_value): - iv_data( std::max(bits_type(1), - bits_type(i_value / 8 / sizeof(bits_type)))) - { - } - - template <typename T, typename TT> - inline buffer_base<T, TT>::buffer_base(std::initializer_list<unit_type> i_value): - iv_data(i_value) - { - } -}; - - - -#endif diff --git a/hwpf/plat/include/buffer_parameters.H b/hwpf/plat/include/buffer_parameters.H deleted file mode 100644 index 2a6e6100..00000000 --- a/hwpf/plat/include/buffer_parameters.H +++ /dev/null @@ -1,70 +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 buffer_parameters.H - * @brief definitions for fapi2 buffer parameter types - */ - -#ifndef __FAPI2_BUFFER_PARAM__ -#define __FAPI2_BUFFER_PARAM__ - -#include <stdint.h> - -namespace fapi2 -{ - /// @cond - /// @brief Traits of buffer parameters - things passed in - /// @tparam T is the type of i_value (typically an integral type) - template<typename T> - class parameterTraits - { - public: - // Why constexpr functions? Enums are hard to do math on, and - // static const doesn't work without -O1 (or greater.) That might - // be a bug in g++ but this works just the same. - constexpr static T mask(void) - { return T(~0); } - - constexpr static uint32_t byte_length(void) - { return sizeof(T); } - - constexpr static uint32_t bit_length(void) - { return sizeof(T) * 8; } - - template<typename U> - inline static void write_element(void* i_data, T i_value, uint32_t i_offset) - { -#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ - T* ptr = (T*)i_data + (i_offset ^ ((sizeof(U) / sizeof(T)) - 1)); -#else - T* ptr = (T*)i_data + i_offset; -#endif - *ptr = i_value; - } - }; - /// @endcond -} - -#endif diff --git a/hwpf/plat/include/buffer_traits.H b/hwpf/plat/include/buffer_traits.H deleted file mode 100644 index 7cab81ff..00000000 --- a/hwpf/plat/include/buffer_traits.H +++ /dev/null @@ -1,242 +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 buffer_traits.H - * @brief trait definitions for fapi2 buffer base class - */ - -#ifndef __FAPI2_BUFFER_TRAITS__ -#define __FAPI2_BUFFER_TRAITS__ - -#include <stdint.h> -#include <vector> -#include <algorithm> -#include <buffer_parameters.H> - -#ifdef FAPI2_DEBUG -#include <iostream> -#endif - -#if !defined(DOXYGEN) && defined(FAPI2_DEBUG) -#include <iterator> -#endif - -namespace fapi2 -{ - /// @cond - /// Types representing a container of bits. Used to create - /// variable_buffer. container_unit must remain 32-bits - /// for now - there will be a lot of code to change if it - /// changes. There are assertions helping to enforce this - /// in places in the code. - typedef uint32_t container_unit; - typedef std::vector<container_unit> bits_container; - - /// @brief Traits of buffers - // In general, we try to give buffers traits reflecting integral types. If - // this fails, the compiler will let someone know. - /// - /// @tparam T is the type of iv_data (std::vector, etc) - /// @tparam B is the type of the bit-specifier, typically uint32_t - template<typename T, typename B = uint32_t> - class bufferTraits - { - public: - -#if !defined(DOXYGEN) && defined(FAPI2_DEBUG) - /// - /// @brief Print a container of bits - /// @param[in] i_data the container of bits - /// - static inline void print(const T& i_data) - { - // convert to uint64_t to prevent uint8_t from being - // printed as a char. - std::cout << "\tdata is " - << std::hex - << static_cast<uint64_t>(i_data) - << std::dec << std::endl; - } -#endif - - /// - /// @brief Return the size of the buffer in E units - /// @tparam E, the element size. - /// @param[in] io_buffer the buffer which to size - /// @return The size of the buffer in E's rounded up - /// - template<typename E> - constexpr static B size(const T& i_buffer) - { - return (bit_length(i_buffer) + - (parameterTraits<E>::bit_length() - 1)) / - parameterTraits<E>::bit_length(); - } - - /// - /// @brief Return the size of the buffer itself - /// @param[in] io_buffer the buffer which to size - /// @return The size of the buffer in bits (not units) - /// - constexpr static B bit_length(const T&) - { return sizeof(T) * 8; } - - /// - /// @brief Clear the buffer - /// @param[in,out] io_buffer the buffer which to clear - /// - static inline void clear(T& io_buffer) - { io_buffer = static_cast<T>(0); } - - /// - /// @brief Set the buffer - /// @param[in,out] io_buffer the buffer which to set - /// - static inline void set(T& io_buffer) - { io_buffer = static_cast<T>(~0); } - - /// - /// @brief Invert the buffer - /// @param[in,out] io_buffer the buffer which to invert - /// - static inline void invert(T& io_buffer) - { io_buffer = ~io_buffer; } - - /// - /// @brief Reverse the buffer - /// @param[in,out] io_buffer the buffer which to reverse - /// - static inline void reverse(T& io_buffer) - { - io_buffer = - ((io_buffer & 0xAAAAAAAAAAAAAAAA) >> 1) | - ((io_buffer & 0x5555555555555555) << 1); - } - - /// - /// @brief Get the address of the buffer as an array - /// @param[in] i_buffer the buffer which to invert - /// @return The address of the first element of the buffer - /// - static inline void* get_address(T& i_buffer) - { return (void*)&i_buffer; } - - typedef B bits_type; - typedef T unit_type; - constexpr static uint32_t bits_per_unit(void) - { return sizeof(unit_type) * 8; } - }; - - // - // - /// @brief Traits for buffers which are a container of bits - // - // - template<> - class bufferTraits<bits_container, uint32_t> - { - public: -#if !defined(DOXYGEN) && defined(FAPI2_DEBUG) - /// - /// @brief Print a container of bits - /// @param[in] i_data the container of bits - /// - static inline void print(const bits_container& i_data) - { - std::cout << "\tdata is " << std::hex; - std::copy(i_data.begin(), i_data.end(), - std::ostream_iterator<container_unit>(std::cout, " ")); - std::cout << std::dec << std::endl; - } -#endif - - /// - /// @brief Return the size of the buffer in E units - /// @tparam E, the element size. - /// @param[in] io_buffer the buffer which to size - /// @return The size of the buffer in E's rounded up - /// - template<typename E> - constexpr static uint32_t size(const bits_container& i_buffer) - { - return (bit_length(i_buffer) + - (parameterTraits<E>::bit_length() - 1)) / - parameterTraits<E>::bit_length(); - } - - /// - /// @brief Return the size of the buffer itself - /// @param[in,out] io_buffer the buffer which to size - /// @return The size of the buffer in bits (not units) - /// - static inline uint32_t bit_length(const bits_container& i_buffer) - { return i_buffer.size() * sizeof(container_unit) * 8; } - - /// - /// @brief Clear the buffer - /// @param[in,out] io_buffer the buffer which to clear - /// - static inline void clear(bits_container& io_buffer) - { io_buffer.assign(io_buffer.size(), 0); } - - /// - /// @brief Set the buffer - /// @param[in,out] io_buffer the buffer which to set - /// - static inline void set(bits_container& io_buffer) - { io_buffer.assign(io_buffer.size(), ~0); } - - /// - /// @brief Invert the buffer - /// @param[in,out] io_buffer the buffer which to invert - /// - static inline void invert(bits_container& io_buffer) - { - std::transform(io_buffer.begin(), io_buffer.end(), - io_buffer.begin(), - [](container_unit u) { return ~u; }); - } - - /// - /// @brief Get the address of the buffer as an array - /// @param[in] i_buffer the buffer which to invert - /// @return The address of the first element of the buffer - /// - static inline void* get_address(bits_container& i_buffer) - { - return (void*)&(i_buffer[0]); - } - - typedef uint32_t bits_type; - typedef container_unit unit_type; - constexpr static uint32_t bits_per_unit(void) - { return sizeof(unit_type) * 8; } - }; - /// @endcond -} - - - -#endif diff --git a/hwpf/plat/include/fapi2.H b/hwpf/plat/include/fapi2.H deleted file mode 100644 index de2295b4..00000000 --- a/hwpf/plat/include/fapi2.H +++ /dev/null @@ -1,53 +0,0 @@ -/// -/// @file fapi2.H -/// @brief top level header for fapi2 -/// - -#ifndef __FAPI2_TOP_LEVEL__ -#define __FAPI2_TOP_LEVEL__ - -// Define which platforms will not have FAPI Return Codes -#undef __noRC__ -#if defined (__CME__) || defined (__SGPE__) || defined (__PGPE__) -#define __noRC__ -#endif - -// Determine if running on a PPE platform -#ifndef __PPE__ -#if defined (__SBE__) || defined (__CME__) || defined (__SGPE__) || defined (__PGPE__) -#define __PPE__ -#endif -#endif - -#include <plat_trace.H> -#include <target.H> -#include <return_code.H> -#include <buffer.H> -#include <hw_access.H> -#include <utils.H> - - - -// In turn includes the needed generated headers (hwp_ffd_classes, etc.) -#include <error_scope.H> -#include <set_sbe_error.H> // Generated file -#include <plat_attributes.H> -#include <plat_target_utils.H> - - -#include <fapi2_hwp_executor.H> - -// Block of headers not currently in fapi2 -#ifdef FAPI2_MISSING_HEADERS - #include <mvpdAccess.H> - #include <mbvpdAccess.H> -#endif - - -#endif // __FAPI2_TOP_LEVEL__ - - - - - - diff --git a/hwpf/plat/include/fapi2AttributeService.H b/hwpf/plat/include/fapi2AttributeService.H deleted file mode 100644 index ab49c9ab..00000000 --- a/hwpf/plat/include/fapi2AttributeService.H +++ /dev/null @@ -1,127 +0,0 @@ -/// -/// @file fapi2AttributeService.H -/// -/// @brief Defines the FAPI_ATTR_GET and FAPI_ATTR_SET macros that a user -/// calls to get/set attributes and a check function that the macros use to -/// verify correct usage -/// - -#ifndef FAPI2ATTRIBUTESERVICE_H_ -#define FAPI2ATTRIBUTESERVICE_H_ -#include <stdint.h> -//#include <attribute_ids.H> -#include <fapi2AttributeIds.H> -#include <target.H> -#include <target_types.H> -//#include <plat_attribute_service.H> -#include <fapi2PlatAttributeService.H> - -/// @brief Macros called by user to get/set attributes for FAPI2 targets -/// -/// Code must have a reference to a FAPI2 Target and an attribute ID (from -/// XML file): -/// fapi2::ReturnCode l_rc; -/// fapi2::Target<target type>& l_target = ????; -/// Ex: Target<TARGET_TYPE_PROC_CHIP>& l_target = ????; -/// -/// To get a copy of an integer attribute and set the attribute -/// uint64_t l_val = 0; -/// l_rc = FAPI_ATTR_GET(<ID>, l_target, l_val); -/// l_rc = FAPI_ATTR_SET(<ID>, l_target, l_val); -/// -/// To get a copy of an integer array attribute and set the attribute -/// uint32_t l_pVal[4] = {0}; -/// l_rc = FAPI_ATTR_GET(<ID>, l_target, l_pVal); -/// l_rc = FAPI_ATTR_SET(<ID>, l_target, l_pVal); -/// -/// A priveleged attribute is one that a HWP should not generally access, -/// examples include ATTR_NAME and ATTR_EC, where usage can lead to a non -/// data-driven design. A privileged attribute can be accessed with -/// FAPI_ATTR_GET_PRIVILEGED and FAPI_ATTR_SET_PRIVILEGED -/// -/// The non-PRIVILEGED macros first call a template function (compiler will -/// optimize out) that will cause a compile failure if the attribute is -/// privileged, they then call a PRIVILEGED macro to get/set the attribute -/// -/// The PRIVILEGED macros call a template function (compiler will optimize out) -/// that will cause a compile failure if the ID is not valid or VAL is not the -/// correct type. -// - -#define FAPI_ATTR_GET(ID, TARGET, VAL) \ - (fapi2::failIfPrivileged<ID##_Privileged>(), \ - fapi2::checkIdType<ID##_Type>(ID, VAL), \ - ID##_GETMACRO(ID, TARGET, VAL)) - -#define FAPI_ATTR_SET(ID, TARGET, VAL) \ - (fapi2::failIfPrivileged<ID##_Privileged>(), \ - fapi2::checkIdType<ID##_Type>(ID, VAL), \ - ID##_SETMACRO(ID, TARGET, VAL)) - -#define FAPI_ATTR_GET_PRIVILEGED(ID, TARGET, VAL) \ - (fapi2::checkIdType<ID##_Type>(ID, VAL), \ - ID##_GETMACRO(ID, TARGET, VAL)) - -#define FAPI_ATTR_SET_PRIVILEGED(ID, TARGET, VAL) \ - (fapi2::checkIdType<ID##_Type>(ID, VAL), \ - ID##_SETMACRO(ID, TARGET, VAL)) - -namespace fapi2 -{ - -/// -/// @brief Get an InitFile attribute for FAPI2 -/// -/// This function gets a copy of an attribute. In the case of an array attribute, -/// The value in the specified index is retrieved. This should be used by the -/// InitFile HWP only, that HWP processes a binary InitFile and therefore needs -/// to read a variable ID of a variable data type. Standard HWPs should use the -/// FAPI2_ATTR_GET macro which automatically checks the type for correct usage. -/// -/// If there are ever attributes with more than 4 dimensions then this function -/// will need to be updated. -/// -/// @Tparam K template parameter, passed in target. -/// @param[in] i_id AttributeID -/// @param[in] i_target Reference to fapi2::Target (can be NULL for system) -/// @param[out] o_val Reference to uint64_t where attribute value is set -/// @param[in] i_arrayIndex1 If array attribute then index1 -/// @param[in] i_arrayIndex2 If at least 2D array attribute then index2 -/// @param[in] i_arrayIndex3 If at least 3D array attribute then index3 -/// @param[in] i_arrayIndex4 If at least 4D array attribute then index4 -/// -/// @return ReturnCode. Zero if success -/// -template< TargetType K > -ReturnCode getInitFileAttr(const AttributeId i_id, - const Target<K>& i_target, - uint64_t & o_val, - const uint32_t i_arrayIndex1 = 0, - const uint32_t i_arrayIndex2 = 0, - const uint32_t i_arrayIndex3 = 0, - const uint32_t i_arrayIndex4 = 0); - -/** - * @brief Check the ID and TYPE - * - * This is called by FAPI code to check at compile time that a FAPI attribute - * access is using the correct data type and a valid AttributeId - */ -template<typename T> inline void checkIdType(AttributeId, T &) {} - -/** - * @brief Fail if attribute privileged - * - * This is called by FAPI code to check at compile time that a standard FAPI - * attribute access (FAPI_ATTR_GET) is not accessing a privileged attribute - */ -class ErrorAccessingPrivilegedAttribute; -template<const bool PRIVILEGED> void failIfPrivileged() -{ - ErrorAccessingPrivilegedAttribute(); -} -template <> inline void failIfPrivileged<false>() {} - -} - -#endif // FAPI2ATTRIBUTESERVICE_H_ diff --git a/hwpf/plat/include/fapi2Structs.H b/hwpf/plat/include/fapi2Structs.H deleted file mode 100644 index 48d8062e..00000000 --- a/hwpf/plat/include/fapi2Structs.H +++ /dev/null @@ -1,109 +0,0 @@ -#ifndef fapiStructs_h -#define fapiStructs_h -// Copyright ********************************************************** -// -// File fapiStructs.H -// -// IBM Confidential -// OCO Source Materials -// 9400 Licensed Internal Code -// (C) COPYRIGHT IBM CORP. 1996 -// -// 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. -// -// End Copyright ****************************************************** - -/** - * @file fapiStructs.H - * @brief fapi eCMD Extension Structures - - * Extension Owner : John Farrugia -*/ - -//-------------------------------------------------------------------- -// Includes -//-------------------------------------------------------------------- -#include <string> - - -//-------------------------------------------------------------------- -// Forward References -//-------------------------------------------------------------------- - -#define ECMD_FAPI_CAPI_VERSION "1.0" ///< eCMD FAPI Extension version - - - -#ifndef ECMD_PERLAPI - -namespace fapi -{ - -/** - * @brief Enumeration of fapi file types - */ -typedef enum { - FAPI_FILE_UNKNOWN, ///< Default for not initialized - FAPI_FILE_HWP -} FileType_t; - - -enum AttributeSource -{ - FAPI_ATTRIBUTE_SOURCE_UNKNOWN = 0x00000000, - FAPI_ATTRIBUTE_SOURCE_PLAT = 0x00000001, - FAPI_ATTRIBUTE_SOURCE_HWP = 0x00000002, -}; - - -#define FAPI_ATTRIBUTE_TYPE_STRING 0x80000000 -#define FAPI_ATTRIBUTE_TYPE_UINT8 0x40000000 -#define FAPI_ATTRIBUTE_TYPE_UINT32 0x20000000 -#define FAPI_ATTRIBUTE_TYPE_UINT64 0x10000000 -#define FAPI_ATTRIBUTE_TYPE_UINT8ARY 0x04000000 -#define FAPI_ATTRIBUTE_TYPE_UINT32ARY 0x02000000 -#define FAPI_ATTRIBUTE_TYPE_UINT64ARY 0x01000000 - -#define FAPI_ATTRIBUTE_MODE_CONST 0x80000000 -/** - @brief Used by the get/set configuration functions to return the data -*/ -template<typename T> -class Attribute -{ -public: - // Constructor - Attribute(); - - // Destructor - ~Attribute(); - - // - /// @brief Assignment Operator. - /// @param[in] i_right Reference to Value to assign from. - /// @return Reference to 'this' Target - /// - Attribute<T>& operator=(const T& i_right) - { - this->value = i_right->value; - } - -private: - T value; - -}; - -inline AttributeData::AttributeData() {} - -inline AttributeData::~AttributeData() {} - -} //namespace -#endif // #ifndef ECMD_PERLAPI -#endif - - - - - diff --git a/hwpf/plat/include/fapi2_hw_access.H b/hwpf/plat/include/fapi2_hw_access.H deleted file mode 100644 index 44a592f8..00000000 --- a/hwpf/plat/include/fapi2_hw_access.H +++ /dev/null @@ -1,464 +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 fapi2_hw_access.H -/// @brief Common file that defines the hardware access functions that -/// platform code must implement. -/// - -#ifndef _FAPI2_COMMON_HWACCESS_H_ -#define _FAPI2_COMMON_HWACCESS_H_ - -#ifdef FAPI_SUPPORT_SPY_AS_ENUM -#include <spy_ids.H> -typedef uint64_t spyId_t; -#endif - -#include <stdint.h> -//#include <thread> -#include <buffer.H> - -// variable_buffer isn't supported on PPE -#ifndef __PPE__ -#include <variable_buffer.H> -#endif - -#include <return_code.H> -#include <target.H> -#include <hw_access_def.H> -#include <plat_hw_access.H> - -#ifdef FAPI_SUPPORT_MULTI_SCOM -#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 void 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 void 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 void 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); -#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 -#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); -#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); -#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 - /// -#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); -#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); -#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. - /// -#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); -#endif - -#if defined(FAPI_SUPPORT_SPY_AS_STRING) || defined(DOXYGEN) - -#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); -#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. - /// -#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); -#endif - -#if defined(FAPI_SUPPORT_SPY_AS_STRING) || defined(DOXYGEN) - -#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); -#endif - -#endif // PPE -}; - -#endif // _FAPI2_HWACCESS_H_ diff --git a/hwpf/plat/include/fapi2_target.H b/hwpf/plat/include/fapi2_target.H deleted file mode 100644 index 32b68618..00000000 --- a/hwpf/plat/include/fapi2_target.H +++ /dev/null @@ -1,562 +0,0 @@ -/// -/// @file fapi2_target.H -/// @brief Common definitions for fapi2 targets -/// - -#ifndef __FAPI2_COMMON_TARGET__ -#define __FAPI2_COMMON_TARGET__ - -#include <stdint.h> -#include <vector> -#include <target_types.H> -#include <target_states.H> -#include <plat_target.H> - -namespace fapi2 -{ - - - /// - /// @brief Typedef for chiplet number values - /// - typedef uint8_t ChipletNumber_t; - - /// - /// @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: - - /// - /// @brief Create a Target, with a value - /// @param[in] Value the value (i.e., specific element this - /// target represents, or pointer) - /// @note Platforms can mangle the value and K to get a - /// single uint64_t in value which represents all the information - /// they might need. value( K | V ), for example - /// - Target(V Value); - -// Target(V Value): -// iv_handle(Value) -// {} - - /// - /// @brief Assignment Operator. - /// @param[in] i_right Reference to Target to assign from. - /// @return Reference to 'this' Target - /// - Target& operator=(const Target& i_right); - - /// - /// @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 - /// - bool operator==(const Target& i_right) const; - - /// - /// @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 - /// - bool operator!=(const Target& i_right) const; - - /// - /// @brief Get the handle. - /// @return V The target's handle, or value - /// - V get(void) const - { - return this->iv_handle.value; - } - - /// - /// @brief Get the handle as a V - /// @return V The target's handle, or value - /// - inline operator V() const - { - return this->iv_handle.value; - } - - /// - /// @brief Get a target's value - /// @return V The target's handle, or value - /// - inline V& operator()(void) - { - return this->iv_handle.value; - } - - /// - /// @brief Get the target type - /// @return The type of target represented by this target - /// - inline TargetType getType(void) const - { - return iv_type; - } - - /// - /// @brief Get this target's immediate parent - /// @tparam T The type of the parent - /// @return Target<T> a target representing the parent - /// - template< TargetType T > - inline Target<T> getParent(void) const; - - /// - /// @brief Is this target a chip? - /// @return Return true if this target is a chip, false otherwise - /// - inline constexpr bool isChip(void) const - { -// return ( (K == TARGET_TYPE_PROC_CHIP) || -// (K == TARGET_TYPE_MEMBUF_CHIP) ); - - return ( (K == TARGET_TYPE_PROC_CHIP) ); - } - - /// - /// @brief Is this target a chiplet? - /// @return Return true if this target is a chiplet, false otherwise - /// - 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_PERV) ); -// (K == TARGET_TYPE_PEC) || -// (K == TARGET_TYPE_PHB) ); - } - - /// - /// @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 T> - inline std::vector<Target<T> > - getChildren(const TargetState i_state = TARGET_STATE_FUNCTIONAL) const; - - /// - /// @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 T> - inline Target<T> - getOtherEnd(const TargetState i_state = TARGET_STATE_FUNCTIONAL) const; - - /// - /// @brief Copy from a Target<O> to a Target<K> - /// @tparam O the target type of the other - /// - template<TargetType O> - inline Target( const Target<O>& Other ): - Target<K, V>(Other.get()) - { - // In case of recursion depth failure, use -ftemplate-depth= - static_assert( (K & O) != 0, - "unable to cast Target, no shared types"); - - static_assert( bitCount<K>::count >= bitCount<O>::count, - "unable to cast to specialized Target"); - } - -#ifdef __PPE__ - - /// - /// @brief Get the target present setting - /// @return Bool whether present - /// - inline bool getPresent(void) const - { - return (this->iv_handle.fields.present ? true : false); - } - - /// - /// @brief Get the target functional setting - /// @return Bool whether functional - /// - inline bool getFunctional(void) const - { - return (this->iv_handle.fields.functional ? true : false); - } - - /// - /// @brief Set the target present setting - /// @return Bool whether present - /// - inline void setPresent(void) - { - this->iv_handle.fields.present = 1; - return; - } - - /// - /// @brief Set the target functional setting - /// @return Bool whether functional - /// - inline void setFunctional(void) - { - this->iv_handle.fields.functional = 1; - return; - } - - - /// Need to optimize PPE Target resoulution in a cheap manner - /// Brian: not sure if the this is the place for this as - /// this is plaform specific. - - /// - /// @brief Get address overlay to reduce runtime processing - /// @return Overlay as a type V - /// - inline V getAddressOverlay(void) const - { - return this->iv_handle.fields.address_overlay; - } - - /// - /// @brief Get target number - /// @return Overlay as a type V - /// - inline uint32_t getTargetNumber(void) const - { - return static_cast<uint32_t>(this->iv_handle.fields.type_target_num); - } - - /// - /// @brief Get target type directly from the handle - /// @return Overlay as a type V - /// - inline TargetTypes_t getTargetType(void) const - { - return static_cast<TargetTypes_t>(this->iv_handle.fields.type); - } - - /// - /// @brief Get chiplet number from the handle - /// @return ChipletNumber_t Chiplet Number - /// - inline ChipletNumber_t getChipletNumber(void) const - { - return static_cast<ChipletNumber_t>(this->iv_handle.fields.chiplet_num); - } - -#endif - - - private: - // Don't use enums here as it makes it hard to assign - // in the platform target cast constructor. - static const TargetType iv_type = K; - - union iv_handle { - V value; - struct { -#ifdef _BIG_ENDIAN - V chiplet_num : 8; - V type_target_num : 8; - V type : 8; - V _reserved_b6 : 6; - V present : 1; - V functional : 1; - V address_overlay : 32; -#else - V address_overlay : 32; - V functional : 1; - V present : 1; - V _reserved_b6 : 6; - V type : 8; - V type_target_num : 8; - V chiplet_num : 8; -#endif - } fields; - // Union Constructor -// iv_handle(V i_value = 0):value(i_value) {} - } 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; - } - - /// - /// @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; - - if (i_thread_id == all_threads) - { - return all_normal_threads_bitset; - } - - // 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[] = { - 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; - } - - /// - /// @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; - - // 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 - /// @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. -#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>()}; - } -#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; } - - -} -#endif diff --git a/hwpf/plat/include/hw_access.H b/hwpf/plat/include/hw_access.H deleted file mode 100644 index 047176a7..00000000 --- a/hwpf/plat/include/hw_access.H +++ /dev/null @@ -1,606 +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 Defines the hardware access functions for PPE platforms that - * don't leverage FAPI2 return codes. - */ - -#ifndef FAPI2_HWACCESS_H_ -#define FAPI2_HWACCESS_H_ - - -// variable_buffer isn't supported on PPE -#ifndef __PPE__ -#include <variable_buffer.H> -#endif - -#include <utils.H> -#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 - void setPIBErrorMask(uint8_t i_mask) - { - PLAT_SET_PIB_ERROR_MASK(i_mask); - } - - /// @brief Gets the PIB error mask - platform dependant - /// @return uint8_t The current PIB error mask - uint8_t getPIBErrorMask(void) - { - PLAT_GET_PIB_ERROR_MASK(o_pib_mask); - return o_pib_mask; - } - - //-------------------------------------------------------------------------- - // 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 - //-------------------------------------------------------------------------- - - /// @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 fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K > - inline void getScom(const Target<K>& i_target, const uint64_t i_address, - buffer<uint64_t>& o_data) - { - - PLAT_GETSCOM(current_err, - i_target, - (uint32_t)(i_address ), - &(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 fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K > - inline void putScom(const Target<K>& i_target, const uint64_t i_address, - buffer<uint64_t> i_data) - { - - PLAT_PUTSCOM(current_err, - i_target, - (uint32_t)(i_address ), - i_data()); - } - - /// @brief Read-modify-write 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 be modified. - /// @param[in] i_modifyMode The modify mode (or/and/xor). - /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K > - inline void modifyScom( const Target<K>& i_target, - const uint64_t i_address, - const buffer<uint64_t> i_data, - const ChipOpModifyMode i_modifyMode) - { - fapi2::buffer<uint64_t> l_modifyDataBuffer; - - PLAT_GETSCOM(current_err, - i_target, - (uint32_t)(i_address ), - &(l_modifyDataBuffer())); - - if ( i_modifyMode == CHIP_OP_MODIFY_MODE_OR) - { - l_modifyDataBuffer |= i_data; - } - - if ( i_modifyMode == CHIP_OP_MODIFY_MODE_AND) - { - l_modifyDataBuffer &= i_data; - } - - if ( i_modifyMode == CHIP_OP_MODIFY_MODE_XOR) - { - l_modifyDataBuffer ^= i_data; - } - - PLAT_PUTSCOM(current_err, - i_target, - (uint32_t)(i_address ), - l_modifyDataBuffer()); - return; - } - - /// @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 fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K > - inline void putScomUnderMask(const Target<K>& i_target, - const uint64_t i_address, - buffer<uint64_t> i_data, - buffer<uint64_t> i_mask) - { - fapi2::buffer<uint64_t> l_modifyDataBuffer = i_data; - - l_modifyDataBuffer &= i_mask; - - PLAT_PUTSCOM(current_err, - i_target, - (uint32_t)(i_address ), - l_modifyDataBuffer()); - return; - } - - - /// @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 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) - { - PLAT_GETCFAM(i_target.get(), - (uint32_t)(i_address & BITS(40,24)), - &(o_data())); - - return FAPI2_RC_SUCCESS; - } - - /// @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 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, - buffer<uint32_t>& i_data) - { - PLAT_PUTCFAM(i_target.get(), - (uint32_t)(i_address & BITS(40,24)), - &(i_data())); - - return FAPI2_RC_SUCCESS; - } - - /// @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 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 ChipOpModifyMode i_modifyMode) - { - PLAT_MODCFAM(i_target.get(), - (uint32_t)(i_address & BITS(40,24)), - &(i_data()), - i_modifyMode); - - return FAPI2_RC_SUCCESS; - } - - // 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 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 = 0) - { - o_data.setBit(0); - o_data.setBit(3); -#ifndef __PPE__ - std::cout << std::hex << " getRing " - << "target: {" << i_target.getType() << "," - << uint64_t(i_target) << "}; " - << "ring address: " << i_address << "; " - << "ring mode: " << i_ringMode << "; " - << "output data:"; - o_data.print(); -#endif - - return FAPI2_RC_SUCCESS; - } - - /// @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 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, - variable_buffer& i_data, - const RingMode i_ringMode = 0) - { - - return FAPI2_RC_SUCCESS; - } - - - /// @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 Pointer to location 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 void* i_data, - const RingMode i_ringMode = 0) - { - uint64_t* dataPtr = reinterpret_cast<uint64_t*>(const_cast<void*>(i_data)); - - return FAPI2_RC_SUCCESS; - } - - /// @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 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, - variable_buffer& i_data, - const ChipOpModifyMode i_modifyMode, - const RingMode i_ringMode = 0) - { - - 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/hwpf/plat/include/hwp_executor.H b/hwpf/plat/include/hwp_executor.H deleted file mode 100644 index 5a451081..00000000 --- a/hwpf/plat/include/hwp_executor.H +++ /dev/null @@ -1,59 +0,0 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// fipsrefactordoc src/hwpf/plat/fapi2PlatHwpExecutor.H 1.1 -// -// IBM CONFIDENTIAL -// -// OBJECT CODE ONLY SOURCE MATERIALS -// -// COPYRIGHT International Business Machines Corp. 2011 -// All Rights Reserved -// -// 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 fapi2PlatHwpExecutor.H - * - * @brief Defines the FAPI HWP Executor Macro. - * - * The HWP Executor macro is called when a PLAT invoker function or a HWP wants - * to execute a HWP. Each platform can modify the macro to do any platform - * specific work to execute the HWP (e.g. dlopening a shared library) - */ - -#ifndef FAPI2PLATHWPEXECUTOR_H_ -#define FAPI2PLATHWPEXECUTOR_H_ - -/** - * @brief HWP Executor macro - * - * By default, this macro just calls the HWP directly. If this cannot be done - * then the platform needs to modify - */ - -#include <return_code.H> -#include <target.H> -#include <string> - - - -// Macro to execute an arbitrary function with an arbitray number of arguments. The -// function is in a shared lib that must be dlopened. All that is required is that -// there is a typedef for the function pointer available that is called <FUNC>_FP_t -// i.e. if the function is called foo, then the typedef is called foo_FP_t -#define FAPI_PLAT_EXEC_HWP(RC, FUNC, _args_...) \ -{\ - RC = FUNC(_args_); \ -} - -#define FAPI_PLAT_EXEC_HWP_LAMBDA(FUNC, _args_...) \ -[&]()->fapi2::ReturnCode \ -{\ - FUNC(_args_); \ -}() - -#endif // FAPI2PLATHWPEXECUTOR_H_ diff --git a/hwpf/plat/include/hwp_ffdc_classes.H b/hwpf/plat/include/hwp_ffdc_classes.H deleted file mode 100644 index e69de29b..00000000 --- a/hwpf/plat/include/hwp_ffdc_classes.H +++ /dev/null diff --git a/hwpf/plat/include/plat_attributes.H b/hwpf/plat/include/plat_attributes.H deleted file mode 100644 index 894d516d..00000000 --- a/hwpf/plat/include/plat_attributes.H +++ /dev/null @@ -1,37 +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 plat_attributes.H - * @brief Platform specific attribute headers - */ - -#ifndef __PLAT_ATTTRIBUTE_H__ -#define __PLAT_ATTTRIBUTE_H__ - -#include <fapi2AttributeService.H> -#include <fapi2AttributeIds.H> // Generated file -//#include <plat_target_pg_attributes.H> - -#endif // __PLAT_ATTTRIBUTE_H__ diff --git a/hwpf/plat/include/plat_error_scope.H b/hwpf/plat/include/plat_error_scope.H deleted file mode 100644 index a2de6bd5..00000000 --- a/hwpf/plat/include/plat_error_scope.H +++ /dev/null @@ -1,65 +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 plat_error_scope.H - * @brief platform definitions which create a scope for automatic error handling - */ - -#ifndef __FAPI2_PLAT_ERROR_SCOPE__ -#define __FAPI2_PLAT_ERROR_SCOPE__ - -/// @cond -#define PLAT_FAPI_TRY_NO_TRACE( __operation__ ) \ - (__operation__) - -#define PLAT_FAPI_TRY_TRACE( __operation__, ... ) \ - FAPI_DBG(__VA_ARGS)); \ - (__operation__) - -/// -/// @brief Assert a conditional is true. -/// If it is not, the FFDC gathering function is called and the -/// trace is output as a FAPI error trace. -/// @param[in] __conditional__ the condition to assert -/// @param[in] __ffdc__ the FFDC gathering function -/// @param[in] ... varargs, as input to FAPI_ERR -/// -#define PLAT_FAPI_ASSERT( __conditional__, __ffdc__, ... ) \ - if (! (__conditional__)) \ - { \ - (__ffdc__).execute(); \ - FAPI_ERR(__VA_ARGS__); \ - goto fapi_try_exit; \ - } - - -/// -/// @brief Temporary macro for error label until all are removed. -/// @todo REMOVE this in time. -#define FAPI_CLEANUP() \ -fapi_try_exit: -/// @endcond - -#endif diff --git a/hwpf/plat/include/plat_hw_access.H b/hwpf/plat/include/plat_hw_access.H deleted file mode 100644 index 7d8e3c86..00000000 --- a/hwpf/plat/include/plat_hw_access.H +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @file plat_hw_access.H - * - * @brief Define platform specific calls for PPE Platforms that use the machine - * check function of the PPE to deal with errors (eg no explicit return codes - * returned) - */ - -#ifndef PLATHWACCESS_H_ -#define PLATHWACCESS_H_ - -#include <plat_includes.H> - -/// PIB Error Mask - -#define PLAT_SET_PIB_ERROR_MASK(_m_mask) \ - { /* Read MSR */ \ - uint32_t msr_data = mfmsr(); \ - /* Set SEM field */ \ - msr_data &= ~(BITS(0,8)); \ - msr_data |= (uint32_t)(i_mask << 24); \ - /* Write MSR */ \ - mtmsr(msr_data); \ - }; - -#define PLAT_GET_PIB_ERROR_MASK(_m_mask) \ - uint8_t _m_mask; \ - uint32_t _sem = mfmsr(); \ - _m_mask = (uint8_t)((_sem & MSR_SEM) >> (32-(MSR_SEM_START_BIT + MSR_SEM_LEN))); - -// Building block PPE instructions -#define PPE_MFMSR(_m_data) \ -asm volatile \ - ( \ - "mfmsr %[data] \n" \ - : [data]"=&r"(*_m_data) \ - : "[data]"(*_m_data) \ - ); - -#define PPE_MTMSR(_m_data) \ -asm volatile \ - ( \ - "mtmsr %[data] \n" \ - : [data]"=&r"(*_m_data) \ - : "[data]"(*_m_data) \ - ); - - -/// GetScom -#define PLAT_GETSCOM(_m_rc, _m_base, _m_offset, _m_data) \ - PPE_LVDX(_m_base.getAddressOverlay(), (uint32_t)(_m_offset & BITS(40,24)), _m_data) - -/// PutScom -#define PLAT_PUTSCOM(_m_rc, _m_base, _m_offset, _m_data) \ - PPE_STVDX(_m_base.getAddressOverlay(), (uint32_t)(_m_offset & BITS(40,24)), _m_data) - -/// ModifyScom -#define PLAT_MODSCOM(_m_base, _m_offset, _m_data, _m_mode) \ - PPE_STVDX(_m_base.getAddressOverlay(), _m_offset, _m_data) - - -/// GetCFAM -#define PLAT_GETCFAM(_m_base, _m_offset, _m_data) \ - static_assert( K == TARGET_TYPE_NONE, \ - "getCfamRegister is not supported by PPE platforms") - -/// PutCFAM -#define PLAT_PUTCFAM(_m_base, _m_offset, _m_data) \ - static_assert( K == TARGET_TYPE_NONE, \ - "putCfamRegister is not supported by PPE platforms") - -/// ModifyCFAM -#define PLAT_MODCFAM(_m_base, _m_offset, _m_data, _m_mode) \ - static_assert( K == TARGET_TYPE_NONE, \ - "modifyCfamRegister is not supported by PPE platforms") - -#endif // PLATHWACCESS_H_ - diff --git a/hwpf/plat/include/plat_includes.H b/hwpf/plat/include/plat_includes.H deleted file mode 100644 index 97074b67..00000000 --- a/hwpf/plat/include/plat_includes.H +++ /dev/null @@ -1,40 +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 plat_includes.H - * @brief Platform specific include to implement FAPI2 APIs - */ - -#ifndef __PLAT_INCLUDES_H__ -#define __PLAT_INCLUDES_H__ - -#include <plat_hw_access.H> - -#include <ppe42_scom.h> -#include <ppe42_msr.h> -//#include <pk.h> - - -#endif // __PLAT_INCLUDES_H__ diff --git a/hwpf/plat/include/plat_target.H b/hwpf/plat/include/plat_target.H deleted file mode 100644 index 1e6a5b70..00000000 --- a/hwpf/plat/include/plat_target.H +++ /dev/null @@ -1,45 +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 plat_target.H - * @brief platform definitions for fapi2 targets - */ - -#ifndef __FAPI2_PLAT_TARGET__ -#define __FAPI2_PLAT_TARGET__ - -#include <return_code.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/hwpf/plat/include/plat_target_definitions.H b/hwpf/plat/include/plat_target_definitions.H deleted file mode 100644 index c2ec0518..00000000 --- a/hwpf/plat/include/plat_target_definitions.H +++ /dev/null @@ -1,112 +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 plat_ppe_target.H - * @brief Definitions for fapi2 PPE targets - */ - -#ifndef __FAPI2_PPE_TARGET__ -#define __FAPI2_PPE_TARGET__ - -#define TARGET_CHIP(_name, _index) \ - fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP > _name((uint64_t)_index); - -#define TARGET_CHIP_PERV(_name, _index) \ - fapi2::Target<fapi2::TARGET_TYPE_PERV> _name((uint64_t)_index); - -#define TARGET_EQ(_name, _index) \ - fapi2::Target<fapi2::TARGET_TYPE_EQ> _name((uint64_t)_index); - -#define TARGET_CORE(_name, _index) \ - fapi2::Target<fapi2::TARGET_TYPE_CORE> _name((uint64_t)_index); - -#define TARGET_EX(_name, _index) \ - fapi2::Target<fapi2::TARGET_TYPE_EX> _name((uint64_t)_index); - -namespace fapi2 -{ - - TARGET_CHIP (chip_target, 0); - TARGET_CHIP_PERV (perv_target, 1); - TARGET_CHIP_PERV (n0_target, 2); - TARGET_CHIP_PERV (n1_target, 3); - TARGET_CHIP_PERV (n2_target, 4); - TARGET_CHIP_PERV (n3_target, 5); - TARGET_CHIP_PERV (xb_target, 6); - TARGET_CHIP_PERV (mc0_target, 7); - TARGET_CHIP_PERV (mc1_target, 8); - TARGET_CHIP_PERV (ob0_target, 9); - TARGET_CHIP_PERV (ob1_target, 10); - TARGET_CHIP_PERV (ob2_target, 11); - TARGET_CHIP_PERV (ob3_target, 12); - TARGET_CHIP_PERV (pci0_target, 13); - TARGET_CHIP_PERV (pci1_target, 14); - TARGET_CHIP_PERV (pci2_target, 15); - TARGET_EQ (eq0_target, 0); - TARGET_EQ (eq1_target, 1); - TARGET_EQ (eq2_target, 2); - TARGET_EQ (eq3_target, 3); - TARGET_EQ (eq4_target, 4); - TARGET_EQ (eq5_target, 5); - TARGET_EX (ex0_target, 0); - TARGET_EX (ex1_target, 1); - TARGET_EX (ex2_target, 2); - TARGET_EX (ex3_target, 3); - TARGET_EX (ex4_target, 4); - TARGET_EX (ex5_target, 5); - TARGET_EX (ex6_target, 6); - TARGET_EX (ex7_target, 7); - TARGET_EX (ex8_target, 8); - TARGET_EX (ex9_target, 9); - TARGET_EX (ex10_target, 10); - TARGET_EX (ex11_target, 11); - TARGET_CORE (core0_target, 0); - TARGET_CORE (core1_target, 1); - TARGET_CORE (core2_target, 2); - TARGET_CORE (core3_target, 3); - TARGET_CORE (core4_target, 4); - TARGET_CORE (core5_target, 5); - TARGET_CORE (core6_target, 6); - TARGET_CORE (core7_target, 7); - TARGET_CORE (core8_target, 8); - TARGET_CORE (core9_target, 9); - TARGET_CORE (core10_target,10); - TARGET_CORE (core11_target,11); - TARGET_CORE (core12_target,12); - TARGET_CORE (core13_target,13); - TARGET_CORE (core14_target,14); - TARGET_CORE (core15_target,15); - TARGET_CORE (core16_target,16); - TARGET_CORE (core17_target,17); - TARGET_CORE (core18_target,18); - TARGET_CORE (core19_target,19); - TARGET_CORE (core20_target,20); - TARGET_CORE (core21_target,21); - TARGET_CORE (core22_target,22); - TARGET_CORE (core23_target,23); - -}; // fapi2 namespace - -#endif // __FAPI2_PPE_TARGET__ diff --git a/hwpf/plat/include/plat_target_parms.H b/hwpf/plat/include/plat_target_parms.H deleted file mode 100644 index ab78a3c5..00000000 --- a/hwpf/plat/include/plat_target_parms.H +++ /dev/null @@ -1,74 +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 plat_ppe_target.H - * @brief Definitions for fapi2 PPE targets - */ - -#ifndef __FAPI2_PPE_TARGET_PARMS__ -#define __FAPI2_PPE_TARGET_PARMS__ - -#include "fapi_sbe_common.H" - - -CONST_UINT32_T(CHIP_TARGET_OFFSET, 0); -CONST_UINT32_T(CHIP_TARGET_COUNT , 1); - -// Pervasive Targets (note; these include the MCS targets as well) -CONST_UINT32_T(PERV_TARGET_OFFSET, CHIP_TARGET_OFFSET + CHIP_TARGET_COUNT); -CONST_UINT32_T(PERV_CHIPLET_OFFSET, 0x1); -CONST_UINT32_T(PERV_TARGET_COUNT, 15); - -// Cache Targets -CONST_UINT32_T(EQ_TARGET_OFFSET, PERV_TARGET_OFFSET + PERV_TARGET_COUNT); -CONST_UINT32_T(EQ_CHIPLET_OFFSET, 0x10); -CONST_UINT32_T(EQ_TARGET_COUNT, 6); - -// Core Targets -CONST_UINT32_T(CORE_TARGET_OFFSET, EQ_TARGET_OFFSET + EQ_TARGET_COUNT); -CONST_UINT32_T(CORE_CHIPLET_OFFSET, 0x20); -CONST_UINT32_T(CORE_TARGET_COUNT, 24); - -// MCS Targets (note: these are phyically Pervastive targets) -CONST_UINT32_T(MCS_TARGET_OFFSET, CORE_TARGET_OFFSET + CORE_TARGET_COUNT); -CONST_UINT32_T(MCS_CHIPLET_OFFSET, 0x7); -CONST_UINT32_T(MCS_TARGET_COUNT, 2); - -CONST_UINT32_T(EX_TARGET_OFFSET, MCS_TARGET_OFFSET + MCS_TARGET_COUNT); -CONST_UINT32_T(EX_CHIPLET_OFFSET, 0x10); -CONST_UINT32_T(EX_TARGET_COUNT, 12); - -CONST_UINT32_T(SYSTEM_TARGET_OFFSET, EX_TARGET_OFFSET + EX_TARGET_COUNT); -CONST_UINT32_T(SYSTEM_TARGET_COUNT, 1); - -CONST_UINT32_T(TARGET_COUNT, CHIP_TARGET_COUNT + - PERV_TARGET_COUNT + - EQ_TARGET_COUNT + - CORE_TARGET_COUNT + - MCS_TARGET_COUNT + - EX_TARGET_COUNT + - SYSTEM_TARGET_COUNT); - -#endif // __FAPI2_PPE_TARGET_PARMS__ diff --git a/hwpf/plat/include/plat_target_pg_attributes.H b/hwpf/plat/include/plat_target_pg_attributes.H deleted file mode 100644 index e27a1784..00000000 --- a/hwpf/plat/include/plat_target_pg_attributes.H +++ /dev/null @@ -1,97 +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 plat_target_pg_attribute.H - * @brief Definitions for fapi2 PPE targets' partial good attribute mapping - */ - -#ifndef __FAPI2_PPE_TARGET_PG_ATTR__ -#define __FAPI2_PPE_TARGET_PG_ATTR__ - - -typedef struct chiplet_pg_entry_t -{ - // char[16] pg_attribute; - uint32_t pg_attribute; - uint8_t target_type; - uint16_t relative_target_num; -} chiplet_pg_entry_t; - -const chiplet_pg_entry_t CHIPLET_PG_ARRAY[] = -{ - // Pervasive Chiplets - { fapi2::ATTR_PG_PRV , fapi2::TARGET_TYPE_PERV, 0x01 }, - { fapi2::ATTR_PG_N0 , fapi2::TARGET_TYPE_PERV, 0x02 }, - { fapi2::ATTR_PG_N1 , fapi2::TARGET_TYPE_PERV, 0x03 }, - { fapi2::ATTR_PG_N2 , fapi2::TARGET_TYPE_PERV, 0x04 }, - { fapi2::ATTR_PG_N3 , fapi2::TARGET_TYPE_PERV, 0x05 }, - { fapi2::ATTR_PG_XB , fapi2::TARGET_TYPE_PERV, 0x06 }, - { fapi2::ATTR_PG_MC01, fapi2::TARGET_TYPE_PERV, 0x07 }, - { fapi2::ATTR_PG_MC23, fapi2::TARGET_TYPE_PERV, 0x08 }, - { fapi2::ATTR_PG_OB0 , fapi2::TARGET_TYPE_PERV, 0x09 }, - { fapi2::ATTR_PG_OB1 , fapi2::TARGET_TYPE_PERV, 0x0A }, - { fapi2::ATTR_PG_OB2 , fapi2::TARGET_TYPE_PERV, 0x0B }, - { fapi2::ATTR_PG_OB3 , fapi2::TARGET_TYPE_PERV, 0x0C }, - { fapi2::ATTR_PG_PCI0, fapi2::TARGET_TYPE_PERV, 0x0D }, - { fapi2::ATTR_PG_PCI1, fapi2::TARGET_TYPE_PERV, 0x0E }, - { fapi2::ATTR_PG_PCI2, fapi2::TARGET_TYPE_PERV, 0x0F }, - // EQ Chiplets - { fapi2::ATTR_PG_EQ0 , fapi2::TARGET_TYPE_EQ, 0x00 }, - { fapi2::ATTR_PG_EQ1 , fapi2::TARGET_TYPE_EQ, 0x01 }, - { fapi2::ATTR_PG_EQ2 , fapi2::TARGET_TYPE_EQ, 0x02 }, - { fapi2::ATTR_PG_EQ3 , fapi2::TARGET_TYPE_EQ, 0x03 }, - { fapi2::ATTR_PG_EQ4 , fapi2::TARGET_TYPE_EQ, 0x04 }, - { fapi2::ATTR_PG_EQ5 , fapi2::TARGET_TYPE_EQ, 0x05 }, - // Core Chiplets - { fapi2::ATTR_PG_EC00, fapi2::TARGET_TYPE_CORE, 0x00 }, - { fapi2::ATTR_PG_EC01, fapi2::TARGET_TYPE_CORE, 0x01 }, - { fapi2::ATTR_PG_EC02, fapi2::TARGET_TYPE_CORE, 0x02 }, - { fapi2::ATTR_PG_EC03, fapi2::TARGET_TYPE_CORE, 0x03 }, - { fapi2::ATTR_PG_EC04, fapi2::TARGET_TYPE_CORE, 0x04 }, - { fapi2::ATTR_PG_EC05, fapi2::TARGET_TYPE_CORE, 0x05 }, - { fapi2::ATTR_PG_EC06, fapi2::TARGET_TYPE_CORE, 0x06 }, - { fapi2::ATTR_PG_EC07, fapi2::TARGET_TYPE_CORE, 0x07 }, - { fapi2::ATTR_PG_EC08, fapi2::TARGET_TYPE_CORE, 0x08 }, - { fapi2::ATTR_PG_EC09, fapi2::TARGET_TYPE_CORE, 0x09 }, - { fapi2::ATTR_PG_EC10, fapi2::TARGET_TYPE_CORE, 0x0A }, - { fapi2::ATTR_PG_EC11, fapi2::TARGET_TYPE_CORE, 0x0B }, - { fapi2::ATTR_PG_EC12, fapi2::TARGET_TYPE_CORE, 0x0C }, - { fapi2::ATTR_PG_EC13, fapi2::TARGET_TYPE_CORE, 0x0D }, - { fapi2::ATTR_PG_EC14, fapi2::TARGET_TYPE_CORE, 0x0E }, - { fapi2::ATTR_PG_EC15, fapi2::TARGET_TYPE_CORE, 0x0F }, - { fapi2::ATTR_PG_EC16, fapi2::TARGET_TYPE_CORE, 0x10 }, - { fapi2::ATTR_PG_EC17, fapi2::TARGET_TYPE_CORE, 0x11 }, - { fapi2::ATTR_PG_EC18, fapi2::TARGET_TYPE_CORE, 0x12 }, - { fapi2::ATTR_PG_EC19, fapi2::TARGET_TYPE_CORE, 0x13 }, - { fapi2::ATTR_PG_EC20, fapi2::TARGET_TYPE_CORE, 0x14 }, - { fapi2::ATTR_PG_EC21, fapi2::TARGET_TYPE_CORE, 0x15 }, - { fapi2::ATTR_PG_EC22, fapi2::TARGET_TYPE_CORE, 0x16 }, - { fapi2::ATTR_PG_EC23, fapi2::TARGET_TYPE_CORE, 0x17 } -}; - -uint32_t CHIPLET_PG_ARRAY_ENTRIES = sizeof(CHIPLET_PG_ARRAY) / - sizeof(chiplet_pg_entry_t); - -#endif // __FAPI2_PPE_TARGET_PG_ATTR__ diff --git a/hwpf/plat/include/plat_target_utils.H b/hwpf/plat/include/plat_target_utils.H deleted file mode 100644 index e1e360c0..00000000 --- a/hwpf/plat/include/plat_target_utils.H +++ /dev/null @@ -1,48 +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 plat_target_util.H - * @brief platform utility definitions for fapi2 targets - */ - -#ifndef __FAPI2_PLAT_TARGET_UTIL__ -#define __FAPI2_PLAT_TARGET_UTIL__ - -// -// Platform Utility functions.. -// -namespace fapi2 -{ - - /// @brief Function to initialize the G_targets vector based on partial good - /// attributes - ReturnCode plat_TargetsInit(); - - /// @brief Function to initialize the G_targets vector based on partial good - /// attributes - Target<TARGET_TYPE_PROC_CHIP> plat_getChipTarget(); - -} -#endif diff --git a/hwpf/plat/include/plat_trace.H b/hwpf/plat/include/plat_trace.H deleted file mode 100644 index 423ef6ea..00000000 --- a/hwpf/plat/include/plat_trace.H +++ /dev/null @@ -1,86 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: $ */ -/* */ -/* OpenPOWER HostBoot Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2011,2015 */ -/* [+] 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 plat_trace.H - * @brief Defines the FAPI2 trace macros. - * - * Note that platform code must provide the implementation. - * - * FAPI has provided a default implementation. Platform code must - * provide an alternate implementation if needed. - */ - -#ifndef FAPI2_PLATTRACE_H_ -#define FAPI2_PLATTRACE_H_ - -#include <stdio.h> -#include <stdint.h> - -// @todo update these headers with extern "C" in a future commit -// or not and leave this just as it is. -extern "C" -{ -#include "pk.h" -#include <pk_trace.h> -#include "trac_interface.h" -} - -// Why not a #define, why is this in the fapi2 namespace? -// To prevent problems with Cronus and the fapi1 definitions. -namespace fapi2 -{ - static const uint32_t MAX_ECMD_STRING_LEN = 64; -}; - -// Information traces (go into fast trace buffer that can wrap often) -#define FAPI_TRACE(_id_, _fmt_, _args_...) \ - PK_TRACE(_fmt_, ##_args_); - - -/* The following is a desirous trace entry but the second line has a - compilation issue that is unresolved - -#define FAPI_TRACE(_id_, _fmt_, _args_...) \ - PK_TRACE("%s: %s:%d ", _id_, __FUNCTION__, __LINE__); \ - PK_TRACE(_fmt_, ##_args_); -*/ - -#define FAPI_INF(_fmt_, _args_...) FAPI_TRACE("inf", _fmt_, ##_args_) - -// Important traces (go into slow trace buffer that should not wrap often) -#define FAPI_IMP(_fmt_, _args_...) FAPI_TRACE("imp", _fmt_, ##_args_) - -// Error traces (go into slow trace buffer that should not wrap often) -#define FAPI_ERR(_fmt_, _args_...) FAPI_TRACE("err", _fmt_, ##_args_) - -// Debug traces (go into fast trace buffer that can wrap often) -#define FAPI_DBG(_fmt_, _args_...) FAPI_TRACE("dbg", _fmt_, ##_args_) - -// Scan traces -#define FAPI_SCAN(_fmt_, _args_...) FAPI_TRACE("scan", _fmt_, ##_args_) - -#define FAPI_MFG(_fmt_, _args_...) FAPI_TRACE("mfg", _fmt_, ##_args_) - -#endif // FAPI2_PLATTRACE_H_ diff --git a/hwpf/plat/include/return_code.H b/hwpf/plat/include/return_code.H deleted file mode 100644 index fd2f7c29..00000000 --- a/hwpf/plat/include/return_code.H +++ /dev/null @@ -1,108 +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 return_code.H - * @brief definitions for fapi2 return codes - */ - -#ifndef __FAPI2_RETURN_CODE__ -#define __FAPI2_RETURN_CODE__ - -#include <stdint.h> -#include <return_code_defs.H> - -#ifndef FAPI2_NO_FFDC - #include <ffdc.H> -#endif - -namespace fapi2 -{ - /// - /// @brief Class representing a FAPI2 ReturnCode - /// - // Remove the inheritance relationship with FirstFailureData if - // the platform doesn't support FFDC. -#ifdef FAPI2_NO_FFDC - class ReturnCode -#else - class ReturnCode : public FirstFailureData<ReturnCode> -#endif - { - public: - - /// - /// @brief Constructor. - /// @param[in] i_rc the rc to set - /// - ReturnCode(const uint64_t i_rc = FAPI2_RC_SUCCESS): - iv_rc(i_rc) - {}; - - /// - /// @brief integral type conversion function. Returns the error code - /// @return The error code - /// - inline operator uint64_t() const { return iv_rc; } - - /// - /// @brief Returns true iff iv_rc == SUCCESS - /// @return true or false - /// - inline operator bool() const { return iv_rc == FAPI2_RC_SUCCESS; } - - /// - /// @brief Assignement operator - /// -#ifdef DOXYGEN - inline ReturnCode& operator=(const uint64_t& rhs) - inline ReturnCode& operator=(const ReturnCodes& rhs) -#endif - - inline bool operator==(const uint64_t& rhs) const - { return rhs == iv_rc; } - - inline bool operator==(const ReturnCodes& rhs) const - { return rhs == iv_rc; } - - inline bool operator!=(const uint64_t& rhs) const - { return rhs != iv_rc; } - - inline bool operator!=(const ReturnCodes& rhs) const - { return rhs != iv_rc; } - - private: - uint64_t iv_rc; - }; - - /// This implementation assumes no exception handling and leverages thread-local - /// storage. For platforms without thread support, a global variable will - /// suffice for the error state. -// extern thread_local ReturnCode current_err; /// the current error state - extern ReturnCode current_err; /// the current error state - extern thread_local uint64_t pib_error_mask; /// the pib mask - extern thread_local uint64_t operational_state; /// the operational mode -} - -#endif diff --git a/hwpf/plat/include/set_sbe_error.H b/hwpf/plat/include/set_sbe_error.H deleted file mode 100644 index e69de29b..00000000 --- a/hwpf/plat/include/set_sbe_error.H +++ /dev/null diff --git a/hwpf/plat/include/target.H b/hwpf/plat/include/target.H deleted file mode 100644 index 0c40642b..00000000 --- a/hwpf/plat/include/target.H +++ /dev/null @@ -1,342 +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 <plat_target_parms.H> -#include <fapi2_target.H> -#include <plat_trace.H> -#include <utils.H> -#include <stdio.h> -#include <stdint.h> -#include <vector> - -extern "C" -{ - extern std::vector<fapi2::plat_target_handle_t> G_vec_targets; -} - -namespace fapi2 -{ - /// @brief Create a Target, with a value - /// @param[in] Value the value (i.e., specific element this - /// target represents, or pointer) - /// @note Platforms can mangle the value and K to get a - /// single uint64_t in value which represents all the information - /// they might need. value( K | V ), for example - /// - template<TargetType K, typename V> - Target<K, V>::Target(V Value) - { - static_assert( ((K == TARGET_TYPE_CORE) & - (K == TARGET_TYPE_EQ) ) != true, - "TARGET_TYPE_CORE and TARGET_TYPE_EQ cannot be specified at the same time"); - - this->iv_handle.value = 0; - if(K & TARGET_TYPE_PROC_CHIP) - { - this->iv_handle.fields.chiplet_num = 0; - this->iv_handle.fields.type = TARGET_TYPE_PROC_CHIP; - this->iv_handle.fields.type_target_num = 0; - } - - if(K & TARGET_TYPE_PERV) - { - this->iv_handle.fields.chiplet_num = Value; - this->iv_handle.fields.type = TARGET_TYPE_PERV; - this->iv_handle.fields.type_target_num = Value; - } - - if(K & TARGET_TYPE_CORE) - { - this->iv_handle.fields.chiplet_num = Value + CORE_CHIPLET_OFFSET; - this->iv_handle.fields.type = TARGET_TYPE_CORE | TARGET_TYPE_PERV; - this->iv_handle.fields.type_target_num = Value; - } - - if(K & TARGET_TYPE_EQ) - { - this->iv_handle.fields.chiplet_num = Value + EQ_CHIPLET_OFFSET; - this->iv_handle.fields.type = TARGET_TYPE_EQ | TARGET_TYPE_PERV; - this->iv_handle.fields.type_target_num = Value; - } - - if(K & TARGET_TYPE_EX) - { - - this->iv_handle.fields.chiplet_num = (Value / 2) + EX_CHIPLET_OFFSET; - this->iv_handle.fields.type = TARGET_TYPE_EX | TARGET_TYPE_PERV; - this->iv_handle.fields.type_target_num = Value; - } - - if(K & TARGET_TYPE_MCS) - { - - this->iv_handle.fields.chiplet_num = Value + MCS_CHIPLET_OFFSET; - this->iv_handle.fields.type = TARGET_TYPE_MCS | TARGET_TYPE_PERV; - this->iv_handle.fields.type_target_num = Value; - } - - if(K == TARGET_TYPE_ALL) - { - this->iv_handle.fields.chiplet_num = Value; - this->iv_handle.fields.type = TARGET_TYPE_ALL; - } - this->iv_handle.fields.address_overlay = - (this->iv_handle.fields.chiplet_num << 24); - - } - - /// - /// @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) - { - this->iv_handle.value = i_right->iv_handle.value; - 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 - { - if (this->iv_handle.value == i_right->iv_handle.value) - return true; - else - return false; - } - - /// - /// @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 - { - if (this->iv_handle.value != i_right->iv_handle.value) - return true; - else - return false; - } - - /// - /// @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 - { - return this->iv_handle.value; - } - - /// - /// @brief Get this target's children - /// @tparam K The type of the parent - /// @tparam T The type of child - /// @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 - { -#define INVALID_CHILD(PARENT, CHILD) \ - static_assert(!((K == PARENT) && (T == CHILD)), \ - #CHILD " is not a child of " #PARENT ); - - // invalid children for proc -// INVALID_CHILD(fapi2::TARGET_TYPE_PROC_CHIP, fapi2::TARGET_TYPE_NONE) -// INVALID_CHILD(fapi2::TARGET_TYPE_PROC_CHIP, fapi2::TARGET_TYPE_SYSTEM) -// INVALID_CHILD(fapi2::TARGET_TYPE_PROC_CHIP, fapi2::TARGET_TYPE_DIMM) -// INVALID_CHILD(fapi2::TARGET_TYPE_PROC_CHIP, fapi2::TARGET_TYPE_PROC_CHIP) -// INVALID_CHILD(fapi2::TARGET_TYPE_PROC_CHIP, fapi2::TARGET_TYPE_MEMBUF_CHIP) -// INVALID_CHILD(fapi2::TARGET_TYPE_PROC_CHIP, fapi2::TARGET_TYPE_MBA) -#undef INVALID_CHILD - -#define INVALID_PARENT(PARENT) \ - static_assert(!((K == PARENT)), \ - #PARENT "is not supported on PPE platforms"); - - // invalid parents -// INVALID_PARENT(fapi2::TARGET_TYPE_SYSTEM) -// INVALID_PARENT(fapi2::TARGET_TYPE_MEMBUF_CHIP) -// INVALID_PARENT(fapi2::TARGET_TYPE_L4) -// INVALID_PARENT(fapi2::TARGET_TYPE_DIMM) -// INVALID_PARENT(fapi2::TARGET_TYPE_MCA) -// INVALID_PARENT(fapi2::TARGET_TYPE_MBA) -// INVALID_PARENT(fapi2::TARGET_TYPE_MI) -// INVALID_PARENT(fapi2::TARGET_TYPE_MCBIST) -// INVALID_PARENT(fapi2::TARGET_TYPE_DMI) -#undef INVALID_PARENT - - // valid children for EQ - // EQ -> CORE - // EQ -> EX - static_assert(!((K == fapi2::TARGET_TYPE_EQ) && - (T != fapi2::TARGET_TYPE_CORE) && - (T != fapi2::TARGET_TYPE_EX)), - "improper child of fapi2::TARGET_TYPE_EQ"); - - // valid children for EX - // EX -> CORE - static_assert(!((K == fapi2::TARGET_TYPE_EX) && - (T != fapi2::TARGET_TYPE_CORE)), - "improper child of fapi2::TARGET_TYPE_EX"); - - // Nimbus Memory - // valid children for MCS - // MCS -> MCA -// static_assert(!((K == fapi2::TARGET_TYPE_MCS) && -// (T != fapi2::TARGET_TYPE_MCA)), -// "improper child of fapi2::TARGET_TYPE_MCS"); - - - std::vector<fapi2::plat_target_handle_t>::iterator l_iter; - FAPI_DBG("getChildren: initializing children vector"); - std::vector<Target<T> > l_children; - - - - uint32_t c = 0; - for (l_iter = G_vec_targets.begin(); l_iter != G_vec_targets.end(); ++l_iter) - { - - Target<T> * l_temp = reinterpret_cast< Target<T>* >(l_iter); - if (((*l_temp).getTargetType() & T) == T) - { - switch (i_state) - { - case TARGET_STATE_PRESENT: - if ((*l_temp).getPresent()) - { - l_children.push_back((*l_temp)); -// FAPI_DBG("Pushing getChildren present 0x%08X", (uint32_t)(((*l_temp)).get()>>32)); - } - break; - case TARGET_STATE_FUNCTIONAL: - if ((*l_temp).getFunctional()) - { - l_children.push_back((*l_temp)); -// FAPI_DBG("Pushing getChildren functional 0x%08X", (uint32_t)(((*l_temp)).get()>>32)); - } - break; - default: - FAPI_ERR("Coming error ASSERT for illegal i_state = %u", i_state); - } - } - ++c; - } - - return l_children; - } - - /// - /// @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 - { -// static_assert( false, "getOtherEnd() is not supported on PPE platforms"); - } - - - /// - /// @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/hwpf/plat/include/target_types.H b/hwpf/plat/include/target_types.H deleted file mode 100644 index 56470cd0..00000000 --- a/hwpf/plat/include/target_types.H +++ /dev/null @@ -1,119 +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_types.H - * @brief definitions for fapi2 target types - */ - -#ifndef __FAPI2_TARGET_TYPES__ -#define __FAPI2_TARGET_TYPES__ - -#ifndef __ASSEMBLER__ - - -/// 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 - /// - /// Target Kind - enum TargetType - { - TARGET_TYPE_NONE = 0x00, ///< No type - TARGET_TYPE_PROC_CHIP = 0x01, ///< Processor type - TARGET_TYPE_EX = 0x02, ///< Ex type - TARGET_TYPE_CORE = 0x04, ///< Core type - TARGET_TYPE_EQ = 0x08, ///< EQ type - TARGET_TYPE_MCS = 0x10, ///< MCS type - TARGET_TYPE_PERV = 0x20, ///< Pervasive type - TARGET_TYPE_MCAST = 0x40, ///< Multicast type - TARGET_TYPE_SYSTEM = 0x80, ///< System type - - TARGET_TYPE_ALL = 0xFF, ///< Any/All types - - // The following are actually illegal targets on PPE platforms -// TARGET_TYPE_SYSTEM = 0xFE, ///< System type -// TARGET_TYPE_DIMM = 0xFD, ///< DIMM type -// TARGET_TYPE_MEMBUF_CHIP = 0xFC, ///< Membuf type -// TARGET_TYPE_MBA = 0xFB, ///< MBA type -// TARGET_TYPE_XBUS = 0xFA, ///< XBUS type -// TARGET_TYPE_ABUS = 0xF9, ///< ABUS type -// TARGET_TYPE_L4 = 0xF8, ///< L4 type -// TARGET_TYPE_MCA = 0xF7, ///< MCA type -// TARGET_TYPE_MCBIST = 0xF6, ///< MCBIST type -// TARGET_TYPE_MIA = 0xF5, ///< MIA type -// TARGET_TYPE_MIS = 0xF4, ///< MIS type -// TARGET_TYPE_DMI = 0xF3, ///< DMI type -// TARGET_TYPE_OBUS = 0xF2, ///< OBUS type -// TARGET_TYPE_NV = 0xF1, ///< NV bus type -// TARGET_TYPE_SBE = 0xF0, ///< SBE type -// TARGET_TYPE_PPE = 0xEF, ///< PPE type -// TARGET_TYPE_PEC = 0xEE, ///< PEC type -// TARGET_TYPE_PHB = 0xED, ///< PHB type -// TARGET_TYPE_MI = 0xEC, ///< MI type - - // 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, - }; - - /// - /// @brief Typedef used when passing multiple TargetType values - /// - typedef uint8_t TargetTypes_t; - - /// @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 { - public: - // Don't use enums, too hard to compare - static const uint8_t count = bitCount<(V >> 1)>::count + (V & 1); - }; - - template<> - class bitCount<0> { - public: - static const uint8_t count = 0; - }; - /// @endcond -}; - -#endif // __ASSEMBLER__ -#endif // __FAPI2_TARGET_TYPES__ diff --git a/hwpf/plat/include/utils.H b/hwpf/plat/include/utils.H deleted file mode 100644 index 69e84d20..00000000 --- a/hwpf/plat/include/utils.H +++ /dev/null @@ -1,81 +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 utils.H - * - * @brief Defines common utility elements for FAPI2 use. - */ - -#ifndef FAPI2_UTILS_H_ -#define FAPI2_UTILS_H_ - -#ifdef __ASSEMBLER__ - -#ifndef ULL -#define ULL(x) x -#endif - -#else - -#ifndef ULL -#define ULL(x) x##ull - -#endif - -#endif // __ASSEMBLER - -/// Create a multi-bit mask of \a n bits starting at bit \a b -#define BITS(b, n) ((ULL(0xffffffffffffffff) << (64 - (n))) >> (b)) - -/// Create a single bit mask at bit \a b -#define BIT(b) BITS((b), 1) - -#ifdef _BIG_ENDIAN - -#define revle16(x) x -#define revle32(x) x -#define revle64(x) x - -#else - -uint16_t revle16(uint16_t i_x); -uint32_t revle32(uint32_t i_x); -uint64_t revle64(uint64_t i_x); - -#endif - -namespace fapi2 -{ - /// @brief Delay this thread. - /// @param[in] i_nanoSeconds nanoseconds to sleep - /// @param[in] i_simCycles count of Awan cycles to advance - /// @return ReturnCode. Zero on success, else platform specified error. - inline ReturnCode delay(uint64_t i_nanoSeconds, uint64_t i_simCycles) - { - return FAPI2_RC_SUCCESS; - } -} - -#endif // FAPI2_UTILS_H_ diff --git a/hwpf/plat/include/variable_buffer.H b/hwpf/plat/include/variable_buffer.H deleted file mode 100644 index fa9e4a05..00000000 --- a/hwpf/plat/include/variable_buffer.H +++ /dev/null @@ -1,670 +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 variable_buffer.H - * @brief definitions for fapi2 variable length buffers - */ - -#ifndef __FAPI2_VARIABLE_BUFFER__ -#define __FAPI2_VARIABLE_BUFFER__ - -#include <buffer_base.H> - -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; - } - - // - // 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> - inline fapi2::ReturnCode _insert(const unit_type* i_source, - bits_type i_source_length, - unit_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_unit = fapi2::parameterTraits<unit_type>::bit_length; - - // tartgetStart 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 == ~0) - { - i_target_start_bit = (i_target_length - (i_source_length - i_source_start_bit)); - } - - // len defaults to (sizeof(OT) * 8) - i_source_start_bit - if (i_length == ~0) - { - i_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; - } - - do - { - const bits_type src_idx = i_source_start_bit / bits_per_unit; - const bits_type trg_idx = i_target_start_bit / bits_per_unit; - - // "slop" = unaligned bits - const bits_type src_slop = i_source_start_bit % bits_per_unit; - const bits_type trg_slop = i_target_start_bit % bits_per_unit; - - // "cnt" = largest number of bits to be moved each pass - bits_type cnt = std::min(i_length, bits_per_unit); - cnt = std::min(cnt, bits_per_unit - src_slop); - cnt = std::min(cnt, bits_per_unit - trg_slop); - - // generate the source mask only once - bits_type mask = fast_mask32(src_slop, cnt); - - // read the source bits only once - bits_type src_bits = i_source[src_idx] & mask; - - // "shift" = amount of shifting needed for target alignment - int32_t shift = trg_slop - src_slop; - - // ideally (i << -1) would yield (i >> 1), but it - // doesn't, so we need an extra branch here - - if (shift < 0) - { - src_bits <<= -shift; - mask <<= -shift; - } - else - { - src_bits >>= shift; - mask >>= shift; - } - - // clear source '0' bits in the target - i_target[trg_idx] &= ~mask; - // set source '1' bits in the target - i_target[trg_idx] |= src_bits; - - i_source_start_bit += cnt; - i_target_start_bit += cnt; - - i_length -= cnt; - } 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 not (presently) declared as std::vector<bool> - /// as it would need to be implemented separate from std::vector, and - /// it's not clear it would give us any real advantage. Howevever, its is - /// more likely this will become a std::vector<bool> than a std::bitset. - class variable_buffer : public buffer_base<bits_container> - { - - public: - - /// - /// @brief Variable buffer constructor - /// @param[in] i_value number of *bits* (sizeof(uint_type) * 8) - /// needed. - variable_buffer(bits_type i_value = 0); - - /// - /// @brief Variable buffer list constructor - /// @param[in] i_value an initializer list to initialize the container. - /// - variable_buffer(const std::initializer_list<unit_type>& i_value); - - /// @name Bit/Word Manipulation Functions - ///@{ - - /// - /// @brief Return the length of the buffer in bits - /// @return Length in bits - /// - inline uint32_t getBitLength(void) const - { return iv_perceived_bit_length; } - - /// - /// @brief Return the length of the buffer in OT units - /// @return Length in OT units rounded up - /// @tparam OT the type to get the length of. For example, if one - /// wanted the length in double words, OT would be uint64_t - /// (getLength<uint64_t>().) Similarly, to get the length in words, - /// getLength<uin32_t>(). - /// - template< typename OT > - inline uint32_t getLength(void) const - { - static const uint32_t bits_in_ot = sizeof(OT) * 8; - return (getBitLength() + (bits_in_ot - 1)) / bits_in_ot; - } - - /// - /// @brief Set a bit in the buffer - /// @param[in] i_bit the bit number to set. - /// @note 0 is left-most - /// @return FAPI2_RC_SUCCESS if OK - /// - inline fapi2::ReturnCode setBit(const bits_type& i_bit) - { - const bits_type index = i_bit / bits_per_unit; - - if (index > iv_data.size()) - { - return FAPI2_RC_INVALID_PARAMETER; - } - - -/// @todo: check with Brian no the correct parens - iv_data[index] |= - unit_type(1) << ((bits_per_unit - 1) - - (i_bit - (index * bits_per_unit))); - - return FAPI2_RC_SUCCESS; - } - - /// - /// @brief Clear a bit in buffer - /// @tparam SB Start bit in buffer to clear. - /// @tparam L Number of consecutive bits from start bit to - /// clear - /// @return FAPI2_RC_SUCCESS on success - /// @note Asserting that all the parameters are known at - /// compile time so this can be templated only. If that is not - /// the case we can add a function parameter version. - /// - template< bits_type SB, bits_type L > - fapi2::ReturnCode clearBit(void); - - /// - /// @brief Invert bit - /// @tparam SB Start bit in buffer to invert. - /// @tparam L Number of consecutive bits from start bit to - /// invert, defaults to 1 - /// @return FAPI2_RC_SUCCESS on success - /// @note Asserting that all the parameters are known at - /// compile time so this can be templated only. If that is not - /// the case we can add a function parameter version. - /// - template< bits_type SB, bits_type L = 1 > - fapi2::ReturnCode flipBit(void); - - /// - /// @brief Get the value of a bit in the buffer - /// @tparam B Bit in buffer to get. - /// @return true/1 if bit is on, false/0 if bit is off - /// @note Asserting that all the parameters are known at - /// compile time so this can be templated only. If that is not - /// the case we can add a function parameter version. - /// - template< bits_type B > - inline bool getBit(void) const - { - const bits_type index = B / bits_per_unit; - const unit_type mask = unit_type(1) << (bits_per_unit - 1) - (B - (index * bits_per_unit)); - return iv_data[index] & mask; - } - - /// - /// @brief Test if multiple bits are set - /// @tparam SB Start bit in buffer to test. - /// @tparam L Number of consecutive bits from start bit to - /// test, defaults to 1 - /// @note Asserting that all the parameters are known at - /// compile time so this can be templated only. If that is not - /// the case we can add a function parameter version. - /// @return true if all bits in range are set - false if any - /// bit is clear - /// - template< bits_type SB, bits_type L = 1 > - bool isBitSet(void) const; - - /// - /// @brief Test if multiple bits are clear - /// @tparam SB Start bit in buffer to test. - /// @tparam L Number of consecutive bits from start bit to - /// test, defaults to 1 - /// @note Asserting that all the parameters are known at - /// compile time so this can be templated only. If that is not - /// the case we can add a function parameter version. - /// @return true if bit is clear - false if bit is set - /// - template< bits_type SB, bits_type L = 1 > - bool isBitClear(void) const; - - /// - /// @brief Count number of bits set in a range - /// @tparam SB Start bit in buffer to test. - /// @tparam L Number of consecutive bits from start bit to - /// test, defaults to 1 - /// @note Asserting that all the parameters are known at - /// compile time so this can be templated only. If that is not - /// the case we can add a function parameter version. - /// @return Number of bits set in range - /// - template< bits_type SB, bits_type L = 1 > - bits_type getNumBitsSet(void) const; - - ///@} - - /// @name Buffer Manipulation Functions - ///@{ - - // 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 - // documenation purposes. - - /// - /// @brief operator>>() - /// -#ifdef DOXYGEN - variable_buffer<T>& operator>>(bits_type i_shiftnum); -#endif - - /// - /// @brief operator<<() - /// -#ifdef DOXYGEN - variable_buffer<T>& operator<<(bits_type i_shiftnum); -#endif - - /// - /// @brief operator+() - /// -#ifdef DOXYGEN - variable_buffer<T>& operator+(const T& rhs); -#endif - - /// - /// @brief operator+=() - /// -#ifdef DOXYGEN - variable_buffer<T>& operator+=(const T& rhs); -#endif - - /// - /// @brief operator|=() - /// -#ifdef DOXYGEN - variable_buffer<T>& operator|=(const T& rhs); -#endif - - /// - /// @brief operator&=() - /// -#ifdef DOXYGEN - variable_buffer<T>& operator&=(const T& rhs); -#endif - - /// - /// @brief operator|() - /// -#ifdef DOXYGEN - variable_buffer<T>& operator|(const T& rhs); -#endif - - /// - /// @brief operator&() - /// -#ifdef DOXYGEN - variable_buffer<T>& operator&(const T& rhs); -#endif - - /// - /// @brief operator^=() - /// -#ifdef DOXYGEN - variable_buffer<T>& operator^=(const T& rhs); -#endif - - /// - /// @brief operator!=() - /// -#ifdef DOXYGEN - bool operator!=(const T& rhs) const; -#endif - - /// - /// @brief operator==() - /// @return true if and only if lhs == rhs - /// - inline bool operator==(const fapi2::bits_container& rhs) const - { - if (&iv_data == &rhs) - { - return true; - } - - return iv_data == rhs; - } - - /// - /// @brief Copy part of an element into the DataBuffer - /// @param[in] i_data OT value to copy into DataBuffer - /// @param[in] i_targetStart The position in this where the copy starts - /// @param[in] i_len How many bits to copy - /// @param[in] i_sourceStart The start positon in i_data, defaults to 0 - /// @return FAPI2_RC_SUCCESS on success, FAPi2_RC_OVERFLOW otherwise - /// - template<typename OT> - fapi2::ReturnCode insert(const OT& i_data, - bits_type i_targetStart = 0, - bits_type i_len = ~0, - bits_type i_sourceStart = 0); - - /// - /// @brief Copy in a right aligned (decimal) element - /// @param[in] i_data the incoming data - /// - data is taken right aligned - /// @param[in] i_targetStart The starting bit position in this - /// - Defaultst to 0 - /// @param[in] i_len The length, in bits, the user wants copied. - /// - Defaults to all of the bits in the source which fit - /// @return FAPI2_RC_SUCCESS on success, FAPI2_RC_OVERFLOW otherwise - /// - template<typename OT> - fapi2::ReturnCode insertFromRight(const OT& i_data, - bits_type i_targetStart = 0, - bits_type i_len = ~0); - - /// - /// @brief Copy data from this buffer into an OT - /// @tparam OT the type of the outgoing data - /// @param[out] o_out OT to copy into - data is placed left aligned - /// @param[in] i_start Start bit to copy from - defaults to 0 - /// @param[in] i_len Length of bits to copy - defaults to filling o_out - /// @return FAPI2_RC_SUCCESS on success - /// - template< typename OT > - fapi2::ReturnCode extract(OT& o_out, - bits_type i_start = 0, - bits_type i_len = ~0) const; - - /// - /// @brief Copy data from this buffer into an OT and right justify - /// @tparam OT the type of the outgoing data - /// @param[out] o_out OT to copy into - data is placed right aligned - /// @param[in] i_start Start bit to copy from - defaults to 0 - /// @param[in] i_len Length of bits to copy - defaults to filling o_out - /// @return FAPI2_RC_SUCCESS on success - /// - template< typename OT > - fapi2::ReturnCode extractToRight(OT& o_out, - bits_type i_start = 0, - bits_type i_len = ~0) const; - ///@} - - private: - // Just shorthand ... - static const bits_type bits_per_unit = - bufferTraits<bits_container>::bits_per_unit; - - // The number of bits the user asked for. The actual size of the - // container might be larger. - bits_type iv_perceived_bit_length; - - /// - /// @brief Internal bit extraction method. - /// @tparam OT The type of the destination - /// @param[in] i_start The starting bit position in this - /// @param[in] i_count The length, in bits, the user wants copied. - /// @param[out] o_dest Where to put the data - /// - template< typename OT > - fapi2::ReturnCode _extract(bits_type i_start, - bits_type i_count, - OT* o_dest) const; - - /// - /// @brief Internal insertFromRight - /// @param[in] i_data, the incoming data - /// @param[in] i_data_length The length in bits of 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 OT> - fapi2::ReturnCode _insertFromRight(const OT& i_data, - bits_type i_data_length, - bits_type i_targetStart, - bits_type i_len); - - }; - - inline variable_buffer:: - variable_buffer(bits_type i_value): - buffer_base(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"); - } - - inline variable_buffer:: - variable_buffer(const std::initializer_list<unit_type>& i_value): - buffer_base(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"); - } - - - - /// @cond - // - // Generic insert - // - template<typename OT> - inline fapi2::ReturnCode variable_buffer::insert(const OT& i_source, - bits_type i_targetStart, - bits_type i_len, - bits_type i_sourceStart) - { - return _insert((unit_type*)(&i_source), parameterTraits<OT>::bit_length, - &(iv_data[0]), getBitLength(), - i_sourceStart, i_targetStart, i_len); - } - - // - // Insert another variable_bufer - // - template<> - inline fapi2::ReturnCode variable_buffer::insert( - const variable_buffer& i_data, - bits_type i_targetStart, - bits_type i_len, - bits_type i_sourceStart) - { - return _insert((unit_type*)&(i_data()[0]), i_data.getBitLength(), - &(iv_data[0]), getBitLength(), - i_sourceStart, i_targetStart, i_len); - } - - // - // Generic insert from right - // - template<typename OT> - inline fapi2::ReturnCode variable_buffer::insertFromRight( - const OT& i_data, - bits_type i_targetStart, - bits_type i_len) - { - /// @todo check with Brian on additional return - return _insertFromRight(i_data, parameterTraits<OT>::bit_length, i_targetStart, i_len); - } - - // - // variable_buffer insert from right - // - template<> - inline fapi2::ReturnCode 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(); - /// @todo check with Brian on additional return - return _insertFromRight(i_data, bit_length_of_source, i_targetStart, i_len); - } - - - - - // - // Generic extract. Extract is an insert with the arguments reversed. - // - template<typename OT> - inline fapi2::ReturnCode variable_buffer::extract( - OT& i_data, - bits_type i_start, - bits_type i_len) const - { - // Needed to trick the compiler into matching the template below - const bits_type max_length = parameterTraits<OT>::bit_length; - - // If thy didn't pass an i_len, assume they want all the data - // which will fit. - if (i_len == ~0) - { - i_len = max_length; - } - - return _insert((container_unit*)&iv_data[0], getBitLength(), - &i_data, max_length, - i_start, 0U, i_len); - } - - // - // Extract in to another variable_bufer - // - template<> - inline fapi2::ReturnCode 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. - // @todo Needed to add (bits_type) to compile. Not clear why this is - // different than other similar comparisons - // error: comparison between signed and unsigned integer expressions [-Werror=sign-compare] - if ( i_len == ~(bits_type)0 ) - { - i_len = i_data.getBitLength(); - } - return _insert((container_unit*)&iv_data[0], getBitLength(), - &(i_data()[0]), i_data.getBitLength(), - i_start, 0U, i_len); - } - - - - template<typename OT> - inline fapi2::ReturnCode variable_buffer::_insertFromRight( - const OT& i_data, - 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. - if( i_len == ~0 ) - { - // The longest the length can be is the length of the data - // This is the miniumum of the length of the data or the - // number of available bits - i_len = std::min(i_data_length, getBitLength() - i_targetStart); - } - - // Source start is the length, counted from the right - return insert(i_data, i_targetStart, i_len, i_data_length - i_len); - } - - // - // Invalid specializations of set - // - /// @cond - // Sepcialize the variable_buffer version to to "undefined" so the - // linker complains loudly if anyone calls it. -#if 0 - template<> - inline fapi2::ReturnCode buffer_base::set( - const variable_buffer& i_value, - bits_type i_offset); -#endif - /// @endcond -}; - - -#endif diff --git a/hwpf/plat/src/Makefile b/hwpf/plat/src/Makefile deleted file mode 100644 index ed98e93f..00000000 --- a/hwpf/plat/src/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# This Makefile is designed to be invoked with the -I argument set to -# the location of the "pk.mk" for the build - -include img_defs.mk -include fapi2ppefiles.mk - - -OBJS := $(addprefix $(OBJDIR)/, $(FAPI2LIB_OBJECTS)) - -all: $(OBJS) - - -$(OBJS) $(OBJS:.o=.d): | $(OBJDIR) - -$(OBJDIR): - mkdir -p $(OBJDIR) - -ifneq ($(MAKECMDGOALS),clean) -include $(OBJS:.o=.d) -endif - diff --git a/hwpf/plat/src/array.C b/hwpf/plat/src/array.C deleted file mode 100644 index 340d8d2f..00000000 --- a/hwpf/plat/src/array.C +++ /dev/null @@ -1,145 +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 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) - { -#ifdef GREG - assert(iv_size <= size_limit); - if (iv_data == nullptr) - { - iv_data = new element_type[iv_size](); - iv_size |= delete_bit; - } -#endif - // 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) - { -#ifdef GREG - delete[] iv_data; -#endif - } - } - - /// @brief operator[] - array::element_type& array::operator[](const uint32_t i_index) - { -#ifdef GREG - assert(i_index < size()); -#endif - return iv_data[i_index]; - } - - /// @brief operator=() - array& array::operator=(const array& i_other) - { -#ifdef GREG - // Check to make sure it'll fit. - assert(i_other.size() <= size()); -#endif - // 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 ... -#ifdef GREG - memcpy(iv_data, i_other.iv_data, iv_size * sizeof(element_type)); -#else - for(size_t i = 0; i < iv_size * sizeof(element_type); ++i) - { - iv_data[i] = i_other.iv_data[i]; - } -#endif - - // ... 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/hwpf/plat/src/error_info.C b/hwpf/plat/src/error_info.C deleted file mode 100644 index 9d44eb58..00000000 --- a/hwpf/plat/src/error_info.C +++ /dev/null @@ -1,410 +0,0 @@ -/* 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 - { - // "variable buffer ffdc not yet implemented"); - assert(iv_ffdcSize != EI_FFDC_SIZE_VBUF); - - switch(iv_ffdcSize) - { - case EI_FFDC_SIZE_BUF: - { - const buffer<uint64_t>* object = - static_cast<const buffer<uint64_t>*>(i_objects[iv_ffdcObjIndex]); - - i_info->iv_ffdcs.push_back(std::shared_ptr<ErrorInfoFfdc>( - new ErrorInfoFfdc(iv_ffdcId, object, - sizeof(object)))); - - FAPI_DBG("addErrorInfo: Adding buffer id: 0x%x size: %lu buf: 0x%lx", - iv_ffdcId, sizeof(object), uint64_t(*object)); - } - break; - - 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/hwpf/plat/src/fapi2ppefiles.mk b/hwpf/plat/src/fapi2ppefiles.mk deleted file mode 100644 index f2e72670..00000000 --- a/hwpf/plat/src/fapi2ppefiles.mk +++ /dev/null @@ -1,30 +0,0 @@ -# @file fapi2ppefiles.mk -# -# @brief mk for including fapi2 object files -# -# @page ChangeLogs Change Logs -# @section fapi2ppefiles.mk -# @verbatim -# -# -# Change Log ****************************************************************** -# Flag Defect/Feature User Date Description -# ------ -------------- ---------- ------------ ----------- -# -# @endverbatim -# -########################################################################## -# Object Files -########################################################################## - - -FAPI2-CPP-SOURCES += fapi2PlatAttributeService.C -FAPI2-CPP-SOURCES += target.C -FAPI2-CPP-SOURCES += plat_utils.C - - -FAPI2-S-SOURCES = - -FAPI2LIB_OBJECTS += $(FAPI2-CPP-SOURCES:.C=.o) -FAPI2LIB_OBJECTS += $(FAPI2-S-SOURCES:.S=.o) - diff --git a/hwpf/plat/src/ffdc.C b/hwpf/plat/src/ffdc.C deleted file mode 100644 index efe922ea..00000000 --- a/hwpf/plat/src/ffdc.C +++ /dev/null @@ -1,57 +0,0 @@ -/* 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 ffdc.C - * @brief Implements the FirstFailureData class - */ - -#include <plat_trace.H> -#include <ffdc.H> -#include <error_info.H> - -namespace fapi2 -{ - - /// - /// @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/hwpf/plat/src/plat_utils.C b/hwpf/plat/src/plat_utils.C deleted file mode 100644 index 18aa4444..00000000 --- a/hwpf/plat/src/plat_utils.C +++ /dev/null @@ -1,212 +0,0 @@ - -/* 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 plat_utils.C - * @brief Implements fapi2 common utilities - */ - -#include <stdint.h> -#include <plat_trace.H> -#include <return_code.H> - -#ifndef __PPE__ -#include <error_info.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); - } - -e 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) - { - // void statements to keep the compiler from complaining - // about unused variables. - static_cast<void>(i_nanoSeconds); - static_cast<void>(i_simCycles); - - // replace with platform specific implementation - return FAPI2_RC_SUCCESS; - } -}; - - -/// Byte-reverse a 16-bit integer if on a little-endian machine - -uint16_t -revle16(uint16_t i_x) -{ - uint16_t rx; - -#ifndef _BIG_ENDIAN - uint8_t *pix = (uint8_t*)(&i_x); - uint8_t *prx = (uint8_t*)(&rx); - - prx[0] = pix[1]; - prx[1] = pix[0]; -#else - rx = i_x; -#endif - - return rx; -} - -#endif - -/// Byte-reverse a 32-bit integer if on a little-endian machine - -uint32_t -revle32(uint32_t i_x) -{ - uint32_t rx; - -#ifndef _BIG_ENDIAN - uint8_t *pix = (uint8_t*)(&i_x); - uint8_t *prx = (uint8_t*)(&rx); - - prx[0] = pix[3]; - prx[1] = pix[2]; - prx[2] = pix[1]; - prx[3] = pix[0]; -#else - rx = i_x; -#endif - - return rx; -} - - -/// Byte-reverse a 64-bit integer if on a little-endian machine - -uint64_t -revle64(const uint64_t i_x) -{ - uint64_t rx; - -#ifndef _BIG_ENDIAN - uint8_t *pix = (uint8_t*)(&i_x); - uint8_t *prx = (uint8_t*)(&rx); - - prx[0] = pix[7]; - prx[1] = pix[6]; - prx[2] = pix[5]; - prx[3] = pix[4]; - prx[4] = pix[3]; - prx[5] = pix[2]; - prx[6] = pix[1]; - prx[7] = pix[0]; -#else - rx = i_x; -#endif - - return rx; -} - - diff --git a/hwpf/plat/src/target.C b/hwpf/plat/src/target.C deleted file mode 100644 index c70fc42c..00000000 --- a/hwpf/plat/src/target.C +++ /dev/null @@ -1,441 +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 */ - - -#include <fapi2.H> -#include <new> -#include <utility> // For move -#include <plat_target_pg_attributes.H> - -// Global Vector containing ALL targets. This structure is referenced by -// fapi2::getChildren to produce the resultant returned vector from that -// call. -std::vector<fapi2::plat_target_handle_t> G_vec_targets; - -fapi2attr::SystemAttributes_t* G_system_attributes_ptr; -fapi2attr::ProcChipAttributes_t* G_proc_chip_attributes_ptr; -fapi2attr::PervAttributes_t* G_perv_attributes_ptr; -fapi2attr::CoreAttributes_t* G_core_attributes_ptr; -fapi2attr::EQAttributes_t* G_eq_attributes_ptr; -fapi2attr::EXAttributes_t* G_ex_attributes_ptr; - -namespace fapi2 -{ - - #ifndef __noRC__ - ReturnCode current_err; - #endif - - - // Not a fan of the switch technique; I would prefer an array lookup - // but the attritute lookup is done via compile time macros that are - // resolved to attribute Ids (hashes). - fapi2::ReturnCode plat_PervPGTargets(const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> & i_target, - const fapi2::TargetTypes_t i_chiplet_num, - bool & o_present) - { - - o_present = false; - uint16_t attr_value = 0; - switch (i_chiplet_num) - { - case 0x00: // Nop - break; - case 0x01: - FAPI_ATTR_GET(ATTR_PG_PRV, i_target, *(&attr_value)); - FAPI_DBG("ATTR_PG_PRV value = %x", attr_value); - break; - case 0x02: - FAPI_ATTR_GET(ATTR_PG_N0, i_target, attr_value); - FAPI_DBG("ATTR_PG_N0 value = %x", attr_value); - break; - case 0x03: - FAPI_ATTR_GET(ATTR_PG_N1, i_target, attr_value); - FAPI_DBG("ATTR_PG_N1 value = %x", attr_value); - break; - case 0x04: - FAPI_ATTR_GET(ATTR_PG_N2, i_target, attr_value); - FAPI_DBG("ATTR_PG_N2 value = %x", attr_value); - break; - case 0x05: - FAPI_ATTR_GET(ATTR_PG_N3, i_target, attr_value); - FAPI_DBG("ATTR_PG_N0 value = %x", attr_value); - break; - case 0x06: - FAPI_ATTR_GET(ATTR_PG_XB, i_target, attr_value); - FAPI_DBG("ATTR_PG_XB value = %x", attr_value); - break; - case 0x07: - FAPI_ATTR_GET(ATTR_PG_MC01, i_target, attr_value); - FAPI_DBG("ATTR_PG_MC01 value = %x", attr_value); - break; - case 0x08: - FAPI_ATTR_GET(ATTR_PG_MC23, i_target, attr_value); - FAPI_DBG("ATTR_PG_MC23 value = %x", attr_value); - break; - case 0x09: - FAPI_ATTR_GET(ATTR_PG_OB0, i_target, attr_value); - FAPI_DBG("ATTR_PG_OB0 value = %x", attr_value); - break; - case 0x0A: - FAPI_ATTR_GET(ATTR_PG_OB1, i_target, attr_value); - FAPI_DBG("ATTR_PG_OB1 value = %x", attr_value); - break; - case 0x0B: - FAPI_ATTR_GET(ATTR_PG_OB2, i_target, attr_value); - FAPI_DBG("ATTR_PG_OB2 value = %x", attr_value); - break; - case 0x0C: - FAPI_ATTR_GET(ATTR_PG_OB3, i_target, attr_value); - FAPI_DBG("ATTR_PG_OB3 value = %x", attr_value); - break; - case 0x0D: - FAPI_ATTR_GET(ATTR_PG_PCI0, i_target, attr_value); - FAPI_DBG("ATTR_PG_PCI0 value = %x", attr_value); - break; - case 0x0E: - FAPI_ATTR_GET(ATTR_PG_PCI1, i_target, attr_value); - FAPI_DBG("ATTR_PG_PCI1 value = %x", attr_value); - break; - case 0x0F: - FAPI_ATTR_GET(ATTR_PG_PCI2, i_target, attr_value); - FAPI_DBG("ATTR_PG_PCI2 value = %x", attr_value); - break; - case 0x10: - FAPI_ATTR_GET(ATTR_PG_EQ0, i_target, attr_value); - FAPI_DBG("ATTR_PG_EQ0 value = %x", attr_value); - break; - case 0x11: - FAPI_ATTR_GET(ATTR_PG_EQ1, i_target, attr_value); - FAPI_DBG("ATTR_PG_EQ1 value = %x", attr_value); - break; - case 0x12: - FAPI_ATTR_GET(ATTR_PG_EQ2, i_target, attr_value); - FAPI_DBG("ATTR_PG_EQ2 value = %x", attr_value); - break; - case 0x13: - FAPI_ATTR_GET(ATTR_PG_EQ3, i_target, attr_value); - FAPI_DBG("ATTR_PG_EQ3 value = %x", attr_value); - break; - case 0x14: - FAPI_ATTR_GET(ATTR_PG_EQ4, i_target, attr_value); - FAPI_DBG("ATTR_PG_EQ4 value = %x", attr_value); - break; - case 0x15: - FAPI_ATTR_GET(ATTR_PG_EQ5, i_target, attr_value); - FAPI_DBG("ATTR_PG_EQ5 value = %x", attr_value); - break; - case 0x20: - FAPI_ATTR_GET(ATTR_PG_EC00, i_target, attr_value); - FAPI_DBG("ATTR_PG_EC00 value = %x", attr_value); - break; - case 0x21: - FAPI_ATTR_GET(ATTR_PG_EC01, i_target, attr_value); - FAPI_DBG("ATTR_PG_EC01 value = %x", attr_value); - break; - case 0x22: - FAPI_ATTR_GET(ATTR_PG_EC02, i_target, attr_value); - FAPI_DBG("ATTR_PG_EC02 value = %x", attr_value); - break; - case 0x23: - FAPI_ATTR_GET(ATTR_PG_EC03, i_target, attr_value); - FAPI_DBG("ATTR_PG_EC03 value = %x", attr_value); - break; - case 0x24: - FAPI_ATTR_GET(ATTR_PG_EC04, i_target, attr_value); - FAPI_DBG("ATTR_PG_EC04 value = %x", attr_value); - break; - case 0x25: - FAPI_ATTR_GET(ATTR_PG_EC05, i_target, attr_value); - FAPI_DBG("ATTR_PG_EC05 value = %x", attr_value); - break; - case 0x26: - FAPI_ATTR_GET(ATTR_PG_EC06, i_target, attr_value); - FAPI_DBG("ATTR_PG_EC06 value = %x", attr_value); - break; - case 0x27: - FAPI_ATTR_GET(ATTR_PG_EC07, i_target, attr_value); - FAPI_DBG("ATTR_PG_EC07 value = %x", attr_value); - break; - case 0x28: - FAPI_ATTR_GET(ATTR_PG_EC08, i_target, attr_value); - FAPI_DBG("ATTR_PG_EC08 value = %x", attr_value); - break; - case 0x29: - FAPI_ATTR_GET(ATTR_PG_EC09, i_target, attr_value); - FAPI_DBG("ATTR_PG_EC09 value = %x", attr_value); - break; - case 0x2A: - FAPI_ATTR_GET(ATTR_PG_EC10, i_target, attr_value); - FAPI_DBG("ATTR_PG_EC10 value = %x", attr_value); - break; - case 0x2B: - FAPI_ATTR_GET(ATTR_PG_EC11, i_target, attr_value); - FAPI_DBG("ATTR_PG_EC11 value = %x", attr_value); - break; - case 0x2C: - FAPI_ATTR_GET(ATTR_PG_EC12, i_target, attr_value); - FAPI_DBG("ATTR_PG_EC12 value = %x", attr_value); - break; - case 0x2D: - FAPI_ATTR_GET(ATTR_PG_EC13, i_target, attr_value); - FAPI_DBG("ATTR_PG_EC13 value = %x", attr_value); - break; - case 0x2E: - FAPI_ATTR_GET(ATTR_PG_EC14, i_target, attr_value); - FAPI_DBG("ATTR_PG_EC14 value = %x", attr_value); - break; - case 0x2F: - FAPI_ATTR_GET(ATTR_PG_EC15, i_target, attr_value); - FAPI_DBG("ATTR_PG_EC15 value = %x", attr_value); - break; - case 0x30: - FAPI_ATTR_GET(ATTR_PG_EC16, i_target, attr_value); - FAPI_DBG("ATTR_PG_EC16 value = %x", attr_value); - break; - case 0x31: - FAPI_ATTR_GET(ATTR_PG_EC17, i_target, attr_value); - FAPI_DBG("ATTR_PG_EC17 value = %x", attr_value); - break; - case 0x32: - FAPI_ATTR_GET(ATTR_PG_EC18, i_target, attr_value); - FAPI_DBG("ATTR_PG_EC18 value = %x", attr_value); - break; - case 0x33: - FAPI_ATTR_GET(ATTR_PG_EC19, i_target, attr_value); - FAPI_DBG("ATTR_PG_EC19 value = %x", attr_value); - break; - case 0x34: - FAPI_ATTR_GET(ATTR_PG_EC20, i_target, attr_value); - FAPI_DBG("ATTR_PG_EC20 value = %x", attr_value); - break; - case 0x35: - FAPI_ATTR_GET(ATTR_PG_EC21, i_target, attr_value); - FAPI_DBG("ATTR_PG_EC21 value = %x", attr_value); - break; - case 0x36: - FAPI_ATTR_GET(ATTR_PG_EC22, i_target, attr_value); - FAPI_DBG("ATTR_PG_EC22 value = %x", attr_value); - break; - case 0x37: - FAPI_ATTR_GET(ATTR_PG_EC23, i_target, attr_value); - FAPI_DBG("ATTR_PG_EC23 value = %x", attr_value); - break; - default: - FAPI_ERR("PervPGTargets: invalid chiplet number %u", i_chiplet_num); - } - - if (attr_value & 0xC000) - { - o_present = true; - } - - return fapi2::FAPI2_RC_SUCCESS; - - } - - /// @brief Function to determine if pervsaive target within a chip is - /// present and, thus, considered functional per PG attributes - template<fapi2::TargetType K> - fapi2::ReturnCode - plat_TargetPresent( fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> & i_chip_target, - fapi2::Target<K> & i_chiplet_target, - bool & b_present) - { - - // Find the PERV target number in the partial good initialization - // array - fapi2::ChipletNumber_t chiplet_number = i_chiplet_target.getChipletNumber(); - - FAPI_TRY(plat_PervPGTargets(i_chip_target, chiplet_number, b_present)); - - if (b_present) - { - i_chiplet_target.setPresent(); - i_chiplet_target.setFunctional(); - } - else - { - FAPI_DBG("Perv target NOT present (nor functional): chiplet_number = %d", - chiplet_number); - } - - FAPI_DBG("Target present = %u, Target functional = %u", - i_chiplet_target.getPresent(), - i_chiplet_target.getFunctional()); - -fapi_try_exit: - return fapi2::current_err; - } - - - /// @brief Function to initialize the G_targets vector based on partial good - /// attributes /// this will move to plat_target.H formally - fapi2::ReturnCode plat_TargetsInit() - { - bool b_present = false; - uint32_t c = 0; - - // Initialise global attribute pointers - G_system_attributes_ptr = &G_system_attributes; - G_proc_chip_attributes_ptr = &G_proc_chip_attributes; - G_perv_attributes_ptr = &G_perv_attributes; - G_core_attributes_ptr = &G_core_attributes; - G_eq_attributes_ptr = &G_eq_attributes; - G_ex_attributes_ptr = &G_ex_attributes; - - - std::vector<fapi2::plat_target_handle_t>::iterator tgt_iter; - uint32_t l_beginning_offset; - - FAPI_DBG("Platform target initialization. Target Count = %u", TARGET_COUNT); - /* - * Initialize all entries to NULL - */ - for (uint32_t i = 0; i < TARGET_COUNT; ++i) - { - G_vec_targets.push_back((fapi2::plat_target_handle_t)0x0); - FAPI_DBG("Nulling G_vec_targets[%u] hi value=0x%08X", - i, (uint32_t)(G_vec_targets.at(i)>>32)); - - } - FAPI_DBG("Vector size: %u", G_vec_targets.size()); - - /* - * Chip Target is the first one - */ - FAPI_DBG("Chip Target info: CHIP_TARGET_OFFSET %u CHIP_TARGET_COUNT %u ", - CHIP_TARGET_OFFSET,CHIP_TARGET_COUNT); - - l_beginning_offset = CHIP_TARGET_OFFSET; - - fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> chip_target((fapi2::plat_target_handle_t)0); - G_vec_targets.at(l_beginning_offset) = revle64((fapi2::plat_target_handle_t)(chip_target.get())); - - /* - * Pervasive Targets - */ - FAPI_DBG("Pervasive Target info: PERV_TARGET_OFFSET %u PERV_TARGET_COUNT %u", - PERV_TARGET_OFFSET, PERV_TARGET_COUNT); - - l_beginning_offset = PERV_TARGET_OFFSET; - for (uint32_t i = 0; i < PERV_TARGET_COUNT; ++i) - { - fapi2::Target<fapi2::TARGET_TYPE_PERV> target_name((fapi2::plat_target_handle_t)i+1); - FAPI_DBG("target_name i = %d hi word = 0x%08X", i+1, (uint32_t)(target_name.get()>>32)); - - // Determine if the chiplet is present and, thus, functional - // via partial good attributes - FAPI_TRY(plat_TargetPresent(chip_target, target_name, b_present)); - - G_vec_targets.at(l_beginning_offset+i) = revle64((fapi2::plat_target_handle_t)(target_name.get())); - FAPI_DBG("G offset = %d", l_beginning_offset+i); - } - - /* - * Cache (EQ) Targets - */ - FAPI_DBG("EQ Target info: EQ_TARGET_OFFSET %u EQ_TARGET_COUNT %u", - EQ_TARGET_OFFSET, EQ_TARGET_COUNT); - l_beginning_offset = EQ_TARGET_OFFSET; - for (uint32_t i = 0; i < EQ_TARGET_COUNT; ++i) - { - fapi2::Target<fapi2::TARGET_TYPE_EQ> target_name((fapi2::plat_target_handle_t)i); - FAPI_DBG("target_name i = %d hi word = 0x%08X", i, (uint32_t)(target_name.get()>>32)); - - // Determine if the chiplet is present and, thus, functional - // via partial good attributes - FAPI_TRY(plat_TargetPresent(chip_target, target_name, b_present)); - - G_vec_targets.at(l_beginning_offset+i) = revle64((fapi2::plat_target_handle_t)(target_name.get())); - FAPI_DBG("G offset = %d", l_beginning_offset+i); - } - - /* - * Core (EC) Targets - */ - FAPI_DBG("Core Target info: CORE_TARGET_OFFSET %u CORE_TARGET_COUNT %u", - CORE_TARGET_OFFSET, CORE_TARGET_COUNT); - - l_beginning_offset = CORE_TARGET_OFFSET; - FAPI_DBG("Core beginning offset =%u", l_beginning_offset); - for (uint32_t i = 0; i < CORE_TARGET_COUNT; ++i) - { - fapi2::Target<fapi2::TARGET_TYPE_CORE> target_name((fapi2::plat_target_handle_t)i); - FAPI_DBG("target_name i = %d hi word = 0x%08X", i, (uint32_t)(target_name.get()>>32)); - - // Determine if the chiplet is present and, thus, functional - // via partial good attributes - FAPI_TRY(plat_TargetPresent(chip_target, target_name, b_present)); - - G_vec_targets.at(l_beginning_offset+i) = revle64((fapi2::plat_target_handle_t)(target_name.get())); - FAPI_DBG("G offset = %d", l_beginning_offset+i); - } - - /* - * Memory Controller Synchronous (MCS) Targets - */ - FAPI_DBG("MCS Target info: MCS_TARGET_OFFSET %u MCS_TARGET_COUNT %u", - MCS_TARGET_OFFSET, MCS_TARGET_COUNT); - - l_beginning_offset = MCS_TARGET_OFFSET; - FAPI_DBG("MCS beginning offset =%u", l_beginning_offset); - for (uint32_t i = 0; i < MCS_TARGET_COUNT; ++i) - { - fapi2::Target<fapi2::TARGET_TYPE_MCS> target_name((fapi2::plat_target_handle_t)i); - FAPI_DBG("target_name i = %d hi word = 0x%08X", i, (uint32_t)(target_name.get()>>32)); - - // Determine if the chiplet is present and, thus, functional - // via partial good attributes - FAPI_TRY(plat_TargetPresent(chip_target, target_name, b_present)); - - G_vec_targets.at(l_beginning_offset+i) = revle64((fapi2::plat_target_handle_t)(target_name.get())); - FAPI_DBG("G offset = %d", l_beginning_offset+i); - - } - - // Trace all entries - for (auto tgt_iter : G_vec_targets) - { - FAPI_DBG("Trace hi word G_vec_targets[%u] value=%08X", - c, (uint32_t)(tgt_iter>>32)); - ++c; - } - -fapi_try_exit: - return fapi2::current_err; - } - - /// @brief Function to initialize the G_targets vector based on partial good - /// attributes - fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> plat_getChipTarget() - { - - // Get the chip specific target - return ((fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>)G_vec_targets.at(0)); - } - - -} // fapi2 diff --git a/hwpf/plat/target_map b/hwpf/plat/target_map deleted file mode 100755 index 4ea3c0d6..00000000 --- a/hwpf/plat/target_map +++ /dev/null @@ -1,49 +0,0 @@ - TARGET_TYPE_NONE = 0x00000000, - TARGET_TYPE_SYSTEM = 0x00000001, - TARGET_TYPE_DIMM = 0x00000002, - TARGET_TYPE_PROC_CHIP = 0x00000004, - TARGET_TYPE_MEMBUF_CHIP = 0x00000008, - TARGET_TYPE_EX = 0x00000010, - TARGET_TYPE_MBA = 0x00000020, - TARGET_TYPE_MCS = 0x00000040, - TARGET_TYPE_XBUS = 0x00000080, - TARGET_TYPE_ABUS = 0x00000100, - TARGET_TYPE_L4 = 0x00000200, - TARGET_TYPE_CORE = 0x00000400, - TARGET_TYPE_EQ = 0x00000800, - TARGET_TYPE_MCA = 0x00001000, - TARGET_TYPE_MCBIST = 0x00002000, - TARGET_TYPE_MIA = 0x00004000, - TARGET_TYPE_MIS = 0x00008000, - TARGET_TYPE_DMI = 0x00010000, - TARGET_TYPE_OBUS = 0x00020000, - TARGET_TYPE_NV = 0x00040000, - TARGET_TYPE_SBE = 0x00080000, - TARGET_TYPE_PPE = 0x00100000, - TARGET_TYPE_PERV = 0x00200000, - TARGET_TYPE_PEC = 0x00400000, - TARGET_TYPE_PHB = 0x00800000, - TARGET_TYPE_ALL = 0xFFFFFFFF - - - Perv 0x01 -N0 0x02 -N1 0x03 -N2 0x04 -N3 0x05 -XB 0x06 -MC0 0x07 -MC1 0x08 -OB0 0x09 -OB1 0x0A -OB2 0x0B -OB3 0x0C -PCI0 0x0D -PCI1 0x0E -PCI2 0x0F - - - - - - |