summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/framework/rule/prdfRuleMetaData.H
blob: 6de1dded13a3c3d6be4ebad5a1c0449f1b67ccf3 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/framework/rule/prdfRuleMetaData.H $  */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2004,2013              */
/*                                                                        */
/* 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                                                     */

/**
 * @file    prdfRuleMetaData.H
 * @brief   Models the register, groups and action and analyzes the attention.
 *
 *          Each Rule file maps to one instance of RuleMetaData. This class uses
 *          the services of rule file parser classes. Once Rule file is parsed,
 *          it models all the physical registers and resolutions. It also models
 *          the logical operation needed to analyze the registers. It furthur
 *          goes to the extent of modelling the entire mechansim of attention
 *          analysis using an entity called Group.All RuleChips modelling target
 *          of type share same instance of RuleMetaData class. It is created
 *          while building PRD object model. Similar to RuleChips, instance of
 *          this class too are contained in System class.
 *
 */


#ifndef __PRDFRULECHIPDATA_H
#define __PRDFRULECHIPDATA_H


#include <iipchip.h>
#include <prdfErrlSmartPtr.H>
#include <string.h>
#include <vector>
#include <map>
#include "prdrCommon.H"
#include <iipCaptureData.h>
#include <prdfExtensibleChip.H>
#include <iipResetErrorRegister.h>

namespace Prdr
{

class Chip;
class Expr;

} // end namespace PRDR

namespace PRDF
{

class ScanFacility;
class ResolutionFactory;
class Resolution;
class Group;
class SCAN_COMM_REGISTER_CLASS;

typedef std::pair<ResetAndMaskErrorRegister::ResetRegisterVector,
                       ResetAndMaskErrorRegister::ResetRegisterVector>
        ResetAndMaskPair;

// x86 compile wants this here - not forward declaired dgilbert
class CaptureRequirement
{
    public:

        CaptureRequirement() :cv_TargetType(TARGETING::TYPE_NA),
            cv_TargetIndex(0), cv_func(NULL)
        { };

        uint32_t cv_TargetType;
        uint32_t cv_TargetIndex;
        ExtensibleChipFunction * cv_func;
        /**
         * @brief     defines != operator for register capture requirement
         */

        inline bool operator != ( const CaptureRequirement & r )
        {
            return ( ( cv_TargetType != r.cv_TargetType )   ||
                     ( cv_TargetIndex != r.cv_TargetIndex ) ||
                     ( cv_func != r.cv_func ) );
        };
};


//--------------------------------------

class CaptureType
{
    public:
        RegType cv_regType;
        /**
         * @brief     constructor
         */
        CaptureType( RegType reg = PRIMARY ):cv_regType( reg )
        { };
};

//--------------------------------------

class RuleMetaData
{
    public:
        typedef std::map<uint32_t, SCAN_COMM_REGISTER_CLASS *> RegMap_t;
        typedef std::map<uint32_t, ErrorRegisterType *>        GroupMap_t;
        typedef std::map<uint32_t, Resolution *>               ActionMap_t;
        typedef std::map<uint32_t, ResetAndMaskPair>           Reset_t;
        typedef std::map<uint32_t, Resolution *>              SharedThreshold_t;

        struct RuleFileData
        {
            RegMap_t & cv_regMap;
            GroupMap_t & cv_groupMap;
            ActionMap_t & cv_actionMap;

            ScanFacility & cv_scanFactory;
            ResolutionFactory & cv_reslFactory;

            Prdr::Chip *& cv_loadChip;

            Reset_t & cv_resets;
            ResetAndMaskPair & cv_currentResets;

            SharedThreshold_t & cv_sharedThresholds;

        };

        /**
         * @brief       constructor
         * @param[in]   i_fileName      name of Rule file
         * @param[in]   i_scanFactory   reference to factory class which
         *                              creates register instances
         * @param[in]   i_targetType    target type associated with Rulechip
         * @param[o]    o_errl          reference to error log handle
         */
        RuleMetaData( const char * i_fileName,
                    ScanFacility & i_scanFactory,
                    ResolutionFactory & i_reslFactory,
                    TARGETING::TYPE i_targetType,
                    errlHndl_t & o_errl );


        /**
         * @brief     destructor
         */

        virtual ~RuleMetaData();

        /**
         * @brief       Analyzes the attention by reading and analyzing group of
         *              registers.
         * @param[io]   io_serviceData   reference to STEP_CODE_DATA_STRUCT
         * @param[in]   i_attn           attention reported by RuleChip
         * @return      SUCCESS|FAIL
         */

        int32_t Analyze( STEP_CODE_DATA_STRUCT & io_serviceData,
                            ATTENTION_TYPE i_attn );
        /**
         * @brief       Captures group of register associated with RuleChip
         * @param[io]   io_capture   reference to CaptureData instance.
         * @param[in]   i_group      capture group number
         * @return      SUCCESS
         */

        int32_t CaptureErrorData( CaptureData & io_capture , int i_group = 1 );
        /**
         * @brief       Masks error
         * @param[in]   i
         * @return      SUCCESS
         */
        int32_t MaskError( uint32_t i ) { return SUCCESS; };
        /**
         * @brief       Returns signature offset associated with registes of a
         *              RuleChip.
         * @return      Error signature offset
         */
         uint32_t getSignatureOffset() const { return iv_sigOff; };
        /**
         * @brief       returns pointer to plugin function
         * @param[in]   i_func          name of the plugin function
         * @param[in]   i_expectNull    plugin function availability status
         * @return      pointer to ExtensibleChipFunction
         */

         ExtensibleChipFunction * getExtensibleFunction( const char * i_func,
                                                    bool i_expectNull = false );
        /**
         * @brief       Returns pointer to physical register.
         * @param[in]   i_reg           name of the register
         * @param[in]   i_expectNull    register non availability expectation
         * @param[in]   i_chip          pointer to RuleChip associated
         * @return      pointer to SCAN_COMM_REGISTER_CLASS
         */
         SCAN_COMM_REGISTER_CLASS * getRegister( const char * i_reg,
                                                 bool i_expectNull,
                                                 ExtensibleChip* i_chip );
        /**
         * @brief       Returns Null register instance
         * @param[in]   i_reg           name of the register
         * @param[in]   i_expectNull    register non availability expectation
         * @return      pointer to SCAN_COMM_REGISTER_CLASS
         */

         SCAN_COMM_REGISTER_CLASS * getNullRegister( const char * i_reg,
                                                    bool i_expectNull );

         ErrorRegisterType * cv_groupAttn[Prdr::NUM_GROUP_ATTN];

    private:  // Data

        const char * cv_fileName; //name of rule file associated with the class
        uint32_t cv_dumpType; // dump type
        uint32_t iv_sigOff;   // signature offset for  registers
        std::map<uint16_t, SCAN_COMM_REGISTER_CLASS *> cv_hwRegs;

        typedef std::vector<SCAN_COMM_REGISTER_CLASS *> scomRegisterList_t ;

        typedef std::map< uint32_t,scomRegisterList_t > HwCaptureGroup_t;
        HwCaptureGroup_t cv_hwCaptureGroups; //capture group associated
        typedef std::map<SCAN_COMM_REGISTER_CLASS *,
                                            CaptureRequirement> HwCaptureReq_t;
        HwCaptureReq_t cv_hwCaptureReq;

        //Adding another std::map for passing some data to capture stuff.
        typedef std::map<SCAN_COMM_REGISTER_CLASS *,
                                                CaptureType> HwCaptureType_t;
        HwCaptureType_t cv_hwCaptureType; // capture type
        std::vector <ErrorRegisterType *> iv_groupList;

        // A std::map to capture secondary register and its corresponding
        // Primary register.
        typedef std::map<SCAN_COMM_REGISTER_CLASS *, SCAN_COMM_REGISTER_CLASS *>
                                                            HwCaptureNonzero_t;
        HwCaptureNonzero_t cv_hwCaptureNonzero;

    private: //operations

        /**
         * @brief       Returns Null register instance
         * @param[in]   i_scanFacility        reference to register factory
         * @param[in]   i_resolutionFactory   refence  to resolution factory
         * @param[in]   i_type                target type associated with
         *                                    RuleChip
         * @return      error log handle
         */

        errlHndl_t loadRuleFile( ScanFacility & i_scanFacility,
                         ResolutionFactory & i_resolutionFactory ,
                         TARGETING::TYPE i_type );
        /**
         * @brief       Models register operation described in rule file.
         * @param[in]   i_expr    expression for logical operation
         * @param[in]   i_data    Reference to RuleFileData instance.
         * @return      pointer to SCAN_COMM_REGISTER_CLASS
         */

        SCAN_COMM_REGISTER_CLASS * createVirtualRegister( Prdr::Expr * i_expr,
                                                        RuleFileData & i_data );
        /**
         * @brief       Models actions described in rule file.
         * @param[in]   i_action  number corresponding to action in rule file.
         * @param[in]   i_data    Reference to RuleFileData instance.
         * @return      pointer to Resolution
         */
        Resolution * createActionClass( uint32_t i_action ,
                                        RuleFileData& i_data );

        /**
         * @brief       Models action described in rule file.
         * @param[in]   i_expr    expression for logical operation.
         * @param[in]   i_data    Reference to RuleFileData instance.
         * @return      pointer to Resolution
         */

        Resolution * createResolution( Prdr::Expr * i_expr,
                                         RuleFileData & i_data );

        /**
         * @brief       Models group described in rule file.
         * @param[in]   i_group   register capture group id
         * @param[in]   i_data    Reference to RuleFileData instance.
         */

        void createGroup( Group * i_group , uint32_t , RuleFileData & i_data );

};



}//namespace PRDF ends

#endif
OpenPOWER on IntegriCloud