summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/framework/config/iipSystem.h
blob: 14f7452fbd727f47609cd99c8477657b385f7146 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/framework/config/iipSystem.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 iipSystem_h
#define iipSystem_h

// Class Specification *************************************************
//
// Class name:   System
// Parent class: None.
//
// Summary: This class provides access to the domains and chips of the
//          actual hardware system.  The System is initially set up with
//          one or more calls to the Add...() functions in which Domains
//          and Chips are added to the system. The System assumes the
//          ownership of the pointers to the chips and domains that are
//          added to the system and will delete the associated chip and
//          domain objects when the destructor of the System is called.
//
//          The Initialize() function calls the Initialize() funciton
//          for each Chip and Domain in the System.  The function is
//          also virtual so that it can be overidden in a derived class
//          for a specific system initialization behaviour.
//
//          The Analyze() function determins which Domain Analzye() function
//          to call. The prioritization for Domain Analysis
//          is based on the value of the Domain ID.  The lower Domain
//          ID has higher priority.  When Analyze() is called, the Domains
//          are queried for attention status starting with the highest
//          priority Domain and moving to the lowest.
//          The first Domain that returns true from Query() will have its
//          Analyze() function called.
//
// Cardinality: N
//
// Performance/Implementation:
//   Space Complexity: Linear based on the number of domains and chips
//                     configured in the hardware system.
//   Time Complexity:  All member functions constant unless otherwise
//                     stated.
//
// Usage Examples:
//
// extern CHIP_CLASS * chips[CHIP_COUNT];
// extern Domain * domains[DOMAIN_COUNT];
// extern ServiceDataCollector sdc;
//
// void foo(void)
//   {
//   System system;
//
//   system.Add(chips, chips + CHIP_COUNT);
//   system.Add(domains, domains + DOMAIN_COUNT);
//
//   CHIP_CLASS * system.GetChip(CHIP_ID);
//   Domain * system.GetDomain(DOMAIN_ID);
//
//   system.Initialize();
//
//   system.Analyze(sdc);
//   }
//
// End Class Specification *********************************************

#include <vector>
#include <map>

#ifndef IIPCONST_H
#include <iipconst.h>   //TARGETING::TargetHandle_t, DOMAIN_ID_TYPE
#endif

#include <iipsdbug.h>    // Include file for ATTENTION_TYPE

namespace PRDF
{

// Forward Declarations
class CHIP_CLASS;
class Domain;
class Resolution;
class RuleMetaData ;
class ScanFacility;
class ResolutionFactory;

struct STEP_CODE_DATA_STRUCT;
typedef std::map< TARGETING::TYPE ,RuleMetaData *> RuleMetaDataList ;

class System
  {
  private:

    typedef std::vector<CHIP_CLASS *>::iterator ChipContainerIterator;
    typedef std::vector<Domain *>::iterator DomainContainerIterator;

  public:

    System(Resolution & noSystemAttentions);
  // Function Specification ********************************************
  //
  // Purpose:      Initialization
  // Parameters:   A resolution to resolve the serviceData if no
  //               attentions are found in the configured system
  // Returns:      No value returned.
  // Requirements: None.
  // Promises:     All data members are initialized.
  // Exceptions:   None.
  // Concurrency:  Reentrant
  //
  // End Function Specification //////////////////////////////////////

  //  System(const System & c);
  // Function Specification ********************************************
  //
  // Purpose:      Copy
  // Parameters:   c: Reference to instance to copy
  // Returns:      No value returned.
  // Requirements: None.
  // Promises:     All data members will be copied (Deep copy).
  // Exceptions:   None.
  // Concurrency:  N/A.
  // Notes:  This constructor is not declared.  This compiler generated
  //         default definition is sufficient.
  //
  // End Function Specification ****************************************

    virtual ~System(void);
  // Function Specification ********************************************
  //
  // Purpose:      Destruction
  // Parameters:   None.
  // Returns:      No value returned
  // Requirements: None.
  // Promises:     None.
  // Exceptions:   None.
  // Concurrency:  Reentrant
  // Notes:  This destructor deletes each Chip and Domain instance in
  //         the respective containers.
  //
  // End Function Specification ****************************************

  //  System & operator=(const System & c);
  // Function Specification ********************************************
  //
  // Purpose:      Assigment
  // Parameters:   Handle to the chip
  // Returns:      Reference to this instance
  // Requirements: None.
  // Promises:     All data members are assigned to
  // Exceptions:   None.
  // Concurrency:  N/A.
  // Notes:  This assingment operator is not declared.  The compiler
  //         generated default definition is sufficient.
  //
  // End Function Specification ****************************************

    CHIP_CLASS * GetChip(TARGETING::TargetHandle_t i_pchipHandle);
  // Function Specification ********************************************
  //
  // Purpose:      Get Chip
  // Parameters:   chipId: Specifies chip to get
  // Returns:      Pointer to CHIP_CLASS
  // Requirements: None.
  // Promises:     Return a pointer to the requested chip if it exists
  // Exceptions:   None.
  // Concurrency:  Reentrant.
  // Notes:  If the specified chip is not in the System, then NULL is
  //         returned.
  //
  // End Function Specification ****************************************

    Domain * GetDomain(DOMAIN_ID domainId);
  // Function Specification ********************************************
  //
  // Purpose:      Get Domain
  // Parameters:   domainId: Specifies domain to get
  // Returns:      Pointer to Domain.
  // Requirements: None.
  // Promises:     Return a pointer to the requested domain if it exists
  // Exceptions:   None.
  // Concurrency:  Reentrant.
  // Notes:  If the specified domain is not in the System, then NULL is
  //         returned.
  //
  // End Function Specification ****************************************

    void AddChips(ChipContainerIterator begin,
      ChipContainerIterator end);
  // Function Specification ********************************************
  //
  // Purpose:      Adds a Chips to the system
  // Parameters:   begin: Iterator to first Chip to add
  //               end: Iterator to end Chip to add
  // Returns:      No value returned.
  // Requirements: None.
  // Promises:     Pointer to chip stored in system, Pointer ownership assumed
  // Exceptions:   None.
  // Concurrency:  Nonreentrant.
  //
  // End Function Specification ****************************************

    void AddDomains(DomainContainerIterator begin,
      DomainContainerIterator end);
  // Function Specification ********************************************
  //
  // Purpose:      Adds Domains to the system
  // Parameters:   Handle of chip that check stopped
  // Returns:      No value returned.
  // Requirements: None.
  // Promises:     Pointer Domain stored in system, Pointer ownership assumed
  // Exceptions:   None.
  // Concurrency:  Nonreentrant.
  //
  // End Function Specification ****************************************

    void RemoveStoppedChips(TARGETING::TargetHandle_t i_pChipHandle);    //@jl02 Unit Check Stop code added

  // Function Specification ********************************************
  //
  // Purpose:      Removes a chip from a Domain that this chip is in if we no longer
  //                 want to have the chip within prds view.
  // Parameters:   chip:  Chip ID to be changed.
  // Returns:      No value returned.
  // Requirements: None.
  // Promises:     None.
  // Exceptions:   None.
  // Concurrency:  Nonreentrant.
  //
  // End Function Specification ****************************************

    void RemoveNonFunctionalChips();    //@jl04 a Add code to remove non functional
  // Function Specification ********************************************
  //
  // Purpose:      Removes chips from a Domain if we no longer
  //                 want to have the chips that are nonfunctional in HOM.
  // Parameters:   None.
  // Returns:      No value returned.
  // Requirements: None.
  // Promises:     None.
  // Exceptions:   None.
  // Concurrency:  Nonreentrant.
  //
  // End Function Specification ****************************************


    virtual void Initialize();
  // Function Specification ********************************************
  //
  // Purpose:      Initializes all chip and domains
  // Parameters:   refCode: Reference code to use if error
  //               stepCode: Step code to use if error
  // Returns:      No value returned.
  // Requirements: None.
  // Promises:     Initialize function on all chip and domains called unless
  //               an error occurrs in one of the Initialize functions.
  // Exceptions:   None.
  // Concurrency:  Reentrant.
  // Notes: The Initialize() function for each Chip and Domain is
  //        called.  If an error code is returned from a Chip or Domain
  //        Initialize call, then SrcFill is called with the specified
  //        reference code, step code, and return code.  No further calls
  //        are made when an error occurs.
  //
  // End Function Specification ****************************************

    virtual int32_t Analyze(STEP_CODE_DATA_STRUCT & serviceData,
                            ATTENTION_TYPE attentionType);
  // Function Specification ********************************************
  //
  // Purpose:      Analyze domains for an error
  // Parameters:   serviceData: Reference to pass back error data in
  //               attentionType: Indicates attention type
  // Returns:      Error value
  // Requirements: None.
  // Promises:     ServiceData completed unless error encountered
  // Exceptions:   None.
  // Concurrency:  Reentrant.
  // Notes: Each Domain is queried using the prioritization sequence.
  //        The first Domain that returns true from Domain Query()
  //        will have its Analyze() function called.  If
  //        there are no Domains, then the error code
  //        NO_DOMAINS_IN_SYSTEM(0xDD20) is returned.  If there are no
  //        Domains at attention, then the error code
  //        NO_DOMAINS_AT_ATTENTION(0xDD21) is returned.
  //

   /**
    * @brief        Get instance of RuleMetaData associated with given target
    *               type.
    * @param[in]    i_type          target type associated with RuleMetaData.
    * @param[in]    i_fileName      name of RuleFile associated
    * @param[in]    i_scanFactory   reference to factory class which
    *                               creates register instance.
    * @param[in]    i_reslFactory   reference to factory which creates
    *                               resolution instance.
    * @param[o]     o_errl          error log handle
    */

    RuleMetaData* getChipMetaData( TARGETING::TYPE i_type,
                                const char *i_fileName,
                                ScanFacility & i_scanFactory,
                                ResolutionFactory & i_reslFactory,
                                errlHndl_t & o_errl );

  // End Function Specification ****************************************

  private:

    typedef std::vector<CHIP_CLASS *> ChipMapType;

    typedef std::vector<Domain *>     DomainContainerType;

    ChipMapType                   chips;

    DomainContainerType           prioritizedDomains;

    Resolution & noAttnResolution;
    RuleMetaDataList iv_listRuleData ;
  };

} // end namespace PRDF

#endif
OpenPOWER on IntegriCloud