summaryrefslogtreecommitdiffstats
path: root/src/usr/htmgt/runtime/rt_occ.C
blob: d25d12f9629d6e94f97bd2c84e77567e26e187d3 (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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/htmgt/runtime/rt_occ.C $                              */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2014,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                                                     */
#include    <runtime/interface.h>
#include    <util/utillidmgr.H>
#include    <htmgt/htmgt.H>
#include    "../htmgt_utility.H"
#include    <targeting/common/commontargeting.H>
#include    <targeting/runtime/rt_targeting.H>


using namespace TARGETING;
extern trace_desc_t* g_trac_hbrt;


namespace HTMGT
{

    //------------------------------------------------------------------------

    void process_occ_error (uint64_t i_chipId)
    {
        TRACFCOMP(g_trac_hbrt, ENTER_MRK" process_occ_error");
#ifdef CONFIG_HTMGT
        TARGETING::Target* l_reportingOccTarget = NULL;
        errlHndl_t err = RT_TARG::getHbTarget(i_chipId,l_reportingOccTarget);
        if (err)
        {
            TMGT_ERR ("process_occ_error: getHbTarget"
                      " failed at %d chipId", i_chipId);
            errlCommit (err, HWPF_COMP_ID);
        }
        else
        {
            HTMGT::processOccError(l_reportingOccTarget);
        }
#else
        TMGT_ERR("Unexpected call to process_occ_error(%d)"
                 " when HTMGT is not enabled", i_chipId);
#endif
        TRACFCOMP(g_trac_hbrt, EXIT_MRK" process_occ_error");
    }

    //------------------------------------------------------------------------

    void process_occ_reset (uint64_t i_chipId)
    {
        TRACFCOMP(g_trac_hbrt, ENTER_MRK" process_occ_reset");
#ifdef CONFIG_HTMGT
        TARGETING::Target* l_failedOccTarget = NULL;
        errlHndl_t err = RT_TARG::getHbTarget(i_chipId,l_failedOccTarget);
        if (err)
        {
            TMGT_ERR ("process_occ_reset: getHbTarget"
                      " failed at %d chipId", i_chipId);
            errlCommit (err, HWPF_COMP_ID);
        }
        else
        {
            HTMGT::processOccReset(l_failedOccTarget);
        }
#else
        TMGT_ERR("Unexpected call to process_occ_reset(%d)"
                 " when HTMGT is not enabled", i_chipId);
#endif
        TRACFCOMP(g_trac_hbrt, EXIT_MRK" process_occ_reset");
    }

    //------------------------------------------------------------------------

    int enable_occ_actuation (int i_occ_activation)
    {
        TRACFCOMP(g_trac_hbrt, ENTER_MRK" enable_occ_actuation");
        int rc = 0;
#ifdef CONFIG_HTMGT
        errlHndl_t err = HTMGT::enableOccActuation(0 != i_occ_activation);
        if (err)
        {
            rc = err->reasonCode();
            if (0 == rc)
            {
                // If there was a failure, be sure to return non-zero status
                rc = -1;
            }
            TMGT_ERR ("enable_occ_actuation: OCC state change"
                      " failed with rc=0x%04X (actuate=%d)",
                      err->reasonCode(), i_occ_activation);
            errlCommit (err, HWPF_COMP_ID);
        }
#else
        rc = -1;
        TMGT_ERR("Unexpected call to enable_occ_actuation(%d)"
                 " when HTMGT is not enabled", i_occ_activation);
#endif
        TRACFCOMP(g_trac_hbrt, EXIT_MRK" enable_occ_actuation: rc=0x%X",rc);
        return rc;
    }

    //------------------------------------------------------------------------

    int htmgt_pass_thru (uint16_t   i_cmdLength,
                             uint8_t *  i_cmdData,
                             uint16_t * o_rspLength,
                             uint8_t *  o_rspData)
    {
        TRACFCOMP(g_trac_hbrt, ENTER_MRK" mfg_htmgt_pass_thru");
        int rc = 0;
#ifdef CONFIG_HTMGT
        errlHndl_t err = HTMGT::passThruCommand(i_cmdLength, i_cmdData,
                                                *o_rspLength, o_rspData);
        if (err)
        {
            rc = err->reasonCode();
            if (0 == rc)
            {
                // If there was a failure, be sure to return non-zero status
                rc = -1;
            }
            if ((i_cmdLength > 0) && (NULL != i_cmdData))
            {
                TMGT_ERR ("htmgt_pass_thru: command 0x%02X"
                          " (%d bytes) failed with rc=0x%04X",
                          i_cmdData[0], i_cmdLength, err->reasonCode());
            }
            errlCommit (err, HWPF_COMP_ID);
        }
#else
        o_rspLength = 0;
#endif
        TRACFCOMP(g_trac_hbrt, EXIT_MRK" mfg_htmgt_pass_thru: rc=0x%X",rc);
        return rc;
    }

    //------------------------------------------------------------------------

    struct registerOcc
    {
        registerOcc()
        {
            runtimeInterfaces_t * rt_intf = getRuntimeInterfaces();
            rt_intf->process_occ_error  = &process_occ_error;
            rt_intf->process_occ_reset  = &process_occ_reset;
            rt_intf->enable_occ_actuation  = &enable_occ_actuation;
            rt_intf->mfg_htmgt_pass_thru = &htmgt_pass_thru;
        }
    };

    registerOcc g_registerOcc;


//------------------------------------------------------------------------

    void process_occ_clr_msgs( void )
    {
#ifdef CONFIG_HTMGT
        // a NULL parameter will cause processOccError() to poll
        //   all of the OCCs (since the parm was invalid)
        TARGETING::Target * l_DummyOccTarget = nullptr;
        HTMGT::processOccError(l_DummyOccTarget);
#else
        TMGT_ERR("Unexpected call to process_occ_clr_msgs"
                " when HTMGT is not enabled");
#endif
    }


    //------------------------------------------------------------------------

    struct registerOccStartup
    {
        registerOccStartup()
        {
            // Register interface for Host to call
            postInitCalls_t * rt_post = getPostInitCalls();
            rt_post->callClearPendingOccMsgs = &process_occ_clr_msgs;
        }

    };

    registerOccStartup g_registerOccStartup;

} // end namespace HTMGT
OpenPOWER on IntegriCloud