summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/framework/rule/prdfRuleChip.H
blob: b7dd194f31817840c30e39cf813aab78b2c3e3b1 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/framework/rule/prdfRuleChip.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                                                     */

#ifndef __PRDFRULECHIP_H
#define __PRDFRULECHIP_H

#include <iipchip.h>
#include <prdfErrlSmartPtr.H>

#include <iipsdbug.h> // for ATTENTION_TYPE
#include <prdfExtensibleChip.H>
#include <prdfPluginDef.H>

#include <string.h>
#include <vector>
#include <map>
#include <iipResetErrorRegister.h>
#include "prdrCommon.H" //@jl02 Added this to get the constant value from the enum.
#include <iipCaptureData.h> // @jl04 Added this for the RegType used for register = "PRIMARY" or "SECONDARY"
//---------------------------------------
// Forward decls.

namespace Prdr
{

class Chip;
class Expr;

} // end namespace PRDR

namespace PRDF
{

class SCAN_COMM_REGISTER_CLASS;
class ScanFacility;
class ResolutionFactory;
class STEP_CODE_DATA_STRUCT;
class CaptureData;
class ErrorRegisterType;
class Resolution;
class Group;


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;

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

//--------------------------------------
// @jl04 a Start.
// Adding capture requirement type for transporting data.
class CaptureType
{
    public:
        RegType cv_regType;
        // if (reg == 1) reg = PRIMARY;
        // if (reg == 2) reg = SECONDARY;
        CaptureType(RegType reg = PRIMARY):cv_regType(reg){};
};
// @jl04 a Stop.
//--------------------------------------


class RuleChip : public ExtensibleChip
{
    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;

            TARGETING::TargetHandle_t cv_chipHandle;
            Prdr::Chip *& cv_loadChip;        // pw01

            Reset_t & cv_resets;
            ResetAndMaskPair & cv_currentResets;

            SharedThreshold_t & cv_sharedThresholds;

        };

    public:

       /*Note:
       At the beginning of all the public function of this class,'this' pointer
       should be pushed to stack maintained in service data collector.Also, at
       the end of same function,it should be popped.It is accomplished by just
       instantiating ChipScopeLock at the beginning of the function.This is
       encapsulated by PRDF_LOCK_CHIP_SCOPE */

        // TODO : add parameter for parent domains, connected chip classes.
        RuleChip(const char * i_fileName,
                     TARGETING::TargetHandle_t   i_pTargetHandle,
                     ScanFacility & i_scanFactory,
                     ResolutionFactory & i_reslFactory
                    )
                : ExtensibleChip(i_pTargetHandle),
                  cv_fileName(i_fileName),
                  cv_dumpType(0),  //@ecdf
                  cv_dataBundle(NULL)
            {
                this->loadRuleFile(i_scanFactory, i_reslFactory);
            };

        ~RuleChip();

        int32_t Analyze(STEP_CODE_DATA_STRUCT &, ATTENTION_TYPE);
        int32_t CaptureErrorData(CaptureData &, int i_group = 1);
        /*Note
          functions like MaskError(),getDataBundle(),getSignatureOffset()
          just return a constant or a member variable. These function don't need
          to call any other functions of RuleChip.Hence,despite the fact that
          these functions are public,we are not using macro PRDF_LOCK_CHIP_SCOPE
          in these function.
        */
        int32_t MaskError(uint32_t i) { return SUCCESS; };

        ExtensibleChipFunction *
                getExtensibleFunction(const char *, bool = false);
        SCAN_COMM_REGISTER_CLASS * getRegister(const char *, bool = false);

        DataBundle *& getDataBundle() { return cv_dataBundle; };

        uint32_t getSignatureOffset() const { return iv_sigOff; };

    private:
        const char * cv_fileName;
        ErrlSmartPtr cv_errl;

        uint32_t cv_dumpType;  //@ecdf

        uint32_t iv_sigOff;

        std::map<uint16_t, SCAN_COMM_REGISTER_CLASS *> cv_hwRegs;

        typedef std::map<uint32_t, std::vector<SCAN_COMM_REGISTER_CLASS *> > HwCaptureGroup_t;
        HwCaptureGroup_t cv_hwCaptureGroups;

        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;

        DataBundle * cv_dataBundle;
        ErrorRegisterType * cv_groupAttn[Prdr::NUM_GROUP_ATTN];

        void loadRuleFile(ScanFacility &,
                          ResolutionFactory &);

        SCAN_COMM_REGISTER_CLASS *
            createVirtualRegister(Prdr::Expr *,
                                  RuleFileData &);

        Resolution *
            createActionClass(uint32_t,
                              RuleFileData &);

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

        void createGroup(Group *,
                         uint32_t,
                         RuleFileData &);
};

} // end namespace PRDF

#endif
OpenPOWER on IntegriCloud