diff options
author | Brian Silver <bsilver@us.ibm.com> | 2015-04-09 09:51:38 -0500 |
---|---|---|
committer | Derk Rembold <rembold@de.ibm.com> | 2015-09-03 07:24:55 -0500 |
commit | 0f872cb6b2ad5cc40fc92304a60b0758a09a6730 (patch) | |
tree | e6eb46c0a7f91fcfabcba9c22d9e43bf4d880522 | |
parent | bda6ee41bdb09c336716c5b17e731e0ea9d75752 (diff) | |
download | talos-sbe-0f872cb6b2ad5cc40fc92304a60b0758a09a6730.tar.gz talos-sbe-0f872cb6b2ad5cc40fc92304a60b0758a09a6730.zip |
Migrate headers to support platform specializations
Add plat_target.H, fapi2_target.H
Add plat_error_scope.H, fapi2_error_scope.H
Update documentation to reflect platform support
Wrap buffer print() API to remove from platforms
Move target operators to platform specific files
Move target states to target_states.H
Add plat_hw_access, fapi2_hw_access.H
Make op mode and pib error platform specific
Change-Id: If376f656b2b8a8f207332d42494dd3ce099790c6
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/16970
Reviewed-by: Matt K. Light <mklight@us.ibm.com>
Reviewed-by: Thi N. Tran <thi@us.ibm.com>
Reviewed-by: Brian Silver <bsilver@us.ibm.com>
Tested-by: Brian Silver <bsilver@us.ibm.com>
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/20135
Tested-by: Jenkins Server
Reviewed-by: Derk Rembold <rembold@de.ibm.com>
-rw-r--r-- | import/hwpf/fapi2/include/buffer_base.H | 4 | ||||
-rw-r--r-- | import/hwpf/fapi2/include/buffer_traits.H | 9 | ||||
-rw-r--r-- | import/hwpf/fapi2/include/error_scope.H | 74 | ||||
-rw-r--r-- | import/hwpf/fapi2/include/fapi2_error_scope.H | 83 | ||||
-rw-r--r-- | import/hwpf/fapi2/include/fapi2_hw_access.H | 463 | ||||
-rw-r--r-- | import/hwpf/fapi2/include/fapi2_target.H | 420 | ||||
-rw-r--r-- | import/hwpf/fapi2/include/hw_access.H | 556 | ||||
-rw-r--r-- | import/hwpf/fapi2/include/hw_access_def.H | 77 | ||||
-rw-r--r-- | import/hwpf/fapi2/include/plat_error_scope.H | 68 | ||||
-rw-r--r-- | import/hwpf/fapi2/include/plat_hw_access.H | 39 | ||||
-rw-r--r-- | import/hwpf/fapi2/include/plat_target.H | 43 | ||||
-rw-r--r-- | import/hwpf/fapi2/include/return_code.H | 13 | ||||
-rw-r--r-- | import/hwpf/fapi2/include/target.H | 410 | ||||
-rw-r--r-- | import/hwpf/fapi2/include/target_states.H | 45 |
14 files changed, 1526 insertions, 778 deletions
diff --git a/import/hwpf/fapi2/include/buffer_base.H b/import/hwpf/fapi2/include/buffer_base.H index 8291de8a..aa611e00 100644 --- a/import/hwpf/fapi2/include/buffer_base.H +++ b/import/hwpf/fapi2/include/buffer_base.H @@ -178,7 +178,7 @@ namespace fapi2 virtual ~buffer_base(void) {} -#ifndef DOXYGEN +#if !defined(DOXYGEN) && defined(FAPI2_DEBUG) /// @brief Print the contents of the buffer to stdout inline void print(void) const { TT::print(iv_data); } @@ -236,7 +236,7 @@ namespace fapi2 static const bits_type bits_in_value = parameterTraits<OT>::bit_length(); const bits_type bit_length = TT::bit_length(iv_data); - if (i_offset + bits_in_value >= bit_length) + if (((i_offset * bits_in_value) + bits_in_value) > bit_length) { return FAPI2_RC_OVERFLOW; } diff --git a/import/hwpf/fapi2/include/buffer_traits.H b/import/hwpf/fapi2/include/buffer_traits.H index e397b70c..c1f5df54 100644 --- a/import/hwpf/fapi2/include/buffer_traits.H +++ b/import/hwpf/fapi2/include/buffer_traits.H @@ -35,8 +35,10 @@ #include <algorithm> #include <buffer_parameters.H> -// for debug printing ... can be removed for flight +#ifdef FAPI2_DEBUG #include <iostream> +#endif + #include <iterator> namespace fapi2 @@ -60,7 +62,8 @@ namespace fapi2 class bufferTraits { public: -#ifndef DOXYGEN + +#if !defined(DOXYGEN) && defined(FAPI2_DEBUG) /// /// @brief Print a container of bits /// @param[in] i_data the container of bits @@ -153,7 +156,7 @@ namespace fapi2 class bufferTraits<bits_container, uint32_t> { public: -#ifndef DOXYGEN +#if !defined(DOXYGEN) && defined(FAPI2_DEBUG) /// /// @brief Print a container of bits /// @param[in] i_data the container of bits diff --git a/import/hwpf/fapi2/include/error_scope.H b/import/hwpf/fapi2/include/error_scope.H index 4c916745..d742dd0e 100644 --- a/import/hwpf/fapi2/include/error_scope.H +++ b/import/hwpf/fapi2/include/error_scope.H @@ -24,82 +24,14 @@ /* IBM_PROLOG_END_TAG */ /** * @file error_scope.H - * @brief definitions which create a scope for automatic error handling + * @brief platform specializations which create a scope for automatic error handling */ #ifndef __FAPI2_ERROR_SCOPE__ #define __FAPI2_ERROR_SCOPE__ -#include <stdint.h> -#include <thread> -#include <stdio.h> -#include <return_code.H> -#include <hwp_ffdc_classes.H> - -/// @cond -#define FAPI_VA_NARGS_IMPL(_1, _2, _3, _4, _5, N, ...) N -#define FAPI_VA_NARGS(...) FAPI_VA_NARGS_IMPL(__VA_ARGS__, 5, 4, 3, 2, 1) - -#define FAPI_TRY_IMPL2(count, ...) FAPI_TRY ## count (__VA_ARGS__) -#define FAPI_TRY_IMPL(count, ...) FAPI_TRY_IMPL2(count, __VA_ARGS__) - -#define FAPI_TRY_NO_TRACE( __operation__ ) \ - if ((fapi2::current_err = (__operation__)) != fapi2::FAPI2_RC_SUCCESS) \ - { \ - goto fapi_try_exit; \ - } - -// Why debug? Because this isn't a mechanism to gather FFDC -// one should be using FAPI_ASSERT. However, it is nice to -// have a conditional trace in the event of a failure in the -// operation, so that's why this is here. -#define FAPI_TRY_TRACE( __operation__, ... ) \ - if ((fapi2::current_err = (__operation__)) != fapi2::FAPI2_RC_SUCCESS) \ - { \ - FAPI_DBG(__VA_ARGS__); \ - goto fapi_try_exit; \ - } - -#define FAPI_TRY1 FAPI_TRY_NO_TRACE -#define FAPI_TRY2 FAPI_TRY_TRACE -#define FAPI_TRY3 FAPI_TRY_TRACE -#define FAPI_TRY4 FAPI_TRY_TRACE -#define FAPI_TRY5 FAPI_TRY_TRACE -/// @endcond - -/// -/// @brief Wrapper to check an operation for an error state -/// and jump to the label cleam_up if there is an error. -/// @param[in] __operation__ an operation which returns a fapi::ReturnCode -/// @param[in] ... vararg format/agruments for trace output (optional) -/// @note This implementation does not support PIB error masks or -/// FSP operational states. -/// @warning The trace information is only going to be seen during -/// debug, it's not an error or informational trace. This is because -/// traces might not be seen in the field. If you want information -/// you will see on a field error, use FAPI_ASSERT. -/// -#ifdef DOXYGEN -#define FAPI_TRY(__operation__, ...) FAPI_TRY_IMPL -#else -#define FAPI_TRY(...) FAPI_TRY_IMPL(FAPI_VA_NARGS(__VA_ARGS__), __VA_ARGS__) -#endif - -/// -/// @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 FAPI_ASSERT( __conditional__, __ffdc__, ... ) \ - if (! (__conditional__)) \ - { \ - (__ffdc__).execute(); \ - FAPI_ERR(__VA_ARGS__); \ - goto fapi_try_exit; \ - } +#include <plat_error_scope.H> +#include <fapi2_error_scope.H> #endif diff --git a/import/hwpf/fapi2/include/fapi2_error_scope.H b/import/hwpf/fapi2/include/fapi2_error_scope.H new file mode 100644 index 00000000..c21e3b63 --- /dev/null +++ b/import/hwpf/fapi2/include/fapi2_error_scope.H @@ -0,0 +1,83 @@ +/* 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_error_scope.H + * @brief common definitions which create a scope for automatic error handling + */ + +#ifndef __FAPI2_COMMON_ERROR_SCOPE__ +#define __FAPI2_COMMON_ERROR_SCOPE__ + +#include <stdint.h> +#include <plat_error_scope.H> +#include <return_code.H> +#include <hwp_ffdc_classes.H> + +/// @cond +#define FAPI_VA_NARGS_IMPL(_1, _2, _3, _4, _5, N, ...) N +#define FAPI_VA_NARGS(...) FAPI_VA_NARGS_IMPL(__VA_ARGS__, 5, 4, 3, 2, 1) + +#define FAPI_TRY_IMPL2(count, ...) FAPI_TRY ## count (__VA_ARGS__) +#define FAPI_TRY_IMPL(count, ...) FAPI_TRY_IMPL2(count, __VA_ARGS__) + +#define FAPI_TRY_NO_TRACE( __operation__ ) PLAT_FAPI_TRY_NO_TRACE( __operation__ ) +#define FAPI_TRY_TRACE( __operation__, ... ) PLAT_FAPI_TRY_TRACE( __operation__, __VA_ARGS__ ) + +#define FAPI_TRY1 FAPI_TRY_NO_TRACE +#define FAPI_TRY2 FAPI_TRY_TRACE +#define FAPI_TRY3 FAPI_TRY_TRACE +#define FAPI_TRY4 FAPI_TRY_TRACE +#define FAPI_TRY5 FAPI_TRY_TRACE +/// @endcond + +/// +/// @brief Wrapper to check an operation for an error state +/// and jump to the label cleam_up if there is an error. +/// @param[in] __operation__ an operation which returns a fapi::ReturnCode +/// @param[in] ... vararg format/agruments for trace output (optional) +/// @note This implementation does not support PIB error masks or +/// FSP operational states. +/// @warning The trace information is only going to be seen during +/// debug, it's not an error or informational trace. This is because +/// traces might not be seen in the field. If you want information +/// you will see on a field error, use FAPI_ASSERT. +/// +#ifdef DOXYGEN +#define FAPI_TRY(__operation__, ...) FAPI_TRY_IMPL +#else +#define FAPI_TRY(...) FAPI_TRY_IMPL(FAPI_VA_NARGS(__VA_ARGS__), __VA_ARGS__) +#endif + +/// +/// @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 FAPI_ASSERT( __conditional__, __ffdc__, ... ) PLAT_FAPI_ASSERT( __conditional__, __ffdc__, __VA_ARGS__ ) + +#endif diff --git a/import/hwpf/fapi2/include/fapi2_hw_access.H b/import/hwpf/fapi2/include/fapi2_hw_access.H new file mode 100644 index 00000000..8eecc011 --- /dev/null +++ b/import/hwpf/fapi2/include/fapi2_hw_access.H @@ -0,0 +1,463 @@ +/* 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 ReturnCode getScom(const Target<K>& i_target, const uint64_t i_address, + buffer<uint64_t>& o_data); + + /// @brief Writes a SCOM register on a chip. + /// @tparam K template parameter, passed in target. + /// @param[in] i_target HW target to operate on. + /// @param[in] i_address SCOM register address to write to. + /// @param[in] i_data Buffer that holds data to write into address. + /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + template< TargetType K > + inline ReturnCode putScom(const Target<K>& i_target, const uint64_t i_address, + const buffer<uint64_t> i_data); + + /// @brief Writes a SCOM register under mask on a chip + /// @tparam K template parameter, passed in target. + /// @param[in] i_target HW target to operate on. + /// @param[in] i_address SCOM register address to write to. + /// @param[in] i_data Buffer that holds data to write into address. + /// @param[in] i_mask Buffer that holds the mask value. + /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + template< TargetType K > + inline ReturnCode putScomUnderMask(const Target<K>& i_target, + const uint64_t i_address, + const buffer<uint64_t> i_data, + const buffer<uint64_t> i_mask); + + /// @brief Reads a CFAM register from a chip. + /// CFAM register is 32-bit wide. + /// @tparam K template parameter, passed in target. + /// @param[in] i_target HW target to operate on. + /// @param[in] i_address CFAM register address to read from. + /// @param[out] o_data Buffer that holds data read from HW target. + /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + template< TargetType K > + inline ReturnCode getCfamRegister(const Target<K>& i_target, + const uint32_t i_address, + buffer<uint32_t>& o_data); + + /// @brief Writes a CFAM register on a chip. + /// CFAM register is 32-bit wide. + /// @tparam K template parameter, passed in target. + /// @param[in] i_target HW target to operate on. + /// @param[in] i_address CFAM register address to write to. + /// @param[in] i_data Buffer that holds data to write into address. + /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + template< TargetType K > + inline ReturnCode putCfamRegister(const Target<K>& i_target, + const uint32_t i_address, + const buffer<uint32_t> i_data); + + /// @brief Read-modify-write a CFAM register on a chip. + /// CFAM register is 32-bit wide. + /// @tparam K template parameter, passed in target. + /// @param[in] i_target HW target to operate on. + /// @param[in] i_address CFAM register address to modify. + /// @param[in] i_data Buffer that holds data to be modified. + /// @param[in] i_modifyMode The modify mode (or/and/xor). + /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + template< TargetType K > + inline ReturnCode modifyCfamRegister(const Target<K>& i_target, + const uint32_t i_address, + const buffer<uint32_t> i_data, + const ChipOpModifyMode i_modifyMode); + + // variable_buffer isn't supported on PPE +#ifndef __PPE__ + /// @brief Reads a ring from a chip. + /// @tparam K template parameter, passed in target. + /// @param[in] i_target Target to operate on. + /// @param[in] i_address Ring address to read from. + /// @param[out] o_data Buffer that holds data read from HW target. + /// @param[in] i_ringMode Ring operation mode. + /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + template< TargetType K > + inline ReturnCode getRing(const Target<K>& i_target, + const scanRingId_t i_address, + variable_buffer& o_data, + const RingMode i_ringMode = 0); + + /// @brief Writes a ring to a chip. + /// @tparam K template parameter, passed in target. + /// @param[in] i_target Target to operate on. + /// @param[in] i_address Ring address to write to. + /// @param[in] i_data Buffer that contains RS4 compressed ring data + /// to write into address + /// @param[in] i_ringMode Ring operation mode. + /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + template< TargetType K > + inline ReturnCode putRing(const Target<K>& i_target, + const scanRingId_t i_address, + const variable_buffer& i_data, + const RingMode i_ringMode = 0); +#endif + + /// @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); + +#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 + +#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 + +#ifdef FAPI_SUPPORT_SPY_AS_STRING + +#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 + /// +#ifdef FAPI_SUPPORT_SPY_AS_ENUM + +#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 + +#ifdef FAPI_SUPPORT_SPY_AS_STRING + +#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. + /// +#ifdef FAPI_SUPPORT_SPY_AS_ENUM + +#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 + +#ifdef FAPI_SUPPORT_SPY_AS_STRING + +#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. + /// +#ifdef FAPI_SUPPORT_SPY_AS_ENUM + +#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 + +#ifdef FAPI_SUPPORT_SPY_AS_STRING + +#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/import/hwpf/fapi2/include/fapi2_target.H b/import/hwpf/fapi2/include/fapi2_target.H new file mode 100644 index 00000000..ce0e950c --- /dev/null +++ b/import/hwpf/fapi2/include/fapi2_target.H @@ -0,0 +1,420 @@ +/* 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_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 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 = 0): + 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 iv_handle; } + + /// + /// @brief Get the handle as a V + /// @return V The target's handle, or value + /// + inline operator V() const { return iv_handle; } + + /// + /// @brief Get a target's value + /// @return V The target's handle, or value + /// + inline V& operator()(void) { return iv_handle; } + + /// + /// @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 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"); + } + + 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; + V iv_handle; + + }; + + // EX threads map to CORE threads: + // t0 / t2 / t4 / t6 fused = t0 / t1 / t2 / t3 normal (c0) + // t1 / t3 / t5 / t7 fused = t0 / t1 / t2 / t3 normal (c1) + // So when splitting the EX, we need to map from EX threads + // to CORE threads. + + /// + /// @brief Given a normal core thread id, translate this to + /// a fused core thread id. (normal to fused) + /// @param[in] the ordinal number of the normal core this thread belongs to + /// @param[in] a normal core thread id - 0, ..., 3 + /// @return the fused core thread id + /// + inline uint8_t thread_id_n2f(const uint8_t i_ordinal, const uint8_t i_thread_id) + { + return (i_thread_id << 1) | i_ordinal; + } + + /// + /// @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/import/hwpf/fapi2/include/hw_access.H b/import/hwpf/fapi2/include/hw_access.H index 7df0f5f5..d1c2ad28 100644 --- a/import/hwpf/fapi2/include/hw_access.H +++ b/import/hwpf/fapi2/include/hw_access.H @@ -22,85 +22,46 @@ /* permissions and limitations under the License. */ /* */ /* IBM_PROLOG_END_TAG */ -/** - * @file hw_access.H - * - * @brief Defines the hardware access functions that platform code must - * implement. - */ -#ifndef FAPI2_HWACCESS_H_ -#define FAPI2_HWACCESS_H_ +/// @file hw_access.H +/// +/// @brief Hardware access functions that needs to be specialized for +/// platform implementation. +/// -#ifdef FAPI_SUPPORT_SPY_AS_ENUM -#include <fapiSpyIds.H> -#endif +#ifndef _FAPI2_HWACCESS_H_ +#define _FAPI2_HWACCESS_H_ -#include <stdint.h> -#include <thread> -#include <buffer.H> + // variable_buffer isn't supported on PPE +#ifndef __PPE__ #include <variable_buffer.H> -#include <return_code.H> -#include <target.H> - -#ifdef FAPI_SUPPORT_MULTI_SCOM -#include <fapiMultiScom.H> #endif -/// @cond -typedef uint64_t spyId_t; -typedef uint64_t scanRingId_t; -/// @endcond +#include <plat_hw_access.H> +#include <fapi2_hw_access.H> namespace fapi2 { - - /// - /// @enum fapi2::ChipOpModifyMode - /// @brief Enumeration of modify modes used in HW access modify operations - /// - enum ChipOpModifyMode - { - CHIP_OP_MODIFY_MODE_OR = 1, ///< Modify or mode - CHIP_OP_MODIFY_MODE_AND = 2, ///< Modify and mode - CHIP_OP_MODIFY_MODE_XOR = 3, ///< Modify xor mode - }; - - /// - /// @enum fapi2::RingMode - /// @brief Enumeration of Ring access operation modes - /// This is a bitmap to allow the user to specify multiple modes. - /// - enum RingMode - { - RING_MODE_SET_PULSE = 0x00000001, ///< Set pulse - RING_MODE_NO_HEADER_CHECK = 0x00000002, ///< Dont' check header - // FUTURE_MODE = 0x00000004, - // FUTURE_MODE = 0x00000008, - }; - //-------------------------------------------------------------------------- // PIB Error Functions //-------------------------------------------------------------------------- /// @brief Sets the PIB error mask - platform dependant /// @param[in] i_mask The new error mask + // note: this can be moved to a C file if desired inline void setPIBErrorMask(uint8_t i_mask) { // Keeps the compiler from complaining about the unused i_mask static_cast<void>(i_mask); - // Platform specific funtion needs to be defined here. - // For Cronus/FSP/Hostboot, this is a no-op. return; } /// @brief Gets the PIB error mask - platform dependant /// @return uint8_t The current PIB error mask + // note: this can be moved to a C file if desired inline uint8_t getPIBErrorMask(void) { - // Platform specific funtion needs to be defined here. - // For Cronus/FSP/Hostboot, this always returns 0 return 0; } @@ -108,17 +69,9 @@ namespace fapi2 // Operational Mode Error Functions //-------------------------------------------------------------------------- - /// @enum OpModes operational Mode Error Functions - enum OpModes - { - // These are bit-masks in case they need to be or'd together - NORMAL = 0x00, - IGNORE_HW_ERROR = 0x01, - DO_NOT_DO_WAKEUP = 0x02, - }; - /// @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 @@ -130,24 +83,28 @@ namespace fapi2 /// @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 - //-------------------------------------------------------------------------- + //------------------------------------------------------------------------------ + // HW Communication Functions to be implemented at the platform layer. + //------------------------------------------------------------------------------ - /// @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. + /// + /// @brief Platform-level implementation of getScom() + /// @Tparam K template parameter, passed in target. + /// @param[in] i_target HW target to operate on. + /// @param[in] i_address SCOM register address to read from. + /// @param[out] o_date Buffer that holds data read from HW target. /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + /// template< TargetType K > - inline ReturnCode getScom(const Target<K>& i_target, const uint64_t i_address, + inline ReturnCode getScom(const Target<K>& i_target, + const uint64_t i_address, buffer<uint64_t>& o_data) { o_data = 0x0000FEEDFACE0000; @@ -157,18 +114,20 @@ namespace fapi2 << "address: " << i_address << "; " << "output data: " << uint64_t(o_data) << std::dec << std::endl; + return FAPI2_RC_SUCCESS; } - /// @brief Writes a SCOM register on a chip. - /// @tparam K template parameter, passed in target. + /// @brief Platform-level implementation of putScom() + /// @Tparam K template parameter, passed in target. /// @param[in] i_target HW target to operate on. /// @param[in] i_address SCOM register address to write to. /// @param[in] i_data Buffer that holds data to write into address. /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. template< TargetType K > - inline ReturnCode putScom(const Target<K>& i_target, const uint64_t i_address, - buffer<uint64_t> i_data) + inline ReturnCode putScom(const Target<K>& i_target, + const uint64_t i_address, + const buffer<uint64_t> i_data) { std::cout << std::hex << " putScom " << "target: {" << i_target.getType() << "," @@ -179,31 +138,7 @@ namespace fapi2 return FAPI2_RC_SUCCESS; } - /// @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 ReturnCode 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 = i_data; - std::cout << std::hex << " modifyScom " - << "target: {" << i_target.getType() << "," - << uint64_t(i_target) << "}; " - << "address: " << i_address << "; " - << "input modifying data: " << uint64_t(l_modifyDataBuffer) << "; " - << "input ChipOpModifyMode: " << i_modifyMode - << std::dec << std::endl; - return FAPI2_RC_SUCCESS; - } - - /// @brief Writes a SCOM register under mask on a chip + /// @brief Platform-level implementation of putScomUnderMask() /// @tparam K template parameter, passed in target. /// @param[in] i_target HW target to operate on. /// @param[in] i_address SCOM register address to write to. @@ -213,8 +148,8 @@ namespace fapi2 template< TargetType K > inline ReturnCode putScomUnderMask(const Target<K>& i_target, const uint64_t i_address, - buffer<uint64_t>& i_data, - buffer<uint64_t>& i_mask) + const buffer<uint64_t> i_data, + const buffer<uint64_t> i_mask) { std::cout << std::hex << " putScomUnderMask " << "target: {" << i_target.getType() << "," @@ -226,13 +161,15 @@ namespace fapi2 return FAPI2_RC_SUCCESS; } - /// @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. + /// + /// @brief Platform-level implementation called by getCfamRegister() + /// Hardware procedures writers will not call this function. + /// @Tparam K template parameter, passed in target. + /// @param[in] i_target HW target to operate on. + /// @param[in] i_address CFAM address to read from. + /// @param[out] o_data 32-bit buffer that holds data read from HW target. /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + /// template< TargetType K > inline ReturnCode getCfamRegister(const Target<K>& i_target, const uint32_t i_address, @@ -248,17 +185,19 @@ namespace fapi2 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. + /// + /// @brief Platform-level implementation of putCfamRegister() + /// Hardware procedures writers will not call this function. + /// @Tparam K template parameter, passed in target. + /// @param[in] i_target HW target to operate on. + /// @param[in] i_address CFAM address to write to. + /// @param[out] i_data 32-bit buffer that holds data to write into address. /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + /// template< TargetType K > inline ReturnCode putCfamRegister(const Target<K>& i_target, const uint32_t i_address, - buffer<uint32_t>& i_data) + const buffer<uint32_t> i_data) { std::cout << std::hex << " putCfamRegister " << "target: {" << i_target.getType() << "," @@ -269,43 +208,50 @@ namespace fapi2 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). + + /// + /// @brief Platform-level implementation of modifyCfamRegister() + /// Hardware procedures writers will not call this function. + /// @Tparam K template parameter, passed in target. + /// @param[in] i_target HW target to operate on. + /// @param[in] i_address CFAM register address to modify. + /// @param[out] i_data 32-bit buffer that holds data to modify. + /// @param[in] i_modifyMode The modify mode (or/and/xor). /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + /// template< TargetType K > inline ReturnCode modifyCfamRegister(const Target<K>& i_target, const uint32_t i_address, - const buffer<uint32_t>& i_data, - const ChipOpModifyMode i_modifyMode) + const buffer<uint32_t> i_data, + const fapi2::ChipOpModifyMode i_modifyMode) { - fapi2::buffer<uint32_t> l_modifyDataBuffer = i_data; std::cout << std::hex << " modifyCfamRegister " << "target: {" << i_target.getType() << "," << uint64_t(i_target) << "}; " << "address: " << i_address << "; " - << "input modifying data: " << uint32_t(l_modifyDataBuffer) << "; " + << "input modifying data: " << uint32_t(i_data) << "; " << "input ChipOpModifyMode: " << i_modifyMode << std::dec << std::endl; return FAPI2_RC_SUCCESS; } - /// @brief Reads a ring from a chip. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target Target to operate on. + // variable_buffer isn't supported on PPE +#ifndef __PPE__ + /// + /// @brief Platform-level implementation of getRing() + /// Hardware procedures writers will not call this function. + /// @Tparam K template parameter, passed in target. + /// @param[in] i_target HW target to operate on. /// @param[in] i_address Ring address to read from. - /// @param[out] o_data Buffer that holds data read from HW target. + /// @param[out] o_data Buffer that holds ring data read from HW target. /// @param[in] i_ringMode Ring operation mode. /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + /// template< TargetType K > inline ReturnCode getRing(const Target<K>& i_target, const scanRingId_t i_address, variable_buffer& o_data, - const RingMode i_ringMode = 0) + const RingMode i_ringMode) { o_data.setBit(0); o_data.setBit(3); @@ -314,13 +260,14 @@ namespace fapi2 << uint64_t(i_target) << "}; " << "ring address: " << i_address << "; " << "ring mode: " << i_ringMode << "; " - << "output data:"; - o_data.print(); + << "first element of output data: " << o_data()[0] + << std::endl; return FAPI2_RC_SUCCESS; } - /// @brief Writes a ring to a chip. + /// @brief Platform-level implementation of putRing() + /// Hardware procedures writers will not call this function. /// @tparam K template parameter, passed in target. /// @param[in] i_target Target to operate on. /// @param[in] i_address Ring address to write to. @@ -331,51 +278,21 @@ namespace fapi2 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) + const variable_buffer& i_data, + const RingMode i_ringMode) { std::cout << std::hex << " putRing " << "target: {" << i_target.getType() << "," << uint64_t(i_target) << "}; " << "address: " << i_address << "; " << "ring mode: " << i_ringMode << "; " - << "input data:"; - i_data.print(); + << "first element of the input data: " << i_data()[0] + << std::endl; 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)); - std::cout << std::hex << " putRing (void*) " - << "target: {" << i_target.getType() << "," - << uint64_t(i_target) << "}; " - << "address: " << i_address << "; " - << "ring mode: " << i_ringMode << "; " - << "input data: " << (uint64_t)(*dataPtr) - << (uint64_t)*(dataPtr+1) - << (uint64_t)*(dataPtr+2) - << (uint64_t)*(dataPtr+3); - std::cout << std::dec << std::endl; - - return FAPI2_RC_SUCCESS; - } - - /// @brief Read-modify-write a ring on a chip. + /// @brief Platform-level implementation of modifyRing() /// @tparam K template parameter, passed in target. /// @param[in] i_target Target to operate on. /// @param[in] i_address Ring address to modify. @@ -387,9 +304,9 @@ namespace fapi2 template< TargetType K > inline ReturnCode modifyRing(const Target<K>& i_target, const scanRingId_t i_address, - variable_buffer& i_data, + const variable_buffer& i_data, const ChipOpModifyMode i_modifyMode, - const RingMode i_ringMode = 0) + const RingMode i_ringMode) { std::cout << std::hex << " modifyRing " << "target: {" << i_target.getType() << "," @@ -397,23 +314,73 @@ namespace fapi2 << "address: " << i_address << "; " << "input ChipOpModifyMode: " << i_modifyMode << "; " << "ring mode: " << i_ringMode << "; " - << "input data: "; - i_data.print(); + << "first element of the input data: " << i_data()[0] + << std::endl; return FAPI2_RC_SUCCESS; } +#endif - /// @note - /// These spy access interfaces are only used in FSP and cronus - /// HB does not allow spy access +#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 -#if defined(FAPI_SUPPORT_SPY_AS_ENUM) || defined(FAPI_SUPPORT_SPY_AS_STRING) || defined(DOXYGEN) + // -------------------------------------------------------------------------- + // 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 fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. /// /// @note: The string version is only supported for cronus. /// @@ -441,60 +408,38 @@ namespace fapi2 /// /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS /// - /// fapi::ReturnCode rc = fapiGetSpy( targ, + /// 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 /// -#endif - -// Set to 1 for fapi2 API test -#define FAPI_SUPPORT_SPY_AS_ENUM 1 - #ifdef FAPI_SUPPORT_SPY_AS_ENUM - -#ifndef DOXYGEN -#define fapiGetSpy(TARGET, ID, DATA) \ - _fapiGetSpy(TARGET, FAPI_SPY_NAMES::ID.value, DATA ) -#endif template< TargetType K > - inline ReturnCode _fapiGetSpy(const Target<K>& i_target, - const spyId_t i_spyId, - variable_buffer& o_data) + inline ReturnCode getSpy(const Target<K>& i_target, + const spyId_t i_spyId, + variable_buffer& o_data) { - o_data.setBit(1); - o_data.setBit(4); - std::cout << std::hex << " _fapiGetSpy " - << "target: {" << i_target.getType() << "," - << uint64_t(i_target) << "}; " - << "Spy ID: " << i_spyId << "; " - << "output data:"; - o_data.print(); - - return FAPI2_RC_SUCCESS; + static_assert(K == 0, "implement getSpy (string)"); + return ~FAPI2_RC_SUCCESS; } - #endif - #ifdef FAPI_SUPPORT_SPY_AS_STRING - -#ifndef DOXYGEN -#define fapiGetSpy(TARGET, ID, DATA) _fapiGetSpy(TARGET, #ID, DATA) -#endif template< TargetType K > - inline ReturnCode _fapiGetSpy(const Target<K>& i_target, - const char * const i_spyId, - variable_buffer& o_data); + 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 - -#if defined(FAPI_SUPPORT_SPY_AS_ENUM) || defined(FAPI_SUPPORT_SPY_AS_STRING) || defined(DOXYGEN) /// @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 fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. /// /// @note: The string version is only supported for cronus. /// @@ -522,47 +467,32 @@ namespace fapi2 /// /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS /// - /// fapi::ReturnCode rc = fapiPutSpy( targ, + /// 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 /// -#endif - #ifdef FAPI_SUPPORT_SPY_AS_ENUM -#ifndef DOXYGEN -#define fapiPutSpy(TARGET, ID, DATA) \ - _fapiPutSpy(TARGET, FAPI_SPY_NAMES::ID.value, DATA) -#endif template< TargetType K > - inline ReturnCode _fapiPutSpy(const Target<K>& i_target, - const spyId_t i_spyId, - variable_buffer& i_data) + inline ReturnCode putSpy(const Target<K>& i_target, + const spyId_t i_spyId, + variable_buffer& i_data) { - std::cout << std::hex << " _fapiPutSpy " - << "target: {" << i_target.getType() << "," - << uint64_t(i_target) << "}; " - << "Spy Id: " << i_spyId << "; " - << "input data:"; - i_data.print(); - - return FAPI2_RC_SUCCESS; + static_assert(K == 0, "implement putSpy (enum)"); + return ~FAPI2_RC_SUCCESS; } #endif - #ifdef FAPI_SUPPORT_SPY_AS_STRING -#ifndef DOXYGEN -#define fapiPutSpy(TARGET, ID, DATA) _fapiPutSpy(TARGET, #ID, DATA) -#endif template< TargetType K > - inline ReturnCode _fapiPutSpy(const Target<K>& i_target, - const char* const i_spyId, - variable_buffer& i_data); + 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 - -#if defined(FAPI_SUPPORT_SPY_AS_ENUM) || defined(FAPI_SUPPORT_SPY_AS_STRING) - /// @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. @@ -572,7 +502,7 @@ namespace fapi2 /// @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 fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. /// /// @note: The string version is only supported for cronus. /// @@ -583,58 +513,35 @@ namespace fapi2 /// /// See fapiPutSpy for details on spy id specifics. /// -#endif - #ifdef FAPI_SUPPORT_SPY_AS_ENUM -#ifndef DOCUMENTATION -#define fapiPutSpyImage(TARGET, ID, DATA1, DATA2) \ - _fapiPutSpyImage(TARGET, \ - FAPI_SPY_NAMES::ID.value, \ - DATA1, DATA2) -#endif template< TargetType K > - inline ReturnCode _fapiPutSpyImage(const Target<K>& i_target, - const spyId_t i_spyId, - variable_buffer& i_data, - variable_buffer& o_imageData) + inline ReturnCode putSpyImage(const Target<K>& i_target, + const spyId_t i_spyId, + const variable_buffer& i_data, + variable_buffer& o_imageData) { - std::cout << std::hex << " _fapiPutSpyImage " - << "target: {" << i_target.getType() << "," - << uint64_t(i_target) << "}; " - << "Spy Id: " << i_spyId << "; " - << "input data: "; - i_data.print(); - - // Set fake output data - o_imageData.invert(); - - return FAPI2_RC_SUCCESS; + static_assert(K == 0, "implement putSpyImage (enum)"); + return ~FAPI2_RC_SUCCESS; } #endif - #ifdef FAPI_SUPPORT_SPY_AS_STRING -// fapiPutSpyImage function Cronus version -#ifndef DOCUMENTATION -#define fapiPutSpyImage(TARGET, ID, DATA1, DATA2) \ - _fapiPutSpyImage(TARGET, #ID, \ - DATA1,DATA2) -#endif - template< TargetType K > - inline ReturnCode _fapiPutSpyImage(const Target<K>& i_target, - const char* const i_spyId, - variable_buffer& i_data, - variable_buffer& o_imageData); + 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 - -#if defined(FAPI_SUPPORT_SPY_AS_ENUM) || defined(FAPI_SUPPORT_SPY_AS_STRING) || defined(DOXYGEN) /// @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 fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. /// /// @note: The string version is only supported for cronus. /// @@ -645,82 +552,31 @@ namespace fapi2 /// /// See fapiPutSpy for details on spy id specifics. /// -#endif - #ifdef FAPI_SUPPORT_SPY_AS_ENUM -#ifndef DOXYGEN -#define fapiGetSpyImage(TARGET, ID, DATA1, DATA2) \ - _fapiGetSpyImage(TARGET, \ - FAPI_SPY_NAMES::ID.value, \ - DATA1, DATA2) -#endif template< TargetType K > - inline ReturnCode _fapiGetSpyImage(const Target<K>& i_target, - const spyId_t i_spyId, - variable_buffer& o_data, - const variable_buffer& i_imageData); + 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 -// fapiGetSpyImage function Cronus version -#ifndef DOXYGEN -#define fapiGetSpyImage(TARGET, ID, DATA1, DATA2) \ - _fapiGetSpyImage(TARGET, \ - #ID, DATA1,DATA2) -#endif - - inline fapi::ReturnCode _fapiGetSpyImage( - const fapi::Target& i_target, - const char* const i_spyId, - fapi::buffer<fapi::bits_container> & o_data, - const fapi::buffer<fapi::bits_container> & i_imageData); + template< TargetType K > + inline ReturnCode getSpyImage(const Target<K>& i_target, + const char * const i_spyId, + variable_buffer& o_data, + const variable_buffer& i_imageData) + { + static_assert(K == 0, "implement getSpyImage (string)"); + return ~FAPI2_RC_SUCCESS; + } #endif -#if defined(FAPI_SUPPORT_MULTI_SCOM) || defined(DOXYGEN) - - /// @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 fapi::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. - /// - fapi::ReturnCode fapiMultiScom (const Target<K>& i_target, - MultiScom& io_multiScomObj); -#endif // FAPI_SUPPORT_MULTI_SCOM +#endif // PPE }; -#endif // FAPI2HWACCESS_H_ +#endif // _FAPI2_HWACCESS_H_ diff --git a/import/hwpf/fapi2/include/hw_access_def.H b/import/hwpf/fapi2/include/hw_access_def.H new file mode 100644 index 00000000..098efb8c --- /dev/null +++ b/import/hwpf/fapi2/include/hw_access_def.H @@ -0,0 +1,77 @@ +/* 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_def.H +/// @brief Hardware access definitions +/// + +#ifndef FAPI2_HWACCESSDEF_H_ +#define FAPI2_HWACCESSDEF_H_ + +#include <stdint.h> + +/// @cond +typedef uint64_t spyId_t; +typedef uint64_t scanRingId_t; +/// @endcond + +namespace fapi2 +{ + /// + /// @enum fapi2::ChipOpModifyMode + /// @brief Enumeration of modify modes used in HW access modify operations + /// + enum ChipOpModifyMode + { + CHIP_OP_MODIFY_MODE_OR = 1, ///< Modify or mode + CHIP_OP_MODIFY_MODE_AND = 2, ///< Modify and mode + CHIP_OP_MODIFY_MODE_XOR = 3, ///< Modify xor mode + }; + + /// + /// @enum fapi2::RingMode + /// @brief Enumeration of Ring access operation modes + /// This is a bitmap to allow the user to specify multiple modes. + /// + enum RingMode + { + RING_MODE_SET_PULSE = 0x00000001, ///< Set pulse + RING_MODE_NO_HEADER_CHECK = 0x00000002, ///< Dont' check header + // FUTURE_MODE = 0x00000004, + // FUTURE_MODE = 0x00000008, + }; + + /// @enum OpModes operational Mode Error Functions + enum OpModes + { + // These are bit-masks in case they need to be or'd together + NORMAL = 0x00, + IGNORE_HW_ERROR = 0x01, + DO_NOT_DO_WAKEUP = 0x02, + }; + +} + +#endif diff --git a/import/hwpf/fapi2/include/plat_error_scope.H b/import/hwpf/fapi2/include/plat_error_scope.H new file mode 100644 index 00000000..1c0bc239 --- /dev/null +++ b/import/hwpf/fapi2/include/plat_error_scope.H @@ -0,0 +1,68 @@ +/* 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__ ) \ + if ((fapi2::current_err = (__operation__)) != fapi2::FAPI2_RC_SUCCESS) \ + { \ + goto fapi_try_exit; \ + } + +// Why debug? Because this isn't a mechanism to gather FFDC +// one should be using FAPI_ASSERT. However, it is nice to +// have a conditional trace in the event of a failure in the +// operation, so that's why this is here. +#define PLAT_FAPI_TRY_TRACE( __operation__, ... ) \ + if ((fapi2::current_err = (__operation__)) != fapi2::FAPI2_RC_SUCCESS) \ + { \ + FAPI_DBG(__VA_ARGS__); \ + goto fapi_try_exit; \ + } + +/// +/// @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; \ + } +/// @endcond + +#endif diff --git a/import/hwpf/fapi2/include/plat_hw_access.H b/import/hwpf/fapi2/include/plat_hw_access.H new file mode 100644 index 00000000..208ed759 --- /dev/null +++ b/import/hwpf/fapi2/include/plat_hw_access.H @@ -0,0 +1,39 @@ +/* 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_hw_access.H +/// +/// @brief Platform hardware-access definitions +/// + +#ifndef _FAPI2_PLAT_HWACCESS_H_ +#define _FAPI2_PLAT_HWACCESS_H_ + +namespace fapi2 +{ + +} + +#endif // _FAPI2_PLAT_HWACCESS_H_ diff --git a/import/hwpf/fapi2/include/plat_target.H b/import/hwpf/fapi2/include/plat_target.H new file mode 100644 index 00000000..86c70465 --- /dev/null +++ b/import/hwpf/fapi2/include/plat_target.H @@ -0,0 +1,43 @@ +/* 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__ + +// +// 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/import/hwpf/fapi2/include/return_code.H b/import/hwpf/fapi2/include/return_code.H index e4f8edac..32e4af19 100644 --- a/import/hwpf/fapi2/include/return_code.H +++ b/import/hwpf/fapi2/include/return_code.H @@ -32,8 +32,9 @@ #include <stdint.h> -// Remove this for platforms which don't support FFDC -#include <ffdc.H> +#ifndef FAPI2_NO_FFDC + #include <ffdc.H> +#endif /// /// @brief Set HWP Error macro @@ -115,9 +116,13 @@ namespace fapi2 /// /// @brief Class representing a FAPI2 ReturnCode /// - /// @note Remove the inheritance relationship with FirstFailureData if - /// the platform doesn't support FFDC. + // 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: diff --git a/import/hwpf/fapi2/include/target.H b/import/hwpf/fapi2/include/target.H index ee340452..1cd14451 100644 --- a/import/hwpf/fapi2/include/target.H +++ b/import/hwpf/fapi2/include/target.H @@ -24,343 +24,102 @@ /* IBM_PROLOG_END_TAG */ /** * @file target.H - * @brief definitions for fapi2 targets + * @brief platform specializations for fapi2 targets */ #ifndef __FAPI2_TARGET__ #define __FAPI2_TARGET__ -#include <stdint.h> -#include <vector> -#include <target_types.H> +#include <plat_target.H> +#include <fapi2_target.H> #include <stdio.h> namespace fapi2 { - /// - /// @brief Enumeration of target state values (bitmask values) - /// - enum TargetState - { - TARGET_STATE_PRESENT = 0x00000001, - TARGET_STATE_FUNCTIONAL = 0x00000002, - }; /// - /// @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>(); + /// @brief Assignment Operator. + /// @param[in] i_right Reference to Target to assign from. + /// @return Reference to 'this' Target /// - /// // 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 = uint64_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 = 0): - 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) - { iv_handle = i_right.iv_handle; return *this; } - - /// - /// @brief Equality Comparison Operator - /// @param[in] i_right Reference to Target to compare. - /// @return bool. True if equal. - /// @note Platforms need to define this so that the physical - /// targets are determined to be equivilent rather than just the handles - /// - bool operator==(const Target& i_right) const - { return i_right.iv_handle == iv_handle; } - - /// - /// @brief Inquality Comparison Operator - /// @param[in] i_right Reference to Target to compare. - /// @return bool. True if not equal. - /// @note Platforms need to define this so that the physical - /// targets are determined to be equivilent rather than just the handles - /// - bool operator!=(const Target& i_right) const - { return i_right.iv_handle != iv_handle; } - - /// - /// @brief Get the handle. - /// @return V The target's handle, or value - /// - V get(void) const - { return iv_handle; } - - /// - /// @brief Get the handle as a V - /// @return V The target's handle, or value - /// - inline operator V() const { return iv_handle; } - - /// - /// @brief Get a target's value - /// @return V The target's handle, or value - /// - inline V& operator()(void) { return iv_handle; } - - /// - /// @brief Get the target type - /// @return The type of target represented by this target - /// - inline TargetType getType(void) const { return iv_type; } - - /// - /// @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 - { - // For testing - return Target<T>(iv_handle); - } - - /// - /// @brief Get this target's children - /// @tparam T The type of the parent - /// @param[in] i_state The desired TargetState of the children - /// @return std::vector<Target<T> > a vector of present/functional - /// children - /// @warning The children of EX's (cores) are expected to be returned - /// in order. That is, core 0 is std::vector[0]. - /// - template< TargetType T> - inline std::vector<Target<T> > - getChildren(const TargetState i_state = TARGET_STATE_FUNCTIONAL) const - { - // To keep the compiler quiet about unused variables - static_cast<void>(i_state); - // For testing - return {Target<T>(), Target<T>()}; - } - - /// - /// @brief Get the target at the other end of a bus - dimm included - /// @tparam T The type of the parent - /// @param[in] i_state The desired TargetState of the children - /// @return Target<T> a target representing the thing on the other end - /// @note Can be easily changed to a vector if needed - /// - template<TargetType T> - inline Target<T> - getOtherEnd(const TargetState i_state = TARGET_STATE_FUNCTIONAL) const - { - // Implementation note: cast to a composite of - // bus types and the compiler will check if this is - // a good function at compile time - return Target<T>(); - } - - /// - /// @brief 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"); - } - - 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; - V iv_handle; - - }; - - // EX threads map to CORE threads: - // t0 / t2 / t4 / t6 fused = t0 / t1 / t2 / t3 normal (c0) - // t1 / t3 / t5 / t7 fused = t0 / t1 / t2 / t3 normal (c1) - // So when splitting the EX, we need to map from EX threads - // to CORE threads. + template<TargetType K, typename V> + Target<K, V>& Target<K, V>::operator=(const Target& i_right) + { iv_handle = i_right.iv_handle; return *this; } /// - /// @brief 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 + /// @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 /// - inline uint8_t thread_id_n2f(const uint8_t i_ordinal, const uint8_t i_thread_id) - { - return (i_thread_id << 1) | i_ordinal; - } + template<TargetType K, typename V> + bool Target<K, V>::operator==(const Target& i_right) const + { return i_right.iv_handle == iv_handle; } /// - /// @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 + /// @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 /// - inline uint8_t thread_id_f2n(const uint8_t i_thread_id) - { - return i_thread_id >> 1; - } + template<TargetType K, typename V> + bool Target<K, V>::operator!=(const Target& i_right) const + { return i_right.iv_handle != iv_handle; } /// - /// @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. + /// @brief Get this target's immediate parent + /// @tparam T The type of the parent + /// @return Target<T> a target representing the parent /// - inline uint8_t thread_id2bitset(const uint8_t i_thread_id) + template<TargetType K, typename V> + template<TargetType T> + inline Target<T> Target<K, V>::getParent(void) const { - // 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)); + // For testing + return Target<T>(iv_handle); } /// - /// @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 + /// @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]. /// - inline uint8_t thread_bitset_n2f(const uint8_t i_ordinal, const uint8_t i_threads) + template<TargetType K, typename V> + template< TargetType T> + inline std::vector<Target<T> > + Target<K, V>::getChildren(const TargetState i_state) const { - // 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; + // To keep the compiler quiet about unused variables + static_cast<void>(i_state); + // For testing + return {Target<T>(), Target<T>()}; } /// - /// @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 + /// @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 /// - inline uint8_t thread_bitset_f2n(const uint8_t i_ordinal, const uint8_t i_threads) + template<TargetType K, typename V> + template<TargetType T> + inline Target<T> + Target<K, V>::getOtherEnd(const TargetState i_state) const { - 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; + // Implementation note: cast to a composite of + // bus types and the compiler will check if this is + // a good function at compile time + return Target<T>(); } + /// /// @brief Return the string interpretation of this target /// @tparam T The type of the target @@ -407,51 +166,6 @@ namespace fapi2 // For testing return Target<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/import/hwpf/fapi2/include/target_states.H b/import/hwpf/fapi2/include/target_states.H new file mode 100644 index 00000000..bebd43d0 --- /dev/null +++ b/import/hwpf/fapi2/include/target_states.H @@ -0,0 +1,45 @@ +/* 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_states.H + * @brief common state for fapi2 targets + */ + +#ifndef __FAPI2_TARGET_STATES__ +#define __FAPI2_TARGET_STATES__ + +namespace fapi2 +{ + /// + /// @brief Enumeration of target state values (bitmask values) + /// + enum TargetState + { + TARGET_STATE_PRESENT = 0x00000001, + TARGET_STATE_FUNCTIONAL = 0x00000002, + }; +} + +#endif |