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
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/sbefw/sbecmdparser.C $ */
/* */
/* OpenPOWER sbe Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2015,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
/* you may not use this file except in compliance with the License. */
/* You may obtain a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
/* implied. See the License for the specific language governing */
/* permissions and limitations under the License. */
/* */
/* IBM_PROLOG_END_TAG */
/*
* @file: ppe/sbe/sbefw/sbecmdparser.C
*
* @brief This file contains the SBE FIFO Commands
*
*/
#include "sbecmdparser.H"
#include "sbecmdscomaccess.H"
#include "sbecmdiplcontrol.H"
#include "sbecmdgeneric.H"
#include "sbecmdmemaccess.H"
#include "sbecmdregaccess.H"
#include "sbecmdcntrldmt.H"
#include "sbecmdringaccess.H"
#include "sbecmdsram.H"
#include "sbecmdcntlinst.H"
#include "sbecmdringaccess.H"
#include "sbetrace.H"
#include "sbe_sp_intf.H"
#include "sbeHostMsg.H"
#include "sbe_host_intf.H"
#include "sbestates.H"
#include "sberegaccess.H"
#include "sbecmdmpipl.H"
#include "sbecmdtracearray.H"
#include "sbecmdCntrlTimer.H"
#include "sbecmdfastarray.H"
// Declaration
static const uint16_t HARDWARE_FENCED_STATE =
SBE_FENCE_AT_CONTINUOUS_IPL|SBE_FENCE_AT_DMT;
static const uint16_t PUT_HARDWARE_FENCED_STATE =
HARDWARE_FENCED_STATE|SBE_FENCE_AT_MPIPL;
////////////////////////////////////////////////////////////////
// @brief g_sbeScomCmdArray
////////////////////////////////////////////////////////////////
static sbeCmdStruct_t g_sbeScomCmdArray [] =
{
{sbeGetScom,
SBE_CMD_GETSCOM,
HARDWARE_FENCED_STATE,
},
{sbePutScom,
SBE_CMD_PUTSCOM,
PUT_HARDWARE_FENCED_STATE,
},
{sbeModifyScom,
SBE_CMD_MODIFYSCOM,
PUT_HARDWARE_FENCED_STATE,
},
{sbePutScomUnderMask,
SBE_CMD_PUTSCOM_MASK,
PUT_HARDWARE_FENCED_STATE,
},
{sbeMultiScom,
SBE_CMD_MULTISCOM,
PUT_HARDWARE_FENCED_STATE,
},
};
////////////////////////////////////////////////////////////////
// @brief g_sbeIplControlCmdArray
//
////////////////////////////////////////////////////////////////
static sbeCmdStruct_t g_sbeIplControlCmdArray [] =
{
{sbeHandleIstep,
SBE_CMD_EXECUTE_ISTEP,
HARDWARE_FENCED_STATE|SBE_FENCE_AT_DUMPING,
// TODO - Issue 157287 - Allow MPIIPL in Isteps state
},
};
////////////////////////////////////////////////////////////////
// @brief g_sbeGenericCmdArray
//
////////////////////////////////////////////////////////////////
static sbeCmdStruct_t g_sbeGenericCmdArray [] =
{
{sbeGetCapabilities,
SBE_CMD_GET_SBE_CAPABILITIES,
SBE_NO_FENCE,
},
{sbeGetFfdc,
SBE_CMD_GET_SBE_FFDC,
SBE_NO_FENCE,
},
{sbeFifoQuiesce,
SBE_CMD_QUIESCE,
SBE_NO_FENCE,
},
};
//////////////////////////////////////////////////////////////
// @brief g_sbeMemoryAccessCmdArray
//
//////////////////////////////////////////////////////////////
static sbeCmdStruct_t g_sbeMemoryAccessCmdArray [] =
{
{sbeGetMem,
SBE_CMD_GETMEM,
SBE_FENCE_AT_CONTINUOUS_IPL,
},
{sbePutMem,
SBE_CMD_PUTMEM,
PUT_HARDWARE_FENCED_STATE,
},
{sbeGetOccSram,
SBE_CMD_GETSRAM_OCC,
HARDWARE_FENCED_STATE,
},
{sbePutOccSram,
SBE_CMD_PUTSRAM_OCC,
PUT_HARDWARE_FENCED_STATE,
},
};
//////////////////////////////////////////////////////////////
// @brief g_sbeInstructionCntlCmdArray
//
//////////////////////////////////////////////////////////////
static sbeCmdStruct_t g_sbeInstructionCntlCmdArray[] =
{
{sbeCntlInst,
SBE_CMD_CONTROL_INSTRUCTIONS,
PUT_HARDWARE_FENCED_STATE,
},
};
//////////////////////////////////////////////////////////////
// @brief g_sbeRegAccessCmdArray
//
//////////////////////////////////////////////////////////////
static sbeCmdStruct_t g_sbeRegAccessCmdArray [] =
{
{sbeGetReg,
SBE_CMD_GETREG,
HARDWARE_FENCED_STATE,
},
{sbePutReg,
SBE_CMD_PUTREG,
PUT_HARDWARE_FENCED_STATE,
},
};
//////////////////////////////////////////////////////////////
// @brief g_sbeMpiplCmdArray
//
//////////////////////////////////////////////////////////////
static sbeCmdStruct_t g_sbeMpiplCmdArray[] =
{
{sbeEnterMpipl,
SBE_CMD_MPIPL_ENTER,
PUT_HARDWARE_FENCED_STATE|SBE_FENCE_AT_ISTEP|
SBE_FENCE_AT_DUMPING,
// Allow Fspless system to enter MPIPL
// Issue 157287
},
{sbeContinueMpipl,
SBE_CMD_MPIPL_CONTINUE,
HARDWARE_FENCED_STATE|SBE_FENCE_AT_ISTEP|
SBE_FENCE_AT_RUNTIME|SBE_FENCE_AT_DUMPING,
// Only allowed State is MPIPL
},
{sbeStopClocks,
SBE_CMD_MPIPL_STOPCLOCKS,
HARDWARE_FENCED_STATE|SBE_FENCE_AT_DUMPING,
},
};
//////////////////////////////////////////////////////////////
// @brief g_sbeRingAccessCmdArray
//
//////////////////////////////////////////////////////////////
static sbeCmdStruct_t g_sbeRingAccessCmdArray [] =
{
{sbeGetRing,
SBE_CMD_GETRING,
SBE_FENCE_AT_CONTINUOUS_IPL|SBE_FENCE_AT_QUIESCE,
},
{sbePutRing,
SBE_CMD_PUTRING,
PUT_HARDWARE_FENCED_STATE|SBE_FENCE_AT_QUIESCE,
},
};
// @brief g_sbeArrayAccessCmdArray[]
//
////////////////////////////////////////////////////////////////
static sbeCmdStruct_t g_sbeArrayAccessCmdArray[] =
{
{sbeControlFastArray,
SBE_CMD_CONTROL_FAST_ARRAY,
SBE_FENCE_AT_QUIESCE,
},
{sbeControlTraceArray,
SBE_CMD_CONTROL_TRACE_ARRAY,
SBE_FENCE_AT_QUIESCE,
},
};
//////////////////////////////////////////////////////////////
// @brief g_sbeCoreStateControlCmdArray
//
//////////////////////////////////////////////////////////////
static sbeCmdStruct_t g_sbeCoreStateControlCmdArray [] =
{
{sbeControlDeadmanTimer,
SBE_PSU_CMD_CONTROL_DEADMAN,
SBE_FENCE_AT_CONTINUOUS_IPL|SBE_FENCE_AT_QUIESCE|
SBE_FENCE_AT_MPIPL|SBE_FENCE_AT_ISTEP|
SBE_FENCE_AT_DUMPING,
},
};
//////////////////////////////////////////////////////////////
// @brief g_sbeControlTimerCmdArray
//
//////////////////////////////////////////////////////////////
static sbeCmdStruct_t g_sbeControlTimerCmdArray [] =
{
{sbeCntrlTimer,
SBE_PSU_CMD_CONTROL_TIMER,
SBE_FENCE_AT_CONTINUOUS_IPL|SBE_FENCE_AT_QUIESCE|
SBE_FENCE_AT_MPIPL|SBE_FENCE_AT_DUMPING,
},
};
//////////////////////////////////////////////////////////////
// @brief g_sbePutRingFromImageCmdArray
//
//////////////////////////////////////////////////////////////
static sbeCmdStruct_t g_sbePutRingFromImageCmdArray [] =
{
{sbePutRingFromImagePSU,
SBE_PSU_MSG_PUT_RING_FROM_IMAGE,
PUT_HARDWARE_FENCED_STATE|SBE_FENCE_AT_QUIESCE,
},
};
//////////////////////////////////////////////////////////////
// @brief g_sbePsuGenericCmdArray
//
//////////////////////////////////////////////////////////////
static sbeCmdStruct_t g_sbePsuGenericCmdArray[] =
{
{sbeSetFFDCAddr,
SBE_PSU_GENERIC_MSG_SET_FFDC_ADDR,
SBE_NO_FENCE,
},
{sbePsuQuiesce,
SBE_PSU_GENERIC_MSG_QUIESCE,
SBE_NO_FENCE,
},
{sbeSetSystemFabricMap,
SBE_PSU_GENERIC_MSG_SYSTEM_FABRIC_MAP,
SBE_NO_FENCE,
},
};
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
uint8_t sbeGetCmdStructAttr (const uint8_t i_cmdClass,
sbeCmdStruct_t **o_ppCmd)
{
#define SBE_FUNC " sbeGetCmdStructAttr "
uint8_t l_numCmds = 0;
*o_ppCmd = NULL;
switch(i_cmdClass)
{
// FIFO Commands
case SBE_CMD_CLASS_IPL_CONTROL:
// @TODO via RTC : 128655
// Use C++ style typecase
l_numCmds = sizeof(g_sbeIplControlCmdArray) /
sizeof(sbeCmdStruct_t);
*o_ppCmd = (sbeCmdStruct_t*)g_sbeIplControlCmdArray;
break;
case SBE_CMD_CLASS_SCOM_ACCESS:
l_numCmds = sizeof(g_sbeScomCmdArray) /
sizeof(sbeCmdStruct_t);
*o_ppCmd = (sbeCmdStruct_t*)g_sbeScomCmdArray;
break;
case SBE_CMD_CLASS_GENERIC_MESSAGE:
l_numCmds = sizeof(g_sbeGenericCmdArray) /
sizeof(sbeCmdStruct_t);
*o_ppCmd = (sbeCmdStruct_t*)g_sbeGenericCmdArray;
break;
case SBE_CMD_CLASS_MEMORY_ACCESS:
l_numCmds = sizeof(g_sbeMemoryAccessCmdArray) /
sizeof(sbeCmdStruct_t);
*o_ppCmd = (sbeCmdStruct_t*)g_sbeMemoryAccessCmdArray;
break;
case SBE_CMD_CLASS_INSTRUCTION_CONTROL:
l_numCmds = sizeof(g_sbeInstructionCntlCmdArray) /
sizeof(sbeCmdStruct_t);
*o_ppCmd = (sbeCmdStruct_t*)g_sbeInstructionCntlCmdArray;
break;
case SBE_CMD_CLASS_REGISTER_ACCESS:
l_numCmds = sizeof(g_sbeRegAccessCmdArray) /
sizeof(sbeCmdStruct_t);
*o_ppCmd = (sbeCmdStruct_t*)g_sbeRegAccessCmdArray;
break;
case SBE_CMD_CLASS_RING_ACCESS:
l_numCmds = sizeof(g_sbeRingAccessCmdArray) /
sizeof(sbeCmdStruct_t);
*o_ppCmd = (sbeCmdStruct_t*)g_sbeRingAccessCmdArray;
break;
case SBE_CMD_CLASS_MPIPL_COMMANDS:
l_numCmds = sizeof(g_sbeMpiplCmdArray) /
sizeof(sbeCmdStruct_t);
*o_ppCmd = (sbeCmdStruct_t*)g_sbeMpiplCmdArray;
break;
case SBE_CMD_CLASS_ARRAY_ACCESS:
l_numCmds = sizeof(g_sbeArrayAccessCmdArray) /
sizeof(sbeCmdStruct_t);
*o_ppCmd = (sbeCmdStruct_t*)g_sbeArrayAccessCmdArray;
break;
// PSU Commands
case SBE_PSU_CMD_CLASS_CORE_STATE:
l_numCmds = sizeof(g_sbeCoreStateControlCmdArray) /
sizeof(sbeCmdStruct_t);
*o_ppCmd = (sbeCmdStruct_t*)g_sbeCoreStateControlCmdArray;
break;
case SBE_PSU_CMD_CLASS_RING_ACCESS:
l_numCmds = sizeof(g_sbePutRingFromImageCmdArray) /
sizeof(sbeCmdStruct_t);
*o_ppCmd = (sbeCmdStruct_t*)g_sbePutRingFromImageCmdArray;
break;
case SBE_PSU_CMD_CLASS_GENERIC:
l_numCmds = sizeof(g_sbePsuGenericCmdArray) /
sizeof(sbeCmdStruct_t);
*o_ppCmd = (sbeCmdStruct_t*)g_sbePsuGenericCmdArray;
break;
case SBE_PSU_CMD_CLASS_CNTRL_TIMER:
l_numCmds = sizeof(g_sbeControlTimerCmdArray) /
sizeof(sbeCmdStruct_t);
*o_ppCmd = (sbeCmdStruct_t*)g_sbeControlTimerCmdArray;
break;
// This will grow with each class of chipOp in future
default:
break;
}
return l_numCmds;
#undef SBE_FUNC
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
uint8_t sbeValidateCmdClass (const uint8_t i_cmdClass,
const uint8_t i_cmdOpcode)
{
#define SBE_FUNC " sbeValidateCmdClass "
uint8_t l_rc = SBE_SEC_COMMAND_NOT_SUPPORTED;
SBE_INFO(SBE_FUNC"i_cmdClass[0x%02X], "
"i_cmdOpcode[0x%02X]", i_cmdClass, i_cmdOpcode);
do
{
uint8_t l_numCmds = 0;
sbeCmdStruct_t *l_pCmd = NULL;
l_numCmds = sbeGetCmdStructAttr (i_cmdClass, &l_pCmd);
if (!l_numCmds)
{
SBE_ERROR(SBE_FUNC"SBE_SEC_COMMAND_CLASS_NOT_SUPPORTED "
"i_cmdClass[0x%02X], i_cmdOpcode[0x%02X]",
i_cmdClass, i_cmdOpcode);
// Command class not supported
l_rc = SBE_SEC_COMMAND_CLASS_NOT_SUPPORTED;
break;
}
// @TODO via RTC : 128654
// Analyze on merging the validation functions into one
// and also on using loop vs switch case performance
for (uint8_t l_cnt = 0; l_cnt < l_numCmds; ++l_cnt, ++l_pCmd)
{
if (i_cmdOpcode == l_pCmd->cmd_opcode)
{
// Command found
l_rc = SBE_SEC_OPERATION_SUCCESSFUL;
break;
}
}
} while (false);
return l_rc;
#undef SBE_FUNC
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
bool sbeIsCmdAllowedAtState (const uint8_t i_cmdClass,
const uint8_t i_cmdOpcode)
{
#define SBE_FUNC " sbeIsCmdAllowedAtState "
uint8_t l_numCmds = 0;
sbeCmdStruct_t *l_pCmd = NULL;
bool l_ret = false;
l_numCmds = sbeGetCmdStructAttr (i_cmdClass, &l_pCmd);
for (uint8_t l_cnt = 0; l_cnt < l_numCmds; ++l_cnt, ++l_pCmd)
{
if (i_cmdOpcode == l_pCmd->cmd_opcode)
{
// Get the Present State
uint64_t l_state =
SbeRegAccess::theSbeRegAccess().getSbeState();
SBE_INFO(SBE_FUNC "SBE State [0x%08X] Fence State[0x%04X]",
(uint32_t)(l_state & 0xFFFFFFFF),l_pCmd->cmd_state_fence);
switch(l_state)
{
case SBE_STATE_UNKNOWN:
case SBE_STATE_FAILURE:
// All operations are fenced here, return false
// Reset is the only Option available
break;
case SBE_STATE_IPLING:
{
l_ret = ((l_pCmd->cmd_state_fence &
SBE_FENCE_AT_CONTINUOUS_IPL)? false:true);
break;
}
case SBE_STATE_ISTEP:
{
l_ret = ((l_pCmd->cmd_state_fence &
SBE_FENCE_AT_ISTEP)? false:true);
break;
}
case SBE_STATE_RUNTIME:
{
l_ret = ((l_pCmd->cmd_state_fence &
SBE_FENCE_AT_RUNTIME)? false:true);
break;
}
case SBE_STATE_DUMP:
{
l_ret = ((l_pCmd->cmd_state_fence &
SBE_FENCE_AT_DUMPING)? false:true);
break;
}
case SBE_STATE_MPIPL:
{
l_ret = ((l_pCmd->cmd_state_fence &
SBE_FENCE_AT_MPIPL)? false:true);
break;
}
case SBE_STATE_DMT:
{
l_ret = ((l_pCmd->cmd_state_fence &
SBE_FENCE_AT_DMT)? false:true);
break;
}
case SBE_STATE_QUIESCE:
{
l_ret = ((l_pCmd->cmd_state_fence &
SBE_FENCE_AT_QUIESCE)? false:true);
break;
}
default: break;
}
}
}
// For any other state, which is not handled above, return from here
return l_ret;
#undef SBE_FUNC
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
sbeCmdFunc_t sbeFindCmdFunc (const uint8_t i_cmdClass,
const uint8_t i_cmdOpcode)
{
#define SBE_FUNC " sbeFindCmdFunc "
uint8_t l_numCmds = 0;
sbeCmdStruct_t *l_pCmd = NULL;
l_numCmds = sbeGetCmdStructAttr (i_cmdClass, &l_pCmd);
for (uint8_t l_cnt = 0; l_cnt < l_numCmds; ++l_cnt, ++l_pCmd)
{
if (i_cmdOpcode == l_pCmd->cmd_opcode)
{
break;
}
}
return l_pCmd ? (l_pCmd->cmd_func) : NULL;
#undef SBE_FUNC
}
|