summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/framework/service/prdfPlatServices_common.C
blob: 20a4cdea8269e5aa2dffb4a1898a83b97f45082a (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
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
/* 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 <prdfCenAddress.H>
#include <prdfCenDqBitmap.H>
#include <prdfCenMarkstore.H>

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

#include <io_read_erepair.H>
#include <io_power_down_lanes.H>
#include <io_clear_firs.H>
#include <erepairAccessorHwpFuncs.H>
#include <io_fir_isolation.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, char * o_ecidStr )
{
    sprintf(o_ecidStr, "%s", "N/A");
    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
//##############################################################################

//##############################################################################
//##                       Lane Repair functions
//##############################################################################

int32_t readErepair(TargetHandle_t i_rxBusTgt,
                    std::vector<uint8_t> &o_rxFailLanes)
{
    int32_t o_rc = SUCCESS;
    errlHndl_t err = NULL;

    PRD_FAPI_TO_ERRL(err,
                     io_read_erepair,
                     getFapiTarget(i_rxBusTgt),
                     o_rxFailLanes);

     if(NULL != err)
    {
        PRDF_ERR( "[PlatServices::readErepair] HUID: 0x%08x io_read_erepair "
                  "failed", getHuid(i_rxBusTgt) );
        PRDF_COMMIT_ERRL( err, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }

    return o_rc;
}

int32_t clearIOFirs(TargetHandle_t i_rxBusTgt)
{
    int32_t o_rc = SUCCESS;
    errlHndl_t err = NULL;

    PRD_FAPI_TO_ERRL(err,
                     io_clear_firs,
                     getFapiTarget(i_rxBusTgt));

    if(NULL != err)
    {
        PRDF_ERR( "[PlatServices::clearIOFirs] HUID: 0x%08x io_clear_firs "
                  "failed", getHuid(i_rxBusTgt) );
        PRDF_COMMIT_ERRL( err, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }

    return o_rc;
}

int32_t powerDownLanes(TargetHandle_t i_rxBusTgt,
                       const std::vector<uint8_t> &i_rxFailLanes,
                       const std::vector<uint8_t> &i_txFailLanes)
{
    int32_t o_rc = SUCCESS;
    errlHndl_t err = NULL;

    PRD_FAPI_TO_ERRL(err,
                     io_power_down_lanes,
                     getFapiTarget(i_rxBusTgt),
                     i_txFailLanes,
                     i_rxFailLanes);

    if(NULL != err)
    {
        PRDF_ERR( "[PlatServices::powerDownLanes] HUID: 0x%08x "
                  "io_power_down_lanes failed", getHuid(i_rxBusTgt) );
        PRDF_COMMIT_ERRL( err, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }
    return o_rc;
}


int32_t getVpdFailedLanes(TargetHandle_t i_rxBusTgt,
                          std::vector<uint8_t> &o_rxFailLanes,
                          std::vector<uint8_t> &o_txFailLanes)
{
    int32_t o_rc = SUCCESS;
    errlHndl_t err = NULL;

    PRD_FAPI_TO_ERRL(err,
                     erepairGetFailedLanes,
                     getFapiTarget(i_rxBusTgt),
                     o_rxFailLanes,
                     o_txFailLanes);

    if(NULL != err)
    {
        PRDF_ERR( "[PlatServices::getVpdFailedLanes] HUID: 0x%08x "
                  "erepairGetFailedLanes failed",
                  getHuid(i_rxBusTgt));
        PRDF_COMMIT_ERRL( err, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }
    return o_rc;
}

int32_t setVpdFailedLanes(TargetHandle_t i_rxBusTgt,
                          TargetHandle_t i_txBusTgt,
                          std::vector<uint8_t> &i_rxFailLanes,
                          bool & o_thrExceeded)
{
    int32_t o_rc = SUCCESS;
    errlHndl_t err = NULL;

    PRD_FAPI_TO_ERRL(err,
                    erepairSetFailedLanes,
                    getFapiTarget(i_txBusTgt),
                    getFapiTarget(i_rxBusTgt),
                    i_rxFailLanes,
                    o_thrExceeded);
    if(NULL != err)
    {
        PRDF_ERR( "[PlatServices::setVpdFailedLanes] rxHUID: 0x%08x "
                  "txHUID: 0x%08x erepairSetFailedLanes failed",
                  getHuid(i_rxBusTgt), getHuid(i_txBusTgt));
        PRDF_COMMIT_ERRL( err, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }
    return o_rc;
}

int32_t erepairFirIsolation(TargetHandle_t i_rxBusTgt)
{
    errlHndl_t err = NULL;

    PRD_FAPI_TO_ERRL(err, io_fir_isolation, getFapiTarget(i_rxBusTgt));

    if(NULL != err)
    {
        PRDF_TRAC( "[PlatServices::setVpdFailedLanes] rxHUID: 0x%08x "
                  "committing io_fir_isolation log",
                  getHuid(i_rxBusTgt));
        PRDF_COMMIT_ERRL( err, ERRL_ACTION_REPORT );
    }

    // Return SUCCESS since we expect this procedure to generate an error
    return SUCCESS;
}
//##############################################################################
//##                        Memory specific functions
//##############################################################################

int32_t getBadDqBitmap( TargetHandle_t i_mba, const CenRank & i_rank,
                        CenDqBitmap & o_bitmap )
{
    #define PRDF_FUNC "[PlatServices::getBadDqBitmap] "

    int32_t o_rc = SUCCESS;

    uint8_t data[PORT_SLCT_PER_MBA][DIMM_DQ_RANK_BITMAP_SIZE];

    for ( int32_t ps = 0; ps < PORT_SLCT_PER_MBA; ps++ )
    {
        errlHndl_t errl = NULL;
        PRD_FAPI_TO_ERRL( errl, dimmGetBadDqBitmap, getFapiTarget(i_mba),
                          ps, i_rank.getDimmSlct(), i_rank.getRankSlct(),
                          data[ps] );
        if ( NULL != errl )
        {
            PRDF_ERR( PRDF_FUNC"dimmGetBadDqBitmap() failed: MBA=0x%08x "
                      "ps=%d ds=%d rs=%d", getHuid(i_mba), ps,
                      i_rank.getDimmSlct(), i_rank.getRankSlct() );
            PRDF_COMMIT_ERRL( errl, ERRL_ACTION_REPORT );
            o_rc = FAIL; break;
        }
    }

    if ( SUCCESS == o_rc )
    {
        o_bitmap = CenDqBitmap ( i_mba, i_rank, data );
    }

    return o_rc;

    #undef PRDF_FUNC
}

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

int32_t setBadDqBitmap( TargetHandle_t i_mba, const CenRank & i_rank,
                        const CenDqBitmap & i_bitmap )
{
    #define PRDF_FUNC "[PlatServices::setBadDqBitmap] "

    int32_t o_rc = SUCCESS;

    const uint8_t (&data)[PORT_SLCT_PER_MBA][DIMM_DQ_RANK_BITMAP_SIZE]
                                                        = i_bitmap.getData();

    for ( int32_t ps = 0; ps < PORT_SLCT_PER_MBA; ps++ )
    {
        errlHndl_t errl = NULL;
        PRD_FAPI_TO_ERRL( errl, dimmSetBadDqBitmap, getFapiTarget(i_mba),
                          ps, i_rank.getDimmSlct(), i_rank.getRankSlct(),
                          data[ps] );
        if ( NULL != errl )
        {
            PRDF_ERR( PRDF_FUNC"dimmSetBadDqBitmap() failed: MBA=0x%08x "
                      "ps=%d ds=%d rs=%d", getHuid(i_mba), ps,
                      i_rank.getDimmSlct(), i_rank.getRankSlct() );
            PRDF_COMMIT_ERRL( errl, ERRL_ACTION_REPORT );
            o_rc = FAIL;
        }
    }

    return o_rc;

    #undef PRDF_FUNC
}

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

int32_t mssGetMarkStore( TargetHandle_t i_mba, const CenRank & i_rank,
                         CenMark & o_mark )
{
    int32_t o_rc = SUCCESS;

    errlHndl_t errl = NULL;

    uint8_t symbolMark, chipMark;
    PRD_FAPI_TO_ERRL( errl, mss_get_mark_store, getFapiTarget(i_mba),
                      i_rank.flatten(), symbolMark, chipMark );

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

    return o_rc;
}

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

int32_t mssSetMarkStore( TargetHandle_t i_mba, const CenRank & i_rank,
                         const CenMark & i_mark, bool & o_writeBlocked,
                         bool i_allowWriteBlocked )
{
    #define PRDF_FUNC "[PlatServices::mssSetMarkStore] "

    int32_t o_rc = SUCCESS;

    errlHndl_t errl = NULL;

    uint8_t symbolMark = i_mark.getSM().isValid() ? i_mark.getSM().getSymbol()
                                                  : MSS_INVALID_SYMBOL;
    uint8_t chipMark   = i_mark.getCM().isValid() ? i_mark.getCM().getSymbol()
                                                  : MSS_INVALID_SYMBOL;

    fapi::ReturnCode l_rc = mss_put_mark_store( getFapiTarget(i_mba),
                                                i_rank.flatten(), symbolMark,
                                                chipMark );

    if ( i_allowWriteBlocked &&
         fapi::RC_MSS_MAINT_MARKSTORE_WRITE_BLOCKED == l_rc )
    {
        o_writeBlocked = true;
    }
    else
    {
        errl = fapi::fapiRcToErrl(l_rc);
        if ( NULL != errl )
        {
            PRDF_ERR( PRDF_FUNC"mss_put_mark_store() failed. HUID: 0x%08x "
                      "rank: %d sm: %d cm: %d", getHuid(i_mba),
                      i_rank.flatten(), symbolMark, chipMark );
            PRDF_COMMIT_ERRL( errl, ERRL_ACTION_REPORT );
            o_rc = FAIL;
        }
    }

    return o_rc;

    #undef PRDF_FUNC
}

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

int32_t mssGetSteerMux( TargetHandle_t i_mba, const CenRank & i_rank,
                        CenSymbol & o_port0Spare, CenSymbol & o_port1Spare,
                        CenSymbol & o_eccSpare )
{
    int32_t o_rc = SUCCESS;

    errlHndl_t errl = NULL;

    uint8_t port0Spare, port1Spare, eccSpare;
    PRD_FAPI_TO_ERRL( errl, mss_check_steering, getFapiTarget(i_mba),
                      i_rank.flatten(), port0Spare, port1Spare, eccSpare );

    if ( NULL != errl )
    {
        PRDF_ERR( "[PlatServices::mssGetSteerMux] mss_check_steering() "
                  "failed. HUID: 0x%08x rank: %d",
                  getHuid(i_mba), i_rank.flatten() );
        PRDF_COMMIT_ERRL( errl, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }
    else
    {
        o_port0Spare = CenSymbol::fromSymbol( i_mba, i_rank, port0Spare );
        o_port1Spare = CenSymbol::fromSymbol( i_mba, i_rank, port1Spare );
        o_eccSpare   = CenSymbol::fromSymbol( i_mba, i_rank, eccSpare   );
    }

    return o_rc;
}

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

int32_t mssSetSteerMux( TargetHandle_t i_mba, const CenRank & i_rank,
                        const CenSymbol & i_symbol, bool i_x4EccSpare )
{
    int32_t o_rc = SUCCESS;

    errlHndl_t errl = NULL;

    PRD_FAPI_TO_ERRL( errl, mss_do_steering, getFapiTarget(i_mba),
                      i_rank.flatten(), i_symbol.getSymbol(), i_x4EccSpare );

    if ( NULL != errl )
    {
        PRDF_ERR( "[PlatServices::mssSetSteerMux] mss_do_steering "
                  "failed. HUID: 0x%08x rank: %d symbol: %d eccSpare: %c",
                  getHuid(i_mba), i_rank.flatten(), i_symbol.getSymbol(),
                  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::setupAndExecuteCmd()
{
    #define PRDF_FUNC "[mss_MaintCmdWrapper::setupAndExecuteCmd] "

    int32_t o_rc = SUCCESS;

    fapi::ReturnCode l_rc = iv_cmd->setupAndExecuteCmd();
    errlHndl_t errl = fapi::fapiRcToErrl( l_rc );
    if ( NULL != errl )
    {
        PRDF_GET_REASONCODE( errl, o_rc );
        PRDF_ERR( PRDF_FUNC"setupAndExecuteCmd() failed: rc=0x%x", o_rc );
        PRDF_COMMIT_ERRL( errl, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }

    return o_rc;

    #undef PRDF_FUNC
}

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

int32_t mss_MaintCmdWrapper::stopCmd()
{
    #define PRDF_FUNC "[mss_MaintCmdWrapper::stopCmd] "

    int32_t o_rc = SUCCESS;

    fapi::ReturnCode l_rc = iv_cmd->stopCmd();
    errlHndl_t errl = fapi::fapiRcToErrl( l_rc );
    if ( NULL != errl )
    {
        PRDF_GET_REASONCODE( errl, o_rc );
        PRDF_ERR( PRDF_FUNC"stopCmd() failed: rc=0x%x", o_rc );
        PRDF_COMMIT_ERRL( errl, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }

    return o_rc;

    #undef PRDF_FUNC
}

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

int32_t mss_MaintCmdWrapper::cleanupCmd()
{
    #define PRDF_FUNC "[mss_MaintCmdWrapper::cleanupCmd] "

    int32_t o_rc = SUCCESS;

    fapi::ReturnCode l_rc = iv_cmd->cleanupCmd();
    errlHndl_t errl = fapi::fapiRcToErrl( l_rc );
    if ( NULL != errl )
    {
        PRDF_GET_REASONCODE( errl, o_rc );
        PRDF_ERR( PRDF_FUNC"cleanupCmd() failed: rc=0x%x", o_rc );
        PRDF_COMMIT_ERRL( errl, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }

    return o_rc;

    #undef PRDF_FUNC
}

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

// Helper function for the createMssCmd() functions.
int32_t getMemAddrRange( TargetHandle_t i_mba, uint8_t i_rank,
                         ecmdDataBufferBase & o_startAddr,
                         ecmdDataBufferBase & o_endAddr )
{
    #define PRDF_FUNC "[PlatServices::getMemAddrRange] "

    int32_t o_rc = SUCCESS;

    do
    {
        // Check parameters.
        if ( TYPE_MBA != getTargetType(i_mba) )
        {
            PRDF_ERR( PRDF_FUNC"The given target is not TYPE_MBA" );
            o_rc = FAIL; break;
        }

        if ( MSS_ALL_RANKS != i_rank && MAX_RANKS_PER_MBA <= i_rank )
        {
            PRDF_ERR( PRDF_FUNC"The given rank is not valid" );
            o_rc = FAIL; break;
        }

        errlHndl_t errl = NULL;
        PRD_FAPI_TO_ERRL( errl, mss_get_address_range, getFapiTarget(i_mba),
                          i_rank, o_startAddr, o_endAddr );
        if ( NULL != errl )
        {
            PRDF_ERR( PRDF_FUNC"mss_get_address_range() failed" );
            PRDF_COMMIT_ERRL( errl, ERRL_ACTION_REPORT );
            o_rc = FAIL; break;
        }

        // Verify addresses are of the valid register size.
        if ( 64 != o_startAddr.getBitLength() ||
             64 != o_endAddr.getBitLength() )
        {
            PRDF_ERR( PRDF_FUNC"Addresses returned from "
                      "mss_get_address_range() are not 64-bit" );
            o_rc = FAIL; break;
        }

    } while (0);

    if ( SUCCESS != o_rc )
    {
        PRDF_ERR( PRDF_FUNC"Failed: 0x%08x 0x%02x", getHuid(i_mba), i_rank );
    }

    return o_rc;

    #undef PRDF_FUNC
}

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

// Helper function for the other createMssCmd() functions.
mss_MaintCmdWrapper * createMssCmd( mss_MaintCmdWrapper::CmdType i_cmdType,
                                    TargetHandle_t i_mba, uint32_t i_stopCond,
                                    bool i_isFastSpeed,
                                    ecmdDataBufferBase i_startAddr,
                                    ecmdDataBufferBase i_endAddr )
{
    #define PRDF_FUNC "[PlatServices::getMssCmd] "

    mss_MaintCmdWrapper * o_cmd = NULL;

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

    mss_MaintCmd * cmd = NULL;

    switch ( i_cmdType )
    {
        case mss_MaintCmdWrapper::TIMEBASE_SCRUB:
            cmd = new mss_TimeBaseScrub( getFapiTarget(i_mba), i_startAddr,
                                         i_endAddr, cmdSpeed, i_stopCond,
                                         false );
            break;
        case mss_MaintCmdWrapper::TIMEBASE_STEER_CLEANUP:
            cmd = new mss_TimeBaseSteerCleanup( getFapiTarget(i_mba),
                                                i_startAddr, i_endAddr,
                                                cmdSpeed, i_stopCond, false );
            break;
        case mss_MaintCmdWrapper::SUPERFAST_READ:
            cmd = new mss_SuperFastRead( getFapiTarget(i_mba), i_startAddr,
                                         i_endAddr, i_stopCond, false );
            break;
        default:
            PRDF_ERR( PRDF_FUNC"Unsupported command type: 0x%x", i_cmdType );
    }

    if ( NULL != cmd )
        o_cmd = new mss_MaintCmdWrapper(cmd);

    return o_cmd;

    #undef PRDF_FUNC
}

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

mss_MaintCmdWrapper * createMssCmd( mss_MaintCmdWrapper::CmdType i_cmdType,
                                    TargetHandle_t i_mba, uint32_t i_stopCond,
                                    bool i_isFastSpeed )
{
    mss_MaintCmdWrapper * o_cmd = NULL;

    ecmdDataBufferBase sAddr(64), eAddr(64);
    int32_t l_rc = getMemAddrRange( i_mba, MSS_ALL_RANKS, sAddr, eAddr );
    if ( SUCCESS == l_rc )
    {
        o_cmd = createMssCmd( i_cmdType, i_mba, i_stopCond, i_isFastSpeed,
                              sAddr, eAddr );
    }

    return o_cmd;
}

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

mss_MaintCmdWrapper * createMssCmd( mss_MaintCmdWrapper::CmdType i_cmdType,
                                    TargetHandle_t i_mba, uint32_t i_stopCond,
                                    bool i_isFastSpeed, const CenRank & i_rank )
{
    mss_MaintCmdWrapper * o_cmd = NULL;

    ecmdDataBufferBase sAddr(64), eAddr(64);
    int32_t l_rc = getMemAddrRange( i_mba, i_rank.flatten(), sAddr, eAddr );
    if ( SUCCESS == l_rc )
    {
        o_cmd = createMssCmd( i_cmdType, i_mba, i_stopCond, i_isFastSpeed,
                              sAddr, eAddr );
    }

    return o_cmd;
}

} // end namespace PlatServices

} // end namespace PRDF

OpenPOWER on IntegriCloud