summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/framework/register/iipResetErrorRegister.h
blob: 18c16a32af213d307b0ee513069fbd9da94ababb (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/framework/register/iipResetErrorRegister.h $ */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 1996,2014              */
/*                                                                        */
/* 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                                                     */

#ifndef iipResetErrorRegister_h
#define iipResetErrorRegister_h

/**
 @file iipResetErrorRegister.h
 @brief ResetErrorRegister declaration
*/

// Class Description *************************************************
//
//  Name:  ResetErrorRegister
//  Base class: ErrorRegisterMask
//
//  Description: Reset the error register after analysis by turning off
//               the bits in the SCR that were used for the analysis
//  Usage: Initialization
//   ScanCommRegisterChip scr1(...), scr2(...);
//   ResolutionMap rm(...);
//     *** Reset SCR same as One used to read error reg ***
//   ErrorRegister * er = new ResetErrorRegister(scr1,rm);
//
//     *** Reset SCR different from one used to read error reg ***
//   ErrorRegister * er1 = new ResetErrorRegister(scr1,rm,scr2);
//
//     *** Using a Filter ****
//  FilterClass * f =  new PriorityFilter(...);
//  ErrorRegister * er = new ResetErrorRegister(scr1,rm,f);
//  ErrorRegister *er1 = new ResetErrorRegister(scr1,rm,scr2,f);
//
//  Regular usage same as ErrorRegister
//
//  RESET:
//     if scr2 is not given then turn off bits in scr1 specified by bit_list
//             and scr1.Write();
//     if scr2 then copy bitlist from scr1 to scr2 then set off bits
//                  in scr2 specified by bit_list  then scr2.Write();
//
// End Class Description *********************************************
//--------------------------------------------------------------------
// Includes
//--------------------------------------------------------------------

#ifndef iipErrorRegisterMask_h
#include <iipErrorRegisterMask.h>
#endif

#include <vector>
#include <prdfResetOperators.H>

namespace PRDF
{

//--------------------------------------------------------------------
//  Forward References
//--------------------------------------------------------------------

class ResetErrorRegister : public ErrorRegisterMask
{
public:
  /**
   Constructor
   <ul>
   <br><b>Parameter:   </b> Scan comm register associated with the error register
   <br><b>Parameter:   </b> ResolutionMap
   <br><b>Parameter:   </b> Optional filter
   <br><b>Parameter:   </b> Optional scrId - to use in the error signature
   <br><b>Notes:       </b> If no scrId is provided than the address of the scan comm register is used
   </ul><br>
   */
  ResetErrorRegister(SCAN_COMM_REGISTER_CLASS & r, ResolutionMap & rm, FILTER_CLASS * f = NULL, uint16_t scrID = 0x0fff, SCAN_COMM_REGISTER_CLASS & maskScr = *((SCAN_COMM_REGISTER_CLASS *) NULL));

  /**
   Constructor
   <ul>
   <br><b>Parameter:   </b> Scan comm register associated with the error register
   <br><b>Parameter:   </b> ResolutionMap
   <br><b>Parameter:   </b> scrId - used in the error signature
   <br><b>Notes:       </b> If no scrId is provided than the address of the scan comm register is used
   </ul><br>
   */
  ResetErrorRegister(SCAN_COMM_REGISTER_CLASS & r, ResolutionMap & rm, uint16_t scrID, SCAN_COMM_REGISTER_CLASS & maskScr = *((SCAN_COMM_REGISTER_CLASS *) NULL));

  /**
   Constructor - Where scan comm register to read is different from the scan comm register to write to reset
   <ul>
   <br><b>Parameter:   </b> Scan comm register associated with the error register
   <br><b>Parameter:   </b> ResolutionMap
   <br><b>Parameter:   </b> Scan comm register to write to reset the error
   <br><b>Parameter:   </b> Optional filter
   <br><b>Parameter:   </b> Optional scrId - to use in the error signature
   <br><b>Notes:       </b> If no scrId is provided than the address of the scan comm register is used
   </ul><br>
   */
  ResetErrorRegister(SCAN_COMM_REGISTER_CLASS & r, ResolutionMap & rm, SCAN_COMM_REGISTER_CLASS & reset, FILTER_CLASS * f = NULL, uint16_t scrID = 0x0fff);

  /**
   Constructor - Where scan comm register to read is different from the scan comm register to write to reset
   <ul>
   <br><b>Parameter:   </b> Scan comm register associated with the error register
   <br><b>Parameter:   </b> ResolutionMap
   <br><b>Parameter:   </b> Scan comm register to write to reset the error
   <br><b>Parameter:   </b> scrId - to use in the error signature
   <br><b>Notes:       </b> If no scrId is provided than the address of the scan comm register is used
   </ul><br>
   */
  ResetErrorRegister(SCAN_COMM_REGISTER_CLASS & r, ResolutionMap & rm, SCAN_COMM_REGISTER_CLASS & reset, uint16_t scrID);

  // Function Specification ********************************************
  //
  // Purpose:      Destruction
  // Parameters:   None.
  // Returns:      No value returned
  // Requirements: None.
  // Promises:     None.
  // Exceptions:   None.
  // Concurrency:  Reentrant
  // Notes:        Compiler default is sufficient
  //
  // End Function Specification ****************************************
  //~ResetErrorRegister();

protected:  // functions

  /**
   Reset the error register and set mask bit if sdc is at theshold
   <ul>
   <br><b>Parameters:  </b> BitList
   <br><b>Returns:     </b> return code
   <br><b>Requirements:</b> Filter()
   <br><b>Promises:    </b> bitStringMask bit(s) set if error.service_data->IsAtThreshold()
                            Hardware modified
   <br><b>Exceptions:  </b> None
   <br><b>Notes:       </b> Zeros written to hardware
   </ul><br>
   */
  virtual int32_t Reset(const BIT_LIST_CLASS & bit_list, STEP_CODE_DATA_STRUCT & error);

private: // functions

  /** Copy prohibited */
  ResetErrorRegister(const ResetErrorRegister & er);
  /** Assignment prohibited */
  ResetErrorRegister & operator=(const ResetErrorRegister & er);

private:  // Data

  SCAN_COMM_REGISTER_CLASS * resetScr;

};


inline
ResetErrorRegister::ResetErrorRegister(SCAN_COMM_REGISTER_CLASS & r,
                                       ResolutionMap & rm,
                                       FILTER_CLASS * f,
                                       uint16_t scrId,
                                       SCAN_COMM_REGISTER_CLASS & maskScr)
: ErrorRegisterMask(r,rm,f,scrId,maskScr), resetScr(&r)
{}

inline
ResetErrorRegister::ResetErrorRegister(SCAN_COMM_REGISTER_CLASS & r,
                                       ResolutionMap & rm,
                                       SCAN_COMM_REGISTER_CLASS & reset,
                                       FILTER_CLASS * f,
                                       uint16_t scrId)
: ErrorRegisterMask(r,rm,f,scrId), resetScr(&reset)
{}

inline
ResetErrorRegister::ResetErrorRegister(SCAN_COMM_REGISTER_CLASS & r,
                                       ResolutionMap & rm,
                                       uint16_t scrId,
                                       SCAN_COMM_REGISTER_CLASS & maskScr)
: ErrorRegisterMask(r,rm,scrId,maskScr), resetScr(&r)
{}

inline
ResetErrorRegister::ResetErrorRegister(SCAN_COMM_REGISTER_CLASS & r,
                                       ResolutionMap & rm,
                                       SCAN_COMM_REGISTER_CLASS & reset,
                                       uint16_t scrId)
: ErrorRegisterMask(r,rm,scrId), resetScr(&reset)
{}


/**
 * @class ResetAndMaskErrorRegister
 * ErrorRegister to reset and mask errors.
 *
 * Similar to ResetErrorRegister, but adds mask capability and multiple
 * reset/mask registers.
 *
 * Will do masking if isAtThreshold().
 * Always does resets.  (TODO: Should this be done only on recov?)
 */
class ResetAndMaskErrorRegister : public ErrorRegisterMask
{
    public:
        /**
         * @struct ResetRegisterStruct
         * Stores information required to do reset/mask.
         */
        struct ResetRegisterStruct
        {
            RegisterResetOperator * op;
            SCAN_COMM_REGISTER_CLASS * read;
            SCAN_COMM_REGISTER_CLASS * write;

            bool operator<(const ResetRegisterStruct & rhs) const
            {
                if (this->op != rhs.op)
                    return (this->op < rhs.op);
                else if (this->read != rhs.read)
                    return (this->read < rhs.read);
                else
                    return (this->write < rhs.write);
            };

            bool operator==(const ResetRegisterStruct & rhs) const
            {
                return (this->op == rhs.op) &&
                       (this->read == rhs.read) &&
                       (this->write == rhs.write);
            };
        };

        typedef std::vector<ResetRegisterStruct> ResetRegisterVector;

    public:
        /**
         * Constructor
         * @param r : Register for error isolation.
         * @param rm : Resolution map for error.
         * @param f : Register filter.
         * @param scrId : ScanComm register ID.
         */
        ResetAndMaskErrorRegister(SCAN_COMM_REGISTER_CLASS & r,
                                  ResolutionMap & rm,
                                  FILTER_CLASS * f = NULL,
                                  uint16_t scrId = 0x0fff)
            : ErrorRegisterMask(r, rm, f, scrId), cv_resets(), cv_masks() {};

        /**
         * Constructor
         * @param r : Register for error isolation.
         * @param rm : Resolution map for error.
         * @param scrId : ScanComm register ID.
         */
        ResetAndMaskErrorRegister(SCAN_COMM_REGISTER_CLASS & r,
                                  ResolutionMap & rm,
                                  uint16_t scrId = 0x0fff)
            : ErrorRegisterMask(r, rm, scrId), cv_resets(), cv_masks() {};

        /**
         * Add additional reset register to list.
         */
        void addReset(ResetRegisterStruct i_reset)
                { cv_resets.push_back(i_reset); };

        /**
         * Add additional mask register to list.
         */
        void addMask(ResetRegisterStruct i_mask)
                { cv_masks.push_back(i_mask); };

    protected:
        /**
         * Reset/Mask error after error isolation.
         *
         * @param bl : bit list of errors detected.
         * @param sdc : current STEP_CODE.
         */
        virtual int32_t Reset(const BIT_LIST_CLASS & bl,
                              STEP_CODE_DATA_STRUCT & sdc);

    private:
        // prohibit copy, assignment.
        ResetAndMaskErrorRegister(const ResetAndMaskErrorRegister &);
        ResetAndMaskErrorRegister& operator=(const ResetAndMaskErrorRegister&);

    private:

        /**
         * List of resets.
         */
        ResetRegisterVector cv_resets;
        /**
         * List of masks.
         */
        ResetRegisterVector cv_masks;
};

} // end namespace PRDF

#endif /* iipResetErrorRegister_h */
OpenPOWER on IntegriCloud