summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/hwp/tod_init/TodHwpIntf.C
blob: 55ddd8c3ffef1a35fa4726527c01670571ad559b (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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/hwpf/hwp/tod_init/TodHwpIntf.C $                      */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2013,2014              */
/*                                                                        */
/* p1                                                                     */
/*                                                                        */
/* Object Code Only (OCO) source materials                                */
/* Licensed Internal Code Source Materials                                */
/* IBM HostBoot Licensed Internal Code                                    */
/*                                                                        */
/* 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.                              */
/*                                                                        */
/* Origin: 30                                                             */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */

/**
 *  @file TodHwpIntf.C
 *
 *  @brief Implementation of TOD Hardware Procedure interfaces
 *
 *  HWP_IGNORE_VERSION_CHECK
 *
 */

//------------------------------------------------------------------------------
//Includes
//------------------------------------------------------------------------------
#include <fapiPlatHwpInvoker.H>
#include <tod_init/tod_init_reasoncodes.H>
#include "TodTrace.H"
#include "TodHwpIntf.H"
#include "TodControls.H"
#include "proc_tod_setup.H"
#include "proc_tod_save_config.H"
#include "proc_tod_init.H"

namespace TOD
{

errlHndl_t todSetupHwp(const proc_tod_setup_tod_sel i_topologyType)
{
    TOD_ENTER("todSetupHwp");

    errlHndl_t l_errHdl = NULL;

    do
    {
        //Get the MDMT
        TodProc* l_pMDMT =
            TodControls::getTheInstance().getMDMT(i_topologyType);
        if(NULL == l_pMDMT)
        {
            TOD_ERR("MDMT not found");
            /*@
             * @errortype
             * @reasoncode   TOD_NO_MASTER_PROC
             * @moduleid     TOD_SETUP_HWP
             * @devdesc      MDMT could not be found
             */
            l_errHdl = new ERRORLOG::ErrlEntry(
                               ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                               TOD_SETUP_HWP,
                               TOD_NO_MASTER_PROC,0,0);
            break;
        }

        FAPI_INVOKE_HWP(l_errHdl,
                        proc_tod_setup,
                        l_pMDMT->getTopologyNode(),
                        i_topologyType,
                        TOD_OSC_0);
        if(l_errHdl)
        {
          TOD_ERR("Error in call to proc_tod_setup. "
                   "Topology type 0x%.8X. "
                   "MDMT's HUID is 0x%.8X. "
                   "MDMT Master type : 0x%.8X. ",
                   i_topologyType,
                   l_pMDMT->getTarget()->getAttr<TARGETING::ATTR_HUID>(),
                   l_pMDMT->getMasterType());
          TOD_ERR("MDMT Bus RX 0x%.8X, Bus TX 0x%.8X.",
                   l_pMDMT->getBusIn(), l_pMDMT->getBusOut());
          break;
        }

        //Mark the MDMT role in ATTR.  Note the same chip
        //can be both primary/secondary.  Attr is volatile
        //init'ed to zero
        TARGETING::Target * l_proc =
                const_cast<TARGETING::Target*>(l_pMDMT->getTarget());
        uint8_t l_role = l_proc->getAttr<TARGETING::ATTR_TOD_ROLE>();
        if (TOD_PRIMARY == i_topologyType)
        {
            l_role |= TARGETING::TOD_ROLE_PRIMARY;
        }
        else //Secondary
        {
            l_role |= TARGETING::TOD_ROLE_SECONDARY;
        }
        l_proc->setAttr<TARGETING::ATTR_TOD_ROLE>(l_role);

    }while(0);

    TOD_EXIT("todSetupHwp. errHdl = %p", l_errHdl);

    return l_errHdl;
}

errlHndl_t todSaveRegsHwp(const proc_tod_setup_tod_sel i_topologyType)
{
    TOD_ENTER("todSaveRegsHwp");

    errlHndl_t l_errHdl = NULL;

    do
    {
        //Get the MDMT
        TodProc* l_pMDMT =
            TodControls::getTheInstance().getMDMT(i_topologyType);
        if(NULL == l_pMDMT)
        {
            TOD_ERR("MDMT not found");
            /*@
             * @errortype
             * @reasoncode   TOD_NO_MASTER_PROC
             * @moduleid     TOD_SAVEREGS_HWP
             * @devdesc      MDMT could not be found
             */
            l_errHdl = new ERRORLOG::ErrlEntry(
                               ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                               TOD_SAVEREGS_HWP,
                               TOD_NO_MASTER_PROC,0,0);
            break;
        }

        FAPI_INVOKE_HWP(l_errHdl,
                        proc_tod_save_config,
                        l_pMDMT->getTopologyNode());
        if(l_errHdl)
        {
          TOD_ERR("Error in call to proc_tod_save_config. "
                  "Topology type 0x%.8X. "
                  "MDMT's HUID is 0x%.8X. "
                  "MDMT Master type : 0x%.8X. ",
                  i_topologyType,
                  l_pMDMT->getTarget()->getAttr<TARGETING::ATTR_HUID>(),
                  l_pMDMT->getMasterType());
          TOD_ERR("MDMT Bus RX 0x%.8X, Bus TX 0x%.8X.",
                  l_pMDMT->getBusIn(), l_pMDMT->getBusOut());
          break;
        }
    }while(0);

    TOD_EXIT("todSaveRegsHwp. errHdl = %p", l_errHdl);

    return l_errHdl;
}

errlHndl_t todInitHwp(const proc_tod_setup_tod_sel i_topologyType)
{
    TOD_ENTER("todInitHwp");

    errlHndl_t l_errHdl = NULL;

    do
    {
        //Get the MDMT
        TodProc* l_pMDMT =
            TodControls::getTheInstance().getMDMT(i_topologyType);
        if(NULL == l_pMDMT)
        {
            TOD_ERR("MDMT not found");
            /*@
             * @errortype
             * @reasoncode   TOD_NO_MASTER_PROC
             * @moduleid     TOD_INIT_HWP
             * @devdesc      MDMT could not be found
             */
            l_errHdl = new ERRORLOG::ErrlEntry(
                               ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                               TOD_INIT_HWP,
                               TOD_NO_MASTER_PROC,0,0);
            break;
        }

        FAPI_INVOKE_HWP(l_errHdl,
                        proc_tod_init,
                        l_pMDMT->getTopologyNode());

        if(l_errHdl)
        {
          TOD_ERR("Error in call to proc_tod_init. "
                   "Topology type 0x%.8X. "
                   "MDMT's HUID is 0x%.8X. "
                   "MDMT Master type : 0x%.8X. ",
                   i_topologyType,
                   l_pMDMT->getTarget()->getAttr<TARGETING::ATTR_HUID>(),
                   l_pMDMT->getMasterType());
          TOD_ERR("MDMT Bus RX 0x%.8X, Bus TX 0x%.8X.",
                   l_pMDMT->getBusIn(), l_pMDMT->getBusOut());
          break;
        }
    }while(0);

    TOD_EXIT("todInitHwp. errHdl = %p", l_errHdl);

    return l_errHdl;
}

} //namespace TOD
OpenPOWER on IntegriCloud