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
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/include/usr/fapi2/target.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2015,2018 */
/* [+] 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 target.H
///
/// @brief Defines the platform target functions that needs to be
/// specialized for platform implementation.
///
/**
* @file target.H
* @brief platform specializations for fapi2 targets
*/
#ifndef __FAPI2_TARGET__
#define __FAPI2_TARGET__
#include <plat_target.H>
#include <stdio.h>
#include <stdint.h>
#include <vector>
#include <target_types.H>
#include <return_code_defs.H>
#include <fapi2_target.H>
#include <hwpf_fapi2_reasoncodes.H>
// HB platform support
#include <fapiPlatTrace.H>
#include <targeting/common/target.H>
#include <targeting/common/commontargeting.H>
#include <targeting/common/targetservice.H>
#include <targeting/common/utilFilter.H>
#include <targeting/common/predicates/predicatectm.H>
#include <targeting/common/predicates/predicateisfunctional.H>
//@TODO RTC:150675 get error info from getOtherEnd fails
//#include <errl/errlentry.H>
//#include <errl/errlmanager.H>
namespace PLAT_TARGET
{
///
/// @brief Helper function for specialized system target allows
/// for the constructor to call targetservice::getTopLevel
/// @param[in/out] io_handle Reference to TARGETING::Target to assign
/// iv_handle to.
/// @return void
///
void systemTargCtorHelperFunc(fapi2::plat_target_handle_t& io_handle);
}
namespace fapi2
{
///
/// @brief Specialization for TARGET_TYPE_SYSTEM targets
/// for the constructor to call targetservice::getTopLevel
/// @param[in/out] io_handle Reference to TARGETING::Target to assign
/// iv_handle to.
/// @return void
///
/// @note the default templated constructor is delagated to constructors
/// take take in a plat_target_handle_t
///
template<>
inline Target<TARGET_TYPE_SYSTEM, plat_target_handle_t>
::Target(const plat_target_handle_t& v)
{
PLAT_TARGET::systemTargCtorHelperFunc(iv_handle);
}
///
/// @brief Assignment Operator.
/// @tparam K The type of target on which this is called
/// @tparam V the type of the target's Value
/// @param[in] i_right Reference to Target to assign from.
/// @return Reference to 'this' Target
///
template<TargetType K, typename V>
Target<K, V>& Target<K, V>::operator=(const Target& i_right)
{ iv_handle = i_right.iv_handle; return *this; }
///
/// @brief Equality Comparison Operator
/// @tparam K The type of target on which this is called
/// @tparam V the type of the target's Value
/// @param[in] i_right Reference to Target to compare.
/// @return bool. True if equal.
/// @note This platform uses handles for comparison as
/// target handles are statically defined so the order
/// is consistent.
///
template<TargetType K, typename V>
bool Target<K, V>::operator==(const Target& i_right) const
{ return i_right.iv_handle == iv_handle; }
///
/// @brief Inquality Comparison Operator
/// @tparam K The type of target on which this is called
/// @tparam V the type of the target's Value
/// @param[in] i_right Reference to Target to compare.
/// @return bool. True if not equal.
/// @note This platform uses handles for comparison as
/// target handles are statically defined so the order
/// is consistent.
///
template<TargetType K, typename V>
bool Target<K, V>::operator!=(const Target& i_right) const
{ return i_right.iv_handle != iv_handle; }
///
/// @brief Less Than Comparison Operator
/// @param[in] i_right Reference to Target to compare.
/// @return bool. True if less than i_right
/// @note This platform uses handles for comparison as
/// target handles are statically defined so the order
/// is consistent.
///
template<TargetType K, typename V>
bool Target<K, V>::operator<(const Target& i_right) const
{
return iv_handle < i_right.iv_handle;
}
///
/// @brief This function takes in a FAPI2 Type and returns the corresponding
/// TARGETING::Target type
///
/// @param[in] i_fapi2Type
///
/// @returns TARGETTING::Type equivelent to fapi2 type
inline TARGETING::TYPE convertFapi2TypeToTargeting(fapi2::TargetType i_T)
{
TARGETING::TYPE o_targetingType = TARGETING::TYPE_NA;
switch (i_T)
{
case fapi2::TARGET_TYPE_NONE:
o_targetingType = TARGETING::TYPE_NA;
break;
case fapi2::TARGET_TYPE_SYSTEM:
o_targetingType = TARGETING::TYPE_SYS;
break;
case fapi2::TARGET_TYPE_DIMM:
o_targetingType = TARGETING::TYPE_DIMM;
break;
case fapi2::TARGET_TYPE_PROC_CHIP:
o_targetingType = TARGETING::TYPE_PROC;
break;
case fapi2::TARGET_TYPE_MEMBUF_CHIP:
o_targetingType = TARGETING::TYPE_MEMBUF;
break;
case fapi2::TARGET_TYPE_EX:
o_targetingType = TARGETING::TYPE_EX;
break;
case fapi2::TARGET_TYPE_MBA:
o_targetingType = TARGETING::TYPE_MBA;
break;
case fapi2::TARGET_TYPE_MCS:
o_targetingType = TARGETING::TYPE_MCS;
break;
case fapi2::TARGET_TYPE_XBUS:
o_targetingType = TARGETING::TYPE_XBUS;
break;
case fapi2::TARGET_TYPE_ABUS:
o_targetingType = TARGETING::TYPE_ABUS;
break;
case fapi2::TARGET_TYPE_L4:
o_targetingType = TARGETING::TYPE_L4;
break;
case fapi2::TARGET_TYPE_CORE:
o_targetingType = TARGETING::TYPE_CORE;
break;
case fapi2::TARGET_TYPE_EQ:
o_targetingType = TARGETING::TYPE_EQ;
break;
case fapi2::TARGET_TYPE_MCA:
o_targetingType = TARGETING::TYPE_MCA;
break;
case fapi2::TARGET_TYPE_MCBIST:
o_targetingType = TARGETING::TYPE_MCBIST;
break;
case fapi2::TARGET_TYPE_MI:
o_targetingType = TARGETING::TYPE_MI;
break;
case fapi2::TARGET_TYPE_CAPP:
o_targetingType = TARGETING::TYPE_CAPP;
break;
case fapi2::TARGET_TYPE_DMI:
o_targetingType = TARGETING::TYPE_DMI;
break;
case fapi2::TARGET_TYPE_OBUS:
o_targetingType = TARGETING::TYPE_OBUS;
break;
case fapi2::TARGET_TYPE_OBUS_BRICK:
o_targetingType = TARGETING::TYPE_OBUS_BRICK;
break;
case fapi2::TARGET_TYPE_SBE:
o_targetingType = TARGETING::TYPE_SBE;
break;
case fapi2::TARGET_TYPE_PPE:
o_targetingType = TARGETING::TYPE_PPE;
break;
case fapi2::TARGET_TYPE_PERV:
o_targetingType = TARGETING::TYPE_PERV;
break;
case fapi2::TARGET_TYPE_PEC:
o_targetingType = TARGETING::TYPE_PEC;
break;
case fapi2::TARGET_TYPE_PHB:
o_targetingType = TARGETING::TYPE_PHB;
break;
case fapi2::TARGET_TYPE_MC:
o_targetingType = TARGETING::TYPE_MC;
break;
case fapi2::TARGET_TYPE_OMI:
o_targetingType = TARGETING::TYPE_OMI;
break;
case fapi2::TARGET_TYPE_OMIC:
o_targetingType = TARGETING::TYPE_OMIC;
break;
case fapi2::TARGET_TYPE_MCC:
o_targetingType = TARGETING::TYPE_MCC;
break;
case fapi2::TARGET_TYPE_OCMB_CHIP:
o_targetingType = TARGETING::TYPE_OCMB_CHIP;
break;
case fapi2::TARGET_TYPE_MEM_PORT:
o_targetingType = TARGETING::TYPE_MEM_PORT;
break;
default:
FAPI_ERR("convertFapi2TypeToTargeting:: Chiplet type not supported 0x%.8X!", i_T);
assert(false);
break;
}
return o_targetingType;
}
///
/// @brief This function takes in a TARGETING Type and returns the corresponding
/// FAPI::Target type
///
/// @param[in] i_fapi2Type
///
/// @returns TARGETTING::Type equivelent to fapi2 type
inline fapi2::TargetType convertTargetingTypeToFapi2(TARGETING::TYPE i_T)
{
fapi2::TargetType o_targetingType = fapi2::TARGET_TYPE_NONE;
switch (i_T)
{
case TARGETING::TYPE_NA:
o_targetingType = fapi2::TARGET_TYPE_NONE;
break;
case TARGETING::TYPE_SYS:
o_targetingType = fapi2::TARGET_TYPE_SYSTEM;
break;
case TARGETING::TYPE_DIMM:
o_targetingType = fapi2::TARGET_TYPE_DIMM;
break;
case TARGETING::TYPE_PROC:
o_targetingType = fapi2::TARGET_TYPE_PROC_CHIP;
break;
case TARGETING::TYPE_MEMBUF:
o_targetingType = fapi2::TARGET_TYPE_MEMBUF_CHIP;
break;
case TARGETING::TYPE_EX:
o_targetingType = fapi2::TARGET_TYPE_EX;
break;
case TARGETING::TYPE_MBA:
o_targetingType = fapi2::TARGET_TYPE_MBA;
break;
case TARGETING::TYPE_MCS:
o_targetingType = fapi2::TARGET_TYPE_MCS;
break;
case TARGETING::TYPE_XBUS:
o_targetingType = fapi2::TARGET_TYPE_XBUS;
break;
case TARGETING::TYPE_ABUS:
o_targetingType = fapi2::TARGET_TYPE_ABUS;
break;
case TARGETING::TYPE_L4:
o_targetingType = fapi2::TARGET_TYPE_L4;
break;
case TARGETING::TYPE_CORE:
o_targetingType = fapi2::TARGET_TYPE_CORE;
break;
case TARGETING::TYPE_EQ:
o_targetingType = fapi2::TARGET_TYPE_EQ;
break;
case TARGETING::TYPE_MCA:
o_targetingType = fapi2::TARGET_TYPE_MCA;
break;
case TARGETING::TYPE_MCBIST:
o_targetingType = fapi2::TARGET_TYPE_MCBIST;
break;
case TARGETING::TYPE_MI:
o_targetingType = fapi2::TARGET_TYPE_MI;
break;
case TARGETING::TYPE_CAPP:
o_targetingType = fapi2::TARGET_TYPE_CAPP;
break;
case TARGETING::TYPE_DMI:
o_targetingType = fapi2::TARGET_TYPE_DMI;
break;
case TARGETING::TYPE_OBUS:
o_targetingType = fapi2::TARGET_TYPE_OBUS;
break;
case TARGETING::TYPE_OBUS_BRICK:
o_targetingType = fapi2::TARGET_TYPE_OBUS_BRICK;
break;
case TARGETING::TYPE_SBE:
o_targetingType = fapi2::TARGET_TYPE_SBE;
break;
case TARGETING::TYPE_PPE:
o_targetingType = fapi2::TARGET_TYPE_PPE;
break;
case TARGETING::TYPE_PERV:
o_targetingType = fapi2::TARGET_TYPE_PERV;
break;
case TARGETING::TYPE_PEC:
o_targetingType = fapi2::TARGET_TYPE_PEC;
break;
case TARGETING::TYPE_PHB:
o_targetingType = fapi2::TARGET_TYPE_PHB;
break;
case TARGETING::TYPE_MC:
o_targetingType = fapi2::TARGET_TYPE_MC;
break;
case TARGETING::TYPE_OMI:
o_targetingType = fapi2::TARGET_TYPE_OMI;
break;
case TARGETING::TYPE_OMIC:
o_targetingType = fapi2::TARGET_TYPE_OMIC;
break;
case TARGETING::TYPE_MCC:
o_targetingType = fapi2::TARGET_TYPE_MCC;
break;
case TARGETING::TYPE_OCMB_CHIP:
o_targetingType = fapi2::TARGET_TYPE_OCMB_CHIP;
break;
case TARGETING::TYPE_MEM_PORT:
o_targetingType = fapi2::TARGET_TYPE_MEM_PORT;
break;
default:
o_targetingType = fapi2::TARGET_TYPE_NONE;
break;
}
return o_targetingType;
}
///
/// @brief Get this target's immediate parent
/// @tparam T_SELF The type of target on which this is called
/// @tparam K_PARENT The desired type of the parent target
/// @tparam V the type of the target's Value
/// @return Target<T> a target representing the parent
///
template<TargetType T_SELF, typename V>
template<TargetType K_PARENT>
inline Target<K_PARENT, V> Target<T_SELF, V>::getParent(void) const
{
FAPI_DBG(ENTER_MRK "getParent. Type of parent 0x%08x", K_PARENT);
// General compound chiplet check for proc parent
const fapi2::TargetType TARGET_TYPE_PROC_CHILDREN = fapi2::TARGET_TYPE_EX |
fapi2::TARGET_TYPE_MCS |
fapi2::TARGET_TYPE_XBUS |
fapi2::TARGET_TYPE_CORE |
fapi2::TARGET_TYPE_EQ |
fapi2::TARGET_TYPE_MCA |
fapi2::TARGET_TYPE_MCBIST |
fapi2::TARGET_TYPE_MC |
fapi2::TARGET_TYPE_MI |
fapi2::TARGET_TYPE_OMI |
fapi2::TARGET_TYPE_MCC |
fapi2::TARGET_TYPE_OMIC |
fapi2::TARGET_TYPE_CAPP |
fapi2::TARGET_TYPE_DMI |
fapi2::TARGET_TYPE_OBUS |
fapi2::TARGET_TYPE_OBUS_BRICK |
fapi2::TARGET_TYPE_SBE |
fapi2::TARGET_TYPE_PPE |
fapi2::TARGET_TYPE_PERV |
fapi2::TARGET_TYPE_PEC |
fapi2::TARGET_TYPE_DIMM |
fapi2::TARGET_TYPE_PHB;
static_assert( !((K_PARENT == fapi2::TARGET_TYPE_PROC_CHIP) &&
((T_SELF & TARGET_TYPE_PROC_CHILDREN) == fapi2::TARGET_TYPE_NONE)),
"fapi2::TARGET_TYPE_PROC_CHIP is not a valid parent" );
const fapi2::TargetType TARGET_TYPE_PERV_CHIPLETS = fapi2::TARGET_TYPE_EQ |
fapi2::TARGET_TYPE_CORE |
fapi2::TARGET_TYPE_XBUS |
fapi2::TARGET_TYPE_OBUS |
fapi2::TARGET_TYPE_CAPP |
fapi2::TARGET_TYPE_OBUS_BRICK |
fapi2::TARGET_TYPE_MCBIST |
fapi2::TARGET_TYPE_MCS |
fapi2::TARGET_TYPE_MCA |
fapi2::TARGET_TYPE_MI |
fapi2::TARGET_TYPE_MC |
fapi2::TARGET_TYPE_DMI |
fapi2::TARGET_TYPE_PEC |
fapi2::TARGET_TYPE_PHB |
fapi2::TARGET_TYPE_OMI |
fapi2::TARGET_TYPE_OMIC |
fapi2::TARGET_TYPE_MCC;
static_assert( !((K_PARENT == fapi2::TARGET_TYPE_PERV) &&
((T_SELF & TARGET_TYPE_PERV_CHIPLETS) == fapi2::TARGET_TYPE_NONE)),
"fapi2::TARGET_TYPE_PERV is not a valid parent" );
// Specific parent checks for each TargetType
// valid parents for DIMM
// DIMM -> MEMPORT
// DIMM -> OCMB
// DIMM -> OMI
// DIMM -> OMIC
// DIMM -> MCC
// DIMM -> MI
// DIMM -> MC
// DIMM -> PROC_CHIP
// DIMM -> MCA
// DIMM -> MBA
static_assert(!((T_SELF == fapi2::TARGET_TYPE_DIMM) &&
(K_PARENT != fapi2::TARGET_TYPE_MCA) &&
(K_PARENT != fapi2::TARGET_TYPE_MBA) &&
(K_PARENT != fapi2::TARGET_TYPE_OCMB_CHIP) &&
(K_PARENT != fapi2::TARGET_TYPE_SYSTEM) &&
(K_PARENT != fapi2::TARGET_TYPE_OMI) &&
(K_PARENT != fapi2::TARGET_TYPE_MCC) &&
(K_PARENT != fapi2::TARGET_TYPE_MI) &&
(K_PARENT != fapi2::TARGET_TYPE_MC) &&
(K_PARENT != fapi2::TARGET_TYPE_OMIC) &&
(K_PARENT != fapi2::TARGET_TYPE_PROC_CHIP)),
"improper parent of fapi2::TARGET_TYPE_DIMM");
// valid parents for PROC
// PROC -> SYSTEM
static_assert(!((T_SELF == fapi2::TARGET_TYPE_PROC_CHIP) &&
(K_PARENT != fapi2::TARGET_TYPE_SYSTEM)),
"improper parent of fapi2::TARGET_TYPE_PROC_CHIP");
// valid parents for MEMBUF
// MEMBUF -> SYSTEM
// MEMBUF -> DMI
static_assert(!((T_SELF == fapi2::TARGET_TYPE_MEMBUF_CHIP) &&
(K_PARENT != fapi2::TARGET_TYPE_SYSTEM) &&
(K_PARENT != fapi2::TARGET_TYPE_DMI)),
"improper parent of fapi2::TARGET_TYPE_MEMBUF_CHIP");
// valid parents for OCMB
// OCMB -> SYSTEM
// OCMB -> OMI
// OCMB -> MCC
// OCMB -> MI
// OCMB -> MC
// OCMB -> OMIC
// OCMB -> PROC_CHIP
static_assert(!((T_SELF == fapi2::TARGET_TYPE_OCMB_CHIP) &&
(K_PARENT != fapi2::TARGET_TYPE_SYSTEM) &&
(K_PARENT != fapi2::TARGET_TYPE_OMI) &&
(K_PARENT != fapi2::TARGET_TYPE_MCC) &&
(K_PARENT != fapi2::TARGET_TYPE_MI) &&
(K_PARENT != fapi2::TARGET_TYPE_MC) &&
(K_PARENT != fapi2::TARGET_TYPE_OMIC) &&
(K_PARENT != fapi2::TARGET_TYPE_PROC_CHIP)),
"improper parent of fapi2::TARGET_TYPE_OCMB_CHIP");
// valid parents for MEM_PORT
// MEM_PORT -> SYSTEM
// MEM_PORT -> OCMB_CHIP
// MEM_PORT -> OMI
// MEM_PORT -> MCC
// MEM_PORT -> MI
// MEM_PORT -> MC
// MEM_PORT -> OMIC
// MEM_PORT -> PROC_CHIP
static_assert(!((T_SELF == fapi2::TARGET_TYPE_MEM_PORT) &&
(K_PARENT != fapi2::TARGET_TYPE_SYSTEM) &&
(K_PARENT != fapi2::TARGET_TYPE_OCMB_CHIP) &&
(K_PARENT != fapi2::TARGET_TYPE_OMI) &&
(K_PARENT != fapi2::TARGET_TYPE_MCC) &&
(K_PARENT != fapi2::TARGET_TYPE_MI) &&
(K_PARENT != fapi2::TARGET_TYPE_MC) &&
(K_PARENT != fapi2::TARGET_TYPE_OMIC) &&
(K_PARENT != fapi2::TARGET_TYPE_PROC_CHIP)),
"improper parent of fapi2::TARGET_TYPE_MEM_PORT");
// valid parents for EX
// EX -> EQ
// EX -> PROC
static_assert(!((T_SELF == fapi2::TARGET_TYPE_EX) &&
(K_PARENT != fapi2::TARGET_TYPE_EQ) &&
(K_PARENT != fapi2::TARGET_TYPE_PROC_CHIP)),
"improper parent of fapi2::TARGET_TYPE_EX");
// valid parents for MBA
// MBA -> MEMBUF
static_assert(!((T_SELF == fapi2::TARGET_TYPE_MBA) &&
(K_PARENT != fapi2::TARGET_TYPE_MEMBUF_CHIP)),
"improper parent of fapi2::TARGET_TYPE_MBA");
// valid parents for MCS
// MCS -> MCBIST
// MCS -> PERV
// MCS -> PROC
static_assert(!((T_SELF == fapi2::TARGET_TYPE_MCS) &&
(K_PARENT != fapi2::TARGET_TYPE_MCBIST) &&
(K_PARENT != fapi2::TARGET_TYPE_PERV) &&
(K_PARENT != fapi2::TARGET_TYPE_PROC_CHIP)),
"improper parent of fapi2::TARGET_TYPE_MCS");
// valid parents for L4
// L4 -> MEMBUF
static_assert(!((T_SELF == fapi2::TARGET_TYPE_L4) &&
(K_PARENT != fapi2::TARGET_TYPE_MEMBUF_CHIP)),
"improper parent of fapi2::TARGET_TYPE_L4");
// valid parents for CORE
// CORE -> EX
// CORE -> EQ
// CORE -> PERV
// CORE -> PROC
static_assert(!((T_SELF == fapi2::TARGET_TYPE_CORE) &&
(K_PARENT != fapi2::TARGET_TYPE_EX) &&
(K_PARENT != fapi2::TARGET_TYPE_EQ) &&
(K_PARENT != fapi2::TARGET_TYPE_PERV) &&
(K_PARENT != fapi2::TARGET_TYPE_PROC_CHIP)),
"improper parent of fapi2::TARGET_TYPE_CORE");
// valid parents for EQ
// EQ -> PROC
// EQ -> PERV
static_assert(!((T_SELF == fapi2::TARGET_TYPE_EQ) &&
(K_PARENT != fapi2::TARGET_TYPE_PERV) &&
(K_PARENT != fapi2::TARGET_TYPE_PROC_CHIP)),
"improper parent of fapi2::TARGET_TYPE_EQ");
// valid parents for MCA
// MCA -> MCS
// MCA -> MCBIST
// MCA -> PERV
// MCA -> PROC
static_assert(!((T_SELF == fapi2::TARGET_TYPE_MCA) &&
(K_PARENT != fapi2::TARGET_TYPE_MCS) &&
(K_PARENT != fapi2::TARGET_TYPE_MCBIST) &&
(K_PARENT != fapi2::TARGET_TYPE_PERV) &&
(K_PARENT != fapi2::TARGET_TYPE_PROC_CHIP)),
"improper parent of fapi2::TARGET_TYPE_MCA");
// valid parents for MCBIST
// MCBIST -> PERV
// MCBIST -> PROC
static_assert(!((T_SELF == fapi2::TARGET_TYPE_MCBIST) &&
(K_PARENT != fapi2::TARGET_TYPE_PERV) &&
(K_PARENT != fapi2::TARGET_TYPE_PROC_CHIP)),
"improper parent of fapi2::TARGET_TYPE_MCBIST");
// valid parents for MC
// MC -> PERV
// MC -> PROC
static_assert(!((T_SELF == fapi2::TARGET_TYPE_MC) &&
(K_PARENT != fapi2::TARGET_TYPE_PERV) &&
(K_PARENT != fapi2::TARGET_TYPE_PROC_CHIP)),
"improper parent of fapi2::TARGET_TYPE_MC");
// valid parents for MI
// MI -> MC
// MI -> PERV
// MI -> PROC
static_assert(!((T_SELF == fapi2::TARGET_TYPE_MI) &&
(K_PARENT != fapi2::TARGET_TYPE_MC) &&
(K_PARENT != fapi2::TARGET_TYPE_PERV) &&
(K_PARENT != fapi2::TARGET_TYPE_PROC_CHIP)),
"improper parent of fapi2::TARGET_TYPE_MI");
// valid parents for MCC
// MCC -> PERV
// MCC -> MI
// MCC -> MC
// MCC -> PROC
static_assert(!((T_SELF == fapi2::TARGET_TYPE_MCC) &&
(K_PARENT != fapi2::TARGET_TYPE_PERV) &&
(K_PARENT != fapi2::TARGET_TYPE_MI) &&
(K_PARENT != fapi2::TARGET_TYPE_MC) &&
(K_PARENT != fapi2::TARGET_TYPE_PROC_CHIP)),
"improper parent of fapi2::TARGET_TYPE_MI");
// valid parents for OMI
// OMI -> PERV
// OMI -> MCC
// OMI -> MI
// OMI -> MC
// OMI -> OMIC
// OMI -> PROC
static_assert(!((T_SELF == fapi2::TARGET_TYPE_OMI) &&
(K_PARENT != fapi2::TARGET_TYPE_PERV) &&
(K_PARENT != fapi2::TARGET_TYPE_MCC) &&
(K_PARENT != fapi2::TARGET_TYPE_MI) &&
(K_PARENT != fapi2::TARGET_TYPE_MC) &&
(K_PARENT != fapi2::TARGET_TYPE_OMIC) &&
(K_PARENT != fapi2::TARGET_TYPE_PROC_CHIP)),
"improper parent of fapi2::TARGET_TYPE_MI");
// valid parents for OMIC
// OMIC -> PERV
// OMIC -> MC
// OMIC -> PROC
static_assert(!((T_SELF == fapi2::TARGET_TYPE_MI) &&
(K_PARENT != fapi2::TARGET_TYPE_PERV) &&
(K_PARENT != fapi2::TARGET_TYPE_MC) &&
(K_PARENT != fapi2::TARGET_TYPE_PROC_CHIP)),
"improper parent of fapi2::TARGET_TYPE_OMIC");
// valid parents for DMI
// DMI -> MI
// DMI -> MC
// DMI -> PERV
// DMI -> PROC
static_assert(!((T_SELF == fapi2::TARGET_TYPE_DMI) &&
(K_PARENT != fapi2::TARGET_TYPE_MI) &&
(K_PARENT != fapi2::TARGET_TYPE_MC) &&
(K_PARENT != fapi2::TARGET_TYPE_PERV) &&
(K_PARENT != fapi2::TARGET_TYPE_PROC_CHIP)),
"improper parent of fapi2::TARGET_TYPE_DMI");
// valid parents for SBE
// SBE -> PROC
static_assert(!((T_SELF == fapi2::TARGET_TYPE_SBE) &&
(K_PARENT != fapi2::TARGET_TYPE_PROC_CHIP)),
"improper parent of fapi2::TARGET_TYPE_SBE");
// valid parents for PPE
// PPE -> PROC
static_assert(!((T_SELF == fapi2::TARGET_TYPE_PPE) &&
(K_PARENT != fapi2::TARGET_TYPE_PROC_CHIP)),
"improper parent of fapi2::TARGET_TYPE_PPE");
// valid parents for PERV
// PERV -> PROC
static_assert(!((T_SELF == fapi2::TARGET_TYPE_PERV) &&
(K_PARENT != fapi2::TARGET_TYPE_PROC_CHIP)),
"improper parent of fapi2::TARGET_TYPE_PERV");
// valid parents for PEC
// PEC -> PERV
// PEC -> PROC
static_assert(!((T_SELF == fapi2::TARGET_TYPE_PEC) &&
(K_PARENT != fapi2::TARGET_TYPE_PERV) &&
(K_PARENT != fapi2::TARGET_TYPE_PROC_CHIP)),
"improper parent of fapi2::TARGET_TYPE_PEC");
// valid parents for PHB
// PHB -> PERV
// PHB -> PROC
static_assert(!((T_SELF == fapi2::TARGET_TYPE_PHB) &&
(K_PARENT != fapi2::TARGET_TYPE_PERV) &&
(K_PARENT != fapi2::TARGET_TYPE_PROC_CHIP)),
"improper parent of fapi2::TARGET_TYPE_PHB");
// valid parents for XBUS
// XBUS -> PERV
// XBUS -> PROC
static_assert(!((T_SELF == fapi2::TARGET_TYPE_XBUS) &&
(K_PARENT != fapi2::TARGET_TYPE_PERV) &&
(K_PARENT != fapi2::TARGET_TYPE_PROC_CHIP)),
"improper parent of fapi2::TARGET_TYPE_XBUS");
// valid parents for OBUS
// OBUS -> PERV
// OBUS -> PROC
static_assert(!((T_SELF == fapi2::TARGET_TYPE_OBUS) &&
(K_PARENT != fapi2::TARGET_TYPE_PERV) &&
(K_PARENT != fapi2::TARGET_TYPE_PROC_CHIP)),
"improper parent of fapi2::TARGET_TYPE_OBUS");
// valid parents for OBUS_BRICK
// OBUS_BRICK -> PERV
// OBUS_BRICK -> OBUS
// OBUS_BRICK -> PROC
static_assert(!((T_SELF == fapi2::TARGET_TYPE_OBUS_BRICK) &&
(K_PARENT != fapi2::TARGET_TYPE_PERV) &&
(K_PARENT != fapi2::TARGET_TYPE_OBUS) &&
(K_PARENT != fapi2::TARGET_TYPE_PROC_CHIP)),
"improper parent of fapi2::TARGET_TYPE_OBUS_BRICK");
// valid parents for CAPP
// CAPP -> PERV
// CAPP -> PROC
static_assert(!((T_SELF == fapi2::TARGET_TYPE_CAPP) &&
(K_PARENT != fapi2::TARGET_TYPE_PERV) &&
(K_PARENT != fapi2::TARGET_TYPE_PROC_CHIP)),
"improper parent of fapi2::TARGET_TYPE_CAPP");
TARGETING::TargetHandleList l_parentList;
TARGETING::TYPE requiredPType =
fapi2::convertFapi2TypeToTargeting(K_PARENT);
if(K_PARENT == fapi2::TARGET_TYPE_PERV)
{
TARGETING::getParentPervasiveTargetsByState(
l_parentList,
static_cast<TARGETING::Target*>(this->get()),
TARGETING::CLASS_NA,
requiredPType,
TARGETING::UTIL_FILTER_ALL);
}
else
{
TARGETING::getParentAffinityTargetsByState(
l_parentList,
static_cast<TARGETING::Target*>(this->get()),
TARGETING::CLASS_NA,
requiredPType,
TARGETING::UTIL_FILTER_ALL);
}
assert(l_parentList.size() == 1, "Found %d parents of the same type. Target HUID %x ,\
looking for parents of type %x", l_parentList.size(), TARGETING::get_huid(this->get()) , requiredPType);
TARGETING::Target * l_parentTarget = l_parentList[0];
assert(l_parentTarget != NULL,
"No parent of type %x was found for the target of type %x, Found required parent plat type to be %x",
K_PARENT, T_SELF, requiredPType)
Target<K_PARENT> outTarget(l_parentTarget);
FAPI_DBG(EXIT_MRK "getParent");
return outTarget;
}
///
/// @brief Get this target's children
/// @tparam T_SELF The type of target on which this is called
/// @tparam K_CHILD The desired type of child target
/// @tparam V the type of the target's Value
/// @param[in] i_state The desired TargetState of the children
/// @return std::vector<Target<T> > a vector of present/functional
/// children
/// @warning The children of EX's (cores) are expected to be returned
/// in order. That is, core 0 is std::vector[0].
///
template<TargetType T_SELF, typename V>
template< TargetType K_CHILD>
inline std::vector<Target<K_CHILD, V> >
Target<T_SELF, V>::getChildren(const TargetState i_state) const
{
FAPI_DBG(ENTER_MRK "getChildren. Type 0x%08x State:0x%08x", K_CHILD, i_state);
#define INVALID_CHILD(_PARENT, _CHILD) \
static_assert(!((T_SELF == _PARENT) && (K_CHILD == _CHILD)), \
#_CHILD " is not a child of " #_PARENT );
// invalid children for proc
INVALID_CHILD(fapi2::TARGET_TYPE_PROC_CHIP, fapi2::TARGET_TYPE_NONE)
INVALID_CHILD(fapi2::TARGET_TYPE_PROC_CHIP, fapi2::TARGET_TYPE_SYSTEM)
INVALID_CHILD(fapi2::TARGET_TYPE_PROC_CHIP, fapi2::TARGET_TYPE_PROC_CHIP)
INVALID_CHILD(fapi2::TARGET_TYPE_PROC_CHIP, fapi2::TARGET_TYPE_MEMBUF_CHIP)
INVALID_CHILD(fapi2::TARGET_TYPE_PROC_CHIP, fapi2::TARGET_TYPE_MBA)
#undef INVALID_CHILD
// valid children for PERV
// PERV -> EQ
// PERV -> CORE
// PERV -> XBUS
// PERV -> OBUS
// PERV -> CAPP
// PERV -> OBUS_BRICK
// PERV -> MCBIST
// PERV -> MCS
// PERV -> MCA
// PERV -> PEC
// PERV -> PHB
// PERV -> MC
// PERV -> MI
// PERV -> MCC
// PERV -> OMIC
// PERV -> OMI
// PERV -> DMI
static_assert(!((T_SELF == fapi2::TARGET_TYPE_PERV) &&
(K_CHILD != fapi2::TARGET_TYPE_EQ) &&
(K_CHILD != fapi2::TARGET_TYPE_CORE) &&
(K_CHILD != fapi2::TARGET_TYPE_XBUS) &&
(K_CHILD != fapi2::TARGET_TYPE_OBUS) &&
(K_CHILD != fapi2::TARGET_TYPE_CAPP) &&
(K_CHILD != fapi2::TARGET_TYPE_OBUS_BRICK) &&
(K_CHILD != fapi2::TARGET_TYPE_MCBIST) &&
(K_CHILD != fapi2::TARGET_TYPE_MCS) &&
(K_CHILD != fapi2::TARGET_TYPE_MCA) &&
(K_CHILD != fapi2::TARGET_TYPE_PEC) &&
(K_CHILD != fapi2::TARGET_TYPE_PHB) &&
(K_CHILD != fapi2::TARGET_TYPE_MC) &&
(K_CHILD != fapi2::TARGET_TYPE_MI) &&
(K_CHILD != fapi2::TARGET_TYPE_MCC) &&
(K_CHILD != fapi2::TARGET_TYPE_OMIC) &&
(K_CHILD != fapi2::TARGET_TYPE_OMI) &&
(K_CHILD != fapi2::TARGET_TYPE_DMI)),
"improper child of fapi2::TARGET_TYPE_PERV");
// valid children for MEMBUF
// MEMBUF -> L4
// MEMBUF -> MBA
static_assert(!((T_SELF == fapi2::TARGET_TYPE_MEMBUF_CHIP) &&
(K_CHILD != fapi2::TARGET_TYPE_L4) &&
(K_CHILD != fapi2::TARGET_TYPE_MBA)),
"improper child of fapi2::TARGET_TYPE_MEMBUF_CHIP");
// valid children for system
// SYSTEM -> PROC
// SYSTEM -> MEMBUF
// SYSTEM -> DIMM ??? disabled for now
static_assert(!((T_SELF == fapi2::TARGET_TYPE_SYSTEM) &&
(K_CHILD != fapi2::TARGET_TYPE_PROC_CHIP) &&
(K_CHILD != fapi2::TARGET_TYPE_MEMBUF_CHIP)),
"improper child of fapi2::TARGET_TYPE_SYSTEM");
// valid children for EQ
// EQ -> CORE
// EQ -> EX
static_assert(!((T_SELF == fapi2::TARGET_TYPE_EQ) &&
(K_CHILD != fapi2::TARGET_TYPE_CORE) &&
(K_CHILD != fapi2::TARGET_TYPE_EX)),
"improper child of fapi2::TARGET_TYPE_EQ");
// valid children for EX
// EX -> CORE
static_assert(!((T_SELF == fapi2::TARGET_TYPE_EX) &&
(K_CHILD != fapi2::TARGET_TYPE_CORE)),
"improper child of fapi2::TARGET_TYPE_EX");
// Nimbus Memory
// valid children for MCS
// MCS -> MCA
static_assert(!((T_SELF == fapi2::TARGET_TYPE_MCS) &&
(K_CHILD != fapi2::TARGET_TYPE_MCA)),
"improper child of fapi2::TARGET_TYPE_MCS");
// valid children for MCA
// MCA -> DIMM
static_assert(!((T_SELF == fapi2::TARGET_TYPE_MCA) &&
(K_CHILD != fapi2::TARGET_TYPE_DIMM)),
"improper child of fapi2::TARGET_TYPE_MCA");
// valid children for MCBIST
// MCBIST -> MCA
// MCBIST -> MCS
static_assert(!((T_SELF == fapi2::TARGET_TYPE_MCBIST) &&
(K_CHILD != fapi2::TARGET_TYPE_MCA) &&
(K_CHILD != fapi2::TARGET_TYPE_MCS)),
"improper child of fapi2::TARGET_TYPE_MCBIST");
// Cumulus Memory
// valid children for MC
// MC -> MI
// MC -> MCC
// MC -> OMIC
// MC -> OMI
// MC -> DMI
static_assert(!((T_SELF == fapi2::TARGET_TYPE_MC) &&
(K_CHILD != fapi2::TARGET_TYPE_MI) &&
(K_CHILD != fapi2::TARGET_TYPE_MCC) &&
(K_CHILD != fapi2::TARGET_TYPE_OMIC) &&
(K_CHILD != fapi2::TARGET_TYPE_OMI) &&
(K_CHILD != fapi2::TARGET_TYPE_DMI)),
"improper child of fapi2::TARGET_TYPE_MC");
// valid children for MI
// MI -> MCC
// MI -> OMI
// MI -> DMI
static_assert(!((T_SELF == fapi2::TARGET_TYPE_MI) &&
(K_CHILD != fapi2::TARGET_TYPE_MCC) &&
(K_CHILD != fapi2::TARGET_TYPE_OMI) &&
(K_CHILD != fapi2::TARGET_TYPE_DMI)),
"improper child of fapi2::TARGET_TYPE_MI");
// valid children for MCC
// MCC -> OMI
static_assert(!((T_SELF == fapi2::TARGET_TYPE_MCC) &&
(K_CHILD != fapi2::TARGET_TYPE_OMI)),
"improper child of fapi2::TARGET_TYPE_MCC");
// valid children for OMIC
// OMIC -> OMI
static_assert(!((T_SELF == fapi2::TARGET_TYPE_OMIC) &&
(K_CHILD != fapi2::TARGET_TYPE_OMI)),
"improper child of fapi2::TARGET_TYPE_OMIC");
// valid children for OCMB
// OCMB -> MEM_PORT
// OCMB -> DIMM
static_assert(!((T_SELF == fapi2::TARGET_TYPE_OCMB_CHIP) &&
(K_CHILD != fapi2::TARGET_TYPE_MEM_PORT) &&
(K_CHILD != fapi2::TARGET_TYPE_DIMM)),
"improper child of fapi2::TARGET_TYPE_OCMB_CHIP");
// valid children for MEM_PORT
// MEM_PORT -> DIMM
static_assert(!((T_SELF == fapi2::TARGET_TYPE_MEM_PORT) &&
(K_CHILD != fapi2::TARGET_TYPE_DIMM)),
"improper child of fapi2::TARGET_TYPE_MEM_PORT");
// valid children for DMI
// DMI -> MEMBUF
static_assert(!((T_SELF == fapi2::TARGET_TYPE_DMI) &&
(K_CHILD != fapi2::TARGET_TYPE_MEMBUF_CHIP)),
"improper child of fapi2::TARGET_TYPE_DMI");
// valid children for MBA
// MBA -> DIMM
static_assert(!((T_SELF == fapi2::TARGET_TYPE_MBA) &&
(K_CHILD != fapi2::TARGET_TYPE_DIMM)),
"improper child of fapi2::TARGET_TYPE_MBA");
//Check that we are not calling this on a target with no children
static_assert((T_SELF != fapi2::TARGET_TYPE_NONE),
"fapi2::TARGET_TYPE_NONE has no children");
static_assert((T_SELF != fapi2::TARGET_TYPE_XBUS),
"fapi2::TARGET_TYPE_XBUS has no children");
static_assert((T_SELF != fapi2::TARGET_TYPE_ABUS),
"fapi2::TARGET_TYPE_ABUS has no children");
static_assert((T_SELF != fapi2::TARGET_TYPE_L4),
"fapi2::TARGET_TYPE_L4 has no children");
static_assert((T_SELF != fapi2::TARGET_TYPE_CORE),
"fapi2::TARGET_TYPE_CORE has no children");
static_assert((T_SELF != fapi2::TARGET_TYPE_CAPP),
"fapi2::TARGET_TYPE_CAPP has no children");
static_assert((T_SELF != fapi2::TARGET_TYPE_OBUS_BRICK),
"fapi2::TARGET_TYPE_OBUS_BRICK has no children");
static_assert((T_SELF != fapi2::TARGET_TYPE_SBE),
"fapi2::TARGET_TYPE_SBE has no children");
static_assert((T_SELF != fapi2::TARGET_TYPE_PPE),
"fapi2::TARGET_TYPE_PPE has no children");
static_assert((T_SELF != fapi2::TARGET_TYPE_PHB),
"fapi2::TARGET_TYPE_PHB has no children");
std::vector<Target<K_CHILD>> l_children;
//Get the platform target type of the current fapi2::target
TARGETING::TYPE l_type = fapi2::convertFapi2TypeToTargeting(K_CHILD);
TARGETING::TargetHandleList l_childList;
bool l_functional = (i_state & fapi2::TARGET_STATE_FUNCTIONAL)? true:false;
if(!l_functional)
{
// PERV targets use a special interface
if(T_SELF == fapi2::TARGET_TYPE_PERV)
{
TARGETING::getPervasiveChildTargetsByState(l_childList,
static_cast<TARGETING::Target*>(this->get()),
TARGETING::CLASS_NA,
l_type,
TARGETING::UTIL_FILTER_ALL);
}
// DIMMs need to use PRESENT so that we don't report things
// that aren't installed
else if(K_CHILD == fapi2::TARGET_TYPE_DIMM)
{
TARGETING::getChildAffinityTargetsByState(l_childList,
static_cast<TARGETING::Target*>(this->get()),
TARGETING::CLASS_NA,
l_type,
TARGETING::UTIL_FILTER_PRESENT);
}
// All chiplets need to use ALL so that we report the architectural
// limits, versus what PG might say
else
{
TARGETING::getChildAffinityTargetsByState(l_childList,
static_cast<TARGETING::Target*>(this->get()),
TARGETING::CLASS_NA,
l_type,
TARGETING::UTIL_FILTER_ALL);
}
}
else
{
if(T_SELF == fapi2::TARGET_TYPE_PERV)
{
TARGETING::getPervasiveChildTargetsByState(l_childList,
static_cast<TARGETING::Target*>(this->get()),
TARGETING::CLASS_NA,
l_type,
TARGETING::UTIL_FILTER_FUNCTIONAL);
}
else
{
TARGETING::getChildAffinityTargetsByState(l_childList,
static_cast<TARGETING::Target*>(this->get()),
TARGETING::CLASS_NA,
l_type,
TARGETING::UTIL_FILTER_FUNCTIONAL);
}
}
FAPI_DBG("getChildren: l_functional 0x%.8X, l_type = 0x%.8X, ChipUnitId 0x%.8X",
l_functional, l_type, TARGETING::get_huid(this->get()));
FAPI_DBG("getChildren: l_childList size %d", l_childList.size());
// Return fapi2::Targets to the caller
for (TARGETING::TargetHandleList::const_iterator
chipletIter = l_childList.begin();
chipletIter != l_childList.end();
++chipletIter)
{
fapi2::Target<K_CHILD> l_target(*chipletIter);
l_children.push_back(l_target);
}
FAPI_DBG(EXIT_MRK "getChildren. %d results", l_children.size());
return l_children;
}
///
/// @brief Get this target's children, filtered
/// @tparam T The type of the parent
/// @tparam T_SELF The type of target on which this is called
/// @tparam V the type of the target's Value
/// @param[in] i_filter The desired chiplet filter
/// @param[in] i_state The desired TargetState of the children
/// @return std::vector<Target<T> > a vector of present/functional
/// children
///
template<TargetType T_SELF, typename V>
template< TargetType T>
inline std::vector<Target<T, V> >
Target<T_SELF, V>::getChildren(const TargetFilter i_filter,
const TargetState i_state) const
{
std::vector<Target<T>> l_children;
l_children = this->getChildren<T>(i_state);
FAPI_DBG("getChildrenFilter: Tgt=0x%.8X, i_filter=0x%.16X,"
"T_SELF-Type=0x%.8X, T-Type=0x%.8X, sizeA=%d",
TARGETING::get_huid(this->get()), i_filter,
T_SELF, T, l_children.size());
// Limit to getting Pervasive children from proc_chip parent for now
//@TODO RTC:155755 to track possible additional support
static_assert(((T == fapi2::TARGET_TYPE_PERV) &&
(T_SELF == fapi2::TARGET_TYPE_PROC_CHIP)),
"fapi2::getChildren-Filter only supports getting fapi2::TARGET_TYPE_PERV children on a fapi2::TARGET_TYPE_PROC_CHIP");
for ( auto childIter = l_children.begin();
childIter != l_children.end();
// ++childIter incremented below
)
{
const TARGETING::Target * l_platTarget =
static_cast<const TARGETING::Target*>(childIter->get());
uint8_t l_chiplet_num = 0;
uint32_t l_fapi2_type = childIter->getType();
uint64_t l_bitMask = 0x0;
// ATTR_CHIP_UNIT represents the Pervasive Chiplet numbering and is
// needed to create the l_bitMask to use against i_filter
if(!l_platTarget->tryGetAttr<TARGETING::ATTR_CHIP_UNIT>(l_chiplet_num))
{
FAPI_ERR("ERROR: getChildrenFilter: Can not read CHIP_UNIT attribute"
"Keeping Target 0x%lx for 0x%x", l_platTarget, T);
l_bitMask = 0xFFFFFFFFFFFFFFFF;
}
else
{
l_bitMask = 0x8000000000000000 >> l_chiplet_num;
}
if (i_filter & l_bitMask) // keep child
{
FAPI_DBG("getChildrenFilter: keep child=0x%.8X, type=0x%.8X, l_bitMask=0x%.16X, num=0x%.2X",
TARGETING::get_huid(l_platTarget), l_fapi2_type, l_bitMask, l_chiplet_num );
++childIter;
}
else // remove child
{
childIter = l_children.erase(childIter); // this increments childIter
FAPI_DBG("getChildrenFilter: removed child=0x%.8X, type=0x%.8X, l_bitMask=0x%.16X, num=0x%.2X",
TARGETING::get_huid(l_platTarget), l_fapi2_type, l_bitMask, l_chiplet_num );
}
}
// Return filtered fapi2::Targets to the caller
return l_children;
}
///
/// @brief Get the target at the other end of a bus
/// @tparam T The type of the target on the other end
/// @param[out] o_target A target representing the thing on the other end
/// @param[in] i_state The desired TargetState of the other end
/// @return FAPI2_RC_SUCCESS if OK, platforms will return a non-success
/// ReturnCode in the event of failure
/// @note o_target is only valid if return is FAPI2_RC_SUCCESS
///
template<TargetType T_SELF, typename V>
template<TargetType T>
inline fapi2::ReturnCodes
Target<T_SELF, V>::getOtherEnd(fapi2::Target<T, V>& o_target,
const TargetState i_state) const
{
ReturnCodes l_rc;
// errlHndl_t l_errl = NULL;
TARGETING::TargetHandleList l_peerTargetList;
TARGETING::CLASS targetClass = TARGETING::CLASS_NA;
// Only supporting these relationships:
// XBUS <-> XBUS
// ABUS <-> ABUS
// OBUS <-> OBUS
static_assert( T_SELF==T, "both ends must be of same fapi2::TARGET_TYPE");
static_assert ( ( (T_SELF==fapi2::TARGET_TYPE_XBUS) ||
(T_SELF==fapi2::TARGET_TYPE_ABUS) ||
(T_SELF==fapi2::TARGET_TYPE_OBUS) ),
"Only types of XBUS, ABUS, and OBUS are supported");
// for the supported types above, only one option supported
targetClass = TARGETING::CLASS_UNIT;
TARGETING::PredicateCTM l_peerFilter(targetClass,
fapi2::convertFapi2TypeToTargeting(T));
if(i_state == TARGET_STATE_FUNCTIONAL)
{
TARGETING::PredicateIsFunctional l_funcFilter;
TARGETING::PredicatePostfixExpr l_funcAndpeerFilter;
l_funcAndpeerFilter.push(&l_peerFilter).push(&l_funcFilter).And();
getPeerTargets( l_peerTargetList, // list of targets on other end
static_cast<TARGETING::Target*>(this->get()),//To this target
NULL/*&l_peerFilter*/, // Don't need to filter peers
&l_funcAndpeerFilter);//filter results to be the right class & state
}
else if(i_state == TARGET_STATE_PRESENT)
{
TARGETING::PredicatePostfixExpr l_presAndpeerFilter;
l_presAndpeerFilter.push(&l_peerFilter);
getPeerTargets( l_peerTargetList, // list of targets on other end
static_cast<TARGETING::Target*>(this->get()), //to this target
NULL, //No need to filter peers
&l_presAndpeerFilter);//filter results to be the right class & state
}
fapi2::Target<T> fapi2_peerTarget = NULL;
if(l_peerTargetList.size() == 0)
{
l_rc = FAPI2_RC_FALSE;
//@TODO RTC:150675 get error info from getOtherEnd fails
#if 0
/*@
* @errortype ERRORLOG::ERRL_SEV_UNRECOVERABLE
* @moduleid fapi2::MOD_FAPI2_PLAT_GET_OTHER_END
* @reasoncode fapi2::RC_FOUND_NO_PEERS
* @userdata1[0:31] Unused
* @userdata1[32:63] Unused
* @userdata2 Unused
* @devdesc Unable to resolve other end of xbus
*/
l_errl = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
fapi2::MOD_FAPI2_PLAT_GET_OTHER_END,
fapi2::RC_FOUND_NO_PEERS,
NULL,
NULL,
true/*SW Error*/);
errlCommit(l_errl,FAPI2_COMP_ID);
// Add the error log pointer as data to the ReturnCode
l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
#endif
}
else if(l_peerTargetList.size() > 1)
{
l_rc = FAPI2_RC_FALSE;
//@TODO RTC:150675 get error info from getOtherEnd fails
#if 0
/*@
* @errortype ERRORLOG::ERRL_SEV_UNRECOVERABLE
* @moduleid fapi2::MOD_FAPI2_PLAT_GET_OTHER_END
* @reasoncode fapi2::RC_FOUND_TOO_MANY_PEERS
* @userdata1[0:31] Unused
* @userdata1[32:63] Unused
* @userdata2 Unused
* @devdesc Unable to resolve other end of xbus
*/
l_errl = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
fapi2::MOD_FAPI2_PLAT_GET_OTHER_END,
fapi2::RC_FOUND_TOO_MANY_PEERS,
NULL,
NULL,
true/*SW Error*/);
errlCommit(l_errl,FAPI2_COMP_ID);
// Add the error log pointer as data to the ReturnCode
l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_err));
#endif
}
else
{
l_rc = FAPI2_RC_SUCCESS;
fapi2_peerTarget = fapi2::Target<T>(l_peerTargetList[0]);
}
o_target = fapi2_peerTarget;
return l_rc;
}
///
/// @brief Determine whether the target is functional or not
/// @return true if the target is functional, false otherwise
///
template< TargetType T_SELF, typename V >
inline bool Target< T_SELF, V >::isFunctional(void) const
{
TARGETING::PredicateIsFunctional l_functional;
return l_functional(static_cast<TARGETING::Target*>(this->get()));
}
///
/// @brief Return the string interpretation of this target
/// @tparam T The type of the target
/// @param[in] i_target Target<T>
/// @param[in/out] io_buffer buffer to write in to
/// @param[in] i_bsize size of the buffer
/// @return void
/// @post The contents of the buffer is replaced with the string
/// representation of the target
///
template< TargetType T, typename V >
inline void toString(const Target<T, V>& i_target, char* io_buffer, size_t i_bsize)
{
TARGETING::ATTR_FAPI_NAME_type l_nameString = {0};
const TARGETING::Target * l_platTarget =
static_cast<const TARGETING::Target*>(i_target.get());
if(!l_platTarget->tryGetAttr<TARGETING::ATTR_FAPI_NAME>(l_nameString))
{
FAPI_ERR("ERROR: Can not read FAPI_NAME attribute");
snprintf(io_buffer, i_bsize, "Target 0x%lx/0x%x", l_platTarget, T);
}
else
{
size_t needed_buffer_size = strlen((const char*)l_nameString) + 1;
// Is i_buffer large enough for the entire string + null
if (i_bsize < needed_buffer_size)
{
FAPI_INF("Should use a larger buffer size (%d instead of %d) for %s",
needed_buffer_size, i_bsize, l_nameString);
memcpy(io_buffer, l_nameString, i_bsize);
if (i_bsize > 0)
{
io_buffer[i_bsize-1] = '\0';
}
}
else
{
// copy full attribute string + null character
memcpy(io_buffer, l_nameString, needed_buffer_size);
}
}
}
///
/// @brief Return the string interpretation of this target
/// @tparam T The type of the target
/// @param[in] A pointer to the Target<T>
/// @param[in/out] io_buffer buffer to write in to
/// @param[in] i_bsize size of the buffer
/// @return void
/// @post The contents of the buffer is replaced with the string
/// representation of the target
///
template< TargetType T, typename V >
inline void toString(const Target<T, V> *i_target, char* io_buffer, size_t i_bsize)
{
toString(*i_target, io_buffer, i_bsize);
}
///
/// @brief Get a target from its Type and instance info
/// @tparam T The type of the target to return
/// @tparam V type of the targets value
/// @param[in] i_type - Type of target to find
/// @param[in] instance - instance of the target to find
///
/// @return Target<T>* pointer to a target of type T
///
/// NOTE: Function caller owns the object returned.
///
#ifdef FAPI2_ENABLE_PLATFORM_GET_TARGET
template<TargetType T, typename V=fapi2::plat_target_handle_t>
inline Target<T,V>* getTarget(TargetType i_type, uint8_t instance)
{
Target<T,V> * l_target = NULL;
TARGETING::TYPE l_type = convertFapi2TypeToTargeting(i_type);
// get a list of all the targets
TARGETING::TargetService& l_targetService = TARGETING::targetService();
TARGETING::TargetRangeFilter l_targets(l_targetService.begin(),
l_targetService.end());
// create a check for the desired target type
TARGETING::PredicateCTM l_typePredicate;
l_typePredicate.setType(l_type);
// create a check for the FAPI_POS of a target
TARGETING::PredicateAttrVal<TARGETING::ATTR_FAPI_POS>
l_fapiPosAttr(instance);
TARGETING::PredicatePostfixExpr l_Query;
// look for the type and instance
l_Query.push(&l_typePredicate).push(&l_fapiPosAttr).And();
l_targets.setPredicate(&l_Query);
// reset l_targets to contain only the targets matching our predicates
l_targets.reset();
TARGETING::Target * l_t = NULL;
uint32_t l_count = 0;
for(; l_targets; ++l_targets, ++l_count)
{
l_t = *l_targets;
}
// we should not find more than one target
assert(!(l_count > 1));
if(l_count == 1)
{
l_target = new fapi2::Target<T,V>(l_t);
}
return l_target;
}
#endif
/// @tparam T The type of the target
/// @param[in] Ordinal representing the ordinal number of
/// the desired target
/// @return Target<T> the target requested
///
template<TargetType T, typename V>
inline Target<T, V> getTarget(uint64_t i_ordinal_id )
{
uint16_t l_fapi_pos = 0;
TARGETING::Target * l_platTarget = nullptr;
// get the top-level target
TARGETING::Target * l_pSys;
TARGETING::targetService().getTopLevelTarget(l_pSys);
TARGETING::PredicateCTM l_tPred(TARGETING::CLASS_NA,
fapi2::convertFapi2TypeToTargeting(T));
// get a list of all targets of type T
TARGETING::TargetHandleList l_TargetList;
TARGETING::targetService().getAssociated( l_TargetList, l_pSys,
TARGETING::TargetService::CHILD,
TARGETING::TargetService::ALL,
&l_tPred);
if (!l_TargetList.empty())
{
FAPI_DBG("getTarget: Ordinal: %.8X", i_ordinal_id );
// Iterate through all targets and find out matching
// FAPI_POS target
for( auto & l_target_elem : l_TargetList)
{
l_fapi_pos = l_target_elem->getAttr<TARGETING::ATTR_FAPI_POS>();
if (l_fapi_pos == i_ordinal_id )
{
l_platTarget = l_target_elem;
FAPI_DBG("getTarget() - FAPI_POS: (%.8X) HUID: (%.8X)",
l_fapi_pos,
TARGETING::get_huid(l_target_elem));
break;
}
}
}
// Target list is empty or Target of Ordinal not Found
if (l_platTarget == nullptr)
{
FAPI_ERR("getTarget(): empty TargetList of T or Target of Ordinal not Found");
assert(false);
}
// Create a fapi2 target & return
Target<T> l_fapi2_target(l_platTarget);
return l_fapi2_target;
}
///
/// @brief Returns the chiplet number associated with the Target
/// @return The chiplet number for the Target. 0 is returned if the
/// Target does not have a chiplet number (for ex, the PROC_CHIP Target)
/// @note For logical targets such as the EX, the chiplet number of
/// their immediate parent chiplet is returned
///
template< TargetType T_SELF, typename V >
inline uint8_t Target< T_SELF, V >::getChipletNumber(void) const
{
const TARGETING::Target * l_pTarget =
static_cast<TARGETING::Target*>(this->get());
uint8_t l_chiplet_id = 0;
if(!l_pTarget->tryGetAttr<TARGETING::ATTR_CHIPLET_ID>(l_chiplet_id))
{
FAPI_ERR("ERROR: getChipletNumber: Can not read CHIPLET_ID attribute");
}
return l_chiplet_id;
}
} // End namespace fapi2
#endif // End __FAPI2_TARGET__
|