<commit_before>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: hwpf/fapi2/include/fapi2_hw_access.H $                        */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* EKB Project                                                            */
/*                                                                        */
/* COPYRIGHT 2012,2016                                                    */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* The source code for this program is not published or otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* 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 <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>
#include <p9_ringId.H>

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);

/// @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_ringID   Ring ID that will identify the Ring in the image.
/// @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 RingID i_ringID,
                          const RingMode i_ringMode = RING_MODE_HEADER_CHECK);

// 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 ><commit_msg>Removing inline specifier for fapi2::putRing<commit_after>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: hwpf/fapi2/include/fapi2_hw_access.H $                        */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* EKB Project                                                            */
/*                                                                        */
/* COPYRIGHT 2012,2016                                                    */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* The source code for this program is not published or otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* 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 <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>
#include <p9_ringId.H>

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);

/// @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_ringID   Ring ID that will identify the Ring in the image.
/// @param[in] i_ringMode Ring operation mode.
/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
template< TargetType K >
ReturnCode putRing(const Target<K>& i_target,
                   const RingID i_ringID,
                   const RingMode i_ringMode = RING_MODE_HEADER_CHECK);

// 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 >
{'fraction_non_alphanumeric': 0.1448443083205717, 'fraction_numerical': 0.00874170495150587, 'mean_word_length': 1.522207917605407, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 65, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 82, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5209413', 'n_tokens_mistral': 4078, 'n_tokens_neox': 3950, 'n_words': 1403}