From 84f49a31edbf1f4dbdca4397194a498c97d4244c Mon Sep 17 00:00:00 2001 From: Santosh Puranik Date: Mon, 12 Sep 2016 11:55:14 -0500 Subject: FAPI Plat Cleanup - II -- Changed names of some generated files -- Names in line with the ones use in EKB Change-Id: Id14e97e3b3a062246596eaed9e008f5dc3570d77 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/29495 Tested-by: Jenkins Server Reviewed-by: Sachin Gupta Tested-by: FSP CI Jenkins Reviewed-by: Shakeeb A. Pasha B K Reviewed-by: Santosh S. Puranik --- src/hwpf/include/fapi2AttributeService.H | 151 --- src/hwpf/include/fapi2_attribute_service.H | 148 +++ src/hwpf/include/hw_access.H | 604 ------------ src/hwpf/include/plat/hw_access.H | 603 ++++++++++++ src/hwpf/include/plat/plat_attributes.H | 5 +- src/hwpf/src/plat/plat_attribute_service.H | 1416 ++++++++++++++++++++++++++++ src/hwpf/src/plat/plat_utils.C | 98 +- src/hwpf/src/plat_ring_traverse.C | 44 +- 8 files changed, 2193 insertions(+), 876 deletions(-) delete mode 100644 src/hwpf/include/fapi2AttributeService.H create mode 100644 src/hwpf/include/fapi2_attribute_service.H delete mode 100644 src/hwpf/include/hw_access.H create mode 100644 src/hwpf/include/plat/hw_access.H create mode 100644 src/hwpf/src/plat/plat_attribute_service.H (limited to 'src/hwpf') diff --git a/src/hwpf/include/fapi2AttributeService.H b/src/hwpf/include/fapi2AttributeService.H deleted file mode 100644 index 6b0300c7..00000000 --- a/src/hwpf/include/fapi2AttributeService.H +++ /dev/null @@ -1,151 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/hwpf/include/fapi2AttributeService.H $ */ -/* */ -/* OpenPOWER sbe Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2016 */ -/* [+] International Business Machines Corp. */ -/* */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ -/* implied. See the License for the specific language governing */ -/* permissions and limitations under the License. */ -/* */ -/* IBM_PROLOG_END_TAG */ -/// -/// @file fapi2AttributeService.H -/// -/// @brief Defines the FAPI_ATTR_GET and FAPI_ATTR_SET macros that a user -/// calls to get/set attributes and a check function that the macros use to -/// verify correct usage -/// - -#ifndef FAPI2ATTRIBUTESERVICE_H_ -#define FAPI2ATTRIBUTESERVICE_H_ -#include -//#include -#include -#include -#include -//#include -#include - -/// @brief Macros called by user to get/set attributes for FAPI2 targets -/// -/// Code must have a reference to a FAPI2 Target and an attribute ID (from -/// XML file): -/// fapi2::ReturnCode l_rc; -/// fapi2::Target& l_target = ????; -/// Ex: Target& l_target = ????; -/// -/// To get a copy of an integer attribute and set the attribute -/// uint64_t l_val = 0; -/// l_rc = FAPI_ATTR_GET(, l_target, l_val); -/// l_rc = FAPI_ATTR_SET(, l_target, l_val); -/// -/// To get a copy of an integer array attribute and set the attribute -/// uint32_t l_pVal[4] = {0}; -/// l_rc = FAPI_ATTR_GET(, l_target, l_pVal); -/// l_rc = FAPI_ATTR_SET(, l_target, l_pVal); -/// -/// A priveleged attribute is one that a HWP should not generally access, -/// examples include ATTR_NAME and ATTR_EC, where usage can lead to a non -/// data-driven design. A privileged attribute can be accessed with -/// FAPI_ATTR_GET_PRIVILEGED and FAPI_ATTR_SET_PRIVILEGED -/// -/// The non-PRIVILEGED macros first call a template function (compiler will -/// optimize out) that will cause a compile failure if the attribute is -/// privileged, they then call a PRIVILEGED macro to get/set the attribute -/// -/// The PRIVILEGED macros call a template function (compiler will optimize out) -/// that will cause a compile failure if the ID is not valid or VAL is not the -/// correct type. -// - -#define FAPI_ATTR_GET(ID, TARGET, VAL) \ - (fapi2::failIfPrivileged(), \ - fapi2::checkIdType(ID, VAL), \ - ID##_GETMACRO(ID, TARGET, VAL)) - -#define FAPI_ATTR_SET(ID, TARGET, VAL) \ - (fapi2::failIfPrivileged(), \ - fapi2::checkIdType(ID, VAL), \ - ID##_SETMACRO(ID, TARGET, VAL)) - -#define FAPI_ATTR_GET_PRIVILEGED(ID, TARGET, VAL) \ - (fapi2::checkIdType(ID, VAL), \ - ID##_GETMACRO(ID, TARGET, VAL)) - -#define FAPI_ATTR_SET_PRIVILEGED(ID, TARGET, VAL) \ - (fapi2::checkIdType(ID, VAL), \ - ID##_SETMACRO(ID, TARGET, VAL)) - -namespace fapi2 -{ - -/// -/// @brief Get an InitFile attribute for FAPI2 -/// -/// This function gets a copy of an attribute. In the case of an array attribute, -/// The value in the specified index is retrieved. This should be used by the -/// InitFile HWP only, that HWP processes a binary InitFile and therefore needs -/// to read a variable ID of a variable data type. Standard HWPs should use the -/// FAPI2_ATTR_GET macro which automatically checks the type for correct usage. -/// -/// If there are ever attributes with more than 4 dimensions then this function -/// will need to be updated. -/// -/// @Tparam K template parameter, passed in target. -/// @param[in] i_id AttributeID -/// @param[in] i_target Reference to fapi2::Target (can be NULL for system) -/// @param[out] o_val Reference to uint64_t where attribute value is set -/// @param[in] i_arrayIndex1 If array attribute then index1 -/// @param[in] i_arrayIndex2 If at least 2D array attribute then index2 -/// @param[in] i_arrayIndex3 If at least 3D array attribute then index3 -/// @param[in] i_arrayIndex4 If at least 4D array attribute then index4 -/// -/// @return ReturnCode. Zero if success -/// -template< TargetType K > -ReturnCode getInitFileAttr(const AttributeId i_id, - const Target& i_target, - uint64_t & o_val, - const uint32_t i_arrayIndex1 = 0, - const uint32_t i_arrayIndex2 = 0, - const uint32_t i_arrayIndex3 = 0, - const uint32_t i_arrayIndex4 = 0); - -/** - * @brief Check the ID and TYPE - * - * This is called by FAPI code to check at compile time that a FAPI attribute - * access is using the correct data type and a valid AttributeId - */ -template inline void checkIdType(AttributeId, T &) {} - -/** - * @brief Fail if attribute privileged - * - * This is called by FAPI code to check at compile time that a standard FAPI - * attribute access (FAPI_ATTR_GET) is not accessing a privileged attribute - */ -class ErrorAccessingPrivilegedAttribute; -template void failIfPrivileged() -{ - ErrorAccessingPrivilegedAttribute(); -} -template <> inline void failIfPrivileged() {} - -} - -#endif // FAPI2ATTRIBUTESERVICE_H_ diff --git a/src/hwpf/include/fapi2_attribute_service.H b/src/hwpf/include/fapi2_attribute_service.H new file mode 100644 index 00000000..b1c7a668 --- /dev/null +++ b/src/hwpf/include/fapi2_attribute_service.H @@ -0,0 +1,148 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/hwpf/include/fapi2_attribute_service.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2016 */ +/* */ +/* */ +/* 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 fapi2AttributeService.H +/// +/// @brief Defines the FAPI_ATTR_GET and FAPI_ATTR_SET macros that a user +/// calls to get/set attributes and a check function that the macros use to +/// verify correct usage +/// + +#ifndef FAPI2ATTRIBUTESERVICE_H_ +#define FAPI2ATTRIBUTESERVICE_H_ +#include +#include +#include +#include +#include + +/// @brief Macros called by user to get/set attributes for FAPI2 targets +/// +/// Code must have a reference to a FAPI2 Target and an attribute ID (from +/// XML file): +/// fapi2::ReturnCode l_rc; +/// fapi2::Target& l_target = ????; +/// Ex: Target& l_target = ????; +/// +/// To get a copy of an integer attribute and set the attribute +/// uint64_t l_val = 0; +/// l_rc = FAPI_ATTR_GET(, l_target, l_val); +/// l_rc = FAPI_ATTR_SET(, l_target, l_val); +/// +/// To get a copy of an integer array attribute and set the attribute +/// uint32_t l_pVal[4] = {0}; +/// l_rc = FAPI_ATTR_GET(, l_target, l_pVal); +/// l_rc = FAPI_ATTR_SET(, l_target, l_pVal); +/// +/// A priveleged attribute is one that a HWP should not generally access, +/// examples include ATTR_NAME and ATTR_EC, where usage can lead to a non +/// data-driven design. A privileged attribute can be accessed with +/// FAPI_ATTR_GET_PRIVILEGED and FAPI_ATTR_SET_PRIVILEGED +/// +/// The non-PRIVILEGED macros first call a template function (compiler will +/// optimize out) that will cause a compile failure if the attribute is +/// privileged, they then call a PRIVILEGED macro to get/set the attribute +/// +/// The PRIVILEGED macros call a template function (compiler will optimize out) +/// that will cause a compile failure if the ID is not valid or VAL is not the +/// correct type. +// + +#define FAPI_ATTR_GET(ID, TARGET, VAL) \ + (fapi2::failIfPrivileged(), \ + fapi2::checkIdType(ID, VAL), \ + ID##_GETMACRO(ID, TARGET, VAL)) + +#define FAPI_ATTR_SET(ID, TARGET, VAL) \ + (fapi2::failIfPrivileged(), \ + fapi2::checkIdType(ID, VAL), \ + ID##_SETMACRO(ID, TARGET, VAL)) + +#define FAPI_ATTR_GET_PRIVILEGED(ID, TARGET, VAL) \ + (fapi2::checkIdType(ID, VAL), \ + ID##_GETMACRO(ID, TARGET, VAL)) + +#define FAPI_ATTR_SET_PRIVILEGED(ID, TARGET, VAL) \ + (fapi2::checkIdType(ID, VAL), \ + ID##_SETMACRO(ID, TARGET, VAL)) + +namespace fapi2 +{ + +/// +/// @brief Get an InitFile attribute for FAPI2 +/// +/// This function gets a copy of an attribute. In the case of an array attribute, +/// The value in the specified index is retrieved. This should be used by the +/// InitFile HWP only, that HWP processes a binary InitFile and therefore needs +/// to read a variable ID of a variable data type. Standard HWPs should use the +/// FAPI2_ATTR_GET macro which automatically checks the type for correct usage. +/// +/// If there are ever attributes with more than 4 dimensions then this function +/// will need to be updated. +/// +/// @Tparam K template parameter, passed in target. +/// @param[in] i_id AttributeID +/// @param[in] i_target Reference to fapi2::Target (can be NULL for system) +/// @param[out] o_val Reference to uint64_t where attribute value is set +/// @param[in] i_arrayIndex1 If array attribute then index1 +/// @param[in] i_arrayIndex2 If at least 2D array attribute then index2 +/// @param[in] i_arrayIndex3 If at least 3D array attribute then index3 +/// @param[in] i_arrayIndex4 If at least 4D array attribute then index4 +/// +/// @return ReturnCode. Zero if success +/// +template< TargetType K > +ReturnCode getInitFileAttr(const AttributeId i_id, + const Target& i_target, + uint64_t & o_val, + const uint32_t i_arrayIndex1 = 0, + const uint32_t i_arrayIndex2 = 0, + const uint32_t i_arrayIndex3 = 0, + const uint32_t i_arrayIndex4 = 0); + +/** + * @brief Check the ID and TYPE + * + * This is called by FAPI code to check at compile time that a FAPI attribute + * access is using the correct data type and a valid AttributeId + */ +template inline void checkIdType(AttributeId, T &) {} + +/** + * @brief Fail if attribute privileged + * + * This is called by FAPI code to check at compile time that a standard FAPI + * attribute access (FAPI_ATTR_GET) is not accessing a privileged attribute + */ +class ErrorAccessingPrivilegedAttribute; +template void failIfPrivileged() +{ + ErrorAccessingPrivilegedAttribute(); +} +template <> inline void failIfPrivileged() {} + +} + +#endif // FAPI2ATTRIBUTESERVICE_H_ diff --git a/src/hwpf/include/hw_access.H b/src/hwpf/include/hw_access.H deleted file mode 100644 index 0501970c..00000000 --- a/src/hwpf/include/hw_access.H +++ /dev/null @@ -1,604 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/hwpf/include/hw_access.H $ */ -/* */ -/* OpenPOWER sbe Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2012,2016 */ -/* [+] International Business Machines Corp. */ -/* */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ -/* implied. See the License for the specific language governing */ -/* permissions and limitations under the License. */ -/* */ -/* IBM_PROLOG_END_TAG */ -/** - * @file hw_access.H - * -* @brief Defines the hardware access functions that platform code must - * implement. - */ - -#ifndef FAPI2_HWACCESS_H_ -#define FAPI2_HWACCESS_H_ - - -// variable_buffer isn't supported on PPE -#ifndef __PPE__ -#include -#endif - -#include -#include -#include -#include "plat_ring_traverse.H" // for findRS4InImageAndApply - -namespace fapi2 -{ - - //-------------------------------------------------------------------------- - // PIB Error Functions - //-------------------------------------------------------------------------- - - /// @brief Sets the PIB error mask - platform dependant - /// @param[in] i_mask The new error mask - void setPIBErrorMask(uint8_t i_mask) - { - PLAT_SET_PIB_ERROR_MASK(i_mask); - } - - /// @brief Gets the PIB error mask - platform dependant - /// @return uint8_t The current PIB error mask - uint8_t getPIBErrorMask(void) - { - PLAT_GET_PIB_ERROR_MASK(o_pib_mask); - return o_pib_mask; - } - - //-------------------------------------------------------------------------- - // Operational Mode Error Functions - //-------------------------------------------------------------------------- - - /// @brief Sets the operational mode - /// @param[in] i_mode The new mode - // note: this can be moved to a C file if desired - inline void setOpMode(const OpModes i_mode) - { - // Keeps the compiler from complaining about the unused i_mode - static_cast(i_mode); - - // No-op for now. Should set thread-local operational mode - return; - } - - /// @brief Gets the operational mode - /// @return the operational mode - // note: this can be moved to a C file if desired - inline OpModes getOpMode(void) - { - // No-op for now. Should read thread-local operational mode - return NORMAL; - } - - //-------------------------------------------------------------------------- - // HW Communication Functions - //-------------------------------------------------------------------------- - - /// @brief Reads a SCOM register from a chip. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target HW target to operate on. - /// @param[in] i_address SCOM register address to read from. - /// @param[out] o_data Buffer that holds data read from HW target. - /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K, typename V > - __attribute__((always_inline)) - inline ReturnCode getScom(const Target& i_target, const uint64_t i_address, - buffer& o_data) - { - fapi2::ReturnCode l_rc; - PLAT_GETSCOM(l_rc, - i_target, - i_address, - &(o_data())); - - return l_rc; - } - - /// @brief Writes a SCOM register on a chip. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target HW target to operate on. - /// @param[in] i_address SCOM register address to write to. - /// @param[in] i_data Buffer that holds data to write into address. - /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K, typename V > - __attribute__((always_inline)) - inline ReturnCode putScom(const Target& i_target, const uint64_t i_address, - const buffer i_data) - { - fapi2::ReturnCode l_rc; - PLAT_PUTSCOM(l_rc, - i_target, - i_address, - i_data()); - - return l_rc; - } - - /// @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, typename V > - inline ReturnCode modifyScom(const Target& i_target, - const uint64_t i_address, - const buffer i_data, - const ChipOpModifyMode i_modifyMode) - { - fapi2::buffer l_modifyDataBuffer; - - fapi2::ReturnCode l_rc; - PLAT_GETSCOM(l_rc, - i_target, - (uint32_t)(i_address & BITS(40,24)), - &(l_modifyDataBuffer())); - if (l_rc) goto __fapi2exit__; - - if ( i_modifyMode == CHIP_OP_MODIFY_MODE_OR) - { - l_modifyDataBuffer |= i_data; - } - - if ( i_modifyMode == CHIP_OP_MODIFY_MODE_AND) - { - l_modifyDataBuffer &= i_data; - } - - if ( i_modifyMode == CHIP_OP_MODIFY_MODE_XOR) - { - l_modifyDataBuffer ^= i_data; - } - - PLAT_PUTSCOM(l_rc, - i_target, - (uint32_t)(i_address & BITS(40,24)), - l_modifyDataBuffer()); - if (l_rc) goto __fapi2exit__; - - -__fapi2exit__: - return l_rc; - - } - - /// @brief Writes a SCOM register under mask on a chip - /// @tparam K template parameter, passed in target. - /// @param[in] i_target HW target to operate on. - /// @param[in] i_address SCOM register address to write to. - /// @param[in] i_data Buffer that holds data to write into address. - /// @param[in] i_mask Buffer that holds the mask value. - /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K, typename V > - inline ReturnCode putScomUnderMask( const Target& i_target, - const uint64_t i_address, - buffer i_data, - buffer i_mask) - { - fapi2::buffer l_modifyDataBuffer = i_data; - - l_modifyDataBuffer &= i_mask; - - fapi2::ReturnCode l_rc; - PLAT_PUTSCOM(l_rc, - i_target, - (uint32_t)(i_address & BITS(40,24)), - l_modifyDataBuffer()); - - return l_rc; - - } - - - /// @brief Reads a CFAM register from a chip. - /// CFAM register is 32-bit wide. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target HW target to operate on. - /// @param[in] i_address CFAM register address to read from. - /// @param[out] o_data Buffer that holds data read from HW target. - /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K, typename V > - inline ReturnCode getCfamRegister(const Target& i_target, - const uint32_t i_address, - buffer& o_data) - { - PLAT_GETCFAM(i_target.get(), - (uint32_t)(i_address & BITS(40,24)), - &(o_data())); - - return FAPI2_RC_SUCCESS; - } - - /// @brief Writes a CFAM register on a chip. - /// CFAM register is 32-bit wide. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target HW target to operate on. - /// @param[in] i_address CFAM register address to write to. - /// @param[in] i_data Buffer that holds data to write into address. - /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K, typename V > - inline ReturnCode putCfamRegister(const Target& i_target, - const uint32_t i_address, - buffer& i_data) - { - PLAT_PUTCFAM(i_target.get(), - (uint32_t)(i_address & BITS(40,24)), - &(i_data())); - - return FAPI2_RC_SUCCESS; - } - - /// @brief Read-modify-write a CFAM register on a chip. - /// CFAM register is 32-bit wide. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target HW target to operate on. - /// @param[in] i_address CFAM register address to modify. - /// @param[in] i_data Buffer that holds data to be modified. - /// @param[in] i_modifyMode The modify mode (or/and/xor). - /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K, typename V > - inline ReturnCode modifyCfamRegister(const Target& i_target, - const uint32_t i_address, - const buffer& i_data, - const ChipOpModifyMode i_modifyMode) - { - PLAT_MODCFAM(i_target.get(), - (uint32_t)(i_address & BITS(40,24)), - &(i_data()), - i_modifyMode); - - return FAPI2_RC_SUCCESS; - } - - /// @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_ringID Ring ID that will identify the Ring in the image. - /// @param[in] i_ringMode Ring operation mode. - /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K, typename V > - inline ReturnCode putRing(const Target& i_target, - const RingID i_ringID, - const RingMode i_ringMode) - { - ReturnCode l_rc = FAPI2_RC_SUCCESS; - - // Find the RS4 string in the SEEPROM - l_rc = findRS4InImageAndApply(i_target, i_ringID, i_ringMode); - - return l_rc; - } - - // variable_buffer isn't supported on PPE -#ifndef __PPE__ - /// @brief Reads a ring from a chip. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target Target to operate on. - /// @param[in] i_address Ring address to read from. - /// @param[out] o_data Buffer that holds data read from HW target. - /// @param[in] i_ringMode Ring operation mode. - /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K, typename V > - inline ReturnCode getRing(const Target& i_target, - const scanRingId_t i_address, - variable_buffer& o_data, - const RingMode i_ringMode = 0) - { - o_data.setBit(0); - o_data.setBit(3); -#ifndef __PPE__ - std::cout << std::hex << " getRing " - << "target: {" << i_target.getType() << "," - << uint64_t(i_target) << "}; " - << "ring address: " << i_address << "; " - << "ring mode: " << i_ringMode << "; " - << "output data:"; - o_data.print(); -#endif - - return FAPI2_RC_SUCCESS; - } - - /// @brief Read-modify-write a ring on a chip. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target Target to operate on. - /// @param[in] i_address Ring address to modify. - /// @param[in] i_data Buffer that contains RS4 compressed ring data - /// to be modified. - /// @param[in] i_modifyMode The modify mode (or/and/xor) - /// @param[in] i_ringMode Ring operation mode. - /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K, typename V > - inline ReturnCode modifyRing(const Target& i_target, - const scanRingId_t i_address, - variable_buffer& i_data, - const ChipOpModifyMode i_modifyMode, - const RingMode i_ringMode = 0) - { - - return FAPI2_RC_SUCCESS; - } -#endif - - -#ifdef FAPI_SUPPORT_MULTI_SCOM - /// @brief Performs a multiple SCOM operation - /// This interface performs multiple SCOM operations on a chip in the - /// order specified by the input MultiScom object. - /// See fapiMultiScom.H for details of how to populate the MultiScom - /// object with SCOM operations. - /// - /// @tparam K template parameter, passed in target. - /// @param[in] i_target Target to operate on. - /// @param[in,out] io_multiScomObj Reference to a MultiScom object, - /// pre-populated with SingleScomInfo entries - /// to perform multiple SCOMs on input target - /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - /// - /// @note This is a synchronous interface and would return after all the - /// SCOM operations are completed or on the first failed operation - /// - /// @note SCOMs will be performed in the order they were added to the - /// input MultiScom object - /// - /// @note In case of errors, the platform code is responsible to collect - /// and add all the required error info and FFDC into the error data - /// for debugging - /// - /// @note If the SCOM operations added are specific to a processor chip, - /// then the FSI Shift Engine configured in scatter-gather DMA mode - /// extension would be used to execute the SCOM operations in a - /// performance optimize mode. In this mode, the special - /// SCOM_BULK_READ_MODE and SCOM_BULK_WRITE_MODE operations are - /// supported that allow a large bulk of SCOM access (in multiple of - /// 64 bits) for targets that support auto-increment. The - /// SCOM_WRITE_UNDER_MASK operation is not supported in this mode - /// - /// @note If the SCOM operations added are specific to a memory buffer - /// chip, then the regular SCOM engine is used to execute the SCOM - /// operations. SCOM_WRITE_UNDER_MASK operation is supported in - /// this mode, but the special SCOM_BULK_READ_MODE and - /// SCOM_BULK_WRITE_MODE operations are not supported due to - /// hardware limitations. - /// - template< TargetType K, typename V > - fapi2::ReturnCode multiScom (const Target& i_target, - MultiScom& io_multiScomObj) - { - } -#endif - - // -------------------------------------------------------------------------- - // NOTE: - // Implement platform Spy access functions if platform supports them. - // -------------------------------------------------------------------------- - - // variable_buffer isn't supported on PPE -#ifndef __PPE__ - /// @brief Reads a spy from a chip. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target Target to operate on. - /// @param[in] i_spyId Id of the spy whose data to be read. - /// @param[out] o_data Buffer that holds data read from HW target. - /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - /// - /// @note: The string version is only supported for cronus. - /// - /// The fapi design to support both FSP and cronus use of get and - /// put spy functions is dependant on the SPY names being expanded - /// to resemble a valid C identifier. This design places some - /// restrictions on the SPY names which can be used. - /// - /// 1. if the spy name contains a # procedure writers should replace - /// it with an __P__ for example - - /// - /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS - /// becomes - /// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS - /// - /// 2. if the spy name has a number following a "." it must have an - /// underscore prepended to the number. - /// - /// EH.TPCHIP.2KX100_ARY_CLK_EDGES_DLY - /// becomes - /// EH.TPCHIP._2KX100_ARY_CLK_EDGES_DLY - /// - /// Example SPY name: - /// The hardware procedure should call the function like: - /// - /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS - /// - /// fapi2::ReturnCode rc = fapiGetSpy( targ, - /// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS, data ); - /// - /// @note The ID is not in quotes the fapi code will handle adding - /// the quotes for the cronus environment - /// -#ifdef FAPI_SUPPORT_SPY_AS_ENUM - template< TargetType K, typename V > - inline ReturnCode getSpy(const Target& i_target, - const spyId_t i_spyId, - variable_buffer& o_data) - { - static_assert(K == 0, "implement getSpy (string)"); - return ~FAPI2_RC_SUCCESS; - } -#endif -#ifdef FAPI_SUPPORT_SPY_AS_STRING - template< TargetType K, typename V > - inline ReturnCode getSpy(const Target& i_target, - const char * const i_spyId, - variable_buffer& o_data) - { - static_assert(K == 0, "implement getSpy (string)"); - return ~FAPI2_RC_SUCCESS; - } -#endif - /// @brief Writes a spy on a chip. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target Target to operate on. - /// @param[in] i_spyId Id of the spy to write data to. - /// @param[out] i_data Buffer that holds data to write into spy. - /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - /// - /// @note: The string version is only supported for cronus. - /// - /// The fapi design to support both FSP and cronus use of get and - /// put spy functions is dependent on the SPY names being expanded - /// to resemble a valid C identifier. This design places some - /// restrictions on the SPY names which can be used. - /// - /// 1. if the spy name contains a # procedure writers should replace - /// is with an __P__ for example - - /// - /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS - /// becomes - /// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS - /// - /// 2. if the spy name has a number following a "." it must have an - /// underscore prepended to the number. - /// - /// EH.TPCHIP.2KX100_ARY_CLK_EDGES_DLY - /// becomes - /// EH.TPCHIP._2KX100_ARY_CLK_EDGES_DLY - /// - /// Example SPY name: - /// The hardware procedure should call the function like: - /// - /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS - /// - /// fapi2::ReturnCode rc = fapiPutSpy( targ, - /// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS, data ); - /// - /// @note The ID is not in quotes the fapi code will handle adding - /// the quotes for the cronus environment - /// -#ifdef FAPI_SUPPORT_SPY_AS_ENUM - template< TargetType K, typename V > - inline ReturnCode putSpy(const Target& i_target, - const spyId_t i_spyId, - variable_buffer& i_data) - { - static_assert(K == 0, "implement putSpy (enum)"); - return ~FAPI2_RC_SUCCESS; - } -#endif -#ifdef FAPI_SUPPORT_SPY_AS_STRING - template< TargetType K, typename V > - inline ReturnCode putSpy(const Target& i_target, - const char* const i_spyId, - variable_buffer& i_data) - { - static_assert(K == 0, "implement putSpy (string)"); - return ~FAPI2_RC_SUCCESS; - } -#endif - /// @brief Writes spy data into a buffer holding ring data image - /// This API is used by L2/L3 repair to put column repair data - /// into a ring buffer image. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target Target to operate on. - /// @param[in] i_spyId Id of the spy. - /// @param[in] i_data Buffer that holds spy data to write into ring - /// image. - /// @param[out] o_data Buffer that holds updated ring image. - /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - /// - /// @note: The string version is only supported for cronus. - /// - /// The fapi design to support both FSP and cronus use of get and - /// put spy functions is dependent on the SPY names being expanded - /// to resemble a valid C identifier. This design places some - /// restrictions on the SPY names which can be used. - /// - /// See fapiPutSpy for details on spy id specifics. - /// -#ifdef FAPI_SUPPORT_SPY_AS_ENUM - template< TargetType K, typename V > - inline ReturnCode putSpyImage(const Target& i_target, - const spyId_t i_spyId, - const variable_buffer& i_data, - variable_buffer& o_imageData) - { - static_assert(K == 0, "implement putSpyImage (enum)"); - return ~FAPI2_RC_SUCCESS; - } -#endif -#ifdef FAPI_SUPPORT_SPY_AS_STRING - template< TargetType K, typename V > - inline ReturnCode putSpyImage(const Target& i_target, - const char* const i_spyId, - const variable_buffer& i_data, - variable_buffer& o_imageData) - { - static_assert(K == 0, "implement putSpyImage (string)"); - return ~FAPI2_RC_SUCCESS; - } -#endif - /// @brief Reads spy data from a ring image buffer - /// @param[in] i_target Target to operate on - /// @param[in] i_spyId The spy's id - /// @param[out] o_data Buffer that holds data read from ring image. - /// @param[in] i_imageData Buffer that holds ring image to read data - /// from. - /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - /// - /// @note: The string version is only supported for cronus. - /// - /// The fapi design to support both FSP and cronus use of get and - /// put spy functions is dependent on the SPY names being expanded - /// to resemble a valid C identifier. This design places some - /// restrictions on the SPY names which can be used. - /// - /// See fapiPutSpy for details on spy id specifics. - /// -#ifdef FAPI_SUPPORT_SPY_AS_ENUM - template< TargetType K, typename V > - inline ReturnCode getSpyImage(const Target& i_target, - const spyId_t i_spyId, - variable_buffer& o_data, - const variable_buffer& i_imageData) - { - static_assert(K == 0, "implement getSpyImage (enum)"); - return ~FAPI2_RC_SUCCESS; - } -#endif -#ifdef FAPI_SUPPORT_SPY_AS_STRING - template< TargetType K, typename V > - inline ReturnCode getSpyImage(const Target& i_target, - const char * const i_spyId, - variable_buffer& o_data, - const variable_buffer& i_imageData) - { - static_assert(K == 0, "implement getSpyImage (string)"); - return ~FAPI2_RC_SUCCESS; - } -#endif - -#endif // PPE - -}; - -#endif // _FAPI2_HWACCESS_H_ diff --git a/src/hwpf/include/plat/hw_access.H b/src/hwpf/include/plat/hw_access.H new file mode 100644 index 00000000..24f826a3 --- /dev/null +++ b/src/hwpf/include/plat/hw_access.H @@ -0,0 +1,603 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/hwpf/include/plat/hw_access.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2012,2016 */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +/** + * @file hw_access.H + * +* @brief Defines the hardware access functions that platform code must + * implement. + */ + +#ifndef FAPI2_HWACCESS_H_ +#define FAPI2_HWACCESS_H_ + + +// variable_buffer isn't supported on PPE +#ifndef __PPE__ +#include +#endif + +#include +#include +#include +#include "plat_ring_traverse.H" // for findRS4InImageAndApply + +namespace fapi2 +{ + + //-------------------------------------------------------------------------- + // PIB Error Functions + //-------------------------------------------------------------------------- + + /// @brief Sets the PIB error mask - platform dependant + /// @param[in] i_mask The new error mask + void setPIBErrorMask(uint8_t i_mask) + { + PLAT_SET_PIB_ERROR_MASK(i_mask); + } + + /// @brief Gets the PIB error mask - platform dependant + /// @return uint8_t The current PIB error mask + uint8_t getPIBErrorMask(void) + { + PLAT_GET_PIB_ERROR_MASK(o_pib_mask); + return o_pib_mask; + } + + //-------------------------------------------------------------------------- + // Operational Mode Error Functions + //-------------------------------------------------------------------------- + + /// @brief Sets the operational mode + /// @param[in] i_mode The new mode + // note: this can be moved to a C file if desired + inline void setOpMode(const OpModes i_mode) + { + // Keeps the compiler from complaining about the unused i_mode + static_cast(i_mode); + + // No-op for now. Should set thread-local operational mode + return; + } + + /// @brief Gets the operational mode + /// @return the operational mode + // note: this can be moved to a C file if desired + inline OpModes getOpMode(void) + { + // No-op for now. Should read thread-local operational mode + return NORMAL; + } + + //-------------------------------------------------------------------------- + // HW Communication Functions + //-------------------------------------------------------------------------- + + /// @brief Reads a SCOM register from a chip. + /// @tparam K template parameter, passed in target. + /// @param[in] i_target HW target to operate on. + /// @param[in] i_address SCOM register address to read from. + /// @param[out] o_data Buffer that holds data read from HW target. + /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + template< TargetType K, typename V > + __attribute__((always_inline)) + inline ReturnCode getScom(const Target& i_target, const uint64_t i_address, + buffer& o_data) + { + fapi2::ReturnCode l_rc; + PLAT_GETSCOM(l_rc, + i_target, + i_address, + &(o_data())); + + return l_rc; + } + + /// @brief Writes a SCOM register on a chip. + /// @tparam K template parameter, passed in target. + /// @param[in] i_target HW target to operate on. + /// @param[in] i_address SCOM register address to write to. + /// @param[in] i_data Buffer that holds data to write into address. + /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + template< TargetType K, typename V > + __attribute__((always_inline)) + inline ReturnCode putScom(const Target& i_target, const uint64_t i_address, + const buffer i_data) + { + fapi2::ReturnCode l_rc; + PLAT_PUTSCOM(l_rc, + i_target, + i_address, + i_data()); + + return l_rc; + } + + /// @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, typename V > + inline ReturnCode modifyScom(const Target& i_target, + const uint64_t i_address, + const buffer i_data, + const ChipOpModifyMode i_modifyMode) + { + fapi2::buffer l_modifyDataBuffer; + + fapi2::ReturnCode l_rc; + PLAT_GETSCOM(l_rc, + i_target, + (uint32_t)(i_address & BITS(40,24)), + &(l_modifyDataBuffer())); + if (l_rc) goto __fapi2exit__; + + if ( i_modifyMode == CHIP_OP_MODIFY_MODE_OR) + { + l_modifyDataBuffer |= i_data; + } + + if ( i_modifyMode == CHIP_OP_MODIFY_MODE_AND) + { + l_modifyDataBuffer &= i_data; + } + + if ( i_modifyMode == CHIP_OP_MODIFY_MODE_XOR) + { + l_modifyDataBuffer ^= i_data; + } + + PLAT_PUTSCOM(l_rc, + i_target, + (uint32_t)(i_address & BITS(40,24)), + l_modifyDataBuffer()); + if (l_rc) goto __fapi2exit__; + + +__fapi2exit__: + return l_rc; + + } + + /// @brief Writes a SCOM register under mask on a chip + /// @tparam K template parameter, passed in target. + /// @param[in] i_target HW target to operate on. + /// @param[in] i_address SCOM register address to write to. + /// @param[in] i_data Buffer that holds data to write into address. + /// @param[in] i_mask Buffer that holds the mask value. + /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + template< TargetType K, typename V > + inline ReturnCode putScomUnderMask( const Target& i_target, + const uint64_t i_address, + buffer i_data, + buffer i_mask) + { + fapi2::buffer l_modifyDataBuffer = i_data; + + l_modifyDataBuffer &= i_mask; + + fapi2::ReturnCode l_rc; + PLAT_PUTSCOM(l_rc, + i_target, + (uint32_t)(i_address & BITS(40,24)), + l_modifyDataBuffer()); + + return l_rc; + + } + + + /// @brief Reads a CFAM register from a chip. + /// CFAM register is 32-bit wide. + /// @tparam K template parameter, passed in target. + /// @param[in] i_target HW target to operate on. + /// @param[in] i_address CFAM register address to read from. + /// @param[out] o_data Buffer that holds data read from HW target. + /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + template< TargetType K, typename V > + inline ReturnCode getCfamRegister(const Target& i_target, + const uint32_t i_address, + buffer& o_data) + { + PLAT_GETCFAM(i_target.get(), + (uint32_t)(i_address & BITS(40,24)), + &(o_data())); + + return FAPI2_RC_SUCCESS; + } + + /// @brief Writes a CFAM register on a chip. + /// CFAM register is 32-bit wide. + /// @tparam K template parameter, passed in target. + /// @param[in] i_target HW target to operate on. + /// @param[in] i_address CFAM register address to write to. + /// @param[in] i_data Buffer that holds data to write into address. + /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + template< TargetType K, typename V > + inline ReturnCode putCfamRegister(const Target& i_target, + const uint32_t i_address, + buffer& i_data) + { + PLAT_PUTCFAM(i_target.get(), + (uint32_t)(i_address & BITS(40,24)), + &(i_data())); + + return FAPI2_RC_SUCCESS; + } + + /// @brief Read-modify-write a CFAM register on a chip. + /// CFAM register is 32-bit wide. + /// @tparam K template parameter, passed in target. + /// @param[in] i_target HW target to operate on. + /// @param[in] i_address CFAM register address to modify. + /// @param[in] i_data Buffer that holds data to be modified. + /// @param[in] i_modifyMode The modify mode (or/and/xor). + /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + template< TargetType K, typename V > + inline ReturnCode modifyCfamRegister(const Target& i_target, + const uint32_t i_address, + const buffer& i_data, + const ChipOpModifyMode i_modifyMode) + { + PLAT_MODCFAM(i_target.get(), + (uint32_t)(i_address & BITS(40,24)), + &(i_data()), + i_modifyMode); + + return FAPI2_RC_SUCCESS; + } + + /// @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_ringID Ring ID that will identify the Ring in the image. + /// @param[in] i_ringMode Ring operation mode. + /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + template< TargetType K, typename V > + inline ReturnCode putRing(const Target& i_target, + const RingID i_ringID, + const RingMode i_ringMode) + { + ReturnCode l_rc = FAPI2_RC_SUCCESS; + + // Find the RS4 string in the SEEPROM + l_rc = findRS4InImageAndApply(i_target, i_ringID, i_ringMode); + + return l_rc; + } + + // variable_buffer isn't supported on PPE +#ifndef __PPE__ + /// @brief Reads a ring from a chip. + /// @tparam K template parameter, passed in target. + /// @param[in] i_target Target to operate on. + /// @param[in] i_address Ring address to read from. + /// @param[out] o_data Buffer that holds data read from HW target. + /// @param[in] i_ringMode Ring operation mode. + /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + template< TargetType K, typename V > + inline ReturnCode getRing(const Target& i_target, + const scanRingId_t i_address, + variable_buffer& o_data, + const RingMode i_ringMode = 0) + { + o_data.setBit(0); + o_data.setBit(3); +#ifndef __PPE__ + std::cout << std::hex << " getRing " + << "target: {" << i_target.getType() << "," + << uint64_t(i_target) << "}; " + << "ring address: " << i_address << "; " + << "ring mode: " << i_ringMode << "; " + << "output data:"; + o_data.print(); +#endif + + return FAPI2_RC_SUCCESS; + } + + /// @brief Read-modify-write a ring on a chip. + /// @tparam K template parameter, passed in target. + /// @param[in] i_target Target to operate on. + /// @param[in] i_address Ring address to modify. + /// @param[in] i_data Buffer that contains RS4 compressed ring data + /// to be modified. + /// @param[in] i_modifyMode The modify mode (or/and/xor) + /// @param[in] i_ringMode Ring operation mode. + /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + template< TargetType K, typename V > + inline ReturnCode modifyRing(const Target& i_target, + const scanRingId_t i_address, + variable_buffer& i_data, + const ChipOpModifyMode i_modifyMode, + const RingMode i_ringMode = 0) + { + + return FAPI2_RC_SUCCESS; + } +#endif + + +#ifdef FAPI_SUPPORT_MULTI_SCOM + /// @brief Performs a multiple SCOM operation + /// This interface performs multiple SCOM operations on a chip in the + /// order specified by the input MultiScom object. + /// See fapiMultiScom.H for details of how to populate the MultiScom + /// object with SCOM operations. + /// + /// @tparam K template parameter, passed in target. + /// @param[in] i_target Target to operate on. + /// @param[in,out] io_multiScomObj Reference to a MultiScom object, + /// pre-populated with SingleScomInfo entries + /// to perform multiple SCOMs on input target + /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + /// + /// @note This is a synchronous interface and would return after all the + /// SCOM operations are completed or on the first failed operation + /// + /// @note SCOMs will be performed in the order they were added to the + /// input MultiScom object + /// + /// @note In case of errors, the platform code is responsible to collect + /// and add all the required error info and FFDC into the error data + /// for debugging + /// + /// @note If the SCOM operations added are specific to a processor chip, + /// then the FSI Shift Engine configured in scatter-gather DMA mode + /// extension would be used to execute the SCOM operations in a + /// performance optimize mode. In this mode, the special + /// SCOM_BULK_READ_MODE and SCOM_BULK_WRITE_MODE operations are + /// supported that allow a large bulk of SCOM access (in multiple of + /// 64 bits) for targets that support auto-increment. The + /// SCOM_WRITE_UNDER_MASK operation is not supported in this mode + /// + /// @note If the SCOM operations added are specific to a memory buffer + /// chip, then the regular SCOM engine is used to execute the SCOM + /// operations. SCOM_WRITE_UNDER_MASK operation is supported in + /// this mode, but the special SCOM_BULK_READ_MODE and + /// SCOM_BULK_WRITE_MODE operations are not supported due to + /// hardware limitations. + /// + template< TargetType K, typename V > + fapi2::ReturnCode multiScom (const Target& i_target, + MultiScom& io_multiScomObj) + { + } +#endif + + // -------------------------------------------------------------------------- + // NOTE: + // Implement platform Spy access functions if platform supports them. + // -------------------------------------------------------------------------- + + // variable_buffer isn't supported on PPE +#ifndef __PPE__ + /// @brief Reads a spy from a chip. + /// @tparam K template parameter, passed in target. + /// @param[in] i_target Target to operate on. + /// @param[in] i_spyId Id of the spy whose data to be read. + /// @param[out] o_data Buffer that holds data read from HW target. + /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + /// + /// @note: The string version is only supported for cronus. + /// + /// The fapi design to support both FSP and cronus use of get and + /// put spy functions is dependant on the SPY names being expanded + /// to resemble a valid C identifier. This design places some + /// restrictions on the SPY names which can be used. + /// + /// 1. if the spy name contains a # procedure writers should replace + /// it with an __P__ for example - + /// + /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS + /// becomes + /// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS + /// + /// 2. if the spy name has a number following a "." it must have an + /// underscore prepended to the number. + /// + /// EH.TPCHIP.2KX100_ARY_CLK_EDGES_DLY + /// becomes + /// EH.TPCHIP._2KX100_ARY_CLK_EDGES_DLY + /// + /// Example SPY name: + /// The hardware procedure should call the function like: + /// + /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS + /// + /// fapi2::ReturnCode rc = fapiGetSpy( targ, + /// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS, data ); + /// + /// @note The ID is not in quotes the fapi code will handle adding + /// the quotes for the cronus environment + /// +#ifdef FAPI_SUPPORT_SPY_AS_ENUM + template< TargetType K, typename V > + inline ReturnCode getSpy(const Target& i_target, + const spyId_t i_spyId, + variable_buffer& o_data) + { + static_assert(K == 0, "implement getSpy (string)"); + return ~FAPI2_RC_SUCCESS; + } +#endif +#ifdef FAPI_SUPPORT_SPY_AS_STRING + template< TargetType K, typename V > + inline ReturnCode getSpy(const Target& i_target, + const char * const i_spyId, + variable_buffer& o_data) + { + static_assert(K == 0, "implement getSpy (string)"); + return ~FAPI2_RC_SUCCESS; + } +#endif + /// @brief Writes a spy on a chip. + /// @tparam K template parameter, passed in target. + /// @param[in] i_target Target to operate on. + /// @param[in] i_spyId Id of the spy to write data to. + /// @param[out] i_data Buffer that holds data to write into spy. + /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + /// + /// @note: The string version is only supported for cronus. + /// + /// The fapi design to support both FSP and cronus use of get and + /// put spy functions is dependent on the SPY names being expanded + /// to resemble a valid C identifier. This design places some + /// restrictions on the SPY names which can be used. + /// + /// 1. if the spy name contains a # procedure writers should replace + /// is with an __P__ for example - + /// + /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS + /// becomes + /// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS + /// + /// 2. if the spy name has a number following a "." it must have an + /// underscore prepended to the number. + /// + /// EH.TPCHIP.2KX100_ARY_CLK_EDGES_DLY + /// becomes + /// EH.TPCHIP._2KX100_ARY_CLK_EDGES_DLY + /// + /// Example SPY name: + /// The hardware procedure should call the function like: + /// + /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS + /// + /// fapi2::ReturnCode rc = fapiPutSpy( targ, + /// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS, data ); + /// + /// @note The ID is not in quotes the fapi code will handle adding + /// the quotes for the cronus environment + /// +#ifdef FAPI_SUPPORT_SPY_AS_ENUM + template< TargetType K, typename V > + inline ReturnCode putSpy(const Target& i_target, + const spyId_t i_spyId, + variable_buffer& i_data) + { + static_assert(K == 0, "implement putSpy (enum)"); + return ~FAPI2_RC_SUCCESS; + } +#endif +#ifdef FAPI_SUPPORT_SPY_AS_STRING + template< TargetType K, typename V > + inline ReturnCode putSpy(const Target& i_target, + const char* const i_spyId, + variable_buffer& i_data) + { + static_assert(K == 0, "implement putSpy (string)"); + return ~FAPI2_RC_SUCCESS; + } +#endif + /// @brief Writes spy data into a buffer holding ring data image + /// This API is used by L2/L3 repair to put column repair data + /// into a ring buffer image. + /// @tparam K template parameter, passed in target. + /// @param[in] i_target Target to operate on. + /// @param[in] i_spyId Id of the spy. + /// @param[in] i_data Buffer that holds spy data to write into ring + /// image. + /// @param[out] o_data Buffer that holds updated ring image. + /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + /// + /// @note: The string version is only supported for cronus. + /// + /// The fapi design to support both FSP and cronus use of get and + /// put spy functions is dependent on the SPY names being expanded + /// to resemble a valid C identifier. This design places some + /// restrictions on the SPY names which can be used. + /// + /// See fapiPutSpy for details on spy id specifics. + /// +#ifdef FAPI_SUPPORT_SPY_AS_ENUM + template< TargetType K, typename V > + inline ReturnCode putSpyImage(const Target& i_target, + const spyId_t i_spyId, + const variable_buffer& i_data, + variable_buffer& o_imageData) + { + static_assert(K == 0, "implement putSpyImage (enum)"); + return ~FAPI2_RC_SUCCESS; + } +#endif +#ifdef FAPI_SUPPORT_SPY_AS_STRING + template< TargetType K, typename V > + inline ReturnCode putSpyImage(const Target& i_target, + const char* const i_spyId, + const variable_buffer& i_data, + variable_buffer& o_imageData) + { + static_assert(K == 0, "implement putSpyImage (string)"); + return ~FAPI2_RC_SUCCESS; + } +#endif + /// @brief Reads spy data from a ring image buffer + /// @param[in] i_target Target to operate on + /// @param[in] i_spyId The spy's id + /// @param[out] o_data Buffer that holds data read from ring image. + /// @param[in] i_imageData Buffer that holds ring image to read data + /// from. + /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + /// + /// @note: The string version is only supported for cronus. + /// + /// The fapi design to support both FSP and cronus use of get and + /// put spy functions is dependent on the SPY names being expanded + /// to resemble a valid C identifier. This design places some + /// restrictions on the SPY names which can be used. + /// + /// See fapiPutSpy for details on spy id specifics. + /// +#ifdef FAPI_SUPPORT_SPY_AS_ENUM + template< TargetType K, typename V > + inline ReturnCode getSpyImage(const Target& i_target, + const spyId_t i_spyId, + variable_buffer& o_data, + const variable_buffer& i_imageData) + { + static_assert(K == 0, "implement getSpyImage (enum)"); + return ~FAPI2_RC_SUCCESS; + } +#endif +#ifdef FAPI_SUPPORT_SPY_AS_STRING + template< TargetType K, typename V > + inline ReturnCode getSpyImage(const Target& i_target, + const char * const i_spyId, + variable_buffer& o_data, + const variable_buffer& i_imageData) + { + static_assert(K == 0, "implement getSpyImage (string)"); + return ~FAPI2_RC_SUCCESS; + } +#endif + +#endif // PPE + +}; + +#endif // _FAPI2_HWACCESS_H_ diff --git a/src/hwpf/include/plat/plat_attributes.H b/src/hwpf/include/plat/plat_attributes.H index e89062d3..781cbd56 100644 --- a/src/hwpf/include/plat/plat_attributes.H +++ b/src/hwpf/include/plat/plat_attributes.H @@ -30,8 +30,7 @@ #ifndef __PLAT_ATTTRIBUTE_H__ #define __PLAT_ATTTRIBUTE_H__ -#include -#include // Generated file -//#include +#include +#include // Generated file #endif // __PLAT_ATTTRIBUTE_H__ diff --git a/src/hwpf/src/plat/plat_attribute_service.H b/src/hwpf/src/plat/plat_attribute_service.H new file mode 100644 index 00000000..9e2a26a2 --- /dev/null +++ b/src/hwpf/src/plat/plat_attribute_service.H @@ -0,0 +1,1416 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/hwpf/src/plat/plat_attribute_service.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2015,2016 */ +/* */ +/* */ +/* 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 fapiPlatAttributeService.H + * + * @brief Defines the PLAT attribute access macros and defines which macro + * handles each attribute. + * + */ + + +#ifndef FAPI2PLATATTRIBUTESERVICE_H_ +#define FAPI2PLATATTRIBUTESERVICE_H_ + +#include +#include +#include +#include +#include +#include +#include "proc_sbe_fixed.H" +#include "plat_target_parms.H" + +#define PLAT_GET_CHIP_EC_FEATURE_OVERRIDE(ID, PTARGET, VAL) \ + _getEcFeatureOverride(ID, PTARGET, VAL) + +/* INSERT NEW ATTRIBUTES HERE */ + + +/******************************************************************************/ +/* * Global macros * */ +/* These macros are called by the macros above to invoke the appropriate API. */ +/* These macros do not need to change when a new attribute is introduced. */ +/******************************************************************************/ + +/* global get uint8_t 1D array macro */ +#define PLAT_ATTR_GET_UINT8_1D_ARRAY(ID, PTARGET, VAL) \ + _getAttributeArrayShort(ID##_TargetTypes), ID> \ + (ID, PTARGET, VAL) + +/* global set uint8_t 1D array macro */ +#define PLAT_ATTR_SET_UINT8_1D_ARRAY(ID, PTARGET, VAL) \ + _setAttributeArrayShort(ID##_TargetTypes), ID> \ + (ID, PTARGET, VAL) + +/* global get uint8_t 2D array macro */ +#define PLAT_ATTR_GET_UINT8_2D_ARRAY(ID, PTARGET, VAL) \ + _getAttributeArrayShort(ID, PTARGET, VAL[0]) +/* global set uint8_t 2D array macro */ +#define PLAT_ATTR_SET_UINT8_2D_ARRAY(ID, PTARGET, VAL) \ + _setAttributeArrayShort(ID, PTARGET, VAL[0]) + +/* global get uint8_t 3D array macro */ +#define PLAT_ATTR_GET_UINT8_3D_ARRAY(ID, PTARGET, VAL) \ + _getAttributeArrayShort(ID, PTARGET, VAL[0][0]) +/* global set uint8_t 3D array macro */ +#define PLAT_ATTR_SET_UINT8_3D_ARRAY(ID, PTARGET, VAL) \ + _setAttributeArrayShort(ID, PTARGET, VAL[0][0]) + +/* global get uint8_t 4D array macro */ +#define PLAT_ATTR_GET_UINT8_4D_ARRAY(ID, PTARGET, VAL) \ + _getAttributeArrayShort(ID, PTARGET, VAL[0][0][0]) +/* global set uint8_t 4D array macro */ +#define PLAT_ATTR_SET_UINT8_4D_ARRAY(ID, PTARGET, VAL) \ + _setAttributeArrayShort(ID, PTARGET, VAL[0][0][0]) + +/* global get uint32_t 1D array macro */ +#define PLAT_ATTR_GET_UINT32_1D_ARRAY(ID, PTARGET, VAL) \ + _getAttributeArrayWord(ID, PTARGET, VAL) +/* global set uint32_t 1D array macro */ +#define PLAT_ATTR_SET_UINT32_1D_ARRAY(ID, PTARGET, VAL) \ + _setAttributeArrayWord(ID, PTARGET, VAL) + +/* global get uint32_t 2D array macro */ +#define PLAT_ATTR_GET_UINT32_2D_ARRAY(ID, PTARGET, VAL) \ + _getAttributeArrayWord(ID, PTARGET, VAL[0]) +/* global set uint32_t 2D array macro */ +#define PLAT_ATTR_SET_UINT32_2D_ARRAY(ID, PTARGET, VAL) \ + _setAttributeArrayWord(ID, PTARGET, VAL[0]) + +/* global get uint32_t 3D array macro */ +#define PLAT_ATTR_GET_UINT32_3D_ARRAY(ID, PTARGET, VAL) \ + _getAttributeArrayWord(ID, PTARGET, VAL[0][0]) +/* global set uint32_t 3D array macro */ +#define PLAT_ATTR_SET_UINT32_3D_ARRAY(ID, PTARGET, VAL) \ + _setAttributeArrayWord(ID, PTARGET, VAL[0][0]) + +/* global get uint32_t 4D array macro */ +#define PLAT_ATTR_GET_UINT32_4D_ARRAY(ID, PTARGET, VAL) \ + _getAttributeArrayWord(ID, PTARGET, VAL[0][0][0]) +/* global set uint32_t 4D array macro */ +#define PLAT_ATTR_SET_UINT32_4D_ARRAY(ID, PTARGET, VAL) \ + _setAttributeArrayWord(ID, PTARGET, VAL[0][0][0]) + + +/* global get uint64_t 1D array macro */ +#define PLAT_ATTR_GET_UINT64_1D_ARRAY(ID, PTARGET, VAL) \ + _getAttributeArrayDoubleWord(ID, PTARGET, VAL) +/* global set uint64_t 1D array macro */ +#define PLAT_ATTR_SET_UINT64_1D_ARRAY(ID, PTARGET, VAL) \ + _setAttributeArrayDoubleWord(ID, PTARGET, VAL) + +/* global get uint64_t 2D array macro */ +#define PLAT_ATTR_GET_UINT64_2D_ARRAY(ID, PTARGET, VAL) \ + _getAttributeArrayDoubleWord(ID, PTARGET, VAL[0]) +/* global set uint64_t 2D array macro */ +#define PLAT_ATTR_SET_UINT64_2D_ARRAY(ID, PTARGET, VAL) \ + _setAttributeArrayDoubleWord(ID, PTARGET, VAL[0]) + +/* global get uint64_t 3D array macro */ +#define PLAT_ATTR_GET_UINT64_3D_ARRAY(ID, PTARGET, VAL) \ + _getAttributeArrayDoubleWord(ID, PTARGET, VAL[0][0]) +/* global set uint64_t 3D array macro */ +#define PLAT_ATTR_SET_UINT64_3D_ARRAY(ID, PTARGET, VAL) \ + _setAttributeArrayDoubleWord(ID, PTARGET, VAL[0][0]) + +/* global get uint64_t 4D array macro */ +#define PLAT_ATTR_GET_UINT64_4D_ARRAY(ID, PTARGET, VAL) \ + _getAttributeArrayDoubleWord(ID, PTARGET, VAL[0][0][0]) +/* global set uint64_t 4D array macro */ +#define PLAT_ATTR_SET_UINT64_4D_ARRAY(ID, PTARGET, VAL) \ + _setAttributeArrayDoubleWord(ID, PTARGET, VAL[0][0][0]) + +/* global get int macro (uint8_t, 16, 32 and 64) */ +#define PLAT_ATTR_GET_GLOBAL_INT(ID, PTARGET, VAL) \ + _get(ID##_TargetTypes), ID> \ + (ID, PTARGET, VAL) + +/* global set int macro (uint8_t, 16, 32 and 64) */ +#define PLAT_ATTR_SET_GLOBAL_INT(ID, PTARGET, VAL) \ + _set(ID##_TargetTypes), ID> \ + (ID, PTARGET, VAL) + + +//here + +/******************************************************************************/ +// Get Override Macros +/******************************************************************************/ +/* global get override uint8_t 1D array macro */ +#define PLAT_ATTR_GET_OVERRIDE_UINT8_1D_ARRAY(ID, PTARGET, VAL) \ + _getAttributeOverrideArrayShort(ID, PTARGET, VAL) +/* global get override uint8_t 2D array macro */ +#define PLAT_ATTR_GET_OVERRIDE_UINT8_2D_ARRAY(ID, PTARGET, VAL) \ + _getAttributeOverrideArrayShort(ID, PTARGET, VAL[0]) +/* global get override uint8_t 3D array macro */ +#define PLAT_ATTR_GET_OVERRIDE_UINT8_3D_ARRAY(ID, PTARGET, VAL) \ + _getAttributeOverrideArrayShort(ID, PTARGET, VAL[0][0]) +/* global get override uint8_t 4D array macro */ +#define PLAT_ATTR_GET_OVERRIDE_UINT8_4D_ARRAY(ID, PTARGET, VAL) \ + _getAttributeOverrideArrayShort(ID, PTARGET, VAL[0][0][0]) + + +/* global get override uint32_t 1D array macro */ +#define PLAT_ATTR_GET_OVERRIDE_UINT32_1D_ARRAY(ID, PTARGET, VAL) \ + _getAttributeOverrideArrayWord(ID, PTARGET, VAL) +/* global get override uint32_t 2D array macro */ +#define PLAT_ATTR_GET_OVERRIDE_UINT32_2D_ARRAY(ID, PTARGET, VAL) \ + _getAttributeOverrideArrayWord(ID, PTARGET, VAL[0]) +/* global get override uint32_t 3D array macro */ +#define PLAT_ATTR_GET_OVERRIDE_UINT32_3D_ARRAY(ID, PTARGET, VAL) \ + _getAttributeOverrideArrayWord(ID, PTARGET, VAL[0][0]) +/* global get override uint32_t 4D array macro */ +#define PLAT_ATTR_GET_OVERRIDE_UINT32_4D_ARRAY(ID, PTARGET, VAL) \ + _getAttributeOverrideArrayWord(ID, PTARGET, VAL[0][0][0]) + + +/* global get override uint64_t 1D array macro */ +#define PLAT_ATTR_GET_OVERRIDE_UINT64_1D_ARRAY(ID, PTARGET, VAL) \ + _getAttributeOverrideArrayDoubleWord(ID, PTARGET, VAL) +/* global get override uint64_t 2D array macro */ +#define PLAT_ATTR_GET_OVERRIDE_UINT64_2D_ARRAY(ID, PTARGET, VAL) \ + _getAttributeOverrideArrayDoubleWord(ID, PTARGET, VAL[0]) +/* global get override uint64_t 3D array macro */ +#define PLAT_ATTR_GET_OVERRIDE_UINT64_3D_ARRAY(ID, PTARGET, VAL) \ + _getAttributeOverrideArrayDoubleWord(ID, PTARGET, VAL[0][0]) +/* global get override uint64_t 4D array macro */ +#define PLAT_ATTR_GET_OVERRIDE_UINT64_4D_ARRAY(ID, PTARGET, VAL) \ + _getAttributeOverrideArrayDoubleWord(ID, PTARGET, VAL[0][0][0]) + +/* global get override int macro (uint8_t, 32 and 64) */ +#define PLAT_ATTR_GET_OVERRIDE_GLOBAL_INT(ID, PTARGET, VAL) \ + _getOverride(ID, PTARGET, VAL) + +/******************************************************************************/ +// Get string +/******************************************************************************/ + +extern "C" +{ + extern fapi2attr::SystemAttributes_t G_system_attributes asm("G_system_attributes") __attribute__ ((section (".fixed"))); + extern fapi2attr::ProcChipAttributes_t G_proc_chip_attributes asm("G_proc_chip_attributes") __attribute__ ((section (".fixed"))); + extern fapi2attr::PervAttributes_t G_perv_attributes asm("G_perv_attributes") __attribute__ ((section (".fixed"))); + extern fapi2attr::CoreAttributes_t G_core_attributes asm("G_core_attributes") __attribute__ ((section (".fixed"))); + extern fapi2attr::EQAttributes_t G_eq_attributes asm("G_eq_attributes") __attribute__ ((section (".fixed"))); + extern fapi2attr::EXAttributes_t G_ex_attributes asm("G_ex_attributes") __attribute__ ((section (".fixed"))); + + extern fapi2attr::SystemAttributes_t* G_system_attributes_ptr; + extern fapi2attr::ProcChipAttributes_t* G_proc_chip_attributes_ptr; + extern fapi2attr::PervAttributes_t* G_perv_attributes_ptr; + extern fapi2attr::CoreAttributes_t* G_core_attributes_ptr; + extern fapi2attr::EQAttributes_t* G_eq_attributes_ptr; + extern fapi2attr::EXAttributes_t* G_ex_attributes_ptr; + +} + +namespace fapi2 +{ + + +// Parameters are done as pointers (vs references) to allow the attribute +// storage to be relocated +template +void __set( const Target& i_ptarget, TAttrStruct* object, const AttributeId attrid, const TValue& value ); + +template +void __get( const Target& i_ptarget, const TAttrStruct* object, const AttributeId attrid, TValue* value ); + + +/* INSERT NEW GETTER AND SETTER FUNCTIONS HERE */ + + + +//****************************************************************************** +// Get base template +//****************************************************************************** +template +ReturnCode _get(const AttributeId i_id, + const Target & i_pTarget, + T& o_value) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get uint8_t +//****************************************************************************** +template +ReturnCode _get(const AttributeId i_id, + const Target & i_pTarget, + uint8_t& o_value) +{ + static_assert(std::is_same::value, "Attribute type mismatch"); + + if(K & TARGET_TYPE_SYSTEM) + { + __get( i_pTarget, G_system_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_PROC_CHIP) + { + __get( i_pTarget, G_proc_chip_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_PERV) + { + __get( i_pTarget, G_perv_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_CORE) + { + __get( i_pTarget, G_core_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_EQ) + { + __get( i_pTarget, G_eq_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_EX) + { + __get( i_pTarget, G_ex_attributes_ptr, i_id, &o_value ); + } + + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get uint16_t +//****************************************************************************** +template +ReturnCode _get(const AttributeId i_id, + const Target & i_pTarget, + uint16_t& o_value) +{ + static_assert(std::is_same::value, "Attribute type mismatch"); + + if(K & TARGET_TYPE_SYSTEM) + { + __get( i_pTarget, G_system_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_PROC_CHIP) + { + __get( i_pTarget, G_proc_chip_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_PERV) + { + __get( i_pTarget, G_perv_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_CORE) + { + __get( i_pTarget, G_core_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_EQ) + { + __get( i_pTarget, G_eq_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_EX) + { + __get( i_pTarget, G_ex_attributes_ptr, i_id, &o_value ); + } + + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Get uint32_t +//****************************************************************************** +template +ReturnCode _get(const AttributeId i_id, + const Target & i_pTarget, + uint32_t& o_value) +{ + static_assert(std::is_same::value, "Attribute type mismatch"); + + if(K & TARGET_TYPE_SYSTEM) + { + __get( i_pTarget, G_system_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_PROC_CHIP) + { + __get( i_pTarget, G_proc_chip_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_PERV) + { + __get( i_pTarget, G_perv_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_CORE) + { + __get( i_pTarget, G_core_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_EQ) + { + __get( i_pTarget, G_eq_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_EX) + { + __get( i_pTarget, G_ex_attributes_ptr, i_id, &o_value ); + } + + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Get uint64_t +//****************************************************************************** +template +ReturnCode _get(const AttributeId i_id, + const Target & i_pTarget, + uint64_t& o_value) +{ + static_assert(std::is_same::value, "Attribute type mismatch"); + + if(K & TARGET_TYPE_SYSTEM) + { + __get( i_pTarget, G_system_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_PROC_CHIP) + { + __get( i_pTarget, G_proc_chip_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_PERV) + { + __get( i_pTarget, G_perv_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_CORE) + { + __get( i_pTarget, G_core_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_EQ) + { + __get( i_pTarget, G_eq_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_EX) + { + __get( i_pTarget, G_ex_attributes_ptr, i_id, &o_value ); + } + + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Get Override uint8_t +//****************************************************************************** +template +ReturnCode _getOverride(const AttributeId i_id, + const Target & i_pTarget, + uint8_t& o_value) +{ + static_assert(std::is_same::value, "Attribute type mismatch"); + + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Get Override uint16_t +//****************************************************************************** +template +ReturnCode _getOverride(const AttributeId i_id, + const Target & i_pTarget, + uint16_t& o_value) +{ + static_assert(std::is_same::value, "Attribute type mismatch"); + + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Get Override uint32_t +//****************************************************************************** +template +ReturnCode _getOverride(const AttributeId i_id, + const Target & i_pTarget, + uint32_t& o_value) +{ + static_assert(std::is_same::value, "Attribute type mismatch"); + + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Get Override uint64_t +//****************************************************************************** +template +ReturnCode _getOverride(const AttributeId i_id, + const Target & i_pTarget, + uint64_t& o_value) +{ + static_assert(std::is_same::value, "Attribute type mismatch"); + + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Get override EC Feature (uint8_t) +//****************************************************************************** +template +ReturnCode _getEcFeatureOverride(const AttributeId i_id, + const Target & i_pTarget, + uint8_t& o_value) +{ + static_assert(std::is_same::value, "Attribute type mismatch"); + + // The way this is implemented, we want to return a non-zero return code if we found an override. + // Return 0 if there was an error. + // This is how it's implemented: + // PLAT_GET_CHIP_EC_FEATURE_OVERRIDE(ID, PTARGET, VAL) ? fapi::FAPI_RC_SUCCESS : fapi::fapiQueryChipEcFeature(fapi::ID, PTARGET, VAL) + + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Get uint8_t array +//****************************************************************************** +template +ReturnCode _getAttributeArrayShort(const AttributeId i_id, + const Target & i_pTarget, + uint8_t * o_pValues) +{ +// fapi2::Attributeta o_data; +// fapi2::ReturnCode l_fapi_rc(FAPI2_RC_SUCCESS); +// uint32_t l_ecmd_rc = ECMD_SUCCESS; +// +// ecmdChipTarget l_ecmd_target; +// fapiTargetPointerToEcmdTarget(i_pTarget, l_ecmd_target); +// +// o_data.faValidMask = FAPI_ATTRIBUTE_TYPE_UINT8ARY; +// o_data.faUint8ary = o_pValues; +// +// l_ecmd_rc = fapi2GetAttribute(l_ecmd_target, i_id, o_data); +// if (l_ecmd_rc) +// { +// l_fapi_rc = (ReturnCodes) l_ecmd_rc; +// } +// return l_fapi_rc; + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Set uint8_t array +//****************************************************************************** +template +ReturnCode _setAttributeArrayShort(const AttributeId i_id, + const Target & i_pTarget, + uint8_t * i_pValues) +{ + if(K & TARGET_TYPE_SYSTEM) + { + __set( i_pTarget, G_system_attributes_ptr, i_id, *i_pValues ); + } + + if(K & TARGET_TYPE_PROC_CHIP) + { + __set( i_pTarget, G_proc_chip_attributes_ptr, *i_pValues ); + } + + if(K & TARGET_TYPE_PERV) + { + __set( i_pTarget, G_perv_attributes_ptr, *i_pValues ); + } + + if(K & TARGET_TYPE_CORE) + { + __set( i_pTarget, G_core_attributes_ptr, *i_pValues ); + } + + if(K & TARGET_TYPE_EQ) + { + __set( i_pTarget, G_eq_attributes_ptr, *i_pValues ); + } + + if(K & TARGET_TYPE_EX) + { + __set( i_pTarget, G_ex_attributes_ptr, *i_pValues ); + } + + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get uint16_t array +//****************************************************************************** +template +ReturnCode _getAttributeArrayWord(const AttributeId i_id, + const Target & i_pTarget, + uint16_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Set uint16_t array +//****************************************************************************** +template +ReturnCode _setAttributeArrayWord(const AttributeId i_id, + const Target & i_pTarget, + uint16_t * i_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get uint32_t array +//****************************************************************************** +template +ReturnCode _getAttributeArrayWord(const AttributeId i_id, + const Target & i_pTarget, + uint32_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Set uint32_t array +//****************************************************************************** +template +ReturnCode _setAttributeArrayWord(const AttributeId i_id, + const Target & i_pTarget, + uint32_t * i_pValues) +{ + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Get uint64_t array +//****************************************************************************** +template +ReturnCode _getAttributeArrayDoubleWord(const AttributeId i_id, + const Target & i_pTarget, + uint64_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Set uint64_t array +//****************************************************************************** +template +ReturnCode _setAttributeArrayDoubleWord(const AttributeId i_id, + const Target & i_pTarget, + uint64_t * i_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get Override uint8_t array +//****************************************************************************** +template +ReturnCode _getAttributeOverrideArrayShort(const AttributeId i_id, + const Target & i_pTarget, + uint8_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get Override uint16_t array +//****************************************************************************** +template +ReturnCode _getAttributeOverrideArrayWord(const AttributeId i_id, + const Target & i_pTarget, + uint16_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get Override uint32_t array +//****************************************************************************** +template +ReturnCode _getAttributeOverrideArrayWord(const AttributeId i_id, + const Target & i_pTarget, + uint32_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get Override uint64_t array +//****************************************************************************** +template +ReturnCode _getAttributeOverrideArrayDoubleWord(const AttributeId i_id, + const Target & i_pTarget, + uint64_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Set base template +//****************************************************************************** +template +ReturnCode _set(const AttributeId i_id, + const Target & i_pTarget, + const T& i_value) +{ + return FAPI2_RC_SUCCESS; +} + + + +//****************************************************************************** +// Set uint8_t +//****************************************************************************** +template +ReturnCode _set(const AttributeId i_id, + const Target & i_pTarget, + const uint8_t& i_value) +{ + static_assert(std::is_same::value, "Attribute type mismatch"); // May need to remove + + if(K & TARGET_TYPE_SYSTEM) + { + __set( i_pTarget, G_system_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_PROC_CHIP) + { + __set( i_pTarget, G_proc_chip_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_PERV) + { + __set( i_pTarget, G_perv_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_CORE) + { + __set( i_pTarget, G_core_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_EQ) + { + __set( i_pTarget, G_eq_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_EX) + { + __set( i_pTarget, G_ex_attributes_ptr, i_id, i_value ); + } + + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Set uint16_t +//****************************************************************************** +template +ReturnCode _set(const AttributeId i_id, + const Target & i_pTarget, + const uint16_t& i_value) +{ + static_assert(std::is_same::value, "Attribute type mismatch"); // May need to remove + + if(K & TARGET_TYPE_SYSTEM) + { + __set( i_pTarget, G_system_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_PROC_CHIP) + { + __set( i_pTarget, G_proc_chip_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_PERV) + { + __set( i_pTarget, G_perv_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_CORE) + { + __set( i_pTarget, G_core_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_EQ) + { + __set( i_pTarget, G_eq_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_EX) + { + __set( i_pTarget, G_ex_attributes_ptr, i_id, i_value ); + } + + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Set uint32_t +//****************************************************************************** +template +ReturnCode _set(const AttributeId i_id, + const Target & i_pTarget, + const uint32_t& i_value) +{ + static_assert(std::is_same::value, "Attribute type mismatch"); // May need to remove + + if(K & TARGET_TYPE_SYSTEM) + { + __set( i_pTarget, G_system_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_PROC_CHIP) + { + __set( i_pTarget, G_proc_chip_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_PERV) + { + __set( i_pTarget, G_perv_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_CORE) + { + __set( i_pTarget, G_core_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_EQ) + { + __set( i_pTarget, G_eq_attributes_ptr, i_id,i_value ); + } + + if(K & TARGET_TYPE_EX) + { + __set( i_pTarget, G_ex_attributes_ptr, i_id, i_value ); + } + + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Set uint64_t +//****************************************************************************** + +template +ReturnCode _set(const AttributeId i_id, + const Target & i_pTarget, + const uint64_t & i_value) +{ + static_assert(std::is_same::value, "Attribute type mismatch"); // May need to remove + + if(K & TARGET_TYPE_SYSTEM) + { + __set( i_pTarget, G_system_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_PROC_CHIP) + { + __set( i_pTarget, G_proc_chip_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_PERV) + { + __set( i_pTarget, G_perv_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_CORE) + { + __set( i_pTarget, G_core_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_EQ) + { + __set( i_pTarget, G_eq_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_EX) + { + __set( i_pTarget, G_ex_attributes_ptr, i_id, i_value ); + } + + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Get int8_t +//****************************************************************************** +template +ReturnCode _get(const AttributeId i_id, + const Target & i_pTarget, + int8_t& o_value) +{ + static_assert(std::is_same::value, "Attribute type mismatch"); + + if(K & TARGET_TYPE_SYSTEM) + { + __get( i_pTarget, G_system_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_PROC_CHIP) + { + __get( i_pTarget, G_proc_chip_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_PERV) + { + __get( i_pTarget, G_perv_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_CORE) + { + __get( i_pTarget, G_core_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_EQ) + { + __get( i_pTarget, G_eq_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_EX) + { + __get( i_pTarget, G_ex_attributes_ptr, i_id, &o_value ); + } + + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get int16_t +//****************************************************************************** +template +ReturnCode _get(const AttributeId i_id, + const Target & i_pTarget, + int16_t& o_value) +{ + static_assert(std::is_same::value, "Attribute type mismatch"); + + if(K & TARGET_TYPE_SYSTEM) + { + __get( i_pTarget, G_system_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_PROC_CHIP) + { + __get( i_pTarget, G_proc_chip_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_PERV) + { + __get( i_pTarget, G_perv_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_CORE) + { + __get( i_pTarget, G_core_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_EQ) + { + __get( i_pTarget, G_eq_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_EX) + { + __get( i_pTarget, G_ex_attributes_ptr, i_id, &o_value ); + } + + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Get int32_t +//****************************************************************************** +template +ReturnCode _get(const AttributeId i_id, + const Target & i_pTarget, + int32_t& o_value) +{ + static_assert(std::is_same::value, "Attribute type mismatch"); + + if(K & TARGET_TYPE_SYSTEM) + { + __get( i_pTarget, G_system_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_PROC_CHIP) + { + __get( i_pTarget, G_proc_chip_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_PERV) + { + __get( i_pTarget, G_perv_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_CORE) + { + __get( i_pTarget, G_core_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_EQ) + { + __get( i_pTarget, G_eq_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_EX) + { + __get( i_pTarget, G_ex_attributes_ptr, i_id, &o_value ); + } + + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Get int64_t +//****************************************************************************** +template +ReturnCode _get(const AttributeId i_id, + const Target & i_pTarget, + int64_t& o_value) +{ + static_assert(std::is_same::value, "Attribute type mismatch"); + + if(K & TARGET_TYPE_SYSTEM) + { + __set( i_pTarget, G_system_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_PROC_CHIP) + { + __get( i_pTarget, G_proc_chip_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_PERV) + { + __get( i_pTarget, G_perv_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_CORE) + { + __get( i_pTarget, G_core_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_EQ) + { + __get( i_pTarget, G_eq_attributes_ptr, i_id, &o_value ); + } + + if(K & TARGET_TYPE_EX) + { + __get( i_pTarget, G_ex_attributes_ptr, i_id, &o_value ); + } + + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Get Override int8_t +//****************************************************************************** +template +ReturnCode _getOverride(const AttributeId i_id, + const Target & i_pTarget, + int8_t& o_value) +{ + static_assert(std::is_same::value, "Attribute type mismatch"); + + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get Override int16_t +//****************************************************************************** +template +ReturnCode _getOverride(const AttributeId i_id, + const Target & i_pTarget, + int16_t& o_value) +{ + static_assert(std::is_same::value, "Attribute type mismatch"); + + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get Override int32_t +//****************************************************************************** +template +ReturnCode _getOverride(const AttributeId i_id, + const Target & i_pTarget, + int32_t& o_value) +{ + static_assert(std::is_same::value, "Attribute type mismatch"); + + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get Override int64_t +//****************************************************************************** +template +ReturnCode _getOverride(const AttributeId i_id, + const Target & i_pTarget, + int64_t& o_value) +{ + static_assert(std::is_same::value, "Attribute type mismatch"); + + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Get int8_t array +//****************************************************************************** +template +ReturnCode _getAttributeArraySignedShort(const AttributeId i_id, + const Target & i_pTarget, + int8_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Set int8_t array +//****************************************************************************** +template +ReturnCode _setAttributeArraySignedShort(const AttributeId i_id, + const Target & i_pTarget, + int8_t * i_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get int16_t array +//****************************************************************************** +template +ReturnCode _getAttributeArraySignedWord(const AttributeId i_id, + const Target & i_pTarget, + int16_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Set int16_t array +//****************************************************************************** +template +ReturnCode _setAttributeArraySignedWord(const AttributeId i_id, + const Target & i_pTarget, + int16_t * i_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get int32_t array +//****************************************************************************** +template +ReturnCode _getAttributeArraySignedWord(const AttributeId i_id, + const Target & i_pTarget, + int32_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Set int32_t array +//****************************************************************************** +template +ReturnCode _setAttributeArraySignedWord(const AttributeId i_id, + const Target & i_pTarget, + int32_t * i_pValues) +{ + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Get int64_t array +//****************************************************************************** +template +ReturnCode _getAttributeArraySignedDoubleWord(const AttributeId i_id, + const Target & i_pTarget, + int64_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Set int64_t array +//****************************************************************************** +template +ReturnCode _setAttributeArraySignedDoubleWord(const AttributeId i_id, + const Target & i_pTarget, + int64_t * i_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get Override int8_t array +//****************************************************************************** +template +ReturnCode _getAttributeOverrideArraySignedShort(const AttributeId i_id, + const Target & i_pTarget, + int8_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get Override int16_t array +//****************************************************************************** +template +ReturnCode _getAttributeOverrideArraySignedWord(const AttributeId i_id, + const Target & i_pTarget, + int16_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get Override int32_t array +//****************************************************************************** +template +ReturnCode _getAttributeOverrideArraySignedWord(const AttributeId i_id, + const Target & i_pTarget, + int32_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Get Override int64_t array +//****************************************************************************** +template +ReturnCode _getAttributeOverrideArraySignedDoubleWord(const AttributeId i_id, + const Target & i_pTarget, + int64_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Set int8_t +//****************************************************************************** +template +ReturnCode _set(const AttributeId i_id, + const Target & i_pTarget, + const int8_t& i_value) +{ + static_assert(std::is_same::value, "Attribute type mismatch"); // May need to remove + + if(K & TARGET_TYPE_SYSTEM) + { + __set( i_pTarget, G_system_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_PROC_CHIP) + { + __set( i_pTarget, G_proc_chip_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_PERV) + { + __set( i_pTarget, G_perv_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_CORE) + { + __set( i_pTarget, G_core_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_EQ) + { + __set( i_pTarget, G_eq_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_EX) + { + __set( i_pTarget, G_ex_attributes_ptr, i_id, i_value ); + } + + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Set int16_t +//****************************************************************************** +template +ReturnCode _set(const AttributeId i_id, + const Target & i_pTarget, + const int16_t& i_value) +{ + static_assert(std::is_same::value, "Attribute type mismatch"); // May need to remove + + if(K & TARGET_TYPE_SYSTEM) + { + __set( i_pTarget, G_system_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_PROC_CHIP) + { + __set( i_pTarget, G_proc_chip_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_PERV) + { + __set( i_pTarget, G_perv_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_CORE) + { + __set( i_pTarget, G_core_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_EQ) + { + __set( i_pTarget, G_eq_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_EX) + { + __set( i_pTarget, G_ex_attributes_ptr, i_id, i_value ); + } + + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Set int32_t +//****************************************************************************** +template +ReturnCode _set(const AttributeId i_id, + const Target & i_pTarget, + const int32_t& i_value) +{ + static_assert(std::is_same::value, "Attribute type mismatch"); // May need to remove + + if(K & TARGET_TYPE_SYSTEM) + { + __set( i_pTarget, G_system_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_PROC_CHIP) + { + __set( i_pTarget, G_proc_chip_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_PERV) + { + __set( i_pTarget, G_perv_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_CORE) + { + __set( i_pTarget, G_core_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_EQ) + { + __set( i_pTarget, G_eq_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_EX) + { + __set( i_pTarget, G_ex_attributes_ptr, i_id, i_value ); + } + + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Set int64_t +//****************************************************************************** +template +ReturnCode _set(const AttributeId i_id, + const Target & i_pTarget, + const int64_t & i_value) +{ + static_assert(std::is_same::value, "Attribute type mismatch"); // May need to remove + + if(K & TARGET_TYPE_SYSTEM) + { + __set( i_pTarget, G_system_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_PROC_CHIP) + { + __set( i_pTarget, G_proc_chip_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_PERV) + { + __set( i_pTarget, G_perv_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_CORE) + { + __set( i_pTarget, G_core_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_EQ) + { + __set( i_pTarget, G_eq_attributes_ptr, i_id, i_value ); + } + + if(K & TARGET_TYPE_EX) + { + __set( i_pTarget, G_ex_attributes_ptr, i_id, i_value ); + } + + return FAPI2_RC_SUCCESS; +} + + +} // namespace fapi2 +#endif // FAPIPLATATTRIBUTESERVICE_H_ diff --git a/src/hwpf/src/plat/plat_utils.C b/src/hwpf/src/plat/plat_utils.C index 93a0cb2f..f9bbea9a 100644 --- a/src/hwpf/src/plat/plat_utils.C +++ b/src/hwpf/src/plat/plat_utils.C @@ -29,109 +29,15 @@ */ #include -#include -#include +#include +#include #include #include #include -#ifndef __PPE__ -#include -#endif - namespace fapi2 { -#ifndef __PPE__ - /// - /// @brief Log an error. - /// - void logError( - fapi2::ReturnCode & io_rc, - fapi2::errlSeverity_t i_sev = fapi2::FAPI2_ERRL_SEV_UNRECOVERABLE, - bool i_unitTestError = false ) - { - // To keep the compiler from complaing about i_sevbeing unused. - static_cast(i_sev); - static_cast(i_unitTestError); - - FAPI_DBG("logging 0x%lx.", uint64_t(io_rc)); - - // Iterate over the vectors and output what is in them. - const ErrorInfo* ei = io_rc.getErrorInfo(); - - FAPI_DBG("ffdcs: %lu", ei->iv_ffdcs.size()); - for( auto i = ei->iv_ffdcs.begin(); i != ei->iv_ffdcs.end(); ++i ) - { - uint32_t sz; - (*i)->getData(sz); - FAPI_DBG("\tid: 0x%x size %d", (*i)->getFfdcId(), sz); - } - - FAPI_DBG("hwCallouts: %lu", ei->iv_hwCallouts.size()); - for( auto i = ei->iv_hwCallouts.begin(); i != ei->iv_hwCallouts.end(); - ++i ) - { - FAPI_DBG("\thw: %d pri %d target: 0x%lx", - (*i)->iv_hw, (*i)->iv_calloutPriority, - (*i)->iv_refTarget.get()); - } - - FAPI_DBG("procedureCallouts: %lu", ei->iv_procedureCallouts.size()); - for( auto i = ei->iv_procedureCallouts.begin(); - i != ei->iv_procedureCallouts.end(); ++i ) - { - FAPI_DBG("\tprocedure: %d pri %d", - (*i)->iv_procedure, (*i)->iv_calloutPriority); - } - -e FAPI_DBG("busCallouts: %lu", ei->iv_busCallouts.size()); - for( auto i = ei->iv_busCallouts.begin(); i != ei->iv_busCallouts.end(); - ++i ) - { - FAPI_DBG("\tbus: t1: 0x%lx t2: 0x%lx pri: %d", - (*i)->iv_target1.get(), (*i)->iv_target2.get(), - (*i)->iv_calloutPriority); - } - - - FAPI_DBG("cdgs: %lu", ei->iv_CDGs.size()); - for( auto i = ei->iv_CDGs.begin(); i != ei->iv_CDGs.end(); ++i ) - { - FAPI_DBG("\ttarget: 0x%lx co: %d dc: %d gard: %d pri: %d", - (*i)->iv_target.get(), - (*i)->iv_callout, - (*i)->iv_deconfigure, - (*i)->iv_gard, - (*i)->iv_calloutPriority); - - } - - FAPI_DBG("childrenCDGs: %lu", ei->iv_childrenCDGs.size()); - for( auto i = ei->iv_childrenCDGs.begin(); - i != ei->iv_childrenCDGs.end(); ++i ) - { - FAPI_DBG("\tchildren: parent 0x%lx co: %d dc: %d gard: %d pri: %d", - (*i)->iv_parent.get(), - (*i)->iv_callout, - (*i)->iv_deconfigure, - (*i)->iv_gard, - (*i)->iv_calloutPriority); - } - - FAPI_DBG("traces: %lu", ei->iv_traces.size()); - for( auto i = ei->iv_traces.begin(); i != ei->iv_traces.end(); ++i ) - { - FAPI_DBG("\ttraces: 0x%x", (*i)->iv_eiTraceId); - } - - // Release the ffdc information now that we're done with it. - io_rc.forgetData(); - - } -#endif - - /// /// @brief Delay this thread. /// ReturnCode delay(uint64_t i_nanoSeconds, uint64_t i_simCycles, bool i_fixed /* = false*/) diff --git a/src/hwpf/src/plat_ring_traverse.C b/src/hwpf/src/plat_ring_traverse.C index 42dab1b2..86c6515d 100644 --- a/src/hwpf/src/plat_ring_traverse.C +++ b/src/hwpf/src/plat_ring_traverse.C @@ -27,7 +27,7 @@ #include // for RS4 decompression utilities #include -#include // for FAPI_ATTR_GET +#include // for FAPI_ATTR_GET #include // for plat_getChipTarget // SEEPROM start address @@ -64,7 +64,7 @@ fapi2::ReturnCode findRS4InImageAndApply( // Get the address of the Section-TOR P9XipHeader *l_hdr = getXipHdr(); - P9XipSection *l_section = + P9XipSection *l_section = &(l_hdr->iv_section[P9_XIP_SECTION_SBE_RINGS]); if (!(l_section->iv_offset)) @@ -73,7 +73,7 @@ fapi2::ReturnCode findRS4InImageAndApply( break; } - SectionTOR *l_sectionTOR = (SectionTOR *)(g_seepromAddr + + SectionTOR *l_sectionTOR = (SectionTOR *)(g_seepromAddr + l_section->iv_offset); l_rc = getRS4ImageFromTor(i_target,i_ringID,l_sectionTOR, @@ -89,7 +89,7 @@ fapi2::ReturnCode findRS4InImageAndApply( //Apply scanring from .ring section l_applyOverride = true; l_section = NULL; - l_section = + l_section = &(l_hdr->iv_section[P9_XIP_SECTION_SBE_OVERRIDES]); if (!(l_section->iv_offset)) @@ -99,7 +99,7 @@ fapi2::ReturnCode findRS4InImageAndApply( } l_sectionTOR = NULL; - l_sectionTOR = (SectionTOR *)(g_seepromAddr + + l_sectionTOR = (SectionTOR *)(g_seepromAddr + l_section->iv_offset); @@ -149,10 +149,10 @@ fapi2::ReturnCode getRS4ImageFromTor( { case PERV_TYPE: // PERV l_chipletData = PERV::g_pervData; - l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - (sizeof(PERV::RingVariants) / + l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : + (sizeof(PERV::RingVariants) / sizeof(l_cpltRingVariantSz)); - + l_sectionOffset = i_sectionTOR->TOC_PERV_COMMON_RING; if(INSTANCE_RING == l_ringType) { @@ -164,7 +164,7 @@ fapi2::ReturnCode getRS4ImageFromTor( case N0_TYPE: // Nest - N0 l_chipletData = N0::g_n0Data; l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - (sizeof(N0::RingVariants) / + (sizeof(N0::RingVariants) / sizeof(l_cpltRingVariantSz)); l_sectionOffset = i_sectionTOR->TOC_N0_COMMON_RING; @@ -206,7 +206,7 @@ fapi2::ReturnCode getRS4ImageFromTor( case N3_TYPE: // Nest - N3 l_chipletData = N3::g_n3Data; l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - (sizeof(N3::RingVariants) / + (sizeof(N3::RingVariants) / sizeof(l_cpltRingVariantSz)); l_sectionOffset = i_sectionTOR->TOC_N3_COMMON_RING; @@ -234,7 +234,7 @@ fapi2::ReturnCode getRS4ImageFromTor( case MC_TYPE: // MC - MC23 l_chipletData = MC::g_mcData; l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - (sizeof(MC::RingVariants)/ + (sizeof(MC::RingVariants)/ sizeof(l_cpltRingVariantSz)); l_sectionOffset = i_sectionTOR->TOC_MC_COMMON_RING; @@ -248,7 +248,7 @@ fapi2::ReturnCode getRS4ImageFromTor( case OB0_TYPE: // OB0 l_chipletData = OB0::g_ob0Data; l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - (sizeof(OB0::RingVariants) / + (sizeof(OB0::RingVariants) / sizeof(l_cpltRingVariantSz)); l_sectionOffset = i_sectionTOR->TOC_OB0_COMMON_RING; @@ -261,7 +261,7 @@ fapi2::ReturnCode getRS4ImageFromTor( case OB1_TYPE: // OB1 l_chipletData = OB1::g_ob1Data; l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - (sizeof(OB1::RingVariants) / + (sizeof(OB1::RingVariants) / sizeof(l_cpltRingVariantSz)); l_sectionOffset = i_sectionTOR->TOC_OB1_COMMON_RING; @@ -274,7 +274,7 @@ fapi2::ReturnCode getRS4ImageFromTor( case OB2_TYPE: // OB2 l_chipletData = OB2::g_ob2Data; l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - (sizeof(OB2::RingVariants) / + (sizeof(OB2::RingVariants) / sizeof(l_cpltRingVariantSz)); l_sectionOffset = i_sectionTOR->TOC_OB2_COMMON_RING; @@ -287,7 +287,7 @@ fapi2::ReturnCode getRS4ImageFromTor( case OB3_TYPE: // OB3 l_chipletData = OB3::g_ob3Data; l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - (sizeof(OB3::RingVariants) / + (sizeof(OB3::RingVariants) / sizeof(l_cpltRingVariantSz)); l_sectionOffset = i_sectionTOR->TOC_OB3_COMMON_RING; @@ -316,7 +316,7 @@ fapi2::ReturnCode getRS4ImageFromTor( case PCI1_TYPE: // PCI - PCI1 l_chipletData = PCI1::g_pci1Data; l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - (sizeof(PCI1::RingVariants) / + (sizeof(PCI1::RingVariants) / sizeof(l_cpltRingVariantSz)); l_sectionOffset = i_sectionTOR->TOC_PCI1_COMMON_RING; @@ -330,7 +330,7 @@ fapi2::ReturnCode getRS4ImageFromTor( case PCI2_TYPE: // PCI - PCI2 l_chipletData = PCI2::g_pci2Data; l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - (sizeof(PCI2::RingVariants) / + (sizeof(PCI2::RingVariants) / sizeof(l_cpltRingVariantSz)); l_sectionOffset = i_sectionTOR->TOC_PCI2_COMMON_RING; @@ -344,7 +344,7 @@ fapi2::ReturnCode getRS4ImageFromTor( case EQ_TYPE: // EQ - Quad 0 - Quad 5 l_chipletData = EQ::g_eqData; l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - ( sizeof(EQ::RingVariants) / + ( sizeof(EQ::RingVariants) / sizeof(l_cpltRingVariantSz)); l_sectionOffset = i_sectionTOR->TOC_EQ_COMMON_RING; @@ -383,7 +383,7 @@ fapi2::ReturnCode getRS4ImageFromTor( FAPI_INF("l_sectionOffset %08x",l_sectionOffset); // Determine the section TOR address for the ring - uint32_t *l_sectionAddr = reinterpret_cast(g_seepromAddr + + uint32_t *l_sectionAddr = reinterpret_cast(g_seepromAddr + i_sectionOffset + l_sectionOffset); SBE_TRACE ("l_sectionAddr %08X",l_sectionAddr); @@ -395,7 +395,7 @@ fapi2::ReturnCode getRS4ImageFromTor( { uint8_t l_chipletOffset = (l_chipletID - l_chipletData.iv_base_chiplet_number); - l_sectionAddr += (l_chipletOffset * + l_sectionAddr += (l_chipletOffset * (l_chipletData.iv_num_instance_rings )); } } @@ -408,8 +408,8 @@ fapi2::ReturnCode getRS4ImageFromTor( SBE_TRACE ("l_sectionAddr %08X",l_sectionAddr); // TOR records of Ring TOR are 2 bytes in size. - uint16_t *l_ringTorAddr = reinterpret_cast(l_sectionAddr) + - (l_torOffset * l_cpltRingVariantSz); + uint16_t *l_ringTorAddr = reinterpret_cast(l_sectionAddr) + + (l_torOffset * l_cpltRingVariantSz); SBE_TRACE ("ring tor address %04X\n",l_ringTorAddr); // If there are non-base variants of the ring, we'll have to check -- cgit v1.2.1