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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/usr/hwas/hwasPlat.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 */
/**
* @file hwasPlat.C
*
* @brief Platform specifics
*/
#include <hwas/common/hwas.H>
#include <hwas/common/hwasCommon.H>
#include <hwas/common/hwasCallout.H>
#include <hwas/common/deconfigGard.H>
#include <devicefw/driverif.H>
#include <initservice/taskargs.H>
#include <vpd/mvpdenums.H>
#include <stdio.h>
#include <sys/mm.h>
#include <pnor/pnorif.H>
namespace HWAS
{
class RegisterHWASFunctions
{
public:
RegisterHWASFunctions()
{
// HWAS is awake
// register processCallout function for ErrlEntry::commit
HWAS_DBG("module load: calling errlog::setHwasProcessCalloutFn");
ERRORLOG::ErrlManager::setHwasProcessCalloutFn(
(processCalloutFn)(&processCallout));
}
};
// this causes the function to get run at module load.
RegisterHWASFunctions registerHWASFunctions;
using namespace TARGETING;
//******************************************************************************
// platReadIDEC function
//******************************************************************************
errlHndl_t platReadIDEC(const TargetHandle_t &i_target)
{
// we got a target - read the ID/EC
// and update the appropriate ATTR_ field.
uint64_t id_ec;
size_t op_size = sizeof(id_ec);
errlHndl_t errl = NULL;
// At the time when we read IDEC, the tp chiplet of Centaur & slave
// processors are not yet enabled; therefore, we can not read IDEC
// using SCOM path. We must use FSI path to read the IDEC values.
// For master proc, use scom
// For everything else, use FSI(0x1028)
TARGETING::Target* l_pMasterProcChip = NULL;
TARGETING::targetService(). masterProcChipTargetHandle(l_pMasterProcChip);
if (i_target == l_pMasterProcChip)
{
errl = DeviceFW::deviceRead(i_target, &id_ec,
op_size,
DEVICE_SCOM_ADDRESS(0x000F000Full));
}
else
{
errl = DeviceFW::deviceRead(i_target, &id_ec, op_size,
DEVICE_FSI_ADDRESS(0x01028));
}
if (errl == NULL)
{ // no error, so we got a valid ID/EC value back
// EC - nibbles 0,2
// 01234567
uint8_t ec = (((id_ec & 0xF000000000000000ull) >> 56) |
((id_ec & 0x00F0000000000000ull) >> 52));
i_target->setAttr<ATTR_EC>(ec);
// ID - nibbles 1,5,3,4
// 01234567
uint32_t id = (((id_ec & 0x0F00000000000000ull) >> 44) |
((id_ec & 0x00000F0000000000ull) >> 32) |
((id_ec & 0x000F000000000000ull) >> 44) |
((id_ec & 0x0000F00000000000ull) >> 44));
i_target->setAttr<ATTR_CHIP_ID>(id);
HWAS_DBG( "i_target %.8X - id %x ec %x",
i_target->getAttr<ATTR_HUID>(), id, ec);
}
else
{ // errl was set - this is an error condition.
HWAS_ERR( "i_target %.8X - failed ID/EC read",
i_target->getAttr<ATTR_HUID>());
}
return errl;
} // platReadIDEC
//******************************************************************************
// platReadPartialGood function
//******************************************************************************
errlHndl_t platReadPartialGood(const TargetHandle_t &i_target,
void *o_pgData)
{
errlHndl_t errl = NULL;
HWAS_DBG( "i_target %.8X",
i_target->getAttr<ATTR_HUID>());
// call deviceRead() to find the PartialGood record
uint8_t pgRaw[VPD_CP00_PG_HDR_LENGTH + VPD_CP00_PG_DATA_LENGTH];
size_t pgSize = sizeof(pgRaw);
errl = deviceRead(i_target, pgRaw, pgSize,
DEVICE_MVPD_ADDRESS(MVPD::CP00, MVPD::PG));
if (unlikely(errl != NULL))
{ // errl was set - this is an error condition.
HWAS_ERR( "i_target %.8X - failed partialGood read",
i_target->getAttr<ATTR_HUID>());
}
else
{
#if 0
// Unit test. set P8_MURANO.config to have 4 procs, and this code will
// alter the VPD so that some of the procs and chiplets should get marked
// as NOT functional.
{
// skip past the header
uint16_t *pgData = reinterpret_cast <uint16_t *>(&pgRaw[VPD_CP00_PG_HDR_LENGTH]);
if (i_target->getAttr<ATTR_HUID>() == 0x50000)
{ // 1st proc - let it go thru ok.
}
else
if (i_target->getAttr<ATTR_HUID>() == 0x50001)
{ // 2nd proc - mark Pervasive bad - entire chip
// should be marked present and NOT functional
pgData[VPD_CP00_PG_PERVASIVE_INDEX] = 0;
}
else
if (i_target->getAttr<ATTR_HUID>() == 0x50002)
{ // 3rd proc - part of XBUS is bad
pgData[VPD_CP00_PG_XBUS_INDEX] = 0;
}
else
if (i_target->getAttr<ATTR_HUID>() == 0x50003)
{ // 4th proc - EX13 and EX14 are bad
pgData[VPD_CP00_PG_EX0_INDEX+13] = 0;
pgData[VPD_CP00_PG_EX0_INDEX+14] = 0;
}
}
#endif
// skip past the header
void *pgData = static_cast<void *>(&pgRaw[VPD_CP00_PG_HDR_LENGTH]);
HWAS_DBG_BIN("PG record", pgData, VPD_CP00_PG_DATA_LENGTH);
// copy the data back into the caller's buffer
memcpy(o_pgData, pgData, VPD_CP00_PG_DATA_LENGTH);
}
return errl;
} // platReadPartialGood
//******************************************************************************
// platPresenceDetect function
//******************************************************************************
errlHndl_t platPresenceDetect(TargetHandleList &io_targets)
{
errlHndl_t errl = NULL;
// we got a list of targets - determine if they are present
// if not, delete them from the list
for (TargetHandleList::iterator pTarget_it = io_targets.begin();
pTarget_it != io_targets.end();
) // increment will be done in the loop below
{
TargetHandle_t pTarget = *pTarget_it;
// if CLASS_ENC
// by definition, hostboot only has 1 node/enclosure, and we're
// here, so it is functional
if (pTarget->getAttr<ATTR_CLASS>() == CLASS_ENC)
{
HWAS_DBG("pTarget %.8X - detected present",
pTarget->getAttr<ATTR_HUID>());
// on to the next target
pTarget_it++;
continue;
}
// call deviceRead() to see if they are present
bool present = false;
size_t presentSize = sizeof(present);
errl = deviceRead(pTarget, &present, presentSize,
DEVICE_PRESENT_ADDRESS());
if (unlikely(errl != NULL))
{ // errl was set - this is an error condition.
HWAS_ERR( "pTarget %.8X - failed presence detect",
pTarget->getAttr<ATTR_HUID>());
// commit the error but keep going
errlCommit(errl, HWAS_COMP_ID);
// errl is now NULL
// target is not present - fall thru
present = false;
}
if (present == true)
{
HWAS_DBG( "pTarget %.8X - detected present",
pTarget->getAttr<ATTR_HUID>());
// advance to next entry in the list
pTarget_it++;
}
else
{ // chip not present -- remove from list
HWAS_DBG( "pTarget %.8X - no presence",
pTarget->getAttr<ATTR_HUID>());
// erase this target, and 'increment' to next
pTarget_it = io_targets.erase(pTarget_it);
}
} // for pTarget_it
return errl;
} // platPresenceDetect
GardAddress::GardAddress(bool &o_gardEnabled)
{
DeconfigGard::GardRecord *l_addr = HWAS::theDeconfigGard().iv_pGardRecords;
HWAS_INF("GardAddress ctor: iv_pGardRecords %p", l_addr);
o_gardEnabled = true;
// if this is the first time thru here, get the PNOR address.
if (l_addr == NULL)
{
PNOR::SectionInfo_t l_section;
errlHndl_t errl;
errl = PNOR::getSectionInfo(PNOR::GUARD_DATA, PNOR::CURRENT_SIDE,
l_section);
if (errl)
{
HWAS_ERR("PNOR::getSectionInfo failed!!!");
// no support for GARD in this configuration.
// Commit the log as unrecoverable and keep going.
errlCommit(errl, HWAS_COMP_ID);
// errl is now NULL
// set flag so that we don't continue to try to write GARD records
o_gardEnabled = false;
}
else
{
l_addr = reinterpret_cast<DeconfigGard::GardRecord *>
(l_section.vaddr);
HWAS_DBG("PNOR vaddr=%p size=%d", l_section.vaddr, l_section.size);
// tell the DeconfigGard what the address
HWAS::theDeconfigGard().iv_pGardRecords = l_addr;
// and let him compute and save maxRecords and nextRecordId
HWAS::theDeconfigGard()._GardRecordIdSetup(l_section.size);
}
HWAS_INF("GardAddress iv_pGardRecords=%p", l_addr);
}
}
GardAddress::~GardAddress()
{
// flush PNOR iff we wrote
if (iv_addr.size() > 0)
{
for (std::vector<void *>::iterator iter = iv_addr.begin();
iter != iv_addr.end();
iter++)
{
HWAS_DBG("flushing GARD in PNOR: addr=%p", *iter);
int l_rc = mm_remove_pages(FLUSH, (void *) *iter,
sizeof(DeconfigGard::GardRecord));
if (l_rc)
{
HWAS_ERR("mm_remove_pages(FLUSH,%p,%d) returned %d",
*iter, sizeof(DeconfigGard::GardRecord),l_rc);
}
}
// all done - just get rid of them all
iv_addr.clear();
}
}
} // namespace HWAS
|