summaryrefslogtreecommitdiffstats
path: root/src/sbefw/core/sbes0handler.C
blob: 06507eb770c9d352bb4967aa430479095384d2ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/sbefw/core/sbes0handler.C $                               */
/*                                                                        */
/* OpenPOWER sbe Project                                                  */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2017,2018                        */
/* [+] 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: ppe/src/sbefw/sbes0handler.C
 *
 * @brief This file contains the SBE S0 Handler
 *
 */

#include "sbefifo.H"
#include "sbeSpMsg.H"
#include "sbe_sp_intf.H"
#include "sbetrace.H"
#include "sbeFifoMsgUtils.H"
#include "sberegaccess.H"
#include "sbefapiutil.H"
#include "sbecmdiplcontrol.H"
#include "sbecmdmpipl.H"
#include "sbeFFDC.H"
#include "sbes0handler.H"
#include "sbearchregdump.H"

#include "fapi2.H"
#include "p9_perv_scom_addresses.H"

using namespace fapi2;

#ifdef __SBEFW_SEEPROM__

///////////////////////////////////////////////////////////////////////
// @brief sbeHandleS0
//
// @return  RC from the function
///////////////////////////////////////////////////////////////////////
uint32_t sbeHandleS0(uint8_t *i_pArg)
{
    #define SBE_FUNC " sbeHandleS0 "
    SBE_ENTER(SBE_FUNC);
    uint32_t rc = SBE_SEC_OPERATION_SUCCESSFUL;
    ReturnCode fapiRc = FAPI2_RC_SUCCESS;

    do // Do while for both StartMpipl and ContinueMpipl
    {
        fapiRc = startMpiplIstepsExecute();
        if(fapiRc != FAPI2_RC_SUCCESS)
        {
            rc = SBE_SEC_S0_START_MPIPL_FAILED;
            SBE_ERROR(SBE_FUNC "Failed in Start Mpipl S0 Interface");
            break;
        }

        // Collect Architected Register Dump
        fapiRc = sbeDumpArchRegs();
        if(fapiRc != FAPI2_RC_SUCCESS)
        {
            rc = SBE_SEC_S0_ARCH_REG_DUMP_FAILED;
            SBE_ERROR(SBE_FUNC "Failed to collect ArchRegDump S0 Interface");
            break;
        }

        // TODO - RTC: 190585
        //Core and Cache stop Clock
        fapiRc = stopClockS0();
        if(fapiRc != FAPI2_RC_SUCCESS)
        {
            rc = SBE_SEC_S0_STOP_CLOCK_FAILED;
            SBE_ERROR(SBE_FUNC "Failed in Core/Cache StopClock S0 Interface");
            break;
        }

        sbeRole sbeRole = SbeRegAccess::theSbeRegAccess().isSbeSlave() ?
                    SBE_ROLE_SLAVE : SBE_ROLE_MASTER;

        if(sbeRole == SBE_ROLE_MASTER)
        {
            fapiRc = continueMpiplIstepsExecute(sbeRole);
            if(fapiRc != FAPI2_RC_SUCCESS)
            {
                rc = SBE_SEC_S0_CONTINUE_MPIPL_FAILED;
                SBE_ERROR(SBE_FUNC "Failed in Continue Mpipl S0 Interface, "
                        "SBE Role[%d]", sbeRole);
                break;
            }
        }
    }while(0);

    if(rc)
    {
        // Async Response to be stored
        captureAsyncFFDC(SBE_PRI_GENERIC_EXECUTION_FAILURE, rc);
    }
    SBE_EXIT(SBE_FUNC);
    return rc;
    #undef SBE_FUNC
}

#endif // #ifdef __SBEFW_SEEPROM__

#ifndef __SBEFW_SEEPROM__

uint32_t clearS0interrupt()
{
    #define SBE_FUNC "clearS0interrupt"
    SBE_ENTER(SBE_FUNC);
    uint32_t rc = FAPI2_RC_SUCCESS;
    // Default Mask bit for S0 Innterrupt, bit 49
    uint64_t MASK_ALL_AND_MODIFY_BIT = 0xFFFDFFFFFFFFFFFFULL;
    
    do
    {
        Target<TARGET_TYPE_PROC_CHIP > procTgt = plat_getChipTarget();
        uint64_t data;
        rc = getscom_abs_wrap (&procTgt, PERV_SB_CS_SCOM, &data);
        if( rc )
        {
            break;
        }
        data = data & MASK_ALL_AND_MODIFY_BIT;
        rc = putscom_abs_wrap (&procTgt, PERV_SB_CS_SCOM, data);
        if( rc )
        {
            break;
        }
    }while(0);

    SBE_EXIT(SBE_FUNC);
    return rc;
    #undef SBE_FUNC
}

#endif // #ifndef __SBEFW_SEEPROM__

OpenPOWER on IntegriCloud