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

/**
 * @file prdrLoadChip.H
 * @brief Describes classes and enums needed to load a .prf file.
 */


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

#include <stdint.h>

#include <errlentry.H>
#include <utilstream.H>

#include <vector>

#include <prdrCommon.H>
#include <targeting/common/target.H>

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

/**
 * @namespace Prdr
 * @brief Namespace to encapsulate Prdr specific enums, classes, and typedefs.
 */
namespace Prdr
{
    /**
     * @brief read string data out from the stream
     * @note  caller must call delete[] to release the buffer
     */
    void ReadString(UtilStream & i_stream, char *& o_string);

    /**
     * @class Register
     * @brief Holds data associated with a register.
     */
    class Register
    {
        public:
            uint16_t        cv_name;         /** hash id of Register Short Name */

            uint32_t        cv_flags;         /** Attribute flags */

            uint64_t        cv_scomAddr;         /** Scom Address */
            uint16_t        cv_scomLen;         /** Scom Length */

            Register();
            ~Register();

            struct ResetOrMaskStruct
            {
                char op;
                uint64_t addr_r;
                uint64_t addr_w;

                friend UtilStream& operator>>(UtilStream& i_left,
                                              ResetOrMaskStruct & i_right)
                {
                    return (i_left >> i_right.op
                                   >> i_right.addr_r
                                   >> i_right.addr_w);
                };
            };

            std::vector<ResetOrMaskStruct> cv_resets;
            std::vector<ResetOrMaskStruct> cv_masks;

            struct CaptureInfoStruct
            {
                uint8_t op;
                uint32_t data[2];
                char* func;

                friend UtilStream& operator>>(UtilStream& i_left,
                                              CaptureInfoStruct & i_right)
                {
                    i_left >> i_right.op;
                    int loopMax = 0;
                    switch (i_right.op)
                    {
                        case 'G':
                        case 'T':
                        case 'P':
                            loopMax = 1;
                            break;

                        case 'C':
                            loopMax = 2;
                            break;

                        case 'f':
                            loopMax = 0;
                            break;
                    }

                    for (int i = 0; i < loopMax; i++)
                        i_left >> i_right.data[i];

                    i_right.func = NULL;

                    if ('f' == i_right.op)
                    {
                        ReadString(i_left, i_right.func);
                    }

                    return i_left;
                }
            };

            std::vector<CaptureInfoStruct> cv_captures;

    };

    /**
     * @class Expr
     * @brief Contains data for the basic rule object, the "expression".
     */
    class Expr
    {
        public:
            union value { uint32_t i; Expr * p; };

                    /** Maximum number of entries a expression can have. */
            static const uint32_t MAX_VALUES = 6;

            unsigned char cv_op;        /** Type of expr this is. */

            // Arrays for the expression entries.  cv_deletePtr remembers if
            // the p-value should be 'deleted' when we destruct this object.
            bool        cv_deletePtr[MAX_VALUES];
            value        cv_value[MAX_VALUES];

            // action function pointer
            char * cv_actFunc;
            // vector of bit string data
            std::vector<uint64_t> cv_bitStrVect;

            /**
             * @func Expr()
             * @brief Default constructor.  Clear entry arrays.
             */
            Expr();

            /**
             * @func ~Expr()
             * @brief Default destructor.  Delete all attached pointers, as
             * requested.
             */
            ~Expr();

        private:
            // Don't let us copy these things, we don't want to mess with the
            // pointer tree.
            Expr(const Expr & i_copy) {};
    };

    class Chip
    {
        public:
            uint32_t        cv_chipId;
            TARGETING::TYPE cv_targetType;
            uint32_t        cv_signatureOffset; // Offset for error register ids.
            uint32_t        cv_dumpType;        // default dump content type.
            uint16_t        cv_scomLen;         // default scom length.
            uint16_t        cv_regCount;
            Register *  cv_registers;
            uint16_t        cv_ruleCount;
            Expr *      cv_rules;
            uint16_t        cv_groupCount;
            uint16_t        cv_groupAttn[NUM_GROUP_ATTN];
            uint16_t *      cv_groupSize;
            uint8_t *       cv_groupFlags;
            Expr **     cv_groupPriorityBits;
            Expr **     cv_groups;
            uint16_t        cv_actionCount;
            uint16_t *      cv_actionSize;
            Expr **     cv_actions;

            Chip() : cv_regCount(0), cv_registers(NULL),
                         cv_ruleCount(0), cv_rules(NULL),
                         cv_groupCount(0), cv_groupSize(NULL),
                         cv_groupFlags(NULL), cv_groupPriorityBits(NULL),
                         cv_groups(NULL),
                         cv_actionCount(0), cv_actionSize(NULL),
                         cv_actions(NULL)
            {
            };

            ~Chip()
            {
                if (NULL != cv_registers) delete[] cv_registers;
                if (NULL != cv_rules) delete[] cv_rules;
                for (int i = 0; i < cv_groupCount; i++)
                {
                    if (NULL != cv_groupPriorityBits[i])
                        delete cv_groupPriorityBits[i];
                    if (NULL != cv_groups[i])
                        delete[] cv_groups[i];
                }
                if (NULL != cv_groups) delete[] cv_groups;
                if (NULL != cv_groupSize) delete[] cv_groupSize;
                if (NULL != cv_groupFlags) delete[] cv_groupFlags;
                if (NULL != cv_groupPriorityBits) delete[] cv_groupPriorityBits;
                for (int i = 0; i < cv_actionCount; i++)
                    if (NULL != cv_actions[i]) delete[] cv_actions[i];
                if (NULL != cv_actions) delete[] cv_actions;
                if (NULL != cv_actionSize) delete[] cv_actionSize;
            };
    };

    errlHndl_t LoadChip(UtilStream & i_stream, Chip & o_chip);

} // end namespace Prdr

#endif
OpenPOWER on IntegriCloud