diff options
| author | crgeddes <crgeddes@us.ibm.com> | 2015-12-10 15:55:51 -0600 |
|---|---|---|
| committer | WILLIAM G. HOFFA <wghoffa@us.ibm.com> | 2016-02-26 08:49:33 -0600 |
| commit | 581462957e6df9ea663914fabf65f9f77b4e4bfa (patch) | |
| tree | 26602a2bccd1a3bfdc95d8c935ae74cecd155aed /src/include | |
| parent | a9e3b39d8520ff5c0356e85d4ce27ebf8f9a5fef (diff) | |
| download | talos-hostboot-581462957e6df9ea663914fabf65f9f77b4e4bfa.tar.gz talos-hostboot-581462957e6df9ea663914fabf65f9f77b4e4bfa.zip | |
Basic Hostboot platform support for FAPI2
Allows clean compile and link of FAPI2 procedures and a subset of the
platform functional support
RTC:123290
Change-Id: I9faa3bea86d1b43bca0a7eaca3869b45cc0b0d54
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/23046
Tested-by: Jenkins Server
Reviewed-by: Martin Gloff <mgloff@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Reviewed-by: Richard J. Knight <rjknight@us.ibm.com>
Reviewed-by: WILLIAM G. HOFFA <wghoffa@us.ibm.com>
Diffstat (limited to 'src/include')
20 files changed, 2764 insertions, 21 deletions
diff --git a/src/include/usr/fapi2/attribute_service.H b/src/include/usr/fapi2/attribute_service.H new file mode 100644 index 000000000..44277bf5b --- /dev/null +++ b/src/include/usr/fapi2/attribute_service.H @@ -0,0 +1,252 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/fapi2/attribute_service.H $ */ +/* */ +/* OpenPOWER HostBoot 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 src/include/usr/hwpf/plat/attribute_service.H +/// +/// @brief Defines the PLAT attribute access macros and the functions that +/// access attributes for FAPI2 +/// +/// Note that platform code must provide the code. +/// + +#ifndef ATTRIBUTESERVICE_H_ +#define ATTRIBUTESERVICE_H_ + +//****************************************************************************** +// Includes +//****************************************************************************** + +#include <stdint.h> +#include <return_code.H> +#include <target.H> +#include <target_types.H> + +#include <plat_attribute_service.H> +#include <fapi2_attribute_service.H> +#include <targeting/common/attributes.H> +#include <fapi2platattrmacros.H> + +#include <devicefw/driverif.H> +#include <plat_attr_override_sync.H> +#include <vpd/spdenums.H> + + +//****************************************************************************** +// Interface +//****************************************************************************** + +namespace fapi2 +{ + +namespace platAttrSvc +{ + +/// +/// @brief Gets the TARGETING object for the input FAPI target +/// +/// @param[in] i_pFapiTarget FAPI2 Target reference +/// @param[o] o_pTarget Output TARGETING object +/// @param[in] i_expectedType Expecting TARGETING object type +/// @return errlHndl_t +/// +errlHndl_t getTargetingTarget(const Target<TARGET_TYPE_ALL>& i_pFapiTarget, + TARGETING::Target* & o_pTarget, + const TARGETING::TYPE i_expectedType = TARGETING::TYPE_NA); + +/// +/// @brief Helper function for getTargetingAttr, this function is a friend of +/// TARGETING::Target so it can call _tryGetAttr +/// +/// +/// @param[in] i_pTargTarget Targeting Target reference +/// @param[in] i_targAttrId TARGETING Attribute ID +/// @param[in] i_attrSize Size of attribute in bytes +/// @param[in] o_pAttr Pointer to attribute where value is copied to +/// @return boolean describing if it was successful +bool getTargetingAttrHelper(TARGETING::Target * l_pTargTarget, + const TARGETING::ATTRIBUTE_ID i_targAttrId, + const uint32_t i_attrSize, void * o_pAttr); + +/// +/// @brief Gets a Targeting attribute, this is called by the macro that maps a +/// FAPI Attribute get to a TARGETING attribute and should not be called +/// directly +/// +/// @param[in] i_pFapiTarget FAPI2 Target reference +/// @param[in] i_targAttrId TARGETING Attribute ID +/// @param[in] i_attrSize Size of attribute in bytes +/// @param[in] o_pAttr Pointer to attribute where value is copied to +/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +ReturnCode getTargetingAttr(const Target<TARGET_TYPE_ALL, + plat_target_handle_t >& i_pFapiTarget, + const TARGETING::ATTRIBUTE_ID i_targAttrId, + const uint32_t i_attrSize, + void * o_pAttr); + +/// +/// @brief Helper function for setTargetingAttr, this function is a friend of +/// TARGETING::Target so it can call _trySetAttr +/// +/// +/// @param[in] i_pTargTarget Targeting Target reference +/// @param[in] i_targAttrId TARGETING Attribute ID +/// @param[in] i_attrSize Size of attribute in bytes +/// @param[in] o_pAttr Pointer to attribute where value is copied to +/// @return boolean describing if it was successful +/// +bool setTargetingAttrHelper(TARGETING::Target * l_pTargTarget, + const TARGETING::ATTRIBUTE_ID i_targAttrId, + const uint32_t i_attrSize, + void * o_pAttr); + +/// +/// @brief Sets a Targeting attribute, this is called by the macro that maps a +/// FAPI Attribute set to a FAPI2 TARGETING attribute and should not be +/// called directly +/// +/// @param[in] i_pFapiTarget FAPI2 Target reference +/// @param[in] i_targAttrId TARGETING Attribute ID +/// @param[in] i_attrSize Size of attribute in bytes +/// @param[in] i_pAttr Pointer to attribute where value is retrieved from +/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +ReturnCode setTargetingAttr(const Target<TARGET_TYPE_ALL>& i_pFapiTarget, + const TARGETING::ATTRIBUTE_ID i_targAttrId, + const uint32_t i_attrSize, + void * i_pAttr); + +/// +/// @brief This function is called by the FAPI_ATTR_GET macro when accessing +/// an attribute where zero needs to be returned. The use-case is for attributes +/// that exist solely for overriding +/// +/// @param[out] o_data Pointer to user's attribute variable +/// @param[in] i_len Size of o_data +/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +inline ReturnCode platGetZeroAttrData(void * o_data, + size_t i_len) +{ + memset(o_data, 0, i_len); + return fapi2::FAPI2_RC_SUCCESS; +} + + +/// +/// @brief This function is called by the FAPI_ATTR_GET macro when getting +/// ATTR_NAME. It should not be called directly +/// +/// @param[in] i_pFapiTarget FAPI2 Target reference +/// @param[out] o_name Output Name (from enum ATTR_NAME_Enum) +/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +ReturnCode platGetTargetName(const Target<TARGET_TYPE_ALL>& i_pFapiTarget, + uint8_t & o_name); + +/// +/// @brief This function is called by the FAPI_ATTR_GET macro when getting +/// ATTR_FUNCTIONAL. It should not be called directly +/// +/// @param[in] i_pFapiTarget FAPI2 Target reference +/// @param[out] o_functional 1 = functional, else 0 +/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +ReturnCode platGetFunctional(const Target<TARGET_TYPE_ALL>& i_pFapiTarget, + uint8_t & o_functional); + +/// +/// @brief This function is called by the FAPI_ATTR_GET macro when getting +/// ATTR_POS. It should not be called directly +/// +/// This is needed because the HWPF attribute is a uint32_t and the Hostboot +/// attribute is a uint16_t so a direct map will not work +/// +/// @param[in] i_pFapiTarget FAPI2 Target reference +/// @param[out] o_pos Output Posititon +/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +ReturnCode platGetTargetPos(const Target<TARGET_TYPE_ALL>& i_pFapiTarget, + uint32_t & o_pos); + + +// ----------------------------------------------------------------------------- +// End TODO: End to be supported functions +// ----------------------------------------------------------------------------- + +} // namespace platAttrSvc + +} // namespace fapi2 + +/** + * @brief Macro that directly maps a FAPI_ATTR_GET to a Targeting attr get + * + * Firstly there is a compile time check that the user's VAL variable matches + * the Targeting attribute type, this is optimized out, then there is a + * single function call + */ +#define FAPI2_PLAT_ATTR_SVC_GETMACRO_DIRECT(ID, PTARGET, VAL) \ +platAttrSvc::getTargetingAttr(PTARGET, (const TARGETING::ATTRIBUTE_ID)\ +fapiToTargeting::ID, sizeof(VAL), &(VAL)) + + +/** + * @brief Macro that directly maps a FAPI_ATTR_SET to a Targeting attr set + * + * Firstly there is a compile time check that the user's VAL variable matches + * the Targeting attribute type, this is optimized out, then there is a + * single function call + */ +#define FAPI2_PLAT_ATTR_SVC_SETMACRO_DIRECT(ID, PTARGET, VAL) \ +platAttrSvc::setTargetingAttr(PTARGET, (const TARGETING::ATTRIBUTE_ID)\ +fapiToTargeting::ID, sizeof(VAL), &(VAL)) + + + +//------------------------------------------------------------------------------ +// MACRO to route ATTR_NAME access to the correct Hostboot function +//------------------------------------------------------------------------------ +#define ATTR_NAME_GETMACRO(ID, PTARGET, VAL) \ + AttrOverrideSync::getAttrOverrideFunc(ID, PTARGET, &VAL)\ + ? fapi2::FAPI2_RC_SUCCESS : \ + fapi2::platAttrSvc::platGetTargetName(PTARGET, VAL) + +//------------------------------------------------------------------------------ +// MACRO to route ATTR_FUNCTIONAL access to the correct Hostboot function +//------------------------------------------------------------------------------ +#define ATTR_FUNCTIONAL_GETMACRO(ID, PTARGET, VAL) \ + AttrOverrideSync::getAttrOverrideFunc(ID, PTARGET, &VAL)\ + ? fapi2::FAPI2_RC_SUCCESS : \ + fapi2::platAttrSvc::platGetFunctional(PTARGET, VAL) + +//------------------------------------------------------------------------------ +// MACRO to route ATTR_POS access to the correct Hostboot function +//------------------------------------------------------------------------------ +#define ATTR_POS_GETMACRO(ID, PTARGET, VAL) \ + AttrOverrideSync::getAttrOverrideFunc(ID, PTARGET, &VAL)\ + ? fapi2::FAPI2_RC_SUCCESS : \ + fapi2::platAttrSvc::platGetTargetPos(PTARGET, VAL) + +#endif // ATTRIBUTESERVICE_H_ diff --git a/src/include/usr/fapi2/chip_ec_feature.H b/src/include/usr/fapi2/chip_ec_feature.H new file mode 100644 index 000000000..801e0d962 --- /dev/null +++ b/src/include/usr/fapi2/chip_ec_feature.H @@ -0,0 +1,61 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/fapi2/chip_ec_feature.H $ */ +/* */ +/* OpenPOWER HostBoot 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 */ +#ifndef CHIPECFEATURE_H_ +#define CHIPECFEATURE_H_ + +#include <plat_chip_ec_feature.H> +#include <fapi2_chip_ec_feature.H> + +#include <stdint.h> +#include <target.H> +#include <return_code.H> + +namespace fapi2 +{ + +/// +/// @brief Platform implementation of querying chip ec feature +/// +/// This should only be called by FAPI during the processing of a FAPI_ATTR_GET +/// for a Chip EC Feature attribute +/// +/// @param[in] i_id Attribute ID of the Chip EC Feature +/// @param[in] i_pTarget Pointer to chip target +/// @param[out] o_hasFeature Set to 1 if chip has feature else 0 +/// @return ReturnCode. Zero on success, else platform specified error +/// +template< TargetType K > +ReturnCode queryChipEcFeature(AttributeId i_id, + const Target<K>& i_pTarget, + uint8_t & o_hasFeature) +{ + ReturnCode l_rc; + //@todo-RTC:128106 + return l_rc; +} + +} // end namespace + +#endif // CHIPECFEATURE_H_ diff --git a/src/include/usr/fapi2/fapiPlatTrace.H b/src/include/usr/fapi2/fapiPlatTrace.H new file mode 100644 index 000000000..ff9079a22 --- /dev/null +++ b/src/include/usr/fapi2/fapiPlatTrace.H @@ -0,0 +1,95 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/fapi2/fapiPlatTrace.H $ */ +/* */ +/* OpenPOWER HostBoot 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 platTrace.H + * + * @brief Defines the FAPI trace macros. + * + * Note that platform code must provide the implementation. + * + * FAPI has provided a default implementation of printfs. Platform code must + * provide an alternate implementation if needed. + */ + +//testing_thi_outside + +#ifndef PLATTRACE_H_ +#define PLATTRACE_H_ + +#include <stdio.h> +#include <trace/interface.H> +#include <config.h> + +//****************************************************************************** +// Trace buffer names +//****************************************************************************** +const char * const FAPI_TRACE_NAME = "FAPI"; +const char * const FAPI_IMP_TRACE_NAME = "FAPI_I"; +const char * const FAPI_SCAN_TRACE_NAME = "SCAN"; +const char * const FAPI_MFG_TRACE_NAME = "FAPI_MFG"; + +//****************************************************************************** +// Trace descriptors that are defined in a C file +//****************************************************************************** +extern trace_desc_t* g_fapiTd; +extern trace_desc_t* g_fapiImpTd; +extern trace_desc_t* g_fapiScanTd; +extern trace_desc_t* g_fapiMfgTd; + +// Information traces (go into fast trace buffer that can wrap often) +#define FAPI_INF(_fmt_, _args_...) TRACFCOMP(g_fapiTd, TRACE_FILENAME _fmt_, ##_args_ ) + +// Important traces (go into slow trace buffer that should not wrap often) +#define FAPI_IMP(_fmt_, _args_...) TRACFCOMP(g_fapiImpTd, TRACE_FILENAME _fmt_, ##_args_ ) + +// Error traces (go into slow trace buffer that should not wrap often) +#define FAPI_ERR(_fmt_, _args_...) TRACFCOMP(g_fapiImpTd, TRACE_FILENAME _fmt_, ##_args_ ) + +// Debug traces (go into fast trace buffer that can wrap often) +#define FAPI_DBG(_fmt_, _args_...) TRACDCOMP(g_fapiTd, TRACE_FILENAME _fmt_, ##_args_) + +// Scan traces +#define FAPI_SCAN(_fmt_, _args_...) TRACSCOMP(g_fapiScanTd, _fmt_, ##_args_) + +// FAPI Mfg traces +#if defined(CONFIG_CONSOLE) && !defined(__HOSTBOOT_RUNTIME) && \ + !defined(CONFIG_CONSOLE_OUTPUT_TRACE) +#include <console/consoleif.H> +// Traces will go to console if attr override set for this +#define FAPI_MFG(_fmt_, _args_...) \ + { \ + if(TRACE::isDebugEnabled(g_fapiMfgTd)) \ + { \ + CONSOLE::displayf(FAPI_MFG_TRACE_NAME,_fmt_, ##_args_); \ + } \ + } +#else + // Just define to standard TRACS buffer +#define FAPI_MFG(_fmt_, _args_...) \ + TRACSCOMP(g_fapiMfgTd, _fmt_, ##_args_) +#endif + + +#endif // PLATTRACE_H_ diff --git a/src/include/usr/fapi2/hw_access.H b/src/include/usr/fapi2/hw_access.H new file mode 100644 index 000000000..07ef14373 --- /dev/null +++ b/src/include/usr/fapi2/hw_access.H @@ -0,0 +1,316 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/fapi2/hw_access.H $ */ +/* */ +/* OpenPOWER HostBoot 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 hw_access.H +/// +/// @brief Hardware access functions that needs to be specialized for +/// platform implementation. +/// + +#ifndef _FAPI2_HWACCESS_H_ +#define _FAPI2_HWACCESS_H_ + +// Variable_buffer isn't supported on PPE +#ifndef __PPE__ +#include <variable_buffer.H> +#endif + +#include <plat_hw_access.H> +#include <fapi2_hw_access.H> + +namespace fapi2 +{ + +//-------------------------------------------------------------------------- +// PIB Error Functions +//-------------------------------------------------------------------------- + +/// @brief Sets the PIB error mask - platform dependant +/// @param[in] i_mask The new error mask +// note: this can be moved to a C file if desired +inline void setPIBErrorMask(uint8_t i_mask) +{ + // Keeps the compiler from complaining about the unused i_mask + static_cast<void>(i_mask); + //TODO: RTC 124195 FAPI2 - PIB error mask and Operation mode supports + return; +} + +/// @brief Gets the PIB error mask - platform dependant +/// @return uint8_t The current PIB error mask +// note: this can be moved to a C file if desired +inline uint8_t getPIBErrorMask(void) +{ + //TODO: RTC 124195 FAPI2 - PIB error mask and Operation mode supports + return 0; +} + +//-------------------------------------------------------------------------- +// Operational Mode Error Functions +//-------------------------------------------------------------------------- + +/// @brief Sets the operational mode +/// @param[in] i_mode The new mode +// note: this can be moved to a C file if desired +inline void setOpMode(const OpModes i_mode) +{ + // Keeps the compiler from complaining about the unused i_mode + static_cast<void>(i_mode); + //TODO: RTC 124195 FAPI2 - PIB error mask and Operation mode supports + // 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) +{ + //TODO: RTC 124195 FAPI2 - PIB error mask and Operation mode supports + // No-op for now. Should read thread-local operational mode + return NORMAL; +} + +//------------------------------------------------------------------------------ +// HW Communication Functions to be implemented at the platform layer. +//------------------------------------------------------------------------------ + +/// +/// @brief Platform-level implementation of getScom() +/// @Tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @param[in] i_address SCOM register address to read from. +/// @param[out] o_data Buffer that holds data read from HW target. +/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +template< TargetType K > +inline ReturnCode getScom(const Target<K>& i_target, + const uint64_t i_address, + buffer<uint64_t>& o_data) +{ + return platGetScom(i_target, i_address, o_data); +} + +/// @brief Platform-level implementation of putScom() +/// @Tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @param[in] i_address SCOM register address to write to. +/// @param[in] i_data Buffer that holds data to write into address. +/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +template< TargetType K > +inline ReturnCode putScom(const Target<K>& i_target, + const uint64_t i_address, + const buffer<uint64_t> i_data) +{ + return platPutScom(i_target, i_address, i_data); +} + +/// @brief Platform-level implementation of putScomUnderMask() +/// @tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @param[in] i_address SCOM register address to write to. +/// @param[in] i_data Buffer that holds data to write into address. +/// @param[in] i_mask Buffer that holds the mask value. +/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +template< TargetType K > +inline ReturnCode putScomUnderMask(const Target<K>& i_target, + const uint64_t i_address, + const buffer<uint64_t> i_data, + const buffer<uint64_t> i_mask) +{ + return platPutScomUnderMask(i_target, i_address, i_data, i_mask); +} + +/// +/// @brief Platform-level implementation called by getCfamRegister() +/// Hardware procedures writers will not call this function. +/// @Tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @param[in] i_address CFAM address to read from. +/// @param[out] o_data 32-bit buffer that holds data read from HW target. +/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +template< TargetType K > +inline ReturnCode getCfamRegister(const Target<K>& i_target, + const uint32_t i_address, + buffer<uint32_t>& o_data) +{ + return platGetCfamRegister(i_target, i_address, o_data); +} + +/// +/// @brief Platform-level implementation of putCfamRegister() +/// Hardware procedures writers will not call this function. +/// @Tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @param[in] i_address CFAM address to write to. +/// @param[out] i_data 32-bit buffer that holds data to write into address. +/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +template< TargetType K > +inline ReturnCode putCfamRegister(const Target<K>& i_target, + const uint32_t i_address, + const buffer<uint32_t> i_data) +{ + return platPutCfamRegister(i_target, i_address, i_data); +} + + +/// +/// @brief Platform-level implementation of modifyCfamRegister() +/// Hardware procedures writers will not call this function. +/// @Tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @param[in] i_address CFAM register address to modify. +/// @param[out] i_data 32-bit buffer that holds data to modify. +/// @param[in] i_modifyMode The modify mode (or/and/xor). +/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +template< TargetType K > +inline ReturnCode modifyCfamRegister(const Target<K>& i_target, + const uint32_t i_address, + const buffer<uint32_t> i_data, + const fapi2::ChipOpModifyMode i_modifyMode) +{ + return platModifyCfamRegister(i_target, i_address, i_data, i_modifyMode); +} + +// variable_buffer isn't supported on PPE +#ifndef __PPE__ +/// +/// @brief Platform-level implementation of getRing() +/// Hardware procedures writers will not call this function. +/// @Tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @param[in] i_address Ring address to read from. +/// @param[out] o_data Buffer that holds ring data read from HW target. +/// @param[in] i_ringMode Ring operation mode. +/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +template< TargetType K > +inline ReturnCode getRing(const Target<K>& i_target, + const scanRingId_t i_address, + variable_buffer& o_data, + const RingMode i_ringMode) +{ + return platGetRing(i_target, i_address, o_data, i_ringMode); +} + +/// @brief Platform-level implementation of putRing() +/// Hardware procedures writers will not call this function. +/// @tparam K template parameter, passed in target. +/// @param[in] i_target Target to operate on. +/// @param[in] i_address Ring address to write to. +/// @param[in] i_data Buffer that contains RS4 compressed ring data +/// to write into address +/// @param[in] i_ringMode Ring operation mode. +/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +template< TargetType K > +inline ReturnCode putRing(const Target<K>& i_target, + const scanRingId_t i_address, + const variable_buffer& i_data, + const RingMode i_ringMode) +{ + return platPutRing(i_target, i_address, i_data, i_ringMode); +} + +/// @brief Platform-level implementation of modifyRing() +/// @tparam K template parameter, passed in target. +/// @param[in] i_target Target to operate on. +/// @param[in] i_address Ring address to modify. +/// @param[in] i_data Buffer that contains RS4 compressed ring data +/// to be modified. +/// @param[in] i_modifyMode The modify mode (or/and/xor) +/// @param[in] i_ringMode Ring operation mode. +/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +template< TargetType K > +inline ReturnCode modifyRing(const Target<K>& i_target, + const scanRingId_t i_address, + const variable_buffer& i_data, + const ChipOpModifyMode i_modifyMode, + const RingMode i_ringMode) +{ + return platModifyRing(i_target, + i_address, + i_data, + i_modifyMode, + i_ringMode); +} +#endif + +#ifdef FAPI_SUPPORT_MULTI_SCOM + /// @brief Performs a multiple SCOM operation + /// This interface performs multiple SCOM operations on a chip in the + /// order specified by the input MultiScom object. + /// See fapiMultiScom.H for details of how to populate the MultiScom + /// object with SCOM operations. + /// + /// @tparam K template parameter, passed in target. + /// @param[in] i_target Target to operate on. + /// @param[in,out] io_multiScomObj Reference to a MultiScom object, + /// pre-populated with SingleScomInfo entries + /// to perform multiple SCOMs on input target + /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + /// + /// @note This is a synchronous interface and would return after all the + /// SCOM operations are completed or on the first failed operation + /// + /// @note SCOMs will be performed in the order they were added to the + /// input MultiScom object + /// + /// @note In case of errors, the platform code is responsible to collect + /// and add all the required error info and FFDC into the error data + /// for debugging + /// + /// @note If the SCOM operations added are specific to a processor chip, + /// then the FSI Shift Engine configured in scatter-gather DMA mode + /// extension would be used to execute the SCOM operations in a + /// performance optimize mode. In this mode, the special + /// SCOM_BULK_READ_MODE and SCOM_BULK_WRITE_MODE operations are + /// supported that allow a large bulk of SCOM access (in multiple of + /// 64 bits) for targets that support auto-increment. The + /// SCOM_WRITE_UNDER_MASK operation is not supported in this mode + /// + /// @note If the SCOM operations added are specific to a memory buffer + /// chip, then the regular SCOM engine is used to execute the SCOM + /// operations. SCOM_WRITE_UNDER_MASK operation is supported in + /// this mode, but the special SCOM_BULK_READ_MODE and + /// SCOM_BULK_WRITE_MODE operations are not supported due to + /// hardware limitations. + /// + template< TargetType K > + fapi2::ReturnCode multiScom (const Target<K>& i_target, + MultiScom& io_multiScomObj) + { + } +#endif + + // ------------------------------------------------------------------------- + // NOTE: + // No spy access in Hostboot + // ------------------------------------------------------------------------- + +}; + +#endif // _FAPI2_HWACCESS_H_ diff --git a/src/include/usr/fapi2/hwp_executor.H b/src/include/usr/fapi2/hwp_executor.H new file mode 100644 index 000000000..72f00a694 --- /dev/null +++ b/src/include/usr/fapi2/hwp_executor.H @@ -0,0 +1,50 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/fapi2/hwp_executor.H $ */ +/* */ +/* OpenPOWER HostBoot 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 plat_hwp_executor.H +/// +/// @brief Defines the platform Executor Macro. +/// +/// The PLAT HWP Executor macro is called by the FAPI HWP Executor macro 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 HWPEXECUTOR_H_ +#define HWPEXECUTOR_H_ + +#include <plat_hwp_executor.H> +#include <fapi2_hwp_executor.H> + +/** + * @brief HWP Executor macro + * + * Call the HWP directly. + */ +#define FAPI_PLAT_EXEC_HWP(RC, FUNC, _args_...) \ + RC = FUNC(_args_) + +#endif // HWPEXECUTOR_H_ diff --git a/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H b/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H new file mode 100644 index 000000000..7eba42eaa --- /dev/null +++ b/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H @@ -0,0 +1,106 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H $ */ +/* */ +/* OpenPOWER HostBoot 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 hwpf_fapi2_reasoncodes.H +/// +/// @brief Define error reason codes for FAPI2 HWPs +/// +/// + +#ifndef HWPF_FAPI2_REASONCODES_H_ +#define HWPF_FAPI2_REASONCODES_H_ + +#include <hbotcompid.H> + +namespace fapi2 +{ + /** + * @brief Defines the FAPI2 HWPF error log module IDs + */ + enum fapi2ModuleId + { + MOD_FAPI2_RC_TO_ERRL = 0x01, + MOD_FAPI2_GET_TARGETING_TARGET = 0x02, + MOD_FAPI2_PLAT_GET_TARGET_NAME = 0x03, + MOD_FAPI2_PLAT_HWP_TEST = 0x04, + MOD_FAPI2_PLAT_GET_PARENT_TEST = 0x05, + }; + + /** + * @brief Defines the HWPF error log reason codes + */ + enum fapi2ReasonCode + { + // FAPI generated errors (must match return_code_defs.H) + RC_INVALID_ATTR_GET = HWPF_COMP_ID | 0x01, + RC_INVALID_CHIP_EC_FEATURE_GET = HWPF_COMP_ID | 0x02, + RC_INVALID_TARG_TARGET = HWPF_COMP_ID | 0x07, + RC_MISMATCHED_FAPI_TARG_TARGET = HWPF_COMP_ID | 0x08, + RC_UNKNOWN_MODEL = HWPF_COMP_ID | 0x09, + RC_NULL_FAPI_TARGET = HWPF_COMP_ID | 0x0A, + RC_LOOKING_FOR_TYPE_NA = HWPF_COMP_ID | 0x0B, + + + //Platform generated errors + RC_NO_PROCS_FOUND = FAPI2_COMP_ID | 0x0B, + RC_NO_PATH_TO_TARGET_FOUND = FAPI2_COMP_ID | 0x0C, + RC_CORE_NO_EX_FOUND = FAPI2_COMP_ID | 0x0D, + RC_CORE_NO_EQ_FOUND = FAPI2_COMP_ID | 0x0E, + RC_CORE_NO_PROC_FOUND = FAPI2_COMP_ID | 0x10, + RC_EX_NO_EQ_FOUND = FAPI2_COMP_ID | 0x11, + RC_EX_NO_PROC_FOUND = FAPI2_COMP_ID | 0x12, + RC_EQ_NO_PROC_FOUND = FAPI2_COMP_ID | 0x13, + RC_MCA_NO_MCS_FOUND = FAPI2_COMP_ID | 0x14, + RC_MCA_NO_PROC_FOUND = FAPI2_COMP_ID | 0x15, + RC_MCS_NO_PROC_FOUND = FAPI2_COMP_ID | 0x16, + RC_MCBIST_NO_PROC_FOUND = FAPI2_COMP_ID | 0x17, + RC_PHB_NO_PEC_FOUND = FAPI2_COMP_ID | 0x18, + RC_PHB_NO_PROC_FOUND = FAPI2_COMP_ID | 0x19, + RC_PEC_NO_PROC_FOUND = FAPI2_COMP_ID | 0x1a, + RC_XBUS_NO_PROC_FOUND = FAPI2_COMP_ID | 0x1b, + RC_OBUS_NO_PROC_FOUND = FAPI2_COMP_ID | 0x1c, + RC_NVBUS_NO_PROC_FOUND = FAPI2_COMP_ID | 0x1d, + RC_PPE_NO_PROC_FOUND = FAPI2_COMP_ID | 0x1e, + RC_PERV_NO_PROC_FOUND = FAPI2_COMP_ID | 0x1f, + RC_CAPP_NO_PROC_FOUND = FAPI2_COMP_ID | 0x20, + RC_SBE_NO_PROC_FOUND = FAPI2_COMP_ID | 0x21, + + // HWP generated errors + RC_HWP_GENERATED_ERROR = HWPF_COMP_ID | 0x0f, + + }; + + /** + * @brief Defines the HWPF error log user detail data sections + */ + enum fapi2UserDetailDataSubSection + { + HWPF_FAPI2_UDT_HWP_RCVALUE = 0x01, + HWPF_FAPI2_UDT_HWP_FFDC = 0x02, + HWPF_FAPI2_UDT_STEP_ERROR_DETAILS = 0x03, + }; +}; + +#endif // HWPF_FAPI2_REASONCODES_H_ diff --git a/src/include/usr/fapi2/plat_attr_override_sync.H b/src/include/usr/fapi2/plat_attr_override_sync.H new file mode 100644 index 000000000..6dca60bbe --- /dev/null +++ b/src/include/usr/fapi2/plat_attr_override_sync.H @@ -0,0 +1,258 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/fapi2/plat_attr_override_sync.H $ */ +/* */ +/* OpenPOWER HostBoot 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 plat_attr_override_sync.H +/// +/// @brief Defines the AttrOverrideSync class that contains functions for +/// Attribute Override and Sync. +/// + +#ifndef PLATATTROVERRIDESYNC_H_ +#define PLATATTROVERRIDESYNC_H_ + +//****************************************************************************** +// Includes +//****************************************************************************** +#include <stdint.h> +#include <mbox/mboxif.H> +#include <targeting/common/attributeTank.H> +#include <pnor/pnorif.H> + +#include <attribute_ids.H> +#include <return_code.H> +#include <target.H> +#include <target_types.H> + + +//****************************************************************************** +// Interface +//****************************************************************************** +namespace TARGETING +{ + errlHndl_t getAttrOverrides(PNOR::SectionInfo_t &i_sectionInfo, + AttributeTank* io_tanks[AttributeTank::TANK_LAYER_LAST]); +} + +namespace fapi2 +{ + +// Forward references +class AttrOverrideSync; +//class Target; + +/** + * @brief Return the AttrOverrideSync Singleton. Other modules must call this + * rather than using Singleton<> + * + * @return Reference to the AttrOverrideSync Singleton + */ +AttrOverrideSync & theAttrOverrideSync(); + +/** + * @class AttrOverrideSync + * + * This class contains the FAPI Attribute Override and Sync tanks. It provides + * functions to: + * - Monitor for incoming attribute override/sync messages from the FSP + * - Send attribute override/syncs to the FSP + * - Return any attribute override on an attribute get + * - Cancel any non-const attribute override and save the attribute in the sync + * tank on an attribute set + */ +class AttrOverrideSync +{ +public: + /** + * @brief Allow a debug tool to directly access the override tank + */ + friend void directOverride(); + + /** + * @brief Allow a attribute override to directly access the override tank + */ + friend errlHndl_t TARGETING::getAttrOverrides( + PNOR::SectionInfo_t &i_sectionInfo, + TARGETING::AttributeTank* + io_tanks[TARGETING::AttributeTank::TANK_LAYER_LAST]); + + /** + * @brief Maximum size of a direct attribute override + */ + static const size_t MAX_DIRECT_OVERRIDE_ATTR_SIZE_BYTES = 64; + + /** + * @brief Attribute Override/Sync Mailbox Message Type Constants + * These must be kept in sync with FSP firmware + */ + enum MAILBOX_MSG_TYPE + { + MSG_SET_OVERRIDES = MBOX::FIRST_UNSECURE_MSG + 0x10, // FSP<->Hb + MSG_CLEAR_ALL_OVERRIDES = MBOX::FIRST_UNSECURE_MSG + 0x11, // FSP<->Hb + MSG_SET_SYNC_ATTS = MBOX::FIRST_UNSECURE_MSG + 0x12, // FSP<--Hb + MSG_GET_OVERRIDES = MBOX::FIRST_UNSECURE_MSG + 0x13, // FSP<--Hb + }; + + /** + * @brief Default constructor + */ + AttrOverrideSync(); + + /** + * @brief Destructor + */ + ~AttrOverrideSync(); + + /** + * @brief Monitors for incoming attribute override messages from the FSP. + * This function never returns and must be called by a task + * specifically started to monitor for these messages + */ + void monitorForFspMessages(); + + /** + * @brief Sends Attribute Overrides and Syncs to the FSP + * + * This is called at the end of an IStep. For both FAPI/TARG tanks it: + * - Clears the FSP Attribute Overrides + * - Sends the Hostboot Attribute Overrides to the FSP + * - Sends the Hostboot Attribute Syncs to the FSP + */ + void sendAttrOverridesAndSyncsToFsp(); + + /** + * @brief Gets Attribute Overrides and Syncs from the FSP + * + * This is called at the start of a normal (non-istep) IPL if an attribute + * is set indicating that the FSP has attribute overrides in place + */ + void getAttrOverridesFromFsp(); + + /** + * @brief This function gets any Attribute Override on an attribute get + * + * This is called for those FAPI Attributes that do not map to Targeting + * attributes - their overrides live in the FAPI Attribute tanks. + * + * @param[in] i_attrId FAPI Attribute ID + * @param[in] i_pTarget Pointer to FAPI Target + * @param[in] o_pVal Pointer to attribute value + * + * @return true if an override exists and was written to o_pVal + */ + bool getAttrOverride(const AttributeId i_attrId, + const Target<TARGET_TYPE_ALL>* i_pTarget, + void * o_pVal) const; + + /** + * @brief This function gets any Attribute Override on an attribute get + * + * This is a wrapper that calls getAttrOverride on the AttrOverrideSync + * singleton, it should be called by external modules to avoid the + * performance penalty of calling theAttrOverrideSync() then getAttrOverride + * + * @param[in] i_attrId FAPI Attribute ID + * @param[in] i_pTarget Reference to FAPI2 Target + * @param[in] o_pVal Pointer to attribute value + * + * @return true if an override exists and was written to o_pVal + */ + static bool getAttrOverrideFunc(const AttributeId i_attrId, + const Target<TARGET_TYPE_ALL>& i_pTarget, + void * o_pVal); + + /** + * @brief This function performs the actions required on an attribute set + * + * This is called for those FAPI Attributes that do not map to Targeting + * attributes - their overrides/syncs live in the FAPI Attribute tanks. + * + * - Any non-const attribute override is cleared + * - The attribute is saved to be synced to Cronus (if Cronus Sync enabled) + * + * @param[in] i_attrId FAPI Attribute ID + * @param[in] i_pTarget Pointer to FAPI Target + * @param[in] i_size Size of attribute value + * @param[in] i_pVal Pointer to attribute value + */ + void setAttrActions(const AttributeId i_attrId, + const Target<TARGET_TYPE_ALL>* i_pTarget, + const uint32_t i_size, + const void * i_pVal); + + /** + * @brief This function performs the actions required on an attribute set + * + * This is a wrapper that calls setAttrActions on the AttrOverrideSync + * singleton, it should be called by external modules to avoid the + * performance penalty of calling theAttrOverrideSync() then setAttrActions + * + * @param[in] i_attrId FAPI Attribute ID + * @param[in] i_pTarget Reference to FAPI2 Target + * @param[in] i_size Size of attribute value + * @param[in] i_pVal Pointer to attribute value + */ + static void setAttrActionsFunc(const AttributeId i_attrId, + const Target<TARGET_TYPE_ALL>& i_pTarget, + const uint32_t i_size, + const void * i_pVal); + +private: + + /** + * @brief Utility function that sends attributes to the FSP + * + * This function frees the allocated memory in the input vector of chunks + * and empties the vector + * + * @param[in] i_msgType Message type (ID) to send + * @param[in] i_tankLayer Tank Layer to send attribute to + * @param[io] io_attributes Attributes to send. + * + * @return error log handle + */ + static errlHndl_t sendAttrsToFsp( + const MAILBOX_MSG_TYPE i_msgType, + const TARGETING::AttributeTank::TankLayer i_tankLayer, + std::vector<TARGETING::AttributeTank::AttributeSerializedChunk> & + io_attributes); + + /** + * @brief Utility function that gets the target type of a FAPI Target as + * used in an attribute tank + * + * @param[in] i_pTarget Pointer to FAPI Target (NULL = system) + * + * @return Target Type + */ + static uint32_t getTargetType(const Target<TARGET_TYPE_ALL>* i_pTarget); + + // The FAPI Attribute Tanks + TARGETING::AttributeTank iv_overrideTank; + TARGETING::AttributeTank iv_syncTank; +}; + +} // namespace fapi2 + +#endif // PLATATTROVERRIDESYNC_H_ diff --git a/src/include/usr/fapi2/plat_attribute_service.H b/src/include/usr/fapi2/plat_attribute_service.H new file mode 100644 index 000000000..ec9c5bdca --- /dev/null +++ b/src/include/usr/fapi2/plat_attribute_service.H @@ -0,0 +1,49 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/fapi2/plat_attribute_service.H $ */ +/* */ +/* OpenPOWER HostBoot 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 src/include/usr/hwpf/plat/plat_attribute_service.H +/// +/// @brief Defines the specialized platform attribute access functions +/// +/// Note that platform code must provide the code. +/// + +#ifndef PLATATTRIBUTESERVICE_H_ +#define PLATATTRIBUTESERVICE_H_ + +#include <attribute_service.H> +namespace fapi2 +{ + +namespace platAttrSvc +{ + + // Currently empty because no specialized functions for Hostboot. + +} // namespace platAttrSvc + +} // namespace fapi2 + +#endif // PLATATTRIBUTESERVICE_H_ diff --git a/src/include/usr/fapi2/plat_chip_ec_feature.H b/src/include/usr/fapi2/plat_chip_ec_feature.H new file mode 100644 index 000000000..018f0d0c6 --- /dev/null +++ b/src/include/usr/fapi2/plat_chip_ec_feature.H @@ -0,0 +1,41 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/fapi2/plat_chip_ec_feature.H $ */ +/* */ +/* OpenPOWER HostBoot 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 plat_hwp_executor.H +/// +/// @brief Defines the specialized platform HWP Executor Macro. +/// +/// The PLAT HWP Executor macro is called by the FAPI HWP Executor macro 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 PLATCHIPECFEATURE_H_ +#define PLATCHIPECFEATURE_H_ + +// Currently empty because no specialzation for Hostboot + +#endif // PLATCHIPECFEATURE_H_ diff --git a/src/include/usr/fapi2/plat_error_scope.H b/src/include/usr/fapi2/plat_error_scope.H new file mode 100644 index 000000000..1b47aa40d --- /dev/null +++ b/src/include/usr/fapi2/plat_error_scope.H @@ -0,0 +1,65 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/fapi2/plat_error_scope.H $ */ +/* */ +/* OpenPOWER HostBoot 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_error_scope.H + * @brief platform definitions which create a scope for automatic error handling + */ + +#ifndef __FAPI2_PLAT_ERROR_SCOPE__ +#define __FAPI2_PLAT_ERROR_SCOPE__ + +/// @cond +#define PLAT_FAPI_TRY_NO_TRACE( __operation__ ) \ + if ((fapi2::current_err = (__operation__)) != fapi2::FAPI2_RC_SUCCESS) \ + { \ + goto fapi_try_exit; \ + } + +#define PLAT_FAPI_TRY_TRACE( __operation__, ... ) \ + if ((fapi2::current_err = (__operation__)) != fapi2::FAPI2_RC_SUCCESS) \ + { \ + 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; \ + } + +/// @endcond + +#endif diff --git a/src/include/usr/fapi2/plat_hw_access.H b/src/include/usr/fapi2/plat_hw_access.H new file mode 100644 index 000000000..febfb5c3e --- /dev/null +++ b/src/include/usr/fapi2/plat_hw_access.H @@ -0,0 +1,821 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/fapi2/plat_hw_access.H $ */ +/* */ +/* OpenPOWER HostBoot 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 plat_hw_access.H +/// +/// @brief Defines hardware-access functions for the platform layer. +/// Hardware procedure writers will not call these functions. +/// These platform entry points are called by fapi2 functions from +/// hw_access.H, output scand traces common to all platforms. +/// These functions have the same argument signatures as the +/// fapi-level functions, but the function names her start with +/// "plat." +/// + +#ifndef PLATHWACCESS_H_ +#define PLATHWACCESS_H_ + +#include <stdint.h> +#include <errl/errlentry.H> +#include <devicefw/userif.H> +#include <return_code.H> +#include <buffer.H> +#include <target.H> +#include <target_types.H> +#include <hw_access_def.H> +#include <plat_utils.H> + +namespace fapi2 +{ + +//------------------------------------------------------------------------------ +// HW Communication Functions to be implemented at the platform layer. +//------------------------------------------------------------------------------ + +/// +/// @brief Platform-level implementation called by getScom() +/// @Tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @param[in] i_address SCOM register address to read from. +/// @param[out] o_date Buffer that holds data read from HW target. +/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +template< TargetType K > +inline ReturnCode platGetScom(const Target<K>& i_target, + const uint64_t i_address, + buffer<uint64_t>& o_data) +{ + ReturnCode l_rc; + errlHndl_t l_err = NULL; + + FAPI_DBG(ENTER_MRK "platGetScom"); + // Note: Trace is placed here in plat code because PPE doesn't support + // trace in common fapi2_hw_access.H + bool l_traceit = platIsScanTraceEnabled(); + + // Extract the component pointer + TARGETING::Target* l_target = + reinterpret_cast<TARGETING::Target*>(i_target.get()); + + //TODO: RTC 124195 - Support target::toEcmdString() for SCAN trace + const char* tmpScomStr = "TargetString"; + + // Perform SCOM read + size_t l_size = sizeof(uint64_t); + l_err = deviceRead(l_target, + &o_data(), + l_size, + DEVICE_SCOM_ADDRESS(i_address)); + if (l_err) + { + FAPI_ERR("platGetScom: deviceRead returns error!"); + FAPI_ERR("fapiGetScom failed - Target %s, Addr %.16llX", + tmpScomStr, i_address); +// Add the error log pointer as data to the ReturnCode +//@TODO RTC:143127 Need fapi2 support in ReturnCode class + //l_rc.setPlatError(reinterpret_cast<void *> (l_err)); + } + + if (l_traceit) + { + uint64_t l_data = (uint64_t)o_data; + FAPI_SCAN("TRACE : GETSCOM : %s : %.16llX %.16llX", + tmpScomStr, + i_address, + l_data); + } + + FAPI_DBG(EXIT_MRK "platGetScom"); + return l_rc; +} + +/// @brief Platform-level implementation called by putScom() +/// @Tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @param[in] i_address SCOM register address to write to. +/// @param[in] i_data Buffer that holds data to write into address. +/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +template< TargetType K > +inline ReturnCode platPutScom(const Target<K>& i_target, + const uint64_t i_address, + const buffer<uint64_t> i_data) +{ + ReturnCode l_rc; + errlHndl_t l_err = NULL; + + FAPI_DBG(ENTER_MRK "platPutScom"); + // Note: Trace is placed here in plat code because PPE doesn't support + // trace in common fapi2_hw_access.H + bool l_traceit = platIsScanTraceEnabled(); + + // Extract the component pointer + TARGETING::Target* l_target = + reinterpret_cast<TARGETING::Target*>(i_target.get()); + + //TODO: RTC 124195 - Support target::toEcmdString() for SCAN trace + const char* tmpScomStr = "TargetString"; + + // Perform SCOM write + size_t l_size = sizeof(uint64_t); + uint64_t l_data = static_cast<uint64_t>(i_data); + l_err = deviceWrite(l_target, + &l_data, + l_size, + DEVICE_SCOM_ADDRESS(i_address)); + if (l_err) + { + FAPI_ERR("platPutScom: deviceRead returns error!"); + FAPI_ERR("platPutScom failed - Target %s, Addr %.16llX", + tmpScomStr, i_address); +// Add the error log pointer as data to the ReturnCode +//@TODO RTC:143127 Need fapi2 support in ReturnCode class + //l_rc.setPlatError(reinterpret_cast<void *> (l_err)); + } + + if (l_traceit) + { + FAPI_SCAN("TRACE : PUTSCOM : %s : %.16llX %.16llX", + tmpScomStr, + i_address, + l_data); + } + + FAPI_DBG(EXIT_MRK "platPutScom"); + return l_rc; +} + +/// @brief Platform-level implementation called by putScomUnderMask() +/// @tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @param[in] i_address SCOM register address to write to. +/// @param[in] i_data Buffer that holds data to write into address. +/// @param[in] i_mask Buffer that holds the mask value. +/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +template< TargetType K > +inline ReturnCode platPutScomUnderMask(const Target<K>& i_target, + const uint64_t i_address, + const buffer<uint64_t> i_data, + const buffer<uint64_t> i_mask) +{ + ReturnCode l_rc; + errlHndl_t l_err = NULL; + + FAPI_DBG(ENTER_MRK "platPutScomUnderMask"); + // Note: Trace is placed here in plat code because PPE doesn't support + // trace in common fapi2_hw_access.H + bool l_traceit = platIsScanTraceEnabled(); + + //TODO: RTC 124195 - Support target::toEcmdString() for SCAN trace + const char* tmpScomStr = "TargetString"; + + do + { + // Extract the component pointer + TARGETING::Target* l_target = + reinterpret_cast<TARGETING::Target*>(i_target.get()); + + // Get current value from HW + uint64_t l_data = 0; + size_t l_size = sizeof(uint64_t); + l_err = deviceRead(l_target, + &l_data, + l_size, + DEVICE_SCOM_ADDRESS(i_address)); + if (l_err) + { + FAPI_ERR("platPutScomUnderMask: deviceRead returns error!"); +// Add the error log pointer as data to the ReturnCode +//@TODO RTC:143127 Need fapi2 support in ReturnCode class + //l_rc.setPlatError(reinterpret_cast<void *> (l_err)); + break; + } + + // Calculate new value to write to reg + uint64_t l_inMaskInverted = ~i_mask; // Write mask inverted + uint64_t l_newMask = (i_data & i_mask); // Retain set data bits + + // l_data = current data set bits + l_data &= l_inMaskInverted; + + // l_data = current data set bit + set mask bits + l_data |= l_newMask; + + // Write new value + l_err = deviceWrite(l_target, + &l_data, + l_size, + DEVICE_SCOM_ADDRESS(i_address)); + if (l_err) + { + FAPI_ERR("platPutScomUnderMask: deviceWrite returns error!"); +// Add the error log pointer as data to the ReturnCode +//@TODO RTC:143127 Need fapi2 support in ReturnCode class + //l_rc.setPlatError(reinterpret_cast<void *> (l_err)); + break; + } + + } while (0); + + if (l_rc != fapi2::FAPI2_RC_SUCCESS) + { + FAPI_ERR("platPutScomUnderMask failed - Target %s, Addr %.16llX", + tmpScomStr, i_address); + } + + if( l_traceit ) + { + uint64_t l_data = i_data; + uint64_t l_mask = i_mask; + FAPI_SCAN( "TRACE : PUTSCOMMASK : %s : %.16llX %.16llX %.16llX", + tmpScomStr, + i_address, + l_data, + l_mask); + } + + FAPI_DBG(EXIT_MRK "platPutScomUnderMask"); + return l_rc; +} + +/// +/// @brief Platform-level implementation of modifyScom() +/// Hardware procedures writers will not call this function. +/// @Tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @param[in] i_address SCOM address to modify. +/// @param[out] i_data 64-bit buffer that holds data to modify. +/// @param[in] i_modifyMode The modify mode (or/and/xor). +/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +template< TargetType K > +inline ReturnCode platModifyScom(const Target<K>& i_target, + const uint32_t i_address, + const buffer<uint32_t> i_data, + const fapi2::ChipOpModifyMode i_modifyMode) +{ + + // --------------- Will implement when needed -------------------- + + FAPI_DBG(ENTER_MRK "platModifyScom"); + ReturnCode l_rc; + + FAPI_ERR("platModifyScom: Error: Hostboot not yet support modifyScom function!"); + +// Add the error log pointer as data to the ReturnCode +//@TODO RTC:143127 Need fapi2 support in ReturnCode class + //l_rc.setPlatError(reinterpret_cast<void *> (l_err)); + + FAPI_DBG(EXIT_MRK "platModifyScom"); + return l_rc; +} + +/// +/// @brief Verify target of a cfam access +/// We can't access the cfam engine of the master processor. +/// Only allow access to the other processors. +/// This function will return an error if the input target is +/// the boot processor. +/// @Tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @param[in] i_address CFAM address to read from. +/// @return errlHndl_t +/// +template< TargetType K > +static errlHndl_t verifyCfamAccessTarget(const Target<K>& i_target, + const uint32_t i_address) +{ + errlHndl_t l_err = NULL; + + // Can't access cfam engine on the master processor + if (i_target.getType() == fapi2::TARGET_TYPE_PROC_CHIP) + { + TARGETING::Target* l_pMasterProcChip = NULL; + TARGETING::targetService(). + masterProcChipTargetHandle( l_pMasterProcChip ); + + TARGETING::Target* l_pTarget = + reinterpret_cast<TARGETING::Target*>(i_target.get()); + + if( l_pMasterProcChip == l_pTarget ) + { + FAPI_ERR("verifyCfamAccessTarget: Attempt to access CFAM register %.8X on the master processor chip", + i_address); + } + } + return l_err; +} + +/// +/// @brief Internal function that gets the chip target for cfam access +/// HW procedures may pass in non-chip targets (such as MBA or +/// MBS as a target), so we need to find the parent chip in order +/// to pass it to the device driver. +/// @param[in] i_target HW target to operate on. +/// @param[out] o_chipTarget The output chip target. +/// @return errlHndl_t +/// +static errlHndl_t getCfamChipTarget(const TARGETING::Target* i_target, + TARGETING::Target*& o_chipTarget) +{ + errlHndl_t l_err = NULL; + + // Default to input target + o_chipTarget = const_cast<TARGETING::Target*>(i_target); + + // Check to see if this is a chiplet + if (i_target->getAttr<TARGETING::ATTR_CLASS>() == TARGETING::CLASS_UNIT) + { + // Look for its chip parent + TARGETING::PredicateCTM l_chipClass(TARGETING::CLASS_CHIP); + TARGETING::TargetHandleList l_list; + TARGETING::TargetService& l_targetService = TARGETING::targetService(); + (void) l_targetService.getAssociated( + l_list, + i_target, + TARGETING::TargetService::PARENT, + TARGETING::TargetService::ALL, + &l_chipClass); + + if ( l_list.size() == 1 ) + { + o_chipTarget = l_list[0]; + } + else + { + // Something is wrong here, can't have more than one parent chip + FAPI_ERR("getCfamChipTarget: Invalid number of parent chip for this target chiplet - # parent chips %d", l_list.size()); + } + } + return l_err; +} + +/// +/// @brief Platform-level implementation called by getCfamRegister() +/// Hardware procedures writers will not call this function. +/// @Tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @param[in] i_address CFAM address to read from. +/// @param[out] o_data 32-bit buffer that holds data read from HW target. +/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +template< TargetType K > +inline ReturnCode platGetCfamRegister(const Target<K>& i_target, + const uint32_t i_address, + buffer<uint32_t>& o_data) +{ + FAPI_DBG(ENTER_MRK "platGetCfamRegister"); + ReturnCode l_rc; + errlHndl_t l_err = NULL; + bool l_traceit = platIsScanTraceEnabled(); + + //TODO: RTC 124195 - Support target::toEcmdString() for SCAN trace + const char* tmpScomStr = "TargetString"; + + do + { + // Can't access cfam engine on master processor + l_err = verifyCfamAccessTarget(i_target,i_address); + if (l_err) + { + FAPI_ERR("platGetCfamRegister: verifyCfamAccessTarget returns error!"); + // Add the error log pointer as data to the ReturnCode + //TODO RTC:143127 Need fapi2 support in ReturnCode class + //l_rc.setPlatError(reinterpret_cast<void *> (l_err)); + break; + } + + // Extract the component pointer + TARGETING::Target* l_target = + reinterpret_cast<TARGETING::Target*>(i_target.get()); + + // Get the chip target if l_target is not a chip + TARGETING::Target* l_myChipTarget = NULL; + l_err = getCfamChipTarget(l_target, l_myChipTarget); + if (l_err) + { + FAPI_ERR("platGetCfamRegister: getCfamChipTarget returns error!"); + FAPI_ERR("fapiGetCfamRegister failed - Target %s, Addr %.8X", + tmpScomStr, i_address); + // Add the error log pointer as data to the ReturnCode + //TODO RTC:143127: Need fapi2 support in ReturnCode class + //l_rc.setPlatError(reinterpret_cast<void *> (l_err)); + break; + } + + // Perform CFAM read via FSI + // Address needs to be multiply by 4 because register addresses are + // word offsets but the FSI addresses are byte offsets. + // However, we need to preserve the engine's offset of 0x0C00 and 0x1000 + uint64_t l_addr = ((i_address & 0x003F) << 2) | (i_address & 0xFF00); + size_t l_size = sizeof(uint32_t); + l_err = deviceRead(l_myChipTarget, + &o_data(), + l_size, + DEVICE_FSI_ADDRESS(l_addr)); + if (l_err) + { + FAPI_ERR("platGetCfamRegister: deviceRead returns error!"); + // Add the error log pointer as data to the ReturnCode + //TODO RTC:143127: Need fapi2 support in ReturnCode class + //l_rc.setPlatError(reinterpret_cast<void *> (l_err)); + break; + } + + } while(0); + + if (l_rc != fapi2::FAPI2_RC_SUCCESS) + { + FAPI_ERR("fapiGetCfamRegister failed - Target %s, Addr %.8X", + tmpScomStr, i_address); + } + + if( l_traceit ) + { + uint32_t l_data = (uint32_t)o_data; + FAPI_SCAN( "TRACE : GETCFAMREG : %s : %.8X %.8X", + tmpScomStr, + i_address, + l_data); + } + + FAPI_DBG(EXIT_MRK "platGetCfamRegister"); + return l_rc; +} + +/// +/// @brief Platform-level implementation called by putCfamRegister() +/// Hardware procedures writers will not call this function. +/// @Tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @param[in] i_address CFAM address to write to. +/// @param[out] i_data 32-bit buffer that holds data to write into address. +/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +template< TargetType K > +inline ReturnCode platPutCfamRegister(const Target<K>& i_target, + const uint32_t i_address, + const buffer<uint32_t> i_data) +{ + FAPI_DBG(ENTER_MRK "platPutCfamRegister"); + ReturnCode l_rc; + errlHndl_t l_err = NULL; + bool l_traceit = platIsScanTraceEnabled(); + + //TODO: RTC 124195 - Support target::toEcmdString() for SCAN trace + const char* tmpScomStr = "TargetString"; + + do + { + // Can't access cfam engine on master processor + l_err = verifyCfamAccessTarget(i_target,i_address); + if (l_err) + { + FAPI_ERR("platPutCfamRegister: verifyCfamAccessTarget returns error!"); + // Add the error log pointer as data to the ReturnCode + //TODO RTC:143127: Need fapi2 support in ReturnCode class + //l_rc.setPlatError(reinterpret_cast<void *> (l_err)); + break; + } + + // Extract the component pointer + TARGETING::Target* l_target = + reinterpret_cast<TARGETING::Target*>(i_target.get()); + + TARGETING::Target* l_myChipTarget = NULL; + // Get the chip target if l_target is not a chip + l_err = getCfamChipTarget(l_target, l_myChipTarget); + if (l_err) + { + FAPI_ERR("platPutCfamRegister: getCfamChipTarget returns error!"); + // Add the error log pointer as data to the ReturnCode + //TODO RTC:143127: Need fapi2 support in ReturnCode class + //l_rc.setPlatError(reinterpret_cast<void *> (l_err)); + break; + } + + // Perform CFAM write via FSI + // Address needs to be multiply by 4 because register addresses are word + // offsets but the FSI addresses are byte offsets + // However, we need to preserve the engine's offset of 0x0C00 and 0x1000 + uint64_t l_addr = ((i_address & 0x003F) << 2) | (i_address & 0xFF00); + size_t l_size = sizeof(uint32_t); + uint32_t l_data = static_cast<uint32_t>(i_data); + l_err = deviceWrite(l_myChipTarget, + &l_data, + l_size, + DEVICE_FSI_ADDRESS(l_addr)); + if (l_err) + { + FAPI_ERR("platPutCfamRegister: deviceWrite returns error!"); + // Add the error log pointer as data to the ReturnCode + //TODO RTC:143127: Need fapi2 support in ReturnCode class + //l_rc.setPlatError(reinterpret_cast<void *> (l_err)); + break; + } + + } while (0); + + if (l_rc != fapi2::FAPI2_RC_SUCCESS) + { + FAPI_ERR("platPutCfamRegister failed - Target %s, Addr %.8X", + tmpScomStr, i_address); + } + + if( l_traceit ) + { + uint32_t l_data = i_data; + FAPI_SCAN( "TRACE : PUTCFAMREG : %s : %.8X %.8X", + tmpScomStr, + i_address, + l_data); + } + + FAPI_DBG(EXIT_MRK "platPutCfamRegister"); + return l_rc; +} + + +/// @brief Modifying input 32-bit data with the specified mode +/// This method modify 32-bit input data (io_modifiedData) by applying the +/// specified modify mode along with the input data (i_origData). +/// +/// @param[in] i_modifyMode Modification mode +/// @param[in] i_origData 32-bit data to be used for modification +/// @param[out] io_modifiedData 32-bit data to be modified +/// +/// @return void +/// +static void platProcess32BitModifyMode( + const fapi2::ChipOpModifyMode i_modifyMode, + const buffer<uint32_t> i_origDataBuf, + buffer<uint32_t>& io_modifiedData) +{ + +//@TODO RTC:143118 This should be a switch statement + + // OR operation + if (fapi2::CHIP_OP_MODIFY_MODE_OR == i_modifyMode) + { + io_modifiedData |= i_origDataBuf; + } + // AND operation + else if (fapi2::CHIP_OP_MODIFY_MODE_AND == i_modifyMode) + { + io_modifiedData &= i_origDataBuf; + } + // Must be XOR operation + else + { + io_modifiedData ^= i_origDataBuf; + } + + return; +} + +/// +/// @brief Platform-level implementation of modifyCfamRegister() +/// Hardware procedures writers will not call this function. +/// @Tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @param[in] i_address CFAM register address to modify. +/// @param[out] i_data 32-bit buffer that holds data to modify. +/// @param[in] i_modifyMode The modify mode (or/and/xor). +/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +template< TargetType K > +inline ReturnCode platModifyCfamRegister(const Target<K>& i_target, + const uint32_t i_address, + const buffer<uint32_t> i_data, + const fapi2::ChipOpModifyMode i_modifyMode) +{ + FAPI_DBG(ENTER_MRK "platModifyCfamRegister"); + ReturnCode l_rc; + errlHndl_t l_err = NULL; + bool l_traceit = platIsScanTraceEnabled(); + + //TODO: RTC 124195 - Support target::toEcmdString() for SCAN trace + const char* tmpScomStr = "TargetString"; + + do + { + // Can't access cfam engine on master processor + l_err = verifyCfamAccessTarget(i_target,i_address); + if (l_err) + { + FAPI_ERR("platModifyCfamRegister: verifyCfamAccessTarget returns error!"); + // Add the error log pointer as data to the ReturnCode + //TODO RTC:143127: Need fapi2 support in ReturnCode class + //l_rc.setPlatError(reinterpret_cast<void *> (l_err)); + break; + } + + // Extract the component pointer + TARGETING::Target* l_target = + reinterpret_cast<TARGETING::Target*>(i_target.get()); + + // Get the chip target if l_target is not a chip + TARGETING::Target* l_myChipTarget = NULL; + l_err = getCfamChipTarget(l_target, l_myChipTarget); + if (l_err) + { + FAPI_ERR("platModifyCfamRegister: getCfamChipTarget returns error!"); + // Add the error log pointer as data to the ReturnCode + //TODO RTC:143127: Need fapi2 support in ReturnCode class + //l_rc.setPlatError(reinterpret_cast<void *> (l_err)); + break; + } + + // Read current value + // Address needs to be multiply by 4 because register addresses are word + // offsets but the FSI addresses are byte offsets. + // However, we need to preserve the engine's offset of 0x0C00 and 0x1000 + uint64_t l_addr = ((i_address & 0x003F) << 2) | (i_address & 0xFF00); + buffer<uint32_t> l_data = 0; + size_t l_size = sizeof(uint32_t); + l_err = deviceRead(l_myChipTarget, + &l_data(), + l_size, + DEVICE_FSI_ADDRESS(l_addr)); + if (l_err) + { + FAPI_ERR("platModifyCfamRegister: deviceRead returns error!"); + // Add the error log pointer as data to the ReturnCode + //TODO RTC:143127: Need fapi2 support in ReturnCode class + //l_rc.setPlatError(reinterpret_cast<void *> (l_err)); + break; + } + + // Applying modification + platProcess32BitModifyMode(i_modifyMode, i_data, l_data); + + // Write back + l_err = deviceWrite(l_target, + &l_data(), + l_size, + DEVICE_FSI_ADDRESS(l_addr)); + if (l_err) + { + FAPI_ERR("platModifyCfamRegister: deviceWrite returns error!"); + // Add the error log pointer as data to the ReturnCode + //TODO RTC:143127: Need fapi2 support in ReturnCode class + //l_rc.setPlatError(reinterpret_cast<void *> (l_err)); + break; + } + + } while (0); + + if (l_rc != fapi2::FAPI2_RC_SUCCESS) + { + FAPI_ERR("platModifyCfamRegister failed - Target %s, Addr %.8X", + tmpScomStr, i_address); + } + + if( l_traceit ) + { + // get string representation of the modify mode + const char * l_pMode = NULL; + + if (i_modifyMode == fapi2::CHIP_OP_MODIFY_MODE_OR) + { + l_pMode = "OR"; + } + else if (i_modifyMode == fapi2::CHIP_OP_MODIFY_MODE_AND) + { + l_pMode = "AND"; + } + else if (i_modifyMode == fapi2::CHIP_OP_MODIFY_MODE_XOR) + { + l_pMode = "XOR"; + } + else + { + l_pMode = "?"; + } + + uint32_t l_data = (uint32_t)i_data; + FAPI_SCAN( "TRACE : MODCFAMREG : %s : %.8X %.8X %s", + tmpScomStr, + i_address, + l_data, + l_pMode ); + } + + FAPI_DBG(EXIT_MRK "platModifyCfamRegister"); + return l_rc; +} + +//@TODO RTC:126630 getRing is not yet supported + +#if 0 + +/// +/// @brief Platform-level implementation called by fapiGetRing() +/// Hardware procedures writers will not call this function. +/// @Tparam K template parameter, passed in target. +/// @param[in] i_target HW target to operate on. +/// @param[in] i_address Ring address to read from. +/// @param[out] o_data Buffer that holds ring data read from HW target. +/// @param[in] i_ringMode Ring operation mode. +/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +template< TargetType K > +inline ReturnCode platGetRing(const Target<K>& i_target, + const scanRingId_t i_address, + variable_buffer& o_data, + const RingMode i_ringMode = 0) +{ + FAPI_DBG(ENTER_MRK "platGetRing"); + ReturnCode l_rc; + errlHndl_t l_err = NULL; + + // Extract the component pointer + TARGETING::Target* l_target = + reinterpret_cast<TARGETING::Target*>(i_target.get()); + + // Output buffer must be set to ring's len by user + uint64_t l_ringLen = o_data.getBitLength(); + uint64_t l_flag = platGetDDScanMode(i_ringMode); + size_t l_size = o_data.getByteLength(); + l_err = deviceRead(l_target, + ecmdDataBufferBaseImplementationHelper::getDataPtr(&o_data), + l_size, + DEVICE_SCAN_ADDRESS(i_address, l_ringLen, l_flag)); + if (l_err) + { + // Add the error log pointer as data to the ReturnCode + //TODO RTC:143127: Need fapi2 support in ReturnCode class + //l_rc.setPlatError(reinterpret_cast<void *> (l_err)); + } + + FAPI_DBG(EXIT_MRK "platGetRing"); + return l_rc; +} + + +/// @brief Platform-level implementation called by fapiPutRing() +/// Hardware procedures writers will not call this function. +/// @tparam K template parameter, passed in target. +/// @param[in] i_target Target to operate on. +/// @param[in] i_address Ring address to write to. +/// @param[in] i_data Buffer that contains RS4 compressed ring data +/// to write into address +/// @param[in] i_ringMode Ring operation mode. +/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +template< TargetType K > +inline ReturnCode platPutRing(const Target<K>& i_target, + const scanRingId_t i_address, + variable_buffer& i_data, + const RingMode i_ringMode = 0) +{ +} + +/// @brief Platform-level implementation called by fapiModifyRing() +/// @tparam K template parameter, passed in target. +/// @param[in] i_target Target to operate on. +/// @param[in] i_address Ring address to modify. +/// @param[in] i_data Buffer that contains RS4 compressed ring data +/// to be modified. +/// @param[in] i_modifyMode The modify mode (or/and/xor) +/// @param[in] i_ringMode Ring operation mode. +/// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +template< TargetType K > +inline ReturnCode modifyRing(const Target<K>& i_target, + const scanRingId_t i_address, + variable_buffer& i_data, + const ChipOpModifyMode i_modifyMode, + const RingMode i_ringMode = 0) +{ +} + +#endif // End if 0 + +// -------------------------------------------------------------------------- +// NOTE: +// No spy access interface as HB doesn't allow spy access. +// -------------------------------------------------------------------------- + + +} // End namespace + +#endif // PLATHWACCESS_H_ diff --git a/src/include/usr/fapi2/plat_hwp_executor.H b/src/include/usr/fapi2/plat_hwp_executor.H new file mode 100644 index 000000000..ebffe2f3c --- /dev/null +++ b/src/include/usr/fapi2/plat_hwp_executor.H @@ -0,0 +1,58 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/fapi2/plat_hwp_executor.H $ */ +/* */ +/* OpenPOWER HostBoot 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 plat_hwp_executor.H +/// +/// @brief Defines the specialized platform HWP Executor Macro. +/// +/// The PLAT HWP Executor macro is called by the FAPI HWP Executor macro 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) +/// + +// plat_hwp_executor.H (platform owned file) - Platform specialization +// of functions. +// +// fapi2_hwp_executor.H (common file) - contains the templates +// and calls a required macro +// for non-specialized methods. +// +// hw_executor.H (platform owned file) - Platform implementation of +// functions defined in +// fapi2_hwp_executor.H above. +// -- Include order -- +// procedure.C +// #include <hwp_executor.H> +// target.H +// #include plat_hwp_executor.H +// #include fapi2_hwp_executor.H + +#ifndef PLATHWPEXECUTOR_H_ +#define PLATHWPEXECUTOR_H_ + +// Currently empty because no specialzation for Hostboot + +#endif // PLATHWPEXECUTOR_H_ diff --git a/src/include/usr/fapi2/plat_hwp_invoker.H b/src/include/usr/fapi2/plat_hwp_invoker.H new file mode 100644 index 000000000..0d55c3e01 --- /dev/null +++ b/src/include/usr/fapi2/plat_hwp_invoker.H @@ -0,0 +1,67 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/fapi2/plat_hwp_invoker.H $ */ +/* */ +/* OpenPOWER HostBoot 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 plat_hwp_invoker.H + * + * @brief Defines the HostBoot HWP invoker macro and a function to convert a + * fapi::ReturnCode to an error log + */ + +/// +/// @file src/include/usr/hwpf/plat/plat_hwp_invoker.H +/// +/// @brief Defines the HostBoot FAPI2 HWP invoker macro and a function to +/// convert a fapi2::ReturnCode to an error log +/// +/// Note that platform code must provide the code. +/// + +#ifndef PLATHWPINVOKER_H_ +#define PLATHWPINVOKER_H_ + +#include <return_code.H> +#include <plat_utils.H> + +/** + * @brief HWP Invoker macro + * + * This macro is called by HostBoot PLAT code to invoke a HW Procedure (HWP). + * The caller must create any necessary fapi::Targets and pass them as + * parameters. This macro simply calls the FAPI HWP executor macro and converts + * the returned fapi::Return code to a HostBoot error log + * + * ERRHNDL - errlHndl_t + * FUNC - HWP function name + * _args_... - Any additional arguments that the HWP requires + */ + +#define FAPI_INVOKE_HWP(ERRHNDL, FUNC, _args_...) \ + {\ + fapi2::ReturnCode l_rc; \ + FAPI_EXEC_HWP(l_rc, FUNC, ##_args_); \ + ERRHNDL = fapi2::rcToErrl(l_rc);\ + } + +#endif // PLATHWPINVOKER_H_ diff --git a/src/include/usr/fapi2/plat_target.H b/src/include/usr/fapi2/plat_target.H new file mode 100644 index 000000000..2b98b168a --- /dev/null +++ b/src/include/usr/fapi2/plat_target.H @@ -0,0 +1,41 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/fapi2/plat_target.H $ */ +/* */ +/* OpenPOWER HostBoot 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 plat_target.H +/// @brief Define FAPI2 target functions for the platform layer. +/// + +#ifndef __FAPI2_PLAT_TARGET__ +#define __FAPI2_PLAT_TARGET__ + +// HB platform support +#include <targeting/common/target.H> + +namespace fapi2 +{ + typedef TARGETING::Target* plat_target_handle_t; +} // End namespace fapi2 + +#endif // __FAPI2_PLAT_TARGET__ diff --git a/src/include/usr/fapi2/plat_trace.H b/src/include/usr/fapi2/plat_trace.H new file mode 100644 index 000000000..9d03adcff --- /dev/null +++ b/src/include/usr/fapi2/plat_trace.H @@ -0,0 +1,43 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/fapi2/plat_trace.H $ */ +/* */ +/* OpenPOWER HostBoot 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 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 PLAT_TRACE_H_ +#define PLAT_TRACE_H_ + +// Use the same macro from FAPI1 +#include <fapiPlatTrace.H> + +static const uint32_t MAX_ECMD_STRING_LEN = 64; + +#endif // PLAT_TRACE_H_ diff --git a/src/include/usr/fapi2/plat_utils.H b/src/include/usr/fapi2/plat_utils.H new file mode 100644 index 000000000..ce822faa6 --- /dev/null +++ b/src/include/usr/fapi2/plat_utils.H @@ -0,0 +1,63 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/fapi2/plat_utils.H $ */ +/* */ +/* OpenPOWER HostBoot 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 plat_utils.H +/// +/// @brief FAPI2 utility functions +/// +/// Note that platform code must provide the implementation. +/// + +#ifndef PLAT_UTILS_H_ +#define PLAT_UTILS_H_ + +#include <return_code.H> + +namespace fapi2 +{ + +/// +/// @brief This function answers the question, is scand tracing turned on? +/// The implementation of this function is specific to the platform. +/// +/// @returns Boolean indication +/// +bool platIsScanTraceEnabled(); + +/// +/// @brief Converts a fapi2::ReturnCode to a HostBoot PLAT error log +/// +/// @param[io] io_rc Reference to ReturnCode (set to success after function) +/// @param[in] i_sev Error log severity defaulted to unrecoverable +/// +/// @return errlHndl_t (NULL if Return Code contained success) +/// +errlHndl_t rcToErrl(ReturnCode & io_rc, + ERRORLOG::errlSeverity_t i_sev = + ERRORLOG::ERRL_SEV_UNRECOVERABLE); + +} // End namespace fapi2 + +#endif // PLAT_UTILS_H_ diff --git a/src/include/usr/fapi2/target.H b/src/include/usr/fapi2/target.H new file mode 100644 index 000000000..b783a42e5 --- /dev/null +++ b/src/include/usr/fapi2/target.H @@ -0,0 +1,336 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/fapi2/target.H $ */ +/* */ +/* OpenPOWER HostBoot 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 target.H +/// +/// @brief Defines the platform target functions that needs to be +/// specialized for platform implementation. +/// +/** + * @file target.H + * @brief platform specializations for fapi2 targets + */ + +#ifndef __FAPI2_TARGET__ +#define __FAPI2_TARGET__ + +#include <plat_target.H> +#include <stdio.h> +#include <stdint.h> +#include <vector> +#include <fapi2_target.H> +#include <target_types.H> + +// HB platform support +#include <fapiPlatTrace.H> +#include <targeting/common/target.H> +#include <targeting/common/commontargeting.H> +#include <targeting/common/utilFilter.H> + +namespace fapi2 +{ + +/// +/// @brief Assignment Operator. +/// @param[in] i_right Reference to Target to assign from. +/// @return Reference to 'this' Target +/// +template<TargetType K, typename V> +Target<K, V>& Target<K, V>::operator=(const Target& i_right) +{ iv_handle = i_right.iv_handle; return *this; } + +/// +/// @brief Equality Comparison Operator +/// @param[in] i_right Reference to Target to compare. +/// @return bool. True if equal. +/// @note Platforms need to define this so that the physical +/// targets are determined to be equivilent rather than just the handles +/// +template<TargetType K, typename V> +bool Target<K, V>::operator==(const Target& i_right) const +{ return i_right.iv_handle == iv_handle; } + +/// +/// @brief Inquality Comparison Operator +/// @param[in] i_right Reference to Target to compare. +/// @return bool. True if not equal. +/// @note Platforms need to define this so that the physical +/// targets are determined to be equivilent rather than just the handles +/// +template<TargetType K, typename V> +bool Target<K, V>::operator!=(const Target& i_right) const +{ return i_right.iv_handle != iv_handle; } + +/// +/// @brief This function takes in a FAPI2 Type and returns the corresponding +/// TARGETING::Target type +/// +/// @param[in] i_fapi2Type +/// +/// @returns TARGETTING::Type equivelent to fapi2 type +inline TARGETING::TYPE convertFapi2TypeToTargeting(fapi2::TargetType i_T) +{ + TARGETING::TYPE o_targetingType = TARGETING::TYPE_NA; + + switch (i_T) + { + case fapi2::TARGET_TYPE_NONE: + o_targetingType = TARGETING::TYPE_NA; + break; + case fapi2::TARGET_TYPE_SYSTEM: + o_targetingType = TARGETING::TYPE_SYS; + break; + case fapi2::TARGET_TYPE_DIMM: + o_targetingType = TARGETING::TYPE_DIMM; + break; + case fapi2::TARGET_TYPE_PROC_CHIP: + o_targetingType = TARGETING::TYPE_PROC; + break; + case fapi2::TARGET_TYPE_MEMBUF_CHIP: + o_targetingType = TARGETING::TYPE_MEMBUF; + break; + case fapi2::TARGET_TYPE_EX: + o_targetingType = TARGETING::TYPE_EX; + break; + case fapi2::TARGET_TYPE_MBA: + o_targetingType = TARGETING::TYPE_MBA; + break; + case fapi2::TARGET_TYPE_MCS: + o_targetingType = TARGETING::TYPE_MCS; + break; + case fapi2::TARGET_TYPE_XBUS: + o_targetingType = TARGETING::TYPE_XBUS; + break; + case fapi2::TARGET_TYPE_ABUS: + o_targetingType = TARGETING::TYPE_ABUS; + break; + case fapi2::TARGET_TYPE_L4: + o_targetingType = TARGETING::TYPE_L4; + break; + case fapi2::TARGET_TYPE_CORE: + o_targetingType = TARGETING::TYPE_CORE; + break; + case fapi2::TARGET_TYPE_EQ: + o_targetingType = TARGETING::TYPE_EQ; + break; + case fapi2::TARGET_TYPE_MCA: + o_targetingType = TARGETING::TYPE_MCA; + break; + case fapi2::TARGET_TYPE_MCBIST: + o_targetingType = TARGETING::TYPE_MCBIST; + break; + case fapi2::TARGET_TYPE_MI: + o_targetingType = TARGETING::TYPE_MI; + break; + case fapi2::TARGET_TYPE_CAPP: + o_targetingType = TARGETING::TYPE_CAPP; + break; + case fapi2::TARGET_TYPE_DMI: + o_targetingType = TARGETING::TYPE_DMI; + break; + case fapi2::TARGET_TYPE_OBUS: + o_targetingType = TARGETING::TYPE_OBUS; + break; + case fapi2::TARGET_TYPE_NV: + o_targetingType = TARGETING::TYPE_NVBUS; + break; + case fapi2::TARGET_TYPE_SBE: + o_targetingType = TARGETING::TYPE_SBE; + break; + case fapi2::TARGET_TYPE_PPE: + o_targetingType = TARGETING::TYPE_PPE; + break; + case fapi2::TARGET_TYPE_PERV: + o_targetingType = TARGETING::TYPE_PERV; + break; + case fapi2::TARGET_TYPE_PEC: + o_targetingType = TARGETING::TYPE_PEC; + break; + case fapi2::TARGET_TYPE_PHB: + o_targetingType = TARGETING::TYPE_PHB; + break; + default: + FAPI_ERR("Chiplet type not supported 0x%.8X!", i_T); + break; + } + + return o_targetingType; +} + + +/// +/// @brief Get this target's immediate parent +/// @tparam T The desired type of the parent target +/// @return Target<T> a target representing the parent +/// +template<TargetType K, typename V> +template<TargetType T> +inline Target<T> Target<K, V>::getParent(void) const +{ + //@TODO RTC:129517 fapi2 getParent + // For testing + return Target<T>(iv_handle); +} + +/// +/// @brief Get this target's children +/// @tparam T The desired type of child target +/// @param[in] i_state The desired TargetState of the children +/// @return std::vector<Target<T> > a vector of present/functional +/// children +/// @warning The children of EX's (cores) are expected to be returned +/// in order. That is, core 0 is std::vector[0]. +/// +template<TargetType K, typename V> +template< TargetType T> +inline std::vector<Target<T> > + Target<K, V>::getChildren(const TargetState i_state) const +{ + std::vector<Target<T>> l_children; + TARGETING::TYPE l_type = TARGETING::TYPE_NA; + TARGETING::TargetHandleList l_chipletList; + bool l_functional = (i_state & fapi2::TARGET_STATE_FUNCTIONAL)? true:false; + + FAPI_INF(ENTER_MRK "getChildren. Type 0x%08x State:0x%08x", T, i_state); + + switch (T) + { + //@TODO RTC:129517 to add the rest of the types + case TARGET_TYPE_EX_CHIPLET: l_type = TARGETING::TYPE_EX; break; + case TARGET_TYPE_MBA_CHIPLET: l_type = TARGETING::TYPE_MBA; break; + case TARGET_TYPE_MCS_CHIPLET: l_type = TARGETING::TYPE_MCS; break; + case TARGET_TYPE_XBUS_ENDPOINT: l_type = TARGETING::TYPE_XBUS; break; + case TARGET_TYPE_ABUS_ENDPOINT: l_type = TARGETING::TYPE_ABUS; break; + case TARGET_TYPE_L4: l_type = TARGETING::TYPE_L4; break; + default: + FAPI_ERR("getChildren: Chiplet type 0x%08x not supported 0x%08x", + T); + assert(false); + break; + } + + TARGETING::getChildChiplets(l_chipletList, + static_cast<TARGETING::Target*>(this->get()), + l_type, + l_functional); + + FAPI_INF("getChildren: l_functional 0x%.8X, l_type = 0x%.8X, ChipUnitId 0x%.8X", + l_functional, l_type, TARGETING::get_huid(this->get())); + FAPI_INF("getChildren: l_chipletList size %d", l_chipletList.size()); + + // Return fapi::Targets to the caller + for (TARGETING::TargetHandleList::const_iterator + chipletIter = l_chipletList.begin(); + chipletIter != l_chipletList.end(); + ++chipletIter) + { + TARGETING::HwasState l_state = + (*chipletIter)->getAttr<TARGETING::ATTR_HWAS_STATE>(); + + // HWPs/FAPI considers partial good chiplets as present, but + // firmware considers them not-present. Return all chiplets + // in the model when caller requests PRESENT + if ((fapi2::TARGET_STATE_FUNCTIONAL == i_state) && + !l_state.functional) + { + continue; + } + fapi2::Target<T> l_target(*chipletIter); + l_children.push_back(l_target); + } + FAPI_INF(EXIT_MRK "getChildren. %d results", l_children.size()); + + return l_children; +} + +/// +/// @brief Get the target at the other end of a bus - dimm included +/// @tparam T The type of the parent +/// @param[in] i_state The desired TargetState of the children +/// @return Target<T> a target representing the thing on the other end +/// @note Can be easily changed to a vector if needed +/// +template<TargetType K, typename V> +template<TargetType T> +inline Target<T> +Target<K, V>::getOtherEnd(const TargetState i_state) const +{ + //@TODO RTC:129517 + // Implementation note: cast to a composite of + // bus types and the compiler will check if this is + // a good function at compile time + return Target<T>(); +} + + +/// +/// @brief Return the string interpretation of this target +/// @tparam T The type of the target +/// @param[in] i_target Target<T> +/// @param[in] i_buffer buffer to write in to +/// @param[in] i_bsize size of the buffer +/// @return void +/// @post The contents of the buffer is replaced with the string +/// representation of the target +/// +template< TargetType T > +inline void toString(const Target<T>& i_target, char* i_buffer, size_t i_bsize) +{ + snprintf(i_buffer, i_bsize, "Target 0x%lx/0x%x", i_target.get(), T); +} + +/// +/// @brief Return the string interpretation of this target +/// @tparam T The type of the target +/// @param[in] A pointer to the Target<T> +/// @param[in] i_buffer buffer to write in to +/// @param[in] i_bsize size of the buffer +/// @return void +/// @post The contents of the buffer is replaced with the string +/// representation of the target +/// +template< TargetType T > +inline void toString(const Target<T>* i_target, char* i_buffer, size_t i_bsize) +{ + snprintf(i_buffer, i_bsize, "Target 0x%lx/0x%x", i_target->get(), T); +} + +/// +/// @brief Get an enumerated target of a specific type +/// @tparam T The type of the target +/// @param[in] Ordinal representing the ordinal number of +/// the desired target +/// @return Target<T> the target requested +/// +template<TargetType T> +inline Target<T> getTarget(uint64_t Ordinal) +{ + //@TODO RTC:129517 + // For testing + return Target<T>(Ordinal); +} + +} // End namespace fapi2 + +#endif // End __FAPI2_TARGET__ diff --git a/src/include/usr/hbotcompid.H b/src/include/usr/hbotcompid.H index dc5b79d41..bfb5b29d7 100644 --- a/src/include/usr/hbotcompid.H +++ b/src/include/usr/hbotcompid.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2015 */ +/* Contributors Listed Below - COPYRIGHT 2011,2016 */ /* [+] Google Inc. */ /* [+] International Business Machines Corp. */ /* */ @@ -391,6 +391,13 @@ const compId_t SIO_COMP_ID = 0x3200; const char SIO_COMP_NAME[] = "sio"; //@} +/** @name FAPI2 + * FAPI2 Interface + */ +const compId_t FAPI2_COMP_ID = 0x3300; +const char FAPI2_COMP_NAME[] = "fapi2"; + + /** @name PRDF * PRDF component * @Note PRDF_COMP_ID=0xE500 matches with what diff --git a/src/include/usr/hwas/common/hwasCallout.H b/src/include/usr/hwas/common/hwasCallout.H index 622b1ca84..1ed36f119 100644 --- a/src/include/usr/hwas/common/hwasCallout.H +++ b/src/include/usr/hwas/common/hwasCallout.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2015 */ +/* Contributors Listed Below - COPYRIGHT 2012,2016 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -134,8 +134,15 @@ enum partTypeEnum LPC_SLAVE_PART_TYPE = 5, GPIO_EXPANDER_PART_TYPE = 6, SPIVID_SLAVE_PART_TYPE = 7, + TOD_CLOCK = 8, + MEM_REF_CLOCK = 9, + PROC_REF_CLOCK = 10, + PCI_REF_CLOCK = 11, }; + + + // const uint8_t HW_CALLOUT = 0x01; const uint8_t PROCEDURE_CALLOUT = 0x02; diff --git a/src/include/usr/targeting/common/target.H b/src/include/usr/targeting/common/target.H index bf5b7dad4..4901845c8 100644 --- a/src/include/usr/targeting/common/target.H +++ b/src/include/usr/targeting/common/target.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2015 */ +/* Contributors Listed Below - COPYRIGHT 2012,2016 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -54,17 +54,20 @@ //****************************************************************************** // Forward declarations to allow friend functions to work //****************************************************************************** -namespace fapi + + +namespace fapi2 { - class ReturnCode; - class Target; - namespace platAttrSvc + namespace platAttrSvc { - fapi::ReturnCode getTargetingAttr(const fapi::Target *, - const TARGETING::ATTRIBUTE_ID, const uint32_t, void *); - fapi::ReturnCode setTargetingAttr(const fapi::Target *, - const TARGETING::ATTRIBUTE_ID, const uint32_t, void *); + + bool setTargetingAttrHelper(TARGETING::Target * , + const TARGETING::ATTRIBUTE_ID , + const uint32_t , void * ); + bool getTargetingAttrHelper(TARGETING::Target * , + const TARGETING::ATTRIBUTE_ID , + const uint32_t , void * ); } } @@ -351,8 +354,7 @@ class Target void getAttrTankTargetPosData(uint16_t & o_pos, uint8_t & o_unitPos, uint8_t & o_node) const; - - private: // Private helper interfaces + private: // Private helper interfaces /** * @brief Tries to get the target's specified attribute value @@ -404,6 +406,7 @@ class Target uint32_t i_size, const void* i_pAttrData) const; + /** * @brief Gets a pointer to the target's associated attribute * @@ -573,15 +576,19 @@ class Target friend class AssociationManager; friend class AttributeTank; - // Friend functions to allow FAPI Attribute code to directly call - // _tryGetAttr and _trySetAttr for code size optimization - friend fapi::ReturnCode fapi::platAttrSvc::getTargetingAttr( - const fapi::Target *, TARGETING::ATTRIBUTE_ID, const uint32_t, - void *); - friend fapi::ReturnCode fapi::platAttrSvc::setTargetingAttr( - const fapi::Target *, TARGETING::ATTRIBUTE_ID, const uint32_t, - void *); + + + friend bool fapi2:: + platAttrSvc:: + setTargetingAttrHelper(TARGETING::Target*, + const TARGETING::ATTRIBUTE_ID , + const uint32_t , void * ); + friend bool fapi2:: + platAttrSvc:: + getTargetingAttrHelper(TARGETING::Target * , + const TARGETING::ATTRIBUTE_ID , + const uint32_t , void * ); /* * @brief allow targetattrbulksync access to the target class store. */ |

