summaryrefslogtreecommitdiffstats
path: root/src/include/usr/hwpf/hwp/dram_initialization/mss_memdiag/mss_maint_cmds.H
blob: c45791c18f4df47173d92b2241eeb7b0b5b456fd (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
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/include/usr/hwpf/hwp/dram_initialization/mss_memdiag/mss_maint_cmds.H $ */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2012                   */
/*                                                                        */
/* 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                                                     */
// $Id: mss_maint_cmds.H,v 1.14 2012/11/21 21:21:42 gollub Exp $
//------------------------------------------------------------------------------
// Don't forget to create CVS comments when you check in your changes!
//------------------------------------------------------------------------------
// CHANGE HISTORY:
//------------------------------------------------------------------------------
// Version:|   Date:  | Author: | Comment:
//---------|----------|---------|-----------------------------------------------
//         | 11/02/11 | gollub  | Created
//         | 11/15/11 | gollub  | Fixed some reg addresses
//         | 03/30/12 | gollub  | Made stop condition parm into a mask.
//         |          |         | Added support for both MBAs
//         | 04/25/12 | gollub  | Added doxygen tags 
//         | 05/23/12 | gollub  | Updates from review.
//         | 07/13/12 | gollub  | Updates from review.
//   1.7   | 07/16/12 | bellows | added in Id tag
//   1.8   | 07/18/12 | gollub  | Updates for timebase scrub.
//   1.9   | 08/15/12 | gollub  | Added stop condition enums
//         |          |         | STOP_IMMEDIATE
//         |          |         | ENABLE_CMD_COMPLETE_ATTENTION_ON_CLEAN_AND_ERROR
//         |          |         | Added iv_saved_MBA_WRD_MODE to allow 
//         |          |         | save/restore of setting for super fast read
//   1.10  | 09/07/12 | gollub  | Updates from review.
//         |          |         | Support for more patterns.
//   1.11  | 09/28/12 | gollub  | Added mss_restore_DRAM_repairs
//   1.12  | 11/02/12 | gollub  | Updates from review.  
//   1.13  | 11/08/12 | gollub  | Added timebase steer cleanup      
//   1.14  | 11/21/12 | gollub  | Updates from review.


#ifndef _MSS_MAINT_CMDS_H
#define _MSS_MAINT_CMDS_H

/** @file  mss_maint_cmds.H
 *  @brief General utility functions to for running maint cmds,  
 *         accessing markstore, and accessing steer muxes.
 */


//------------------------------------------------------------------------------
//  Includes
//------------------------------------------------------------------------------

#include <fapi.H>
#include <ecmdDataBufferBase.H>



//------------------------------------------------------------------------------
// Constants and enums
//------------------------------------------------------------------------------

/**
 * @brief Used to get addess range of all ranks from get_address_range()
 */
const uint8_t MSS_ALL_RANKS = 0xff;


/**
 * @brief Used to indicate invalid symbol
 */
const uint8_t MSS_INVALID_SYMBOL = 0xff;



namespace mss_SteerMux
{

/**
 * @brief Used to specify read or write steer mux
 */
    enum muxType
    {
        READ_MUX = 0,
        WRITE_MUX = 1,
    };

/**
 * @brief Used to specify steer type
 */
    enum steerType
    {
        DRAM_SPARE_PORT0 = 0,    // Spare DRAM on port0
        DRAM_SPARE_PORT1 = 1,    // Spare DRAM on port1
        ECC_SPARE = 2,           // ECC spare (used in x4 mode only)
    };
};



//------------------------------------------------------------------------------
// Parent class for all maintenance command types
//------------------------------------------------------------------------------

/**
 * @brief Contains functions common to multiple maint cmd types.
 */

class mss_MaintCmd
{

  public: // enums

    /**
     * @brief Index into array containing data patterns to load into memory
     */
    enum PatternIndex
    {
        PATTERN_0       = 0,  //0x00
        PATTERN_1       = 1,  //0xFF
        PATTERN_2       = 2,  //0xF0
        PATTERN_3       = 3,  //0x0F
        PATTERN_4       = 4,  //0xAA
        PATTERN_5       = 5,  //0x55
        PATTERN_6       = 6,  //0xCC
        PATTERN_7       = 7,  //0x33
        PATTERN_RANDOM  = 1,  // NOTE: Using PATTERN_1 as random seed
    };

    /**
     * @brief Inject type used for atomic error inject maint cmd
     */
    enum InjectType
    {
        ATOMIC_ALT_CE_INJ =         0,
        ATOMIC_ALT_CHIPKILL_INJ =   1,
        ATOMIC_ALT_UE_INJ =         2,
        ATOMIC_ALT_SUE_INJ =        3,
    };
    
    /**
     * @brief Stop conditions for maint cmds. 
     */
    enum StopCondition
    {    
        // Turn off all stop conditions
        NO_STOP_CONDITIONS =                 0x0000,
                
        // Stop immediately if stop on error condition hit
        STOP_IMMEDIATE =                     0x8000,

        // Stop at end of rank if stop on error condition hit
        STOP_END_OF_RANK =                   0x4000,
        
        // Stop on hard new CE error threshlold equal        
        STOP_ON_HARD_NCE_ETE =               0x2000,        
        
        // Stop on intermittent new CE error threshlold equal
        STOP_ON_INT_NCE_ETE =                0x1000,        
        
        // Stop on soft new CE error threshlold equal
        STOP_ON_SOFT_NCE_ETE =               0x0800,        
        
        // Stop on symbol corrected error (error on symbol already marked)
        STOP_ON_SCE =                        0x0400,        
        
        // Stop on mark corrected error (error on chip already marked)
        STOP_ON_MCE =                        0x0200,        
        
        // Stop on retry CE (UE that went away on retry)
        STOP_ON_RETRY_CE =                   0x0100,        
        
        // Stop on mark placed error (hw placed a chip mark)
        STOP_ON_MPE =                        0x0080,        
        
        // Stop on UE
        STOP_ON_UE =                         0x0040,        
        
        // Stop on SUE
        STOP_ON_SUE =                        0x0020,        
        
        // Stop when MBMACAQ = MBMEAQ
        STOP_ON_END_ADDRESS =                0x0010,        
        
        // Enable command complete attention
        ENABLE_CMD_COMPLETE_ATTENTION =      0x0008,        
        
        // Enable command complete attention for both stop clean, and stop
        // due to error
        ENABLE_CMD_COMPLETE_ATTENTION_ON_CLEAN_AND_ERROR = 0x0004,        

    };

    /**
     * @brief speed options for time base commands.
     */
    enum TimeBaseSpeed
    {    
        FAST_AS_POSSIBLE =                     0, 
        SLOW_12H =                             1,
    };


  protected:

    /**
     * @brief Maintenance command types
     */    
    enum CmdType
    {
        TIMEBASE_READ =                     0,
        TIMEBASE_SCRUB =                    1,
        TIMEBASE_STEER_CLEANUP =            2,
        TIMEBASE_INIT =                     3,
        TIMEBASE_RANDOM_INIT =              4,
    
        SUPERFAST_READ =                    8,
        SUPERFAST_INIT =                    9,
        SUPERFAST_RANDOM_INIT =             10,

        MEMORY_DISPLAY =                    16,
        MEMORY_ALTER =                      17,
        MEMORY_ALTER_WITH_ECC_OVERRIDE =    18,
        ATOMIC_ALTER_ERROR_INJECT =         19,
        INCREMENT_MBMACA_ADDRESS =          20,
    };



  public:
  
    /**
     * @brief Constructor
     *
     * @param i_target          MBA target
     * @param i_startAddr       Address cmd will start at
     * @param i_endAddr,        Address cmd will stop at
     * @param i_stopCondition   Mask of error conditions cmd should stop on
     * @param i_poll            Set to true if you wait for command to complete
     * @param i_cmdType         Command type
     */
    mss_MaintCmd( const fapi::Target & i_target,
                  const ecmdDataBufferBase & i_startAddr,
                  const ecmdDataBufferBase & i_endAddr,
                  uint32_t i_stopCondition,
                  bool i_poll,
                  CmdType i_cmdType );


    /**
     * @brief Destructor
     */
    virtual ~mss_MaintCmd() {}


    //----------------------------------------------------------------------
    // These are pure virtual functions that must be defined by every child 
    // class. 
    //----------------------------------------------------------------------

    /**
     * @brief  Stops running maint cmd, and saves the address it stopped at.
     * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise.
     * @note   NOT YET IMPLEMENTED     
     */
    virtual fapi::ReturnCode stopCmd() = 0;

    /**
     * @brief  Gets the cmd type of a given object
     * @return CmdType
     */
    virtual CmdType getCmdType() const = 0;



    //----------------------------------------------------------------------
    // These are virtual functions that will have a default definition in this 
    // class but can be overriden by a child class.
    //----------------------------------------------------------------------
        
    /**
     * @brief  Saves any settings that need to be restored when command is done.
     *         Loads the setup parameters into the hardware. Starts the command,
     *         then either polls for complete or exits with command running.
     * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise.     
     */
    virtual fapi::ReturnCode setupAndExecuteCmd();

    /**
     * @brief  Called once a command is done if we need to restore settings that
     *         had to be modified to run a specific command type, or clear error
     *         data in the hw that is no longer relevant.
     * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise.     
     * @note   NOT YET IMPLEMENTED     
     */
    virtual fapi::ReturnCode cleanupCmd();

  protected:
    //----------------------------------------------------------------------
    // These are virtual functions that will have a default definition in this 
    // class but can be overriden by a child class.
    //----------------------------------------------------------------------
    
    /**
     * @brief  Checks for valid hw state and setup required before a cmd is run.
     * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise.     
     */    
    virtual fapi::ReturnCode preConditionCheck();

    /**
     * @brief  Loads command type into hw.
     * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise.     
     */    
    virtual fapi::ReturnCode loadCmdType();
    
    /**
     * @brief  Loads start address into hw.
     * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise.     
     */    
    virtual fapi::ReturnCode loadStartAddress();

    /**
     * @brief  Loads end address into hw.
     * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise.     
     */    
    virtual fapi::ReturnCode loadEndAddress();
    
    /**
     * @brief  Loads stop conditions into hw.
     * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise.     
     */        
    virtual fapi::ReturnCode loadStopCondMask();
    
    /**
     * @brief  Starts command.
     * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise.     
     */    
    virtual fapi::ReturnCode startMaintCmd();
    
    /**
     * @brief  Polls for command complete.
     * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise.     
     */        
    virtual fapi::ReturnCode pollForMaintCmdComplete();

    /**
     * @brief  FOR DEBUG ONLY: Reads hw regs for FFDC after command is done.
     * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise.     
     */        
    virtual fapi::ReturnCode collectFFDC();
    
    /**
     * @brief  Loads pattern into hw.
     * @param  i_initPattern    Index into array containing patterns to load.
     * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise.
     * @note   For now, no array of pattens, just hardcoded pattern of all 0's.      
     */            
    virtual fapi::ReturnCode loadPattern(PatternIndex i_initPattern);
    
    /**
     * @brief  Loads timebase speed into hw.
     * @param  i_speed  FAST_AS_POSSIBLE or SLOW_12H
     * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise.
     */                
    virtual fapi::ReturnCode loadSpeed(TimeBaseSpeed i_speed);

    /**
     * @brief  Checks for hw to be right state after cmd is started.
     * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise.
     * @note   For now, no array of pattens, just hardcoded pattern of all 0's.      
     */                
    virtual fapi::ReturnCode postConditionCheck();
    
  protected:
  
    const fapi::Target iv_target;       // MBA
    fapi::Target iv_targetCentaur;      // Centaur associated with this MBA
    ecmdDataBufferBase iv_startAddr;    // Start address
    ecmdDataBufferBase iv_endAddr;      // End address
    uint32_t iv_stopCondition;          // Mask of stop contitions
    bool iv_poll;                       // Set true to wait for cmd complete
    const CmdType iv_cmdType;           // Command type
    uint8_t iv_mbaPosition;             // 0 = mba01, 1 = mba23



        
};

//------------------------------------------------------------------------------
// Child classes
//------------------------------------------------------------------------------


//------------------------------------------------------------------------------
// mss_SuperFastInit
//------------------------------------------------------------------------------
class mss_SuperFastInit : public mss_MaintCmd
{
  public:

    // Constructor
    mss_SuperFastInit( const fapi::Target & i_target,            // MBA target
                       const ecmdDataBufferBase & i_startAddr,   // Address cmd will start at
                       const ecmdDataBufferBase & i_endAddr,     // Address cmd will stop at
                       PatternIndex i_initPattern,               // Index into table containing patterns to load into memory
                       uint32_t i_stopCondition,                 // Mask of error conditions cmd should stop on
                       bool i_poll );                            // Set to true if you wait for command to complete

  public:

    fapi::ReturnCode setupAndExecuteCmd();
    fapi::ReturnCode stopCmd();
    CmdType getCmdType() const { return cv_cmdType; }

    // This class's implementation of parent class functions that can be 
    // overridden.
    fapi::ReturnCode cleanupCmd();

    void setStartAddr(ecmdDataBufferBase i_startAddr) 
    { iv_startAddr = i_startAddr; }
    
    void setEndAddr(  ecmdDataBufferBase i_endAddr  ) 
    { iv_endAddr   = i_endAddr;   }

    ecmdDataBufferBase getStartAddr() const { return iv_startAddr; }
    ecmdDataBufferBase getEndAddr()   const { return iv_endAddr; }

  private:

    fapi::ReturnCode setSavedData( uint32_t i_savedData ) 
    {fapi::ReturnCode l_rc; iv_savedData = i_savedData; return l_rc;}
    
    uint32_t getSavedData() { return iv_savedData; }

  private: // Class variable(s)

    static const CmdType cv_cmdType;

  private: // Instance variable(s)

    // List of things to save may be cmd-specific, so keep it here for now
    uint32_t iv_savedData; 
    // Index into table containing patterns to load into memory
    PatternIndex iv_initPattern; 

};


//------------------------------------------------------------------------------
// SuperFastRandomInit
//------------------------------------------------------------------------------
class mss_SuperFastRandomInit : public mss_MaintCmd
{
  public: // Constructor(s)

    // Constructor
    mss_SuperFastRandomInit( const fapi::Target & i_target,             // MBA target
                             const ecmdDataBufferBase & i_startAddr,    // Address cmd will start at
                             const ecmdDataBufferBase & i_endAddr,      // Address cmd will stop at
                             PatternIndex i_initPattern,                // Index into table containing pattern to use for random seed
                             uint32_t i_stopCondition,                  // Mask of error conditions cmd should stop on
                             bool i_poll );                             // Set to true if you wait for command to complete

  public:

    fapi::ReturnCode setupAndExecuteCmd();
    fapi::ReturnCode stopCmd();
    CmdType getCmdType() const { return cv_cmdType; }

    // This class's implementation of parent class functions that can be 
    // overridden.
    fapi::ReturnCode cleanupCmd();

    void setStartAddr(ecmdDataBufferBase i_startAddr) 
    { iv_startAddr = i_startAddr; }
    
    void setEndAddr(  ecmdDataBufferBase i_endAddr  ) 
    { iv_endAddr   = i_endAddr;   }

    ecmdDataBufferBase getStartAddr() const { return iv_startAddr; }
    ecmdDataBufferBase getEndAddr()   const { return iv_endAddr; }

  private:

    fapi::ReturnCode setSavedData( uint32_t i_savedData ) 
    {fapi::ReturnCode l_rc; iv_savedData = i_savedData; return l_rc;}
    
    uint32_t getSavedData() { return iv_savedData; }

  private: // Class variable(s)

    static const CmdType cv_cmdType;

  private: // Instance variable(s)

    // List of things to save may be cmd-specific, so keep it here for now
    uint32_t iv_savedData;
    // Index into table containing patterns to load into memory
    PatternIndex iv_initPattern; 
    // Setting that had to be restored when done
    ecmdDataBufferBase iv_saved_MBA_WRD_MODE; 

};



//------------------------------------------------------------------------------
// mss_SuperFastRead
//------------------------------------------------------------------------------
class mss_SuperFastRead : public mss_MaintCmd
{
  public: // Constructor(s)

    mss_SuperFastRead( const fapi::Target & i_target,            // MBA target
                       const ecmdDataBufferBase & i_startAddr,   // Address cmd will start at
                       const ecmdDataBufferBase & i_endAddr,     // Address cmd will stop at
                       uint32_t i_stopCondition,                 // Mask of error conditions cmd should stop on
                       bool i_poll );                            // Set to true if you wait for command to complete

  public:

    fapi::ReturnCode setupAndExecuteCmd();
    fapi::ReturnCode stopCmd();
    CmdType getCmdType() const { return cv_cmdType; }

    // This class's implementation of parent class functions that can be 
    // overridden.
    fapi::ReturnCode cleanupCmd();

    void setStartAddr(ecmdDataBufferBase i_startAddr) 
    { iv_startAddr = i_startAddr; }
    
    void setEndAddr(  ecmdDataBufferBase i_endAddr  ) 
    { iv_endAddr   = i_endAddr;   }

    ecmdDataBufferBase getStartAddr() const { return iv_startAddr; }
    ecmdDataBufferBase getEndAddr()   const { return iv_endAddr; }

  private:

    fapi::ReturnCode setSavedData( uint32_t i_savedData ) 
    {fapi::ReturnCode l_rc; iv_savedData = i_savedData; return l_rc; }
    
    uint32_t getSavedData() { return iv_savedData; }

  private: // Class variable(s)

    static const CmdType cv_cmdType;

  private: // Instance variable(s)

    // List of things to save may be cmd-specific, so keep it here for now
    uint32_t iv_savedData;
    // Setting that had to be restored when done
    ecmdDataBufferBase iv_saved_MBA_RRQ0; 
    
};



//------------------------------------------------------------------------------
// mss_AtomicInject
//------------------------------------------------------------------------------
class mss_AtomicInject : public mss_MaintCmd
{
  public: // Constructor(s)

    mss_AtomicInject( const fapi::Target & i_target,            // MBA target
                      const ecmdDataBufferBase & i_startAddr,   // Address to inject on
                      InjectType i_injectType);                 // Inject type



  public:

    fapi::ReturnCode setupAndExecuteCmd();
    fapi::ReturnCode stopCmd();
    CmdType getCmdType() const { return cv_cmdType; }

    void setStartAddr(ecmdDataBufferBase i_startAddr) 
    { iv_startAddr = i_startAddr; }

    ecmdDataBufferBase getStartAddr() const { return iv_startAddr; }
    
    void setInjectType(InjectType i_injectType) 
    { iv_injectType = i_injectType;   }


  private:
  
    fapi::ReturnCode setSavedData( uint32_t i_savedData ) 
    {fapi::ReturnCode l_rc; iv_savedData = i_savedData; return l_rc; }
    
    uint32_t getSavedData() { return iv_savedData; }

  private: // Class variable(s)

    static const CmdType cv_cmdType;

  private: // Instance variable(s)

    // List of things to save may be cmd-specific, so keep it here for now
    uint32_t iv_savedData;
    // Inject type
    InjectType iv_injectType; 
};


//------------------------------------------------------------------------------
// Display
//------------------------------------------------------------------------------
class mss_Display : public mss_MaintCmd
{
  public: // Constructor(s)

    mss_Display( const fapi::Target & i_target,            // MBA target
                 const ecmdDataBufferBase & i_startAddr ); // Address to display

  public: // Function declaration(s)

    fapi::ReturnCode setupAndExecuteCmd();
    fapi::ReturnCode stopCmd();
    CmdType getCmdType() const { return cv_cmdType; }

    void setStartAddr(const ecmdDataBufferBase & i_startAddr) 
    { iv_startAddr = i_startAddr; }

    ecmdDataBufferBase getStartAddr() const { return iv_startAddr; }


  private: 
  
    fapi::ReturnCode setSavedData( uint32_t i_savedData ) 
    {fapi::ReturnCode l_rc; iv_savedData = i_savedData; return l_rc; }
    
    uint32_t getSavedData() { return iv_savedData; }

  private: // Class variable(s)

    static const CmdType cv_cmdType;

  private: // Instance variable(s)

    // List of things to save may be cmd-specific, so keep it here for now
    uint32_t iv_savedData;
};



//------------------------------------------------------------------------------
// mss_IncrementAddress
//------------------------------------------------------------------------------
class mss_IncrementAddress : public mss_MaintCmd
{
  public: // Constructor(s)

    mss_IncrementAddress( const fapi::Target & i_target );    // MBA target

  public:

    fapi::ReturnCode setupAndExecuteCmd();
    fapi::ReturnCode stopCmd();
    CmdType getCmdType() const { return cv_cmdType; }

  private:

    static const CmdType cv_cmdType;
};


//------------------------------------------------------------------------------
// mss_TimeBaseScrub
//------------------------------------------------------------------------------
class mss_TimeBaseScrub : public mss_MaintCmd
{
  public: // Constructor(s)

    mss_TimeBaseScrub( const fapi::Target & i_target,           // MBA target
                       const ecmdDataBufferBase & i_startAddr,  // Address cmd will start at
                       const ecmdDataBufferBase & i_endAddr,    // Address cmd will stop at
                       TimeBaseSpeed i_speed,                   // Fast as possible, or slow (all memory on the MBA in 12h)
                       uint32_t i_stopCondition,                // Mask of error conditions cmd should stop on
                       bool i_poll );                           // Set to true if you wait for command to complete

  public:

    fapi::ReturnCode setupAndExecuteCmd();
    fapi::ReturnCode stopCmd();
    CmdType getCmdType() const { return cv_cmdType; }

    // This class's implementation of parent class functions that can be 
    // overridden.
    fapi::ReturnCode cleanupCmd();



    void setStartAddr(ecmdDataBufferBase i_startAddr) 
    { iv_startAddr = i_startAddr; }
    
    void setEndAddr(  ecmdDataBufferBase i_endAddr  ) 
    { iv_endAddr   = i_endAddr;   }

    ecmdDataBufferBase getStartAddr() const { return iv_startAddr; }
    ecmdDataBufferBase getEndAddr()   const { return iv_endAddr; }

  private:

    fapi::ReturnCode setSavedData( uint32_t i_savedData ) 
    {fapi::ReturnCode l_rc; iv_savedData = i_savedData; return l_rc; }
    
    uint32_t getSavedData() { return iv_savedData; }

  private: // Class variable(s)

    static const CmdType cv_cmdType;

  private: // Instance variable(s)

    // list of things to save may be specific to each cmd, so keep it 
    // here for now
    uint32_t iv_savedData;
    
    // Fast as possible, or slow (all memory on the MBA in 12h) 
    TimeBaseSpeed iv_speed; 
};


//------------------------------------------------------------------------------
// mss_TimeBaseSteerCleanup
//------------------------------------------------------------------------------
class mss_TimeBaseSteerCleanup : public mss_MaintCmd
{
  public: // Constructor(s)

    mss_TimeBaseSteerCleanup( const fapi::Target & i_target,    // MBA target
                       const ecmdDataBufferBase & i_startAddr,  // Address cmd will start at
                       const ecmdDataBufferBase & i_endAddr,    // Address cmd will stop at
                       TimeBaseSpeed i_speed,                   // TODO: fast for runtime, faster for ipl?
                       uint32_t i_stopCondition,                // Mask of error conditions cmd should stop on
                       bool i_poll );                           // Set to true if you wait for command to complete

  public:

    fapi::ReturnCode setupAndExecuteCmd();
    fapi::ReturnCode stopCmd();
    CmdType getCmdType() const { return cv_cmdType; }

    // This class's implementation of parent class functions that can be 
    // overridden.
    fapi::ReturnCode cleanupCmd();



    void setStartAddr(ecmdDataBufferBase i_startAddr) 
    { iv_startAddr = i_startAddr; }
    
    void setEndAddr(  ecmdDataBufferBase i_endAddr  ) 
    { iv_endAddr   = i_endAddr;   }

    ecmdDataBufferBase getStartAddr() const { return iv_startAddr; }
    ecmdDataBufferBase getEndAddr()   const { return iv_endAddr; }

  private:

    fapi::ReturnCode setSavedData( uint32_t i_savedData ) 
    {fapi::ReturnCode l_rc; iv_savedData = i_savedData; return l_rc; }
    
    uint32_t getSavedData() { return iv_savedData; }

  private: // Class variable(s)

    static const CmdType cv_cmdType;

  private: // Instance variable(s)

    // list of things to save may be specific to each cmd, so keep it 
    // here for now
    uint32_t iv_savedData;
    
    // TODO: Want as fast as possible, but IPL may be able to go faster than
    // runtime since no fetch traffic to worry about.
    TimeBaseSpeed iv_speed; 
};



//------------------------------------------------------------------------------
// Utility funcitons
//------------------------------------------------------------------------------


/**
 * @brief  Calculates start and end address for a single rank, or all ranks
 *         behind the MBA.
 *
 * @param  i_target       MBA target
 * @param  i_rank         Either single rank on the MBA to get start/end address
 *                        for (0x00-0x07)
 *                        Or MSS_ALL_RANKS = 0xff to get start/end address for 
 *                        all ranks behind the MBA.
 * @param  o_startAddr    Address to start cmd at.
 * @param  o_endAddr      Address to stop cmd at.
 * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise.
 */
fapi::ReturnCode mss_get_address_range( const fapi::Target & i_target,
                                        uint8_t i_rank,
                                        ecmdDataBufferBase & o_startAddr,
                                        ecmdDataBufferBase & o_endAddr );


/**
 * @brief  Mark store is implemented as one register per rank, so read register 
 *         for the given rank.
 *         If MPE FIR for the given rank (scrub or fetch) is on after the read, 
 *         we will read one more time to make sure we get latest.
 *
 * @param  i_target        MBA target
 * @param  i_rank          Rank to get markstore for.
 * @param  o_symbolMark    Symbol mark, converted from galois field to symbol 
 *                         index,(if no mark return 0xff)
 * @param  o_chipMark      Chip mark, converted from galois field to first 
 *                         symbol index of the chip, (if no mark return 0xff)
 * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise. 
 */
fapi::ReturnCode mss_get_mark_store( const fapi::Target & i_target,
                                     uint8_t i_rank,
                                     uint8_t & o_symbolMark,
                                     uint8_t & o_chipMark );


/**
 * @brief  Mark store is implemented as one register per rank, so write register
 *         for the given rank.  NOTE: Will be writing to both chip and symbol 
 *         field at same time, so should use a read/modify/write approach to 
 *         avoid unintentionally over-writing something.
 *
 * @param  i_target       MBA target
 * @param  i_rank         Rank to write markstore for.
 * @param  i_symbolMark   Symbol index, which will be converted to galois field
 *                        (if input is 0xff, we write 0x00 for no symbol mark).
 * @param  i_chipMark     First symbol index of the chip, which will be 
 *                        converted to galois field (if input is 0xff, we write
 *                        0x00 for no chip mark).
 * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise. 
 */
fapi::ReturnCode mss_put_mark_store( const fapi::Target & i_target,
                                     uint8_t i_rank,
                                     uint8_t i_symbolMark,
                                     uint8_t i_chipMark );
                                    

/**
 * @brief  Gets either the read or write steer mux control register for the 
 *         given rank, and converts from steer code to x8/x4 dram index to 
 *         first symbol index for all DRAMs steered on that rank. 
 *
 * @param  i_target                 MBA target
 * @param  i_rank                   Rank we want to read steer mux for.
 * @param  i_muxType                Select either the read mux or the write mux 
 *                                  to get.
 * @param  o_dramSparePort0Symbol   First symbol index of the DRAM fixed by the 
 *                                  spare on port0 (if no steer, return 0xff)
 * @param  o_dramSparePort1Symbol   First symbol index of the DRAM fixed by the
 *                                  spare on port1 (if no steer, return 0xff)
 * @param  o_eccSpareSymbol         First symbol index of the DRAM fixed by the
 *                                  ECC spare, which can be used on either port0
 *                                  or port1 (if no steer, return 0xff)
 * @note   The ECC spare is available only with x4 mode ECC.
 * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise. 
 */
fapi::ReturnCode mss_get_steer_mux( const fapi::Target & i_target,
                                    uint8_t i_rank,
                                    mss_SteerMux::muxType i_muxType,
                                    uint8_t & o_dramSparePort0Symbol,
                                    uint8_t & o_dramSparePort1Symbol,
                                    uint8_t & o_eccSpareSymbol );
                                    
/**
 * @brief  Updates either the read or write steer mux control register with the
 *         selected steer type for the given rank.
 *
 * @param  i_target                MBA target
 * @param  i_rank                  Rank we want to write steer mux for.
 * @param  i_muxType               Select either the read mux or the write mux 
 *                                 to update.
 * @param  i_steerType             0 = DRAM_SPARE_PORT0, Spare DRAM on port0
 *                                 1 = DRAM_SPARE_PORT1, Spare DRAM on port1
 *                                 2 = ECC_SPARE, ECC spare (used in x4 mode only)
 * @param  i_symbol                First symbol index of the DRAM to steer 
 *                                 around.
 * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise. 
 */
fapi::ReturnCode mss_put_steer_mux( const fapi::Target & i_target,
                                    uint8_t i_rank,
                                    mss_SteerMux::muxType i_muxType,
                                    uint8_t i_steerType,
                                    uint8_t i_symbol );




/**
 * @brief  This procedure applies the maximum possible DRAM repairs 
 *         (chip/symbol marks, DRAM steers) to known bad bits recorded in 
 *         DIMM VPD. This operation is done on both valid logical DIMM pairs
 *         behind the given MBA.
 *
 * @param  i_target                MBA target
 * @param  o_repairs_applied       8-bit mask, where a bit set means the
 *                                 specified rank had any repairs applied. 
 *
 *                       rank0 = 0x80 		(maps to port0_dimm0, port1_dimm0)
 *                       rank1 = 0x40 		(maps to port0_dimm0, port1_dimm0)
 *                       rank2 = 0x20 		(maps to port0_dimm0, port1_dimm0)
 *                       rank3 = 0x10 		(maps to port0_dimm0, port1_dimm0)
 *                       rank4 = 0x08 		(maps to port0_dimm1, port1_dimm1)
 *                       rank5 = 0x04 		(maps to port0_dimm1, port1_dimm1)
 *                       rank6 = 0x02 		(maps to port0_dimm1, port1_dimm1)
 *                       rank7 = 0x01 		(maps to port0_dimm1, port1_dimm1)
 *
 * @param  o_repairs_exceeded      4-bit mask, where a bit set means the 
 *                                 specified DIMM-select on the specified port
 *                                 had more bad bits than could be repaired.
 *
 *                        port0_dimm0 = 0x8
 *                        port0_dimm1 = 0x4
 *                        port1_dimm0 = 0x2
 *                        port1_dimm1 = 0x1
 *
 * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise. 
 */
fapi::ReturnCode mss_restore_DRAM_repairs( const fapi::Target & i_target,
                                           uint8_t & o_repairs_applied,
                                           uint8_t & o_repairs_exceeded);



/**
 * @brief  This function takes converts from a Centaur DQ on a given port
 *         to a corresponding symbol index.
 *
 * @param  i_dq     Centaur DQ from 0-71
 *
 * @param  i_port   port 0 or 1
 *
 * @return          Symbol index
 */

uint8_t mss_centaurDQ_to_symbol( uint8_t i_dq, uint8_t i_port );



#endif /* _MSS_MAINT_CMDS_H */
OpenPOWER on IntegriCloud