<commit_before>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/p10/procedures/hwp/nest/p10_revert_sbe_mcs_setup.C $ */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,2019                        */
/* [+] 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 p10_revert_sbe_mcs_setup.C
/// @brief Revert MC configuration applied by SBE (FAPI2)
///
/// @author <NAME> <<EMAIL>>
///

//
// *HWP HW Maintainer: <NAME> <<EMAIL>>
// *HWP FW Maintainer: <NAME> <<EMAIL>>
// *HWP Consumed by  : HB
//

//------------------------------------------------------------------------------
// Includes
//------------------------------------------------------------------------------
#include <p10_revert_sbe_mcs_setup.H>

//------------------------------------------------------------------------------
// Function definitions
//------------------------------------------------------------------------------

///
/// @brief helper function to revert HB dcbz configuration
///
/// @param[in] i_target Reference to a chip target
/// @param[in] i_target_mc Reference to MC with config'd BAR
/// @return FAPI2_RC_SUCCESS if success, else error code.
///
fapi2::ReturnCode
revert_mc_hb_dcbz_config(
    const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
    const fapi2::Target<fapi2::TARGET_TYPE_MI>& i_target_mc)
{
    FAPI_DBG("Start");

    fapi2::ATTR_PROC_SBE_MCS_SETUP_REG_STATES_Type l_reg_states;

    FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_PROC_SBE_MCS_SETUP_REG_STATES,
                           i_target,
                           l_reg_states),
             "Error from FAPI_ATTR_GET (ATTR_PROC_SBE_MCS_SETUP_REG_STATES)");

    FAPI_TRY(fapi2::putScom(i_target_mc, scomt::mc::SCOMFIR_MCFGP0,
                            l_reg_states[fapi2::ENUM_ATTR_PROC_SBE_MCS_SETUP_REG_STATES_MCFGP0]),
             "Error from putScom (MCFGP0)");

    FAPI_TRY(fapi2::putScom(i_target_mc, scomt::mc::SCOMFIR_MCMODE0,
                            l_reg_states[fapi2::ENUM_ATTR_PROC_SBE_MCS_SETUP_REG_STATES_MCMODE0]),
             "Error from putScom (MCMODE0)");

    FAPI_TRY(fapi2::putScom(i_target_mc, scomt::mc::SCOMFIR_MCMODE1,
                            l_reg_states[fapi2::ENUM_ATTR_PROC_SBE_MCS_SETUP_REG_STATES_MCMODE1]),
             "Error from putScom (MCMODE1)");

    FAPI_TRY(fapi2::putScom(i_target_mc, scomt::mc::SCOMFIR_MCMODE2,
                            l_reg_states[fapi2::ENUM_ATTR_PROC_SBE_MCS_SETUP_REG_STATES_MCMODE2]),
             "Error from putScom (MCMODE2)");

    FAPI_TRY(fapi2::putScom(i_target_mc, scomt::mc::SCOMFIR_MCPERF1,
                            l_reg_states[fapi2::ENUM_ATTR_PROC_SBE_MCS_SETUP_REG_STATES_MCPERF1]),
             "Error from putScom (MCPERF1)");

    FAPI_TRY(fapi2::putScom(i_target_mc, scomt::mc::SCOMFIR_MCFIRMASK_RW,
                            l_reg_states[fapi2::ENUM_ATTR_PROC_SBE_MCS_SETUP_REG_STATES_MCFIRMASK]),
             "Error from putScom (MCFIR_WRX)");
/////// TODO: RTC: 209863
//    FAPI_TRY(fapi2::putScom(i_target_mc, scomt::mc::SCOMFIR_MCFIRACT0,
//                l_reg_states[fapi2::ENUM_ATTR_PROC_SBE_MCS_SETUP_REG_STATES_MCFIRACT0]),
//             "Error from putScom (MCFIRACT0)");
//
//    FAPI_TRY(fapi2::putScom(i_target_mc, scomt::mc::SCOMFIR_MCFIRACT1,
//                l_reg_states[fapi2::ENUM_ATTR_PROC_SBE_MCS_SETUP_REG_STATES_MCFIRACT1]),
//             "Error from putScom (MCFIRACT1)");

    FAPI_TRY(fapi2::putScom(i_target_mc, scomt::mc::SCOMFIR_MCTO,
                            l_reg_states[fapi2::ENUM_ATTR_PROC_SBE_MCS_SETUP_REG_STATES_MCTO]),
             "Error from putScom (MCTO)");
fapi_try_exit:
    FAPI_DBG("End");
    return fapi2::current_err;
}

// HWP entry point
fapi2::ReturnCode
p10_revert_sbe_mcs_setup(
    const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target)
{
    FAPI_DBG("Start");
    fapi2::ATTR_SYSTEM_IPL_PHASE_Type     l_ipl_type;
    fapi2::ATTR_PROC_SBE_MASTER_CHIP_Type l_is_master_sbe;
    fapi2::ATTR_IS_MPIPL_Type             l_is_mpipl;
    const fapi2::Target<fapi2::TARGET_TYPE_SYSTEM> FAPI_SYSTEM;

    FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_PROC_SBE_MASTER_CHIP,
                           i_target,
                           l_is_master_sbe),
             "Error from FAPI_ATTR_GET (ATTR_PROC_SBE_MASTER_CHIP)");
    FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_IS_MPIPL,
                           FAPI_SYSTEM,
                           l_is_mpipl),
             "Error from FAPI_ATTR_GET (ATTR_IS_MPIPL)");
    FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_SYSTEM_IPL_PHASE,
                           FAPI_SYSTEM,<commit_msg>sbe_mcs_setup Updates: Scom header inclusions and bugs<commit_after>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/p10/procedures/hwp/nest/p10_revert_sbe_mcs_setup.C $ */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,2019                        */
/* [+] 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 p10_revert_sbe_mcs_setup.C
/// @brief Revert MC configuration applied by SBE (FAPI2)
///
/// @author <NAME> <<EMAIL>>
///

//
// *HWP HW Maintainer: <NAME> <<EMAIL>>
// *HWP FW Maintainer: <NAME> <<EMAIL>>
// *HWP Consumed by  : HB
//

//------------------------------------------------------------------------------
// Includes
//------------------------------------------------------------------------------
#include <p10_revert_sbe_mcs_setup.H>

//------------------------------------------------------------------------------
// Function definitions
//------------------------------------------------------------------------------

///
/// @brief helper function to revert HB dcbz configuration
///
/// @param[in] i_target Reference to a chip target
/// @param[in] i_target_mc Reference to MC with config'd BAR
/// @return FAPI2_RC_SUCCESS if success, else error code.
///
fapi2::ReturnCode
revert_mc_hb_dcbz_config(
    const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
    const fapi2::Target<fapi2::TARGET_TYPE_MI>& i_target_mc)
{
    FAPI_DBG("Start");

    fapi2::ATTR_PROC_SBE_MCS_SETUP_REG_STATES_Type l_reg_states;

    FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_PROC_SBE_MCS_SETUP_REG_STATES,
                           i_target,
                           l_reg_states),
             "Error from FAPI_ATTR_GET (ATTR_PROC_SBE_MCS_SETUP_REG_STATES)");

    FAPI_TRY(fapi2::putScom(i_target_mc, scomt::mc::SCOMFIR_MCFGP0,
                            l_reg_states[fapi2::ENUM_ATTR_PROC_SBE_MCS_SETUP_REG_STATES_MCFGP0]),
             "Error from putScom (MCFGP0)");

    FAPI_TRY(fapi2::putScom(i_target_mc, scomt::mc::SCOMFIR_MCMODE0,
                            l_reg_states[fapi2::ENUM_ATTR_PROC_SBE_MCS_SETUP_REG_STATES_MCMODE0]),
             "Error from putScom (MCMODE0)");

    FAPI_TRY(fapi2::putScom(i_target_mc, scomt::mc::SCOMFIR_MCMODE1,
                            l_reg_states[fapi2::ENUM_ATTR_PROC_SBE_MCS_SETUP_REG_STATES_MCMODE1]),
             "Error from putScom (MCMODE1)");

    FAPI_TRY(fapi2::putScom(i_target_mc, scomt::mc::SCOMFIR_MCMODE2,
                            l_reg_states[fapi2::ENUM_ATTR_PROC_SBE_MCS_SETUP_REG_STATES_MCMODE2]),
             "Error from putScom (MCMODE2)");

    FAPI_TRY(fapi2::putScom(i_target_mc, scomt::mc::SCOMFIR_MCPERF1,
                            l_reg_states[fapi2::ENUM_ATTR_PROC_SBE_MCS_SETUP_REG_STATES_MCPERF1]),
             "Error from putScom (MCPERF1)");

    FAPI_TRY(fapi2::putScom(i_target_mc, scomt::mc::SCOMFIR_MCFIRMASK_RW,
                            l_reg_states[fapi2::ENUM_ATTR_PROC_SBE_MCS_SETUP_REG_STATES_MCFIRMASK]),
             "Error from putScom (MCFIR_WRX)");

    FAPI_TRY(fapi2::putScom(i_target_mc, scomt::mc::SCOMFIR_MCFIRACT0,
                            l_reg_states[fapi2::ENUM_ATTR_PROC_SBE_MCS_SETUP_REG_STATES_MCFIRACT0]),
             "Error from putScom (MCFIRACT0)");

    FAPI_TRY(fapi2::putScom(i_target_mc, scomt::mc::SCOMFIR_MCFIRACT1,
                            l_reg_states[fapi2::ENUM_ATTR_PROC_SBE_MCS_SETUP_REG_STATES_MCFIRACT1]),
             "Error from putScom (MCFIRACT1)");

    FAPI_TRY(fapi2::putScom(i_target_mc, scomt::mc::SCOMFIR_MCTO,
                            l_reg_states[fapi2::ENUM_ATTR_PROC_SBE_MCS_SETUP_REG_STATES_MCTO]),
             "Error from putScom (MCTO)");
fapi_try_exit:
    FAPI_DBG("End");
    return fapi2::current_err;
}

// HWP entry point
fapi2::ReturnCode
p10_revert_sbe_mcs_setup(
    const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target)
{
    FAPI_DBG("Start");
    fapi2::ATTR_SYSTEM_IPL_PHASE_Type     l_ipl_type;
    fapi2::ATTR_PROC_SBE_MASTER_CHIP_Type l_is_master_sbe;
    fapi2::ATTR_IS_MPIPL_Type             l_is_mpipl;
    const fapi2::Target<fapi2::TARGET_TYPE_SYSTEM> FAPI_SYSTEM;

    FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_PROC_SBE_MASTER_CHIP,
                           i_target,
                           l_is_master_sbe),
             "Error from FAPI_ATTR_GET (ATTR_PROC_SBE_MASTER_CHIP)");
    FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_IS_MPIPL,
                           FAPI_SYSTEM,
                           l_is_mpipl),
             "Error from FAPI_ATTR_GET (ATTR_IS_MPIPL)");
    FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_SYSTEM_IPL_PHASE,
                           FAPI_SYSTEM,
{'fraction_non_alphanumeric': 0.14385000808146112, 'fraction_numerical': 0.013738483917892355, 'mean_word_length': 1.516778523489933, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 62, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6744209', 'n_tokens_mistral': 3870, 'n_tokens_neox': 3858, 'n_words': 572}