summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/util/prdfErrorSignature.H
blob: 0497fcbb4814485e42f92ec0efcc61072e51d542 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/util/prdfErrorSignature.H $          */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2012,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 ErrorSignature_h
#define ErrorSignature_h

/** @file prdfErrorSignature.H
 *  @brief PRD error signature
 */

#include <iipconst.h>
#include <prdfTrace.H>

namespace PRDF
{
/** @class ErrorSignature
 *
 *  A complete error signature is a 64-bit number where:
 *      The 1st 32-bits is representation of a chip.
 *      The 2nd 32-bits is the signature ID.
 *  The signature ID is defined the following:
 *      The 1st 16-bits is the register ID.
 *      The 2nd 16-bits is the error code.
 */
class ErrorSignature
{
  public:

    /**
     * @brief Constructor
     */
    ErrorSignature() : iv_chipId(0), iv_regId(0), iv_errCode(0) {}

    /**
     * @brief operator==
     */
    int operator==( const ErrorSignature & r ) const
    {
        return ( iv_chipId  == r.iv_chipId  &&
                 iv_regId   == r.iv_regId   &&
                 iv_errCode == r.iv_errCode );
    }

    /**
     * @brief operator!=
     */
    int operator!=( const ErrorSignature & r ) const
    {
        return ( iv_chipId  != r.iv_chipId  ||
                 iv_regId   != r.iv_regId   ||
                 iv_errCode != r.iv_errCode );
    }

    /**
     * @brief operator<
     */
    bool operator<( const ErrorSignature & r ) const
    {
        if ( iv_chipId == r.iv_chipId )
        {
            if ( iv_regId == r.iv_regId )
                return ( iv_errCode < r.iv_errCode );
            else
                return ( iv_regId < r.iv_regId );
        }
        else
            return ( iv_chipId < r.iv_chipId );
    };

    /**
     * @brief Clears the signature.
     */
    void clear()
    {
        iv_chipId   = 0;
        iv_regId    = 0;
        iv_errCode  = 0;
        TraceSignature();
    }

    /**
     * @brief Sets the chip ID.
     * @note  Clears signature ID.
     * @param i_chipId The chip's ID.
     */
    void setChipId( uint32_t i_chipId )
    {
        iv_chipId   = i_chipId;
        iv_regId    = 0;
        iv_errCode  = 0;
        TraceSignature();
    }

    /**
     * @brief Sets the signature ID.
     * @param i_sigId The signature ID.
     */
    void setSigId( uint32_t i_sigId )
    {
        iv_regId    = (uint16_t)(i_sigId >> 16);
        iv_errCode  = (uint16_t)(i_sigId & 0xffff);
        TraceSignature();
    }

    /**
     * @brief Sets the signature's register ID.
     * @param i_regId The signature's register ID.
     */
    void setRegId( uint16_t i_regId )
    {
        iv_regId    = i_regId;
        iv_errCode  = 0;
        TraceSignature();
    }

    /**
     * @brief Sets the signature's error code.
     * @param i_errCode The signature's error code.
     */
    void setErrCode( uint16_t i_errCode )
    {
        iv_errCode  = i_errCode;
        TraceSignature();
    }

    /**
     * @return The chip ID.
     */
    uint32_t getChipId() const { return iv_chipId; }

    /**
     * @return The signature ID.
     */
    uint32_t getSigId() const
    {
        return ((uint32_t)iv_regId << 16) | (uint32_t)iv_errCode;
    }

  private:

    /**
     * @brief Create a trace statement for the current signature.
     */
    void TraceSignature() const
    {
        PRDF_INF( "PRD Signature %08X %08X", getChipId(), getSigId() );
    }

    uint32_t iv_chipId;  ///< 32-bit representation of a chip
    uint16_t iv_regId;   ///< 16-bit register ID
    uint16_t iv_errCode; ///< 16-bit error code
};
} //End namespace PRDF
#endif

OpenPOWER on IntegriCloud