From e97705e412957844cc516486a6686de1a8d69ecb Mon Sep 17 00:00:00 2001 From: Santosh Puranik Date: Mon, 29 May 2017 06:15:17 -0500 Subject: FAPI Plat Cleanup -- Remove src and include subdirs Change-Id: I47d2b7d0b3667e7765692fb014932ae23a6325f7 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/41085 Tested-by: Jenkins Server Tested-by: FSP CI Jenkins Reviewed-by: Sachin Gupta Reviewed-by: Shakeeb A. Pasha B K Reviewed-by: Santosh S. Puranik --- src/hwpf/Makefile | 48 + src/hwpf/fapi2sbefiles.mk | 52 + src/hwpf/ffdc.C | 41 + src/hwpf/hw_access.H | 610 ++++++++++ src/hwpf/hwp_executor.H | 64 + src/hwpf/include/plat/hw_access.H | 611 ---------- src/hwpf/include/plat/hwp_executor.H | 65 - src/hwpf/include/plat/multicast.H | 55 - src/hwpf/include/plat/plat_attributes.H | 36 - src/hwpf/include/plat/plat_error_scope.H | 80 -- src/hwpf/include/plat/plat_hw_access.H | 166 --- src/hwpf/include/plat/plat_includes.H | 40 - src/hwpf/include/plat/plat_ring_traverse.H | 117 -- src/hwpf/include/plat/plat_target.H | 292 ----- src/hwpf/include/plat/plat_target_definitions.H | 112 -- src/hwpf/include/plat/plat_target_filter.H | 90 -- src/hwpf/include/plat/plat_target_parms.H | 101 -- src/hwpf/include/plat/plat_target_utils.H | 89 -- src/hwpf/include/plat/plat_trace.H | 114 -- src/hwpf/include/plat/plat_utils.H | 65 - src/hwpf/include/plat/target.H | 410 ------- src/hwpf/multicast.H | 54 + src/hwpf/plat_attribute_service.H | 1441 ++++++++++++++++++++++ src/hwpf/plat_attributes.H | 35 + src/hwpf/plat_error_scope.H | 79 ++ src/hwpf/plat_hw_access.C | 357 ++++++ src/hwpf/plat_hw_access.H | 165 +++ src/hwpf/plat_includes.H | 39 + src/hwpf/plat_ring_traverse.C | 498 ++++++++ src/hwpf/plat_ring_traverse.H | 116 ++ src/hwpf/plat_target.H | 291 +++++ src/hwpf/plat_target_definitions.H | 111 ++ src/hwpf/plat_target_filter.H | 89 ++ src/hwpf/plat_target_parms.H | 100 ++ src/hwpf/plat_target_utils.H | 88 ++ src/hwpf/plat_trace.H | 113 ++ src/hwpf/plat_utils.C | 196 +++ src/hwpf/plat_utils.H | 65 + src/hwpf/src/Makefile | 52 - src/hwpf/src/fapi2sbefiles.mk | 50 - src/hwpf/src/ffdc.C | 42 - src/hwpf/src/plat/Makefile | 42 - src/hwpf/src/plat/fapi2sbeplatfiles.mk | 53 - src/hwpf/src/plat/plat_attribute_service.H | 1442 ----------------------- src/hwpf/src/plat/plat_hw_access.C | 358 ------ src/hwpf/src/plat/plat_utils.C | 197 ---- src/hwpf/src/plat/target.C | 755 ------------ src/hwpf/src/plat_ring_traverse.C | 499 -------- src/hwpf/src/return_code.C | 47 - src/hwpf/target.C | 754 ++++++++++++ src/hwpf/target.H | 409 +++++++ 51 files changed, 5815 insertions(+), 5980 deletions(-) create mode 100644 src/hwpf/Makefile create mode 100644 src/hwpf/fapi2sbefiles.mk create mode 100644 src/hwpf/ffdc.C create mode 100644 src/hwpf/hw_access.H create mode 100644 src/hwpf/hwp_executor.H delete mode 100644 src/hwpf/include/plat/hw_access.H delete mode 100644 src/hwpf/include/plat/hwp_executor.H delete mode 100644 src/hwpf/include/plat/multicast.H delete mode 100644 src/hwpf/include/plat/plat_attributes.H delete mode 100644 src/hwpf/include/plat/plat_error_scope.H delete mode 100644 src/hwpf/include/plat/plat_hw_access.H delete mode 100644 src/hwpf/include/plat/plat_includes.H delete mode 100644 src/hwpf/include/plat/plat_ring_traverse.H delete mode 100644 src/hwpf/include/plat/plat_target.H delete mode 100644 src/hwpf/include/plat/plat_target_definitions.H delete mode 100644 src/hwpf/include/plat/plat_target_filter.H delete mode 100644 src/hwpf/include/plat/plat_target_parms.H delete mode 100644 src/hwpf/include/plat/plat_target_utils.H delete mode 100644 src/hwpf/include/plat/plat_trace.H delete mode 100644 src/hwpf/include/plat/plat_utils.H delete mode 100644 src/hwpf/include/plat/target.H create mode 100644 src/hwpf/multicast.H create mode 100644 src/hwpf/plat_attribute_service.H create mode 100644 src/hwpf/plat_attributes.H create mode 100644 src/hwpf/plat_error_scope.H create mode 100644 src/hwpf/plat_hw_access.C create mode 100644 src/hwpf/plat_hw_access.H create mode 100644 src/hwpf/plat_includes.H create mode 100644 src/hwpf/plat_ring_traverse.C create mode 100644 src/hwpf/plat_ring_traverse.H create mode 100644 src/hwpf/plat_target.H create mode 100644 src/hwpf/plat_target_definitions.H create mode 100644 src/hwpf/plat_target_filter.H create mode 100644 src/hwpf/plat_target_parms.H create mode 100644 src/hwpf/plat_target_utils.H create mode 100644 src/hwpf/plat_trace.H create mode 100644 src/hwpf/plat_utils.C create mode 100644 src/hwpf/plat_utils.H delete mode 100644 src/hwpf/src/Makefile delete mode 100644 src/hwpf/src/fapi2sbefiles.mk delete mode 100644 src/hwpf/src/ffdc.C delete mode 100644 src/hwpf/src/plat/Makefile delete mode 100644 src/hwpf/src/plat/fapi2sbeplatfiles.mk delete mode 100644 src/hwpf/src/plat/plat_attribute_service.H delete mode 100644 src/hwpf/src/plat/plat_hw_access.C delete mode 100644 src/hwpf/src/plat/plat_utils.C delete mode 100644 src/hwpf/src/plat/target.C delete mode 100644 src/hwpf/src/plat_ring_traverse.C delete mode 100644 src/hwpf/src/return_code.C create mode 100644 src/hwpf/target.C create mode 100644 src/hwpf/target.H (limited to 'src/hwpf') diff --git a/src/hwpf/Makefile b/src/hwpf/Makefile new file mode 100644 index 00000000..e61d8a18 --- /dev/null +++ b/src/hwpf/Makefile @@ -0,0 +1,48 @@ +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: src/hwpf/Makefile $ +# +# OpenPOWER sbe Project +# +# Contributors Listed Below - COPYRIGHT 2015,2017 +# +# +# 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 +# This Makefile is designed to be invoked with the -I argument + +export SUB_OBJDIR = /fapi2 + +include img_defs.mk +include fapi2sbefiles.mk + + +OBJS := $(addprefix $(OBJDIR)/, $(FAPI2PLATLIB_OBJECTS)) + +libfapi2.a: fapi2 hwpf + $(AR) crs $(OBJDIR)/libfapi2.a $(OBJDIR)/*.o + +.PHONY: clean fapi2 hwpf +fapi2: $(OBJS) + +$(OBJS) $(OBJS:.o=.d): | $(OBJDIR) + +$(OBJDIR): + mkdir -p $(OBJDIR) + +ifneq ($(MAKECMDGOALS),clean) +include $(OBJS:.o=.d) +endif + diff --git a/src/hwpf/fapi2sbefiles.mk b/src/hwpf/fapi2sbefiles.mk new file mode 100644 index 00000000..93409440 --- /dev/null +++ b/src/hwpf/fapi2sbefiles.mk @@ -0,0 +1,52 @@ +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: src/hwpf/fapi2sbefiles.mk $ +# +# OpenPOWER sbe Project +# +# Contributors Listed Below - COPYRIGHT 2015,2017 +# +# +# 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 fapi2ppefiles.mk +# +# @brief mk for including fapi2 object files +# +# @page ChangeLogs Change Logs +# @section fapi2ppefiles.mk +# @verbatim +# +# +# Change Log ****************************************************************** +# Flag Defect/Feature User Date Description +# ------ -------------- ---------- ------------ ----------- +# +# @endverbatim +# +########################################################################## +# Object Files +########################################################################## + +FAPI2PLAT-CPP-SOURCES += plat_hw_access.C +FAPI2PLAT-CPP-SOURCES += plat_utils.C +FAPI2PLAT-CPP-SOURCES += target.C +FAPI2PLAT-CPP-SOURCES += ffdc.C +FAPI2PLAT-CPP-SOURCES += plat_ring_traverse.C +FAPI2PLAT-C-SOURCES = +FAPI2PLAT-S-SOURCES = + +FAPI2PLATLIB_OBJECTS += $(FAPI2PLAT-CPP-SOURCES:.C=.o) $(FAPI2PLAT-C-SOURCES:.c=.o) $(FAPI2PLAT-S-SOURCES:.S=.o) + diff --git a/src/hwpf/ffdc.C b/src/hwpf/ffdc.C new file mode 100644 index 00000000..05f14793 --- /dev/null +++ b/src/hwpf/ffdc.C @@ -0,0 +1,41 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/hwpf/ffdc.C $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2016,2017 */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +/** + * @file ffdc.C + * @brief Implements the ffdc for sbe + */ + +#include +#include + + +namespace fapi2 +{ + +#ifdef MINIMUM_FFDC + // buffer used to hold ffdc data + SbeFfdcData_t g_FfdcData; +#endif + +}; diff --git a/src/hwpf/hw_access.H b/src/hwpf/hw_access.H new file mode 100644 index 00000000..9c5da3aa --- /dev/null +++ b/src/hwpf/hw_access.H @@ -0,0 +1,610 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/hwpf/hw_access.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2012,2017 */ +/* */ +/* */ +/* 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 +{ + + /// @brief Default template to disallow at compile time any operations the + // plat does not support on Targets + template + struct does_plat_allow {static constexpr bool value = false;}; + + //-------------------------------------------------------------------------- + // PIB Error Functions + //-------------------------------------------------------------------------- + + /// @brief Sets the PIB error mask - platform dependant + /// @param[in] i_mask The new error mask + inline void setPIBErrorMask(uint8_t i_mask) + { + PLAT_SET_PIB_ERROR_MASK(i_mask); + } + + /// @brief Gets the PIB error mask - platform dependant + /// @return uint8_t The current PIB error mask + inline 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) + { + // TODO: via RTC: 160143: Fix the plat implementation + static_assert(does_plat_allow::value, "putScomUnderMask not suppported"); + 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 = RING_MODE_HEADER_CHECK) + { + 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/hwp_executor.H b/src/hwpf/hwp_executor.H new file mode 100644 index 00000000..f3d2ba0a --- /dev/null +++ b/src/hwpf/hwp_executor.H @@ -0,0 +1,64 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/hwpf/hwp_executor.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2016,2017 */ +/* */ +/* */ +/* 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 fapi2PlatHwpExecutor.H + * + * @brief Defines the FAPI HWP Executor Macro. + * + * The HWP Executor macro is called when a PLAT invoker function or a HWP wants + * to execute a HWP. Each platform can modify the macro to do any platform + * specific work to execute the HWP (e.g. dlopening a shared library) + */ + +#ifndef FAPI2PLATHWPEXECUTOR_H_ +#define FAPI2PLATHWPEXECUTOR_H_ + +/** + * @brief HWP Executor macro + * + * By default, this macro just calls the HWP directly. If this cannot be done + * then the platform needs to modify + */ + +#include +#include + + + +// Macro to execute an arbitrary function with an arbitray number of arguments. The +// function is in a shared lib that must be dlopened. All that is required is that +// there is a typedef for the function pointer available that is called _FP_t +// i.e. if the function is called foo, then the typedef is called foo_FP_t +#define FAPI_PLAT_EXEC_HWP(RC, FUNC, _args_...) \ +{\ + RC = FUNC(_args_); \ +} + +#define FAPI_PLAT_EXEC_HWP_LAMBDA(FUNC, _args_...) \ +[&]()->fapi2::ReturnCode \ +{\ + FUNC(_args_); \ +}() + +#endif // FAPI2PLATHWPEXECUTOR_H_ diff --git a/src/hwpf/include/plat/hw_access.H b/src/hwpf/include/plat/hw_access.H deleted file mode 100644 index fdbca56a..00000000 --- a/src/hwpf/include/plat/hw_access.H +++ /dev/null @@ -1,611 +0,0 @@ -/* 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,2017 */ -/* [+] International Business Machines Corp. */ -/* */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ -/* implied. See the License for the specific language governing */ -/* permissions and limitations under the License. */ -/* */ -/* IBM_PROLOG_END_TAG */ -/** - * @file 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 -{ - - /// @brief Default template to disallow at compile time any operations the - // plat does not support on Targets - template - struct does_plat_allow {static constexpr bool value = false;}; - - //-------------------------------------------------------------------------- - // PIB Error Functions - //-------------------------------------------------------------------------- - - /// @brief Sets the PIB error mask - platform dependant - /// @param[in] i_mask The new error mask - inline void setPIBErrorMask(uint8_t i_mask) - { - PLAT_SET_PIB_ERROR_MASK(i_mask); - } - - /// @brief Gets the PIB error mask - platform dependant - /// @return uint8_t The current PIB error mask - inline 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) - { - // TODO: via RTC: 160143: Fix the plat implementation - static_assert(does_plat_allow::value, "putScomUnderMask not suppported"); - 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 = RING_MODE_HEADER_CHECK) - { - 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/hwp_executor.H b/src/hwpf/include/plat/hwp_executor.H deleted file mode 100644 index c77b163a..00000000 --- a/src/hwpf/include/plat/hwp_executor.H +++ /dev/null @@ -1,65 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/hwpf/include/plat/hwp_executor.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 fapi2PlatHwpExecutor.H - * - * @brief Defines the FAPI HWP Executor Macro. - * - * The HWP Executor macro is called when a PLAT invoker function or a HWP wants - * to execute a HWP. Each platform can modify the macro to do any platform - * specific work to execute the HWP (e.g. dlopening a shared library) - */ - -#ifndef FAPI2PLATHWPEXECUTOR_H_ -#define FAPI2PLATHWPEXECUTOR_H_ - -/** - * @brief HWP Executor macro - * - * By default, this macro just calls the HWP directly. If this cannot be done - * then the platform needs to modify - */ - -#include -#include - - - -// Macro to execute an arbitrary function with an arbitray number of arguments. The -// function is in a shared lib that must be dlopened. All that is required is that -// there is a typedef for the function pointer available that is called _FP_t -// i.e. if the function is called foo, then the typedef is called foo_FP_t -#define FAPI_PLAT_EXEC_HWP(RC, FUNC, _args_...) \ -{\ - RC = FUNC(_args_); \ -} - -#define FAPI_PLAT_EXEC_HWP_LAMBDA(FUNC, _args_...) \ -[&]()->fapi2::ReturnCode \ -{\ - FUNC(_args_); \ -}() - -#endif // FAPI2PLATHWPEXECUTOR_H_ diff --git a/src/hwpf/include/plat/multicast.H b/src/hwpf/include/plat/multicast.H deleted file mode 100644 index 5bf1c549..00000000 --- a/src/hwpf/include/plat/multicast.H +++ /dev/null @@ -1,55 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/hwpf/include/plat/multicast.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 */ -#ifndef __FAPI2_MULTICAST__ -#define __FAPI2_MULTICAST__ - -#include - -namespace fapi2 -{ - -template -template -inline void Multicast::updateHandle(V& i_value) -{ - // Update handle only if multicast bit is set in handle, else we leave the - // handle unchanged. This enables the same procedure to work with both - // multicast and unicast targets - if(i_value.fields.is_multicast) - { - // Update the handle to reflect the new multicast type and group - i_value.fields.chiplet_num = (0x40) | (O << 3) | N; - } -} - -template -inline bool Multicast::isMulticast() const -{ - return iv_handle.fields.is_multicast; -} - -} - -#endif diff --git a/src/hwpf/include/plat/plat_attributes.H b/src/hwpf/include/plat/plat_attributes.H deleted file mode 100644 index 781cbd56..00000000 --- a/src/hwpf/include/plat/plat_attributes.H +++ /dev/null @@ -1,36 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/hwpf/include/plat/plat_attributes.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 plat_attributes.H - * @brief Platform specific attribute headers - */ - -#ifndef __PLAT_ATTTRIBUTE_H__ -#define __PLAT_ATTTRIBUTE_H__ - -#include -#include // Generated file - -#endif // __PLAT_ATTTRIBUTE_H__ diff --git a/src/hwpf/include/plat/plat_error_scope.H b/src/hwpf/include/plat/plat_error_scope.H deleted file mode 100644 index 153de5e2..00000000 --- a/src/hwpf/include/plat/plat_error_scope.H +++ /dev/null @@ -1,80 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/hwpf/include/plat/plat_error_scope.H $ */ -/* */ -/* OpenPOWER sbe Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2012,2017 */ -/* [+] International Business Machines Corp. */ -/* */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ -/* implied. See the License for the specific language governing */ -/* permissions and limitations under the License. */ -/* */ -/* IBM_PROLOG_END_TAG */ -/** - * @file plat_error_scope.H - * @brief platform definitions which create a scope for automatic error handling - */ - -#ifndef __FAPI2_PLAT_ERROR_SCOPE__ -#define __FAPI2_PLAT_ERROR_SCOPE__ - -/// @cond -#define PLAT_FAPI_TRY_NO_TRACE( __operation__ ) \ - if(std::is_same::value) \ - { \ - (void)((__operation__)); \ - } \ - else \ - { \ - if ((fapi2::current_err = (__operation__)) != fapi2::FAPI2_RC_SUCCESS) \ - { \ - goto fapi_try_exit; \ - } \ - } - - -#define PLAT_FAPI_TRY_TRACE( __operation__, ... ) \ - if ((fapi2::current_err = (__operation__)) != fapi2::FAPI2_RC_SUCCESS) \ - { /* TODO via RTC 172311 */ \ - /* Enable these traces back again */ \ - /* FAPI_ERR(__VA_ARGS__); */ \ - goto fapi_try_exit; \ - } - -/// -/// @brief Assert a conditional is true. -/// If it is not, the FFDC gathering function is called and the -/// trace is output as a FAPI error trace. -/// @param[in] __conditional__ the condition to assert -/// @param[in] __ffdc__ the FFDC gathering function -/// @param[in] ... varargs, as input to FAPI_ERR -/// -#define PLAT_FAPI_ASSERT( __conditional__, __ffdc__, ... ) \ - if (! (__conditional__)) \ - { \ - (__ffdc__).execute(); \ - FAPI_ERR(__VA_ARGS__); \ - goto fapi_try_exit; \ - } - - -/// -/// @brief Temporary macro for error label until all are removed. -/// @todo REMOVE this in time. -#define FAPI_CLEANUP() \ -fapi_try_exit: -/// @endcond - -#endif diff --git a/src/hwpf/include/plat/plat_hw_access.H b/src/hwpf/include/plat/plat_hw_access.H deleted file mode 100644 index 55c84f98..00000000 --- a/src/hwpf/include/plat/plat_hw_access.H +++ /dev/null @@ -1,166 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/hwpf/include/plat/plat_hw_access.H $ */ -/* */ -/* OpenPOWER sbe Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2015,2017 */ -/* [+] International Business Machines Corp. */ -/* */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ -/* implied. See the License for the specific language governing */ -/* permissions and limitations under the License. */ -/* */ -/* IBM_PROLOG_END_TAG */ -/** - * @file plat_hw_access.H - * - * @brief Define platform specific calls for hardware accesses. - */ - -#ifndef PLATHWACCESS_H_ -#define PLATHWACCESS_H_ - -#include -#include "hw_access_def.H" -#include -#include - -// PIB errors -enum PCB_ERRORS -{ - PIB_NO_ERROR = 0x0, - PIB_XSCOM_ERROR = 0x1, - PIB_OFFLINE_ERROR = 0x2, - PIB_PARTIAL_ERROR = 0x3, - PIB_ADDRESS_ERROR = 0x4, - PIB_CLOCK_ERROR = 0x5, - PIB_PARITY_ERROR = 0x6, - PIB_TIMEOUT_ERROR = 0x7 -}; - -/// PIB Error Mask - -#define PLAT_SET_PIB_ERROR_MASK(_m_mask) \ - { /* Read MSR */ \ - uint32_t msr_data = mfmsr(); \ - /* Set SEM field */ \ - msr_data &= ~(BITS(0,8)); \ - msr_data |= (uint32_t)(i_mask << 24); \ - /* Write MSR */ \ - mtmsr(msr_data); \ - }; - -#define PLAT_GET_PIB_ERROR_MASK(_m_mask) \ - uint8_t _m_mask; \ - uint32_t _sem = mfmsr(); \ - _m_mask = (uint8_t)((_sem & MSR_SEM) >> (32-(MSR_SEM_START_BIT + MSR_SEM_LEN))); - -// Building block PPE instructions -#define PPE_MFMSR(_m_data) \ -asm volatile \ - ( \ - "mfmsr %[data] \n" \ - : [data]"=&r"(*_m_data) \ - : "[data]"(*_m_data) \ - ); - -#define PPE_MTMSR(_m_data) \ -asm volatile \ - ( \ - "mtmsr %[data] \n" \ - : [data]"=&r"(*_m_data) \ - : "[data]"(*_m_data) \ - ); - -/// GetScom -#define PLAT_GETSCOM(_m_rc, _m_base, _m_offset, _m_data) \ - _m_rc = fapi2::getscom_abs_wrap(&(_m_base), _m_offset, _m_data) - -/// PutScom -#define PLAT_PUTSCOM(_m_rc, _m_base, _m_offset, _m_data) \ - _m_rc = fapi2::putscom_abs_wrap(&(_m_base), _m_offset, _m_data) - -/// GetCFAM -#define PLAT_GETCFAM(_m_base, _m_offset, _m_data) \ - static_assert( K == TARGET_TYPE_NONE, \ - "getCfamRegister is not supported by PPE platforms") - -/// PutCFAM -#define PLAT_PUTCFAM(_m_base, _m_offset, _m_data) \ - static_assert( K == TARGET_TYPE_NONE, \ - "putCfamRegister is not supported by PPE platforms") - -/// ModifyCFAM -#define PLAT_MODCFAM(_m_base, _m_offset, _m_data, _m_mode) \ - static_assert( K == TARGET_TYPE_NONE, \ - "modifyCfamRegister is not supported by PPE platforms") - -namespace fapi2 -{ - // This function loads the scan region data for the given ring address and - // updates the check word data - // @param[in] : ring addtress - // @param[in]: ring mode - // @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - fapi2::ReturnCode getRing_setup(const uint32_t i_ringAddress, - const fapi2::RingMode i_ringMode); - - // This function verify the check word data is matching or not and will - // clean up the scan region data - // @param[in] i_ringAddress - absolute ring address - // @param[in] i_ringMode - Ring mode value - // @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - fapi2::ReturnCode getRing_verifyAndcleanup(const uint32_t i_ringAddress, - const fapi2::RingMode i_ringMode); - - typedef union plat_target_handle plat_target_handle_t; - /// - /// @brief Platform wrapper over PK getscom_abs - /// - /// @param [in] i_addr The SCOM address - /// @param [out] o_data The data read - /// - /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - /// - fapi2::ReturnCode getscom_abs_wrap(const void *i_target, - const uint32_t i_addr, uint64_t *o_data); - - /// - /// @brief Platform wrapper over PK putscom_abs - /// - /// @param [in] i_addr The SCOM address - /// @param [in] i_data The data to write - /// - /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - /// - fapi2::ReturnCode putscom_abs_wrap(const void *i_target, - const uint32_t i_addr, uint64_t i_data); - - /// - /// @brief Platform wrapper to retry scom for parity/timeout errors - /// - /// @param [in] i_addr The SCOM address - /// @param [io] io_data The data pointer - /// @param [in] i_pibErr PIB error code - /// @param [in] i_isRead True if read operation, false otherwise - /// - /// @return PCB-PIB return code - /// - uint32_t p9_pibErrRetry( const uint32_t i_addr, uint64_t *io_data, - const uint8_t i_pibErr, const bool i_isRead); -} - - -#endif // PLATHWACCESS_H_ - diff --git a/src/hwpf/include/plat/plat_includes.H b/src/hwpf/include/plat/plat_includes.H deleted file mode 100644 index bc706f28..00000000 --- a/src/hwpf/include/plat/plat_includes.H +++ /dev/null @@ -1,40 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/hwpf/include/plat/plat_includes.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 plat_includes.H - * @brief Platform specific include to implement FAPI2 APIs - */ - -#ifndef __PLAT_INCLUDES_H__ -#define __PLAT_INCLUDES_H__ - -#include - -#include -#include -//#include - - -#endif // __PLAT_INCLUDES_H__ diff --git a/src/hwpf/include/plat/plat_ring_traverse.H b/src/hwpf/include/plat/plat_ring_traverse.H deleted file mode 100644 index 54723051..00000000 --- a/src/hwpf/include/plat/plat_ring_traverse.H +++ /dev/null @@ -1,117 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/hwpf/include/plat/plat_ring_traverse.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 */ - -#ifndef _PLAT_RING_TRAVERSE_H_ -#define _PLAT_RING_TRAVERSE_H_ - -#include // for RS4 decompression utilities - -using namespace RING_TYPES; - -/// @brief This structure represents the layout of the Section-TOR -/// Section-TOR has the offsets to the different chiplet's -/// Common Ring section and Instance Ring section -struct SectionTOR -{ - uint32_t TOC_PERV_COMMON_RING; // Offset of Perv Common Ring section - uint32_t TOC_PERV_INSTANCE_RING; // Offset of Perv Instance Ring section - - uint32_t TOC_N0_COMMON_RING; // Offset of N0 Common Ring section - uint32_t TOC_N0_INSTANCE_RING; // Offset of N0 Instance Ring section - - uint32_t TOC_N1_COMMON_RING; // Offset of N1 Common Ring section - uint32_t TOC_N1_INSTANCE_RING; // Offset of N1 Instance Ring section - - uint32_t TOC_N2_COMMON_RING; // Offset of N2 Common Ring section - uint32_t TOC_N2_INSTANCE_RING; // Offset of N2 Instance Ring section - - uint32_t TOC_N3_COMMON_RING; // Offset of N3 Common Ring section - uint32_t TOC_N3_INSTANCE_RING; // Offset of N3 Instance Ring section - - uint32_t TOC_XB_COMMON_RING; // Offset of XB Common Ring section - uint32_t TOC_XB_INSTANCE_RING; // Offset of XB Instance Ring section - - uint32_t TOC_MC_COMMON_RING; // Offset of MC Common Ring section - uint32_t TOC_MC_INSTANCE_RING; // Offset of MC Instance Ring section - - uint32_t TOC_OB0_COMMON_RING; // Offset of OB0 Common Ring section - uint32_t TOC_OB0_INSTANCE_RING; // Offset of OB0 Instance Ring section - - uint32_t TOC_OB1_COMMON_RING; // Offset of OB1 Common Ring section - uint32_t TOC_OB1_INSTANCE_RING; // Offset of OB1 Instance Ring section - - uint32_t TOC_OB2_COMMON_RING; // Offset of OB2 Common Ring section - uint32_t TOC_OB2_INSTANCE_RING; // Offset of OB2 Instance Ring section - - uint32_t TOC_OB3_COMMON_RING; // Offset of OB3 Common Ring section - uint32_t TOC_OB3_INSTANCE_RING; // Offset of OB3 Instance Ring section - - uint32_t TOC_PCI0_COMMON_RING; // Offset of PCI0 Common Ring section - uint32_t TOC_PCI0_INSTANCE_RING; // Offset of PCI0 Instance Ring section - - uint32_t TOC_PCI1_COMMON_RING; // Offset of PCI1 Common Ring section - uint32_t TOC_PCI1_INSTANCE_RING; // Offset of PCI1 Instance Ring section - - uint32_t TOC_PCI2_COMMON_RING; // Offset of PCI2 Common Ring section - uint32_t TOC_PCI2_INSTANCE_RING; // Offset of PCI2 Instance Ring section - - uint32_t TOC_EQ_COMMON_RING; // Offset of Quad Common Ring section - uint32_t TOC_EQ_INSTANCE_RING; // Offset of Quad Instance Ring section - - uint32_t TOC_EC_COMMON_RING; // Offset of Core Common Ring section - uint32_t TOC_EC_INSTANCE_RING; // Offset of Core Instance Ring section -}; - - -/// -/// @brief This is a plat pecific (SBE Plat) function that locates the -/// Ring Container in the image and calls the functin to decompress the -/// RS4 string and apply it to the hardware. -/// @param i_target The target of Ring apply. -/// @param i_ringID The Ring ID that identifies the ring to be applied. -/// @return FAPI2_RC_SUCCESS on success, else error code. -/// -fapi2::ReturnCode findRS4InImageAndApply( - const fapi2::Target& i_target, - const RingID i_ringID, - const fapi2::RingMode i_ringMode); -/// -/// @brief This is a plat pecific (SBE Plat) function that locates the -/// Ring Container in the image and calls the functin to decompress the -/// RS4 string and apply it to the hardware. -/// @param i_target The target of Ring apply. -/// @param i_ringID The Ring ID that identifies the ring to be applied. -/// @param i_sectionTOR TOR section address -/// @param i_applyOverride override is enabled or not -/// @return FAPI2_RC_SUCCESS on success, else error code. -/// -fapi2::ReturnCode getRS4ImageFromTor( - const fapi2::Target& i_target, - const RingID i_ringID, - SectionTOR *i_sectionTOR, - bool i_applyOverride, - const uint32_t i_sectionOffset, - const fapi2::RingMode i_ringMode); -#endif diff --git a/src/hwpf/include/plat/plat_target.H b/src/hwpf/include/plat/plat_target.H deleted file mode 100644 index 88d7e231..00000000 --- a/src/hwpf/include/plat/plat_target.H +++ /dev/null @@ -1,292 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/hwpf/include/plat/plat_target.H $ */ -/* */ -/* OpenPOWER sbe Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2015,2017 */ -/* [+] International Business Machines Corp. */ -/* */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ -/* implied. See the License for the specific language governing */ -/* permissions and limitations under the License. */ -/* */ -/* IBM_PROLOG_END_TAG */ -/** - * @file plat_target.H - * @brief platform definitions for fapi2 targets - */ - -#ifndef __FAPI2_PLAT_TARGET__ -#define __FAPI2_PLAT_TARGET__ - -#include -#include -#include -#include -#include -#include - -static const uint8_t CORES_PER_QUAD = 4; -static const uint8_t EX_PER_QUAD = 2; -static const uint8_t CORES_PER_EX = 2; -static const uint8_t N2_CHIPLET = 4; -static const uint8_t N3_CHIPLET = 5; -static const uint8_t MCS_PER_MCBIST = 2; -static const uint8_t PCI0_CHIPLET = 0x0D; - -// -// Define what a platform handle looks like. For Hostboot, -// for example, this might be a void*. For the SBE, this -// will be a uint32_t ... -// -namespace fapi2 -{ - typedef enum plat_target_type - { - PPE_TARGET_TYPE_NONE = 0x00, - PPE_TARGET_TYPE_PROC_CHIP = 0x01, - PPE_TARGET_TYPE_MCS = 0x02, - PPE_TARGET_TYPE_CORE = 0x04, - PPE_TARGET_TYPE_EQ = 0x08, - PPE_TARGET_TYPE_EX = 0x10, - PPE_TARGET_TYPE_PERV = 0x20, - PPE_TARGET_TYPE_MCBIST = 0x40, - PPE_TARGET_TYPE_SYSTEM = 0x80, - PPE_TARGET_TYPE_PHB = 0x100, - PPE_TARGET_TYPE_ALL = 0xFFF, - } plat_target_type_t; - - typedef union plat_target_handle { - uint32_t value; - struct { -#ifdef _BIG_ENDIAN - uint32_t chiplet_num : 8; - uint32_t type_target_num : 8; - uint32_t present : 1; - uint32_t functional : 1; - uint32_t is_multicast : 1; - uint32_t valid : 1; - uint32_t type : 12; -#else - uint32_t type : 12; - uint32_t valid : 1; - uint32_t is_multicast : 1; - uint32_t functional : 1; - uint32_t present : 1; - uint32_t type_target_num : 8; - uint32_t chiplet_num : 8; -#endif - } fields; - /// - /// @brief Plat target handle constructor - /// - /// @param i_value Value to instantiate handle with - /// - explicit plat_target_handle(uint32_t i_value = 0):value(i_value) {} - - /// - /// @brief Get the fapi2::TargetType for this target - /// - /// @par Converts the internal PPE type for this target to fapi2 enum - /// - /// @return The fapi2::TargetType for this target - /// - TargetType getFapiTargetType() const; - - /// - /// @brief Get the scom address overlay for this target - /// - /// @return Address overlay - /// - uint32_t getAddressOverlay() const - { - return (value & 0xFF000000); - } - - /// - /// @brief Get the plat target type - /// - /// @return The plat target type as a fapi2::TargetType - /// - TargetType getTargetType() const - { - return static_cast(fields.type); - } - - /// - /// @brief Get the instance number for this target - /// - /// @return The instance number for this target - /// - uint32_t getTargetInstance() const - { - return fields.type_target_num; - } - - /// - /// @brief Returns whether this target is functional - /// - /// @return true if Target is functional - /// - bool getFunctional() const - { - return fields.functional; - } - - /// - /// @brief Set functional state of the Target - /// - /// @param [in] i_state Functional state to set - /// - void setFunctional(const bool &i_state) - { - fields.functional = i_state; - } - - /// - /// @brief Returns whether this target is present - /// - /// @return true if Target is present - /// - bool getPresent() const - { - return fields.present; - } - - /// - /// @brief Set Target as present - /// - void setPresent() - { - fields.present = true; - } - - /// - /// @brief Get this target's parent - /// - /// @param [in] The fapi2 type of the requested parent - /// @return Plat target handle to the parent target - /// - plat_target_handle getParent(const TargetType i_parentType) const; - - /// - /// @brief Get this target's children - /// - /// @param [in] i_parentType fapi2 type of the parent - /// @param [in] i_childType fapi2 type of the child - /// @param [in] i_platType Plat type of the parent - /// @param [in] i_state Required state of the children - /// @param [out] o_children A vector of child target handles - /// - void getChildren(const TargetType i_parentType, - const TargetType i_childType, - const plat_target_type_t i_platType, - const TargetState i_state, - std::vector &o_children) const; - - /// - /// @brief Get proc chip target's children - filtered - /// - /// @param [in] i_filter Target filter - /// @param [in] i_state Required state of the children - /// @param [out] o_children A vector of child target handles - /// - void getChildren(const TargetFilter i_filter, - const TargetState i_state, - std::vector& o_children) const; - - /// - /// @brief Gets the plat target handle as a uint32 - /// - /// @return Plat target handle as a uint32_t - /// - operator uint32_t() const {return value;} - } plat_target_handle_t; - - typedef plat_target_handle_t plat_target_argument_t; - - template - plat_target_handle_t createPlatTargetHandle(const uint32_t i_plat_argument) - { - static_assert((MULTICAST != true) || (K == TARGET_TYPE_PROC_CHIP), - "Only PROC_CHIP types can be multicast"); - plat_target_handle_t l_handle; - - if(MULTICAST == true) - { - // Simply set the is multicast flag - l_handle.fields.is_multicast = 1; - } - else if(K & TARGET_TYPE_PROC_CHIP) - { - l_handle.fields.chiplet_num = 0; - l_handle.fields.type = PPE_TARGET_TYPE_PROC_CHIP; - l_handle.fields.type_target_num = 0; - } - else if(K & TARGET_TYPE_PERV) - { - l_handle.fields.chiplet_num = i_plat_argument + NEST_GROUP1_CHIPLET_OFFSET; - l_handle.fields.type = PPE_TARGET_TYPE_PERV; - l_handle.fields.type_target_num = i_plat_argument; - } - else if(K & TARGET_TYPE_CORE) - { - l_handle.fields.chiplet_num = i_plat_argument + CORE_CHIPLET_OFFSET; - l_handle.fields.type = PPE_TARGET_TYPE_CORE | PPE_TARGET_TYPE_PERV; - l_handle.fields.type_target_num = i_plat_argument; - } - else if(K & TARGET_TYPE_EQ) - { - l_handle.fields.chiplet_num = i_plat_argument + EQ_CHIPLET_OFFSET; - l_handle.fields.type = PPE_TARGET_TYPE_EQ | PPE_TARGET_TYPE_PERV; - l_handle.fields.type_target_num = i_plat_argument; - } - else if(K & TARGET_TYPE_EX) - { - l_handle.fields.chiplet_num = (i_plat_argument / 2) + EX_CHIPLET_OFFSET; - l_handle.fields.type = PPE_TARGET_TYPE_EX; - l_handle.fields.type_target_num = i_plat_argument; - } - else if(K & TARGET_TYPE_MCBIST) - { - l_handle.fields.chiplet_num = i_plat_argument + MCBIST_CHIPLET_OFFSET; - l_handle.fields.type = PPE_TARGET_TYPE_MCBIST | PPE_TARGET_TYPE_PERV; - l_handle.fields.type_target_num = i_plat_argument; - } - else if(K & TARGET_TYPE_MCS) - { - l_handle.fields.chiplet_num = N3_CHIPLET - (MCS_PER_MCBIST * (i_plat_argument / MCS_PER_MCBIST)); - l_handle.fields.type = PPE_TARGET_TYPE_MCS; - l_handle.fields.type_target_num = i_plat_argument; - } - else if(K & TARGET_TYPE_PHB) - { - l_handle.fields.chiplet_num = (0 == i_plat_argument) ? PCI0_CHIPLET : - (((i_plat_argument / 3) + 1) + PCI0_CHIPLET); - l_handle.fields.type = PPE_TARGET_TYPE_PHB; - l_handle.fields.type_target_num = i_plat_argument; - } - else if(K == TARGET_TYPE_ALL) - { - l_handle.fields.chiplet_num = i_plat_argument; - l_handle.fields.type = PPE_TARGET_TYPE_ALL; - } - - l_handle.fields.valid = 1; - return l_handle; - } - -}; - -#endif diff --git a/src/hwpf/include/plat/plat_target_definitions.H b/src/hwpf/include/plat/plat_target_definitions.H deleted file mode 100644 index 24991ebb..00000000 --- a/src/hwpf/include/plat/plat_target_definitions.H +++ /dev/null @@ -1,112 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/hwpf/include/plat/plat_target_definitions.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 plat_ppe_target.H - * @brief Definitions for fapi2 PPE targets - */ - -#ifndef __FAPI2_PPE_TARGET__ -#define __FAPI2_PPE_TARGET__ - -#define TARGET_CHIP(_name, _index) \ - fapi2::Target _name((uint64_t)_index); - -#define TARGET_CHIP_PERV(_name, _index) \ - fapi2::Target _name((uint64_t)_index); - -#define TARGET_EQ(_name, _index) \ - fapi2::Target _name((uint64_t)_index); - -#define TARGET_CORE(_name, _index) \ - fapi2::Target _name((uint64_t)_index); - -#define TARGET_EX(_name, _index) \ - fapi2::Target _name((uint64_t)_index); - -namespace fapi2 -{ - - TARGET_CHIP (chip_target, 0); - TARGET_CHIP_PERV (perv_target, 1); - TARGET_CHIP_PERV (n0_target, 2); - TARGET_CHIP_PERV (n1_target, 3); - TARGET_CHIP_PERV (n2_target, 4); - TARGET_CHIP_PERV (n3_target, 5); - TARGET_CHIP_PERV (xb_target, 6); - TARGET_CHIP_PERV (mc0_target, 7); - TARGET_CHIP_PERV (mc1_target, 8); - TARGET_CHIP_PERV (ob0_target, 9); - TARGET_CHIP_PERV (ob1_target, 10); - TARGET_CHIP_PERV (ob2_target, 11); - TARGET_CHIP_PERV (ob3_target, 12); - TARGET_CHIP_PERV (pci0_target, 13); - TARGET_CHIP_PERV (pci1_target, 14); - TARGET_CHIP_PERV (pci2_target, 15); - TARGET_EQ (eq0_target, 0); - TARGET_EQ (eq1_target, 1); - TARGET_EQ (eq2_target, 2); - TARGET_EQ (eq3_target, 3); - TARGET_EQ (eq4_target, 4); - TARGET_EQ (eq5_target, 5); - TARGET_EX (ex0_target, 0); - TARGET_EX (ex1_target, 1); - TARGET_EX (ex2_target, 2); - TARGET_EX (ex3_target, 3); - TARGET_EX (ex4_target, 4); - TARGET_EX (ex5_target, 5); - TARGET_EX (ex6_target, 6); - TARGET_EX (ex7_target, 7); - TARGET_EX (ex8_target, 8); - TARGET_EX (ex9_target, 9); - TARGET_EX (ex10_target, 10); - TARGET_EX (ex11_target, 11); - TARGET_CORE (core0_target, 0); - TARGET_CORE (core1_target, 1); - TARGET_CORE (core2_target, 2); - TARGET_CORE (core3_target, 3); - TARGET_CORE (core4_target, 4); - TARGET_CORE (core5_target, 5); - TARGET_CORE (core6_target, 6); - TARGET_CORE (core7_target, 7); - TARGET_CORE (core8_target, 8); - TARGET_CORE (core9_target, 9); - TARGET_CORE (core10_target,10); - TARGET_CORE (core11_target,11); - TARGET_CORE (core12_target,12); - TARGET_CORE (core13_target,13); - TARGET_CORE (core14_target,14); - TARGET_CORE (core15_target,15); - TARGET_CORE (core16_target,16); - TARGET_CORE (core17_target,17); - TARGET_CORE (core18_target,18); - TARGET_CORE (core19_target,19); - TARGET_CORE (core20_target,20); - TARGET_CORE (core21_target,21); - TARGET_CORE (core22_target,22); - TARGET_CORE (core23_target,23); - -}; // fapi2 namespace - -#endif // __FAPI2_PPE_TARGET__ diff --git a/src/hwpf/include/plat/plat_target_filter.H b/src/hwpf/include/plat/plat_target_filter.H deleted file mode 100644 index 0e19fa71..00000000 --- a/src/hwpf/include/plat/plat_target_filter.H +++ /dev/null @@ -1,90 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/hwpf/include/plat/plat_target_filter.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 */ -#ifndef __FAPI2_PLAT_TARGET_FILTER__ -#define __FAPI2_PLAT_TARGET_FILTER__ - -#include - -// -// Define TargetFilter enum values for the platform -// -namespace fapi2 -{ -namespace PlatTargetFilter -{ -// These values must contain only 1 bit 'on' so that they can be ORed -// together as composite filters - -constexpr uint64_t PLAT_TARGET_FILTER_TP = 0x8000000000000000; // Pervasive 1 -constexpr uint64_t PLAT_TARGET_FILTER_NEST_NORTH = 0x4000000000000000; // Pervasive 2 -constexpr uint64_t PLAT_TARGET_FILTER_NEST_EAST = 0x2000000000000000; // Pervasive 3 -constexpr uint64_t PLAT_TARGET_FILTER_NEST_SOUTH = 0x1000000000000000; // Pervasive 4 -constexpr uint64_t PLAT_TARGET_FILTER_NEST_WEST = 0x0800000000000000; // Pervasive 5 -constexpr uint64_t PLAT_TARGET_FILTER_XBUS = 0x0400000000000000; // Pervasive 6 -constexpr uint64_t PLAT_TARGET_FILTER_MC_WEST = 0x0200000000000000; // Pervasive 7 -constexpr uint64_t PLAT_TARGET_FILTER_MC_EAST = 0x0100000000000000; // Pervasive 8 -constexpr uint64_t PLAT_TARGET_FILTER_OBUS0 = 0x0080000000000000; // Pervasive 9 -constexpr uint64_t PLAT_TARGET_FILTER_OBUS1 = 0x0040000000000000; // Pervasive 10 -constexpr uint64_t PLAT_TARGET_FILTER_OBUS2 = 0x0020000000000000; // Pervasive 11 -constexpr uint64_t PLAT_TARGET_FILTER_OBUS3 = 0x0010000000000000; // Pervasive 12 -constexpr uint64_t PLAT_TARGET_FILTER_PCI0 = 0x0008000000000000; // Pervasive 13 -constexpr uint64_t PLAT_TARGET_FILTER_PCI1 = 0x0004000000000000; // Pervasive 14 -constexpr uint64_t PLAT_TARGET_FILTER_PCI2 = 0x0002000000000000; // Pervasive 15 -constexpr uint64_t PLAT_TARGET_FILTER_CACHE0 = 0x0001000000000000; // Pervasive 16 -constexpr uint64_t PLAT_TARGET_FILTER_CACHE1 = 0x0000800000000000; // Pervasive 17 -constexpr uint64_t PLAT_TARGET_FILTER_CACHE2 = 0x0000400000000000; // Pervasive 18 -constexpr uint64_t PLAT_TARGET_FILTER_CACHE3 = 0x0000200000000000; // Pervasive 19 -constexpr uint64_t PLAT_TARGET_FILTER_CACHE4 = 0x0000100000000000; // Pervasive 20 -constexpr uint64_t PLAT_TARGET_FILTER_CACHE5 = 0x0000080000000000; // Pervasive 21 -constexpr uint64_t PLAT_TARGET_FILTER_CORE0 = 0x0000040000000000; // Pervasive 32 -constexpr uint64_t PLAT_TARGET_FILTER_CORE1 = 0x0000020000000000; // Pervasive 33 -constexpr uint64_t PLAT_TARGET_FILTER_CORE2 = 0x0000010000000000; // Pervasive 34 -constexpr uint64_t PLAT_TARGET_FILTER_CORE3 = 0x0000008000000000; // Pervasive 35 -constexpr uint64_t PLAT_TARGET_FILTER_CORE4 = 0x0000004000000000; // Pervasive 36 -constexpr uint64_t PLAT_TARGET_FILTER_CORE5 = 0x0000002000000000; // Pervasive 37 -constexpr uint64_t PLAT_TARGET_FILTER_CORE6 = 0x0000001000000000; // Pervasive 38 -constexpr uint64_t PLAT_TARGET_FILTER_CORE7 = 0x0000000800000000; // Pervasive 39 -constexpr uint64_t PLAT_TARGET_FILTER_CORE8 = 0x0000000400000000; // Pervasive 40 -constexpr uint64_t PLAT_TARGET_FILTER_CORE9 = 0x0000000200000000; // Pervasive 41 -constexpr uint64_t PLAT_TARGET_FILTER_CORE10 = 0x0000000100000000; // Pervasive 42 -constexpr uint64_t PLAT_TARGET_FILTER_CORE11 = 0x0000000080000000; // Pervasive 43 -constexpr uint64_t PLAT_TARGET_FILTER_CORE12 = 0x0000000040000000; // Pervasive 44 -constexpr uint64_t PLAT_TARGET_FILTER_CORE13 = 0x0000000020000000; // Pervasive 45 -constexpr uint64_t PLAT_TARGET_FILTER_CORE14 = 0x0000000010000000; // Pervasive 46 -constexpr uint64_t PLAT_TARGET_FILTER_CORE15 = 0x0000000008000000; // Pervasive 47 -constexpr uint64_t PLAT_TARGET_FILTER_CORE16 = 0x0000000004000000; // Pervasive 48 -constexpr uint64_t PLAT_TARGET_FILTER_CORE17 = 0x0000000002000000; // Pervasive 49 -constexpr uint64_t PLAT_TARGET_FILTER_CORE18 = 0x0000000001000000; // Pervasive 50 -constexpr uint64_t PLAT_TARGET_FILTER_CORE19 = 0x0000000000800000; // Pervasive 51 -constexpr uint64_t PLAT_TARGET_FILTER_CORE20 = 0x0000000000400000; // Pervasive 52 -constexpr uint64_t PLAT_TARGET_FILTER_CORE21 = 0x0000000000200000; // Pervasive 53 -constexpr uint64_t PLAT_TARGET_FILTER_CORE22 = 0x0000000000100000; // Pervasive 54 -constexpr uint64_t PLAT_TARGET_FILTER_CORE23 = 0x0000000000080000; // Pervasive 55 - -} // namespace PlatTargetFilter - -} // namespace fapi2 - -#endif diff --git a/src/hwpf/include/plat/plat_target_parms.H b/src/hwpf/include/plat/plat_target_parms.H deleted file mode 100644 index 79d9edf0..00000000 --- a/src/hwpf/include/plat/plat_target_parms.H +++ /dev/null @@ -1,101 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/hwpf/include/plat/plat_target_parms.H $ */ -/* */ -/* OpenPOWER sbe Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2012,2017 */ -/* [+] International Business Machines Corp. */ -/* */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ -/* implied. See the License for the specific language governing */ -/* permissions and limitations under the License. */ -/* */ -/* IBM_PROLOG_END_TAG */ -/** - * @file plat_ppe_target.H - * @brief Definitions for fapi2 PPE targets - */ - -#ifndef __FAPI2_PPE_TARGET_PARMS__ -#define __FAPI2_PPE_TARGET_PARMS__ - -#include "fapi_sbe_common.H" - - -CONST_UINT32_T(CHIP_TARGET_OFFSET, 0); -CONST_UINT32_T(CHIP_TARGET_COUNT , 1); - -// Nest targets - Group 1 -CONST_UINT32_T(NEST_GROUP1_TARGET_OFFSET, CHIP_TARGET_OFFSET + CHIP_TARGET_COUNT); -CONST_UINT32_T(NEST_GROUP1_CHIPLET_OFFSET, 0x1); -CONST_UINT32_T(NEST_GROUP1_TARGET_COUNT, 6); - -// MCBIST targets -CONST_UINT32_T(MCBIST_TARGET_OFFSET, NEST_GROUP1_TARGET_OFFSET + NEST_GROUP1_TARGET_COUNT); -CONST_UINT32_T(MCBIST_CHIPLET_OFFSET, 0x7); -CONST_UINT32_T(MCBIST_TARGET_COUNT, 2); - -// Nest targets - Group 2 -CONST_UINT32_T(NEST_GROUP2_TARGET_OFFSET, MCBIST_TARGET_OFFSET + MCBIST_TARGET_COUNT); -CONST_UINT32_T(NEST_GROUP2_TARGET_COUNT, 7); -CONST_UINT32_T(NEST_GROUP2_CHIPLET_OFFSET, 0x9); - -// Cache Targets -CONST_UINT32_T(EQ_TARGET_OFFSET, NEST_GROUP2_TARGET_OFFSET + NEST_GROUP2_TARGET_COUNT); -CONST_UINT32_T(EQ_CHIPLET_OFFSET, 0x10); -CONST_UINT32_T(EQ_TARGET_COUNT, 6); - -// Core Targets -CONST_UINT32_T(CORE_TARGET_OFFSET, EQ_TARGET_OFFSET + EQ_TARGET_COUNT); -CONST_UINT32_T(CORE_CHIPLET_OFFSET, 0x20); -CONST_UINT32_T(CORE_TARGET_COUNT, 24); - -// Ex Targets -CONST_UINT32_T(EX_TARGET_OFFSET, CORE_TARGET_OFFSET + CORE_TARGET_COUNT); -CONST_UINT32_T(EX_CHIPLET_OFFSET, 0x10); -CONST_UINT32_T(EX_TARGET_COUNT, 12); - -// MCS Targets -CONST_UINT32_T(MCS_TARGET_OFFSET, EX_TARGET_OFFSET + EX_TARGET_COUNT); -CONST_UINT32_T(MCS_TARGET_COUNT, 4); - -// PHB Targets -CONST_UINT32_T(PHB_TARGET_OFFSET, MCS_TARGET_OFFSET + MCS_TARGET_COUNT); -CONST_UINT32_T(PHB_TARGET_COUNT, 6); - -// System Target -CONST_UINT32_T(SYSTEM_TARGET_OFFSET, PHB_TARGET_OFFSET + PHB_TARGET_COUNT); -CONST_UINT32_T(SYSTEM_TARGET_COUNT, 1); - -CONST_UINT32_T(MCAST_TARGET_OFFSET, SYSTEM_TARGET_OFFSET + SYSTEM_TARGET_COUNT); -CONST_UINT32_T(MCAST_CHIPLET_OFFSET, 4); -CONST_UINT32_T(MCAST_TARGET_COUNT, 3); // PPE only needs multicast groups 4-6 - -// Total number of pervasive targets (Both NEST groups + EQs + COREs +MCBISTs) -CONST_UINT32_T(PERV_TARGET_COUNT, NEST_GROUP1_TARGET_COUNT + NEST_GROUP2_TARGET_COUNT + - MCBIST_TARGET_COUNT + EQ_TARGET_COUNT + CORE_TARGET_COUNT); - -// Total Target Count -CONST_UINT32_T(TARGET_COUNT, CHIP_TARGET_COUNT + - PERV_TARGET_COUNT + - EX_TARGET_COUNT + - MCS_TARGET_COUNT + - PHB_TARGET_COUNT + - SYSTEM_TARGET_COUNT + - MCAST_TARGET_COUNT); - -// Maximum possible Pervasive chiplets -CONST_UINT32_T(MAX_PERV_CHIPLETS, 64); - -#endif // __FAPI2_PPE_TARGET_PARMS__ diff --git a/src/hwpf/include/plat/plat_target_utils.H b/src/hwpf/include/plat/plat_target_utils.H deleted file mode 100644 index 9d3e520f..00000000 --- a/src/hwpf/include/plat/plat_target_utils.H +++ /dev/null @@ -1,89 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/hwpf/include/plat/plat_target_utils.H $ */ -/* */ -/* OpenPOWER sbe Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2012,2017 */ -/* [+] International Business Machines Corp. */ -/* */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ -/* implied. See the License for the specific language governing */ -/* permissions and limitations under the License. */ -/* */ -/* IBM_PROLOG_END_TAG */ -/** - * @file plat_target_util.H - * @brief platform utility definitions for fapi2 targets - */ - -#ifndef __FAPI2_PLAT_TARGET_UTIL__ -#define __FAPI2_PLAT_TARGET_UTIL__ - -#include - -#pragma pack(8) //Start of packing to 8byte boundary - typedef struct { - fapi2attr::SystemAttributes_t G_system_attrs; - fapi2attr::ProcChipAttributes_t G_proc_chip_attrs; - fapi2attr::PervAttributes_t G_perv_attrs; - fapi2attr::CoreAttributes_t G_core_attrs; - fapi2attr::EXAttributes_t G_ex_attrs; - fapi2attr::EQAttributes_t G_eq_attrs; - } G_sbe_attrs_t; -#pragma pack()//End of packing to 8byte boundary - -// -// Platform Utility functions.. -// -namespace fapi2 -{ - /// @brief Function to initialize the G_targets vector based on partial good - /// attributes - ReturnCode plat_TargetsInit(); - - /// @brief Function to apply any gard records set (via - // ATTR_EQ_GARD/ATTR_EC_GARD) to mark corresponding targets non functional - ReturnCode plat_ApplyGards(); - - /// @brief Function to initialize the G_targets vector based on partial good - /// attributes - Target plat_getChipTarget(); - - /// @brief Function to return a platform target handle, given the chiplet - // number and the fapi2 Target type - // @tparam K The fapi2 TargetType - // @param i_chipletNumber The chiplet number of the target - // @return Platform handle - // @note The caller can use the platform handle to construct a Target of - // it's choice. Ex: - // fapi2::Target - // l_core(plat_getTargetHandleByChipletNumber(0x20); - template - plat_target_handle_t plat_getTargetHandleByChipletNumber( - const uint8_t i_chipletNumber); - - /// @brief Function to return a platform target handle, given the target - /// instance number and the fapi2 Target type - // @tparam K The fapi2 TargetType - // @param i_targetNum The instance number for the target - // @return Platform handle - // @note The caller can use the platform handle to construct a Target of - // it's choice. Ex: - // fapi2::Target - // l_ex(plat_getTargetHandleByInstance(0); - template - plat_target_handle_t plat_getTargetHandleByInstance( - const uint8_t i_targetNum); -} -#endif diff --git a/src/hwpf/include/plat/plat_trace.H b/src/hwpf/include/plat/plat_trace.H deleted file mode 100644 index fcc87899..00000000 --- a/src/hwpf/include/plat/plat_trace.H +++ /dev/null @@ -1,114 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/hwpf/include/plat/plat_trace.H $ */ -/* */ -/* OpenPOWER sbe Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2011,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 plat_trace.H - * @brief Defines the FAPI2 trace macros. - * - * Note that platform code must provide the implementation. - * - * FAPI has provided a default implementation. Platform code must - * provide an alternate implementation if needed. - */ - -#ifndef FAPI2_PLATTRACE_H_ -#define FAPI2_PLATTRACE_H_ - -#include - -// @todo update these headers with extern "C" in a future commit -// or not and leave this just as it is. -extern "C" -{ -#include "pk.h" -#include -#include "trac_interface.h" -} - -// Why not a #define, why is this in the fapi2 namespace? -// To prevent problems with Cronus and the fapi1 definitions. -namespace fapi2 -{ - static const uint32_t MAX_ECMD_STRING_LEN = 64; -}; - -// Information traces (go into fast trace buffer that can wrap often) -#define FAPI_TRACE(_id_, _fmt_, _args_...) \ - PK_TRACE(_fmt_, ##_args_); - - -/* The following is a desirous trace entry but the second line has a - compilation issue that is unresolved - -#define FAPI_TRACE(_id_, _fmt_, _args_...) \ - PK_TRACE("%s: %s:%d ", _id_, __FUNCTION__, __LINE__); \ - PK_TRACE(_fmt_, ##_args_); -*/ -// FAPI_TRACE_LEVEL controls what traces are included in the code build -// 0 == No tracing -// 1 == ERR traces only -// 2 == ERR and IMP only -// 3 == ERR, IMP and INF only. This is the default in Makefile -// > 4 == All traces (ERR, IMP, INF, DBG, SCAN, MFG) -#if (FAPI_TRACE_LEVEL >= 3) -#define FAPI_INF(_fmt_, _args_...) FAPI_TRACE("inf", _fmt_, ##_args_) -#else -#define FAPI_INF(_fmt_, _args_...) -#endif - -// Important traces (go into slow trace buffer that should not wrap often) -#if (FAPI_TRACE_LEVEL >= 2) -#define FAPI_IMP(_fmt_, _args_...) FAPI_TRACE("imp", _fmt_, ##_args_) -#else -#define FAPI_IMP(_fmt_, _args_...) -#endif - -// Error traces (go into slow trace buffer that should not wrap often) -#if (FAPI_TRACE_LEVEL >= 1) -#define FAPI_ERR(_fmt_, _args_...) FAPI_TRACE("err", _fmt_, ##_args_) -#else -#define FAPI_ERR(_fmt_, _args_...) -#endif - -// Debug traces (go into fast trace buffer that can wrap often) -#if (FAPI_TRACE_LEVEL >= 4) -#define FAPI_DBG(_fmt_, _args_...) FAPI_TRACE("dbg", _fmt_, ##_args_) -#else -#define FAPI_DBG(_fmt_, _args_...) -#endif - -// Scan traces -#if (FAPI_TRACE_LEVEL >= 4) -#define FAPI_SCAN(_fmt_, _args_...) FAPI_TRACE("scan", _fmt_, ##_args_) -#else -#define FAPI_SCAN(_fmt_, _args_...) -#endif - -#if (FAPI_TRACE_LEVEL >= 4) -#define FAPI_MFG(_fmt_, _args_...) FAPI_TRACE("mfg", _fmt_, ##_args_) -#else -#define FAPI_MFG(_fmt_, _args_...) -#endif - -#endif // FAPI2_PLATTRACE_H_ diff --git a/src/hwpf/include/plat/plat_utils.H b/src/hwpf/include/plat/plat_utils.H deleted file mode 100644 index eadee6aa..00000000 --- a/src/hwpf/include/plat/plat_utils.H +++ /dev/null @@ -1,65 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/hwpf/include/plat/plat_utils.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 */ -#ifndef _PLAT_UTILS_H_ -#define _PLAT_UTILS_H_ - -#ifdef __ASSEMBLER__ - -#ifndef ULL -#define ULL(x) x -#endif - -#else - -#ifndef ULL -#define ULL(x) x##ull - -#endif - -#endif // __ASSEMBLER - -/// Create a multi-bit mask of \a n bits starting at bit \a b -#ifndef BITS - #define BITS(b, n) ((ULL(0xffffffffffffffff) << (64 - (n))) >> (b)) -#endif - -/// Create a single bit mask at bit \a b -#ifndef BIT - #define BIT(b) BITS((b), 1) -#endif - -#ifdef _BIG_ENDIAN - -#define revle16(x) x -#define revle32(x) x -#define revle64(x) x - -#else - -uint16_t revle16(uint16_t i_x); -uint32_t revle32(uint32_t i_x); -uint64_t revle64(uint64_t i_x); - -#endif -#endif //_PLAT_UTILS_H_ diff --git a/src/hwpf/include/plat/target.H b/src/hwpf/include/plat/target.H deleted file mode 100644 index 3bdfc4dc..00000000 --- a/src/hwpf/include/plat/target.H +++ /dev/null @@ -1,410 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/hwpf/include/plat/target.H $ */ -/* */ -/* OpenPOWER sbe Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2012,2017 */ -/* [+] International Business Machines Corp. */ -/* */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ -/* implied. See the License for the specific language governing */ -/* permissions and limitations under the License. */ -/* */ -/* IBM_PROLOG_END_TAG */ -/** - * @file target.H - * @brief platform specializations for fapi2 targets - */ - -#ifndef __FAPI2_TARGET__ -#define __FAPI2_TARGET__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -extern "C" -{ - extern std::vector G_vec_targets; -} - -struct ScomAddr -{ - ScomAddr(uint32_t i_addr) : iv_addr(i_addr) - { - } - - operator uint32_t() - { - return iv_addr; - } - - union - { - struct - { - uint32_t iv_unused : 1; - uint32_t iv_multicast : 1; - uint32_t iv_chiplet : 6; - uint32_t iv_pibMaster : 4; - uint32_t iv_port : 4; - uint32_t iv_unused2 : 2; - uint32_t iv_ring : 4; - uint32_t iv_satId : 4; - uint32_t iv_satOffset : 6; - }; - uint32_t iv_addr; - }; -}; - - -namespace fapi2 -{ - - template - constexpr plat_target_type_t fapiTargetTypeToPlatTargetType() - { - return PPE_TARGET_TYPE_NONE; - } - - template<> - constexpr plat_target_type_t fapiTargetTypeToPlatTargetType() - { - return PPE_TARGET_TYPE_PROC_CHIP; - } - - template<> - constexpr plat_target_type_t fapiTargetTypeToPlatTargetType() - { - return PPE_TARGET_TYPE_EQ; - } - - template<> - constexpr plat_target_type_t fapiTargetTypeToPlatTargetType() - { - return PPE_TARGET_TYPE_CORE; - } - - template<> - constexpr plat_target_type_t fapiTargetTypeToPlatTargetType() - { - return PPE_TARGET_TYPE_EX; - } - - template<> - constexpr plat_target_type_t fapiTargetTypeToPlatTargetType() - { - return PPE_TARGET_TYPE_MCS; - } - - template<> - constexpr plat_target_type_t fapiTargetTypeToPlatTargetType() - { - return PPE_TARGET_TYPE_PHB; - } - - template<> - constexpr plat_target_type_t fapiTargetTypeToPlatTargetType() - { - return PPE_TARGET_TYPE_MCBIST; - } - - template<> - constexpr plat_target_type_t fapiTargetTypeToPlatTargetType() - { - return PPE_TARGET_TYPE_PERV; - } - - /// - /// @brief Assignment Operator. - /// @param[in] i_right Reference to Target to assign from. - /// @return Reference to 'this' Target - /// - template - Target& Target::operator=(const Target& i_right) - { - this->iv_handle.value = i_right.iv_handle.value; - return *this; - } - /// - /// @brief Equality Comparison Operator - /// @param[in] i_right Reference to Target to compare. - /// @return bool. True if equal. - /// @note Platforms need to define this so that the physical - /// targets are determined to be equivilent rather than just the handles - /// - template - bool Target::operator==(const Target& i_right) const - { - if (this->iv_handle.value == i_right.iv_handle.value) - return true; - else - return false; - } - - /// - /// @brief Inquality Comparison Operator - /// @param[in] i_right Reference to Target to compare. - /// @return bool. True if not equal. - /// @note Platforms need to define this so that the physical - /// targets are determined to be equivilent rather than just the handles - /// - template - bool Target::operator!=(const Target& i_right) const - { - if (this->iv_handle.value != i_right.iv_handle.value) - return true; - else - return false; - } - - /// - /// @brief Get this target's immediate parent - /// @tparam T The type of the parent - /// @return Target a target representing the parent - /// - template - template - inline Target Target::getParent(void) const - { - constexpr TargetType TARGET_TYPE_PROC_CHILDREN = - TARGET_TYPE_EQ | TARGET_TYPE_PERV | TARGET_TYPE_EX | - TARGET_TYPE_MCBIST | TARGET_TYPE_CORE | - TARGET_TYPE_MCS | TARGET_TYPE_PROC_CHIP | TARGET_TYPE_PHB; - - static_assert((( - ((K & TARGET_TYPE_PROC_CHILDREN) != TARGET_TYPE_NONE) || - (K == TARGET_TYPE_ALL)) && - ((T == TARGET_TYPE_EQ) || - (T == TARGET_TYPE_EX) || - (T == TARGET_TYPE_PROC_CHIP) || - (T == TARGET_TYPE_PERV))), - "Invalid parent/child target type passed"); - - static_assert(!((K == TARGET_TYPE_EQ) && - (T != TARGET_TYPE_PERV) && - (T != TARGET_TYPE_PROC_CHIP)), - "Invalid parent for EQ target, must be PERV or " - "PROC_CHIP"); - - static_assert(!((T == TARGET_TYPE_PROC_CHIP) && - ((K & TARGET_TYPE_PROC_CHILDREN) == TARGET_TYPE_NONE)), - "Parent proc chip invalid for this target type"); - - static_assert(!((K == TARGET_TYPE_MCBIST) && - (T != TARGET_TYPE_PERV) && - (T != TARGET_TYPE_PROC_CHIP)), - "Invalid parent for MCBIST target, must be PERV or " - "PROC_CHIP"); - - static_assert(!((K == TARGET_TYPE_CORE) && - (T != TARGET_TYPE_PERV) && - (T != TARGET_TYPE_PROC_CHIP) && - (T != TARGET_TYPE_EQ) && - (T != TARGET_TYPE_EX)), - "Invalid parent for CORE target, must be PERV or " - "PROC_CHIP or EQ or EX"); - - static_assert(!((K == TARGET_TYPE_PERV) && - (T != TARGET_TYPE_PERV) && - (T != TARGET_TYPE_PROC_CHIP)), - "Invalid parent for PERV target, must be PERV or " - "PROC_CHIP"); - - static_assert(!((K == TARGET_TYPE_EX) && - (T != TARGET_TYPE_PROC_CHIP) && - (T != TARGET_TYPE_EQ)), - "Invalid parent for EX target, must be PERV or " - "PROC_CHIP or EQ"); - - if(TARGET_TYPE_PERV == T) // EQ/EC/MCBIST/PERV ===> PERV - { - return static_cast(this->iv_handle); - } - if(TARGET_TYPE_PROC_CHIP == T) // EQ/EC/EX/MCBIST/PERV ===> PROC - { - return static_cast(G_vec_targets[CHIP_TARGET_OFFSET]); - } - if((TARGET_TYPE_EQ == T) && (TARGET_TYPE_CORE == K)) // EC ===> EQ - { - return static_cast(G_vec_targets[(static_cast(get()).getTargetInstance() / CORES_PER_QUAD) + EQ_TARGET_OFFSET]); - } - if((TARGET_TYPE_EQ == T) && (TARGET_TYPE_EX == K)) // EX ===> EQ - { - return static_cast(G_vec_targets[(static_cast(get()).getTargetInstance() / EX_PER_QUAD) + EQ_TARGET_OFFSET]); - } - if(TARGET_TYPE_EX == T) // EC ===> EX - { - return static_cast(G_vec_targets[(static_cast(get()).getTargetInstance() / CORES_PER_EX) + EX_TARGET_OFFSET]); - } - } - - /// - /// @brief Get this target's immediate parent - specialization for compound - // target (PROC_CHIP | CORE | EX) - /// @tparam T The type of the parent - /// @return Target a target representing the parent - /// - template<> - template - Target - Target::getParent(void) const - { - static_assert(((T == TARGET_TYPE_PROC_CHIP) || (T == TARGET_TYPE_EQ)), - "Wrong parent target type"); - return static_cast(get()).getParent(T); - } - - /// @brief Get this target's children - handles EQ/EX/EC conversions - /// @tparam K The type of parent - /// @tparam V The plat target handle type - /// @tparam T The type of child - /// @param[in] i_state The desired TargetState of the children - /// @return std::vector > a vector of present/functional - /// children - /// @warning The children are returned in order, ex child[0] is - /// std::vector[0] - template - template - std::vector> - Target::getChildren(const TargetState i_state) const - { - constexpr TargetType L = static_cast(K & ~(TARGET_TYPE_PROC_CHIP)); - constexpr plat_target_type_t P = fapiTargetTypeToPlatTargetType(); - - static_assert(sizeof(Target) == sizeof(plat_target_handle_t), - "Sizes of plat target and FAPI target must match"); - - static_assert(((L == TARGET_TYPE_EQ) || (L == TARGET_TYPE_EX) || (K == TARGET_TYPE_PROC_CHIP)), - "Invalid parent passed to getChildren"); - // valid children for EQ - // EQ -> CORE - // EQ -> EX - static_assert(!((L == fapi2::TARGET_TYPE_EQ) && - (T != fapi2::TARGET_TYPE_CORE) && - (T != fapi2::TARGET_TYPE_EX)), - "improper child of fapi2::TARGET_TYPE_EQ"); - - // valid children for EX - // EX -> CORE - static_assert(!((L == fapi2::TARGET_TYPE_EX) && - (T != fapi2::TARGET_TYPE_CORE)), - "improper child of fapi2::TARGET_TYPE_EX"); - - - std::vector > l_children; - static_cast(get()).getChildren(K, T, P, i_state, reinterpret_cast&>(l_children)); - return l_children; - } - - // Specialization of getChildren, filtered for the chip target - template - template - std::vector > - Target::getChildren(const TargetFilter i_filter, - const TargetState i_state) const - { - static_assert(sizeof(Target) == sizeof(plat_target_handle_t), - "Sizes of plat target and FAPI target must match"); - - static_assert((K == TARGET_TYPE_PROC_CHIP), "Parent target must be the proc chip"); - static_assert((T == TARGET_TYPE_EQ) || (T == TARGET_TYPE_CORE) - || (T == TARGET_TYPE_PERV) || (T == TARGET_TYPE_MCBIST), - "Child target type must be a pervasive chiplet"); - - std::vector > l_children; - - (static_cast(get())).getChildren(i_filter, i_state, reinterpret_cast&>(l_children)); - - return l_children; - } - - /// - /// @brief Is the target functional? - /// @return true if target is functional, false if non-functional - /// - template - inline bool - Target::isFunctional(void) const - { - return static_cast(get()).getFunctional(); - } - - /// - /// @brief Returns the chiplet number for this Target - /// @return The chiplet number - /// - template - inline uint8_t - Target::getChipletNumber(void) const - { - return static_cast(iv_handle).fields.chiplet_num; - } - - /// - /// @brief Return the string interpretation of this target - /// @tparam T The type of the target - /// @param[in] i_target Target - /// @param[in] i_buffer buffer to write in to - /// @param[in] i_bsize size of the buffer - /// @return void - /// @post The contents of the buffer is replaced with the string - /// representation of the target - /// - template< TargetType T, typename V > - inline void toString(const Target& i_target, char* i_buffer, size_t i_bsize) - { - snprintf(i_buffer, i_bsize, "Target 0x%lx/0x%x", i_target.get(), T); - } - - /// - /// @brief Return the string interpretation of this target - /// @tparam T The type of the target - /// @tparam B The type of the buffer - /// @param[in] A pointer to the Target - /// @param[in] i_buffer buffer to write in to - /// @param[in] i_bsize size of the buffer - /// @return void - /// @post The contents of the buffer is replaced with the string - /// representation of the target - /// - template< TargetType T, typename V > - inline void toString(const Target* i_target, char* i_buffer, size_t i_bsize) - { - snprintf(i_buffer, i_bsize, "Target 0x%lx/0x%x", i_target->get(), T); - } - - /// - /// @brief Get an enumerated target of a specific type - /// @tparam T The type of the target - /// @param[in] Ordinal representing the ordinal number of - /// the desired target - /// @return Target the target requested - /// - template - inline Target getTarget(uint64_t Ordinal) - { - // For testing - return Target(Ordinal); - } -} - -#endif diff --git a/src/hwpf/multicast.H b/src/hwpf/multicast.H new file mode 100644 index 00000000..8ec0c4a7 --- /dev/null +++ b/src/hwpf/multicast.H @@ -0,0 +1,54 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/hwpf/multicast.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2016,2017 */ +/* */ +/* */ +/* 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 */ +#ifndef __FAPI2_MULTICAST__ +#define __FAPI2_MULTICAST__ + +#include + +namespace fapi2 +{ + +template +template +inline void Multicast::updateHandle(V& i_value) +{ + // Update handle only if multicast bit is set in handle, else we leave the + // handle unchanged. This enables the same procedure to work with both + // multicast and unicast targets + if(i_value.fields.is_multicast) + { + // Update the handle to reflect the new multicast type and group + i_value.fields.chiplet_num = (0x40) | (O << 3) | N; + } +} + +template +inline bool Multicast::isMulticast() const +{ + return iv_handle.fields.is_multicast; +} + +} + +#endif diff --git a/src/hwpf/plat_attribute_service.H b/src/hwpf/plat_attribute_service.H new file mode 100644 index 00000000..b33065b0 --- /dev/null +++ b/src/hwpf/plat_attribute_service.H @@ -0,0 +1,1441 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/hwpf/plat_attribute_service.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2015,2017 */ +/* */ +/* */ +/* 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) + +#define PLAT_ATTR_INIT(ID, TARGET, VAL) \ + (fapi2::checkIdType(ID, VAL), \ + ID##_PLAT_INIT(ID, TARGET, 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##TargetType), ID> \ + (ID, PTARGET, VAL) + +/* global set uint8_t 1D array macro */ +#define PLAT_ATTR_SET_UINT8_1D_ARRAY(ID, PTARGET, VAL) \ + _setAttributeArrayShort(ID##TargetType), 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##_TargetType), 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##_TargetType), 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 ); + +#define ATTR_CHIP_UNIT_POS_GETMACRO PLAT_ATTR_GET_CHIP_UNIT_POS + +#define PLAT_ATTR_GET_CHIP_UNIT_POS(ID, PTARGET, VAL) \ + _getAttrChipUnitPos(PTARGET, VAL) + +template +inline +AttributeRC _getAttrChipUnitPos(const Target& i_target, + ATTR_CHIP_UNIT_POS_Type& o_val) +{ + o_val = i_target.get().getTargetInstance(); + return FAPI2_RC_SUCCESS; +} + +template<> +inline +AttributeRC _getAttrChipUnitPos(const Target& i_target, + ATTR_CHIP_UNIT_POS_Type& o_val) +{ + o_val = i_target.getChipletNumber(); + return FAPI2_RC_SUCCESS; +} + +/* INSERT NEW GETTER AND SETTER FUNCTIONS HERE */ + + + +//****************************************************************************** +// Get base template +//****************************************************************************** +template +AttributeRC _get(const AttributeId i_id, + const Target & i_pTarget, + T& o_value) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get uint8_t +//****************************************************************************** +template +AttributeRC _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 +AttributeRC _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 +AttributeRC _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 +AttributeRC _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 +AttributeRC _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 +AttributeRC _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 +AttributeRC _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 +AttributeRC _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 +AttributeRC _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 +AttributeRC _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 +AttributeRC _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 +AttributeRC _getAttributeArrayWord(const AttributeId i_id, + const Target & i_pTarget, + uint16_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Set uint16_t array +//****************************************************************************** +template +AttributeRC _setAttributeArrayWord(const AttributeId i_id, + const Target & i_pTarget, + uint16_t * i_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get uint32_t array +//****************************************************************************** +template +AttributeRC _getAttributeArrayWord(const AttributeId i_id, + const Target & i_pTarget, + uint32_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Set uint32_t array +//****************************************************************************** +template +AttributeRC _setAttributeArrayWord(const AttributeId i_id, + const Target & i_pTarget, + uint32_t * i_pValues) +{ + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Get uint64_t array +//****************************************************************************** +template +AttributeRC _getAttributeArrayDoubleWord(const AttributeId i_id, + const Target & i_pTarget, + uint64_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Set uint64_t array +//****************************************************************************** +template +AttributeRC _setAttributeArrayDoubleWord(const AttributeId i_id, + const Target & i_pTarget, + uint64_t * i_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get Override uint8_t array +//****************************************************************************** +template +AttributeRC _getAttributeOverrideArrayShort(const AttributeId i_id, + const Target & i_pTarget, + uint8_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get Override uint16_t array +//****************************************************************************** +template +AttributeRC _getAttributeOverrideArrayWord(const AttributeId i_id, + const Target & i_pTarget, + uint16_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get Override uint32_t array +//****************************************************************************** +template +AttributeRC _getAttributeOverrideArrayWord(const AttributeId i_id, + const Target & i_pTarget, + uint32_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get Override uint64_t array +//****************************************************************************** +template +AttributeRC _getAttributeOverrideArrayDoubleWord(const AttributeId i_id, + const Target & i_pTarget, + uint64_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Set base template +//****************************************************************************** +template +AttributeRC _set(const AttributeId i_id, + const Target & i_pTarget, + const T& i_value) +{ + return FAPI2_RC_SUCCESS; +} + + + +//****************************************************************************** +// Set uint8_t +//****************************************************************************** +template +AttributeRC _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 +AttributeRC _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 +AttributeRC _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 +AttributeRC _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 +AttributeRC _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 +AttributeRC _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 +AttributeRC _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 +AttributeRC _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 +AttributeRC _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 +AttributeRC _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 +AttributeRC _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 +AttributeRC _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 +AttributeRC _getAttributeArraySignedShort(const AttributeId i_id, + const Target & i_pTarget, + int8_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Set int8_t array +//****************************************************************************** +template +AttributeRC _setAttributeArraySignedShort(const AttributeId i_id, + const Target & i_pTarget, + int8_t * i_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get int16_t array +//****************************************************************************** +template +AttributeRC _getAttributeArraySignedWord(const AttributeId i_id, + const Target & i_pTarget, + int16_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Set int16_t array +//****************************************************************************** +template +AttributeRC _setAttributeArraySignedWord(const AttributeId i_id, + const Target & i_pTarget, + int16_t * i_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get int32_t array +//****************************************************************************** +template +AttributeRC _getAttributeArraySignedWord(const AttributeId i_id, + const Target & i_pTarget, + int32_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Set int32_t array +//****************************************************************************** +template +AttributeRC _setAttributeArraySignedWord(const AttributeId i_id, + const Target & i_pTarget, + int32_t * i_pValues) +{ + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Get int64_t array +//****************************************************************************** +template +AttributeRC _getAttributeArraySignedDoubleWord(const AttributeId i_id, + const Target & i_pTarget, + int64_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Set int64_t array +//****************************************************************************** +template +AttributeRC _setAttributeArraySignedDoubleWord(const AttributeId i_id, + const Target & i_pTarget, + int64_t * i_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get Override int8_t array +//****************************************************************************** +template +AttributeRC _getAttributeOverrideArraySignedShort(const AttributeId i_id, + const Target & i_pTarget, + int8_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get Override int16_t array +//****************************************************************************** +template +AttributeRC _getAttributeOverrideArraySignedWord(const AttributeId i_id, + const Target & i_pTarget, + int16_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + +//****************************************************************************** +// Get Override int32_t array +//****************************************************************************** +template +AttributeRC _getAttributeOverrideArraySignedWord(const AttributeId i_id, + const Target & i_pTarget, + int32_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Get Override int64_t array +//****************************************************************************** +template +AttributeRC _getAttributeOverrideArraySignedDoubleWord(const AttributeId i_id, + const Target & i_pTarget, + int64_t * o_pValues) +{ + return FAPI2_RC_SUCCESS; +} + + +//****************************************************************************** +// Set int8_t +//****************************************************************************** +template +AttributeRC _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 +AttributeRC _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 +AttributeRC _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 +AttributeRC _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/plat_attributes.H b/src/hwpf/plat_attributes.H new file mode 100644 index 00000000..ed38221d --- /dev/null +++ b/src/hwpf/plat_attributes.H @@ -0,0 +1,35 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/hwpf/plat_attributes.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2012,2017 */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +/** + * @file plat_attributes.H + * @brief Platform specific attribute headers + */ + +#ifndef __PLAT_ATTTRIBUTE_H__ +#define __PLAT_ATTTRIBUTE_H__ + +#include +#include // Generated file + +#endif // __PLAT_ATTTRIBUTE_H__ diff --git a/src/hwpf/plat_error_scope.H b/src/hwpf/plat_error_scope.H new file mode 100644 index 00000000..8a548c44 --- /dev/null +++ b/src/hwpf/plat_error_scope.H @@ -0,0 +1,79 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/hwpf/plat_error_scope.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2012,2017 */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +/** + * @file plat_error_scope.H + * @brief platform definitions which create a scope for automatic error handling + */ + +#ifndef __FAPI2_PLAT_ERROR_SCOPE__ +#define __FAPI2_PLAT_ERROR_SCOPE__ + +/// @cond +#define PLAT_FAPI_TRY_NO_TRACE( __operation__ ) \ + if(std::is_same::value) \ + { \ + (void)((__operation__)); \ + } \ + else \ + { \ + if ((fapi2::current_err = (__operation__)) != fapi2::FAPI2_RC_SUCCESS) \ + { \ + goto fapi_try_exit; \ + } \ + } + + +#define PLAT_FAPI_TRY_TRACE( __operation__, ... ) \ + if ((fapi2::current_err = (__operation__)) != fapi2::FAPI2_RC_SUCCESS) \ + { /* TODO via RTC 172311 */ \ + /* Enable these traces back again */ \ + /* FAPI_ERR(__VA_ARGS__); */ \ + goto fapi_try_exit; \ + } + +/// +/// @brief Assert a conditional is true. +/// If it is not, the FFDC gathering function is called and the +/// trace is output as a FAPI error trace. +/// @param[in] __conditional__ the condition to assert +/// @param[in] __ffdc__ the FFDC gathering function +/// @param[in] ... varargs, as input to FAPI_ERR +/// +#define PLAT_FAPI_ASSERT( __conditional__, __ffdc__, ... ) \ + if (! (__conditional__)) \ + { \ + (__ffdc__).execute(); \ + FAPI_ERR(__VA_ARGS__); \ + goto fapi_try_exit; \ + } + + +/// +/// @brief Temporary macro for error label until all are removed. +/// @todo REMOVE this in time. +#define FAPI_CLEANUP() \ +fapi_try_exit: +/// @endcond + +#endif diff --git a/src/hwpf/plat_hw_access.C b/src/hwpf/plat_hw_access.C new file mode 100644 index 00000000..d1112533 --- /dev/null +++ b/src/hwpf/plat_hw_access.C @@ -0,0 +1,357 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/hwpf/plat_hw_access.C $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2016,2017 */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ + +#include +#include "hw_access.H" +#include "plat_hw_access.H" +#include "p9_perv_scom_addresses.H" +#include + +namespace fapi2 +{ + +struct restoreOpcgRegisters g_opcgData; + +uint64_t decodeScanRegionData(const uint32_t i_ringAddress) +{ + uint32_t l_scan_region = (i_ringAddress & 0x0000FFF0) << 13; + + uint32_t l_scan_type = 0x00008000 >> (i_ringAddress & 0x0000000F); + + // This is special case if encoded type is 0xF + + if ( (i_ringAddress & 0x0000000F) == 0xF) + { + l_scan_type = 0x00008000 | (l_scan_type << 12); + } + uint64_t l_value = l_scan_region; + l_value = (l_value << 32) | l_scan_type; + + return l_value; +} + +ReturnCode getRing_setup(const uint32_t i_ringAddress, + const RingMode i_ringMode) +{ + fapi2::ReturnCode l_rc = FAPI2_RC_SUCCESS; + uint64_t l_scanRegion = 0; + uint32_t l_chipletId = i_ringAddress >> 24; + + Target l_proc = plat_getChipTarget(); + + do + { + l_scanRegion = decodeScanRegionData(i_ringAddress); + + if (i_ringMode & fapi2::RING_MODE_SET_PULSE_SL) + { + l_rc = storeOPCGRegData (l_proc, g_opcgData, l_chipletId); + if(l_rc != fapi2::FAPI2_RC_SUCCESS) + { + break; + } + + l_rc = setupScanRegionForSetPulse(l_proc, l_scanRegion, + i_ringMode,l_chipletId); + if(l_rc != fapi2::FAPI2_RC_SUCCESS) + { + break; + } + } + else + { + // Set up the scan region for the ring. + l_rc = setupScanRegion(l_proc, l_scanRegion, l_chipletId); + if(l_rc != fapi2::FAPI2_RC_SUCCESS) + { + break; + } + } + // Write a 64 bit value for header. + const uint64_t l_header = 0xa5a5a5a5a5a5a5a5; + uint32_t l_scomAddress = 0x0003E000 | (i_ringAddress & 0xFF000000); + l_rc = fapi2::putScom(l_proc, l_scomAddress, l_header); + if(l_rc != fapi2::FAPI2_RC_SUCCESS) + { + break; + } + + }while(0); + + return l_rc; +} + +ReturnCode getRing_verifyAndcleanup(const uint32_t i_ringAddress, + const RingMode i_ringMode) +{ + fapi2::ReturnCode l_rc = FAPI2_RC_SUCCESS; + uint32_t l_chipletId = i_ringAddress >> 24; + + fapi2::Target l_proc; + + do + { + // Verify header + uint64_t l_header = 0xa5a5a5a5a5a5a5a5; + l_rc = verifyHeader(l_proc, l_header, l_chipletId,i_ringMode); + if(l_rc != fapi2::FAPI2_RC_SUCCESS) + { + break; + } + + l_rc = cleanScanRegionandTypeData(l_proc, l_chipletId); + if(l_rc != fapi2::FAPI2_RC_SUCCESS) + { + break; + } + + if (i_ringMode & fapi2::RING_MODE_SET_PULSE_SL) + { + l_rc = restoreOPCGRegData(l_proc, g_opcgData, l_chipletId); + if(l_rc != fapi2::FAPI2_RC_SUCCESS) + { + break; + } + } + + }while(0); + + return l_rc; +} + +static uint32_t getEffectiveAddress(const plat_target_handle_t &i_target, const uint32_t i_addr) +{ + ScomAddr l_addr(i_addr); + switch(i_target.getTargetType()) + { + case PPE_TARGET_TYPE_EX: + if((EQ_CHIPLET_OFFSET <= l_addr.iv_chiplet) && + ((EQ_CHIPLET_OFFSET + EQ_TARGET_COUNT) > l_addr.iv_chiplet)) + { + l_addr.iv_chiplet = i_target.fields.chiplet_num; + l_addr.iv_ring = (l_addr.iv_ring - (l_addr.iv_ring % 2)) + + (i_target.getTargetInstance() % 2); + } + else if ((CORE_CHIPLET_OFFSET <= l_addr.iv_chiplet) && + ((CORE_CHIPLET_OFFSET + CORE_TARGET_COUNT) > l_addr.iv_chiplet)) + { + l_addr.iv_chiplet = CORE_CHIPLET_OFFSET + (l_addr.iv_chiplet % 2) + + (i_target.getTargetInstance() * 2); + } + else + { + assert(false); + } + break; + case PPE_TARGET_TYPE_MCS: + l_addr.iv_chiplet = i_target.fields.chiplet_num; + l_addr.iv_satId = (2 * (i_target.getTargetInstance() % 2)); + break; + case PPE_TARGET_TYPE_PHB: + if(l_addr.iv_chiplet == N2_CHIPLET) + { + if (i_target.getTargetInstance() == 0) + { + l_addr.iv_ring = 0x3; + l_addr.iv_satId = ((l_addr.iv_satId < 4) ? (1) : (4)); + } + else + { + l_addr.iv_ring = (0x3 + (i_target.getTargetInstance() / 3) + 1) & 0xF; + l_addr.iv_satId = ((l_addr.iv_satId < 4) ? (1) : (4)) + + ((i_target.getTargetInstance() % 2) ? (0) : (1)) + + (2 * (i_target.getTargetInstance() / 5)); + } + } + else + { + l_addr.iv_chiplet = i_target.fields.chiplet_num; + if (i_target.getTargetInstance() == 0) + { + l_addr.iv_satId = ((l_addr.iv_satId < 4) ? (1) : (4)); + } + else + { + l_addr.iv_satId = (((l_addr.iv_satId < 4) ? (1) : (4)) + + ((i_target.getTargetInstance() % 2) ? (0) : (1)) + + (2 * (i_target.getTargetInstance() / 5))); + } + } + break; + default: + if(0 != i_target.getAddressOverlay()) + { + l_addr.iv_chiplet = i_target.fields.chiplet_num; + } + break; + } + return l_addr; +} + +static fapi2::ReturnCode pibRcToFapiRc(const uint32_t i_pibRc) +{ + fapi2::ReturnCode l_fapiRc = FAPI2_RC_SUCCESS; + switch(i_pibRc) + { + case PIB_XSCOM_ERROR: + l_fapiRc = RC_SBE_PIB_XSCOM_ERROR; + break; + case PIB_OFFLINE_ERROR: + l_fapiRc = RC_SBE_PIB_OFFLINE_ERROR; + break; + case PIB_PARTIAL_ERROR: + l_fapiRc = RC_SBE_PIB_PARTIAL_ERROR; + break; + case PIB_ADDRESS_ERROR: + l_fapiRc = RC_SBE_PIB_ADDRESS_ERROR; + break; + case PIB_CLOCK_ERROR: + l_fapiRc = RC_SBE_PIB_CLOCK_ERROR; + break; + case PIB_PARITY_ERROR: + l_fapiRc = RC_SBE_PIB_PARITY_ERROR; + break; + case PIB_TIMEOUT_ERROR: + l_fapiRc = RC_SBE_PIB_TIMEOUT_ERROR; + break; + case PIB_NO_ERROR: + default: + break; + } + return l_fapiRc; +} + +fapi2::ReturnCode getscom_abs_wrap(const void *i_target, + const uint32_t i_addr, uint64_t *o_data) +{ + uint32_t l_pibRc = 0; + uint32_t l_addr = getEffectiveAddress(*(plat_target_handle_t*)i_target, i_addr); + FAPI_INF("getScom: address: 0x%08X", l_addr); + l_pibRc = getscom_abs(l_addr, o_data); + if( PIB_NO_ERROR != l_pibRc ) + { + l_pibRc = p9_pibErrRetry( l_addr, o_data, l_pibRc, true); + } + FAPI_INF("getScom: returned pibRc: 0x%08X, data HI: 0x%08X, " + "data LO: 0x%08X", l_pibRc, (*o_data >> 32), + static_cast(*o_data & 0xFFFFFFFF)); + fapi2::current_err = fapi2::FAPI2_RC_SUCCESS; + // Setting 64bit address in ffdc package as the parsers are + // hard coded to read 64bit address + const uint64_t ffdcAddr = l_addr; + PLAT_FAPI_ASSERT( PIB_NO_ERROR == l_pibRc, + SBE_SCOM_FAILURE(). + set_address(ffdcAddr). + set_pcb_pib_rc(l_pibRc), + "getScom:pcb pib error, pibRc[0x%08X] Scom_Addr[0x%08X]", + l_pibRc,l_addr); +fapi_try_exit: + if(PIB_NO_ERROR != l_pibRc) + { + // Override FAPI RC based on PIB RC + fapi2::current_err = pibRcToFapiRc(l_pibRc); + fapi2::g_FfdcData.fapiRc = fapi2::current_err; + } + return fapi2::current_err; +} + +fapi2::ReturnCode putscom_abs_wrap(const void *i_target, + const uint32_t i_addr, uint64_t i_data) +{ + uint32_t l_pibRc = 0; + uint32_t l_addr = getEffectiveAddress(*(plat_target_handle_t*)i_target, + i_addr); + FAPI_INF("putScom: address: 0x%08X, data HI: 0x%08X, data LO: 0x%08X", + l_addr, (i_data >> 32), + static_cast(i_data & 0xFFFFFFFF)); + l_pibRc = putscom_abs(l_addr, i_data); + if( PIB_NO_ERROR != l_pibRc ) + { + l_pibRc = p9_pibErrRetry( l_addr, &i_data, l_pibRc, false); + } + FAPI_INF("putScom: returned pibRc: 0x%08X", l_pibRc); + fapi2::current_err = fapi2::FAPI2_RC_SUCCESS; + // Setting 64bit address in ffdc package as the parsers are + // hard coded to read 64bit address + const uint64_t ffdcAddr = l_addr; + PLAT_FAPI_ASSERT( PIB_NO_ERROR == l_pibRc, + SBE_SCOM_FAILURE(). + set_address(ffdcAddr). + set_pcb_pib_rc(l_pibRc), + "putScom:pcb pib error, pibRc[0x%08X] Scom_Addr[0x%08X] " + "Scom_Data[0x%08X%08X]", + l_pibRc,l_addr,(i_data >> 32), + static_cast(i_data & 0xFFFFFFFF)); +fapi_try_exit: + if(PIB_NO_ERROR != l_pibRc) + { + // Override FAPI RC based on PIB RC + fapi2::current_err = pibRcToFapiRc(l_pibRc); + fapi2::g_FfdcData.fapiRc = fapi2::current_err; + } + return fapi2::current_err; +} + +uint32_t p9_pibErrRetry( const uint32_t i_addr, uint64_t *io_data, + const uint8_t i_pibErr, const bool i_isRead) +{ + FAPI_INF("Entering p9_pibErrRetry"); + static const uint8_t MAX_RETRIES = 2; + uint8_t l_retryCount = 0; + uint32_t pibErr = i_pibErr; + + do + { + // Only retry for parity and timeout errors + if (( i_pibErr != PIB_PARITY_ERROR ) + && ( i_pibErr != PIB_TIMEOUT_ERROR )) + { + break; + } + for(l_retryCount = 0; l_retryCount < MAX_RETRIES; l_retryCount++) + { + FAPI_DBG( "*** Retry %i ***", l_retryCount ); + + if ( i_isRead ) + { + pibErr = getscom_abs(i_addr, io_data); + } + else + { + pibErr = putscom_abs(i_addr, *io_data); + } + + if( PIB_NO_ERROR == pibErr ) + { + FAPI_INF("Read/Write Retry Successful"); + break; + } + if ( pibErr != i_pibErr ) break; + } + }while(0); + FAPI_INF("Exiting p9_pibErrRetry"); + return pibErr; +} + +}; diff --git a/src/hwpf/plat_hw_access.H b/src/hwpf/plat_hw_access.H new file mode 100644 index 00000000..16bbf0ce --- /dev/null +++ b/src/hwpf/plat_hw_access.H @@ -0,0 +1,165 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/hwpf/plat_hw_access.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2015,2017 */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +/** + * @file plat_hw_access.H + * + * @brief Define platform specific calls for hardware accesses. + */ + +#ifndef PLATHWACCESS_H_ +#define PLATHWACCESS_H_ + +#include +#include "hw_access_def.H" +#include +#include + +// PIB errors +enum PCB_ERRORS +{ + PIB_NO_ERROR = 0x0, + PIB_XSCOM_ERROR = 0x1, + PIB_OFFLINE_ERROR = 0x2, + PIB_PARTIAL_ERROR = 0x3, + PIB_ADDRESS_ERROR = 0x4, + PIB_CLOCK_ERROR = 0x5, + PIB_PARITY_ERROR = 0x6, + PIB_TIMEOUT_ERROR = 0x7 +}; + +/// PIB Error Mask + +#define PLAT_SET_PIB_ERROR_MASK(_m_mask) \ + { /* Read MSR */ \ + uint32_t msr_data = mfmsr(); \ + /* Set SEM field */ \ + msr_data &= ~(BITS(0,8)); \ + msr_data |= (uint32_t)(i_mask << 24); \ + /* Write MSR */ \ + mtmsr(msr_data); \ + }; + +#define PLAT_GET_PIB_ERROR_MASK(_m_mask) \ + uint8_t _m_mask; \ + uint32_t _sem = mfmsr(); \ + _m_mask = (uint8_t)((_sem & MSR_SEM) >> (32-(MSR_SEM_START_BIT + MSR_SEM_LEN))); + +// Building block PPE instructions +#define PPE_MFMSR(_m_data) \ +asm volatile \ + ( \ + "mfmsr %[data] \n" \ + : [data]"=&r"(*_m_data) \ + : "[data]"(*_m_data) \ + ); + +#define PPE_MTMSR(_m_data) \ +asm volatile \ + ( \ + "mtmsr %[data] \n" \ + : [data]"=&r"(*_m_data) \ + : "[data]"(*_m_data) \ + ); + +/// GetScom +#define PLAT_GETSCOM(_m_rc, _m_base, _m_offset, _m_data) \ + _m_rc = fapi2::getscom_abs_wrap(&(_m_base), _m_offset, _m_data) + +/// PutScom +#define PLAT_PUTSCOM(_m_rc, _m_base, _m_offset, _m_data) \ + _m_rc = fapi2::putscom_abs_wrap(&(_m_base), _m_offset, _m_data) + +/// GetCFAM +#define PLAT_GETCFAM(_m_base, _m_offset, _m_data) \ + static_assert( K == TARGET_TYPE_NONE, \ + "getCfamRegister is not supported by PPE platforms") + +/// PutCFAM +#define PLAT_PUTCFAM(_m_base, _m_offset, _m_data) \ + static_assert( K == TARGET_TYPE_NONE, \ + "putCfamRegister is not supported by PPE platforms") + +/// ModifyCFAM +#define PLAT_MODCFAM(_m_base, _m_offset, _m_data, _m_mode) \ + static_assert( K == TARGET_TYPE_NONE, \ + "modifyCfamRegister is not supported by PPE platforms") + +namespace fapi2 +{ + // This function loads the scan region data for the given ring address and + // updates the check word data + // @param[in] : ring addtress + // @param[in]: ring mode + // @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + fapi2::ReturnCode getRing_setup(const uint32_t i_ringAddress, + const fapi2::RingMode i_ringMode); + + // This function verify the check word data is matching or not and will + // clean up the scan region data + // @param[in] i_ringAddress - absolute ring address + // @param[in] i_ringMode - Ring mode value + // @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + fapi2::ReturnCode getRing_verifyAndcleanup(const uint32_t i_ringAddress, + const fapi2::RingMode i_ringMode); + + typedef union plat_target_handle plat_target_handle_t; + /// + /// @brief Platform wrapper over PK getscom_abs + /// + /// @param [in] i_addr The SCOM address + /// @param [out] o_data The data read + /// + /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + /// + fapi2::ReturnCode getscom_abs_wrap(const void *i_target, + const uint32_t i_addr, uint64_t *o_data); + + /// + /// @brief Platform wrapper over PK putscom_abs + /// + /// @param [in] i_addr The SCOM address + /// @param [in] i_data The data to write + /// + /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + /// + fapi2::ReturnCode putscom_abs_wrap(const void *i_target, + const uint32_t i_addr, uint64_t i_data); + + /// + /// @brief Platform wrapper to retry scom for parity/timeout errors + /// + /// @param [in] i_addr The SCOM address + /// @param [io] io_data The data pointer + /// @param [in] i_pibErr PIB error code + /// @param [in] i_isRead True if read operation, false otherwise + /// + /// @return PCB-PIB return code + /// + uint32_t p9_pibErrRetry( const uint32_t i_addr, uint64_t *io_data, + const uint8_t i_pibErr, const bool i_isRead); +} + + +#endif // PLATHWACCESS_H_ + diff --git a/src/hwpf/plat_includes.H b/src/hwpf/plat_includes.H new file mode 100644 index 00000000..a0cd359d --- /dev/null +++ b/src/hwpf/plat_includes.H @@ -0,0 +1,39 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/hwpf/plat_includes.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2012,2017 */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +/** + * @file plat_includes.H + * @brief Platform specific include to implement FAPI2 APIs + */ + +#ifndef __PLAT_INCLUDES_H__ +#define __PLAT_INCLUDES_H__ + +#include + +#include +#include +//#include + + +#endif // __PLAT_INCLUDES_H__ diff --git a/src/hwpf/plat_ring_traverse.C b/src/hwpf/plat_ring_traverse.C new file mode 100644 index 00000000..1a000e87 --- /dev/null +++ b/src/hwpf/plat_ring_traverse.C @@ -0,0 +1,498 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/hwpf/plat_ring_traverse.C $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2016,2017 */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ + +#include + +#include // for RS4 decompression utilities +#include +#include // for FAPI_ATTR_GET +#include // for plat_getChipTarget + +// SEEPROM start address +const uint32_t g_seepromAddr = SBE_SEEPROM_BASE_ORIGIN; +using namespace RING_TYPES; +const uint32_t CACHE_CONTAINED_MODE = 4; +const uint32_t RISK_LEVEL_MODE = 1; +#define CACHE_CONTAINED_MODE_OFFSET_IN_TOR 1 +#define RISK_LEVEL_MODE_OFFSET_IN_TOR 2 +#define OVERRIDE_VARIANT_SIZE 1 + + +/// +/// @brief This is a plat pecific (SBE Plat) function that locates the +/// Ring Container in the image and calls the functin to decompress the +/// RS4 string and apply it to the hardware. +/// @param i_target The target of Ring apply. +/// @param i_ringID The Ring ID that identifies the ring to be applied. +/// @return FAPI2_RC_SUCCESS on success, else error code. +/// +fapi2::ReturnCode findRS4InImageAndApply( + const fapi2::Target& i_target, + const RingID i_ringID, + const fapi2::RingMode i_ringMode) +{ + SBE_TRACE(">> findRS4InImageAndApply"); + + fapi2::ReturnCode l_rc = fapi2::FAPI2_RC_SUCCESS; + bool l_applyOverride = false; + + do + { + //Apply scanring from .ring section + + // Get the address of the Section-TOR + P9XipHeader *l_hdr = getXipHdr(); + P9XipSection *l_section = + &(l_hdr->iv_section[P9_XIP_SECTION_SBE_RINGS]); + + if (!(l_section->iv_offset)) + { + SBE_TRACE("No ring data in .RING section"); + break; + } + + SectionTOR *l_sectionTOR = (SectionTOR *)(g_seepromAddr + + l_section->iv_offset); + + l_rc = getRS4ImageFromTor(i_target,i_ringID,l_sectionTOR, + l_applyOverride, + l_section->iv_offset, + i_ringMode); + + if(l_rc != fapi2::FAPI2_RC_SUCCESS) + { + break; + } + + //Apply scanring from .ring section + l_applyOverride = true; + l_section = NULL; + l_section = + &(l_hdr->iv_section[P9_XIP_SECTION_SBE_OVERRIDES]); + + if (!(l_section->iv_offset)) + { + SBE_TRACE("No ring data in .OVERRIDE section"); + break; + } + + l_sectionTOR = NULL; + l_sectionTOR = (SectionTOR *)(g_seepromAddr + + l_section->iv_offset); + + + l_rc = getRS4ImageFromTor(i_target,i_ringID,l_sectionTOR, + l_applyOverride, + l_section->iv_offset, + i_ringMode); + }while(0); + + return l_rc; +} + +fapi2::ReturnCode getRS4ImageFromTor( + const fapi2::Target& i_target, + const RingID i_ringID, + SectionTOR *i_sectionTOR, + bool i_applyOverride, + const uint32_t i_sectionOffset, + const fapi2::RingMode i_ringMode) +{ + + // Determine the Offset ID and Ring Type for the given Ring ID. + uint32_t l_torOffset = 0; + RINGTYPE l_ringType = COMMON_RING; + CHIPLET_TYPE l_chipLetType; + fapi2::ReturnCode l_rc = fapi2::FAPI2_RC_SUCCESS; + do + { + + getRingProperties(i_ringID, l_torOffset, l_ringType,l_chipLetType); + if(INVALID_RING == l_torOffset) + { + SBE_TRACE("Invalid Ring ID - %d", i_ringID); + l_rc = fapi2::FAPI2_RC_INVALID_PARAMETER; + break; + } + + CHIPLET_DATA l_chipletData; + l_chipletData.iv_base_chiplet_number = 0; + l_chipletData.iv_num_common_rings = 0; + l_chipletData.iv_num_instance_rings = 0; + + uint8_t l_chipletID = i_target.getChipletNumber(); + uint16_t l_cpltRingVariantSz = 0; + uint32_t l_sectionOffset = 0; + uint8_t l_CC_offset = 0; + uint8_t l_RL_offset = 1; + switch(l_chipLetType) + { + case PERV_TYPE: // PERV + l_chipletData = PERV::g_pervData; + 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) + { + l_sectionOffset = i_sectionTOR->TOC_PERV_INSTANCE_RING; + } + + break; + + case N0_TYPE: // Nest - N0 + l_chipletData = N0::g_n0Data; + l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : + (sizeof(N0::RingVariants) / + sizeof(l_cpltRingVariantSz)); + + l_sectionOffset = i_sectionTOR->TOC_N0_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = i_sectionTOR->TOC_N0_INSTANCE_RING; + } + + break; + + case N1_TYPE: // Nest - N1 + l_chipletData = N1::g_n1Data; + l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : + (sizeof(N1::RingVariants) / + sizeof(l_cpltRingVariantSz)); + + l_sectionOffset = i_sectionTOR->TOC_N1_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = i_sectionTOR->TOC_N1_INSTANCE_RING; + } + + break; + + case N2_TYPE: // Nest - N2 + l_chipletData = N2::g_n2Data; + l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : + (sizeof(N2::RingVariants) / + sizeof(l_cpltRingVariantSz)); + + l_sectionOffset = i_sectionTOR->TOC_N2_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = i_sectionTOR->TOC_N2_INSTANCE_RING; + } + + break; + + case N3_TYPE: // Nest - N3 + l_chipletData = N3::g_n3Data; + l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : + (sizeof(N3::RingVariants) / + sizeof(l_cpltRingVariantSz)); + + l_sectionOffset = i_sectionTOR->TOC_N3_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = i_sectionTOR->TOC_N3_INSTANCE_RING; + } + + break; + + case XB_TYPE: // XB - XBus2 + l_chipletData = XB::g_xbData; + l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : + (sizeof(XB::RingVariants) / + sizeof(l_cpltRingVariantSz)); + + l_sectionOffset = i_sectionTOR->TOC_XB_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = i_sectionTOR->TOC_XB_INSTANCE_RING; + } + + break; + + case MC_TYPE: // MC - MC23 + l_chipletData = MC::g_mcData; + l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : + (sizeof(MC::RingVariants)/ + sizeof(l_cpltRingVariantSz)); + + l_sectionOffset = i_sectionTOR->TOC_MC_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = i_sectionTOR->TOC_MC_INSTANCE_RING; + } + + break; + + case OB0_TYPE: // OB0 + l_chipletData = OB0::g_ob0Data; + l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : + (sizeof(OB0::RingVariants) / + sizeof(l_cpltRingVariantSz)); + + l_sectionOffset = i_sectionTOR->TOC_OB0_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = i_sectionTOR->TOC_OB0_INSTANCE_RING; + } + + break; + case OB1_TYPE: // OB1 + l_chipletData = OB1::g_ob1Data; + l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : + (sizeof(OB1::RingVariants) / + sizeof(l_cpltRingVariantSz)); + + l_sectionOffset = i_sectionTOR->TOC_OB1_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = i_sectionTOR->TOC_OB1_INSTANCE_RING; + } + + break; + case OB2_TYPE: // OB2 + l_chipletData = OB2::g_ob2Data; + l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : + (sizeof(OB2::RingVariants) / + sizeof(l_cpltRingVariantSz)); + + l_sectionOffset = i_sectionTOR->TOC_OB2_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = i_sectionTOR->TOC_OB2_INSTANCE_RING; + } + + break; + case OB3_TYPE: // OB3 + l_chipletData = OB3::g_ob3Data; + l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : + (sizeof(OB3::RingVariants) / + sizeof(l_cpltRingVariantSz)); + + l_sectionOffset = i_sectionTOR->TOC_OB3_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = i_sectionTOR->TOC_OB3_INSTANCE_RING; + } + + break; + + + case PCI0_TYPE: // PCI - PCI0 + l_chipletData = PCI0::g_pci0Data; + l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : + (sizeof(PCI0::RingVariants) / + sizeof(l_cpltRingVariantSz)); + + l_sectionOffset = i_sectionTOR->TOC_PCI0_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = i_sectionTOR->TOC_PCI0_INSTANCE_RING; + } + + break; + + case PCI1_TYPE: // PCI - PCI1 + l_chipletData = PCI1::g_pci1Data; + l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : + (sizeof(PCI1::RingVariants) / + sizeof(l_cpltRingVariantSz)); + + l_sectionOffset = i_sectionTOR->TOC_PCI1_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = i_sectionTOR->TOC_PCI1_INSTANCE_RING; + } + + break; + + case PCI2_TYPE: // PCI - PCI2 + l_chipletData = PCI2::g_pci2Data; + l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : + (sizeof(PCI2::RingVariants) / + sizeof(l_cpltRingVariantSz)); + + l_sectionOffset = i_sectionTOR->TOC_PCI2_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = i_sectionTOR->TOC_PCI2_INSTANCE_RING; + } + + break; + + case EQ_TYPE: // EQ - Quad 0 - Quad 5 + l_chipletData = EQ::g_eqData; + l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : + ( sizeof(EQ::RingVariants) / + sizeof(l_cpltRingVariantSz)); + + + l_sectionOffset = i_sectionTOR->TOC_EQ_COMMON_RING; + l_CC_offset = 1; + l_RL_offset = 2; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = i_sectionTOR->TOC_EQ_INSTANCE_RING; + } + + break; + + case EC_TYPE: // EC - Core 0 - 23 + l_chipletData = EC::g_ecData; + l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : + (sizeof(EC::RingVariants) / + sizeof(l_cpltRingVariantSz)); + + l_sectionOffset = i_sectionTOR->TOC_EC_COMMON_RING; + l_CC_offset = 1; + l_RL_offset = 2; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = i_sectionTOR->TOC_EC_INSTANCE_RING; + } + + break; + + default: + SBE_TRACE("Invalid Target/ChipletID - %d", l_chipletID); + l_rc = fapi2::FAPI2_RC_INVALID_PARAMETER; + break; + + } // end of switch(l_chipletID) + + if (l_rc) + { + break; + } + + FAPI_INF("l_sectionOffset %08x",l_sectionOffset); + // Determine the section TOR address for the ring + uint32_t *l_sectionAddr = reinterpret_cast(g_seepromAddr + + i_sectionOffset + l_sectionOffset); + + SBE_TRACE ("l_sectionAddr %08X",(uint32_t)l_sectionAddr); + + uint16_t *l_ringTorAddr = NULL; + + + if(INSTANCE_RING == l_ringType) + { + if ( l_chipletID >= l_chipletData.iv_base_chiplet_number) + { + uint8_t l_chipletOffset = + (l_chipletID - l_chipletData.iv_base_chiplet_number); + if (l_chipLetType == EQ_TYPE) + { + if (fapi2::TARGET_TYPE_EX & (i_target.get().getFapiTargetType())) + { + uint32_t l_ex_number = i_target.get().getTargetInstance(); + l_chipletOffset = l_ex_number; + SBE_TRACE ("l_chipletID %d l_ex_number %d",l_chipletID,l_ex_number); + } + } + SBE_TRACE ("l_chipletID %u l_chipletOffset %u",l_chipletID, l_chipletOffset); + l_ringTorAddr = reinterpret_cast(l_sectionAddr )+ ((l_chipletOffset * + (l_chipletData.iv_num_instance_rings *l_cpltRingVariantSz)) + (l_torOffset * l_cpltRingVariantSz)); + + } + else + { + l_ringTorAddr = reinterpret_cast(l_sectionAddr) + + (l_torOffset * l_cpltRingVariantSz); + } + } + else + { + // TOR records of Ring TOR are 2 bytes in size. + l_ringTorAddr = reinterpret_cast(l_sectionAddr) + + (l_torOffset * l_cpltRingVariantSz); + } + + // The ring variants in section TOR are expected to be in the sequence - + // 1. Base + // 2. Cache-Contained + // 3. Risk Level + + + SBE_TRACE ("ring tor address %08X",(uint32_t)l_ringTorAddr); + + // If there are non-base variants of the ring, we'll have to check + // attributes to determine the sequence of ring apply. + if( l_cpltRingVariantSz > 1) + { + // Check if this is cache-contained IPL + uint8_t l_iplPhase; + FAPI_ATTR_GET(fapi2::ATTR_SYSTEM_IPL_PHASE, + fapi2::Target (), + l_iplPhase); + + // 4 : Use Cache Contained mode _if_ present, else fall back + // to normal ring + if((CACHE_CONTAINED_MODE == l_iplPhase) + && *(l_ringTorAddr + l_CC_offset)) + { + l_ringTorAddr += l_CC_offset; + } + else + { + // Check if this is risk-level IPL + // _if_ present, else fall back to normal ring + uint8_t l_riskLevel; + FAPI_ATTR_GET(fapi2::ATTR_RISK_LEVEL, + fapi2::Target (), + l_riskLevel); + if((RISK_LEVEL_MODE == l_riskLevel) && + *(l_ringTorAddr + l_RL_offset)) + { + l_ringTorAddr += l_RL_offset; + } + } + } + + SBE_TRACE("l_ringTorAddr %u",*l_ringTorAddr); + if(*l_ringTorAddr != 0) + { + uint8_t *l_addr = reinterpret_cast(l_sectionAddr); + uint8_t *l_rs4Address = reinterpret_cast + (l_addr + *l_ringTorAddr); + SBE_TRACE("l_rs4Address %08x",(uint32_t)l_rs4Address); + l_rc = rs4DecompressionSvc(i_target,l_rs4Address, + i_applyOverride,i_ringMode,l_ringType); + if(l_rc != fapi2::FAPI2_RC_SUCCESS) + { + SBE_TRACE("Error from applyRS4_SS"); + break; + } + } + else + { + SBE_TRACE("Ring image is not found for this is ringId %u",i_ringID); + } + }while(0); + + SBE_TRACE("<< findRS4InImageAndApply Exit for ringId %d",i_ringID); + return l_rc; +} + diff --git a/src/hwpf/plat_ring_traverse.H b/src/hwpf/plat_ring_traverse.H new file mode 100644 index 00000000..cd5fbc29 --- /dev/null +++ b/src/hwpf/plat_ring_traverse.H @@ -0,0 +1,116 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/hwpf/plat_ring_traverse.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2016,2017 */ +/* */ +/* */ +/* 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 */ + +#ifndef _PLAT_RING_TRAVERSE_H_ +#define _PLAT_RING_TRAVERSE_H_ + +#include // for RS4 decompression utilities + +using namespace RING_TYPES; + +/// @brief This structure represents the layout of the Section-TOR +/// Section-TOR has the offsets to the different chiplet's +/// Common Ring section and Instance Ring section +struct SectionTOR +{ + uint32_t TOC_PERV_COMMON_RING; // Offset of Perv Common Ring section + uint32_t TOC_PERV_INSTANCE_RING; // Offset of Perv Instance Ring section + + uint32_t TOC_N0_COMMON_RING; // Offset of N0 Common Ring section + uint32_t TOC_N0_INSTANCE_RING; // Offset of N0 Instance Ring section + + uint32_t TOC_N1_COMMON_RING; // Offset of N1 Common Ring section + uint32_t TOC_N1_INSTANCE_RING; // Offset of N1 Instance Ring section + + uint32_t TOC_N2_COMMON_RING; // Offset of N2 Common Ring section + uint32_t TOC_N2_INSTANCE_RING; // Offset of N2 Instance Ring section + + uint32_t TOC_N3_COMMON_RING; // Offset of N3 Common Ring section + uint32_t TOC_N3_INSTANCE_RING; // Offset of N3 Instance Ring section + + uint32_t TOC_XB_COMMON_RING; // Offset of XB Common Ring section + uint32_t TOC_XB_INSTANCE_RING; // Offset of XB Instance Ring section + + uint32_t TOC_MC_COMMON_RING; // Offset of MC Common Ring section + uint32_t TOC_MC_INSTANCE_RING; // Offset of MC Instance Ring section + + uint32_t TOC_OB0_COMMON_RING; // Offset of OB0 Common Ring section + uint32_t TOC_OB0_INSTANCE_RING; // Offset of OB0 Instance Ring section + + uint32_t TOC_OB1_COMMON_RING; // Offset of OB1 Common Ring section + uint32_t TOC_OB1_INSTANCE_RING; // Offset of OB1 Instance Ring section + + uint32_t TOC_OB2_COMMON_RING; // Offset of OB2 Common Ring section + uint32_t TOC_OB2_INSTANCE_RING; // Offset of OB2 Instance Ring section + + uint32_t TOC_OB3_COMMON_RING; // Offset of OB3 Common Ring section + uint32_t TOC_OB3_INSTANCE_RING; // Offset of OB3 Instance Ring section + + uint32_t TOC_PCI0_COMMON_RING; // Offset of PCI0 Common Ring section + uint32_t TOC_PCI0_INSTANCE_RING; // Offset of PCI0 Instance Ring section + + uint32_t TOC_PCI1_COMMON_RING; // Offset of PCI1 Common Ring section + uint32_t TOC_PCI1_INSTANCE_RING; // Offset of PCI1 Instance Ring section + + uint32_t TOC_PCI2_COMMON_RING; // Offset of PCI2 Common Ring section + uint32_t TOC_PCI2_INSTANCE_RING; // Offset of PCI2 Instance Ring section + + uint32_t TOC_EQ_COMMON_RING; // Offset of Quad Common Ring section + uint32_t TOC_EQ_INSTANCE_RING; // Offset of Quad Instance Ring section + + uint32_t TOC_EC_COMMON_RING; // Offset of Core Common Ring section + uint32_t TOC_EC_INSTANCE_RING; // Offset of Core Instance Ring section +}; + + +/// +/// @brief This is a plat pecific (SBE Plat) function that locates the +/// Ring Container in the image and calls the functin to decompress the +/// RS4 string and apply it to the hardware. +/// @param i_target The target of Ring apply. +/// @param i_ringID The Ring ID that identifies the ring to be applied. +/// @return FAPI2_RC_SUCCESS on success, else error code. +/// +fapi2::ReturnCode findRS4InImageAndApply( + const fapi2::Target& i_target, + const RingID i_ringID, + const fapi2::RingMode i_ringMode); +/// +/// @brief This is a plat pecific (SBE Plat) function that locates the +/// Ring Container in the image and calls the functin to decompress the +/// RS4 string and apply it to the hardware. +/// @param i_target The target of Ring apply. +/// @param i_ringID The Ring ID that identifies the ring to be applied. +/// @param i_sectionTOR TOR section address +/// @param i_applyOverride override is enabled or not +/// @return FAPI2_RC_SUCCESS on success, else error code. +/// +fapi2::ReturnCode getRS4ImageFromTor( + const fapi2::Target& i_target, + const RingID i_ringID, + SectionTOR *i_sectionTOR, + bool i_applyOverride, + const uint32_t i_sectionOffset, + const fapi2::RingMode i_ringMode); +#endif diff --git a/src/hwpf/plat_target.H b/src/hwpf/plat_target.H new file mode 100644 index 00000000..534a351a --- /dev/null +++ b/src/hwpf/plat_target.H @@ -0,0 +1,291 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/hwpf/plat_target.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2015,2017 */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +/** + * @file plat_target.H + * @brief platform definitions for fapi2 targets + */ + +#ifndef __FAPI2_PLAT_TARGET__ +#define __FAPI2_PLAT_TARGET__ + +#include +#include +#include +#include +#include +#include + +static const uint8_t CORES_PER_QUAD = 4; +static const uint8_t EX_PER_QUAD = 2; +static const uint8_t CORES_PER_EX = 2; +static const uint8_t N2_CHIPLET = 4; +static const uint8_t N3_CHIPLET = 5; +static const uint8_t MCS_PER_MCBIST = 2; +static const uint8_t PCI0_CHIPLET = 0x0D; + +// +// Define what a platform handle looks like. For Hostboot, +// for example, this might be a void*. For the SBE, this +// will be a uint32_t ... +// +namespace fapi2 +{ + typedef enum plat_target_type + { + PPE_TARGET_TYPE_NONE = 0x00, + PPE_TARGET_TYPE_PROC_CHIP = 0x01, + PPE_TARGET_TYPE_MCS = 0x02, + PPE_TARGET_TYPE_CORE = 0x04, + PPE_TARGET_TYPE_EQ = 0x08, + PPE_TARGET_TYPE_EX = 0x10, + PPE_TARGET_TYPE_PERV = 0x20, + PPE_TARGET_TYPE_MCBIST = 0x40, + PPE_TARGET_TYPE_SYSTEM = 0x80, + PPE_TARGET_TYPE_PHB = 0x100, + PPE_TARGET_TYPE_ALL = 0xFFF, + } plat_target_type_t; + + typedef union plat_target_handle { + uint32_t value; + struct { +#ifdef _BIG_ENDIAN + uint32_t chiplet_num : 8; + uint32_t type_target_num : 8; + uint32_t present : 1; + uint32_t functional : 1; + uint32_t is_multicast : 1; + uint32_t valid : 1; + uint32_t type : 12; +#else + uint32_t type : 12; + uint32_t valid : 1; + uint32_t is_multicast : 1; + uint32_t functional : 1; + uint32_t present : 1; + uint32_t type_target_num : 8; + uint32_t chiplet_num : 8; +#endif + } fields; + /// + /// @brief Plat target handle constructor + /// + /// @param i_value Value to instantiate handle with + /// + explicit plat_target_handle(uint32_t i_value = 0):value(i_value) {} + + /// + /// @brief Get the fapi2::TargetType for this target + /// + /// @par Converts the internal PPE type for this target to fapi2 enum + /// + /// @return The fapi2::TargetType for this target + /// + TargetType getFapiTargetType() const; + + /// + /// @brief Get the scom address overlay for this target + /// + /// @return Address overlay + /// + uint32_t getAddressOverlay() const + { + return (value & 0xFF000000); + } + + /// + /// @brief Get the plat target type + /// + /// @return The plat target type as a fapi2::TargetType + /// + TargetType getTargetType() const + { + return static_cast(fields.type); + } + + /// + /// @brief Get the instance number for this target + /// + /// @return The instance number for this target + /// + uint32_t getTargetInstance() const + { + return fields.type_target_num; + } + + /// + /// @brief Returns whether this target is functional + /// + /// @return true if Target is functional + /// + bool getFunctional() const + { + return fields.functional; + } + + /// + /// @brief Set functional state of the Target + /// + /// @param [in] i_state Functional state to set + /// + void setFunctional(const bool &i_state) + { + fields.functional = i_state; + } + + /// + /// @brief Returns whether this target is present + /// + /// @return true if Target is present + /// + bool getPresent() const + { + return fields.present; + } + + /// + /// @brief Set Target as present + /// + void setPresent() + { + fields.present = true; + } + + /// + /// @brief Get this target's parent + /// + /// @param [in] The fapi2 type of the requested parent + /// @return Plat target handle to the parent target + /// + plat_target_handle getParent(const TargetType i_parentType) const; + + /// + /// @brief Get this target's children + /// + /// @param [in] i_parentType fapi2 type of the parent + /// @param [in] i_childType fapi2 type of the child + /// @param [in] i_platType Plat type of the parent + /// @param [in] i_state Required state of the children + /// @param [out] o_children A vector of child target handles + /// + void getChildren(const TargetType i_parentType, + const TargetType i_childType, + const plat_target_type_t i_platType, + const TargetState i_state, + std::vector &o_children) const; + + /// + /// @brief Get proc chip target's children - filtered + /// + /// @param [in] i_filter Target filter + /// @param [in] i_state Required state of the children + /// @param [out] o_children A vector of child target handles + /// + void getChildren(const TargetFilter i_filter, + const TargetState i_state, + std::vector& o_children) const; + + /// + /// @brief Gets the plat target handle as a uint32 + /// + /// @return Plat target handle as a uint32_t + /// + operator uint32_t() const {return value;} + } plat_target_handle_t; + + typedef plat_target_handle_t plat_target_argument_t; + + template + plat_target_handle_t createPlatTargetHandle(const uint32_t i_plat_argument) + { + static_assert((MULTICAST != true) || (K == TARGET_TYPE_PROC_CHIP), + "Only PROC_CHIP types can be multicast"); + plat_target_handle_t l_handle; + + if(MULTICAST == true) + { + // Simply set the is multicast flag + l_handle.fields.is_multicast = 1; + } + else if(K & TARGET_TYPE_PROC_CHIP) + { + l_handle.fields.chiplet_num = 0; + l_handle.fields.type = PPE_TARGET_TYPE_PROC_CHIP; + l_handle.fields.type_target_num = 0; + } + else if(K & TARGET_TYPE_PERV) + { + l_handle.fields.chiplet_num = i_plat_argument + NEST_GROUP1_CHIPLET_OFFSET; + l_handle.fields.type = PPE_TARGET_TYPE_PERV; + l_handle.fields.type_target_num = i_plat_argument; + } + else if(K & TARGET_TYPE_CORE) + { + l_handle.fields.chiplet_num = i_plat_argument + CORE_CHIPLET_OFFSET; + l_handle.fields.type = PPE_TARGET_TYPE_CORE | PPE_TARGET_TYPE_PERV; + l_handle.fields.type_target_num = i_plat_argument; + } + else if(K & TARGET_TYPE_EQ) + { + l_handle.fields.chiplet_num = i_plat_argument + EQ_CHIPLET_OFFSET; + l_handle.fields.type = PPE_TARGET_TYPE_EQ | PPE_TARGET_TYPE_PERV; + l_handle.fields.type_target_num = i_plat_argument; + } + else if(K & TARGET_TYPE_EX) + { + l_handle.fields.chiplet_num = (i_plat_argument / 2) + EX_CHIPLET_OFFSET; + l_handle.fields.type = PPE_TARGET_TYPE_EX; + l_handle.fields.type_target_num = i_plat_argument; + } + else if(K & TARGET_TYPE_MCBIST) + { + l_handle.fields.chiplet_num = i_plat_argument + MCBIST_CHIPLET_OFFSET; + l_handle.fields.type = PPE_TARGET_TYPE_MCBIST | PPE_TARGET_TYPE_PERV; + l_handle.fields.type_target_num = i_plat_argument; + } + else if(K & TARGET_TYPE_MCS) + { + l_handle.fields.chiplet_num = N3_CHIPLET - (MCS_PER_MCBIST * (i_plat_argument / MCS_PER_MCBIST)); + l_handle.fields.type = PPE_TARGET_TYPE_MCS; + l_handle.fields.type_target_num = i_plat_argument; + } + else if(K & TARGET_TYPE_PHB) + { + l_handle.fields.chiplet_num = (0 == i_plat_argument) ? PCI0_CHIPLET : + (((i_plat_argument / 3) + 1) + PCI0_CHIPLET); + l_handle.fields.type = PPE_TARGET_TYPE_PHB; + l_handle.fields.type_target_num = i_plat_argument; + } + else if(K == TARGET_TYPE_ALL) + { + l_handle.fields.chiplet_num = i_plat_argument; + l_handle.fields.type = PPE_TARGET_TYPE_ALL; + } + + l_handle.fields.valid = 1; + return l_handle; + } + +}; + +#endif diff --git a/src/hwpf/plat_target_definitions.H b/src/hwpf/plat_target_definitions.H new file mode 100644 index 00000000..cf2112a3 --- /dev/null +++ b/src/hwpf/plat_target_definitions.H @@ -0,0 +1,111 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/hwpf/plat_target_definitions.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2012,2017 */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +/** + * @file plat_ppe_target.H + * @brief Definitions for fapi2 PPE targets + */ + +#ifndef __FAPI2_PPE_TARGET__ +#define __FAPI2_PPE_TARGET__ + +#define TARGET_CHIP(_name, _index) \ + fapi2::Target _name((uint64_t)_index); + +#define TARGET_CHIP_PERV(_name, _index) \ + fapi2::Target _name((uint64_t)_index); + +#define TARGET_EQ(_name, _index) \ + fapi2::Target _name((uint64_t)_index); + +#define TARGET_CORE(_name, _index) \ + fapi2::Target _name((uint64_t)_index); + +#define TARGET_EX(_name, _index) \ + fapi2::Target _name((uint64_t)_index); + +namespace fapi2 +{ + + TARGET_CHIP (chip_target, 0); + TARGET_CHIP_PERV (perv_target, 1); + TARGET_CHIP_PERV (n0_target, 2); + TARGET_CHIP_PERV (n1_target, 3); + TARGET_CHIP_PERV (n2_target, 4); + TARGET_CHIP_PERV (n3_target, 5); + TARGET_CHIP_PERV (xb_target, 6); + TARGET_CHIP_PERV (mc0_target, 7); + TARGET_CHIP_PERV (mc1_target, 8); + TARGET_CHIP_PERV (ob0_target, 9); + TARGET_CHIP_PERV (ob1_target, 10); + TARGET_CHIP_PERV (ob2_target, 11); + TARGET_CHIP_PERV (ob3_target, 12); + TARGET_CHIP_PERV (pci0_target, 13); + TARGET_CHIP_PERV (pci1_target, 14); + TARGET_CHIP_PERV (pci2_target, 15); + TARGET_EQ (eq0_target, 0); + TARGET_EQ (eq1_target, 1); + TARGET_EQ (eq2_target, 2); + TARGET_EQ (eq3_target, 3); + TARGET_EQ (eq4_target, 4); + TARGET_EQ (eq5_target, 5); + TARGET_EX (ex0_target, 0); + TARGET_EX (ex1_target, 1); + TARGET_EX (ex2_target, 2); + TARGET_EX (ex3_target, 3); + TARGET_EX (ex4_target, 4); + TARGET_EX (ex5_target, 5); + TARGET_EX (ex6_target, 6); + TARGET_EX (ex7_target, 7); + TARGET_EX (ex8_target, 8); + TARGET_EX (ex9_target, 9); + TARGET_EX (ex10_target, 10); + TARGET_EX (ex11_target, 11); + TARGET_CORE (core0_target, 0); + TARGET_CORE (core1_target, 1); + TARGET_CORE (core2_target, 2); + TARGET_CORE (core3_target, 3); + TARGET_CORE (core4_target, 4); + TARGET_CORE (core5_target, 5); + TARGET_CORE (core6_target, 6); + TARGET_CORE (core7_target, 7); + TARGET_CORE (core8_target, 8); + TARGET_CORE (core9_target, 9); + TARGET_CORE (core10_target,10); + TARGET_CORE (core11_target,11); + TARGET_CORE (core12_target,12); + TARGET_CORE (core13_target,13); + TARGET_CORE (core14_target,14); + TARGET_CORE (core15_target,15); + TARGET_CORE (core16_target,16); + TARGET_CORE (core17_target,17); + TARGET_CORE (core18_target,18); + TARGET_CORE (core19_target,19); + TARGET_CORE (core20_target,20); + TARGET_CORE (core21_target,21); + TARGET_CORE (core22_target,22); + TARGET_CORE (core23_target,23); + +}; // fapi2 namespace + +#endif // __FAPI2_PPE_TARGET__ diff --git a/src/hwpf/plat_target_filter.H b/src/hwpf/plat_target_filter.H new file mode 100644 index 00000000..e620dd70 --- /dev/null +++ b/src/hwpf/plat_target_filter.H @@ -0,0 +1,89 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/hwpf/plat_target_filter.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2016,2017 */ +/* */ +/* */ +/* 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 */ +#ifndef __FAPI2_PLAT_TARGET_FILTER__ +#define __FAPI2_PLAT_TARGET_FILTER__ + +#include + +// +// Define TargetFilter enum values for the platform +// +namespace fapi2 +{ +namespace PlatTargetFilter +{ +// These values must contain only 1 bit 'on' so that they can be ORed +// together as composite filters + +constexpr uint64_t PLAT_TARGET_FILTER_TP = 0x8000000000000000; // Pervasive 1 +constexpr uint64_t PLAT_TARGET_FILTER_NEST_NORTH = 0x4000000000000000; // Pervasive 2 +constexpr uint64_t PLAT_TARGET_FILTER_NEST_EAST = 0x2000000000000000; // Pervasive 3 +constexpr uint64_t PLAT_TARGET_FILTER_NEST_SOUTH = 0x1000000000000000; // Pervasive 4 +constexpr uint64_t PLAT_TARGET_FILTER_NEST_WEST = 0x0800000000000000; // Pervasive 5 +constexpr uint64_t PLAT_TARGET_FILTER_XBUS = 0x0400000000000000; // Pervasive 6 +constexpr uint64_t PLAT_TARGET_FILTER_MC_WEST = 0x0200000000000000; // Pervasive 7 +constexpr uint64_t PLAT_TARGET_FILTER_MC_EAST = 0x0100000000000000; // Pervasive 8 +constexpr uint64_t PLAT_TARGET_FILTER_OBUS0 = 0x0080000000000000; // Pervasive 9 +constexpr uint64_t PLAT_TARGET_FILTER_OBUS1 = 0x0040000000000000; // Pervasive 10 +constexpr uint64_t PLAT_TARGET_FILTER_OBUS2 = 0x0020000000000000; // Pervasive 11 +constexpr uint64_t PLAT_TARGET_FILTER_OBUS3 = 0x0010000000000000; // Pervasive 12 +constexpr uint64_t PLAT_TARGET_FILTER_PCI0 = 0x0008000000000000; // Pervasive 13 +constexpr uint64_t PLAT_TARGET_FILTER_PCI1 = 0x0004000000000000; // Pervasive 14 +constexpr uint64_t PLAT_TARGET_FILTER_PCI2 = 0x0002000000000000; // Pervasive 15 +constexpr uint64_t PLAT_TARGET_FILTER_CACHE0 = 0x0001000000000000; // Pervasive 16 +constexpr uint64_t PLAT_TARGET_FILTER_CACHE1 = 0x0000800000000000; // Pervasive 17 +constexpr uint64_t PLAT_TARGET_FILTER_CACHE2 = 0x0000400000000000; // Pervasive 18 +constexpr uint64_t PLAT_TARGET_FILTER_CACHE3 = 0x0000200000000000; // Pervasive 19 +constexpr uint64_t PLAT_TARGET_FILTER_CACHE4 = 0x0000100000000000; // Pervasive 20 +constexpr uint64_t PLAT_TARGET_FILTER_CACHE5 = 0x0000080000000000; // Pervasive 21 +constexpr uint64_t PLAT_TARGET_FILTER_CORE0 = 0x0000040000000000; // Pervasive 32 +constexpr uint64_t PLAT_TARGET_FILTER_CORE1 = 0x0000020000000000; // Pervasive 33 +constexpr uint64_t PLAT_TARGET_FILTER_CORE2 = 0x0000010000000000; // Pervasive 34 +constexpr uint64_t PLAT_TARGET_FILTER_CORE3 = 0x0000008000000000; // Pervasive 35 +constexpr uint64_t PLAT_TARGET_FILTER_CORE4 = 0x0000004000000000; // Pervasive 36 +constexpr uint64_t PLAT_TARGET_FILTER_CORE5 = 0x0000002000000000; // Pervasive 37 +constexpr uint64_t PLAT_TARGET_FILTER_CORE6 = 0x0000001000000000; // Pervasive 38 +constexpr uint64_t PLAT_TARGET_FILTER_CORE7 = 0x0000000800000000; // Pervasive 39 +constexpr uint64_t PLAT_TARGET_FILTER_CORE8 = 0x0000000400000000; // Pervasive 40 +constexpr uint64_t PLAT_TARGET_FILTER_CORE9 = 0x0000000200000000; // Pervasive 41 +constexpr uint64_t PLAT_TARGET_FILTER_CORE10 = 0x0000000100000000; // Pervasive 42 +constexpr uint64_t PLAT_TARGET_FILTER_CORE11 = 0x0000000080000000; // Pervasive 43 +constexpr uint64_t PLAT_TARGET_FILTER_CORE12 = 0x0000000040000000; // Pervasive 44 +constexpr uint64_t PLAT_TARGET_FILTER_CORE13 = 0x0000000020000000; // Pervasive 45 +constexpr uint64_t PLAT_TARGET_FILTER_CORE14 = 0x0000000010000000; // Pervasive 46 +constexpr uint64_t PLAT_TARGET_FILTER_CORE15 = 0x0000000008000000; // Pervasive 47 +constexpr uint64_t PLAT_TARGET_FILTER_CORE16 = 0x0000000004000000; // Pervasive 48 +constexpr uint64_t PLAT_TARGET_FILTER_CORE17 = 0x0000000002000000; // Pervasive 49 +constexpr uint64_t PLAT_TARGET_FILTER_CORE18 = 0x0000000001000000; // Pervasive 50 +constexpr uint64_t PLAT_TARGET_FILTER_CORE19 = 0x0000000000800000; // Pervasive 51 +constexpr uint64_t PLAT_TARGET_FILTER_CORE20 = 0x0000000000400000; // Pervasive 52 +constexpr uint64_t PLAT_TARGET_FILTER_CORE21 = 0x0000000000200000; // Pervasive 53 +constexpr uint64_t PLAT_TARGET_FILTER_CORE22 = 0x0000000000100000; // Pervasive 54 +constexpr uint64_t PLAT_TARGET_FILTER_CORE23 = 0x0000000000080000; // Pervasive 55 + +} // namespace PlatTargetFilter + +} // namespace fapi2 + +#endif diff --git a/src/hwpf/plat_target_parms.H b/src/hwpf/plat_target_parms.H new file mode 100644 index 00000000..1a8fe9fa --- /dev/null +++ b/src/hwpf/plat_target_parms.H @@ -0,0 +1,100 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/hwpf/plat_target_parms.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2012,2017 */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +/** + * @file plat_ppe_target.H + * @brief Definitions for fapi2 PPE targets + */ + +#ifndef __FAPI2_PPE_TARGET_PARMS__ +#define __FAPI2_PPE_TARGET_PARMS__ + +#include "fapi_sbe_common.H" + + +CONST_UINT32_T(CHIP_TARGET_OFFSET, 0); +CONST_UINT32_T(CHIP_TARGET_COUNT , 1); + +// Nest targets - Group 1 +CONST_UINT32_T(NEST_GROUP1_TARGET_OFFSET, CHIP_TARGET_OFFSET + CHIP_TARGET_COUNT); +CONST_UINT32_T(NEST_GROUP1_CHIPLET_OFFSET, 0x1); +CONST_UINT32_T(NEST_GROUP1_TARGET_COUNT, 6); + +// MCBIST targets +CONST_UINT32_T(MCBIST_TARGET_OFFSET, NEST_GROUP1_TARGET_OFFSET + NEST_GROUP1_TARGET_COUNT); +CONST_UINT32_T(MCBIST_CHIPLET_OFFSET, 0x7); +CONST_UINT32_T(MCBIST_TARGET_COUNT, 2); + +// Nest targets - Group 2 +CONST_UINT32_T(NEST_GROUP2_TARGET_OFFSET, MCBIST_TARGET_OFFSET + MCBIST_TARGET_COUNT); +CONST_UINT32_T(NEST_GROUP2_TARGET_COUNT, 7); +CONST_UINT32_T(NEST_GROUP2_CHIPLET_OFFSET, 0x9); + +// Cache Targets +CONST_UINT32_T(EQ_TARGET_OFFSET, NEST_GROUP2_TARGET_OFFSET + NEST_GROUP2_TARGET_COUNT); +CONST_UINT32_T(EQ_CHIPLET_OFFSET, 0x10); +CONST_UINT32_T(EQ_TARGET_COUNT, 6); + +// Core Targets +CONST_UINT32_T(CORE_TARGET_OFFSET, EQ_TARGET_OFFSET + EQ_TARGET_COUNT); +CONST_UINT32_T(CORE_CHIPLET_OFFSET, 0x20); +CONST_UINT32_T(CORE_TARGET_COUNT, 24); + +// Ex Targets +CONST_UINT32_T(EX_TARGET_OFFSET, CORE_TARGET_OFFSET + CORE_TARGET_COUNT); +CONST_UINT32_T(EX_CHIPLET_OFFSET, 0x10); +CONST_UINT32_T(EX_TARGET_COUNT, 12); + +// MCS Targets +CONST_UINT32_T(MCS_TARGET_OFFSET, EX_TARGET_OFFSET + EX_TARGET_COUNT); +CONST_UINT32_T(MCS_TARGET_COUNT, 4); + +// PHB Targets +CONST_UINT32_T(PHB_TARGET_OFFSET, MCS_TARGET_OFFSET + MCS_TARGET_COUNT); +CONST_UINT32_T(PHB_TARGET_COUNT, 6); + +// System Target +CONST_UINT32_T(SYSTEM_TARGET_OFFSET, PHB_TARGET_OFFSET + PHB_TARGET_COUNT); +CONST_UINT32_T(SYSTEM_TARGET_COUNT, 1); + +CONST_UINT32_T(MCAST_TARGET_OFFSET, SYSTEM_TARGET_OFFSET + SYSTEM_TARGET_COUNT); +CONST_UINT32_T(MCAST_CHIPLET_OFFSET, 4); +CONST_UINT32_T(MCAST_TARGET_COUNT, 3); // PPE only needs multicast groups 4-6 + +// Total number of pervasive targets (Both NEST groups + EQs + COREs +MCBISTs) +CONST_UINT32_T(PERV_TARGET_COUNT, NEST_GROUP1_TARGET_COUNT + NEST_GROUP2_TARGET_COUNT + + MCBIST_TARGET_COUNT + EQ_TARGET_COUNT + CORE_TARGET_COUNT); + +// Total Target Count +CONST_UINT32_T(TARGET_COUNT, CHIP_TARGET_COUNT + + PERV_TARGET_COUNT + + EX_TARGET_COUNT + + MCS_TARGET_COUNT + + PHB_TARGET_COUNT + + SYSTEM_TARGET_COUNT + + MCAST_TARGET_COUNT); + +// Maximum possible Pervasive chiplets +CONST_UINT32_T(MAX_PERV_CHIPLETS, 64); + +#endif // __FAPI2_PPE_TARGET_PARMS__ diff --git a/src/hwpf/plat_target_utils.H b/src/hwpf/plat_target_utils.H new file mode 100644 index 00000000..0c54e2cc --- /dev/null +++ b/src/hwpf/plat_target_utils.H @@ -0,0 +1,88 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/hwpf/plat_target_utils.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2012,2017 */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +/** + * @file plat_target_util.H + * @brief platform utility definitions for fapi2 targets + */ + +#ifndef __FAPI2_PLAT_TARGET_UTIL__ +#define __FAPI2_PLAT_TARGET_UTIL__ + +#include + +#pragma pack(8) //Start of packing to 8byte boundary + typedef struct { + fapi2attr::SystemAttributes_t G_system_attrs; + fapi2attr::ProcChipAttributes_t G_proc_chip_attrs; + fapi2attr::PervAttributes_t G_perv_attrs; + fapi2attr::CoreAttributes_t G_core_attrs; + fapi2attr::EXAttributes_t G_ex_attrs; + fapi2attr::EQAttributes_t G_eq_attrs; + } G_sbe_attrs_t; +#pragma pack()//End of packing to 8byte boundary + +// +// Platform Utility functions.. +// +namespace fapi2 +{ + /// @brief Function to initialize the G_targets vector based on partial good + /// attributes + ReturnCode plat_TargetsInit(); + + /// @brief Function to apply any gard records set (via + // ATTR_EQ_GARD/ATTR_EC_GARD) to mark corresponding targets non functional + ReturnCode plat_ApplyGards(); + + /// @brief Function to initialize the G_targets vector based on partial good + /// attributes + Target plat_getChipTarget(); + + /// @brief Function to return a platform target handle, given the chiplet + // number and the fapi2 Target type + // @tparam K The fapi2 TargetType + // @param i_chipletNumber The chiplet number of the target + // @return Platform handle + // @note The caller can use the platform handle to construct a Target of + // it's choice. Ex: + // fapi2::Target + // l_core(plat_getTargetHandleByChipletNumber(0x20); + template + plat_target_handle_t plat_getTargetHandleByChipletNumber( + const uint8_t i_chipletNumber); + + /// @brief Function to return a platform target handle, given the target + /// instance number and the fapi2 Target type + // @tparam K The fapi2 TargetType + // @param i_targetNum The instance number for the target + // @return Platform handle + // @note The caller can use the platform handle to construct a Target of + // it's choice. Ex: + // fapi2::Target + // l_ex(plat_getTargetHandleByInstance(0); + template + plat_target_handle_t plat_getTargetHandleByInstance( + const uint8_t i_targetNum); +} +#endif diff --git a/src/hwpf/plat_trace.H b/src/hwpf/plat_trace.H new file mode 100644 index 00000000..8a9344c6 --- /dev/null +++ b/src/hwpf/plat_trace.H @@ -0,0 +1,113 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/hwpf/plat_trace.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2011,2017 */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +/** + * @file plat_trace.H + * @brief Defines the FAPI2 trace macros. + * + * Note that platform code must provide the implementation. + * + * FAPI has provided a default implementation. Platform code must + * provide an alternate implementation if needed. + */ + +#ifndef FAPI2_PLATTRACE_H_ +#define FAPI2_PLATTRACE_H_ + +#include + +// @todo update these headers with extern "C" in a future commit +// or not and leave this just as it is. +extern "C" +{ +#include "pk.h" +#include +#include "trac_interface.h" +} + +// Why not a #define, why is this in the fapi2 namespace? +// To prevent problems with Cronus and the fapi1 definitions. +namespace fapi2 +{ + static const uint32_t MAX_ECMD_STRING_LEN = 64; +}; + +// Information traces (go into fast trace buffer that can wrap often) +#define FAPI_TRACE(_id_, _fmt_, _args_...) \ + PK_TRACE(_fmt_, ##_args_); + + +/* The following is a desirous trace entry but the second line has a + compilation issue that is unresolved + +#define FAPI_TRACE(_id_, _fmt_, _args_...) \ + PK_TRACE("%s: %s:%d ", _id_, __FUNCTION__, __LINE__); \ + PK_TRACE(_fmt_, ##_args_); +*/ +// FAPI_TRACE_LEVEL controls what traces are included in the code build +// 0 == No tracing +// 1 == ERR traces only +// 2 == ERR and IMP only +// 3 == ERR, IMP and INF only. This is the default in Makefile +// > 4 == All traces (ERR, IMP, INF, DBG, SCAN, MFG) +#if (FAPI_TRACE_LEVEL >= 3) +#define FAPI_INF(_fmt_, _args_...) FAPI_TRACE("inf", _fmt_, ##_args_) +#else +#define FAPI_INF(_fmt_, _args_...) +#endif + +// Important traces (go into slow trace buffer that should not wrap often) +#if (FAPI_TRACE_LEVEL >= 2) +#define FAPI_IMP(_fmt_, _args_...) FAPI_TRACE("imp", _fmt_, ##_args_) +#else +#define FAPI_IMP(_fmt_, _args_...) +#endif + +// Error traces (go into slow trace buffer that should not wrap often) +#if (FAPI_TRACE_LEVEL >= 1) +#define FAPI_ERR(_fmt_, _args_...) FAPI_TRACE("err", _fmt_, ##_args_) +#else +#define FAPI_ERR(_fmt_, _args_...) +#endif + +// Debug traces (go into fast trace buffer that can wrap often) +#if (FAPI_TRACE_LEVEL >= 4) +#define FAPI_DBG(_fmt_, _args_...) FAPI_TRACE("dbg", _fmt_, ##_args_) +#else +#define FAPI_DBG(_fmt_, _args_...) +#endif + +// Scan traces +#if (FAPI_TRACE_LEVEL >= 4) +#define FAPI_SCAN(_fmt_, _args_...) FAPI_TRACE("scan", _fmt_, ##_args_) +#else +#define FAPI_SCAN(_fmt_, _args_...) +#endif + +#if (FAPI_TRACE_LEVEL >= 4) +#define FAPI_MFG(_fmt_, _args_...) FAPI_TRACE("mfg", _fmt_, ##_args_) +#else +#define FAPI_MFG(_fmt_, _args_...) +#endif + +#endif // FAPI2_PLATTRACE_H_ diff --git a/src/hwpf/plat_utils.C b/src/hwpf/plat_utils.C new file mode 100644 index 00000000..4e4024e7 --- /dev/null +++ b/src/hwpf/plat_utils.C @@ -0,0 +1,196 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/hwpf/plat_utils.C $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2015,2017 */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ + +/** + * @file plat_utils.C + * @brief Implements fapi2 common utilities + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace fapi2 +{ + + // Define own function rather than using PK function + // This is required as PK function does not scale well for low + // frequency till istep 2.7 + inline uint64_t delayCycles(uint64_t i_nanoSeconds ) + { + return ( i_nanoSeconds/1000) * ( SBE_GLOBAL->sbefreq /(1000*1000)); + } + /// @brief Delay this thread. + /// + ReturnCode delay(uint64_t i_nanoSeconds, uint64_t i_simCycles, bool i_fixed /* = false*/) + { + // void statements to keep the compiler from complaining + // about unused variables. + static_cast(i_nanoSeconds); + static_cast(i_simCycles); + + +#ifndef __FAPI_DELAY_SIM__ + + PkTimebase target_time; + PkTimebase current_time; + PkMachineContext ctx; + + + // Only execute if nanoSeconds is non-zero (eg a real wait) + if (i_nanoSeconds) + { + // The critical section enter/exit set is done to ensure the timebase + // operations are non-interrupible. + + pk_critical_section_enter(&ctx); + + target_time = pk_timebase_get() + delayCycles( i_nanoSeconds); + + do + { + current_time = pk_timebase_get(); + } while (target_time > current_time); + + pk_critical_section_exit(&ctx); + } +#else + + // Execute a tight loop that simply counts down the i_simCycles + // value. + + // @todo This can might be optimized with a fused compare branch loop + // Note, though, that subwibnz instruction is optimized for word + // operations. i_simCycles are uint64_t values so the upper + // word values needs to be accounted for. + // + // Need to determine if this optimization is worth the effort. + +#ifndef __FAPI_DELAY_PPE_SIM_CYCLES__ +#define __FAPI_DELAY_PPE_SIM_CYCLES__ 8 +#endif + + static const uint8_t NUM_OVERHEAD_INSTRS = 15; + static const uint8_t NUM_LOOP_INSTRS = 4; + static const uint64_t MIN_DELAY_CYCLES = + ((NUM_OVERHEAD_INSTRS + NUM_LOOP_INSTRS) * __FAPI_DELAY_PPE_SIM_CYCLES__); + + uint64_t l_adjusted_simcycles; + + if (i_simCycles < MIN_DELAY_CYCLES) + l_adjusted_simcycles = MIN_DELAY_CYCLES; + else + l_adjusted_simcycles = i_simCycles; + + uint64_t delay_loop_count = + ((l_adjusted_simcycles - (NUM_OVERHEAD_INSTRS * __FAPI_DELAY_PPE_SIM_CYCLES__)) / + (NUM_LOOP_INSTRS * __FAPI_DELAY_PPE_SIM_CYCLES__)); + + for (auto i = delay_loop_count; i > 0; --i) { + // Force compiler not to optimize for loop + asm(""); + } + +#endif + + // replace with platform specific implementation + return FAPI2_RC_SUCCESS; + } + + /// + /// @brief Queries the ATTR_NAME and ATTR_EC attributes + /// + void queryChipEcAndName( + const Target < fapi2::TARGET_TYPE_PROC_CHIP > & i_target, + fapi2::ATTR_NAME_Type& o_chipName, fapi2::ATTR_EC_Type& o_chipEc ) + { + + FAPI_ATTR_GET_PRIVILEGED(fapi2::ATTR_NAME, i_target, o_chipName); + + FAPI_ATTR_GET_PRIVILEGED(fapi2::ATTR_EC, i_target, o_chipEc); + } +}; + +#ifndef _BIG_ENDIAN + +/// Byte-reverse a 16-bit integer if on a little-endian machine + +uint16_t +revle16(uint16_t i_x) +{ + uint16_t rx; + uint8_t *pix = (uint8_t*)(&i_x); + uint8_t *prx = (uint8_t*)(&rx); + + prx[0] = pix[1]; + prx[1] = pix[0]; + + return rx; +} + +/// Byte-reverse a 32-bit integer if on a little-endian machine + +uint32_t +revle32(uint32_t i_x) +{ + uint32_t rx; + uint8_t *pix = (uint8_t*)(&i_x); + uint8_t *prx = (uint8_t*)(&rx); + + prx[0] = pix[3]; + prx[1] = pix[2]; + prx[2] = pix[1]; + prx[3] = pix[0]; + + return rx; +} + + +/// Byte-reverse a 64-bit integer if on a little-endian machine + +uint64_t +revle64(const uint64_t i_x) +{ + uint64_t rx; + uint8_t *pix = (uint8_t*)(&i_x); + uint8_t *prx = (uint8_t*)(&rx); + + prx[0] = pix[7]; + prx[1] = pix[6]; + prx[2] = pix[5]; + prx[3] = pix[4]; + prx[4] = pix[3]; + prx[5] = pix[2]; + prx[6] = pix[1]; + prx[7] = pix[0]; + + return rx; +} +#endif + diff --git a/src/hwpf/plat_utils.H b/src/hwpf/plat_utils.H new file mode 100644 index 00000000..960aba0a --- /dev/null +++ b/src/hwpf/plat_utils.H @@ -0,0 +1,65 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/hwpf/plat_utils.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2016,2017 */ +/* */ +/* */ +/* 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 */ +#ifndef _PLAT_UTILS_H_ +#define _PLAT_UTILS_H_ + +#ifdef __ASSEMBLER__ + +#ifndef ULL +#define ULL(x) x +#endif + +#else + +#ifndef ULL +#define ULL(x) x##ull + +#endif + +#endif // __ASSEMBLER + +/// Create a multi-bit mask of \a n bits starting at bit \a b +#ifndef BITS + #define BITS(b, n) ((ULL(0xffffffffffffffff) << (64 - (n))) >> (b)) +#endif + +/// Create a single bit mask at bit \a b +#ifndef BIT + #define BIT(b) BITS((b), 1) +#endif + +#ifdef _BIG_ENDIAN + +#define revle16(x) x +#define revle32(x) x +#define revle64(x) x + +#else + +uint16_t revle16(uint16_t i_x); +uint32_t revle32(uint32_t i_x); +uint64_t revle64(uint64_t i_x); + +#endif +#endif //_PLAT_UTILS_H_ diff --git a/src/hwpf/src/Makefile b/src/hwpf/src/Makefile deleted file mode 100644 index 4377a865..00000000 --- a/src/hwpf/src/Makefile +++ /dev/null @@ -1,52 +0,0 @@ -# IBM_PROLOG_BEGIN_TAG -# This is an automatically generated prolog. -# -# $Source: src/hwpf/src/Makefile $ -# -# OpenPOWER sbe Project -# -# Contributors Listed Below - COPYRIGHT 2015,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 -# This Makefile is designed to be invoked with the -I argument - -export SUB_OBJDIR = /fapi2 - -include img_defs.mk -include fapi2sbefiles.mk - - -OBJS := $(addprefix $(OBJDIR)/, $(FAPI2LIB_OBJECTS)) - -libfapi2.a: fapi2 hwpf plat - $(AR) crs $(OBJDIR)/libfapi2.a $(OBJDIR)/*.o - -.PHONY: clean fapi2 hwpf plat -fapi2: $(OBJS) - -plat: - $(MAKE) -I $(BUILD_DIR) -C $(PLAT_FAPI2_DIR)/src/plat - -$(OBJS) $(OBJS:.o=.d): | $(OBJDIR) - -$(OBJDIR): - mkdir -p $(OBJDIR) - -ifneq ($(MAKECMDGOALS),clean) -include $(OBJS:.o=.d) -endif - diff --git a/src/hwpf/src/fapi2sbefiles.mk b/src/hwpf/src/fapi2sbefiles.mk deleted file mode 100644 index e1bdf683..00000000 --- a/src/hwpf/src/fapi2sbefiles.mk +++ /dev/null @@ -1,50 +0,0 @@ -# IBM_PROLOG_BEGIN_TAG -# This is an automatically generated prolog. -# -# $Source: src/hwpf/src/fapi2sbefiles.mk $ -# -# OpenPOWER sbe Project -# -# Contributors Listed Below - COPYRIGHT 2015,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 fapi2ppefiles.mk -# -# @brief mk for including fapi2 object files -# -# @page ChangeLogs Change Logs -# @section fapi2ppefiles.mk -# @verbatim -# -# -# Change Log ****************************************************************** -# Flag Defect/Feature User Date Description -# ------ -------------- ---------- ------------ ----------- -# -# @endverbatim -# -########################################################################## -# Object Files -########################################################################## - -FAPI2-C-SOURCES += ffdc.C -FAPI2-C-SOURCES += plat_ring_traverse.C -FAPI2-S-SOURCES = - - -FAPI2LIB_OBJECTS += $(FAPI2-C-SOURCES:.C=.o) $(FAPI2-S-SOURCES:.S=.o) - diff --git a/src/hwpf/src/ffdc.C b/src/hwpf/src/ffdc.C deleted file mode 100644 index e8242f2a..00000000 --- a/src/hwpf/src/ffdc.C +++ /dev/null @@ -1,42 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/hwpf/src/ffdc.C $ */ -/* */ -/* 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 ffdc.C - * @brief Implements the ffdc for sbe - */ - -#include -#include - - -namespace fapi2 -{ - -#ifdef MINIMUM_FFDC - // buffer used to hold ffdc data - SbeFfdcData_t g_FfdcData; -#endif - -}; diff --git a/src/hwpf/src/plat/Makefile b/src/hwpf/src/plat/Makefile deleted file mode 100644 index c121f162..00000000 --- a/src/hwpf/src/plat/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -# IBM_PROLOG_BEGIN_TAG -# This is an automatically generated prolog. -# -# $Source: src/hwpf/src/plat/Makefile $ -# -# 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 -# This Makefile is designed to be invoked with the -I argument -include img_defs.mk -include fapi2sbeplatfiles.mk - -OBJS := $(addprefix $(OBJDIR)/, $(FAPI2PLATLIB_OBJECTS)) - -all: $(OBJS) - - -$(OBJS) $(OBJS:.o=.d): | $(OBJDIR) - -$(OBJDIR): - mkdir -p $(OBJDIR) - -ifneq ($(MAKECMDGOALS),clean) -include $(OBJS:.o=.d) -endif - diff --git a/src/hwpf/src/plat/fapi2sbeplatfiles.mk b/src/hwpf/src/plat/fapi2sbeplatfiles.mk deleted file mode 100644 index b931f847..00000000 --- a/src/hwpf/src/plat/fapi2sbeplatfiles.mk +++ /dev/null @@ -1,53 +0,0 @@ -# IBM_PROLOG_BEGIN_TAG -# This is an automatically generated prolog. -# -# $Source: src/hwpf/src/plat/fapi2sbeplatfiles.mk $ -# -# OpenPOWER sbe Project -# -# Contributors Listed Below - COPYRIGHT 2015,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 fapi2ppefiles.mk -# -# @brief mk for including fapi2 object files -# -# @page ChangeLogs Change Logs -# @section fapi2ppefiles.mk -# @verbatim -# -# -# Change Log ****************************************************************** -# Flag Defect/Feature User Date Description -# ------ -------------- ---------- ------------ ----------- -# -# @endverbatim -# -########################################################################## -# Object Files -########################################################################## - -FAPI2PLAT-CPP-SOURCES += plat_hw_access.C -FAPI2PLAT-CPP-SOURCES += plat_utils.C -FAPI2PLAT-CPP-SOURCES += target.C - -FAPI2PLAT-C-SOURCES = -FAPI2PLAT-S-SOURCES = - - -FAPI2PLATLIB_OBJECTS += $(FAPI2PLAT-CPP-SOURCES:.C=.o) $(FAPI2PLAT-C-SOURCES:.c=.o) $(FAPI2PLAT-S-SOURCES:.S=.o) - diff --git a/src/hwpf/src/plat/plat_attribute_service.H b/src/hwpf/src/plat/plat_attribute_service.H deleted file mode 100644 index 008132c3..00000000 --- a/src/hwpf/src/plat/plat_attribute_service.H +++ /dev/null @@ -1,1442 +0,0 @@ -/* 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,2017 */ -/* [+] International Business Machines Corp. */ -/* */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ -/* implied. See the License for the specific language governing */ -/* permissions and limitations under the License. */ -/* */ -/* IBM_PROLOG_END_TAG */ -/** - * @file 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) - -#define PLAT_ATTR_INIT(ID, TARGET, VAL) \ - (fapi2::checkIdType(ID, VAL), \ - ID##_PLAT_INIT(ID, TARGET, 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##TargetType), ID> \ - (ID, PTARGET, VAL) - -/* global set uint8_t 1D array macro */ -#define PLAT_ATTR_SET_UINT8_1D_ARRAY(ID, PTARGET, VAL) \ - _setAttributeArrayShort(ID##TargetType), 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##_TargetType), 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##_TargetType), 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 ); - -#define ATTR_CHIP_UNIT_POS_GETMACRO PLAT_ATTR_GET_CHIP_UNIT_POS - -#define PLAT_ATTR_GET_CHIP_UNIT_POS(ID, PTARGET, VAL) \ - _getAttrChipUnitPos(PTARGET, VAL) - -template -inline -AttributeRC _getAttrChipUnitPos(const Target& i_target, - ATTR_CHIP_UNIT_POS_Type& o_val) -{ - o_val = i_target.get().getTargetInstance(); - return FAPI2_RC_SUCCESS; -} - -template<> -inline -AttributeRC _getAttrChipUnitPos(const Target& i_target, - ATTR_CHIP_UNIT_POS_Type& o_val) -{ - o_val = i_target.getChipletNumber(); - return FAPI2_RC_SUCCESS; -} - -/* INSERT NEW GETTER AND SETTER FUNCTIONS HERE */ - - - -//****************************************************************************** -// Get base template -//****************************************************************************** -template -AttributeRC _get(const AttributeId i_id, - const Target & i_pTarget, - T& o_value) -{ - return FAPI2_RC_SUCCESS; -} - -//****************************************************************************** -// Get uint8_t -//****************************************************************************** -template -AttributeRC _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 -AttributeRC _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 -AttributeRC _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 -AttributeRC _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 -AttributeRC _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 -AttributeRC _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 -AttributeRC _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 -AttributeRC _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 -AttributeRC _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 -AttributeRC _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 -AttributeRC _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 -AttributeRC _getAttributeArrayWord(const AttributeId i_id, - const Target & i_pTarget, - uint16_t * o_pValues) -{ - return FAPI2_RC_SUCCESS; -} - -//****************************************************************************** -// Set uint16_t array -//****************************************************************************** -template -AttributeRC _setAttributeArrayWord(const AttributeId i_id, - const Target & i_pTarget, - uint16_t * i_pValues) -{ - return FAPI2_RC_SUCCESS; -} - -//****************************************************************************** -// Get uint32_t array -//****************************************************************************** -template -AttributeRC _getAttributeArrayWord(const AttributeId i_id, - const Target & i_pTarget, - uint32_t * o_pValues) -{ - return FAPI2_RC_SUCCESS; -} - -//****************************************************************************** -// Set uint32_t array -//****************************************************************************** -template -AttributeRC _setAttributeArrayWord(const AttributeId i_id, - const Target & i_pTarget, - uint32_t * i_pValues) -{ - return FAPI2_RC_SUCCESS; -} - - -//****************************************************************************** -// Get uint64_t array -//****************************************************************************** -template -AttributeRC _getAttributeArrayDoubleWord(const AttributeId i_id, - const Target & i_pTarget, - uint64_t * o_pValues) -{ - return FAPI2_RC_SUCCESS; -} - -//****************************************************************************** -// Set uint64_t array -//****************************************************************************** -template -AttributeRC _setAttributeArrayDoubleWord(const AttributeId i_id, - const Target & i_pTarget, - uint64_t * i_pValues) -{ - return FAPI2_RC_SUCCESS; -} - -//****************************************************************************** -// Get Override uint8_t array -//****************************************************************************** -template -AttributeRC _getAttributeOverrideArrayShort(const AttributeId i_id, - const Target & i_pTarget, - uint8_t * o_pValues) -{ - return FAPI2_RC_SUCCESS; -} - -//****************************************************************************** -// Get Override uint16_t array -//****************************************************************************** -template -AttributeRC _getAttributeOverrideArrayWord(const AttributeId i_id, - const Target & i_pTarget, - uint16_t * o_pValues) -{ - return FAPI2_RC_SUCCESS; -} - -//****************************************************************************** -// Get Override uint32_t array -//****************************************************************************** -template -AttributeRC _getAttributeOverrideArrayWord(const AttributeId i_id, - const Target & i_pTarget, - uint32_t * o_pValues) -{ - return FAPI2_RC_SUCCESS; -} - -//****************************************************************************** -// Get Override uint64_t array -//****************************************************************************** -template -AttributeRC _getAttributeOverrideArrayDoubleWord(const AttributeId i_id, - const Target & i_pTarget, - uint64_t * o_pValues) -{ - return FAPI2_RC_SUCCESS; -} - - -//****************************************************************************** -// Set base template -//****************************************************************************** -template -AttributeRC _set(const AttributeId i_id, - const Target & i_pTarget, - const T& i_value) -{ - return FAPI2_RC_SUCCESS; -} - - - -//****************************************************************************** -// Set uint8_t -//****************************************************************************** -template -AttributeRC _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 -AttributeRC _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 -AttributeRC _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 -AttributeRC _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 -AttributeRC _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 -AttributeRC _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 -AttributeRC _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 -AttributeRC _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 -AttributeRC _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 -AttributeRC _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 -AttributeRC _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 -AttributeRC _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 -AttributeRC _getAttributeArraySignedShort(const AttributeId i_id, - const Target & i_pTarget, - int8_t * o_pValues) -{ - return FAPI2_RC_SUCCESS; -} - - -//****************************************************************************** -// Set int8_t array -//****************************************************************************** -template -AttributeRC _setAttributeArraySignedShort(const AttributeId i_id, - const Target & i_pTarget, - int8_t * i_pValues) -{ - return FAPI2_RC_SUCCESS; -} - -//****************************************************************************** -// Get int16_t array -//****************************************************************************** -template -AttributeRC _getAttributeArraySignedWord(const AttributeId i_id, - const Target & i_pTarget, - int16_t * o_pValues) -{ - return FAPI2_RC_SUCCESS; -} - - -//****************************************************************************** -// Set int16_t array -//****************************************************************************** -template -AttributeRC _setAttributeArraySignedWord(const AttributeId i_id, - const Target & i_pTarget, - int16_t * i_pValues) -{ - return FAPI2_RC_SUCCESS; -} - -//****************************************************************************** -// Get int32_t array -//****************************************************************************** -template -AttributeRC _getAttributeArraySignedWord(const AttributeId i_id, - const Target & i_pTarget, - int32_t * o_pValues) -{ - return FAPI2_RC_SUCCESS; -} - - -//****************************************************************************** -// Set int32_t array -//****************************************************************************** -template -AttributeRC _setAttributeArraySignedWord(const AttributeId i_id, - const Target & i_pTarget, - int32_t * i_pValues) -{ - return FAPI2_RC_SUCCESS; -} - - -//****************************************************************************** -// Get int64_t array -//****************************************************************************** -template -AttributeRC _getAttributeArraySignedDoubleWord(const AttributeId i_id, - const Target & i_pTarget, - int64_t * o_pValues) -{ - return FAPI2_RC_SUCCESS; -} - -//****************************************************************************** -// Set int64_t array -//****************************************************************************** -template -AttributeRC _setAttributeArraySignedDoubleWord(const AttributeId i_id, - const Target & i_pTarget, - int64_t * i_pValues) -{ - return FAPI2_RC_SUCCESS; -} - -//****************************************************************************** -// Get Override int8_t array -//****************************************************************************** -template -AttributeRC _getAttributeOverrideArraySignedShort(const AttributeId i_id, - const Target & i_pTarget, - int8_t * o_pValues) -{ - return FAPI2_RC_SUCCESS; -} - -//****************************************************************************** -// Get Override int16_t array -//****************************************************************************** -template -AttributeRC _getAttributeOverrideArraySignedWord(const AttributeId i_id, - const Target & i_pTarget, - int16_t * o_pValues) -{ - return FAPI2_RC_SUCCESS; -} - -//****************************************************************************** -// Get Override int32_t array -//****************************************************************************** -template -AttributeRC _getAttributeOverrideArraySignedWord(const AttributeId i_id, - const Target & i_pTarget, - int32_t * o_pValues) -{ - return FAPI2_RC_SUCCESS; -} - - -//****************************************************************************** -// Get Override int64_t array -//****************************************************************************** -template -AttributeRC _getAttributeOverrideArraySignedDoubleWord(const AttributeId i_id, - const Target & i_pTarget, - int64_t * o_pValues) -{ - return FAPI2_RC_SUCCESS; -} - - -//****************************************************************************** -// Set int8_t -//****************************************************************************** -template -AttributeRC _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 -AttributeRC _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 -AttributeRC _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 -AttributeRC _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_hw_access.C b/src/hwpf/src/plat/plat_hw_access.C deleted file mode 100644 index 8508eda1..00000000 --- a/src/hwpf/src/plat/plat_hw_access.C +++ /dev/null @@ -1,358 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/hwpf/src/plat/plat_hw_access.C $ */ -/* */ -/* OpenPOWER sbe Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2016,2017 */ -/* [+] International Business Machines Corp. */ -/* */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ -/* implied. See the License for the specific language governing */ -/* permissions and limitations under the License. */ -/* */ -/* IBM_PROLOG_END_TAG */ - -#include -#include "hw_access.H" -#include "plat_hw_access.H" -#include "p9_perv_scom_addresses.H" -#include - -namespace fapi2 -{ - -struct restoreOpcgRegisters g_opcgData; - -uint64_t decodeScanRegionData(const uint32_t i_ringAddress) -{ - uint32_t l_scan_region = (i_ringAddress & 0x0000FFF0) << 13; - - uint32_t l_scan_type = 0x00008000 >> (i_ringAddress & 0x0000000F); - - // This is special case if encoded type is 0xF - - if ( (i_ringAddress & 0x0000000F) == 0xF) - { - l_scan_type = 0x00008000 | (l_scan_type << 12); - } - uint64_t l_value = l_scan_region; - l_value = (l_value << 32) | l_scan_type; - - return l_value; -} - -ReturnCode getRing_setup(const uint32_t i_ringAddress, - const RingMode i_ringMode) -{ - fapi2::ReturnCode l_rc = FAPI2_RC_SUCCESS; - uint64_t l_scanRegion = 0; - uint32_t l_chipletId = i_ringAddress >> 24; - - Target l_proc = plat_getChipTarget(); - - do - { - l_scanRegion = decodeScanRegionData(i_ringAddress); - - if (i_ringMode & fapi2::RING_MODE_SET_PULSE_SL) - { - l_rc = storeOPCGRegData (l_proc, g_opcgData, l_chipletId); - if(l_rc != fapi2::FAPI2_RC_SUCCESS) - { - break; - } - - l_rc = setupScanRegionForSetPulse(l_proc, l_scanRegion, - i_ringMode,l_chipletId); - if(l_rc != fapi2::FAPI2_RC_SUCCESS) - { - break; - } - } - else - { - // Set up the scan region for the ring. - l_rc = setupScanRegion(l_proc, l_scanRegion, l_chipletId); - if(l_rc != fapi2::FAPI2_RC_SUCCESS) - { - break; - } - } - // Write a 64 bit value for header. - const uint64_t l_header = 0xa5a5a5a5a5a5a5a5; - uint32_t l_scomAddress = 0x0003E000 | (i_ringAddress & 0xFF000000); - l_rc = fapi2::putScom(l_proc, l_scomAddress, l_header); - if(l_rc != fapi2::FAPI2_RC_SUCCESS) - { - break; - } - - }while(0); - - return l_rc; -} - -ReturnCode getRing_verifyAndcleanup(const uint32_t i_ringAddress, - const RingMode i_ringMode) -{ - fapi2::ReturnCode l_rc = FAPI2_RC_SUCCESS; - uint32_t l_chipletId = i_ringAddress >> 24; - - fapi2::Target l_proc; - - do - { - // Verify header - uint64_t l_header = 0xa5a5a5a5a5a5a5a5; - l_rc = verifyHeader(l_proc, l_header, l_chipletId,i_ringMode); - if(l_rc != fapi2::FAPI2_RC_SUCCESS) - { - break; - } - - l_rc = cleanScanRegionandTypeData(l_proc, l_chipletId); - if(l_rc != fapi2::FAPI2_RC_SUCCESS) - { - break; - } - - if (i_ringMode & fapi2::RING_MODE_SET_PULSE_SL) - { - l_rc = restoreOPCGRegData(l_proc, g_opcgData, l_chipletId); - if(l_rc != fapi2::FAPI2_RC_SUCCESS) - { - break; - } - } - - }while(0); - - return l_rc; -} - -static uint32_t getEffectiveAddress(const plat_target_handle_t &i_target, const uint32_t i_addr) -{ - ScomAddr l_addr(i_addr); - switch(i_target.getTargetType()) - { - case PPE_TARGET_TYPE_EX: - if((EQ_CHIPLET_OFFSET <= l_addr.iv_chiplet) && - ((EQ_CHIPLET_OFFSET + EQ_TARGET_COUNT) > l_addr.iv_chiplet)) - { - l_addr.iv_chiplet = i_target.fields.chiplet_num; - l_addr.iv_ring = (l_addr.iv_ring - (l_addr.iv_ring % 2)) + - (i_target.getTargetInstance() % 2); - } - else if ((CORE_CHIPLET_OFFSET <= l_addr.iv_chiplet) && - ((CORE_CHIPLET_OFFSET + CORE_TARGET_COUNT) > l_addr.iv_chiplet)) - { - l_addr.iv_chiplet = CORE_CHIPLET_OFFSET + (l_addr.iv_chiplet % 2) + - (i_target.getTargetInstance() * 2); - } - else - { - assert(false); - } - break; - case PPE_TARGET_TYPE_MCS: - l_addr.iv_chiplet = i_target.fields.chiplet_num; - l_addr.iv_satId = (2 * (i_target.getTargetInstance() % 2)); - break; - case PPE_TARGET_TYPE_PHB: - if(l_addr.iv_chiplet == N2_CHIPLET) - { - if (i_target.getTargetInstance() == 0) - { - l_addr.iv_ring = 0x3; - l_addr.iv_satId = ((l_addr.iv_satId < 4) ? (1) : (4)); - } - else - { - l_addr.iv_ring = (0x3 + (i_target.getTargetInstance() / 3) + 1) & 0xF; - l_addr.iv_satId = ((l_addr.iv_satId < 4) ? (1) : (4)) + - ((i_target.getTargetInstance() % 2) ? (0) : (1)) + - (2 * (i_target.getTargetInstance() / 5)); - } - } - else - { - l_addr.iv_chiplet = i_target.fields.chiplet_num; - if (i_target.getTargetInstance() == 0) - { - l_addr.iv_satId = ((l_addr.iv_satId < 4) ? (1) : (4)); - } - else - { - l_addr.iv_satId = (((l_addr.iv_satId < 4) ? (1) : (4)) + - ((i_target.getTargetInstance() % 2) ? (0) : (1)) + - (2 * (i_target.getTargetInstance() / 5))); - } - } - break; - default: - if(0 != i_target.getAddressOverlay()) - { - l_addr.iv_chiplet = i_target.fields.chiplet_num; - } - break; - } - return l_addr; -} - -static fapi2::ReturnCode pibRcToFapiRc(const uint32_t i_pibRc) -{ - fapi2::ReturnCode l_fapiRc = FAPI2_RC_SUCCESS; - switch(i_pibRc) - { - case PIB_XSCOM_ERROR: - l_fapiRc = RC_SBE_PIB_XSCOM_ERROR; - break; - case PIB_OFFLINE_ERROR: - l_fapiRc = RC_SBE_PIB_OFFLINE_ERROR; - break; - case PIB_PARTIAL_ERROR: - l_fapiRc = RC_SBE_PIB_PARTIAL_ERROR; - break; - case PIB_ADDRESS_ERROR: - l_fapiRc = RC_SBE_PIB_ADDRESS_ERROR; - break; - case PIB_CLOCK_ERROR: - l_fapiRc = RC_SBE_PIB_CLOCK_ERROR; - break; - case PIB_PARITY_ERROR: - l_fapiRc = RC_SBE_PIB_PARITY_ERROR; - break; - case PIB_TIMEOUT_ERROR: - l_fapiRc = RC_SBE_PIB_TIMEOUT_ERROR; - break; - case PIB_NO_ERROR: - default: - break; - } - return l_fapiRc; -} - -fapi2::ReturnCode getscom_abs_wrap(const void *i_target, - const uint32_t i_addr, uint64_t *o_data) -{ - uint32_t l_pibRc = 0; - uint32_t l_addr = getEffectiveAddress(*(plat_target_handle_t*)i_target, i_addr); - FAPI_INF("getScom: address: 0x%08X", l_addr); - l_pibRc = getscom_abs(l_addr, o_data); - if( PIB_NO_ERROR != l_pibRc ) - { - l_pibRc = p9_pibErrRetry( l_addr, o_data, l_pibRc, true); - } - FAPI_INF("getScom: returned pibRc: 0x%08X, data HI: 0x%08X, " - "data LO: 0x%08X", l_pibRc, (*o_data >> 32), - static_cast(*o_data & 0xFFFFFFFF)); - fapi2::current_err = fapi2::FAPI2_RC_SUCCESS; - // Setting 64bit address in ffdc package as the parsers are - // hard coded to read 64bit address - const uint64_t ffdcAddr = l_addr; - PLAT_FAPI_ASSERT( PIB_NO_ERROR == l_pibRc, - SBE_SCOM_FAILURE(). - set_address(ffdcAddr). - set_pcb_pib_rc(l_pibRc), - "getScom:pcb pib error, pibRc[0x%08X] Scom_Addr[0x%08X]", - l_pibRc,l_addr); -fapi_try_exit: - if(PIB_NO_ERROR != l_pibRc) - { - // Override FAPI RC based on PIB RC - fapi2::current_err = pibRcToFapiRc(l_pibRc); - fapi2::g_FfdcData.fapiRc = fapi2::current_err; - } - return fapi2::current_err; -} - -fapi2::ReturnCode putscom_abs_wrap(const void *i_target, - const uint32_t i_addr, uint64_t i_data) -{ - uint32_t l_pibRc = 0; - uint32_t l_addr = getEffectiveAddress(*(plat_target_handle_t*)i_target, - i_addr); - FAPI_INF("putScom: address: 0x%08X, data HI: 0x%08X, data LO: 0x%08X", - l_addr, (i_data >> 32), - static_cast(i_data & 0xFFFFFFFF)); - l_pibRc = putscom_abs(l_addr, i_data); - if( PIB_NO_ERROR != l_pibRc ) - { - l_pibRc = p9_pibErrRetry( l_addr, &i_data, l_pibRc, false); - } - FAPI_INF("putScom: returned pibRc: 0x%08X", l_pibRc); - fapi2::current_err = fapi2::FAPI2_RC_SUCCESS; - // Setting 64bit address in ffdc package as the parsers are - // hard coded to read 64bit address - const uint64_t ffdcAddr = l_addr; - PLAT_FAPI_ASSERT( PIB_NO_ERROR == l_pibRc, - SBE_SCOM_FAILURE(). - set_address(ffdcAddr). - set_pcb_pib_rc(l_pibRc), - "putScom:pcb pib error, pibRc[0x%08X] Scom_Addr[0x%08X] " - "Scom_Data[0x%08X%08X]", - l_pibRc,l_addr,(i_data >> 32), - static_cast(i_data & 0xFFFFFFFF)); -fapi_try_exit: - if(PIB_NO_ERROR != l_pibRc) - { - // Override FAPI RC based on PIB RC - fapi2::current_err = pibRcToFapiRc(l_pibRc); - fapi2::g_FfdcData.fapiRc = fapi2::current_err; - } - return fapi2::current_err; -} - -uint32_t p9_pibErrRetry( const uint32_t i_addr, uint64_t *io_data, - const uint8_t i_pibErr, const bool i_isRead) -{ - FAPI_INF("Entering p9_pibErrRetry"); - static const uint8_t MAX_RETRIES = 2; - uint8_t l_retryCount = 0; - uint32_t pibErr = i_pibErr; - - do - { - // Only retry for parity and timeout errors - if (( i_pibErr != PIB_PARITY_ERROR ) - && ( i_pibErr != PIB_TIMEOUT_ERROR )) - { - break; - } - for(l_retryCount = 0; l_retryCount < MAX_RETRIES; l_retryCount++) - { - FAPI_DBG( "*** Retry %i ***", l_retryCount ); - - if ( i_isRead ) - { - pibErr = getscom_abs(i_addr, io_data); - } - else - { - pibErr = putscom_abs(i_addr, *io_data); - } - - if( PIB_NO_ERROR == pibErr ) - { - FAPI_INF("Read/Write Retry Successful"); - break; - } - if ( pibErr != i_pibErr ) break; - } - }while(0); - FAPI_INF("Exiting p9_pibErrRetry"); - return pibErr; -} - -}; diff --git a/src/hwpf/src/plat/plat_utils.C b/src/hwpf/src/plat/plat_utils.C deleted file mode 100644 index fe810f4f..00000000 --- a/src/hwpf/src/plat/plat_utils.C +++ /dev/null @@ -1,197 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/hwpf/src/plat/plat_utils.C $ */ -/* */ -/* OpenPOWER sbe Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2015,2017 */ -/* [+] International Business Machines Corp. */ -/* */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ -/* implied. See the License for the specific language governing */ -/* permissions and limitations under the License. */ -/* */ -/* IBM_PROLOG_END_TAG */ - -/** - * @file plat_utils.C - * @brief Implements fapi2 common utilities - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace fapi2 -{ - - // Define own function rather than using PK function - // This is required as PK function does not scale well for low - // frequency till istep 2.7 - inline uint64_t delayCycles(uint64_t i_nanoSeconds ) - { - return ( i_nanoSeconds/1000) * ( SBE_GLOBAL->sbefreq /(1000*1000)); - } - /// @brief Delay this thread. - /// - ReturnCode delay(uint64_t i_nanoSeconds, uint64_t i_simCycles, bool i_fixed /* = false*/) - { - // void statements to keep the compiler from complaining - // about unused variables. - static_cast(i_nanoSeconds); - static_cast(i_simCycles); - - -#ifndef __FAPI_DELAY_SIM__ - - PkTimebase target_time; - PkTimebase current_time; - PkMachineContext ctx; - - - // Only execute if nanoSeconds is non-zero (eg a real wait) - if (i_nanoSeconds) - { - // The critical section enter/exit set is done to ensure the timebase - // operations are non-interrupible. - - pk_critical_section_enter(&ctx); - - target_time = pk_timebase_get() + delayCycles( i_nanoSeconds); - - do - { - current_time = pk_timebase_get(); - } while (target_time > current_time); - - pk_critical_section_exit(&ctx); - } -#else - - // Execute a tight loop that simply counts down the i_simCycles - // value. - - // @todo This can might be optimized with a fused compare branch loop - // Note, though, that subwibnz instruction is optimized for word - // operations. i_simCycles are uint64_t values so the upper - // word values needs to be accounted for. - // - // Need to determine if this optimization is worth the effort. - -#ifndef __FAPI_DELAY_PPE_SIM_CYCLES__ -#define __FAPI_DELAY_PPE_SIM_CYCLES__ 8 -#endif - - static const uint8_t NUM_OVERHEAD_INSTRS = 15; - static const uint8_t NUM_LOOP_INSTRS = 4; - static const uint64_t MIN_DELAY_CYCLES = - ((NUM_OVERHEAD_INSTRS + NUM_LOOP_INSTRS) * __FAPI_DELAY_PPE_SIM_CYCLES__); - - uint64_t l_adjusted_simcycles; - - if (i_simCycles < MIN_DELAY_CYCLES) - l_adjusted_simcycles = MIN_DELAY_CYCLES; - else - l_adjusted_simcycles = i_simCycles; - - uint64_t delay_loop_count = - ((l_adjusted_simcycles - (NUM_OVERHEAD_INSTRS * __FAPI_DELAY_PPE_SIM_CYCLES__)) / - (NUM_LOOP_INSTRS * __FAPI_DELAY_PPE_SIM_CYCLES__)); - - for (auto i = delay_loop_count; i > 0; --i) { - // Force compiler not to optimize for loop - asm(""); - } - -#endif - - // replace with platform specific implementation - return FAPI2_RC_SUCCESS; - } - - /// - /// @brief Queries the ATTR_NAME and ATTR_EC attributes - /// - void queryChipEcAndName( - const Target < fapi2::TARGET_TYPE_PROC_CHIP > & i_target, - fapi2::ATTR_NAME_Type& o_chipName, fapi2::ATTR_EC_Type& o_chipEc ) - { - - FAPI_ATTR_GET_PRIVILEGED(fapi2::ATTR_NAME, i_target, o_chipName); - - FAPI_ATTR_GET_PRIVILEGED(fapi2::ATTR_EC, i_target, o_chipEc); - } -}; - -#ifndef _BIG_ENDIAN - -/// Byte-reverse a 16-bit integer if on a little-endian machine - -uint16_t -revle16(uint16_t i_x) -{ - uint16_t rx; - uint8_t *pix = (uint8_t*)(&i_x); - uint8_t *prx = (uint8_t*)(&rx); - - prx[0] = pix[1]; - prx[1] = pix[0]; - - return rx; -} - -/// Byte-reverse a 32-bit integer if on a little-endian machine - -uint32_t -revle32(uint32_t i_x) -{ - uint32_t rx; - uint8_t *pix = (uint8_t*)(&i_x); - uint8_t *prx = (uint8_t*)(&rx); - - prx[0] = pix[3]; - prx[1] = pix[2]; - prx[2] = pix[1]; - prx[3] = pix[0]; - - return rx; -} - - -/// Byte-reverse a 64-bit integer if on a little-endian machine - -uint64_t -revle64(const uint64_t i_x) -{ - uint64_t rx; - uint8_t *pix = (uint8_t*)(&i_x); - uint8_t *prx = (uint8_t*)(&rx); - - prx[0] = pix[7]; - prx[1] = pix[6]; - prx[2] = pix[5]; - prx[3] = pix[4]; - prx[4] = pix[3]; - prx[5] = pix[2]; - prx[6] = pix[1]; - prx[7] = pix[0]; - - return rx; -} -#endif - diff --git a/src/hwpf/src/plat/target.C b/src/hwpf/src/plat/target.C deleted file mode 100644 index 8ab8f0f4..00000000 --- a/src/hwpf/src/plat/target.C +++ /dev/null @@ -1,755 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/hwpf/src/plat/target.C $ */ -/* */ -/* OpenPOWER sbe Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2012,2017 */ -/* [+] International Business Machines Corp. */ -/* */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ -/* implied. See the License for the specific language governing */ -/* permissions and limitations under the License. */ -/* */ -/* IBM_PROLOG_END_TAG */ - - -#include -#include -#include -#include -#include - -// Global Vector containing ALL targets. This structure is referenced by -// fapi2::getChildren to produce the resultant returned vector from that -// call. -std::vector G_vec_targets; - -// Global variable for fixed section in pibmem -G_sbe_attrs_t G_sbe_attrs; - -fapi2attr::SystemAttributes_t* G_system_attributes_ptr; -fapi2attr::ProcChipAttributes_t* G_proc_chip_attributes_ptr; -fapi2attr::PervAttributes_t* G_perv_attributes_ptr; -fapi2attr::CoreAttributes_t* G_core_attributes_ptr; -fapi2attr::EQAttributes_t* G_eq_attributes_ptr; -fapi2attr::EXAttributes_t* G_ex_attributes_ptr; - -namespace fapi2 -{ - static ReturnCode plat_AttrInit() - { - union - { - struct - { - uint64_t iv_majorEC : 4; - uint64_t iv_deviceIdDontCare : 4; - uint64_t iv_minorEC : 4; - uint64_t iv_chipId : 8; - uint64_t iv_deviceIdDontCare2 : 20; - uint64_t iv_c4Pin : 1; - uint64_t iv_deviceIdDontCare3 : 23; - }; - uint64_t iv_deviceIdReg; - } l_deviceId; - - uint8_t l_chipName = fapi2::ENUM_ATTR_NAME_NONE; - uint8_t l_ec = 0; - fapi2::Target l_chipTarget = - plat_getChipTarget(); - - FAPI_TRY(getscom_abs(PERV_DEVICE_ID_REG, &l_deviceId.iv_deviceIdReg)); - l_ec = (l_deviceId.iv_majorEC << 4) | (l_deviceId.iv_minorEC); - switch(l_deviceId.iv_chipId) - { - case 0xD1: - l_chipName = fapi2::ENUM_ATTR_NAME_NIMBUS; - break; - case 0xD4: - l_chipName = fapi2::ENUM_ATTR_NAME_CUMULUS; - break; - default: - FAPI_ERR("Unsupported chip ID: 0x%02X", - static_cast(l_deviceId.iv_chipId)); - assert(false); - } - - FAPI_TRY(PLAT_ATTR_INIT(fapi2::ATTR_NAME, l_chipTarget, l_chipName)); - - FAPI_TRY(PLAT_ATTR_INIT(fapi2::ATTR_EC, l_chipTarget, l_ec)); -fapi_try_exit: - return fapi2::current_err; - } - - // Get the plat target handle by chiplet number - For PERV targets - template<> - plat_target_handle_t plat_getTargetHandleByChipletNumber( - const uint8_t i_chipletNumber) - { - uint32_t l_idx = 0; - - if((i_chipletNumber > 0) && - (i_chipletNumber < (EQ_CHIPLET_OFFSET + EQ_TARGET_COUNT))) - { - l_idx = (i_chipletNumber - NEST_GROUP1_CHIPLET_OFFSET) + - NEST_GROUP1_TARGET_OFFSET; - } - else if((i_chipletNumber >= CORE_CHIPLET_OFFSET) && - (i_chipletNumber < (CORE_CHIPLET_OFFSET + CORE_TARGET_COUNT))) - { - l_idx = (i_chipletNumber - CORE_CHIPLET_OFFSET) + - CORE_TARGET_OFFSET; - } - else - { - assert(false); - } - return G_vec_targets[l_idx]; - } - - // Get the plat target handle by chiplet number - For EQ targets - template<> - plat_target_handle_t plat_getTargetHandleByChipletNumber( - const uint8_t i_chipletNumber) - { - assert(((i_chipletNumber >= EQ_CHIPLET_OFFSET) && - (i_chipletNumber < (EQ_CHIPLET_OFFSET + EQ_TARGET_COUNT)))) - - uint32_t l_idx = (i_chipletNumber - EQ_CHIPLET_OFFSET) + - EQ_TARGET_OFFSET; - return G_vec_targets[l_idx]; - } - - // Get the plat target handle by chiplet number - For CORE targets - template<> - plat_target_handle_t plat_getTargetHandleByChipletNumber( - const uint8_t i_chipletNumber) - { - assert(((i_chipletNumber >= CORE_CHIPLET_OFFSET) && - (i_chipletNumber < (CORE_CHIPLET_OFFSET + CORE_TARGET_COUNT)))); - - uint32_t l_idx = (i_chipletNumber - CORE_CHIPLET_OFFSET) + - CORE_TARGET_OFFSET; - - return G_vec_targets[l_idx]; - } - - // Get the plat target handle by chiplet number - For EX targets - template<> - plat_target_handle_t plat_getTargetHandleByChipletNumber( - const uint8_t i_chipletNumber) - { - assert(((i_chipletNumber >= CORE_CHIPLET_OFFSET) && - (i_chipletNumber < (CORE_CHIPLET_OFFSET + CORE_TARGET_COUNT)))); - - uint32_t l_idx = ((i_chipletNumber - CORE_CHIPLET_OFFSET) / 2) + - EX_TARGET_OFFSET; - - return G_vec_targets[l_idx]; - } - - // Get plat target handle by instance number - For EX targets - template <> - plat_target_handle_t plat_getTargetHandleByInstance( - const uint8_t i_targetNum) - { - assert(i_targetNum < EX_TARGET_COUNT); - - return G_vec_targets[i_targetNum + EX_TARGET_OFFSET]; - } - - - TargetType plat_target_handle_t::getFapiTargetType() const - { - TargetType l_targetType = TARGET_TYPE_NONE; - switch(fields.type) - { - case PPE_TARGET_TYPE_PROC_CHIP: - l_targetType = TARGET_TYPE_PROC_CHIP; - break; - case PPE_TARGET_TYPE_MCS: - l_targetType = TARGET_TYPE_MCS; - break; - case PPE_TARGET_TYPE_PHB: - l_targetType = TARGET_TYPE_PHB; - break; - case PPE_TARGET_TYPE_CORE | PPE_TARGET_TYPE_PERV: - l_targetType = TARGET_TYPE_CORE; - break; - case PPE_TARGET_TYPE_EQ | PPE_TARGET_TYPE_PERV: - l_targetType = TARGET_TYPE_EQ; - break; - case PPE_TARGET_TYPE_EX: - l_targetType = TARGET_TYPE_EX; - break; - case PPE_TARGET_TYPE_PERV: - l_targetType = TARGET_TYPE_PERV; - break; - case PPE_TARGET_TYPE_SYSTEM: - l_targetType = TARGET_TYPE_SYSTEM; - break; - case PPE_TARGET_TYPE_MCBIST | PPE_TARGET_TYPE_PERV: - l_targetType = TARGET_TYPE_MCBIST; - break; - case PPE_TARGET_TYPE_NONE: - case PPE_TARGET_TYPE_ALL: - default: - assert(false); - break; - } - return l_targetType; - } - - plat_target_handle_t plat_target_handle_t::getParent( - const TargetType i_parentType) const - { - plat_target_handle_t l_handle; - switch(i_parentType) - { - case TARGET_TYPE_PROC_CHIP: - l_handle = G_vec_targets[CHIP_TARGET_OFFSET]; - break; - case TARGET_TYPE_PERV: - assert(fields.type & PPE_TARGET_TYPE_PERV); - l_handle = *this; - break; - case TARGET_TYPE_EX: - assert(fields.type & PPE_TARGET_TYPE_CORE); - l_handle = G_vec_targets - [(fields.type_target_num / EX_PER_QUAD) + EX_TARGET_OFFSET]; - break; - case TARGET_TYPE_EQ: - assert(fields.type & - (PPE_TARGET_TYPE_EX | PPE_TARGET_TYPE_CORE)); - { - uint32_t l_perQuad = (fields.type & PPE_TARGET_TYPE_EX) ? - EX_PER_QUAD : CORES_PER_QUAD; - l_handle = G_vec_targets - [(fields.type_target_num / l_perQuad) + - EQ_TARGET_OFFSET]; - } - break; - default: - assert(false); - } - return l_handle; - } - - void plat_target_handle_t::getChildren(const TargetType i_parentType, - const TargetType i_childType, - const plat_target_type_t i_platType, - const TargetState i_state, - std::vector - &o_children) const - { - uint32_t l_childPerChiplet = 0; - uint32_t l_childTargetOffset = 0; - uint32_t l_loopCount = G_vec_targets.size(); - TargetType l_targetType = i_parentType; - - if((i_parentType & ~(TARGET_TYPE_PROC_CHIP)) != 0) - { - // For composite targets, if multicast, treat as PROC_CHIP, else - // treat as other target - if(this->fields.is_multicast) - { - l_targetType = TARGET_TYPE_PROC_CHIP; - } - else - { - l_targetType = - static_cast(l_targetType & ~(TARGET_TYPE_PROC_CHIP)); - } - } - - // EQ ==> EX - if((l_targetType == TARGET_TYPE_EQ) && (i_childType == TARGET_TYPE_EX)) - { - l_childPerChiplet = EX_PER_QUAD; - l_childTargetOffset = EX_TARGET_OFFSET; - l_loopCount = l_childPerChiplet; - } - - // EQ ==> EC - if((l_targetType == TARGET_TYPE_EQ) && (i_childType == TARGET_TYPE_CORE)) - { - l_childPerChiplet = CORES_PER_QUAD; - l_childTargetOffset = CORE_TARGET_OFFSET; - l_loopCount = l_childPerChiplet; - } - - // EX ==> EC - if((l_targetType == TARGET_TYPE_EX) && (i_childType == TARGET_TYPE_CORE)) - { - l_childPerChiplet = CORES_PER_EX; - l_childTargetOffset = CORE_TARGET_OFFSET; - l_loopCount = l_childPerChiplet; - } - // else it is TARGET_TYPE_PROC_CHIP ==> anything, and we iterate over - // all the targets - - for(uint32_t i = 0; i < l_loopCount; ++i) - { - plat_target_handle_t l_temp = - G_vec_targets.at((this->fields.type_target_num * - l_childPerChiplet) + l_childTargetOffset + i); - if ((l_temp.fields.type & i_platType) == i_platType) - { - switch (i_state) - { - case TARGET_STATE_PRESENT: - if (l_temp.fields.present) - { - o_children.push_back(l_temp); - } - break; - case TARGET_STATE_FUNCTIONAL: - if (l_temp.fields.functional) - { - o_children.push_back(l_temp); - } - break; - default: - assert(false); - } - } - } - } - - void plat_target_handle_t::getChildren(const TargetFilter i_filter, - const TargetState i_state, - std::vector - &o_children) const - { - static const uint64_t mask = 1; - - // Walk the bits in the input target filter. For every bit, at - // position x, that is set, x can be used as an index into our global - // target vector (indexed by chiplet number) - for (uint32_t l_idx = 0; - l_idx < sizeof(TargetFilter) * 8; - ++l_idx) - { - if (i_filter & (mask << (((sizeof(TargetFilter)*8)-1) - l_idx))) - { - plat_target_handle_t l_targetHandle = G_vec_targets.at(l_idx + NEST_GROUP1_CHIPLET_OFFSET); - - if(l_targetHandle.fields.type & PPE_TARGET_TYPE_PERV) // Can be an assertion? - { - switch (i_state) - { - case TARGET_STATE_PRESENT: - if(l_targetHandle.fields.present) - { - o_children.push_back(l_targetHandle); - } - break; - case TARGET_STATE_FUNCTIONAL: - if(l_targetHandle.fields.functional) - { - o_children.push_back(l_targetHandle); - } - break; - default: - break; - } - } - } - } - } - - #ifndef __noRC__ - ReturnCode current_err; - #endif - - fapi2::ReturnCode plat_PervPGTargets(const fapi2::Target & i_target, - bool & o_present) - { - o_present = false; - uint16_t attr_value = 0; - FAPI_ATTR_GET(fapi2::ATTR_PG, - i_target, - attr_value); - FAPI_DBG("Target: 0x%08X, ATTR_PG value = %x", static_cast(i_target.get().value), attr_value); - if (0 == (attr_value & 0x1000)) - { - o_present = true; - } - return fapi2::FAPI2_RC_SUCCESS; - } - - /// @brief Function to determine if pervsaive target within a chip is - /// present and, thus, considered functional per PG attributes - fapi2::ReturnCode - plat_TargetPresent( fapi2::Target & i_chiplet_target, - bool & b_present) - { - - uint8_t l_chipName = fapi2::ENUM_ATTR_NAME_NONE; - - FAPI_TRY(FAPI_ATTR_GET_PRIVILEGED(fapi2::ATTR_NAME, plat_getChipTarget(), l_chipName)); - - // TODO via RTC 164026 - // In nimbus all pervasive chiplets (non quad, non core), are present - // other than OBUS1 and OBUS2. In cumulus all chiplets are present. - // Though on field parts, all chiplets which are present should be - // functional. But in lab when we can get partial good parts, its - // possible that few chiplets are not functional. So we need to - // differentiate between present versus functional chiplets. - // We need to see if we need to use same strategy for cores/caches as - // well. - // Also in current code we are hard coding the chiplets. We need to use - // attribute to differentiate between nimbus versus cumulus config. - static const size_t OBUS1 = 10; - static const size_t OBUS2 = 11; - if((OBUS1 == i_chiplet_target.getChipletNumber()) || - (OBUS2 == i_chiplet_target.getChipletNumber())) - { - if(fapi2::ENUM_ATTR_NAME_CUMULUS == l_chipName) - { - static_cast((i_chiplet_target.operator()())).setPresent(); - } - } - else if( i_chiplet_target.getChipletNumber() < EQ_CHIPLET_OFFSET ) - { - static_cast((i_chiplet_target.operator()())).setPresent(); - } - // Find the PERV target number in the partial good initialization - // array - - FAPI_TRY(plat_PervPGTargets(i_chiplet_target, b_present)); - - if (b_present) - { - if( i_chiplet_target.getChipletNumber() >= EQ_CHIPLET_OFFSET ) - { - static_cast((i_chiplet_target.operator()())).setPresent(); - } - static_cast((i_chiplet_target.operator()())).setFunctional(true); - } - else - { - FAPI_DBG("Perv target NOT present (nor functional): chiplet_number = %d", i_chiplet_target.getChipletNumber()); - } - - FAPI_DBG("Target present = %u, Target functional = %u", - static_cast(i_chiplet_target.get()).getPresent(), - static_cast(i_chiplet_target.get()).getFunctional()); - -fapi_try_exit: - return fapi2::current_err; - } - - - /// @brief Function to initialize the G_targets vector based on partial good - /// attributes /// this will move to plat_target.H formally - fapi2::ReturnCode plat_TargetsInit() - { - bool b_present = false; - - // Copy fixed section from SEEPROM to PIBMEM - G_sbe_attrs.G_system_attrs = G_system_attributes; - G_sbe_attrs.G_proc_chip_attrs = G_proc_chip_attributes; - G_sbe_attrs.G_perv_attrs = G_perv_attributes; - G_sbe_attrs.G_core_attrs = G_core_attributes; - G_sbe_attrs.G_eq_attrs = G_eq_attributes; - G_sbe_attrs.G_ex_attrs = G_ex_attributes; - - // Initialise global attribute pointers - G_system_attributes_ptr = &(G_sbe_attrs.G_system_attrs); - G_proc_chip_attributes_ptr = &(G_sbe_attrs.G_proc_chip_attrs); - G_perv_attributes_ptr = &(G_sbe_attrs.G_perv_attrs); - G_core_attributes_ptr = &(G_sbe_attrs.G_core_attrs); - G_eq_attributes_ptr = &(G_sbe_attrs.G_eq_attrs); - G_ex_attributes_ptr = &(G_sbe_attrs.G_ex_attrs); - - - std::vector::iterator tgt_iter; - uint32_t l_beginning_offset; - - FAPI_DBG("Platform target initialization. Target Count = %u", TARGET_COUNT); - /* - * Initialize all entries to NULL - */ - for (uint32_t i = 0; i < TARGET_COUNT; ++i) - { - G_vec_targets.push_back((fapi2::plat_target_handle_t)0x0); - } - - /* - * Chip Target is the first one - */ - l_beginning_offset = CHIP_TARGET_OFFSET; - - fapi2::Target chip_target((createPlatTargetHandle(0))); - G_vec_targets.at(l_beginning_offset) = revle32((fapi2::plat_target_handle_t)(chip_target.get())); - - // Initialize platform attributes. Needs to be after the chip target is - // created. - FAPI_TRY(plat_AttrInit()); - - /* - * Nest Targets - group 1 - */ - l_beginning_offset = NEST_GROUP1_TARGET_OFFSET; - for (uint32_t i = 0; i < NEST_GROUP1_TARGET_COUNT; ++i) - { - fapi2::Target target_name((createPlatTargetHandle(i))); - - // Determine if the chiplet is present and, thus, functional - // via partial good attributes - FAPI_TRY(plat_TargetPresent(target_name, b_present)); - - G_vec_targets.at(l_beginning_offset+i) = revle32((fapi2::plat_target_handle_t)(target_name.get())); - } - - /* - * Memory Controller Synchronous (MCBIST) Targets - */ - - l_beginning_offset = MCBIST_TARGET_OFFSET; - for (uint32_t i = 0; i < MCBIST_TARGET_COUNT; ++i) - { - fapi2::Target target_name((createPlatTargetHandle(i))); - fapi2::Target l_perv = target_name.getParent(); - - // Determine if the chiplet is present and, thus, functional - // via partial good attributes - FAPI_TRY(plat_TargetPresent(l_perv, b_present)); - - G_vec_targets.at(l_beginning_offset+i) = revle32((fapi2::plat_target_handle_t)(l_perv.get())); - - } - - /* - * Nest Targets - group 2 - */ - l_beginning_offset = NEST_GROUP2_TARGET_OFFSET; - for (uint32_t i = NEST_GROUP2_TARGET_OFFSET; - i < (NEST_GROUP2_TARGET_OFFSET + NEST_GROUP2_TARGET_COUNT); ++i) - { - fapi2::Target target_name((createPlatTargetHandle(i - 1))); - - // Determine if the chiplet is present and, thus, functional - // via partial good attributes - FAPI_TRY(plat_TargetPresent(target_name, b_present)); - - G_vec_targets.at(i) = revle32((fapi2::plat_target_handle_t)(target_name.get())); - } - - /* - * Cache (EQ) Targets - */ - l_beginning_offset = EQ_TARGET_OFFSET; - for (uint32_t i = 0; i < EQ_TARGET_COUNT; ++i) - { - fapi2::Target target_name((createPlatTargetHandle(i))); - fapi2::Target l_perv = target_name.getParent(); - - // Determine if the chiplet is present and, thus, functional - // via partial good attributes - FAPI_TRY(plat_TargetPresent(l_perv, b_present)); - - G_vec_targets.at(l_beginning_offset+i) = revle32((fapi2::plat_target_handle_t)(l_perv.get())); - } - - /* - * Core (EC) Targets - */ - - l_beginning_offset = CORE_TARGET_OFFSET; - for (uint32_t i = 0; i < CORE_TARGET_COUNT; ++i) - { - fapi2::Target target_name((createPlatTargetHandle(i))); - fapi2::Target l_perv = target_name.getParent(); - - // Determine if the chiplet is present and, thus, functional - // via partial good attributes - FAPI_TRY(plat_TargetPresent(l_perv, b_present)); - - G_vec_targets.at(l_beginning_offset+i) = revle32((fapi2::plat_target_handle_t)(l_perv.get())); - } - - /* - * EX Targets - */ - - l_beginning_offset = EX_TARGET_OFFSET; - for (uint32_t i = 0; i < EX_TARGET_COUNT; ++i) - { - fapi2::Target target_name((createPlatTargetHandle(i))); - - fapi2::Target l_parent = target_name.getParent(); - - // Get the parent EQ's ATTR_PG - uint16_t l_eqAttrPg = 0; - FAPI_ATTR_GET(fapi2::ATTR_PG, l_parent.getParent(), l_eqAttrPg); - - // Check if this EX's L2 and L3 regions are marked "good" - if(0 == (i % EX_PER_QUAD)) - { - // Bits 6 and 8 need to be 0 - l_eqAttrPg &= 0x0280; - } - else - { - // Bits 7 and 9 need to be 0 - l_eqAttrPg &= 0x0140; - } - - if(0 == l_eqAttrPg) - { - static_cast(target_name.operator ()()).setPresent(); - static_cast(target_name.operator ()()).setFunctional(true); - } - G_vec_targets.at(l_beginning_offset+i) = revle32((fapi2::plat_target_handle_t)(target_name.get())); - } - - /* - * MCS Targets - */ - - l_beginning_offset = MCS_TARGET_OFFSET; - for (uint32_t i = 0; i < MCS_TARGET_COUNT; ++i) - { - fapi2::Target target_name(createPlatTargetHandle(i)); - - fapi2::Target - l_nestTarget((plat_getTargetHandleByChipletNumber(N3_CHIPLET - (MCS_PER_MCBIST * (i / MCS_PER_MCBIST))))); - - uint16_t l_attrPg = 0; - - FAPI_ATTR_GET(fapi2::ATTR_PG, l_nestTarget, l_attrPg); - - if(0 == (i / MCS_PER_MCBIST)) - { - // Bit 10 needs to be 0 for MCS 0, 1 - l_attrPg &= 0x0020; - } - else - { - // Bit 9 needs to be 0 for MCS 2, 3 - l_attrPg &= 0x0040; - } - - if(0 == l_attrPg) - { - static_cast(target_name.operator ()()).setPresent(); - static_cast(target_name.operator ()()).setFunctional(true); - } - - G_vec_targets.at(l_beginning_offset+i) = revle32((fapi2::plat_target_handle_t)(target_name.get())); - } - - /* - * PHB Targets - */ - l_beginning_offset = PHB_TARGET_OFFSET; - for (uint32_t i = 0; i < PHB_TARGET_COUNT; ++i) - { - fapi2::Target target_name(createPlatTargetHandle(i)); - - fapi2::Target - l_pciTarget((plat_getTargetHandleByChipletNumber(target_name.getChipletNumber()))); - - constexpr uint16_t l_pciPgArray[] = {0xE1FD, 0xE0FD, 0xE07D}; - uint16_t l_attrPg = 0; - - FAPI_ATTR_GET(fapi2::ATTR_PG, l_pciTarget, l_attrPg); - - if(l_pciPgArray[target_name.getChipletNumber() - PCI0_CHIPLET] == l_attrPg) - { - static_cast(target_name.operator ()()).setPresent(); - static_cast(target_name.operator ()()).setFunctional(true); - } - - G_vec_targets.at(l_beginning_offset+i) = revle32((fapi2::plat_target_handle_t)(target_name.get())); - } - - -fapi_try_exit: - return fapi2::current_err; - } - - /// @brief Function to initialize the G_targets vector based on partial good - /// attributes - fapi2::Target plat_getChipTarget() - { - - // Get the chip specific target - return ((fapi2::Target)G_vec_targets.at(0)); - } - - /// @brief Function to apply any gard records set (via - // ATTR_EQ_GARD/ATTR_EC_GARD) to mark corresponding targets non functional - ReturnCode plat_ApplyGards() - { - uint8_t l_eqGards = 0; - uint32_t l_ecGards = 0; - static const uint32_t l_mask = 0x80000000; - bool l_coreGroupNonFunctional = true; - fapi2::Target l_chip = plat_getChipTarget(); - - // Read the EQ and EC gard attributes from the chip target - FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_EQ_GARD, l_chip, l_eqGards)); - FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_EC_GARD, l_chip, l_ecGards)); - - FAPI_DBG("ATTR_EQ_GARD:: 0x%08x", l_eqGards); - FAPI_DBG("ATTR_EC_GARD:: 0x%08x", l_ecGards); - - // Iterate over the bits in EQ and EC gards, if set, mark the - // corresponding target non-functional - for(uint32_t l_idx = 0; l_idx < EQ_TARGET_COUNT; ++l_idx) - { - if((l_mask >> l_idx) & (((uint32_t)(l_eqGards)) << 24)) - { - FAPI_DBG("Making %d'th EQ non-functional", l_idx); - // EQ chiplet l_idx is to be marked non-functional - fapi2::Target l_target = G_vec_targets.at(l_idx + EQ_TARGET_OFFSET); - static_cast(l_target.operator ()()).setFunctional(false); - G_vec_targets.at(l_idx + EQ_TARGET_OFFSET) = l_target.get(); - } - } - - for(uint32_t l_idx = 0; l_idx < CORE_TARGET_COUNT; ++l_idx) - { - if((l_mask >> l_idx) & (l_ecGards)) - { - FAPI_DBG("Making %d'th EC non-functional", l_idx); - // EC chiplet l_idx is to be marked non-functional - fapi2::Target l_target = G_vec_targets.at(l_idx + CORE_TARGET_OFFSET); - static_cast(l_target.operator ()()).setFunctional(false); - G_vec_targets.at(l_idx + CORE_TARGET_OFFSET) = l_target.get(); - } - else - { - l_coreGroupNonFunctional = false; - } - if(0 == ((l_idx + 1) % CORES_PER_EX)) - { - if(true == l_coreGroupNonFunctional) - { - // All cores of this group are non-functional. Mark the EX - // non-functional too. - G_vec_targets.at((l_idx / CORES_PER_EX) + EX_TARGET_OFFSET).fields.functional = false; - } - // Reset ex non-functional flag for the next group - l_coreGroupNonFunctional = true; - } - } -fapi_try_exit: - return fapi2::current_err; - } - -} // fapi2 diff --git a/src/hwpf/src/plat_ring_traverse.C b/src/hwpf/src/plat_ring_traverse.C deleted file mode 100644 index 9b4466a7..00000000 --- a/src/hwpf/src/plat_ring_traverse.C +++ /dev/null @@ -1,499 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/hwpf/src/plat_ring_traverse.C $ */ -/* */ -/* OpenPOWER sbe Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2016,2017 */ -/* [+] International Business Machines Corp. */ -/* */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); */ -/* you may not use this file except in compliance with the License. */ -/* You may obtain a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ -/* implied. See the License for the specific language governing */ -/* permissions and limitations under the License. */ -/* */ -/* IBM_PROLOG_END_TAG */ - -#include - -#include // for RS4 decompression utilities -#include -#include // for FAPI_ATTR_GET -#include // for plat_getChipTarget - -// SEEPROM start address -const uint32_t g_seepromAddr = SBE_SEEPROM_BASE_ORIGIN; -using namespace RING_TYPES; -const uint32_t CACHE_CONTAINED_MODE = 4; -const uint32_t RISK_LEVEL_MODE = 1; -#define CACHE_CONTAINED_MODE_OFFSET_IN_TOR 1 -#define RISK_LEVEL_MODE_OFFSET_IN_TOR 2 -#define OVERRIDE_VARIANT_SIZE 1 - - -/// -/// @brief This is a plat pecific (SBE Plat) function that locates the -/// Ring Container in the image and calls the functin to decompress the -/// RS4 string and apply it to the hardware. -/// @param i_target The target of Ring apply. -/// @param i_ringID The Ring ID that identifies the ring to be applied. -/// @return FAPI2_RC_SUCCESS on success, else error code. -/// -fapi2::ReturnCode findRS4InImageAndApply( - const fapi2::Target& i_target, - const RingID i_ringID, - const fapi2::RingMode i_ringMode) -{ - SBE_TRACE(">> findRS4InImageAndApply"); - - fapi2::ReturnCode l_rc = fapi2::FAPI2_RC_SUCCESS; - bool l_applyOverride = false; - - do - { - //Apply scanring from .ring section - - // Get the address of the Section-TOR - P9XipHeader *l_hdr = getXipHdr(); - P9XipSection *l_section = - &(l_hdr->iv_section[P9_XIP_SECTION_SBE_RINGS]); - - if (!(l_section->iv_offset)) - { - SBE_TRACE("No ring data in .RING section"); - break; - } - - SectionTOR *l_sectionTOR = (SectionTOR *)(g_seepromAddr + - l_section->iv_offset); - - l_rc = getRS4ImageFromTor(i_target,i_ringID,l_sectionTOR, - l_applyOverride, - l_section->iv_offset, - i_ringMode); - - if(l_rc != fapi2::FAPI2_RC_SUCCESS) - { - break; - } - - //Apply scanring from .ring section - l_applyOverride = true; - l_section = NULL; - l_section = - &(l_hdr->iv_section[P9_XIP_SECTION_SBE_OVERRIDES]); - - if (!(l_section->iv_offset)) - { - SBE_TRACE("No ring data in .OVERRIDE section"); - break; - } - - l_sectionTOR = NULL; - l_sectionTOR = (SectionTOR *)(g_seepromAddr + - l_section->iv_offset); - - - l_rc = getRS4ImageFromTor(i_target,i_ringID,l_sectionTOR, - l_applyOverride, - l_section->iv_offset, - i_ringMode); - }while(0); - - return l_rc; -} - -fapi2::ReturnCode getRS4ImageFromTor( - const fapi2::Target& i_target, - const RingID i_ringID, - SectionTOR *i_sectionTOR, - bool i_applyOverride, - const uint32_t i_sectionOffset, - const fapi2::RingMode i_ringMode) -{ - - // Determine the Offset ID and Ring Type for the given Ring ID. - uint32_t l_torOffset = 0; - RINGTYPE l_ringType = COMMON_RING; - CHIPLET_TYPE l_chipLetType; - fapi2::ReturnCode l_rc = fapi2::FAPI2_RC_SUCCESS; - do - { - - getRingProperties(i_ringID, l_torOffset, l_ringType,l_chipLetType); - if(INVALID_RING == l_torOffset) - { - SBE_TRACE("Invalid Ring ID - %d", i_ringID); - l_rc = fapi2::FAPI2_RC_INVALID_PARAMETER; - break; - } - - CHIPLET_DATA l_chipletData; - l_chipletData.iv_base_chiplet_number = 0; - l_chipletData.iv_num_common_rings = 0; - l_chipletData.iv_num_instance_rings = 0; - - uint8_t l_chipletID = i_target.getChipletNumber(); - uint16_t l_cpltRingVariantSz = 0; - uint32_t l_sectionOffset = 0; - uint8_t l_CC_offset = 0; - uint8_t l_RL_offset = 1; - switch(l_chipLetType) - { - case PERV_TYPE: // PERV - l_chipletData = PERV::g_pervData; - 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) - { - l_sectionOffset = i_sectionTOR->TOC_PERV_INSTANCE_RING; - } - - break; - - case N0_TYPE: // Nest - N0 - l_chipletData = N0::g_n0Data; - l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - (sizeof(N0::RingVariants) / - sizeof(l_cpltRingVariantSz)); - - l_sectionOffset = i_sectionTOR->TOC_N0_COMMON_RING; - if(INSTANCE_RING == l_ringType) - { - l_sectionOffset = i_sectionTOR->TOC_N0_INSTANCE_RING; - } - - break; - - case N1_TYPE: // Nest - N1 - l_chipletData = N1::g_n1Data; - l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - (sizeof(N1::RingVariants) / - sizeof(l_cpltRingVariantSz)); - - l_sectionOffset = i_sectionTOR->TOC_N1_COMMON_RING; - if(INSTANCE_RING == l_ringType) - { - l_sectionOffset = i_sectionTOR->TOC_N1_INSTANCE_RING; - } - - break; - - case N2_TYPE: // Nest - N2 - l_chipletData = N2::g_n2Data; - l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - (sizeof(N2::RingVariants) / - sizeof(l_cpltRingVariantSz)); - - l_sectionOffset = i_sectionTOR->TOC_N2_COMMON_RING; - if(INSTANCE_RING == l_ringType) - { - l_sectionOffset = i_sectionTOR->TOC_N2_INSTANCE_RING; - } - - break; - - case N3_TYPE: // Nest - N3 - l_chipletData = N3::g_n3Data; - l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - (sizeof(N3::RingVariants) / - sizeof(l_cpltRingVariantSz)); - - l_sectionOffset = i_sectionTOR->TOC_N3_COMMON_RING; - if(INSTANCE_RING == l_ringType) - { - l_sectionOffset = i_sectionTOR->TOC_N3_INSTANCE_RING; - } - - break; - - case XB_TYPE: // XB - XBus2 - l_chipletData = XB::g_xbData; - l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - (sizeof(XB::RingVariants) / - sizeof(l_cpltRingVariantSz)); - - l_sectionOffset = i_sectionTOR->TOC_XB_COMMON_RING; - if(INSTANCE_RING == l_ringType) - { - l_sectionOffset = i_sectionTOR->TOC_XB_INSTANCE_RING; - } - - break; - - case MC_TYPE: // MC - MC23 - l_chipletData = MC::g_mcData; - l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - (sizeof(MC::RingVariants)/ - sizeof(l_cpltRingVariantSz)); - - l_sectionOffset = i_sectionTOR->TOC_MC_COMMON_RING; - if(INSTANCE_RING == l_ringType) - { - l_sectionOffset = i_sectionTOR->TOC_MC_INSTANCE_RING; - } - - break; - - case OB0_TYPE: // OB0 - l_chipletData = OB0::g_ob0Data; - l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - (sizeof(OB0::RingVariants) / - sizeof(l_cpltRingVariantSz)); - - l_sectionOffset = i_sectionTOR->TOC_OB0_COMMON_RING; - if(INSTANCE_RING == l_ringType) - { - l_sectionOffset = i_sectionTOR->TOC_OB0_INSTANCE_RING; - } - - break; - case OB1_TYPE: // OB1 - l_chipletData = OB1::g_ob1Data; - l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - (sizeof(OB1::RingVariants) / - sizeof(l_cpltRingVariantSz)); - - l_sectionOffset = i_sectionTOR->TOC_OB1_COMMON_RING; - if(INSTANCE_RING == l_ringType) - { - l_sectionOffset = i_sectionTOR->TOC_OB1_INSTANCE_RING; - } - - break; - case OB2_TYPE: // OB2 - l_chipletData = OB2::g_ob2Data; - l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - (sizeof(OB2::RingVariants) / - sizeof(l_cpltRingVariantSz)); - - l_sectionOffset = i_sectionTOR->TOC_OB2_COMMON_RING; - if(INSTANCE_RING == l_ringType) - { - l_sectionOffset = i_sectionTOR->TOC_OB2_INSTANCE_RING; - } - - break; - case OB3_TYPE: // OB3 - l_chipletData = OB3::g_ob3Data; - l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - (sizeof(OB3::RingVariants) / - sizeof(l_cpltRingVariantSz)); - - l_sectionOffset = i_sectionTOR->TOC_OB3_COMMON_RING; - if(INSTANCE_RING == l_ringType) - { - l_sectionOffset = i_sectionTOR->TOC_OB3_INSTANCE_RING; - } - - break; - - - case PCI0_TYPE: // PCI - PCI0 - l_chipletData = PCI0::g_pci0Data; - l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - (sizeof(PCI0::RingVariants) / - sizeof(l_cpltRingVariantSz)); - - l_sectionOffset = i_sectionTOR->TOC_PCI0_COMMON_RING; - if(INSTANCE_RING == l_ringType) - { - l_sectionOffset = i_sectionTOR->TOC_PCI0_INSTANCE_RING; - } - - break; - - case PCI1_TYPE: // PCI - PCI1 - l_chipletData = PCI1::g_pci1Data; - l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - (sizeof(PCI1::RingVariants) / - sizeof(l_cpltRingVariantSz)); - - l_sectionOffset = i_sectionTOR->TOC_PCI1_COMMON_RING; - if(INSTANCE_RING == l_ringType) - { - l_sectionOffset = i_sectionTOR->TOC_PCI1_INSTANCE_RING; - } - - break; - - case PCI2_TYPE: // PCI - PCI2 - l_chipletData = PCI2::g_pci2Data; - l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - (sizeof(PCI2::RingVariants) / - sizeof(l_cpltRingVariantSz)); - - l_sectionOffset = i_sectionTOR->TOC_PCI2_COMMON_RING; - if(INSTANCE_RING == l_ringType) - { - l_sectionOffset = i_sectionTOR->TOC_PCI2_INSTANCE_RING; - } - - break; - - case EQ_TYPE: // EQ - Quad 0 - Quad 5 - l_chipletData = EQ::g_eqData; - l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - ( sizeof(EQ::RingVariants) / - sizeof(l_cpltRingVariantSz)); - - - l_sectionOffset = i_sectionTOR->TOC_EQ_COMMON_RING; - l_CC_offset = 1; - l_RL_offset = 2; - if(INSTANCE_RING == l_ringType) - { - l_sectionOffset = i_sectionTOR->TOC_EQ_INSTANCE_RING; - } - - break; - - case EC_TYPE: // EC - Core 0 - 23 - l_chipletData = EC::g_ecData; - l_cpltRingVariantSz = i_applyOverride ? OVERRIDE_VARIANT_SIZE : - (sizeof(EC::RingVariants) / - sizeof(l_cpltRingVariantSz)); - - l_sectionOffset = i_sectionTOR->TOC_EC_COMMON_RING; - l_CC_offset = 1; - l_RL_offset = 2; - if(INSTANCE_RING == l_ringType) - { - l_sectionOffset = i_sectionTOR->TOC_EC_INSTANCE_RING; - } - - break; - - default: - SBE_TRACE("Invalid Target/ChipletID - %d", l_chipletID); - l_rc = fapi2::FAPI2_RC_INVALID_PARAMETER; - break; - - } // end of switch(l_chipletID) - - if (l_rc) - { - break; - } - - FAPI_INF("l_sectionOffset %08x",l_sectionOffset); - // Determine the section TOR address for the ring - uint32_t *l_sectionAddr = reinterpret_cast(g_seepromAddr + - i_sectionOffset + l_sectionOffset); - - SBE_TRACE ("l_sectionAddr %08X",(uint32_t)l_sectionAddr); - - uint16_t *l_ringTorAddr = NULL; - - - if(INSTANCE_RING == l_ringType) - { - if ( l_chipletID >= l_chipletData.iv_base_chiplet_number) - { - uint8_t l_chipletOffset = - (l_chipletID - l_chipletData.iv_base_chiplet_number); - if (l_chipLetType == EQ_TYPE) - { - if (fapi2::TARGET_TYPE_EX & (i_target.get().getFapiTargetType())) - { - uint32_t l_ex_number = i_target.get().getTargetInstance(); - l_chipletOffset = l_ex_number; - SBE_TRACE ("l_chipletID %d l_ex_number %d",l_chipletID,l_ex_number); - } - } - SBE_TRACE ("l_chipletID %u l_chipletOffset %u",l_chipletID, l_chipletOffset); - l_ringTorAddr = reinterpret_cast(l_sectionAddr )+ ((l_chipletOffset * - (l_chipletData.iv_num_instance_rings *l_cpltRingVariantSz)) + (l_torOffset * l_cpltRingVariantSz)); - - } - else - { - l_ringTorAddr = reinterpret_cast(l_sectionAddr) + - (l_torOffset * l_cpltRingVariantSz); - } - } - else - { - // TOR records of Ring TOR are 2 bytes in size. - l_ringTorAddr = reinterpret_cast(l_sectionAddr) + - (l_torOffset * l_cpltRingVariantSz); - } - - // The ring variants in section TOR are expected to be in the sequence - - // 1. Base - // 2. Cache-Contained - // 3. Risk Level - - - SBE_TRACE ("ring tor address %08X",(uint32_t)l_ringTorAddr); - - // If there are non-base variants of the ring, we'll have to check - // attributes to determine the sequence of ring apply. - if( l_cpltRingVariantSz > 1) - { - // Check if this is cache-contained IPL - uint8_t l_iplPhase; - FAPI_ATTR_GET(fapi2::ATTR_SYSTEM_IPL_PHASE, - fapi2::Target (), - l_iplPhase); - - // 4 : Use Cache Contained mode _if_ present, else fall back - // to normal ring - if((CACHE_CONTAINED_MODE == l_iplPhase) - && *(l_ringTorAddr + l_CC_offset)) - { - l_ringTorAddr += l_CC_offset; - } - else - { - // Check if this is risk-level IPL - // _if_ present, else fall back to normal ring - uint8_t l_riskLevel; - FAPI_ATTR_GET(fapi2::ATTR_RISK_LEVEL, - fapi2::Target (), - l_riskLevel); - if((RISK_LEVEL_MODE == l_riskLevel) && - *(l_ringTorAddr + l_RL_offset)) - { - l_ringTorAddr += l_RL_offset; - } - } - } - - SBE_TRACE("l_ringTorAddr %u",*l_ringTorAddr); - if(*l_ringTorAddr != 0) - { - uint8_t *l_addr = reinterpret_cast(l_sectionAddr); - uint8_t *l_rs4Address = reinterpret_cast - (l_addr + *l_ringTorAddr); - SBE_TRACE("l_rs4Address %08x",(uint32_t)l_rs4Address); - l_rc = rs4DecompressionSvc(i_target,l_rs4Address, - i_applyOverride,i_ringMode,l_ringType); - if(l_rc != fapi2::FAPI2_RC_SUCCESS) - { - SBE_TRACE("Error from applyRS4_SS"); - break; - } - } - else - { - SBE_TRACE("Ring image is not found for this is ringId %u",i_ringID); - } - }while(0); - - SBE_TRACE("<< findRS4InImageAndApply Exit for ringId %d",i_ringID); - return l_rc; -} - diff --git a/src/hwpf/src/return_code.C b/src/hwpf/src/return_code.C deleted file mode 100644 index b9d0f5fd..00000000 --- a/src/hwpf/src/return_code.C +++ /dev/null @@ -1,47 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/hwpf/src/return_code.C $ */ -/* */ -/* 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 return_code.C - * - * @brief Fuctions that process PPE return codes - */ - -#include - -namespace fapi2 -{ - - /// @brief Takes a non-zero PIB return code and inssert the value into - /// a fapi2::ReturnCode - /// @param[in] i_msr Value read from the PPE MSR - /// @return fapi::ReturnCode. Built ReturnCode - ReturnCode& ReturnCode::insertPIBcode(uint32_t& rhs) - { - iv_rc = FAPI2_RC_PLAT_MASK | rhs; - return iv_rc; - } - -} diff --git a/src/hwpf/target.C b/src/hwpf/target.C new file mode 100644 index 00000000..7287105e --- /dev/null +++ b/src/hwpf/target.C @@ -0,0 +1,754 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/hwpf/target.C $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2012,2017 */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ + + +#include +#include +#include +#include +#include + +// Global Vector containing ALL targets. This structure is referenced by +// fapi2::getChildren to produce the resultant returned vector from that +// call. +std::vector G_vec_targets; + +// Global variable for fixed section in pibmem +G_sbe_attrs_t G_sbe_attrs; + +fapi2attr::SystemAttributes_t* G_system_attributes_ptr; +fapi2attr::ProcChipAttributes_t* G_proc_chip_attributes_ptr; +fapi2attr::PervAttributes_t* G_perv_attributes_ptr; +fapi2attr::CoreAttributes_t* G_core_attributes_ptr; +fapi2attr::EQAttributes_t* G_eq_attributes_ptr; +fapi2attr::EXAttributes_t* G_ex_attributes_ptr; + +namespace fapi2 +{ + static ReturnCode plat_AttrInit() + { + union + { + struct + { + uint64_t iv_majorEC : 4; + uint64_t iv_deviceIdDontCare : 4; + uint64_t iv_minorEC : 4; + uint64_t iv_chipId : 8; + uint64_t iv_deviceIdDontCare2 : 20; + uint64_t iv_c4Pin : 1; + uint64_t iv_deviceIdDontCare3 : 23; + }; + uint64_t iv_deviceIdReg; + } l_deviceId; + + uint8_t l_chipName = fapi2::ENUM_ATTR_NAME_NONE; + uint8_t l_ec = 0; + fapi2::Target l_chipTarget = + plat_getChipTarget(); + + FAPI_TRY(getscom_abs(PERV_DEVICE_ID_REG, &l_deviceId.iv_deviceIdReg)); + l_ec = (l_deviceId.iv_majorEC << 4) | (l_deviceId.iv_minorEC); + switch(l_deviceId.iv_chipId) + { + case 0xD1: + l_chipName = fapi2::ENUM_ATTR_NAME_NIMBUS; + break; + case 0xD4: + l_chipName = fapi2::ENUM_ATTR_NAME_CUMULUS; + break; + default: + FAPI_ERR("Unsupported chip ID: 0x%02X", + static_cast(l_deviceId.iv_chipId)); + assert(false); + } + + FAPI_TRY(PLAT_ATTR_INIT(fapi2::ATTR_NAME, l_chipTarget, l_chipName)); + + FAPI_TRY(PLAT_ATTR_INIT(fapi2::ATTR_EC, l_chipTarget, l_ec)); +fapi_try_exit: + return fapi2::current_err; + } + + // Get the plat target handle by chiplet number - For PERV targets + template<> + plat_target_handle_t plat_getTargetHandleByChipletNumber( + const uint8_t i_chipletNumber) + { + uint32_t l_idx = 0; + + if((i_chipletNumber > 0) && + (i_chipletNumber < (EQ_CHIPLET_OFFSET + EQ_TARGET_COUNT))) + { + l_idx = (i_chipletNumber - NEST_GROUP1_CHIPLET_OFFSET) + + NEST_GROUP1_TARGET_OFFSET; + } + else if((i_chipletNumber >= CORE_CHIPLET_OFFSET) && + (i_chipletNumber < (CORE_CHIPLET_OFFSET + CORE_TARGET_COUNT))) + { + l_idx = (i_chipletNumber - CORE_CHIPLET_OFFSET) + + CORE_TARGET_OFFSET; + } + else + { + assert(false); + } + return G_vec_targets[l_idx]; + } + + // Get the plat target handle by chiplet number - For EQ targets + template<> + plat_target_handle_t plat_getTargetHandleByChipletNumber( + const uint8_t i_chipletNumber) + { + assert(((i_chipletNumber >= EQ_CHIPLET_OFFSET) && + (i_chipletNumber < (EQ_CHIPLET_OFFSET + EQ_TARGET_COUNT)))) + + uint32_t l_idx = (i_chipletNumber - EQ_CHIPLET_OFFSET) + + EQ_TARGET_OFFSET; + return G_vec_targets[l_idx]; + } + + // Get the plat target handle by chiplet number - For CORE targets + template<> + plat_target_handle_t plat_getTargetHandleByChipletNumber( + const uint8_t i_chipletNumber) + { + assert(((i_chipletNumber >= CORE_CHIPLET_OFFSET) && + (i_chipletNumber < (CORE_CHIPLET_OFFSET + CORE_TARGET_COUNT)))); + + uint32_t l_idx = (i_chipletNumber - CORE_CHIPLET_OFFSET) + + CORE_TARGET_OFFSET; + + return G_vec_targets[l_idx]; + } + + // Get the plat target handle by chiplet number - For EX targets + template<> + plat_target_handle_t plat_getTargetHandleByChipletNumber( + const uint8_t i_chipletNumber) + { + assert(((i_chipletNumber >= CORE_CHIPLET_OFFSET) && + (i_chipletNumber < (CORE_CHIPLET_OFFSET + CORE_TARGET_COUNT)))); + + uint32_t l_idx = ((i_chipletNumber - CORE_CHIPLET_OFFSET) / 2) + + EX_TARGET_OFFSET; + + return G_vec_targets[l_idx]; + } + + // Get plat target handle by instance number - For EX targets + template <> + plat_target_handle_t plat_getTargetHandleByInstance( + const uint8_t i_targetNum) + { + assert(i_targetNum < EX_TARGET_COUNT); + + return G_vec_targets[i_targetNum + EX_TARGET_OFFSET]; + } + + + TargetType plat_target_handle_t::getFapiTargetType() const + { + TargetType l_targetType = TARGET_TYPE_NONE; + switch(fields.type) + { + case PPE_TARGET_TYPE_PROC_CHIP: + l_targetType = TARGET_TYPE_PROC_CHIP; + break; + case PPE_TARGET_TYPE_MCS: + l_targetType = TARGET_TYPE_MCS; + break; + case PPE_TARGET_TYPE_PHB: + l_targetType = TARGET_TYPE_PHB; + break; + case PPE_TARGET_TYPE_CORE | PPE_TARGET_TYPE_PERV: + l_targetType = TARGET_TYPE_CORE; + break; + case PPE_TARGET_TYPE_EQ | PPE_TARGET_TYPE_PERV: + l_targetType = TARGET_TYPE_EQ; + break; + case PPE_TARGET_TYPE_EX: + l_targetType = TARGET_TYPE_EX; + break; + case PPE_TARGET_TYPE_PERV: + l_targetType = TARGET_TYPE_PERV; + break; + case PPE_TARGET_TYPE_SYSTEM: + l_targetType = TARGET_TYPE_SYSTEM; + break; + case PPE_TARGET_TYPE_MCBIST | PPE_TARGET_TYPE_PERV: + l_targetType = TARGET_TYPE_MCBIST; + break; + case PPE_TARGET_TYPE_NONE: + case PPE_TARGET_TYPE_ALL: + default: + assert(false); + break; + } + return l_targetType; + } + + plat_target_handle_t plat_target_handle_t::getParent( + const TargetType i_parentType) const + { + plat_target_handle_t l_handle; + switch(i_parentType) + { + case TARGET_TYPE_PROC_CHIP: + l_handle = G_vec_targets[CHIP_TARGET_OFFSET]; + break; + case TARGET_TYPE_PERV: + assert(fields.type & PPE_TARGET_TYPE_PERV); + l_handle = *this; + break; + case TARGET_TYPE_EX: + assert(fields.type & PPE_TARGET_TYPE_CORE); + l_handle = G_vec_targets + [(fields.type_target_num / EX_PER_QUAD) + EX_TARGET_OFFSET]; + break; + case TARGET_TYPE_EQ: + assert(fields.type & + (PPE_TARGET_TYPE_EX | PPE_TARGET_TYPE_CORE)); + { + uint32_t l_perQuad = (fields.type & PPE_TARGET_TYPE_EX) ? + EX_PER_QUAD : CORES_PER_QUAD; + l_handle = G_vec_targets + [(fields.type_target_num / l_perQuad) + + EQ_TARGET_OFFSET]; + } + break; + default: + assert(false); + } + return l_handle; + } + + void plat_target_handle_t::getChildren(const TargetType i_parentType, + const TargetType i_childType, + const plat_target_type_t i_platType, + const TargetState i_state, + std::vector + &o_children) const + { + uint32_t l_childPerChiplet = 0; + uint32_t l_childTargetOffset = 0; + uint32_t l_loopCount = G_vec_targets.size(); + TargetType l_targetType = i_parentType; + + if((i_parentType & ~(TARGET_TYPE_PROC_CHIP)) != 0) + { + // For composite targets, if multicast, treat as PROC_CHIP, else + // treat as other target + if(this->fields.is_multicast) + { + l_targetType = TARGET_TYPE_PROC_CHIP; + } + else + { + l_targetType = + static_cast(l_targetType & ~(TARGET_TYPE_PROC_CHIP)); + } + } + + // EQ ==> EX + if((l_targetType == TARGET_TYPE_EQ) && (i_childType == TARGET_TYPE_EX)) + { + l_childPerChiplet = EX_PER_QUAD; + l_childTargetOffset = EX_TARGET_OFFSET; + l_loopCount = l_childPerChiplet; + } + + // EQ ==> EC + if((l_targetType == TARGET_TYPE_EQ) && (i_childType == TARGET_TYPE_CORE)) + { + l_childPerChiplet = CORES_PER_QUAD; + l_childTargetOffset = CORE_TARGET_OFFSET; + l_loopCount = l_childPerChiplet; + } + + // EX ==> EC + if((l_targetType == TARGET_TYPE_EX) && (i_childType == TARGET_TYPE_CORE)) + { + l_childPerChiplet = CORES_PER_EX; + l_childTargetOffset = CORE_TARGET_OFFSET; + l_loopCount = l_childPerChiplet; + } + // else it is TARGET_TYPE_PROC_CHIP ==> anything, and we iterate over + // all the targets + + for(uint32_t i = 0; i < l_loopCount; ++i) + { + plat_target_handle_t l_temp = + G_vec_targets.at((this->fields.type_target_num * + l_childPerChiplet) + l_childTargetOffset + i); + if ((l_temp.fields.type & i_platType) == i_platType) + { + switch (i_state) + { + case TARGET_STATE_PRESENT: + if (l_temp.fields.present) + { + o_children.push_back(l_temp); + } + break; + case TARGET_STATE_FUNCTIONAL: + if (l_temp.fields.functional) + { + o_children.push_back(l_temp); + } + break; + default: + assert(false); + } + } + } + } + + void plat_target_handle_t::getChildren(const TargetFilter i_filter, + const TargetState i_state, + std::vector + &o_children) const + { + static const uint64_t mask = 1; + + // Walk the bits in the input target filter. For every bit, at + // position x, that is set, x can be used as an index into our global + // target vector (indexed by chiplet number) + for (uint32_t l_idx = 0; + l_idx < sizeof(TargetFilter) * 8; + ++l_idx) + { + if (i_filter & (mask << (((sizeof(TargetFilter)*8)-1) - l_idx))) + { + plat_target_handle_t l_targetHandle = G_vec_targets.at(l_idx + NEST_GROUP1_CHIPLET_OFFSET); + + if(l_targetHandle.fields.type & PPE_TARGET_TYPE_PERV) // Can be an assertion? + { + switch (i_state) + { + case TARGET_STATE_PRESENT: + if(l_targetHandle.fields.present) + { + o_children.push_back(l_targetHandle); + } + break; + case TARGET_STATE_FUNCTIONAL: + if(l_targetHandle.fields.functional) + { + o_children.push_back(l_targetHandle); + } + break; + default: + break; + } + } + } + } + } + + #ifndef __noRC__ + ReturnCode current_err; + #endif + + fapi2::ReturnCode plat_PervPGTargets(const fapi2::Target & i_target, + bool & o_present) + { + o_present = false; + uint16_t attr_value = 0; + FAPI_ATTR_GET(fapi2::ATTR_PG, + i_target, + attr_value); + FAPI_DBG("Target: 0x%08X, ATTR_PG value = %x", static_cast(i_target.get().value), attr_value); + if (0 == (attr_value & 0x1000)) + { + o_present = true; + } + return fapi2::FAPI2_RC_SUCCESS; + } + + /// @brief Function to determine if pervsaive target within a chip is + /// present and, thus, considered functional per PG attributes + fapi2::ReturnCode + plat_TargetPresent( fapi2::Target & i_chiplet_target, + bool & b_present) + { + + uint8_t l_chipName = fapi2::ENUM_ATTR_NAME_NONE; + + FAPI_TRY(FAPI_ATTR_GET_PRIVILEGED(fapi2::ATTR_NAME, plat_getChipTarget(), l_chipName)); + + // TODO via RTC 164026 + // In nimbus all pervasive chiplets (non quad, non core), are present + // other than OBUS1 and OBUS2. In cumulus all chiplets are present. + // Though on field parts, all chiplets which are present should be + // functional. But in lab when we can get partial good parts, its + // possible that few chiplets are not functional. So we need to + // differentiate between present versus functional chiplets. + // We need to see if we need to use same strategy for cores/caches as + // well. + // Also in current code we are hard coding the chiplets. We need to use + // attribute to differentiate between nimbus versus cumulus config. + static const size_t OBUS1 = 10; + static const size_t OBUS2 = 11; + if((OBUS1 == i_chiplet_target.getChipletNumber()) || + (OBUS2 == i_chiplet_target.getChipletNumber())) + { + if(fapi2::ENUM_ATTR_NAME_CUMULUS == l_chipName) + { + static_cast((i_chiplet_target.operator()())).setPresent(); + } + } + else if( i_chiplet_target.getChipletNumber() < EQ_CHIPLET_OFFSET ) + { + static_cast((i_chiplet_target.operator()())).setPresent(); + } + // Find the PERV target number in the partial good initialization + // array + + FAPI_TRY(plat_PervPGTargets(i_chiplet_target, b_present)); + + if (b_present) + { + if( i_chiplet_target.getChipletNumber() >= EQ_CHIPLET_OFFSET ) + { + static_cast((i_chiplet_target.operator()())).setPresent(); + } + static_cast((i_chiplet_target.operator()())).setFunctional(true); + } + else + { + FAPI_DBG("Perv target NOT present (nor functional): chiplet_number = %d", i_chiplet_target.getChipletNumber()); + } + + FAPI_DBG("Target present = %u, Target functional = %u", + static_cast(i_chiplet_target.get()).getPresent(), + static_cast(i_chiplet_target.get()).getFunctional()); + +fapi_try_exit: + return fapi2::current_err; + } + + + /// @brief Function to initialize the G_targets vector based on partial good + /// attributes /// this will move to plat_target.H formally + fapi2::ReturnCode plat_TargetsInit() + { + bool b_present = false; + + // Copy fixed section from SEEPROM to PIBMEM + G_sbe_attrs.G_system_attrs = G_system_attributes; + G_sbe_attrs.G_proc_chip_attrs = G_proc_chip_attributes; + G_sbe_attrs.G_perv_attrs = G_perv_attributes; + G_sbe_attrs.G_core_attrs = G_core_attributes; + G_sbe_attrs.G_eq_attrs = G_eq_attributes; + G_sbe_attrs.G_ex_attrs = G_ex_attributes; + + // Initialise global attribute pointers + G_system_attributes_ptr = &(G_sbe_attrs.G_system_attrs); + G_proc_chip_attributes_ptr = &(G_sbe_attrs.G_proc_chip_attrs); + G_perv_attributes_ptr = &(G_sbe_attrs.G_perv_attrs); + G_core_attributes_ptr = &(G_sbe_attrs.G_core_attrs); + G_eq_attributes_ptr = &(G_sbe_attrs.G_eq_attrs); + G_ex_attributes_ptr = &(G_sbe_attrs.G_ex_attrs); + + + std::vector::iterator tgt_iter; + uint32_t l_beginning_offset; + + FAPI_DBG("Platform target initialization. Target Count = %u", TARGET_COUNT); + /* + * Initialize all entries to NULL + */ + for (uint32_t i = 0; i < TARGET_COUNT; ++i) + { + G_vec_targets.push_back((fapi2::plat_target_handle_t)0x0); + } + + /* + * Chip Target is the first one + */ + l_beginning_offset = CHIP_TARGET_OFFSET; + + fapi2::Target chip_target((createPlatTargetHandle(0))); + G_vec_targets.at(l_beginning_offset) = revle32((fapi2::plat_target_handle_t)(chip_target.get())); + + // Initialize platform attributes. Needs to be after the chip target is + // created. + FAPI_TRY(plat_AttrInit()); + + /* + * Nest Targets - group 1 + */ + l_beginning_offset = NEST_GROUP1_TARGET_OFFSET; + for (uint32_t i = 0; i < NEST_GROUP1_TARGET_COUNT; ++i) + { + fapi2::Target target_name((createPlatTargetHandle(i))); + + // Determine if the chiplet is present and, thus, functional + // via partial good attributes + FAPI_TRY(plat_TargetPresent(target_name, b_present)); + + G_vec_targets.at(l_beginning_offset+i) = revle32((fapi2::plat_target_handle_t)(target_name.get())); + } + + /* + * Memory Controller Synchronous (MCBIST) Targets + */ + + l_beginning_offset = MCBIST_TARGET_OFFSET; + for (uint32_t i = 0; i < MCBIST_TARGET_COUNT; ++i) + { + fapi2::Target target_name((createPlatTargetHandle(i))); + fapi2::Target l_perv = target_name.getParent(); + + // Determine if the chiplet is present and, thus, functional + // via partial good attributes + FAPI_TRY(plat_TargetPresent(l_perv, b_present)); + + G_vec_targets.at(l_beginning_offset+i) = revle32((fapi2::plat_target_handle_t)(l_perv.get())); + + } + + /* + * Nest Targets - group 2 + */ + l_beginning_offset = NEST_GROUP2_TARGET_OFFSET; + for (uint32_t i = NEST_GROUP2_TARGET_OFFSET; + i < (NEST_GROUP2_TARGET_OFFSET + NEST_GROUP2_TARGET_COUNT); ++i) + { + fapi2::Target target_name((createPlatTargetHandle(i - 1))); + + // Determine if the chiplet is present and, thus, functional + // via partial good attributes + FAPI_TRY(plat_TargetPresent(target_name, b_present)); + + G_vec_targets.at(i) = revle32((fapi2::plat_target_handle_t)(target_name.get())); + } + + /* + * Cache (EQ) Targets + */ + l_beginning_offset = EQ_TARGET_OFFSET; + for (uint32_t i = 0; i < EQ_TARGET_COUNT; ++i) + { + fapi2::Target target_name((createPlatTargetHandle(i))); + fapi2::Target l_perv = target_name.getParent(); + + // Determine if the chiplet is present and, thus, functional + // via partial good attributes + FAPI_TRY(plat_TargetPresent(l_perv, b_present)); + + G_vec_targets.at(l_beginning_offset+i) = revle32((fapi2::plat_target_handle_t)(l_perv.get())); + } + + /* + * Core (EC) Targets + */ + + l_beginning_offset = CORE_TARGET_OFFSET; + for (uint32_t i = 0; i < CORE_TARGET_COUNT; ++i) + { + fapi2::Target target_name((createPlatTargetHandle(i))); + fapi2::Target l_perv = target_name.getParent(); + + // Determine if the chiplet is present and, thus, functional + // via partial good attributes + FAPI_TRY(plat_TargetPresent(l_perv, b_present)); + + G_vec_targets.at(l_beginning_offset+i) = revle32((fapi2::plat_target_handle_t)(l_perv.get())); + } + + /* + * EX Targets + */ + + l_beginning_offset = EX_TARGET_OFFSET; + for (uint32_t i = 0; i < EX_TARGET_COUNT; ++i) + { + fapi2::Target target_name((createPlatTargetHandle(i))); + + fapi2::Target l_parent = target_name.getParent(); + + // Get the parent EQ's ATTR_PG + uint16_t l_eqAttrPg = 0; + FAPI_ATTR_GET(fapi2::ATTR_PG, l_parent.getParent(), l_eqAttrPg); + + // Check if this EX's L2 and L3 regions are marked "good" + if(0 == (i % EX_PER_QUAD)) + { + // Bits 6 and 8 need to be 0 + l_eqAttrPg &= 0x0280; + } + else + { + // Bits 7 and 9 need to be 0 + l_eqAttrPg &= 0x0140; + } + + if(0 == l_eqAttrPg) + { + static_cast(target_name.operator ()()).setPresent(); + static_cast(target_name.operator ()()).setFunctional(true); + } + G_vec_targets.at(l_beginning_offset+i) = revle32((fapi2::plat_target_handle_t)(target_name.get())); + } + + /* + * MCS Targets + */ + + l_beginning_offset = MCS_TARGET_OFFSET; + for (uint32_t i = 0; i < MCS_TARGET_COUNT; ++i) + { + fapi2::Target target_name(createPlatTargetHandle(i)); + + fapi2::Target + l_nestTarget((plat_getTargetHandleByChipletNumber(N3_CHIPLET - (MCS_PER_MCBIST * (i / MCS_PER_MCBIST))))); + + uint16_t l_attrPg = 0; + + FAPI_ATTR_GET(fapi2::ATTR_PG, l_nestTarget, l_attrPg); + + if(0 == (i / MCS_PER_MCBIST)) + { + // Bit 10 needs to be 0 for MCS 0, 1 + l_attrPg &= 0x0020; + } + else + { + // Bit 9 needs to be 0 for MCS 2, 3 + l_attrPg &= 0x0040; + } + + if(0 == l_attrPg) + { + static_cast(target_name.operator ()()).setPresent(); + static_cast(target_name.operator ()()).setFunctional(true); + } + + G_vec_targets.at(l_beginning_offset+i) = revle32((fapi2::plat_target_handle_t)(target_name.get())); + } + + /* + * PHB Targets + */ + l_beginning_offset = PHB_TARGET_OFFSET; + for (uint32_t i = 0; i < PHB_TARGET_COUNT; ++i) + { + fapi2::Target target_name(createPlatTargetHandle(i)); + + fapi2::Target + l_pciTarget((plat_getTargetHandleByChipletNumber(target_name.getChipletNumber()))); + + constexpr uint16_t l_pciPgArray[] = {0xE1FD, 0xE0FD, 0xE07D}; + uint16_t l_attrPg = 0; + + FAPI_ATTR_GET(fapi2::ATTR_PG, l_pciTarget, l_attrPg); + + if(l_pciPgArray[target_name.getChipletNumber() - PCI0_CHIPLET] == l_attrPg) + { + static_cast(target_name.operator ()()).setPresent(); + static_cast(target_name.operator ()()).setFunctional(true); + } + + G_vec_targets.at(l_beginning_offset+i) = revle32((fapi2::plat_target_handle_t)(target_name.get())); + } + + +fapi_try_exit: + return fapi2::current_err; + } + + /// @brief Function to initialize the G_targets vector based on partial good + /// attributes + fapi2::Target plat_getChipTarget() + { + + // Get the chip specific target + return ((fapi2::Target)G_vec_targets.at(0)); + } + + /// @brief Function to apply any gard records set (via + // ATTR_EQ_GARD/ATTR_EC_GARD) to mark corresponding targets non functional + ReturnCode plat_ApplyGards() + { + uint8_t l_eqGards = 0; + uint32_t l_ecGards = 0; + static const uint32_t l_mask = 0x80000000; + bool l_coreGroupNonFunctional = true; + fapi2::Target l_chip = plat_getChipTarget(); + + // Read the EQ and EC gard attributes from the chip target + FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_EQ_GARD, l_chip, l_eqGards)); + FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_EC_GARD, l_chip, l_ecGards)); + + FAPI_DBG("ATTR_EQ_GARD:: 0x%08x", l_eqGards); + FAPI_DBG("ATTR_EC_GARD:: 0x%08x", l_ecGards); + + // Iterate over the bits in EQ and EC gards, if set, mark the + // corresponding target non-functional + for(uint32_t l_idx = 0; l_idx < EQ_TARGET_COUNT; ++l_idx) + { + if((l_mask >> l_idx) & (((uint32_t)(l_eqGards)) << 24)) + { + FAPI_DBG("Making %d'th EQ non-functional", l_idx); + // EQ chiplet l_idx is to be marked non-functional + fapi2::Target l_target = G_vec_targets.at(l_idx + EQ_TARGET_OFFSET); + static_cast(l_target.operator ()()).setFunctional(false); + G_vec_targets.at(l_idx + EQ_TARGET_OFFSET) = l_target.get(); + } + } + + for(uint32_t l_idx = 0; l_idx < CORE_TARGET_COUNT; ++l_idx) + { + if((l_mask >> l_idx) & (l_ecGards)) + { + FAPI_DBG("Making %d'th EC non-functional", l_idx); + // EC chiplet l_idx is to be marked non-functional + fapi2::Target l_target = G_vec_targets.at(l_idx + CORE_TARGET_OFFSET); + static_cast(l_target.operator ()()).setFunctional(false); + G_vec_targets.at(l_idx + CORE_TARGET_OFFSET) = l_target.get(); + } + else + { + l_coreGroupNonFunctional = false; + } + if(0 == ((l_idx + 1) % CORES_PER_EX)) + { + if(true == l_coreGroupNonFunctional) + { + // All cores of this group are non-functional. Mark the EX + // non-functional too. + G_vec_targets.at((l_idx / CORES_PER_EX) + EX_TARGET_OFFSET).fields.functional = false; + } + // Reset ex non-functional flag for the next group + l_coreGroupNonFunctional = true; + } + } +fapi_try_exit: + return fapi2::current_err; + } + +} // fapi2 diff --git a/src/hwpf/target.H b/src/hwpf/target.H new file mode 100644 index 00000000..190b3da3 --- /dev/null +++ b/src/hwpf/target.H @@ -0,0 +1,409 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/hwpf/target.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2012,2017 */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +/** + * @file target.H + * @brief platform specializations for fapi2 targets + */ + +#ifndef __FAPI2_TARGET__ +#define __FAPI2_TARGET__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" +{ + extern std::vector G_vec_targets; +} + +struct ScomAddr +{ + ScomAddr(uint32_t i_addr) : iv_addr(i_addr) + { + } + + operator uint32_t() + { + return iv_addr; + } + + union + { + struct + { + uint32_t iv_unused : 1; + uint32_t iv_multicast : 1; + uint32_t iv_chiplet : 6; + uint32_t iv_pibMaster : 4; + uint32_t iv_port : 4; + uint32_t iv_unused2 : 2; + uint32_t iv_ring : 4; + uint32_t iv_satId : 4; + uint32_t iv_satOffset : 6; + }; + uint32_t iv_addr; + }; +}; + + +namespace fapi2 +{ + + template + constexpr plat_target_type_t fapiTargetTypeToPlatTargetType() + { + return PPE_TARGET_TYPE_NONE; + } + + template<> + constexpr plat_target_type_t fapiTargetTypeToPlatTargetType() + { + return PPE_TARGET_TYPE_PROC_CHIP; + } + + template<> + constexpr plat_target_type_t fapiTargetTypeToPlatTargetType() + { + return PPE_TARGET_TYPE_EQ; + } + + template<> + constexpr plat_target_type_t fapiTargetTypeToPlatTargetType() + { + return PPE_TARGET_TYPE_CORE; + } + + template<> + constexpr plat_target_type_t fapiTargetTypeToPlatTargetType() + { + return PPE_TARGET_TYPE_EX; + } + + template<> + constexpr plat_target_type_t fapiTargetTypeToPlatTargetType() + { + return PPE_TARGET_TYPE_MCS; + } + + template<> + constexpr plat_target_type_t fapiTargetTypeToPlatTargetType() + { + return PPE_TARGET_TYPE_PHB; + } + + template<> + constexpr plat_target_type_t fapiTargetTypeToPlatTargetType() + { + return PPE_TARGET_TYPE_MCBIST; + } + + template<> + constexpr plat_target_type_t fapiTargetTypeToPlatTargetType() + { + return PPE_TARGET_TYPE_PERV; + } + + /// + /// @brief Assignment Operator. + /// @param[in] i_right Reference to Target to assign from. + /// @return Reference to 'this' Target + /// + template + Target& Target::operator=(const Target& i_right) + { + this->iv_handle.value = i_right.iv_handle.value; + return *this; + } + /// + /// @brief Equality Comparison Operator + /// @param[in] i_right Reference to Target to compare. + /// @return bool. True if equal. + /// @note Platforms need to define this so that the physical + /// targets are determined to be equivilent rather than just the handles + /// + template + bool Target::operator==(const Target& i_right) const + { + if (this->iv_handle.value == i_right.iv_handle.value) + return true; + else + return false; + } + + /// + /// @brief Inquality Comparison Operator + /// @param[in] i_right Reference to Target to compare. + /// @return bool. True if not equal. + /// @note Platforms need to define this so that the physical + /// targets are determined to be equivilent rather than just the handles + /// + template + bool Target::operator!=(const Target& i_right) const + { + if (this->iv_handle.value != i_right.iv_handle.value) + return true; + else + return false; + } + + /// + /// @brief Get this target's immediate parent + /// @tparam T The type of the parent + /// @return Target a target representing the parent + /// + template + template + inline Target Target::getParent(void) const + { + constexpr TargetType TARGET_TYPE_PROC_CHILDREN = + TARGET_TYPE_EQ | TARGET_TYPE_PERV | TARGET_TYPE_EX | + TARGET_TYPE_MCBIST | TARGET_TYPE_CORE | + TARGET_TYPE_MCS | TARGET_TYPE_PROC_CHIP | TARGET_TYPE_PHB; + + static_assert((( + ((K & TARGET_TYPE_PROC_CHILDREN) != TARGET_TYPE_NONE) || + (K == TARGET_TYPE_ALL)) && + ((T == TARGET_TYPE_EQ) || + (T == TARGET_TYPE_EX) || + (T == TARGET_TYPE_PROC_CHIP) || + (T == TARGET_TYPE_PERV))), + "Invalid parent/child target type passed"); + + static_assert(!((K == TARGET_TYPE_EQ) && + (T != TARGET_TYPE_PERV) && + (T != TARGET_TYPE_PROC_CHIP)), + "Invalid parent for EQ target, must be PERV or " + "PROC_CHIP"); + + static_assert(!((T == TARGET_TYPE_PROC_CHIP) && + ((K & TARGET_TYPE_PROC_CHILDREN) == TARGET_TYPE_NONE)), + "Parent proc chip invalid for this target type"); + + static_assert(!((K == TARGET_TYPE_MCBIST) && + (T != TARGET_TYPE_PERV) && + (T != TARGET_TYPE_PROC_CHIP)), + "Invalid parent for MCBIST target, must be PERV or " + "PROC_CHIP"); + + static_assert(!((K == TARGET_TYPE_CORE) && + (T != TARGET_TYPE_PERV) && + (T != TARGET_TYPE_PROC_CHIP) && + (T != TARGET_TYPE_EQ) && + (T != TARGET_TYPE_EX)), + "Invalid parent for CORE target, must be PERV or " + "PROC_CHIP or EQ or EX"); + + static_assert(!((K == TARGET_TYPE_PERV) && + (T != TARGET_TYPE_PERV) && + (T != TARGET_TYPE_PROC_CHIP)), + "Invalid parent for PERV target, must be PERV or " + "PROC_CHIP"); + + static_assert(!((K == TARGET_TYPE_EX) && + (T != TARGET_TYPE_PROC_CHIP) && + (T != TARGET_TYPE_EQ)), + "Invalid parent for EX target, must be PERV or " + "PROC_CHIP or EQ"); + + if(TARGET_TYPE_PERV == T) // EQ/EC/MCBIST/PERV ===> PERV + { + return static_cast(this->iv_handle); + } + if(TARGET_TYPE_PROC_CHIP == T) // EQ/EC/EX/MCBIST/PERV ===> PROC + { + return static_cast(G_vec_targets[CHIP_TARGET_OFFSET]); + } + if((TARGET_TYPE_EQ == T) && (TARGET_TYPE_CORE == K)) // EC ===> EQ + { + return static_cast(G_vec_targets[(static_cast(get()).getTargetInstance() / CORES_PER_QUAD) + EQ_TARGET_OFFSET]); + } + if((TARGET_TYPE_EQ == T) && (TARGET_TYPE_EX == K)) // EX ===> EQ + { + return static_cast(G_vec_targets[(static_cast(get()).getTargetInstance() / EX_PER_QUAD) + EQ_TARGET_OFFSET]); + } + if(TARGET_TYPE_EX == T) // EC ===> EX + { + return static_cast(G_vec_targets[(static_cast(get()).getTargetInstance() / CORES_PER_EX) + EX_TARGET_OFFSET]); + } + } + + /// + /// @brief Get this target's immediate parent - specialization for compound + // target (PROC_CHIP | CORE | EX) + /// @tparam T The type of the parent + /// @return Target a target representing the parent + /// + template<> + template + Target + Target::getParent(void) const + { + static_assert(((T == TARGET_TYPE_PROC_CHIP) || (T == TARGET_TYPE_EQ)), + "Wrong parent target type"); + return static_cast(get()).getParent(T); + } + + /// @brief Get this target's children - handles EQ/EX/EC conversions + /// @tparam K The type of parent + /// @tparam V The plat target handle type + /// @tparam T The type of child + /// @param[in] i_state The desired TargetState of the children + /// @return std::vector > a vector of present/functional + /// children + /// @warning The children are returned in order, ex child[0] is + /// std::vector[0] + template + template + std::vector> + Target::getChildren(const TargetState i_state) const + { + constexpr TargetType L = static_cast(K & ~(TARGET_TYPE_PROC_CHIP)); + constexpr plat_target_type_t P = fapiTargetTypeToPlatTargetType(); + + static_assert(sizeof(Target) == sizeof(plat_target_handle_t), + "Sizes of plat target and FAPI target must match"); + + static_assert(((L == TARGET_TYPE_EQ) || (L == TARGET_TYPE_EX) || (K == TARGET_TYPE_PROC_CHIP)), + "Invalid parent passed to getChildren"); + // valid children for EQ + // EQ -> CORE + // EQ -> EX + static_assert(!((L == fapi2::TARGET_TYPE_EQ) && + (T != fapi2::TARGET_TYPE_CORE) && + (T != fapi2::TARGET_TYPE_EX)), + "improper child of fapi2::TARGET_TYPE_EQ"); + + // valid children for EX + // EX -> CORE + static_assert(!((L == fapi2::TARGET_TYPE_EX) && + (T != fapi2::TARGET_TYPE_CORE)), + "improper child of fapi2::TARGET_TYPE_EX"); + + + std::vector > l_children; + static_cast(get()).getChildren(K, T, P, i_state, reinterpret_cast&>(l_children)); + return l_children; + } + + // Specialization of getChildren, filtered for the chip target + template + template + std::vector > + Target::getChildren(const TargetFilter i_filter, + const TargetState i_state) const + { + static_assert(sizeof(Target) == sizeof(plat_target_handle_t), + "Sizes of plat target and FAPI target must match"); + + static_assert((K == TARGET_TYPE_PROC_CHIP), "Parent target must be the proc chip"); + static_assert((T == TARGET_TYPE_EQ) || (T == TARGET_TYPE_CORE) + || (T == TARGET_TYPE_PERV) || (T == TARGET_TYPE_MCBIST), + "Child target type must be a pervasive chiplet"); + + std::vector > l_children; + + (static_cast(get())).getChildren(i_filter, i_state, reinterpret_cast&>(l_children)); + + return l_children; + } + + /// + /// @brief Is the target functional? + /// @return true if target is functional, false if non-functional + /// + template + inline bool + Target::isFunctional(void) const + { + return static_cast(get()).getFunctional(); + } + + /// + /// @brief Returns the chiplet number for this Target + /// @return The chiplet number + /// + template + inline uint8_t + Target::getChipletNumber(void) const + { + return static_cast(iv_handle).fields.chiplet_num; + } + + /// + /// @brief Return the string interpretation of this target + /// @tparam T The type of the target + /// @param[in] i_target Target + /// @param[in] i_buffer buffer to write in to + /// @param[in] i_bsize size of the buffer + /// @return void + /// @post The contents of the buffer is replaced with the string + /// representation of the target + /// + template< TargetType T, typename V > + inline void toString(const Target& i_target, char* i_buffer, size_t i_bsize) + { + snprintf(i_buffer, i_bsize, "Target 0x%lx/0x%x", i_target.get(), T); + } + + /// + /// @brief Return the string interpretation of this target + /// @tparam T The type of the target + /// @tparam B The type of the buffer + /// @param[in] A pointer to the Target + /// @param[in] i_buffer buffer to write in to + /// @param[in] i_bsize size of the buffer + /// @return void + /// @post The contents of the buffer is replaced with the string + /// representation of the target + /// + template< TargetType T, typename V > + inline void toString(const Target* i_target, char* i_buffer, size_t i_bsize) + { + snprintf(i_buffer, i_bsize, "Target 0x%lx/0x%x", i_target->get(), T); + } + + /// + /// @brief Get an enumerated target of a specific type + /// @tparam T The type of the target + /// @param[in] Ordinal representing the ordinal number of + /// the desired target + /// @return Target the target requested + /// + template + inline Target getTarget(uint64_t Ordinal) + { + // For testing + return Target(Ordinal); + } +} + +#endif -- cgit v1.2.1