summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/framework/resolution/iipResolutionFactory.h
blob: 72ff5938a8288c10469c80b32240817e48bc0388 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/framework/resolution/iipResolutionFactory.h $ */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 1997,2014              */
/*                                                                        */
/* 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                                                     */

#ifndef iipResolutionFactory_h
#define iipResolutionFactory_h

/**
 @file iipResolutionFactory.h
 @brief ResolutionFactory declairation
 */
// Class Description *************************************************
//
//  Name:  ResolutionFactory
//  Base class: None
//
//  Description: Maintains a pool of Analysis Resolutions such that only
//               one instance of a particular Resolution object exists.
//               (flyweight)
//  Usage:
//
//    ResolutionFactory & resolutionPool = ResolutionFactory::Access();
//    FinalResolution & fr = resolutionPool.GetCalloutResolution(EAGLE0_HIGH);
//
//
// End Class Description *********************************************

//#include <xspprdIfCondor.h>     // #define CSP_CONDOR

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

#include <iipconst.h>
#include <prdfGlobal.H>
#include <prdfFlyWeight.H>
#include <prdfFlyWeightS.H>
#include <iipCalloutResolution.h>
#include <prdfThresholdResolutions.H>
#include <prdfCalloutConnected.H>
#include <prdfAnalyzeConnected.H>
#include <prdfPluginCallResolution.H>
#include <iipEregResolution.h>
#include <xspprdTryResolution.h>
#include <xspprdFlagResolution.h>
#include <prdDumpResolution.H>
#include <xspprdGardResolution.h>
#include <prdfCaptureResolution.H>
#include <prdfClockResolution.H>

namespace PRDF
{

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

/**
 "Flyweight" factory of resolutions (singlton)
 @version V4R5
 @author Douglas R. Gilbert
*/
class ResolutionFactory
{
public:

  /**
   * @brief         Accesses the ResolutionFactory singleton
   * @return        Resolution factory
   */
  static ResolutionFactory & Access(void);

  /**
   * @brief         Destructor
   */
  ~ResolutionFactory();


  // dg03a start
  /**
   * @brief         Reset after a re-ipl
   *                Clear the resolution lists that need clearing on a re-ipl
   * @note          currently clears the threshold resolution list and the link
   *                resolution list
   */
  void Reset();
  // dg03a end

  /**
   * @brief         Get a resolution that makes a callout
   * @param [in]    PRDcallout  (see prdfCallouts.H)
   * @param [in]    PRDpriority (see prdfCallouts.H)
   * @return        Resolution &
   * @note          Regatta CSP use only. Do not call this method from a static
   *                object.
   */
  Resolution & GetCalloutResolution( PRDcallout callout,
                                     PRDpriority p = PRDF::MRU_MED);

  /**
   * @brief         Get a threshold Resolution
   * @param[in]     maskId      MaskId to set when threshold is reached
   * @param[in]     policy      policy during normal runtime
   * @param[in]     mfgPolicy   policy for manufactoring mode ( default is
   *                            threshold one,infinate interval )
   * @return        reference to a resolution
   * @post          appropriate Resolution created.
   * @note          the iv_thresholdResoltion FlyWeight is cleared by
   *                this->Reset()
   */
  MaskResolution & GetThresholdResolution(uint32_t maskId,
                    const ThresholdResolution::ThresholdPolicy& policy,
                    const ThresholdResolution::ThresholdPolicy& mfgPolicy);

  MaskResolution & GetThresholdResolution(uint32_t maskId,
                    const ThresholdResolution::ThresholdPolicy& policy);

  MaskResolution & GetThresholdResolution(uint32_t maskId);
  MaskResolution & GetThresholdResolution(uint32_t maskId,
                            const ThresholdResolution::ThresholdPolicy* policy);

  // dg04a - start
  /**
   * @brief          GetConnectedCalloutResolution
   * @param[in]      i_targetType Type of target  connected to i_source
   * @param[in]      idx          index in GetConnected list to use
   * @param[in]      i_priority   @see prdfCallouts.H
   * @param[in]      i_altResolution resolution for failure scenarios
   * @param[in]      i_peerConnType Type of target which connects to peer
                                    of i_targetType
   * @return         reference to a resolution
   * @note           Don't use this to callout clocks - use prdfClockResolution
   */
  Resolution & GetConnectedCalloutResolution(
                                        TARGETING::TYPE i_targetType,
                                        uint32_t i_idx = 0,
                                        PRDpriority i_priority = MRU_MED,
                                        Resolution * i_altResolution = NULL,
                                        TARGETING::TYPE i_peerConnType
                                                       = TARGETING::TYPE_NA );
  // dg04a - end

  // dg05a - start
  /**
   * @brief     GetAnalyzeConnectedResoltuion
   * @param[in] i_targetType type of unit that's connected to the source
   * @param[in] i_dx         index in GetConnected list to analyze
   * @return    reference to a resolution
   */
  Resolution & GetAnalyzeConnectedResolution( TARGETING::TYPE i_targetType,
                                             uint32_t i_idx =0xffffffff );
        // dg05a - end
  // dg06a - start
  /**
   * @brief     Returns object of PluginCallResolution
   * @param[in] i_function pointer to ExtensibleFunction
   * @return    reference to a resolution
   * @post      one instance with these params will exist
   * @note      This flyweight is cleared by this->Reset()
   */
  Resolution & GetPluginCallResolution( ExtensibleChipFunction * i_function );

  /**
   * @brief     Get a threshold signature resolution
   * @param[in] i_policy Reference to ThresholdPolicy struct
   * @return    reference to a resolution
   * @post      one instance with this policy will exist
   * @note      This flyweight is cleared by this->Reset()
   */
  Resolution & GetThresholdSigResolution( const ThresholdResolution::
                                            ThresholdPolicy& i_policy );


  /**
   * @brief     Get an EregResolution
   * @param[in] i_er    Error register
   * @return    reference to a resolution
   * @post      one instance with the param will exist
   * @note      the error register provided must remain in scope as long as the
   *            Resolution Factory
   * @note      This Flyweight is cleared by this->Reset()
   */
  Resolution & GetEregResolution(ErrorRegisterType & i_er);

  /**
   * @brief     Get a TryResolution
   * @param[in] i_tryRes    Resolution to try
   * @param[in] i_defaultRes    Resolution to use if the first one returns a
   *                            non-zero return code
   * @return    reference to a resolution
   * @post      one instance with these params will exist
   * @note      The resolutions provided must remain in scope as long as the
   *            Resolution Factory
   * @note      This Flyweight is cleared by this->Reset()
   */
  Resolution & GetTryResolution(Resolution &i_tryRes, Resolution & i_defaultRes);

  /**
   * @brief     Get a FlagResolution
   * @param[in] i_flag
   * @return    reference to a resolution
   * @post      only one instance of this object with this param will exist
   */
  Resolution & GetFlagResolution(ServiceDataCollector::Flag i_flag);

  /**
   * @brief     Get a DumpResolution
   * @param[in] iDumpRequestContent
   * @return    reference to a resolution
   * @post      only one instance of this obect with these paramaters will exist
   */
  Resolution & GetDumpResolution( hwTableContent iDumpRequestContent =
                                    CONTENT_HW );

  /**
   * @brief     Get a Gard Resolution
   * @param[in] i_gardErrorType gard error type
   * @return    reference to a resolution
   * @post      only one instance of this object with this param will exist
   */
  Resolution & GetGardResolution( GardAction::ErrorType i_gardErrorType );

  /**
   * @brief     Get a Capture Resolution
   * @param[in] i_group  The group to capture.
   * @return    reference to a resolution
   * @post      only one instance of this object with this param will exist
   */
  Resolution & GetCaptureResolution( int32_t i_group );

    /**
   * @brief     Get a ClockResolution
   * @param[in] i_pClockHandle Target pointer pertaining to clock
   * @param[in] i_targetType   desired Targets type connected to clock
   * @return    reference to a resolution
   * @post      only one instance of this obect with these paramaters will exist
   */
  // FIXME: Need support for clock targets
  // FIXME: Need support for clock targets types
  Resolution & GetClockResolution(
                    TARGETING::TargetHandle_t i_pClockHandle = NULL ,
                    TARGETING::TYPE i_targetType = TARGETING::TYPE_PROC );
/**
   Link resolutions to form a single resolution performing the actions of them all
   <ul>
   <br><b>Parameters:  </b> Resolutions
   <br><b>Returns:     </b> Resolution &
   <br><b>Requirements:</b> Valid resolutions given
   <br><b>Promises:    </b> LinkResolutions(r1,r2...).Resolve();  ==
                            r1.Resolve(), r2.Resolve(), ...;
   <br><b>Exceptions:  </b> None.
   <br><b>Notes:       </b> Do not call this method from a static object
   <br><b>Notes:       </b> The iv_Links Flyweight is cleared by this->Reset()
   </ul><br>
   */
  Resolution & LinkResolutions(Resolution &r1, Resolution &r2);
  /**
   Link resolutions to form a single resolution performing the actions of them all
   <ul>
   <br><b>Parameters:  </b> Resolutions
   <br><b>Returns:     </b> Resolution &
   <br><b>Requirements:</b> Valid resolutions given
   <br><b>Promises:    </b> LinkResolutions(r1,r2...).Resolve();  ==
                            r1.Resolve(), r2.Resolve(), ...;
   <br><b>Exceptions:  </b> None.
   <br><b>Notes:       </b> Do not call this method from a static object
   </ul><br>
   */
  Resolution & LinkResolutions(Resolution &r1, Resolution &r2, Resolution &r3);
  /**
   Link resolutions to form a single resolution performing the actions of them all
   <ul>
   <br><b>Parameters:  </b> Resolutions
   <br><b>Returns:     </b> Resolution &
   <br><b>Requirements:</b> Valid resolutions given
   <br><b>Promises:    </b> LinkResolutions(r1,r2...).Resolve();  ==
                            r1.Resolve(), r2.Resolve(), ...;
   <br><b>Exceptions:  </b> None.
   <br><b>Notes:       </b> Do not call this method from a static object
   </ul><br>
   */
  Resolution & LinkResolutions(Resolution &r1, Resolution &r2, Resolution &r3,
                               Resolution &r4);
  /**
   Link resolutions to form a single resolution performing the actions of them all
   <ul>
   <br><b>Parameters:  </b> Resolutions
   <br><b>Returns:     </b> Resolution &
   <br><b>Requirements:</b> Valid resolutions given
   <br><b>Promises:    </b> LinkResolutions(r1,r2...).Resolve();  ==
                            r1.Resolve(), r2.Resolve(), ...;
   <br><b>Exceptions:  </b> None.
   <br><b>Notes:       </b> Do not call this method from a static object
   </ul><br>
   */
  Resolution & LinkResolutions(Resolution &r1, Resolution &r2, Resolution &r3,
                               Resolution &r4, Resolution &r5);

private:  // functions

  /**
   private CTOR
   <ul>
   <br><b>Requirements:</b> May only be called once
   <br><b>Promises:    </b> Object created
   <br><b>Exceptions:  </b> None.
   </ul><br>
   */
  ResolutionFactory() {}

  ResolutionFactory(const ResolutionFactory &f); // not allowed
  ResolutionFactory & operator=(const ResolutionFactory &f); // not allowed

public:
  /**
   Link resolutions together
   @author Douglas R. Gilbert
   @version V4R3
   */
  class ResolutionLink: public Resolution
  {
  public:
    ResolutionLink(): Resolution(), xlnk1(NULL), xlnk2(NULL) {}
    ResolutionLink(Resolution & r1, Resolution & r2)
      : Resolution(), xlnk1(&r1), xlnk2(&r2) {}
    ResolutionLink(const ResolutionLink & rl)
      : xlnk1(rl.xlnk1), xlnk2(rl.xlnk2) {}
    bool operator==(const ResolutionLink & r) const
    { return (xlnk1 == r.xlnk1 && xlnk2 == r.xlnk2); };
    bool operator<(const ResolutionLink & r) const
    {
        if (xlnk1 == r.xlnk1)
            return xlnk2 < r.xlnk2;
        return xlnk1 < r.xlnk1;
    };
    bool operator>=(const ResolutionLink & r) const
    {
        if (xlnk1 == r.xlnk1)
            return xlnk2 >= r.xlnk2;
        return xlnk1 >= r.xlnk1;
    };

    virtual int32_t Resolve(STEP_CODE_DATA_STRUCT & serviceData);
  private: // data
    Resolution * xlnk1;
    Resolution * xlnk2;
  };
#ifdef FLYWEIGHT_PROFILING
/**
 * @brief       prints memory allocated for object residing in flyweight
 */
  void printStats();
#endif

private:  // Data

  // dg01 - start
  typedef FlyWeight< CalloutResolution, 50> CalloutFW;             // dg01a
  typedef FlyWeightS< ResolutionLink, 50> ResolutionLinkFW;        // dg01a

  typedef FlyWeight< ThresholdResolution, 50 > ThresholdResolutionList;  // dg02a
  typedef FlyWeight< MaskResolution, 50 > MaskResolutionFW;           // dg02a

  typedef FlyWeight< CalloutConnected, 25 > ConnectedFW;         // dg04a
  typedef FlyWeight< AnalyzeConnected, 20 > AnalyzeCFW;          // dg05a
  typedef FlyWeight< PluginCallResolution, 10 > PluginCallFW;    // dg06a
  typedef FlyWeight< ThresholdSigResolution, 10 > ThresholdSigFW;    // dg06a
  typedef FlyWeight< EregResolution, 50 > EregResolutionFW;          // dg06a
  typedef FlyWeight< TryResolution, 20 > TryResolutionFW;            // dg06a
  typedef FlyWeight< FlagResolution, 5 > FlagResolutionFW;           // dg06a
  typedef FlyWeight< DumpResolution, 5 > DumpResolutionFW;           // dg06a
  typedef FlyWeight< GardResolution, 5 > GardResolutionFW;           // dg06a
  typedef FlyWeight< CaptureResolution, 5> CaptureResolutionFW;  // pw01
  typedef FlyWeight< ClockResolution, 8 > ClockResolutionFW;         // jl01a

  CalloutFW iv_Callouts;                            // dg01a
  ResolutionLinkFW iv_Links;                        // dg01a

  ThresholdResolutionList iv_thresholdResolutions;  // dg02a
  MaskResolutionFW iv_maskResolutions;            // dg02a
  // dg01 - end
  ConnectedFW iv_connectedCallouts;            // dg04a
  AnalyzeCFW iv_analyzeConnected;              // dg05a
  PluginCallFW iv_pluginCallFW;                // dg06a
  ThresholdSigFW iv_thresholdSigFW;             // dg06a
  EregResolutionFW iv_eregResolutionFW;        // dg06a
  TryResolutionFW iv_tryResolutionFW;          // dg06a
  FlagResolutionFW iv_flagResolutionFW;        // dg06a
  DumpResolutionFW iv_dumpResolutionFW;        // dg06a
  GardResolutionFW iv_gardResolutionFW;        // dg06a
  CaptureResolutionFW iv_captureResolutionFW;  // pw01
  ClockResolutionFW iv_clockResolutionFW;      // jl01a

};

inline
Resolution & ResolutionFactory::LinkResolutions(Resolution &r1,
                                                Resolution &r2,
                                                Resolution &r3)
{
  return LinkResolutions(LinkResolutions(r1,r2),r3);
}

inline
Resolution & ResolutionFactory::LinkResolutions(Resolution &r1,
                                                Resolution &r2,
                                                Resolution &r3,
                                                Resolution &r4)
{
  return LinkResolutions(LinkResolutions(r1,r2),LinkResolutions(r3,r4));
}

inline
Resolution & ResolutionFactory::LinkResolutions(Resolution &r1,
                                                Resolution &r2,
                                                Resolution &r3,
                                                Resolution &r4,
                                                Resolution &r5)
{
  return LinkResolutions(LinkResolutions(r1,r2),LinkResolutions(r3,r4,r5));
}

} // end namespace PRDF

#endif /* iipResolutionFactory_h */
OpenPOWER on IntegriCloud