summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/framework/resolution/prdfResolutionMap.H
blob: 77ca2e04d4904a3a8d3375d8028e73161eb79390 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/framework/resolution/prdfResolutionMap.H $ */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2004,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                                                     */

/*! /file prdfResolutionMap.H
 *  /brief Map Bit List encodings to Resolutions
 */
#ifndef ResolutionMap_h
#define ResolutionMap_h
//--------------------------------------------------------------------
// Includes
//--------------------------------------------------------------------

#include <vector>
#include <prdfBitKey.H>
#include <prdfResolutionList.H>
#include <prdfFilters.H>

namespace PRDF
{

//--------------------------------------------------------------------
//  Forward References
//--------------------------------------------------------------------
struct STEP_CODE_DATA_STRUCT;   //dg04c
//! ResolutionMap
/*!
 This class prvodes mapping of a bitList key to a resolution list
 @code
 Callout callout = { PU0_HIGH , MSCTLR0_HIGH } ;
 FinalResolution default_resolution(&callout);
 FinalResolution error_type1(&callout);
 ResolutionMap Resolutions(expected_size=10,&default_resolution);
 Resolutions.Add(BIT_LIST_STRING_15,&error_type1); // Add resolution for error bit 15
 //...
 foo(ScanCommRegister *scr, ResolutionMap &rm, STEP_CODE_DATA_STRUCT & error_data)
 {
    scr->Read();
    BIT_LIST_CLASS bl = *scr->GetBitString();
    Resolution & r = rm.LookUp(bl);
    r.Resolve(error_data);
 }
 @endcode
*/
class ResolutionMap
{
public:
  /**
   Constructor
   @param entryCount expected (estimated) number of entries
   @param defaultResolution Resolution of use if LookUp failes
   @param ptr to a filter to apply to the bitKey before it is looked up
   @pre None
   @post Object created & space reserved
   */
  ResolutionMap(int32_t entryCount, Resolution &defaultResolution, FilterClass * i_fltr = NULL);

  /*
   Destructor - compiler default is ok
   */
  //~ResolutionMap();

  // DRGDRG - Should we be returning a ResolutionList? or get rid of Default & use no bits on key???
  /**
   Get the default resolution for this map
   @returns a reference to the default resolution
   @pre None
   @post None
   */
  Resolution & GetDefault(void) const;

  /**
   Replace the default Resolution
   @param Reference to new default resolution
   */
  void ReplaceDefaultWith(Resolution & r);

  /**
   Add a key,Resolution pair
   @param i_bitPos - bit position
   @param 1 to 6 Resolutions
   */
  void Add(uint8_t i_bitPos,
           Resolution * i_res );
  void Add(uint8_t i_bitPos,
           Resolution * i_r1, Resolution * i_r2);
  void Add(uint8_t i_bitPos,
           Resolution * i_r1, Resolution * i_r2, Resolution * i_r3);
  void Add(uint8_t i_bitPos,
           Resolution * i_r1, Resolution * i_r2, Resolution * i_r3,
           Resolution * i_r4);
  void Add(uint8_t i_bitPos,
           Resolution * i_r1, Resolution * i_r2, Resolution * i_r3,
           Resolution * i_r4, Resolution * i_r5);
  void Add(uint8_t i_bitPos,
           Resolution * i_r1, Resolution * i_r2, Resolution * i_r3,
           Resolution * i_r4, Resolution * i_r5, Resolution * i_r6);
  void Add(uint8_t i_bitPos,
           Resolution * i_r1, Resolution * i_r2, Resolution * i_r3,
           Resolution * i_r4, Resolution * i_r5, Resolution * i_r6,
           Resolution * i_r7);

  /**
   Add a key,Resolution pair
   @param i_ble - bit list encoding  (array of bitPos)
   @param i_bleLen length of bit list
   @param 1 to 6 Resolutions
   */
  void Add(const uint8_t *i_ble, uint8_t i_bleLen,
                Resolution * res );
  void Add(const uint8_t *i_ble, uint8_t i_bleLen,
                Resolution * r1, Resolution * r2);
  void Add(const uint8_t *i_ble, uint8_t i_bleLen,
                Resolution * r1, Resolution * r2, Resolution * r3);
  void Add(const uint8_t *i_ble, uint8_t i_bleLen,
                Resolution * r1, Resolution * r2, Resolution * r3,
                Resolution * r4);
  void Add(const uint8_t *i_ble, uint8_t i_bleLen,
                Resolution * r1, Resolution * r2, Resolution * r3,
                Resolution * r4, Resolution * r5);
  void Add(const uint8_t *i_ble, uint8_t i_bleLen,
                Resolution * r1, Resolution * r2, Resolution * r3,
                Resolution * r4, Resolution * r5, Resolution * r6);


  //! Old Add interface
  /*!
   */
  void Add(const char *i_ble,
           Resolution * res );
  void Add(const char *i_ble,
           Resolution * r1, Resolution * r2);
  void Add(const char *i_ble,
           Resolution * r1, Resolution * r2, Resolution * r3);
  void Add(const char *i_ble,
           Resolution * r1, Resolution * r2, Resolution * r3,
           Resolution * r4);
  void Add(const char *i_ble,
           Resolution * r1, Resolution * r2, Resolution * r3,
           Resolution * r4, Resolution * r5);
  void Add(const char *i_ble,
           Resolution * r1, Resolution * r2, Resolution * r3,
           Resolution * r4, Resolution * r5, Resolution * r6);
  void Add(const char *i_ble,
           Resolution * r1, Resolution * r2, Resolution * r3,
           Resolution * r4, Resolution * r5, Resolution * r6,
           Resolution * r7);

  void AddRange(const char *i_ble,Resolution * res ) { Add(i_ble,res); }
  void AddRange(const char *i_ble,Resolution * r1, Resolution * r2) { Add(i_ble,r1,r2); }
  void AddRange(const char *i_ble,
                Resolution * r1, Resolution * r2, Resolution * r3) { Add(i_ble,r1,r2,r3); }
  void AddRange(const char *i_ble,
                Resolution * r1, Resolution * r2, Resolution * r3,
                Resolution * r4) { Add(i_ble,r1,r2,r3,r4); }
  void AddRange(const char *i_ble,
                Resolution * r1, Resolution * r2, Resolution * r3,
                Resolution * r4, Resolution * r5) { Add(i_ble,r1,r2,r3,r4,r5); }
  void AddRange(const char *i_ble,
                Resolution * r1, Resolution * r2, Resolution * r3,
                Resolution * r4, Resolution * r5, Resolution * r6) { Add(i_ble,r1,r2,r3,r4,r5,r6); }
  /**
   Look up a Resolution for a bitlist
   @param bitList
   @returns List of all Resolutions that match
   @pre none
   @post Resolution returned is only valid until the next call to LookUp or this object is destroyed.
   i_bitList may be modified
   @notes if the bitList does not have a match then the defaultResolution is returned.
   */
    void LookUp( ResolutionList & o_list, BitKey & io_bitList,
                 STEP_CODE_DATA_STRUCT & scd );

  /**
   * @brief Get the stored filter associated with this resolution map.
   * @returns Currently assigned filter.
   */
  FilterClass * getFilter() { return iv_filter; };

  /**
   * @brief Store a new filter with this resolution map.
   * @param i - Filter to store.
   */
  void setFilter(FilterClass * i) { iv_filter = i; };

protected:  // functions

private: // functions

  /*!
   Copy prohibited
   */
  ResolutionMap(const ResolutionMap &);   // Don't allow copy - No defn

  /*!
   Assignment prohibited
   */
  const ResolutionMap &operator=(const ResolutionMap &); // Don't allow - no defn

private: // Data

  struct RmPair
  {
    BitKey iv_blist;
    Resolution * iv_res;
    RmPair(uint8_t i_bitPos, Resolution *res) : iv_blist(i_bitPos), iv_res(res) {}
    RmPair(void) : iv_blist(), iv_res(NULL) {}
  };

  typedef std::vector<RmPair> MapList;

  Resolution  * defaultRes;
  FilterClass * iv_filter;

  MapList iv_list;
//  MapList iv_rangeList;

};

inline ResolutionMap::ResolutionMap( int32_t entryCount,
                                     Resolution & defaultResolution,
                                     FilterClass * i_fltr ) :
    defaultRes(&defaultResolution), iv_filter(i_fltr), iv_list()
{
    iv_list.reserve(entryCount);
}

inline  Resolution & ResolutionMap::GetDefault(void) const {return *defaultRes; }
inline  void ResolutionMap::ReplaceDefaultWith(Resolution & r) { defaultRes = &r; }

} // end namespace PRDF

#endif /* ResolutionMap_h */

OpenPOWER on IntegriCloud