summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/framework/service/prdfPlatServices_common.C
blob: 10cd90c2a1b6f482f510a9eba1f075396240ce8d (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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: ./common/framework/service/prdfPlatServices_common.C $        */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2012,2013              */
/*                                                                        */
/* 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  prdfPlatServices_common.C
 * @brief Wrapper code for external interfaces used by PRD.
 *
 * This file contains code that is strictly common between FSP and Hostboot. All
 * platform specific code should be in the respective FSP only or Hostboot only
 * files.
 */

#include <prdfPlatServices.H>

#include <prdfGlobal.H>
#include <prdfAssert.h>
#include <prdfTrace.H>
#include <prdfErrlUtil.H>

#include <dimmBadDqBitmapFuncs.H> // for dimm[S|G]etBadDqBitmap()
#include <dram_initialization/mss_memdiag/mss_maint_cmds.H>

using namespace TARGETING;

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

namespace PRDF
{

namespace PlatServices
{

//##############################################################################
//##                     Utility Functions (for this file only)
//##############################################################################

fapi::TargetType getFapiType( TARGETING::TargetHandle_t i_target )
{
    fapi::TargetType o_type = fapi::TARGET_TYPE_NONE;

    switch ( getTargetType(i_target) )
    {
        case TYPE_PROC:   o_type = fapi::TARGET_TYPE_PROC_CHIP;     break;
        case TYPE_EX:     o_type = fapi::TARGET_TYPE_EX_CHIPLET;    break;
        case TYPE_ABUS:   o_type = fapi::TARGET_TYPE_ABUS_ENDPOINT; break;
        case TYPE_XBUS:   o_type = fapi::TARGET_TYPE_XBUS_ENDPOINT; break;
        case TYPE_MCS:    o_type = fapi::TARGET_TYPE_MCS_CHIPLET;   break;
        case TYPE_MEMBUF: o_type = fapi::TARGET_TYPE_MEMBUF_CHIP;   break;
        case TYPE_MBA:    o_type = fapi::TARGET_TYPE_MBA_CHIPLET;   break;
        case TYPE_DIMM:   o_type = fapi::TARGET_TYPE_DIMM;          break;
        default: ;
    }

    return o_type;
}

//##############################################################################
//##                     System Level Utility Functions
//##############################################################################

void getECIDString( TargetHandle_t i_target, const char * o_ecidStr )
{
    o_ecidStr ="";
    PRDF_ERR( "[PlatServices::getECIDString] Function not implemented yet" );
}

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

fapi::Target getFapiTarget( TARGETING::TargetHandle_t i_target )
{
    return fapi::Target( getFapiType(i_target), i_target );
}


//##############################################################################
//##                       Processor specific functions
//##############################################################################

//##############################################################################
//##                        Memory specific functions
//##############################################################################

int32_t getBadDqBitmap( TargetHandle_t i_mbaTarget, const uint8_t i_portSlct,
                        const uint8_t i_dimmSlct, const uint8_t i_rankSlct,
                        uint8_t (&o_data)[DIMM_DQ_RANK_BITMAP_SIZE] )
{
    int32_t o_rc = SUCCESS;

    errlHndl_t errl = NULL;

    PRD_FAPI_TO_ERRL( errl, dimmGetBadDqBitmap, getFapiTarget(i_mbaTarget),
                      i_portSlct, i_dimmSlct, i_rankSlct, o_data );

    if ( NULL != errl )
    {
        PRDF_ERR( "[PlatServices::getBadDqBitmap] dimmGetBadDqBitmap() failed. "
                  "HUID: 0x%08x port: %d DIMM: %d rank: %d",
                  getHuid(i_mbaTarget), i_portSlct, i_dimmSlct, i_rankSlct );
        PRDF_COMMIT_ERRL( errl, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }

    return o_rc;
}

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

int32_t setBadDqBitmap( TargetHandle_t i_mbaTarget, const uint8_t i_portSlct,
                        const uint8_t i_dimmSlct, const uint8_t i_rankSlct,
                        const uint8_t (&i_data)[DIMM_DQ_RANK_BITMAP_SIZE] )
{
    int32_t o_rc = SUCCESS;

    errlHndl_t errl = NULL;

    PRD_FAPI_TO_ERRL( errl, dimmSetBadDqBitmap, getFapiTarget(i_mbaTarget),
                      i_portSlct, i_dimmSlct, i_rankSlct, i_data );

    if ( NULL != errl )
    {
        PRDF_ERR( "[PlatServices::getBadDqBitmap] dimmSetBadDqBitmap() failed. "
                  "HUID: 0x%08x ps: %d ds: %d rs: %d",
                  getHuid(i_mbaTarget), i_portSlct, i_dimmSlct, i_rankSlct );
        PRDF_COMMIT_ERRL( errl, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }

    return o_rc;
}

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

int32_t mssGetMarkStore( TargetHandle_t i_mbaTarget, uint8_t i_rank,
                         uint8_t & o_chipMark, uint8_t & o_symbolMark )
{
    int32_t o_rc = SUCCESS;

    errlHndl_t errl = NULL;

    PRD_FAPI_TO_ERRL( errl, mss_get_mark_store, getFapiTarget(i_mbaTarget),
                      i_rank, o_chipMark, o_symbolMark );

    if ( NULL != errl )
    {
        PRDF_ERR( "[PlatServices::mssGetMarkStore] mss_get_mark_store() "
                  "failed. HUID: 0x%08x rank: %d",
                  getHuid(i_mbaTarget), i_rank );
        PRDF_COMMIT_ERRL( errl, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }

    return o_rc;
}

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

int32_t mssSetMarkStore( TargetHandle_t i_mbaTarget, uint8_t i_rank,
                         uint8_t i_chipMark, uint8_t i_symbolMark )
{
    int32_t o_rc = SUCCESS;

    errlHndl_t errl = NULL;

    // TODO: mss_put_mark_store() will give a certain return code if the write
    //       to mark store was circumvented by hardware. Will need to check this
    //       return code.

    PRD_FAPI_TO_ERRL( errl, mss_put_mark_store, getFapiTarget(i_mbaTarget),
                      i_rank, i_chipMark, i_symbolMark );

    if ( NULL != errl )
    {
        PRDF_ERR( "[PlatServices::mssSetMarkStore] mss_put_mark_store() "
                  "failed. HUID: 0x%08x rank: %d cm: %d sm: %d",
                  getHuid(i_mbaTarget), i_rank, i_chipMark, i_symbolMark );
        PRDF_COMMIT_ERRL( errl, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }

    return o_rc;
}

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

int32_t mssGetSteerMux( TargetHandle_t i_mbaTarget, uint8_t i_rank,
                        uint8_t & o_port0Spare, uint8_t & o_port1Spare,
                        uint8_t & o_eccSpare )
{
    int32_t o_rc = SUCCESS;

/* TODO: Marc is creating a new interface.
    errlHndl_t errl = NULL;

    PRD_FAPI_TO_ERRL( errl, TODO, getFapiTarget(i_mbaTarget),
                      i_rank, o_port0Spare, o_port1Spare, o_eccSpare );

    if ( NULL != errl )
    {
        PRDF_ERR( "[PlatServices::mssGetSteerMux] TODO() "
                  "failed. HUID: 0x%08x rank: %d",
                  getHuid(i_mbaTarget), i_rank );
        PRDF_COMMIT_ERRL( errl, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }
*/

    return o_rc;

}

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

int32_t mssSetSteerMux( TargetHandle_t i_mbaTarget, uint8_t i_rank,
                        uint8_t i_symbol, bool i_x4EccSpare )
{
    int32_t o_rc = SUCCESS;

/* TODO: Marc is creating a new interface.
    errlHndl_t errl = NULL;

    PRD_FAPI_TO_ERRL( errl, TODO, getFapiTarget(i_mbaTarget),
                      i_rank, i_symbol, i_x4EccSpare );

    if ( NULL != errl )
    {
        PRDF_ERR( "[PlatServices::mssSetSteerMux] TODO() "
                  "failed. HUID: 0x%08x rank: %d symbol: %d eccSpare: %c",
                  getHuid(i_mbaTarget), i_rank, i_symbol,
                  i_x4EccSpare ? 'T' : 'F' );
        PRDF_COMMIT_ERRL( errl, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }
*/

    return o_rc;

}

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

/* TODO - Get the memory buffer raw card type (i.e. R/C A). This is needed for
          the DRAM site locations for buffered DIMMs. Should be able to get this
          from an attribute but doesn't look like this is available yet.
getMembufRawCardType()
{
}
*/

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

/* TODO - Get the type of the card a DIMM is plugged into. This is needed for
          the DRAM site locations for IS DIMMs. Should be able to get this from
          an attribute but doesn't look like this is available yet.
getDimmPlugCardType()
{
}
*/

//##############################################################################
//##                    Maintance Command class wrapper
//##############################################################################

mss_MaintCmdWrapper::mss_MaintCmdWrapper( mss_MaintCmd * i_maintCmd ) :
    iv_cmd(i_maintCmd)
{}

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

mss_MaintCmdWrapper::~mss_MaintCmdWrapper()
{
    delete iv_cmd;
}

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

int32_t mss_MaintCmdWrapper::stopCmd()
{
    PRDF_ASSERT( NULL != iv_cmd );
    int32_t o_rc = SUCCESS;
    fapi::ReturnCode l_rc = iv_cmd->stopCmd();

    //  convert FAPI RC to error handle
    errlHndl_t err = fapi::fapiRcToErrl(l_rc);

    if (NULL != err)
    {
        PRDF_GET_REASONCODE(err, o_rc);
        PRDF_ERR( "mss_MaintCmdWrapper::stopCmd failed: [0x%X]", o_rc);
        PRDF_COMMIT_ERRL( err, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }
    return o_rc;
}

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

int32_t mss_MaintCmdWrapper::setupAndExecuteCmd()
{
    PRDF_ASSERT( NULL != iv_cmd );
    int32_t o_rc = SUCCESS;
    fapi::ReturnCode l_rc = iv_cmd->setupAndExecuteCmd();

    //  convert FAPI RC to error handle
    errlHndl_t err = fapi::fapiRcToErrl(l_rc);

    if (NULL != err)
    {
        PRDF_GET_REASONCODE(err, o_rc);
        PRDF_ERR( "mss_MaintCmdWrapper::setupAndExecuteCmd "
                   "failed: [0x%X]", o_rc);
        PRDF_COMMIT_ERRL( err, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }
    return o_rc;
}

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

int32_t mss_MaintCmdWrapper::cleanupCmd()
{
    PRDF_ASSERT( NULL != iv_cmd );
    int32_t o_rc = SUCCESS;
    fapi::ReturnCode l_rc = iv_cmd->cleanupCmd();

    //  convert FAPI RC to error handle
    errlHndl_t err = fapi::fapiRcToErrl(l_rc);

    if (NULL != err)
    {
        PRDF_GET_REASONCODE(err, o_rc);
        PRDF_ERR( "mss_MaintCmdWrapper::cleanupCmd failed: [0x%X]", o_rc);
        PRDF_COMMIT_ERRL( err, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }
    return o_rc;
}

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

mss_MaintCmdWrapper * createTimeBaseScrub(
                        const TARGETING::TargetHandle_t i_mba,
                        uint64_t i_startAddr, uint64_t i_endAddr,
                        bool  i_isFastSpeed, uint32_t i_stopCondition )
{
    ecmdDataBufferBase ecmdStartAddr(64);
    ecmdDataBufferBase ecmdEndAddr(64);

    ecmdStartAddr.setDoubleWord(0, i_startAddr);
    ecmdEndAddr.setDoubleWord(0, i_endAddr);

    mss_MaintCmd::TimeBaseSpeed cmdSpeed = mss_MaintCmd::SLOW_12H;
    if ( i_isFastSpeed )
        cmdSpeed = mss_MaintCmd::FAST_AS_POSSIBLE;

    mss_MaintCmd * cmd = new mss_TimeBaseScrub( getFapiTarget(i_mba),
                                                ecmdStartAddr, ecmdEndAddr,
                                                cmdSpeed, i_stopCondition,
                                                false );

    mss_MaintCmdWrapper * cmdWrapper = new mss_MaintCmdWrapper(cmd);

    return cmdWrapper;
}

} // end namespace PlatServices

} // end namespace PRDF

OpenPOWER on IntegriCloud