diff options
author | Brian Silver <bsilver@us.ibm.com> | 2015-04-20 11:55:59 -0500 |
---|---|---|
committer | Derk Rembold <rembold@de.ibm.com> | 2015-09-03 07:25:53 -0500 |
commit | 1a804befd328a0863d3a330a2359d2546f0ecc0e (patch) | |
tree | 5fb3981cef701542c80fb2dba88fb851beb12bac /import/hwpf/fapi2 | |
parent | 2307a1d4d8d2be9465860b1950746ce34ba2a467 (diff) | |
download | talos-sbe-1a804befd328a0863d3a330a2359d2546f0ecc0e.tar.gz talos-sbe-1a804befd328a0863d3a330a2359d2546f0ecc0e.zip |
Update FFDC mechanism to better handle targets, buffers
Fix bug in --empty-ffdc-classes, exectue()
Change-Id: I2a872efacbe68719495b7d40123db683c3a6db3e
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/17340
Reviewed-by: Thi N. Tran <thi@us.ibm.com>
Reviewed-by: Matt K. Light <mklight@us.ibm.com>
Reviewed-by: Brian Silver <bsilver@us.ibm.com>
Tested-by: Brian Silver <bsilver@us.ibm.com>
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/20138
Tested-by: Jenkins Server
Reviewed-by: Derk Rembold <rembold@de.ibm.com>
Diffstat (limited to 'import/hwpf/fapi2')
-rw-r--r-- | import/hwpf/fapi2/include/collect_reg_ffdc.H | 4 | ||||
-rw-r--r-- | import/hwpf/fapi2/include/error_info.H | 206 | ||||
-rw-r--r-- | import/hwpf/fapi2/include/error_info_defs.H | 247 | ||||
-rw-r--r-- | import/hwpf/fapi2/include/return_code.H | 76 | ||||
-rw-r--r-- | import/hwpf/fapi2/include/return_code_defs.H | 114 | ||||
-rw-r--r-- | import/hwpf/fapi2/include/utils.H | 2 | ||||
-rw-r--r-- | import/hwpf/fapi2/include/variable_buffer.H | 42 |
7 files changed, 386 insertions, 305 deletions
diff --git a/import/hwpf/fapi2/include/collect_reg_ffdc.H b/import/hwpf/fapi2/include/collect_reg_ffdc.H index 495b2a3c..764bb3c8 100644 --- a/import/hwpf/fapi2/include/collect_reg_ffdc.H +++ b/import/hwpf/fapi2/include/collect_reg_ffdc.H @@ -50,7 +50,7 @@ namespace fapi2 /// @warning This should only be called by FAPI during FAPI_SET_HWP_ERROR or /// FAPI_ADD_INFO_TO_HWP_ERROR /// - /// @param[in] i_target Pointer to Target to collect FFDC from + /// @param[in] i_target Pointer to Target to collect FFDC from (ffdc_t.ptr()) /// @param[in] i_ffdcId FFDC Identifier /// @param[out] o_rc Reference to ReturnCode that FFDC is added to /// @param[in] i_child Specifies type of i_target's chiplet to collect @@ -67,7 +67,7 @@ namespace fapi2 /// addresses when collecting register FFDC based on /// present child chiplets. /// - void collectRegFfdc(const fapi2::Target<TARGET_TYPE_ALL>* i_target, + void collectRegFfdc(const fapi2::ffdc_t& i_target, const fapi2::HwpFfdcId i_ffdcId, fapi2::ReturnCode & o_rc, const TargetType i_child = TARGET_TYPE_NONE, diff --git a/import/hwpf/fapi2/include/error_info.H b/import/hwpf/fapi2/include/error_info.H index 3f53503d..033e1bbd 100644 --- a/import/hwpf/fapi2/include/error_info.H +++ b/import/hwpf/fapi2/include/error_info.H @@ -35,215 +35,11 @@ #include <memory> #include <vector> #include <target.H> +#include <error_info_defs.H> #include <assert.h> namespace fapi2 { - class ReturnCode; - - /// - /// @brief Type to hold the ffdc element in the ffdc class - /// Needed so that the size can be squirled away before the - /// macro is called. - /// - class ffdc_t - { - public: - ffdc_t(void) - {} - - operator const void*() const { return iv_value.first; } - operator uint8_t() const - { return *(reinterpret_cast<const uint8_t*>(iv_value.first)); } - - int16_t size(void) const { return iv_value.second; } - int16_t& size(void) { return iv_value.second; } - - const void* ptr(void) const { return iv_value.first; } - const void*& ptr(void) { return iv_value.first; } - - private: - std::pair<const void*, int16_t> iv_value; - }; - - /// - /// @brief Enumeration of ErrorInfo FFDC sizes that are used to indicate a - /// special type that cannot simply be memcopied - enum ErrorInfoFfdcSize - { - EI_FFDC_SIZE_TARGET = 0xfffe, // fapi2::Target - EI_FFDC_MAX_SIZE = 0x1000, // Limit regular FFDC capture to 4kb - }; - - /// - /// @brief Enumeration of error log severity. - /// - enum errlSeverity_t - { - FAPI2_ERRL_SEV_UNDEFINED = 0x00, /// Used internally by ffdc mechanism - FAPI2_ERRL_SEV_RECOVERED = 0x10, /// Not seen by customer - FAPI2_ERRL_SEV_PREDICTIVE = 0x20, /// Error recovered but customer will see - FAPI2_ERRL_SEV_UNRECOVERABLE = 0x40 /// Unrecoverable, general - }; - - /// - /// @brief Enumeration of ErrorInfo types - /// - enum ErrorInfoType - { - EI_TYPE_FFDC = 0, - EI_TYPE_HW_CALLOUT = 1, - EI_TYPE_PROCEDURE_CALLOUT = 2, - EI_TYPE_BUS_CALLOUT = 3, - EI_TYPE_CDG = 4, // Target Callout/Deconfig/GARD - EI_TYPE_CHILDREN_CDG = 5, // Children Callout/Deconfig/GARD - EI_TYPE_COLLECT_TRACE = 6, - EI_LAST_TYPE = EI_TYPE_COLLECT_TRACE + 1, - }; - - /// - /// @enum HwCallout - /// - /// This enumeration defines the possible Hardware Callouts that are not - /// represented by fapi2::Targets - /// - /// Note that platform code may depend on the enum values starting at 0 and - /// incrementing in order to efficiently convert to a platform callout value - /// so do not reorder without consulting all platforms - /// - namespace HwCallouts - { - enum HwCallout - { - // Where indicated, a HW Callout in FAPI Error XML must include a - // reference target that is used to identify the HW. e.g. for - // TOD_CLOCK, the proc chip that the clock is attached to must be - // specified - TOD_CLOCK = 0, // Include proc-chip ref (or child chiplet) - MEM_REF_CLOCK = 1, // Include membuf-chip ref (or child chiplet) - PROC_REF_CLOCK = 2, // Include proc-chip ref (or child chiplet) - PCI_REF_CLOCK = 3, // Include proc-chip ref (or child chiplet) - FLASH_CONTROLLER_PART = 4, - PNOR_PART = 5, - SBE_SEEPROM_PART = 6, - VPD_PART = 7, - LPC_SLAVE_PART = 8, - GPIO_EXPANDER_PART = 9, - SPIVID_SLAVE_PART = 10, - }; - } - - /// - /// @enum ProcedureCallout - /// - /// This enumeration defines the possible Procedure Callouts - /// These instruct the customer/customer-engineer what to do - /// - /// Note that platform code may depend on the enum values starting at 0 and - /// incrementing in order to efficiently convert to a platform callout value - /// so do not reorder without consulting all platforms - /// - namespace ProcedureCallouts - { - enum ProcedureCallout - { - CODE = 0, // Code problem - LVL_SUPPORT = 1, // Call next level of support - MEMORY_PLUGGING_ERROR = 2, // DIMM Plugging error - BUS_CALLOUT = 3, // Bus Called Out - }; - } - - /// - /// @enum CalloutPriority - /// - /// This enumeration defines the possible Procedure and Target callout priorities - /// - /// Note that platform code may depend on the enum values starting at 0 and - /// incrementing in order to efficiently convert to a platform priority value - /// so do not reorder without consulting all platforms - /// - namespace CalloutPriorities - { - enum CalloutPriority - { - LOW = 0, - MEDIUM = 1, - HIGH = 2, - }; - } - - /// - /// @enum Collect Trace - /// - /// This enumeration defines the possible firmware traces to collect - /// - namespace CollectTraces - { - const uint32_t TRACE_SIZE = 256; // limit collected trace size - enum CollectTrace - { - FSI = 1, - SCOM = 2, - SCAN = 3, - MBOX = 4, - }; - } - - /// - /// @brief Get FFDC Size - /// - /// This is called by the FAPI_SET_HWP_ERROR macro to find out the size of - /// FFDC data. If the data is of a special type that is handled differently - /// than types that are simply memcopied then it is handled by a template - /// specialization. - /// If this function template is instantiated with a pointer, the compile - /// will fail. - /// - /// @return uint16_t. Size of the FFDC data - /// - template<typename T> - inline uint16_t getErrorInfoFfdcSize(const T &) - { - static_assert(sizeof(T) <= EI_FFDC_MAX_SIZE, - "FFDC too large to capture"); - return sizeof(T); - } - - /// - /// @brief Compile error if caller tries to get the FFDC size of a pointer - /// - template<typename T> - inline uint16_t getErrorInfoFfdcSize(const T*) - { - static_assert(std::is_pointer<T>::value, - "pointer passed to getErrorInfoFfdcSize"); - return 0; - } - - /// - /// @brief Get FFDC Size specialization for fapi2::Target - /// - template<> - inline uint16_t getErrorInfoFfdcSize(const fapi2::Target<TARGET_TYPE_ALL>*) - { - return EI_FFDC_SIZE_TARGET; - } - - /// - /// @brief Get FFDC Size specialization for ffdc method arguments - /// @note The ffdc class sets the std::pair when the method is - /// called so the size has been calculated. All that needs to be - /// done here is to grab it. We do it this way so the macro definitions - /// can be the same whether the ffdc class is used or the old-school - /// locals. - /// - template<> - inline uint16_t getErrorInfoFfdcSize(const fapi2::ffdc_t& i_thing) - { - return i_thing.size(); - } - /// /// @class ErrorInfoFfdc /// diff --git a/import/hwpf/fapi2/include/error_info_defs.H b/import/hwpf/fapi2/include/error_info_defs.H new file mode 100644 index 00000000..ca899426 --- /dev/null +++ b/import/hwpf/fapi2/include/error_info_defs.H @@ -0,0 +1,247 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2011,2015 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ + +/// +/// @file error_info_defs.H +/// @brief Defines to support the Error Information class +/// + +#ifndef FAPI2_ERRORINFO_DEFS_H_ +#define FAPI2_ERRORINFO_DEFS_H_ + +#include <stdint.h> +#include <target.H> +#include <variable_buffer.H> +#include <assert.h> + +#include <iostream> + +namespace fapi2 +{ + /// + /// @brief Type to hold the ffdc element in the ffdc class + /// Needed so that the size can be squirled away before the + /// macro is called. + /// + class ffdc_t + { + public: + ffdc_t(void) + {} + + operator const void*() const { return iv_value.first; } + operator uint8_t() const + { return *(reinterpret_cast<const uint8_t*>(iv_value.first)); } + + int16_t size(void) const { return iv_value.second; } + int16_t& size(void) { return iv_value.second; } + + const void* ptr(void) const { return iv_value.first; } + const void*& ptr(void) { return iv_value.first; } + + private: + std::pair<const void*, int16_t> iv_value; + }; + + /// + /// @brief Enumeration of ErrorInfo FFDC sizes that are used to indicate a + /// special type that cannot simply be memcopied + enum ErrorInfoFfdcSize + { + EI_FFDC_SIZE_BUF = 0xffff, // fapi2::buffer<T> + EI_FFDC_SIZE_TARGET = 0xfffe, // fapi2::Target + EI_FFDC_SIZE_VBUF = 0xfffd, // fapi2::variable_buffer + EI_FFDC_MAX_SIZE = 0x1000, // Limit regular FFDC capture to 4kb + }; + + /// + /// @brief Enumeration of error log severity. + /// + enum errlSeverity_t + { + FAPI2_ERRL_SEV_UNDEFINED = 0x00, /// Used internally by ffdc mechanism + FAPI2_ERRL_SEV_RECOVERED = 0x10, /// Not seen by customer + FAPI2_ERRL_SEV_PREDICTIVE = 0x20, /// Error recovered but customer will see + FAPI2_ERRL_SEV_UNRECOVERABLE = 0x40 /// Unrecoverable, general + }; + + /// + /// @brief Enumeration of ErrorInfo types + /// + enum ErrorInfoType + { + EI_TYPE_FFDC = 0, + EI_TYPE_HW_CALLOUT = 1, + EI_TYPE_PROCEDURE_CALLOUT = 2, + EI_TYPE_BUS_CALLOUT = 3, + EI_TYPE_CDG = 4, // Target Callout/Deconfig/GARD + EI_TYPE_CHILDREN_CDG = 5, // Children Callout/Deconfig/GARD + EI_TYPE_COLLECT_TRACE = 6, + EI_LAST_TYPE = EI_TYPE_COLLECT_TRACE + 1, + }; + + /// + /// @enum HwCallout + /// + /// This enumeration defines the possible Hardware Callouts that are not + /// represented by fapi2::Targets + /// + /// Note that platform code may depend on the enum values starting at 0 and + /// incrementing in order to efficiently convert to a platform callout value + /// so do not reorder without consulting all platforms + /// + namespace HwCallouts + { + enum HwCallout + { + // Where indicated, a HW Callout in FAPI Error XML must include a + // reference target that is used to identify the HW. e.g. for + // TOD_CLOCK, the proc chip that the clock is attached to must be + // specified + TOD_CLOCK = 0, // Include proc-chip ref (or child chiplet) + MEM_REF_CLOCK = 1, // Include membuf-chip ref (or child chiplet) + PROC_REF_CLOCK = 2, // Include proc-chip ref (or child chiplet) + PCI_REF_CLOCK = 3, // Include proc-chip ref (or child chiplet) + FLASH_CONTROLLER_PART = 4, + PNOR_PART = 5, + SBE_SEEPROM_PART = 6, + VPD_PART = 7, + LPC_SLAVE_PART = 8, + GPIO_EXPANDER_PART = 9, + SPIVID_SLAVE_PART = 10, + }; + } + + /// + /// @enum ProcedureCallout + /// + /// This enumeration defines the possible Procedure Callouts + /// These instruct the customer/customer-engineer what to do + /// + /// Note that platform code may depend on the enum values starting at 0 and + /// incrementing in order to efficiently convert to a platform callout value + /// so do not reorder without consulting all platforms + /// + namespace ProcedureCallouts + { + enum ProcedureCallout + { + CODE = 0, // Code problem + LVL_SUPPORT = 1, // Call next level of support + MEMORY_PLUGGING_ERROR = 2, // DIMM Plugging error + BUS_CALLOUT = 3, // Bus Called Out + }; + } + + /// + /// @enum CalloutPriority + /// + /// This enumeration defines the possible Procedure and Target callout priorities + /// + /// Note that platform code may depend on the enum values starting at 0 and + /// incrementing in order to efficiently convert to a platform priority value + /// so do not reorder without consulting all platforms + /// + namespace CalloutPriorities + { + enum CalloutPriority + { + LOW = 0, + MEDIUM = 1, + HIGH = 2, + }; + } + + /// + /// @enum Collect Trace + /// + /// This enumeration defines the possible firmware traces to collect + /// + namespace CollectTraces + { + const uint32_t TRACE_SIZE = 256; // limit collected trace size + enum CollectTrace + { + FSI = 1, + SCOM = 2, + SCAN = 3, + MBOX = 4, + }; + } + + /// + /// @brief Get FFDC Size + /// + /// This is called by the FAPI_SET_HWP_ERROR macro to find out the size of + /// FFDC data. If the data is of a special type that is handled differently + /// than types that are simply memcopied then it is handled by a template + /// specialization. + /// If this function template is instantiated with a pointer, the compile + /// will fail. + /// + /// @return uint16_t. Size of the FFDC data + /// + template<typename T> + inline uint16_t getErrorInfoFfdcSize(const T &) + { + static_assert(sizeof(T) <= EI_FFDC_MAX_SIZE, + "FFDC too large to capture"); + return sizeof(T); + } + + /// + /// @brief Compile error if caller tries to get the FFDC size of a pointer + /// + template<typename T> + inline uint16_t getErrorInfoFfdcSize(const T*) + { + static_assert(std::is_pointer<T>::value, + "pointer passed to getErrorInfoFfdcSize"); + return 0; + } + + /// + /// @brief Get FFDC Size specialization for fapi2::Target + /// + template<fapi2::TargetType T> + inline uint16_t getErrorInfoFfdcSize(const fapi2::Target<T>&) + { + return EI_FFDC_SIZE_TARGET; + } + + /// + /// @brief Get FFDC Size specialization for variable buffers + /// + template<> + inline uint16_t getErrorInfoFfdcSize(const fapi2::variable_buffer& i_thing) + { + // Limit a variable buffer to 4kb bytes, and we can memcpy the storage. + return std::min(static_cast<uint32_t>(EI_FFDC_MAX_SIZE), + i_thing.getLength<uint8_t>()); + } + +} + +#endif // FAPI2_ERRORINFO_DEFS_H_ diff --git a/import/hwpf/fapi2/include/return_code.H b/import/hwpf/fapi2/include/return_code.H index 32e4af19..2d84ba12 100644 --- a/import/hwpf/fapi2/include/return_code.H +++ b/import/hwpf/fapi2/include/return_code.H @@ -36,84 +36,9 @@ #include <ffdc.H> #endif -/// -/// @brief Set HWP Error macro -/// -/// This macro should be used by a HWP to create an error. The ReturnCode's -/// internal return code is set and any error information in the Error XML file -/// is added to the ReturnCode -/// -#define FAPI_SET_HWP_ERROR(RC, ERROR) \ - RC._setHwpError(fapi2::ERROR); \ - ERROR##_CALL_FUNCS_TO_COLLECT_FFDC(RC); \ - ERROR##_CALL_FUNCS_TO_COLLECT_REG_FFDC(RC); \ - ERROR##_ADD_ERROR_INFO(RC) - -/// -/// @brief Add info to HWP Error macro -/// -/// This macro should be used by an FFDC HWP to add error information from an -/// Error XML file to an existing error. -/// -#define FAPI_ADD_INFO_TO_HWP_ERROR(RC, ERROR) \ - ERROR##_CALL_FUNCS_TO_COLLECT_FFDC(RC); \ - ERROR##_CALL_FUNCS_TO_COLLECT_REG_FFDC(RC); \ - ERROR##_ADD_ERROR_INFO(RC) - namespace fapi2 { /// - /// @brief Enumeration of return codes - /// - enum ReturnCodes - { - ///< Success - FAPI2_RC_SUCCESS = 0, - - // Flag bits indicating which code generated the error. - FAPI2_RC_FAPI2_MASK = 0x04000000, ///< FAPI2 mask - FAPI2_RC_PLAT_MASK = 0x02000000, ///< Platform mask - FAPI2_RC_HWP_MASK = 0x00000000, ///< HWP mask - - // - // FAPI generated return codes - // - - FAPI2_RC_INVALID_ATTR_GET = FAPI2_RC_FAPI2_MASK | 0x01, - ///< Initfile requested an attribute with an invalid attribute ID - - FAPI2_RC_INVALID_CHIP_EC_FEATURE_GET = FAPI2_RC_FAPI2_MASK | 0x02, - ///< HWP requested a chip EC feature with an invalid attribute ID - - FAPI2_RC_INVALID_MULTISCOM_LENGTH = FAPI2_RC_FAPI2_MASK | 0x03, - ///< Invalid multiscom parameters - - FAPI2_RC_INVALID_PARAMETER = FAPI2_RC_FAPI2_MASK | 0x04, - ///< Invalid parameters to a FAPI2 function - - FAPI2_RC_OVERFLOW = FAPI2_RC_FAPI2_MASK | 0x05, - ///< Overflow condition, typically a buffer operation - - FAPI2_RC_FALSE = FAPI2_RC_FAPI2_MASK | 0x06, - ///< The logical opposite of SUCCESS. Needed where procedures want - ///< a multi-bool type of operation (e.g., true, false, scom error) - - // - // PLAT generated return codes. Additional details may be contained in - // ReturnCode platData (this can only be looked at by PLAT code) - // - - FAPI2_RC_PLAT_ERR_SEE_DATA = FAPI2_RC_PLAT_MASK | 0x01, - ///< Generic platform error - - FAPI2_RC_PLAT_ERR_ADU_LOCKED = FAPI2_RC_PLAT_MASK | 0x02, - ///< Operation to AlterDisplay unit failed because it is locked - - FAPI2_RC_PLAT_NOT_SUPPORTED_AT_RUNTIME = FAPI2_RC_PLAT_MASK | 0x03, - ///< Operation not supported by HB runtime - }; - - /// /// @brief Class representing a FAPI2 ReturnCode /// // Remove the inheritance relationship with FirstFailureData if @@ -176,7 +101,6 @@ namespace fapi2 extern thread_local ReturnCode current_err; /// the current error state extern thread_local uint64_t pib_error_mask; /// the pib mask extern thread_local uint64_t operational_state; /// the operational mode - } #endif diff --git a/import/hwpf/fapi2/include/return_code_defs.H b/import/hwpf/fapi2/include/return_code_defs.H new file mode 100644 index 00000000..404bfafa --- /dev/null +++ b/import/hwpf/fapi2/include/return_code_defs.H @@ -0,0 +1,114 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2012,2014 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +/** + * @file return_code.H + * @brief definitions for fapi2 return codes + */ + +#ifndef __FAPI2_RETURN_CODE_DEFS_ +#define __FAPI2_RETURN_CODE_DEFS_ + +#include <stdint.h> + +/// +/// @brief Set HWP Error macro +/// +/// This macro should be used by a HWP to create an error. The ReturnCode's +/// internal return code is set and any error information in the Error XML file +/// is added to the ReturnCode +/// +#define FAPI_SET_HWP_ERROR(RC, ERROR) \ + RC._setHwpError(fapi2::ERROR); \ + ERROR##_CALL_FUNCS_TO_COLLECT_FFDC(RC); \ + ERROR##_CALL_FUNCS_TO_COLLECT_REG_FFDC(RC); \ + ERROR##_ADD_ERROR_INFO(RC) + +/// +/// @brief Add info to HWP Error macro +/// +/// This macro should be used by an FFDC HWP to add error information from an +/// Error XML file to an existing error. +/// +#define FAPI_ADD_INFO_TO_HWP_ERROR(RC, ERROR) \ + ERROR##_CALL_FUNCS_TO_COLLECT_FFDC(RC); \ + ERROR##_CALL_FUNCS_TO_COLLECT_REG_FFDC(RC); \ + ERROR##_ADD_ERROR_INFO(RC) + +namespace fapi2 +{ + /// + /// @brief Enumeration of return codes + /// + enum ReturnCodes + { + ///< Success + FAPI2_RC_SUCCESS = 0, + + // Flag bits indicating which code generated the error. + FAPI2_RC_FAPI2_MASK = 0x04000000, ///< FAPI2 mask + FAPI2_RC_PLAT_MASK = 0x02000000, ///< Platform mask + FAPI2_RC_HWP_MASK = 0x00000000, ///< HWP mask + + // + // FAPI generated return codes + // + + FAPI2_RC_INVALID_ATTR_GET = FAPI2_RC_FAPI2_MASK | 0x01, + ///< Initfile requested an attribute with an invalid attribute ID + + FAPI2_RC_INVALID_CHIP_EC_FEATURE_GET = FAPI2_RC_FAPI2_MASK | 0x02, + ///< HWP requested a chip EC feature with an invalid attribute ID + + FAPI2_RC_INVALID_MULTISCOM_LENGTH = FAPI2_RC_FAPI2_MASK | 0x03, + ///< Invalid multiscom parameters + + FAPI2_RC_INVALID_PARAMETER = FAPI2_RC_FAPI2_MASK | 0x04, + ///< Invalid parameters to a FAPI2 function + + FAPI2_RC_OVERFLOW = FAPI2_RC_FAPI2_MASK | 0x05, + ///< Overflow condition, typically a buffer operation + + FAPI2_RC_FALSE = FAPI2_RC_FAPI2_MASK | 0x06, + ///< The logical opposite of SUCCESS. Needed where procedures want + ///< a multi-bool type of operation (e.g., true, false, scom error) + + // + // PLAT generated return codes. Additional details may be contained in + // ReturnCode platData (this can only be looked at by PLAT code) + // + + FAPI2_RC_PLAT_ERR_SEE_DATA = FAPI2_RC_PLAT_MASK | 0x01, + ///< Generic platform error + + FAPI2_RC_PLAT_ERR_ADU_LOCKED = FAPI2_RC_PLAT_MASK | 0x02, + ///< Operation to AlterDisplay unit failed because it is locked + + FAPI2_RC_PLAT_NOT_SUPPORTED_AT_RUNTIME = FAPI2_RC_PLAT_MASK | 0x03, + ///< Operation not supported by HB runtime + }; + +} + +#endif diff --git a/import/hwpf/fapi2/include/utils.H b/import/hwpf/fapi2/include/utils.H index 67ad99b3..85f334b9 100644 --- a/import/hwpf/fapi2/include/utils.H +++ b/import/hwpf/fapi2/include/utils.H @@ -32,7 +32,7 @@ #include <stdint.h> #include <return_code.H> -#include <error_info.H> +#include <error_info_defs.H> namespace fapi2 { diff --git a/import/hwpf/fapi2/include/variable_buffer.H b/import/hwpf/fapi2/include/variable_buffer.H index b773a924..20ba15d9 100644 --- a/import/hwpf/fapi2/include/variable_buffer.H +++ b/import/hwpf/fapi2/include/variable_buffer.H @@ -32,7 +32,7 @@ #include <buffer_parameters.H> #include <buffer_traits.H> -#include <return_code.H> +#include <return_code_defs.H> namespace fapi2 { @@ -76,7 +76,7 @@ namespace fapi2 /// @param[in] i_length The length, in bits, the user wants copied. /// template<typename unit_type, typename bits_type, typename output_type> - inline fapi2::ReturnCode _insert(const unit_type* i_source, + inline fapi2::ReturnCodes _insert(const unit_type* i_source, bits_type i_source_length, output_type* i_target, bits_type i_target_length, @@ -287,7 +287,7 @@ namespace fapi2 /// variable_buffer into a variable_buffer, use insert() /// template< typename OT> - inline fapi2::ReturnCode set(OT i_value, const bits_type i_offset = 0) + inline fapi2::ReturnCodes set(OT i_value, const bits_type i_offset = 0) { // Compile time check to make sure OT is integral static_assert( std::is_integral<OT>::value, @@ -344,7 +344,7 @@ namespace fapi2 /// @note 0 is left-most /// @return FAPI2_RC_SUCCESS if OK /// - inline fapi2::ReturnCode setBit(const bits_type& i_bit) + inline fapi2::ReturnCodes setBit(const bits_type& i_bit) { const bits_type index = i_bit / bits_per_unit; @@ -371,7 +371,7 @@ namespace fapi2 /// the case we can add a function parameter version. /// template< bits_type SB, bits_type L > - inline fapi2::ReturnCode clearBit(void); + inline fapi2::ReturnCodes clearBit(void); /// /// @brief Invert bit @@ -384,7 +384,7 @@ namespace fapi2 /// the case we can add a function parameter version. /// template< bits_type SB, bits_type L = 1 > - inline fapi2::ReturnCode flipBit(void); + inline fapi2::ReturnCodes flipBit(void); /// /// @brief Get the value of a bit in the buffer @@ -618,7 +618,7 @@ namespace fapi2 /// @return FAPI2_RC_SUCCESS on success, FAPi2_RC_OVERFLOW otherwise /// template<typename OT> - inline fapi2::ReturnCode insert(const OT& i_data, + inline fapi2::ReturnCodes insert(const OT& i_data, bits_type i_targetStart = 0, bits_type i_len = ~0, bits_type i_sourceStart = 0) @@ -645,7 +645,7 @@ namespace fapi2 /// @return FAPI2_RC_SUCCESS on success, FAPI2_RC_OVERFLOW otherwise /// template<typename OT> - inline fapi2::ReturnCode insertFromRight(const OT& i_data, + inline fapi2::ReturnCodes insertFromRight(const OT& i_data, bits_type i_targetStart = 0, bits_type i_len = ~0) { @@ -663,7 +663,7 @@ namespace fapi2 /// // Generic extract. Extract is an insert with the arguments reversed. template< typename OT > - inline fapi2::ReturnCode extract(OT& o_out, + inline fapi2::ReturnCodes extract(OT& o_out, bits_type i_start = 0, bits_type i_len = ~0) const { @@ -678,7 +678,7 @@ namespace fapi2 // _insert likes 32-bit targets. So lets make our target 32 bits. uint32_t l_data = static_cast<uint32_t>(o_out); - ReturnCode rc; + ReturnCodes rc; if ((rc = _insert((container_unit*)&iv_data[0], getBitLength(), &l_data, parameterTraits<uint32_t>::bit_length(), @@ -703,7 +703,7 @@ namespace fapi2 /// // Extract is an insert with the arguments reversed. template< typename OT > - inline fapi2::ReturnCode extractToRight(OT& o_out, + inline fapi2::ReturnCodes extractToRight(OT& o_out, bits_type i_start = 0, bits_type i_len = ~0) const { @@ -719,7 +719,7 @@ namespace fapi2 // _insert likes 32-bit targets. So lets make our target 32 bits. uint32_t l_data = static_cast<uint32_t>(o_out); - ReturnCode rc; + ReturnCodes rc; if ((rc = _insert( reinterpret_cast<const container_unit*>(&iv_data[0]), getBitLength(), @@ -782,7 +782,7 @@ namespace fapi2 /// @param[in] i_length The length, in bits, the user wants copied. /// template<typename OT> - inline fapi2::ReturnCode _insertFromRight(const OT& i_data, + inline fapi2::ReturnCodes _insertFromRight(const OT& i_data, bits_type i_data_length, bits_type i_targetStart, bits_type i_len) @@ -805,7 +805,7 @@ namespace fapi2 // If the source is 64-bits, treat that as 2x32 template<> - inline fapi2::ReturnCode variable_buffer::insert(const uint64_t& i_source, + inline fapi2::ReturnCodes variable_buffer::insert(const uint64_t& i_source, bits_type i_targetStart, bits_type i_len, bits_type i_sourceStart) @@ -824,7 +824,7 @@ namespace fapi2 // Insert another variable_bufer template<> - inline fapi2::ReturnCode variable_buffer::insert( + inline fapi2::ReturnCodes variable_buffer::insert( const variable_buffer& i_data, bits_type i_targetStart, bits_type i_len, @@ -838,7 +838,7 @@ namespace fapi2 // variable_buffer insert from right template<> - inline fapi2::ReturnCode variable_buffer::insertFromRight( + inline fapi2::ReturnCodes variable_buffer::insertFromRight( const variable_buffer& i_data, bits_type i_targetStart, bits_type i_len) @@ -849,7 +849,7 @@ namespace fapi2 } template<> - inline fapi2::ReturnCode variable_buffer::extract( + inline fapi2::ReturnCodes variable_buffer::extract( uint64_t& i_data, bits_type i_start, bits_type i_len) const @@ -870,7 +870,7 @@ namespace fapi2 {static_cast<uint32_t>((i_data & 0xFFFFFFFF00000000) >> 32), static_cast<uint32_t>((i_data & 0x00000000FFFFFFFF))}; - ReturnCode rc; + ReturnCodes rc; if ((rc = _insert((container_unit*)&iv_data[0], getBitLength(), l_data, parameterTraits<uint64_t>::bit_length(), i_start, 0U, i_len)) != FAPI2_RC_SUCCESS) @@ -886,7 +886,7 @@ namespace fapi2 // Extract in to another variable_bufer template<> - inline fapi2::ReturnCode variable_buffer::extract( + inline fapi2::ReturnCodes variable_buffer::extract( variable_buffer& i_data, bits_type i_start, bits_type i_len) const @@ -905,7 +905,7 @@ namespace fapi2 } template<> - inline fapi2::ReturnCode variable_buffer::extractToRight( + inline fapi2::ReturnCodes variable_buffer::extractToRight( uint64_t& i_data, bits_type i_start, bits_type i_len) const @@ -925,7 +925,7 @@ namespace fapi2 {static_cast<uint32_t>((i_data & 0xFFFFFFFF00000000) >> 32), static_cast<uint32_t>((i_data & 0x00000000FFFFFFFF))}; - ReturnCode rc; + ReturnCodes rc; if ((rc = _insert( reinterpret_cast<const container_unit*>(&iv_data[0]), getBitLength(), |