summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/framework/rule/prdrCommon.H
blob: 47502a1bec333aef22cadfa5f84d9294af52040f (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/framework/rule/prdrCommon.H $        */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2005,2012              */
/*                                                                        */
/* 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 __PRDRCOMMON_H
#define __PRDRCOMMON_H

/**
 * @file prdrCommon.H
 * @brief Common enums, typedefs, etc. between compiler and loader for rule
 * table code.
 */

#include <map>
#include <stdint.h>

#ifdef __PRD_RULE_COMPILE
  #include <string>
#endif

// @jl02 JL adding a constant for the number of attention types.
enum PrdrNumberOfAttentions
{
  NUM_GROUP_ATTN = 4,
};


/**
 * @namespace Prdr
 * @brief Namespace to encapsulate Prdr specific enums, classes, and typedefs.
 */
namespace Prdr
{
    /**
     * @enum PrdrRegisterFlags
     * @brief Flags for which register attributes are contained in a register
     * definition.
     *
     * When loading the .prf file, each register entry will contain a set of
     * these flags that describe what attributes are non-default (and therefore
     * contained in the file).
     */
    enum PrdrRegisterFlags
    {
            /** Non-default scomlen */
        PRDR_REGISTER_SCOMLEN = 0x1,
            /** Resets defined */
        PRDR_REGISTER_RESETS = 0x2,
            /** Masks defined */
        PRDR_REGISTER_MASKS = 0x4,
            /** Capture requirements */
        PRDR_REGISTER_CAPTURE = 0x8,
    };

    /**
     * @enum PrdrGroupFlags
     * @brief Flags for which group attributes are contained in a group
     * definition.
     *
     * When loading the .prf file, each group entry will contain a set of
     * these flags that describe what attributes are non-default (and therefore
     * contained in the file).
     */
    enum PrdrGroupFlags
    {
            /** Single Bit Filter */
        PRDR_GROUP_FILTER_SINGLE_BIT = 0x1,
            /** Priority Bit Filter */
        PRDR_GROUP_FILTER_PRIORITY = 0x2,
    };

    /**
     * @enum PrdrTimeBaseFlags
     * @brief Enums for time base
     *
     * When reading rule file, these flags can be used to write in prf files
     * for time base values.
     */
    enum PrdrTimeBaseFlags
    {
        PRDR_TIME_BASE_SEC  = 1,
        PRDR_TIME_BASE_MIN  = PRDR_TIME_BASE_SEC  * 60,
        PRDR_TIME_BASE_HOUR = PRDR_TIME_BASE_MIN  * 60,
        PRDR_TIME_BASE_DAY  = PRDR_TIME_BASE_HOUR * 24,
    };

    /**
     * @enum PrdrExprOps
     * @brief Single char op's defined for .prf files.
     *
     * Needed for properly reading/writing .prf files.
     */
    enum PrdrExprOps
    {
        REF_RULE  = 'r',
        REF_REG   = 'e',
        REF_GRP   = 'g',
        REF_ACT   = 'a',
        INTEGER   = 'I',
        INT_SHORT = 'i',
        BIT_STR   = 'B',
        NOT       = '~',
        AND       = '&',
        OR        = '|',
        XOR       = '^',
        LSHIFT    = 174, // ASCII left-shift
        RSHIFT    = 175, // ASCII right-shift
        RULE      = 'R',
        GROUP     = 'G',
        ACTION    = 'A',

        ATTNLINK  = 'L',

        ACT_THRES = 't',
        ACT_ANALY = 'y',
        ACT_TRY   = '{',
        ACT_DUMP  = 'd',
        ACT_GARD  = '-',
        ACT_CALL  = 'c',
        ACT_FUNC  = 'f',
        ACT_FLAG  = 'F',
        ACT_CAPT  = 'C',
    };

    class PrdrSignatureOp
    {
      public:
        enum { DEFAULT_SIGNATURE = 0x0 };

        static uint16_t combineSig( uint16_t a, uint16_t b )
        {
            // The two signature will be XOR'd together and there is a
            // possibility that the signature could be the same, which would
            // result in 0. So, rotate the first signature to essentially
            // scramble it. This should be able to create a unique signature.
            a = ((a & 0xff80) >> 7) | ((a & 0x007f) << 9); // rotate left 9 bits
            return ( (a ^ b) & 0xffff );
        };
    };

    #ifdef __PRD_RULE_COMPILE
    typedef std::map<uint16_t, std::string> HashCollisionMap;
    #endif
};

#endif


// Change Log *********************************************************
//
//  Flag Reason   Vers Date     Coder    Description
//  ---- -------- ---- -------- -------- -------------------------------
//         D515833  f300 09/19/05 iawillia Add capture support.
//         F526728  f300 10/25/05 iawillia Add >> and << operators to rules.
//         F534311  f300 01/10/06 iawillia Add Bit string.
//         F557408  f310 06/16/06 iawillia Add single-bit filter support.
//  jl02   F605874  f330 07/31/07 lukas    Add functions to PRD framework/Galaxy
//                                                   2 code for unit CS.
// End Change Log *****************************************************
OpenPOWER on IntegriCloud