summaryrefslogtreecommitdiffstats
path: root/sbe/hwpf
diff options
context:
space:
mode:
authorGreg Still <stillgs@us.ibm.com>2015-10-13 20:54:36 -0500
committerMartin Peschke <mpeschke@de.ibm.com>2015-10-21 07:20:47 -0500
commit82fc55596dd107514bc3dea1b8be3c23b653c76a (patch)
tree7375f72411c9ff16775d145ce7ea727fbde46806 /sbe/hwpf
parent43aaa85b59ba06dce6e0f7063234235384e31135 (diff)
downloadtalos-sbe-82fc55596dd107514bc3dea1b8be3c23b653c76a.tar.gz
talos-sbe-82fc55596dd107514bc3dea1b8be3c23b653c76a.zip
Rearrange PPE FAPI2 directory structure to be more in-line with HWPF
- Move files into new structure - Delete old, obsolete files and directories - Pre-import mirror of HWPF into importtemp - No additional function Change-Id: Iadad6eb05349f807acea362ec77d7f58273878b5 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/21150 Tested-by: Jenkins Server Reviewed-by: Santosh S. Puranik <santosh.puranik@in.ibm.com> Reviewed-by: Sachin Gupta <sgupta2m@in.ibm.com> Reviewed-by: Martin Peschke <mpeschke@de.ibm.com>
Diffstat (limited to 'sbe/hwpf')
-rw-r--r--sbe/hwpf/include/README9
-rw-r--r--sbe/hwpf/include/fapi2_hw_access.H464
-rw-r--r--sbe/hwpf/include/hw_access.H619
-rw-r--r--sbe/hwpf/include/plat/plat_error_scope.H71
-rw-r--r--sbe/hwpf/include/plat/plat_hw_access.H70
-rw-r--r--sbe/hwpf/src/Makefile32
-rw-r--r--sbe/hwpf/src/fapi2sbefiles.mk25
-rw-r--r--sbe/hwpf/src/return_code.C47
8 files changed, 1337 insertions, 0 deletions
diff --git a/sbe/hwpf/include/README b/sbe/hwpf/include/README
new file mode 100644
index 00000000..4637505d
--- /dev/null
+++ b/sbe/hwpf/include/README
@@ -0,0 +1,9 @@
+fapi2_hw_access.H is placed here to restore the return code get/putScom APIs
+while allowing PPE Plat include directory to be before the Base HWPF in the
+include path.
+
+1. SBE PLAT (return codes)
+2, PPE PLAT (no return codes) used by SGPE/PGPE/CME
+3. Base HWPF (return codes)
+
+This is a dual maintenance issue that should be reconsidered in the future.
diff --git a/sbe/hwpf/include/fapi2_hw_access.H b/sbe/hwpf/include/fapi2_hw_access.H
new file mode 100644
index 00000000..fca775b1
--- /dev/null
+++ b/sbe/hwpf/include/fapi2_hw_access.H
@@ -0,0 +1,464 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2012,2014 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+///
+/// @file fapi2_hw_access.H
+/// @brief Common file that defines the hardware access functions that
+/// platform code must implement.
+///
+
+#ifndef _FAPI2_COMMON_HWACCESS_H_
+#define _FAPI2_COMMON_HWACCESS_H_
+
+#ifdef FAPI_SUPPORT_SPY_AS_ENUM
+#include <spy_ids.H>
+typedef uint64_t spyId_t;
+#endif
+
+#include <stdint.h>
+#include <thread>
+#include <buffer.H>
+
+// variable_buffer isn't supported on PPE
+#ifndef __PPE__
+#include <variable_buffer.H>
+#endif
+
+#include <return_code.H>
+#include <target.H>
+#include <hw_access_def.H>
+#include <plat_hw_access.H>
+
+#ifdef FAPI_SUPPORT_MULTI_SCOM
+#include <multi_scom.H>
+#endif
+
+namespace fapi2
+{
+ //--------------------------------------------------------------------------
+ // PIB Error Functions
+ //--------------------------------------------------------------------------
+
+ /// @brief Sets the PIB error mask - platform dependant
+ /// @param[in] i_mask The new error mask
+ inline void setPIBErrorMask(uint8_t i_mask);
+
+ /// @brief Gets the PIB error mask - platform dependant
+ /// @return uint8_t The current PIB error mask
+ inline uint8_t getPIBErrorMask(void);
+
+ //--------------------------------------------------------------------------
+ // Operational Mode Error Functions
+ //--------------------------------------------------------------------------
+
+ /// @brief Sets the operational mode
+ /// @param[in] i_mode The new mode
+ inline void setOpMode(const OpModes i_mode);
+
+ /// @brief Gets the operational mode
+ /// @return the operational mode
+ inline OpModes getOpMode(void);
+
+ //--------------------------------------------------------------------------
+ // HW Communication Functions
+ //--------------------------------------------------------------------------
+
+ /// @brief Reads a SCOM register from a chip.
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target HW target to operate on.
+ /// @param[in] i_address SCOM register address to read from.
+ /// @param[out] o_data Buffer that holds data read from HW target.
+ /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ template< TargetType K >
+ inline ReturnCode getScom(const Target<K>& i_target, const uint64_t i_address,
+ buffer<uint64_t>& o_data);
+
+ /// @brief Writes a SCOM register on a chip.
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target HW target to operate on.
+ /// @param[in] i_address SCOM register address to write to.
+ /// @param[in] i_data Buffer that holds data to write into address.
+ /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ template< TargetType K >
+ inline ReturnCode putScom(const Target<K>& i_target, const uint64_t i_address,
+ const buffer<uint64_t> i_data);
+
+ /// @brief Writes a SCOM register under mask on a chip
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target HW target to operate on.
+ /// @param[in] i_address SCOM register address to write to.
+ /// @param[in] i_data Buffer that holds data to write into address.
+ /// @param[in] i_mask Buffer that holds the mask value.
+ /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ template< TargetType K >
+ inline ReturnCode putScomUnderMask(const Target<K>& i_target,
+ const uint64_t i_address,
+ const buffer<uint64_t> i_data,
+ const buffer<uint64_t> i_mask);
+
+ /// @brief Reads a CFAM register from a chip.
+ /// CFAM register is 32-bit wide.
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target HW target to operate on.
+ /// @param[in] i_address CFAM register address to read from.
+ /// @param[out] o_data Buffer that holds data read from HW target.
+ /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ template< TargetType K >
+ inline ReturnCode getCfamRegister(const Target<K>& i_target,
+ const uint32_t i_address,
+ buffer<uint32_t>& o_data);
+
+ /// @brief Writes a CFAM register on a chip.
+ /// CFAM register is 32-bit wide.
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target HW target to operate on.
+ /// @param[in] i_address CFAM register address to write to.
+ /// @param[in] i_data Buffer that holds data to write into address.
+ /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ template< TargetType K >
+ inline ReturnCode putCfamRegister(const Target<K>& i_target,
+ const uint32_t i_address,
+ const buffer<uint32_t> i_data);
+
+ /// @brief Read-modify-write a CFAM register on a chip.
+ /// CFAM register is 32-bit wide.
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target HW target to operate on.
+ /// @param[in] i_address CFAM register address to modify.
+ /// @param[in] i_data Buffer that holds data to be modified.
+ /// @param[in] i_modifyMode The modify mode (or/and/xor).
+ /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ template< TargetType K >
+ inline ReturnCode modifyCfamRegister(const Target<K>& i_target,
+ const uint32_t i_address,
+ const buffer<uint32_t> i_data,
+ const ChipOpModifyMode i_modifyMode);
+
+ // variable_buffer isn't supported on PPE
+#ifndef __PPE__
+ /// @brief Reads a ring from a chip.
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target Target to operate on.
+ /// @param[in] i_address Ring address to read from.
+ /// @param[out] o_data Buffer that holds data read from HW target.
+ /// @param[in] i_ringMode Ring operation mode.
+ /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ template< TargetType K >
+ inline ReturnCode getRing(const Target<K>& i_target,
+ const scanRingId_t i_address,
+ variable_buffer& o_data,
+ const RingMode i_ringMode = 0);
+
+ /// @brief Writes a ring to a chip.
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target Target to operate on.
+ /// @param[in] i_address Ring address to write to.
+ /// @param[in] i_data Buffer that contains RS4 compressed ring data
+ /// to write into address
+ /// @param[in] i_ringMode Ring operation mode.
+ /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ template< TargetType K >
+ inline ReturnCode putRing(const Target<K>& i_target,
+ const scanRingId_t i_address,
+ const variable_buffer& i_data,
+ const RingMode i_ringMode = 0);
+
+
+ /// @brief Read-modify-write a ring on a chip.
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target Target to operate on.
+ /// @param[in] i_address Ring address to modify.
+ /// @param[in] i_data Buffer that contains RS4 compressed ring data
+ /// to be modified.
+ /// @param[in] i_modifyMode The modify mode (or/and/xor)
+ /// @param[in] i_ringMode Ring operation mode.
+ /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ template< TargetType K >
+ inline ReturnCode modifyRing(const Target<K>& i_target,
+ const scanRingId_t i_address,
+ const variable_buffer& i_data,
+ const ChipOpModifyMode i_modifyMode,
+ const RingMode i_ringMode = 0);
+#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:
+ // Implement platform Spy access functions if platform supports them.
+ // --------------------------------------------------------------------------
+
+ // variable_buffer isn't supported on PPE
+#ifndef __PPE__
+ /// @brief Reads a spy from a chip.
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target Target to operate on.
+ /// @param[in] i_spyId Id of the spy whose data to be read.
+ /// @param[out] o_data Buffer that holds data read from HW target.
+ /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ ///
+ /// @note: The string version is only supported for cronus.
+ ///
+ /// The fapi design to support both FSP and cronus use of get and
+ /// put spy functions is dependant on the SPY names being expanded
+ /// to resemble a valid C identifier. This design places some
+ /// restrictions on the SPY names which can be used.
+ ///
+ /// 1. if the spy name contains a # procedure writers should replace
+ /// it with an __P__ for example -
+ ///
+ /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS
+ /// becomes
+ /// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS
+ ///
+ /// 2. if the spy name has a number following a "." it must have an
+ /// underscore prepended to the number.
+ ///
+ /// EH.TPCHIP.2KX100_ARY_CLK_EDGES_DLY
+ /// becomes
+ /// EH.TPCHIP._2KX100_ARY_CLK_EDGES_DLY
+ ///
+ /// Example SPY name:
+ /// The hardware procedure should call the function like:
+ ///
+ /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS
+ ///
+ /// fapi2::ReturnCode rc = fapiGetSpy( targ,
+ /// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS, data );
+ ///
+ /// @note The ID is not in quotes the fapi code will handle adding
+ /// the quotes for the cronus environment
+#if defined(FAPI_SUPPORT_SPY_AS_ENUM) || defined(DOXYGEN)
+
+#define FAPI_GET_SPY(TARGET, ID, DATA) fapi2::getSpy(TARGET, FAPI_SPY_NAMES::ID.value, DATA)
+
+ template< TargetType K >
+ inline ReturnCode getSpy(const Target<K>& i_target,
+ const spyId_t i_spyId,
+ variable_buffer& o_data);
+#endif
+
+#if defined(FAPI_SUPPORT_SPY_AS_STRING) || defined(DOXYGEN)
+
+#define FAPI_GET_SPY(TARGET, ID, DATA) fapi2::getSpy(TARGET, #ID, DATA)
+
+ template< TargetType K >
+ inline ReturnCode getSpy(const Target<K>& i_target,
+ const char * const i_spyId,
+ variable_buffer& o_data);
+#endif
+
+ /// @brief Writes a spy on a chip.
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target Target to operate on.
+ /// @param[in] i_spyId Id of the spy to write data to.
+ /// @param[out] i_data Buffer that holds data to write into spy.
+ /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ ///
+ /// @note: The string version is only supported for cronus.
+ ///
+ /// The fapi design to support both FSP and cronus use of get and
+ /// put spy functions is dependent on the SPY names being expanded
+ /// to resemble a valid C identifier. This design places some
+ /// restrictions on the SPY names which can be used.
+ ///
+ /// 1. if the spy name contains a # procedure writers should replace
+ /// is with an __P__ for example -
+ ///
+ /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS
+ /// becomes
+ /// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS
+ ///
+ /// 2. if the spy name has a number following a "." it must have an
+ /// underscore prepended to the number.
+ ///
+ /// EH.TPCHIP.2KX100_ARY_CLK_EDGES_DLY
+ /// becomes
+ /// EH.TPCHIP._2KX100_ARY_CLK_EDGES_DLY
+ ///
+ /// Example SPY name:
+ /// The hardware procedure should call the function like:
+ ///
+ /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS
+ ///
+ /// fapi2::ReturnCode rc = fapiPutSpy( targ,
+ /// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS, data );
+ ///
+ /// @note The ID is not in quotes the fapi code will handle adding
+ /// the quotes for the cronus environment
+ ///
+#if defined(FAPI_SUPPORT_SPY_AS_ENUM) || defined(DOXYGEN)
+
+#define FAPI_PUT_SPY(TARGET, ID, DATA) fapi2::putSpy(TARGET, FAPI_SPY_NAMES::ID.value, DATA)
+
+ template< TargetType K >
+ inline ReturnCode putSpy(const Target<K>& i_target,
+ const spyId_t i_spyId,
+ variable_buffer& i_data);
+#endif
+
+#if defined(FAPI_SUPPORT_SPY_AS_STRING) || defined(DOXYGEN)
+
+#define FAPI_PUT_SPY(TARGET, ID, DATA) fapi2::putSpy(TARGET, #ID, DATA)
+
+ template< TargetType K >
+ inline ReturnCode putSpy(const Target<K>& i_target,
+ const char* const i_spyId,
+ variable_buffer& i_data);
+#endif
+
+ /// @brief Writes spy data into a buffer holding ring data image
+ /// This API is used by L2/L3 repair to put column repair data
+ /// into a ring buffer image.
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target Target to operate on.
+ /// @param[in] i_spyId Id of the spy.
+ /// @param[in] i_data Buffer that holds spy data to write into ring
+ /// image.
+ /// @param[out] o_data Buffer that holds updated ring image.
+ /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ ///
+ /// @note: The string version is only supported for cronus.
+ ///
+ /// The fapi design to support both FSP and cronus use of get and
+ /// put spy functions is dependent on the SPY names being expanded
+ /// to resemble a valid C identifier. This design places some
+ /// restrictions on the SPY names which can be used.
+ ///
+ /// See fapiPutSpy for details on spy id specifics.
+ ///
+#if defined(FAPI_SUPPORT_SPY_AS_ENUM) || defined(DOXYGEN)
+
+#define FAPI_PUT_SPY_IMAGE(TARGET, ID, DATA1, DATA2) \
+ fapi2::putSpyImage(TARGET, FAPI_SPY_NAMES::ID.value, \
+ DATA1, DATA2)
+
+ template< TargetType K >
+ inline ReturnCode putSpyImage(const Target<K>& i_target,
+ const spyId_t i_spyId,
+ const variable_buffer& i_data,
+ variable_buffer& o_imageData);
+#endif
+
+#if defined(FAPI_SUPPORT_SPY_AS_STRING) || defined(DOXYGEN)
+
+#define FAPI_PUT_SPY_IMAGE(TARGET, ID, DATA1, DATA2) \
+ fapi2::putSpyImage(TARGET, #ID, DATA1,DATA2)
+
+ template< TargetType K >
+ inline ReturnCode putSpyImage(const Target<K>& i_target,
+ const char* const i_spyId,
+ const variable_buffer& i_data,
+ variable_buffer& o_imageData);
+#endif
+
+ /// @brief Reads spy data from a ring image buffer
+ /// @param[in] i_target Target to operate on
+ /// @param[in] i_spyId The spy's id
+ /// @param[out] o_data Buffer that holds data read from ring image.
+ /// @param[in] i_imageData Buffer that holds ring image to read data
+ /// from.
+ /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ ///
+ /// @note: The string version is only supported for cronus.
+ ///
+ /// The fapi design to support both FSP and cronus use of get and
+ /// put spy functions is dependent on the SPY names being expanded
+ /// to resemble a valid C identifier. This design places some
+ /// restrictions on the SPY names which can be used.
+ ///
+ /// See fapiPutSpy for details on spy id specifics.
+ ///
+#if defined(FAPI_SUPPORT_SPY_AS_ENUM) || defined(DOXYGEN)
+
+#define FAPI_GET_SPY_IMAGE(TARGET, ID, DATA1, DATA2) \
+ fapi2:getSpyImage(TARGET, FAPI_SPY_NAMES::ID.value, \
+ DATA1, DATA2)
+
+ template< TargetType K >
+ inline ReturnCode getSpyImage(const Target<K>& i_target,
+ const spyId_t i_spyId,
+ variable_buffer& o_data,
+ const variable_buffer& i_imageData);
+#endif
+
+#if defined(FAPI_SUPPORT_SPY_AS_STRING) || defined(DOXYGEN)
+
+#define FAPI_GET_SPY_IMAGE(TARGET, ID, DATA1, DATA2) \
+ fapi2::getSpyImage(TARGET, #ID, DATA1,DATA2)
+
+ template< TargetType K >
+ inline ReturnCode getSpyImage(const Target<K>& i_target,
+ const char * const i_spyId,
+ variable_buffer& o_data,
+ const variable_buffer& i_imageData);
+#endif
+
+#endif // PPE
+};
+
+#endif // _FAPI2_HWACCESS_H_
diff --git a/sbe/hwpf/include/hw_access.H b/sbe/hwpf/include/hw_access.H
new file mode 100644
index 00000000..af688421
--- /dev/null
+++ b/sbe/hwpf/include/hw_access.H
@@ -0,0 +1,619 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2012,2014 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+/**
+ * @file hw_access.H
+ *
+* @brief Defines the hardware access functions that platform code must
+ * implement.
+ */
+
+#ifndef FAPI2_HWACCESS_H_
+#define FAPI2_HWACCESS_H_
+
+
+// variable_buffer isn't supported on PPE
+#ifndef __PPE__
+#include <variable_buffer.H>
+#endif
+
+#include <utils.H>
+#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
+ void setPIBErrorMask(uint8_t i_mask)
+ {
+ PLAT_SET_PIB_ERROR_MASK(i_mask);
+ }
+
+ /// @brief Gets the PIB error mask - platform dependant
+ /// @return uint8_t The current PIB error mask
+ uint8_t getPIBErrorMask(void)
+ {
+ PLAT_GET_PIB_ERROR_MASK(o_pib_mask);
+ return o_pib_mask;
+ }
+
+ //--------------------------------------------------------------------------
+ // Operational Mode Error Functions
+ //--------------------------------------------------------------------------
+
+ /// @brief Sets the operational mode
+ /// @param[in] i_mode The new mode
+ // note: this can be moved to a C file if desired
+ inline void setOpMode(const OpModes i_mode)
+ {
+ // Keeps the compiler from complaining about the unused i_mode
+ static_cast<void>(i_mode);
+
+ // No-op for now. Should set thread-local operational mode
+ return;
+ }
+
+ /// @brief Gets the operational mode
+ /// @return the operational mode
+ // note: this can be moved to a C file if desired
+ inline OpModes getOpMode(void)
+ {
+ // No-op for now. Should read thread-local operational mode
+ return NORMAL;
+ }
+
+ //--------------------------------------------------------------------------
+ // HW Communication Functions
+ //--------------------------------------------------------------------------
+
+ /// @brief Reads a SCOM register from a chip.
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target HW target to operate on.
+ /// @param[in] i_address SCOM register address to read from.
+ /// @param[out] o_data Buffer that holds data read from HW target.
+ /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ template< TargetType K >
+ inline ReturnCode getScom(const Target<K>& i_target, const uint64_t i_address,
+ buffer<uint64_t>& o_data)
+ {
+ fapi2::ReturnCode l_rc;
+ PLAT_GETSCOM(l_rc,
+ i_target,
+ i_address,
+ &(o_data()));
+
+ return l_rc;
+ }
+
+ /// @brief Writes a SCOM register on a chip.
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target HW target to operate on.
+ /// @param[in] i_address SCOM register address to write to.
+ /// @param[in] i_data Buffer that holds data to write into address.
+ /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ template< TargetType K >
+ inline ReturnCode putScom(const Target<K>& i_target, const uint64_t i_address,
+ const buffer<uint64_t> i_data)
+ {
+ fapi2::ReturnCode l_rc;
+ PLAT_PUTSCOM(l_rc,
+ i_target,
+ i_address,
+ i_data());
+
+ return l_rc;
+ }
+
+ /// @brief Read-modify-write a SCOM register on a chip
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target HW target to operate on.
+ /// @param[in] i_address SCOM register address to write to.
+ /// @param[in] i_data Buffer that holds data to be modified.
+ /// @param[in] i_modifyMode The modify mode (or/and/xor).
+ /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ template< TargetType K >
+ inline ReturnCode modifyScom(const Target<K>& i_target,
+ const uint64_t i_address,
+ const buffer<uint64_t> i_data,
+ const ChipOpModifyMode i_modifyMode)
+ {
+ fapi2::buffer<uint64_t> l_modifyDataBuffer;
+
+ fapi2::ReturnCode l_rc;
+ PLAT_GETSCOM(l_rc,
+ i_target,
+ (uint32_t)(i_address & BITS(40,24)),
+ &(l_modifyDataBuffer()));
+ if (l_rc) goto __fapi2exit__;
+
+ if ( i_modifyMode == CHIP_OP_MODIFY_MODE_OR)
+ {
+ l_modifyDataBuffer |= i_data;
+ }
+
+ if ( i_modifyMode == CHIP_OP_MODIFY_MODE_AND)
+ {
+ l_modifyDataBuffer &= i_data;
+ }
+
+ if ( i_modifyMode == CHIP_OP_MODIFY_MODE_XOR)
+ {
+ l_modifyDataBuffer ^= i_data;
+ }
+
+ PLAT_PUTSCOM(l_rc,
+ i_target,
+ (uint32_t)(i_address & BITS(40,24)),
+ l_modifyDataBuffer());
+ if (l_rc) goto __fapi2exit__;
+
+
+__fapi2exit__:
+ return l_rc;
+
+ }
+
+ /// @brief Writes a SCOM register under mask on a chip
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target HW target to operate on.
+ /// @param[in] i_address SCOM register address to write to.
+ /// @param[in] i_data Buffer that holds data to write into address.
+ /// @param[in] i_mask Buffer that holds the mask value.
+ /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ template< TargetType K >
+ inline ReturnCode putScomUnderMask( const Target<K>& i_target,
+ const uint64_t i_address,
+ buffer<uint64_t> i_data,
+ buffer<uint64_t> i_mask)
+ {
+ fapi2::buffer<uint64_t> l_modifyDataBuffer = i_data;
+
+ l_modifyDataBuffer &= i_mask;
+
+ fapi2::ReturnCode l_rc;
+ PLAT_PUTSCOM(l_rc,
+ i_target,
+ (uint32_t)(i_address & BITS(40,24)),
+ l_modifyDataBuffer());
+
+ return l_rc;
+
+ }
+
+
+ /// @brief Reads a CFAM register from a chip.
+ /// CFAM register is 32-bit wide.
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target HW target to operate on.
+ /// @param[in] i_address CFAM register address to read from.
+ /// @param[out] o_data Buffer that holds data read from HW target.
+ /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ template< TargetType K >
+ inline ReturnCode getCfamRegister(const Target<K>& i_target,
+ const uint32_t i_address,
+ buffer<uint32_t>& o_data)
+ {
+ PLAT_GETCFAM(i_target.get(),
+ (uint32_t)(i_address & BITS(40,24)),
+ &(o_data()));
+
+ return FAPI2_RC_SUCCESS;
+ }
+
+ /// @brief Writes a CFAM register on a chip.
+ /// CFAM register is 32-bit wide.
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target HW target to operate on.
+ /// @param[in] i_address CFAM register address to write to.
+ /// @param[in] i_data Buffer that holds data to write into address.
+ /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ template< TargetType K >
+ inline ReturnCode putCfamRegister(const Target<K>& i_target,
+ const uint32_t i_address,
+ buffer<uint32_t>& i_data)
+ {
+ PLAT_PUTCFAM(i_target.get(),
+ (uint32_t)(i_address & BITS(40,24)),
+ &(i_data()));
+
+ return FAPI2_RC_SUCCESS;
+ }
+
+ /// @brief Read-modify-write a CFAM register on a chip.
+ /// CFAM register is 32-bit wide.
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target HW target to operate on.
+ /// @param[in] i_address CFAM register address to modify.
+ /// @param[in] i_data Buffer that holds data to be modified.
+ /// @param[in] i_modifyMode The modify mode (or/and/xor).
+ /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ template< TargetType K >
+ inline ReturnCode modifyCfamRegister(const Target<K>& i_target,
+ const uint32_t i_address,
+ const buffer<uint32_t>& i_data,
+ const ChipOpModifyMode i_modifyMode)
+ {
+ PLAT_MODCFAM(i_target.get(),
+ (uint32_t)(i_address & BITS(40,24)),
+ &(i_data()),
+ i_modifyMode);
+
+ return FAPI2_RC_SUCCESS;
+ }
+
+ // variable_buffer isn't supported on PPE
+#ifndef __PPE__
+ /// @brief Reads a ring from a chip.
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target Target to operate on.
+ /// @param[in] i_address Ring address to read from.
+ /// @param[out] o_data Buffer that holds data read from HW target.
+ /// @param[in] i_ringMode Ring operation mode.
+ /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ template< TargetType K >
+ inline ReturnCode getRing(const Target<K>& i_target,
+ const scanRingId_t i_address,
+ variable_buffer& o_data,
+ const RingMode i_ringMode = 0)
+ {
+ o_data.setBit(0);
+ o_data.setBit(3);
+#ifndef __PPE__
+ std::cout << std::hex << " getRing "
+ << "target: {" << i_target.getType() << ","
+ << uint64_t(i_target) << "}; "
+ << "ring address: " << i_address << "; "
+ << "ring mode: " << i_ringMode << "; "
+ << "output data:";
+ o_data.print();
+#endif
+
+ return FAPI2_RC_SUCCESS;
+ }
+
+ /// @brief Writes a ring to a chip.
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target Target to operate on.
+ /// @param[in] i_address Ring address to write to.
+ /// @param[in] i_data Buffer that contains RS4 compressed ring data
+ /// to write into address
+ /// @param[in] i_ringMode Ring operation mode.
+ /// @return 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,
+ variable_buffer& i_data,
+ const RingMode i_ringMode = 0)
+ {
+
+ return FAPI2_RC_SUCCESS;
+ }
+
+
+ /// @brief Writes a ring to a chip.
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target Target to operate on.
+ /// @param[in] i_address Ring address to write to.
+ /// @param[in] i_data Pointer to location that contains RS4 compressed
+ // ring data to write into address
+ /// @param[in] i_ringMode Ring operation mode.
+ /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ template< TargetType K >
+ inline ReturnCode putRing(const Target<K>& i_target,
+ const scanRingId_t i_address,
+ const void* i_data,
+ const RingMode i_ringMode = 0)
+ {
+ uint64_t* dataPtr = reinterpret_cast<uint64_t*>(const_cast<void*>(i_data));
+
+ return FAPI2_RC_SUCCESS;
+ }
+
+ /// @brief Read-modify-write a ring on a chip.
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target Target to operate on.
+ /// @param[in] i_address Ring address to modify.
+ /// @param[in] i_data Buffer that contains RS4 compressed ring data
+ /// to be modified.
+ /// @param[in] i_modifyMode The modify mode (or/and/xor)
+ /// @param[in] i_ringMode Ring operation mode.
+ /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ template< TargetType K >
+ 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)
+ {
+
+ return FAPI2_RC_SUCCESS;
+ }
+#endif
+
+
+#ifdef FAPI_SUPPORT_MULTI_SCOM
+ /// @brief Performs a multiple SCOM operation
+ /// This interface performs multiple SCOM operations on a chip in the
+ /// order specified by the input MultiScom object.
+ /// See fapiMultiScom.H for details of how to populate the MultiScom
+ /// object with SCOM operations.
+ ///
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target Target to operate on.
+ /// @param[in,out] io_multiScomObj Reference to a MultiScom object,
+ /// pre-populated with SingleScomInfo entries
+ /// to perform multiple SCOMs on input target
+ /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ ///
+ /// @note This is a synchronous interface and would return after all the
+ /// SCOM operations are completed or on the first failed operation
+ ///
+ /// @note SCOMs will be performed in the order they were added to the
+ /// input MultiScom object
+ ///
+ /// @note In case of errors, the platform code is responsible to collect
+ /// and add all the required error info and FFDC into the error data
+ /// for debugging
+ ///
+ /// @note If the SCOM operations added are specific to a processor chip,
+ /// then the FSI Shift Engine configured in scatter-gather DMA mode
+ /// extension would be used to execute the SCOM operations in a
+ /// performance optimize mode. In this mode, the special
+ /// SCOM_BULK_READ_MODE and SCOM_BULK_WRITE_MODE operations are
+ /// supported that allow a large bulk of SCOM access (in multiple of
+ /// 64 bits) for targets that support auto-increment. The
+ /// SCOM_WRITE_UNDER_MASK operation is not supported in this mode
+ ///
+ /// @note If the SCOM operations added are specific to a memory buffer
+ /// chip, then the regular SCOM engine is used to execute the SCOM
+ /// operations. SCOM_WRITE_UNDER_MASK operation is supported in
+ /// this mode, but the special SCOM_BULK_READ_MODE and
+ /// SCOM_BULK_WRITE_MODE operations are not supported due to
+ /// hardware limitations.
+ ///
+ template< TargetType K >
+ fapi2::ReturnCode multiScom (const Target<K>& i_target,
+ MultiScom& io_multiScomObj)
+ {
+ }
+#endif
+
+ // --------------------------------------------------------------------------
+ // NOTE:
+ // Implement platform Spy access functions if platform supports them.
+ // --------------------------------------------------------------------------
+
+ // variable_buffer isn't supported on PPE
+#ifndef __PPE__
+ /// @brief Reads a spy from a chip.
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target Target to operate on.
+ /// @param[in] i_spyId Id of the spy whose data to be read.
+ /// @param[out] o_data Buffer that holds data read from HW target.
+ /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ ///
+ /// @note: The string version is only supported for cronus.
+ ///
+ /// The fapi design to support both FSP and cronus use of get and
+ /// put spy functions is dependant on the SPY names being expanded
+ /// to resemble a valid C identifier. This design places some
+ /// restrictions on the SPY names which can be used.
+ ///
+ /// 1. if the spy name contains a # procedure writers should replace
+ /// it with an __P__ for example -
+ ///
+ /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS
+ /// becomes
+ /// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS
+ ///
+ /// 2. if the spy name has a number following a "." it must have an
+ /// underscore prepended to the number.
+ ///
+ /// EH.TPCHIP.2KX100_ARY_CLK_EDGES_DLY
+ /// becomes
+ /// EH.TPCHIP._2KX100_ARY_CLK_EDGES_DLY
+ ///
+ /// Example SPY name:
+ /// The hardware procedure should call the function like:
+ ///
+ /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS
+ ///
+ /// fapi2::ReturnCode rc = fapiGetSpy( targ,
+ /// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS, data );
+ ///
+ /// @note The ID is not in quotes the fapi code will handle adding
+ /// the quotes for the cronus environment
+ ///
+#ifdef FAPI_SUPPORT_SPY_AS_ENUM
+ template< TargetType K >
+ inline ReturnCode getSpy(const Target<K>& i_target,
+ const spyId_t i_spyId,
+ variable_buffer& o_data)
+ {
+ static_assert(K == 0, "implement getSpy (string)");
+ return ~FAPI2_RC_SUCCESS;
+ }
+#endif
+#ifdef FAPI_SUPPORT_SPY_AS_STRING
+ template< TargetType K >
+ inline ReturnCode getSpy(const Target<K>& i_target,
+ const char * const i_spyId,
+ variable_buffer& o_data)
+ {
+ static_assert(K == 0, "implement getSpy (string)");
+ return ~FAPI2_RC_SUCCESS;
+ }
+#endif
+ /// @brief Writes a spy on a chip.
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target Target to operate on.
+ /// @param[in] i_spyId Id of the spy to write data to.
+ /// @param[out] i_data Buffer that holds data to write into spy.
+ /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ ///
+ /// @note: The string version is only supported for cronus.
+ ///
+ /// The fapi design to support both FSP and cronus use of get and
+ /// put spy functions is dependent on the SPY names being expanded
+ /// to resemble a valid C identifier. This design places some
+ /// restrictions on the SPY names which can be used.
+ ///
+ /// 1. if the spy name contains a # procedure writers should replace
+ /// is with an __P__ for example -
+ ///
+ /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS
+ /// becomes
+ /// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS
+ ///
+ /// 2. if the spy name has a number following a "." it must have an
+ /// underscore prepended to the number.
+ ///
+ /// EH.TPCHIP.2KX100_ARY_CLK_EDGES_DLY
+ /// becomes
+ /// EH.TPCHIP._2KX100_ARY_CLK_EDGES_DLY
+ ///
+ /// Example SPY name:
+ /// The hardware procedure should call the function like:
+ ///
+ /// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS
+ ///
+ /// fapi2::ReturnCode rc = fapiPutSpy( targ,
+ /// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS, data );
+ ///
+ /// @note The ID is not in quotes the fapi code will handle adding
+ /// the quotes for the cronus environment
+ ///
+#ifdef FAPI_SUPPORT_SPY_AS_ENUM
+ template< TargetType K >
+ inline ReturnCode putSpy(const Target<K>& i_target,
+ const spyId_t i_spyId,
+ variable_buffer& i_data)
+ {
+ static_assert(K == 0, "implement putSpy (enum)");
+ return ~FAPI2_RC_SUCCESS;
+ }
+#endif
+#ifdef FAPI_SUPPORT_SPY_AS_STRING
+ template< TargetType K >
+ inline ReturnCode putSpy(const Target<K>& i_target,
+ const char* const i_spyId,
+ variable_buffer& i_data)
+ {
+ static_assert(K == 0, "implement putSpy (string)");
+ return ~FAPI2_RC_SUCCESS;
+ }
+#endif
+ /// @brief Writes spy data into a buffer holding ring data image
+ /// This API is used by L2/L3 repair to put column repair data
+ /// into a ring buffer image.
+ /// @tparam K template parameter, passed in target.
+ /// @param[in] i_target Target to operate on.
+ /// @param[in] i_spyId Id of the spy.
+ /// @param[in] i_data Buffer that holds spy data to write into ring
+ /// image.
+ /// @param[out] o_data Buffer that holds updated ring image.
+ /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ ///
+ /// @note: The string version is only supported for cronus.
+ ///
+ /// The fapi design to support both FSP and cronus use of get and
+ /// put spy functions is dependent on the SPY names being expanded
+ /// to resemble a valid C identifier. This design places some
+ /// restrictions on the SPY names which can be used.
+ ///
+ /// See fapiPutSpy for details on spy id specifics.
+ ///
+#ifdef FAPI_SUPPORT_SPY_AS_ENUM
+ template< TargetType K >
+ inline ReturnCode putSpyImage(const Target<K>& i_target,
+ const spyId_t i_spyId,
+ const variable_buffer& i_data,
+ variable_buffer& o_imageData)
+ {
+ static_assert(K == 0, "implement putSpyImage (enum)");
+ return ~FAPI2_RC_SUCCESS;
+ }
+#endif
+#ifdef FAPI_SUPPORT_SPY_AS_STRING
+ template< TargetType K >
+ inline ReturnCode putSpyImage(const Target<K>& i_target,
+ const char* const i_spyId,
+ const variable_buffer& i_data,
+ variable_buffer& o_imageData)
+ {
+ static_assert(K == 0, "implement putSpyImage (string)");
+ return ~FAPI2_RC_SUCCESS;
+ }
+#endif
+ /// @brief Reads spy data from a ring image buffer
+ /// @param[in] i_target Target to operate on
+ /// @param[in] i_spyId The spy's id
+ /// @param[out] o_data Buffer that holds data read from ring image.
+ /// @param[in] i_imageData Buffer that holds ring image to read data
+ /// from.
+ /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
+ ///
+ /// @note: The string version is only supported for cronus.
+ ///
+ /// The fapi design to support both FSP and cronus use of get and
+ /// put spy functions is dependent on the SPY names being expanded
+ /// to resemble a valid C identifier. This design places some
+ /// restrictions on the SPY names which can be used.
+ ///
+ /// See fapiPutSpy for details on spy id specifics.
+ ///
+#ifdef FAPI_SUPPORT_SPY_AS_ENUM
+ template< TargetType K >
+ inline ReturnCode getSpyImage(const Target<K>& i_target,
+ const spyId_t i_spyId,
+ variable_buffer& o_data,
+ const variable_buffer& i_imageData)
+ {
+ static_assert(K == 0, "implement getSpyImage (enum)");
+ return ~FAPI2_RC_SUCCESS;
+ }
+#endif
+#ifdef FAPI_SUPPORT_SPY_AS_STRING
+ template< TargetType K >
+ inline ReturnCode getSpyImage(const Target<K>& i_target,
+ const char * const i_spyId,
+ variable_buffer& o_data,
+ const variable_buffer& i_imageData)
+ {
+ static_assert(K == 0, "implement getSpyImage (string)");
+ return ~FAPI2_RC_SUCCESS;
+ }
+#endif
+
+#endif // PPE
+
+};
+
+#endif // _FAPI2_HWACCESS_H_
diff --git a/sbe/hwpf/include/plat/plat_error_scope.H b/sbe/hwpf/include/plat/plat_error_scope.H
new file mode 100644
index 00000000..b6ac62e4
--- /dev/null
+++ b/sbe/hwpf/include/plat/plat_error_scope.H
@@ -0,0 +1,71 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2012,2014 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+/**
+ * @file plat_error_scope.H
+ * @brief platform definitions which create a scope for automatic error handling
+ */
+
+#ifndef __FAPI2_PLAT_ERROR_SCOPE__
+#define __FAPI2_PLAT_ERROR_SCOPE__
+
+/// @cond
+#define PLAT_FAPI_TRY_NO_TRACE( __operation__ ) \
+ if ((fapi2::current_err = (__operation__)) != fapi2::FAPI2_RC_SUCCESS) \
+ { \
+ goto fapi_try_exit; \
+ }
+
+#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; \
+ }
+
+
+///
+/// @brief Temporary macro for error label until all are removed.
+/// @todo REMOVE this in time.
+#define FAPI_CLEANUP() \
+fapi_try_exit:
+/// @endcond
+
+#endif
diff --git a/sbe/hwpf/include/plat/plat_hw_access.H b/sbe/hwpf/include/plat/plat_hw_access.H
new file mode 100644
index 00000000..765837fd
--- /dev/null
+++ b/sbe/hwpf/include/plat/plat_hw_access.H
@@ -0,0 +1,70 @@
+/**
+ * @file plat_hw_access.H
+ *
+ * @brief Define platform specific calls for hardware accesses.
+ */
+
+#ifndef PLATHWACCESS_H_
+#define PLATHWACCESS_H_
+
+#include <plat_includes.H>
+
+/// PIB Error Mask
+
+#define PLAT_SET_PIB_ERROR_MASK(_m_mask) \
+ { /* Read MSR */ \
+ uint32_t msr_data = mfmsr(); \
+ /* Set SEM field */ \
+ msr_data &= ~(BITS(0,8)); \
+ msr_data |= (uint32_t)(i_mask << 24); \
+ /* Write MSR */ \
+ mtmsr(msr_data); \
+ };
+
+#define PLAT_GET_PIB_ERROR_MASK(_m_mask) \
+ uint8_t _m_mask; \
+ uint32_t _sem = mfmsr(); \
+ _m_mask = (uint8_t)((_sem & MSR_SEM) >> (32-(MSR_SEM_START_BIT + MSR_SEM_LEN)));
+
+// Building block PPE instructions
+#define PPE_MFMSR(_m_data) \
+asm volatile \
+ ( \
+ "mfmsr %[data] \n" \
+ : [data]"=&r"(*_m_data) \
+ : "[data]"(*_m_data) \
+ );
+
+#define PPE_MTMSR(_m_data) \
+asm volatile \
+ ( \
+ "mtmsr %[data] \n" \
+ : [data]"=&r"(*_m_data) \
+ : "[data]"(*_m_data) \
+ );
+
+/// GetScom
+#define PLAT_GETSCOM(_m_rc, _m_base, _m_offset, _m_data) \
+ _m_rc = getscom(_m_base.getAddressOverlay(), (0 == _m_base.getAddressOverlay())?_m_offset:(uint32_t)(_m_offset & BITS(40,24)), _m_data);
+
+/// PutScom
+#define PLAT_PUTSCOM(_m_rc, _m_base, _m_offset, _m_data) \
+ _m_rc = putscom(_m_base.getAddressOverlay(), (0 == _m_base.getAddressOverlay())?_m_offset:(uint32_t)(_m_offset & BITS(40,24)), _m_data);
+
+/// GetCFAM
+#define PLAT_GETCFAM(_m_base, _m_offset, _m_data) \
+ static_assert( K == TARGET_TYPE_NONE, \
+ "getCfamRegister is not supported by PPE platforms")
+
+/// PutCFAM
+#define PLAT_PUTCFAM(_m_base, _m_offset, _m_data) \
+ static_assert( K == TARGET_TYPE_NONE, \
+ "putCfamRegister is not supported by PPE platforms")
+
+/// ModifyCFAM
+#define PLAT_MODCFAM(_m_base, _m_offset, _m_data, _m_mode) \
+ static_assert( K == TARGET_TYPE_NONE, \
+ "modifyCfamRegister is not supported by PPE platforms")
+
+#endif // PLATHWACCESS_H_
+
diff --git a/sbe/hwpf/src/Makefile b/sbe/hwpf/src/Makefile
new file mode 100644
index 00000000..7255042e
--- /dev/null
+++ b/sbe/hwpf/src/Makefile
@@ -0,0 +1,32 @@
+# This Makefile is designed to be invoked with the -I argument
+
+export SUB_OBJDIR = /fapi2
+
+include img_defs.mk
+include fapi2sbefiles.mk
+
+
+OBJS := $(addprefix $(OBJDIR)/, $(FAPI2LIB_OBJECTS))
+
+libfapi2.a: fapi2 hwpf
+ $(AR) crs $(OBJDIR)/libfapi2.a $(OBJDIR)/*.o
+
+.PHONY: clean fapi2 hwpf
+fapi2: $(OBJS)
+
+#plat:
+# $(MAKE) -I $(IMAGE_SRCDIR) -C $(PLAT_FAPI2_DIR)
+
+hwpf:
+ @echo "Processing fapi2 hwpf makefile"
+ $(MAKE) -I $(IMAGE_SRCDIR) -C $(PPE_FAPI2_DIR)/src
+
+$(OBJS) $(OBJS:.o=.d): | $(OBJDIR)
+
+$(OBJDIR):
+ mkdir -p $(OBJDIR)
+
+ifneq ($(MAKECMDGOALS),clean)
+include $(OBJS:.o=.d)
+endif
+
diff --git a/sbe/hwpf/src/fapi2sbefiles.mk b/sbe/hwpf/src/fapi2sbefiles.mk
new file mode 100644
index 00000000..da7f3e7c
--- /dev/null
+++ b/sbe/hwpf/src/fapi2sbefiles.mk
@@ -0,0 +1,25 @@
+# @file fapi2ppefiles.mk
+#
+# @brief mk for including fapi2 object files
+#
+# @page ChangeLogs Change Logs
+# @section fapi2ppefiles.mk
+# @verbatim
+#
+#
+# Change Log ******************************************************************
+# Flag Defect/Feature User Date Description
+# ------ -------------- ---------- ------------ -----------
+#
+# @endverbatim
+#
+##########################################################################
+# Object Files
+##########################################################################
+
+FAPI2-C-SOURCES +=
+FAPI2-S-SOURCES =
+
+
+FAPI2LIB_OBJECTS += $(FAPI2-C-SOURCES:.C=.o) $(FAPI2-S-SOURCES:.S=.o)
+
diff --git a/sbe/hwpf/src/return_code.C b/sbe/hwpf/src/return_code.C
new file mode 100644
index 00000000..3dbd7052
--- /dev/null
+++ b/sbe/hwpf/src/return_code.C
@@ -0,0 +1,47 @@
+/* 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.C
+ *
+ * @brief Fuctions that process PPE return codes
+ */
+
+#include <return_code.H>
+
+namespace fapi2
+{
+
+ /// @brief Takes a non-zero PIB return code and inssert the value into
+ /// a fapi2::ReturnCode
+ /// @param[in] i_msr Value read from the PPE MSR
+ /// @return fapi::ReturnCode. Built ReturnCode
+ ReturnCode& ReturnCode::insertPIBcode(uint32_t& rhs)
+ {
+ iv_rc = FAPI2_RC_PLAT_MASK | rhs;
+ return iv_rc;
+ }
+
+}
OpenPOWER on IntegriCloud