summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/test/prdsimSignatureParser.C
blob: aa2927dd5772e3e3e6444973e4a0ec71a51bb961 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/test/prdsimSignatureParser.C $              */
/*                                                                        */
/* 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                                                     */

#include "prdsimSignatureParser.H"
#include <prdfTrace.H>

namespace PRDF
{

static const char * STATUS_BAR = "=================================================";
static const char * SIG_ADD    = "==========     PRD Signature Add       ==========";
static const char * SIG_REPORT = "==========    PRD Signature Report     ==========";
static const char * SIG_SUM    = "==========    PRD Signature Summary    ==========";

/**
 *  @brief Returns a reference to the SimSignatureParser singleton
 *
 *  @return Reference to the SimSignatureParser
 */
/*
SimSignatureParser& getSimSignatureParser()
{
    return PRDF_GET_SINGLETON(theSimSignatureParser);
}
*/
void SimSignatureParser::Add(uint32_t i_chip, uint32_t i_sig)
//:iv_EnumMap(converter)
{
    PRDF_TRAC("%s", STATUS_BAR);
    PRDF_TRAC("%s", SIG_ADD);
    Signature signature(i_chip, i_sig);
    expectedSigList.push_back(signature);
    PRDF_TRAC("Error Signature   : 0x%08X 0x%08X", signature.chip, signature.code);
    PRDF_TRAC("%s", STATUS_BAR);
}

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

void SimSignatureParser::Report(uint32_t i_chip, uint32_t i_sig)
{
  PRDF_TRAC("%s", STATUS_BAR);
  PRDF_TRAC("%s", SIG_REPORT);

  // looking for the following in errlText
  //| PRD Signature            : 0x00811DE0 0x01010004                             |
  Signature signature(i_chip,i_sig);
  actualSigList.push_back(signature);
  const char * passOrFail = " Failed";

  if(expectedSigList.size() == 0)
  {
    PRDF_TRAC(" (W) No expected signature specified");
  }
  else
  {
    int thisIdx = actualSigList.size() - 1;
    int expectedIdx = thisIdx % expectedSigList.size();
    if(expectedSigList[expectedIdx] != actualSigList[thisIdx])
    {
        PRDF_ERR(" (S)FAIL! Expected 0x%08X 0x%08X", expectedSigList[expectedIdx].chip, expectedSigList[expectedIdx].code);
    }
    else
    {
      passOrFail = " Passed";
    }
  }

  PRDF_TRAC("Error Signature   : 0x%08X 0x%08X %s", signature.chip, signature.code, passOrFail);

  PRDF_TRAC("Description       : %s", Description(signature));
  PRDF_TRAC("%s", STATUS_BAR);
}

const char * SimSignatureParser::Description(const Signature & signature)
{
  // this is already in prdfLogParse.C - Need to make it comon TODO
  struct prdfErrorCodeDescription
  {
    uint32_t signature;
    const char * description;
  };

  static prdfErrorCodeDescription l_defaultErrorCodes[] =
  {
    {0xFFFFFFFF, "Undefined error code" },  //this must be first
    {0x0000DD00, "Assert failed in PRD"},
    {0x0000DD01, "Invalid attention type passed to PRD"},
    {0x0000DD02, "No active error bits found"},
    {0x0000DD03, "Chip connection lookup failure"},
    {0x0000DD05, "Internal PRD code"},
    {0x0000DD09, "Fail to access attention data from registry"},
    {0x0000DD11, "SRC Access failure"},
    {0x0000DD12, "HWSV Access failure"},
    {0x0000DD20, "Config error - no domains in system"},
    {0x0000DD21, "No active attentions found"},
    {0x0000DD23, "Unknown chip raised attention"},
    {0x0000DD24, "PRD Model is not built"},
    {0x0000DD27, "PrdRbsCallback failure"},
    {0x0000DD28, "PrdStartScrub failure"},
    {0x0000DD29, "PrdResoreRbs failure"},
    {0x0000DD81, "Multiple bits on in Error Register"},
    {0x0000DD90, "Scan comm access from Error Register failed"},
    {0x0000DD91, "Scan comm access from Error Register failed due to Power Fault"},
    {0x0000DDFF, "Special return code indicating Not to reset or mask FIR bits"},
    {0x00ED0000, "PLL error"},
    {0,NULL} // this must exist and must be last
  };

  const char * result = NULL;
//  PrdrErrSigTable & est = prdfGetErrorSigTable();
//  result = est[l_homt][signature.code];


  if(NULL == result)
  {
      for(uint32_t i = 1; l_defaultErrorCodes[i].description != NULL; ++i)
      {
            if(0x0000DD00 == (signature.code & 0x0000FF00))
            {
                if(l_defaultErrorCodes[i].signature ==
                   (signature.code & 0x0000FFFF))
                {
                    result = l_defaultErrorCodes[i].description;
                    break;
                }
            }
            else
            {
                if(l_defaultErrorCodes[i].signature == signature.code)
                {
                    result = l_defaultErrorCodes[i].description;
                    break;
                }
            }
      }
  }
  if(NULL == result)
  {
    result = "(W) No description found";
  }
  return result;
}

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

bool SimSignatureParser::Summary(void)
{
  PRDF_TRAC("%s", STATUS_BAR);
  PRDF_TRAC("%s", SIG_SUM);
  // expected list rolls
  bool passed = true;
  if(expectedSigList.size() == 0)
  {
    PRDF_TRAC("(W) There were no expected signatures specified in the testcase");
  }
  else
  {
    int iterations = actualSigList.size();
    for(int i = 0; i < iterations; ++i)
    {
      int expectedIdx = i % expectedSigList.size();
      if(expectedSigList[expectedIdx] != actualSigList[i])
      {
        PRDF_ERR("(S)Iteration %d  signature: 0x%08X 0x%08X",
                 i, actualSigList[i].chip, actualSigList[i].code);

        PRDF_ERR(" Expected 0x%08X 0x%08X",
                 expectedSigList[expectedIdx].chip, expectedSigList[expectedIdx].code);

        passed = false;
      }
    }
  }
  if(passed)
  {
    PRDF_TRAC("All error signatures passed (E: %d, A: %d)", expectedSigList.size(), actualSigList.size());
  }
  else
  {
      if((actualSigList.size() == 0) && expectedSigList.size() > 0)
      {
          PRDF_ERR("There were no actual signatures reported");
          int iterations = expectedSigList.size();
          for(int i = 0; i < iterations; ++i)
          {
              PRDF_ERR(" Expected 0x%08X 0x%08X",
                       expectedSigList[i].chip, expectedSigList[i].code);
          }
      }
  }

  PRDF_TRAC("%s", STATUS_BAR);
  return passed;
}

} // End namespace PRDF
OpenPOWER on IntegriCloud