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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/usr/diag/prdf/common/framework/register/prdfHomRegisterAccess.C $ */
/* */
/* IBM CONFIDENTIAL */
/* */
/* COPYRIGHT International Business Machines Corp. 2002,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 */
/**
@file prdfHomRegisterAccess.C
@brief definition of HomRegisterAccess
*/
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#define prdfHomRegisterAccess_C
#ifdef __HOSTBOOT_MODULE
#include <ecmdDataBufferBase.H>
#include <fapi.H>
#include <errlmanager.H>
#include <devicefw/userif.H>
#include <targeting/common/targetservice.H>
#else
#include <ecmdDataBuffer.H>
#include <hwsvScanScom.H>
#include <chicservlib.H>
#include <hwsvExecutionService.H>
#endif
#include <prdfHomRegisterAccess.H>
#include <prdf_service_codes.H>
#include <iipbits.h>
#include <iipglobl.h>
#include <prdfMain.H>
#include <prdfPlatServices.H>
#undef prdfHomRegisterAccess_C
namespace PRDF
{
//----------------------------------------------------------------------
// User Types
//----------------------------------------------------------------------
//----------------------------------------------------------------------
// Constants
//----------------------------------------------------------------------
//----------------------------------------------------------------------
// Macros
//----------------------------------------------------------------------
//----------------------------------------------------------------------
// Internal Function Prototypes
//----------------------------------------------------------------------
//----------------------------------------------------------------------
// Global Variables
//----------------------------------------------------------------------
//------------------------------------------------------------------------------
// Member Function Specifications
//------------------------------------------------------------------------------
ScomService& getScomService()
{
return PRDF_GET_SINGLETON(theScomService);
}
ScomService::ScomService() :
iv_ScomAccessor(NULL)
{
PRDF_DTRAC("ScomService() initializing default iv_ScomAccessor");
iv_ScomAccessor = new ScomAccessor();
}
ScomService::~ScomService()
{
if(NULL != iv_ScomAccessor)
{
PRDF_DTRAC("~ScomService() deleting iv_ScomAccessor");
delete iv_ScomAccessor;
iv_ScomAccessor = NULL;
}
}
void ScomService::setScomAccessor(ScomAccessor & i_ScomAccessor)
{
PRDF_DTRAC("ScomService::setScomAccessor() setting new scom accessor");
if(NULL != iv_ScomAccessor)
{
PRDF_TRAC("ScomService::setScomAccessor() deleting old iv_ScomAccessor");
delete iv_ScomAccessor;
iv_ScomAccessor = NULL;
}
iv_ScomAccessor = &i_ScomAccessor;
}
uint32_t ScomService::Access(TARGETING::TargetHandle_t i_target,
BIT_STRING_CLASS & bs,
uint64_t registerId,
MopRegisterAccess::Operation operation) const
{
PRDF_DENTER("ScomService::Access()");
uint32_t rc = iv_ScomAccessor->Access(i_target,
bs,
registerId,
operation);
PRDF_DEXIT("ScomService::Access(): rc=%d", rc);
return rc;
}
uint32_t ScomAccessor::Access(TARGETING::TargetHandle_t i_target,
BIT_STRING_CLASS & bs,
uint64_t registerId,
MopRegisterAccess::Operation operation) const
{
PRDF_DENTER("ScomAccessor::Access()");
uint32_t rc = SUCCESS;
errlHndl_t errH = NULL;
uint32_t bsize = bs.GetLength();
uint32_t l_ecmdRc = ECMD_DBUF_SUCCESS;
if(i_target != NULL)
{
#ifdef __HOSTBOOT_MODULE
ecmdDataBufferBase buffer(bsize);
uint64_t l_data = 0;
size_t l_size = sizeof(uint64_t);
#else
ecmdDataBuffer buffer(bsize);
#endif
switch (operation)
{
case MopRegisterAccess::WRITE:
for(unsigned int i = 0; i < bsize; ++i)
{
if(bs.IsSet(i)) buffer.setBit(i);
}
// FIXME: If register is in a EX chiplet, need to also update
// PORE image ????
#ifdef __HOSTBOOT_MODULE
l_data = buffer.getDoubleWord(0);
errH = deviceWrite( i_target,
&l_data,
l_size,
DEVICE_SCOM_ADDRESS(registerId));
#else
errH = HWSV::hwsvPutScom(i_target, registerId, buffer);
#endif
break;
case MopRegisterAccess::READ:
bs.Pattern(0x00000000); // clear all bits
#ifdef __HOSTBOOT_MODULE
errH = deviceRead( i_target, &l_data, l_size,
DEVICE_SCOM_ADDRESS(registerId) );
l_ecmdRc = buffer.setDoubleWord(0, l_data);
#else
errH = HWSV::hwsvGetScom(i_target, registerId, buffer);
#endif
for(unsigned int i = 0; i < bsize; ++i)
{
if(buffer.isBitSet(i)) bs.Set(i);
}
break;
default:
PRDF_ERR("ScomAccessor::Access() unsuppported scom op: 0x%08X", operation);
break;
} // end switch operation
}
else // Invalid target
{
/*@
* @errortype
* @subsys EPUB_FIRMWARE_SP
* @reasoncode PRDF_CODE_FAIL
* @moduleid PRDF_HOM_SCOM
* @userdata1 PRD Return code = SCR_ACCESS_FAILED
* @userdata2 The invalid ID causing the fail
* @devdesc Access SCOM failed due to NULL target handle
* @procedure EPUB_PRC_SP_CODE
*/
// create an error log
PRDF_CREATE_ERRL(errH,
ERRL_SEV_PREDICTIVE, // error on diagnostic
ERRL_ETYPE_NOT_APPLICABLE,
SRCI_MACH_CHECK,
SRCI_NO_ATTR,
PRDF_HOM_SCOM, // module id
FSP_DEFAULT_REFCODE, // refcode What do we use???
PRDF_CODE_FAIL, // Reason code
SCR_ACCESS_FAILED, // user data word 1
PlatServices::getHuid(i_target), // user data word 2
0x0000, // user data word 3
0x0000 // user data word 4
);
}
if(errH)
{
rc = PRD_SCANCOM_FAILURE;
PRDF_ADD_SW_ERR(errH, rc, PRDF_HOM_SCOM, __LINE__);
PRDF_ADD_PROCEDURE_CALLOUT(errH, SRCI_PRIORITY_MED, EPUB_PRC_SP_CODE);
bool l_isAbort = false;
PRDF_ABORTING(l_isAbort);
if (!l_isAbort)
{
PRDF_COMMIT_ERRL(errH, ERRL_ACTION_SA|ERRL_ACTION_REPORT);
}
else
{
delete errH;
errH = NULL;
}
}
if (l_ecmdRc != ECMD_DBUF_SUCCESS)
{
PRDF_ERR( "ScomAccessor::Access ecmdDataBuffer "
"operation failed with ecmd_rc = 0x%.8X", l_ecmdRc );
/*@
* @errortype
* @subsys EPUB_FIRMWARE_SP
* @reasoncode PRDF_ECMD_DATA_BUFFER_FAIL
* @moduleid PRDF_HOM_SCOM
* @userdata1 ecmdDataBuffer return code
* @userdata2 Chip HUID
* @userdata3 unused
* @userdata4 unused
* @devdesc Low-level data buffer support returned a failure. Probable firmware error.
* @procedure EPUB_PRC_SP_CODE
*/
errlHndl_t ecmd_rc_errl = NULL;
PRDF_CREATE_ERRL(ecmd_rc_errl,
ERRL_SEV_PREDICTIVE, // error on diagnosticERRL_ETYPE_NOT_APPLICABLE
ERRL_ETYPE_NOT_APPLICABLE,
SRCI_MACH_CHECK, // B1xx src
SRCI_NO_ATTR,
PRDF_HOM_SCOM, // module id
FSP_DEFAULT_REFCODE, // refcode
PRDF_ECMD_DATA_BUFFER_FAIL, // Reason code - see prdf_service_codes.H
l_ecmdRc, // user data word 1
PlatServices::getHuid(i_target), // user data word 2
0, // user data word 3
0 // user data word 4
);
PRDF_ADD_PROCEDURE_CALLOUT(ecmd_rc_errl, SRCI_PRIORITY_MED, EPUB_PRC_SP_CODE);
PRDF_COMMIT_ERRL(ecmd_rc_errl, ERRL_ACTION_REPORT);
rc = FAIL;
}
PRDF_DEXIT("ScomAccessor::Access(): rc=%d", rc);
return rc;
}
//------------------------------------------------------------------------------
uint32_t HomRegisterAccessScom::Access( BIT_STRING_CLASS & bs,
uint64_t registerId,
Operation operation) const
{
PRDF_DENTER("HomRegisterAccessScom::Access()");
uint32_t rc = getScomService().Access(iv_ptargetHandle,
bs,
registerId,
operation);
PRDF_DEXIT("HomRegisterAccessScom::Access() rc=%d", rc);
return rc;
}
//------------------------------------------------------------------------------
HomRegisterAccessScan::HomRegisterAccessScan(
TARGETING::TargetHandle_t i_ptargetHandle,
ScanRingField * start, ScanRingField * end )
: MopRegisterAccess(), iv_punitHandle(i_ptargetHandle)
{
iv_aliasIds.reserve(end-start);
while(start != end)
{
iv_aliasIds.push_back(*start);
++start;
}
}
//------------------------------------------------------------------------------
uint32_t HomRegisterAccessScan::Access(BIT_STRING_CLASS & bs,
uint64_t registerId,
Operation operation) const
{
uint32_t rc = SUCCESS;
errlHndl_t errH = NULL;
HUID l_chipHUID = PlatServices::getHuid(iv_punitHandle);
if(operation == MopRegisterAccess::READ)
{
if(iv_punitHandle != NULL)
{
#ifdef __HOSTBOOT_MODULE
ecmdDataBufferBase buf(bs.GetLength());
#else
ecmdDataBuffer buf(bs.GetLength());
#endif
uint32_t curbit = 0;
bs.Pattern(0x00000000); // clear desination bit string
for(AliasIdList::const_iterator i = iv_aliasIds.begin(); i != iv_aliasIds.end(); ++i)
{
for(uint32_t j = 0; j != i->length; ++j)
{
if(buf.isBitSet(j)) bs.Set(j+curbit);
}
curbit += i->length;
}
}
else
{
/*@
* @errortype
* @subsys EPUB_FIRMWARE_SP
* @reasoncode PRDF_CODE_FAIL
* @moduleid PRDF_HOM_SCAN
* @userdata1 PRD Return code = SCR_ACCESS_FAILED
* @userdata2 The invalid ID causing the fail
* @userdata3 Code location = 0x0001
* @devdesc Access Scan failed due to an invalid function unit
* @procedure EPUB_PRC_SP_CODE
*/
// create an error log
PRDF_CREATE_ERRL(errH,
ERRL_SEV_PREDICTIVE, // error on diagnostic
ERRL_ETYPE_NOT_APPLICABLE,
SRCI_MACH_CHECK,
SRCI_NO_ATTR,
PRDF_HOM_SCAN, // module id
FSP_DEFAULT_REFCODE, // refcode What do we use???
PRDF_CODE_FAIL, // Reason code
SCR_ACCESS_FAILED, // user data word 1
l_chipHUID, // user data word 2
0x0001, // user data word 3
0x0000 // user data word 4
);
}
}
// PRD does not ever expect to write scan rings - create an error log
else
{
PRDF_ERR( "HomRegisterAccessScan::Access "
"only scan read is supported. Invalid Scan Op: 0x%.8X", operation );
/*@
* @errortype
* @subsys EPUB_FIRMWARE_SP
* @reasoncode PRDF_UNSUPPORTED_SCAN_WRITE
* @moduleid PRDF_HOM_SCAN
* @userdata1 PRD Return code = SCR_ACCESS_FAILED
* @userdata2 The ID for the scan
* @userdata3 Code location = 0x0002
* @devdesc Access Scan failed. PRD does not ever expect to write scan rings.
* @procedure EPUB_PRC_SP_CODE
*/
// create an error log
PRDF_CREATE_ERRL(errH,
ERRL_SEV_PREDICTIVE, // error on diagnostic
ERRL_ETYPE_NOT_APPLICABLE,
SRCI_MACH_CHECK,
SRCI_NO_ATTR,
PRDF_HOM_SCAN, // module id
FSP_DEFAULT_REFCODE, // refcode What do we use???
PRDF_UNSUPPORTED_SCAN_WRITE, // Reason code
SCR_ACCESS_FAILED, // user data word 1
l_chipHUID, // user data word 2
0x0002, // user data word 3
0x0000 // user data word 4
);
}
if(errH)
{
rc = PRD_SCANCOM_FAILURE;
PRDF_ADD_SW_ERR(errH, rc, PRDF_HOM_SCAN, __LINE__);
PRDF_ADD_PROCEDURE_CALLOUT(errH, SRCI_PRIORITY_MED, EPUB_PRC_SP_CODE);
bool l_isAbort = false;
PRDF_ABORTING(l_isAbort);
if (!l_isAbort)
{
PRDF_COMMIT_ERRL(errH, ERRL_ACTION_SA|ERRL_ACTION_REPORT);
}
else
{
delete errH;
errH = NULL;
}
}
return rc;
}
} // End namespace PRDF
|