-
Notifications
You must be signed in to change notification settings - Fork 97
/
attribute_service.C
3071 lines (2653 loc) · 115 KB
/
attribute_service.C
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
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/usr/fapi2/attribute_service.C $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2015,2019 */
/* [+] 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 attribute_service.C
///
/// @brief Implements the platform functions that access attributes for FAPI2
///
//******************************************************************************
// Includes
//******************************************************************************
// The following file checks at compile time that all HWPF attributes are
// handled by Hostboot. This is done to ensure that the HTML file listing
// supported HWPF attributes lists attributes handled by Hostboot
#include <stdint.h>
#include <config.h>
#include <return_code.H>
#include <attribute_ids.H>
#include <attributeenums.H>
#include <fapi2platattrmacros.H>
#include <fapi2_attribute_service.H>
#include <attribute_service.H>
#include <attribute_plat_check.H>
#include <targeting/common/attributes.H>
#include <target.H>
#include <target_types.H>
#include <hwpf_fapi2_reasoncodes.H>
#include <chipids.H>
#include <devicefw/driverif.H>
#include <plat_attr_override_sync.H>
#include <vpd/spdenums.H>
#include <p9_pm_get_poundv_bucket_attr.H>
#include <p9_pm_get_poundw_bucket_attr.H>
#include <p9_frequency_buckets.H>
#include <errl/errlmanager.H>
#include <targeting/common/targetservice.H>
#include <targeting/common/predicates/predicatectm.H>
#include <targeting/common/utilFilter.H>
#include <targeting/common/util.H>
#include <../memory/lib/shared/dimmConsts.H>
#include <../memory/lib/shared/mss_const.H>
#include <../memory/lib/rosetta_map/rosetta_map.H>
#include <util/utilcommonattr.H>
#include <secureboot/service.H>
#include<vpd_accessors/accessMBvpdL4BankDelete.H>
#include<vpd_accessors/getControlCapableData.H>
#include<vpd_accessors/getDQAttrISDIMM.H>
#include<vpd_accessors/getDQSAttrISDIMM.H>
#include<vpd_accessors/getISDIMMTOC4DAttrs.H>
#include<vpd_accessors/getMBvpdAddrMirrorData.H>
#include<vpd_accessors/getMBvpdDram2NModeEnabled.H>
#include<vpd_accessors/getMBvpdMemoryDataVersion.H>
#include<vpd_accessors/getMBvpdSPDXRecordVersion.H>
#include<vpd_accessors/getMBvpdSlopeInterceptData.H>
#include<vpd_accessors/getMBvpdSensorMap.H>
#include<vpd_accessors/getMBvpdSpareDramData.H>
#include<vpd_accessors/getMBvpdVersion.H>
#include<vpd_accessors/getMBvpdVoltageSettingData.H>
#include<vpd_accessors/getMBvpdAttr.H>
//******************************************************************************
// Implementation
//******************************************************************************
namespace fapi2
{
namespace platAttrSvc
{
///
/// @brief Gets the TARGETING object for the input FAPI target
/// See doxygen in attribute_service.H
///
errlHndl_t getTargetingTarget(const Target<TARGET_TYPE_ALL>& i_pFapiTarget,
TARGETING::Target* & o_pTarget,
const TARGETING::TYPE i_expectedType)
{
errlHndl_t l_errl = NULL;
do
{
if (i_pFapiTarget.get() == NULL)
{
// Fapi Target object isnt point to a real target
FAPI_ERR("getTargetingTarget. NULL Fapi Target");
/*@
* @errortype
* @moduleid fapi2::MOD_FAPI2_GET_TARGETING_TARGET
* @reasoncode RC_NULL_FAPI_TARGET
* @userdata1[0:31] Fapi2 Expected Type
* @userdata1[32:63] <unused>
* @userdata2[0:7] Is Chip
* @userdata2[8:15] Is Chiplet
* @userdata2[16:63] <unused>
* @devdesc Unable to resolve FapiTarget from input
* @custdesc Firmware Error
*/
l_errl = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
MOD_FAPI2_GET_TARGETING_TARGET,
RC_NULL_FAPI_TARGET,
i_expectedType,
TWO_UINT8_TO_UINT16(
i_pFapiTarget.isChip(),
i_pFapiTarget.isChiplet()));
l_errl->collectTrace(FAPI_TRACE_NAME);
l_errl->collectTrace(FAPI_IMP_TRACE_NAME);
break;
}
o_pTarget = reinterpret_cast<TARGETING::Target*>(i_pFapiTarget.get());
if(i_expectedType != TARGETING::TYPE_NA)
{
TARGETING::TYPE l_type = o_pTarget->getAttr<TARGETING::ATTR_TYPE>();
if (l_type != i_expectedType)
{
FAPI_ERR("getTargetingTarget. Type: %d, expected %d", l_type,
i_expectedType);
/*@
* @errortype
* @moduleid fapi2::MOD_FAPI2_GET_TARGETING_TARGET
* @reasoncode RC_MISMATCHED_FAPI_TARG_TARGET
* @userdata1[0:31] Actual Type
* @userdata1[32:63] Expected Type
* @userdata2[0:31] Initial FAPI2 Type
* @userdata2[32:47] Is Chip
* @userdata2[48:63] Is Chiplet
* @devdesc When coverting from FAPI2::target to
* Targeting::target the resulting
Targeting::target's was incorrect
* @custdesc Firmware Error
*/
l_errl = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
MOD_FAPI2_GET_TARGETING_TARGET,
RC_MISMATCHED_FAPI_TARG_TARGET,
TWO_UINT32_TO_UINT64(l_type,
i_expectedType),
TWO_UINT32_TO_UINT64(
i_pFapiTarget.getType(),
TWO_UINT16_TO_UINT32(
i_pFapiTarget.isChip(),
i_pFapiTarget.isChiplet())));
l_errl->collectTrace(FAPI_TRACE_NAME);
l_errl->collectTrace(FAPI_IMP_TRACE_NAME);
break;
}
}
} while(0);
return l_errl;
}
bool getTargetingAttrHelper(TARGETING::Target * i_pTargTarget,
const TARGETING::ATTRIBUTE_ID i_targAttrId,
const uint32_t i_attrSize, void * o_pAttr)
{
return i_pTargTarget->_tryGetAttr(i_targAttrId, i_attrSize, o_pAttr);
}
///
/// @brief Gets a Targeting attribute, this is called by the macro that maps a
/// FAPI Attribute get to a TARGETING attribute and should not be called
/// directly.
/// See doxygen in H file.
///
ReturnCode getTargetingAttr(
const Target< TARGET_TYPE_ALL, MULTICAST_OR,
plat_target_handle_t >& i_pFapiTarget,
const TARGETING::ATTRIBUTE_ID i_targAttrId,
const uint32_t i_attrSize,
void * o_pAttr)
{
errlHndl_t l_errl = NULL;
ReturnCode l_rc;
TARGETING::Target * l_pTargTarget = NULL;
l_errl = getTargetingTarget(i_pFapiTarget, l_pTargTarget);
if (l_errl)
{
FAPI_ERR("getTargetingAttr: Error from getTargetingTarget");
l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
}
else
{
// Note directly calling Target's private _tryGetAttr function for code
// size optimization, the public function is a template function that
// cannot be called with a variable attribute ID, the template function
// checks at compile time that the Targeting attribute is readable, but
// that is already checked by the Targeting compiler
bool l_success = getTargetingAttrHelper(l_pTargTarget,
i_targAttrId,
i_attrSize, o_pAttr);
if (!l_success)
{
FAPI_ERR("getTargetingAttr: Error from getTargetingAttrHelper "
"for target 0x%.8X and attribute 0x%x",
TARGETING::get_huid(l_pTargTarget), i_targAttrId);
/*@
* @errortype
* @moduleid fapi2::MOD_FAPI2_GET_TARGETING_ATTR
* @reasoncode RC_INVALID_ATTRIBUTE
* @userdata1[0:31] FAPI2 Target Type
* @userdata1[32:63] HB Target HUID
* @userdata2 Requested attribute ID
* @devdesc Invalid attribute read request
* @custdesc Firmware Error
*/
l_errl = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
MOD_FAPI2_GET_TARGETING_ATTR,
RC_INVALID_ATTRIBUTE,
TWO_UINT32_TO_UINT64(
i_pFapiTarget.getType(),
TARGETING::get_huid(l_pTargTarget)
),
i_targAttrId);
l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
}
}
return l_rc;
}
bool setTargetingAttrHelper(TARGETING::Target * l_pTargTarget,
const TARGETING::ATTRIBUTE_ID i_targAttrId,
const uint32_t i_attrSize,
void * o_pAttr)
{
return l_pTargTarget->_trySetAttr(i_targAttrId, i_attrSize, o_pAttr);
}
///
/// @brief Sets a Targeting attribute, this is called by the macro that maps a
/// FAPI Attribute set to a FAPI2 TARGETING attribute and should not be
/// called directly
/// See doxygen in H file
///
ReturnCode setTargetingAttr(
const Target<TARGET_TYPE_ALL, MULTICAST_OR,
plat_target_handle_t >& i_pFapiTarget,
const TARGETING::ATTRIBUTE_ID i_targAttrId,
const uint32_t i_attrSize,
void * i_pAttr)
{
ReturnCode l_rc;
errlHndl_t l_errl = NULL;
TARGETING::Target * l_pTargTarget = NULL;
l_errl = getTargetingTarget(i_pFapiTarget, l_pTargTarget);
if (l_errl)
{
FAPI_ERR("setTargetingAttr: Error from getTargetingTarget");
l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
}
else
{
// Note directly calling Target's private _trySetAttr function for code
// size optimization, the public function is a template function that
// cannot be called with a variable attribute ID, the template function
// checks at compile time that the Targeting attribute is readable, but
// that is already checked by the Targeting compiler
bool l_success = setTargetingAttrHelper(l_pTargTarget,
i_targAttrId,
i_attrSize,
i_pAttr);
if (!l_success)
{
FAPI_ERR("setTargetingAttr: Error from setTargetingAttrHelper "
"for target 0x%.8X and attribute 0x%x",
TARGETING::get_huid(l_pTargTarget), i_targAttrId);
/*@
* @errortype
* @moduleid fapi2::MOD_FAPI2_SET_TARGETING_ATTR
* @reasoncode RC_INVALID_ATTRIBUTE
* @userdata1[0:31] FAPI2 Target Type
* @userdata1[32:63] HB Target HUID
* @userdata2 Requested attribute ID
* @devdesc Invalid attribute write request
* @custdesc Firmware Error
*/
l_errl = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
MOD_FAPI2_SET_TARGETING_ATTR,
RC_INVALID_ATTRIBUTE,
TWO_UINT32_TO_UINT64(
i_pFapiTarget.getType(),
TARGETING::get_huid(l_pTargTarget)
),
i_targAttrId);
l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
}
}
return l_rc;
}
//******************************************************************************
// platGetTargetName function
//******************************************************************************
ReturnCode platGetTargetName(const Target<TARGET_TYPE_ALL>& i_pFapiTarget,
uint8_t & o_name)
{
ReturnCode l_rc;
errlHndl_t l_errl = NULL;
TARGETING::Target * l_pHbTarget = NULL;
o_name = ENUM_ATTR_NAME_NONE;
do
{
l_errl = getTargetingTarget(i_pFapiTarget, l_pHbTarget);
if (l_errl)
{
FAPI_ERR("platGetTargetName: Error from getTargetingTarget");
l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
break;
}
TARGETING::MODEL l_model =
l_pHbTarget->getAttr<TARGETING::ATTR_MODEL>();
if (l_model == TARGETING::MODEL_NIMBUS)
{
o_name = ENUM_ATTR_NAME_NIMBUS;
}
else if (l_model == TARGETING::MODEL_CUMULUS)
{
o_name = ENUM_ATTR_NAME_CUMULUS;
}
else if (l_model == TARGETING::MODEL_CENTAUR)
{
o_name = ENUM_ATTR_NAME_CENTAUR;
}
else if (l_model == TARGETING::MODEL_AXONE)
{
o_name = ENUM_ATTR_NAME_AXONE;
}
else if (l_model == TARGETING::MODEL_OCMB)
{
// For MODEL_OCMB the ATTR_CHIP_ID determines if it is a
// Gemini or an Explorer chip
uint32_t l_chipID =
l_pHbTarget->getAttr<TARGETING::ATTR_CHIP_ID>();
if (l_chipID == POWER_CHIPID::EXPLORER_16)
{
o_name = ENUM_ATTR_NAME_EXPLORER;
}
else if (l_chipID == POWER_CHIPID::GEMINI_16)
{
o_name = ENUM_ATTR_NAME_GEMINI;
}
else
{
FAPI_ERR("platGetTargetName. Unknown CHIP_ID 0x%x for MODEL_OCMB 0x%x", l_chipID, l_model);
/*@
* @errortype
* @moduleid fapi2::MOD_FAPI2_GET_TARGETING_TARGET
* @reasoncode RC_UNKNOWN_OCMB_CHIP_TYPE
* @userdata1[0:31] FAPI2 Type
* @userdata1[32:63] HB Target HUID
* @userdata2[0:31] HB Type
* @userdata2[32:63] HB Target CHIP_ID
* @devdesc HB OCMB_CHIP target found with unknown
* model based on ATTR_CHIP_ID
* @custdesc Firmware Error
*/
l_errl = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
MOD_FAPI2_GET_TARGETING_TARGET,
RC_UNKNOWN_OCMB_CHIP_TYPE,
TWO_UINT32_TO_UINT64(
i_pFapiTarget.getType(),
TARGETING::get_huid(l_pHbTarget)
),
TWO_UINT32_TO_UINT64(
l_pHbTarget->
getAttr<TARGETING::ATTR_TYPE>(),
l_chipID));
l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
break;
}
}
else
{
FAPI_ERR("platGetTargetName. Unknown name 0x%x", l_model);
/*@
* @errortype
* @moduleid fapi2::MOD_FAPI2_GET_TARGETING_TARGET
* @reasoncode RC_UNKNOWN_MODEL
* @userdata1[0:31] FAPI2 Type
* @userdata1[32:63] HB Target HUID
* @userdata2[0:31] HB Type
* @userdata2[32:63] HB Model
* @devdesc HB target found with unknown model attribute
* @custdesc Firmware Error
*/
l_errl = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
MOD_FAPI2_GET_TARGETING_TARGET,
RC_UNKNOWN_MODEL,
TWO_UINT32_TO_UINT64(
i_pFapiTarget.getType(),
TARGETING::get_huid(l_pHbTarget)
),
TWO_UINT32_TO_UINT64(
l_pHbTarget->
getAttr<TARGETING::ATTR_TYPE>(),
l_model));
l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
break;
}
} while (0);
return l_rc;
}
//******************************************************************************
// platGetFunctional function
//******************************************************************************
ReturnCode platGetFunctional(const Target<TARGET_TYPE_ALL>& i_pFapiTarget,
uint8_t & o_functional)
{
errlHndl_t l_errl = NULL;
ReturnCode l_rc;
TARGETING::Target * l_pHbTarget = NULL;
o_functional = 0;
l_errl = getTargetingTarget(i_pFapiTarget, l_pHbTarget);
if (l_errl)
{
FAPI_ERR("platGetFunctional: Error from getTargetingTarget");
l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
}
else
{
TARGETING::PredicateIsFunctional l_functional;
if (l_functional(l_pHbTarget))
{
o_functional = 1;
}
}
return l_rc;
}
//******************************************************************************
// fapi::platAttrSvc::platGetTargetPos function
//******************************************************************************
ReturnCode platGetTargetPos(const Target<TARGET_TYPE_ALL>& i_pFapiTarget,
uint32_t & o_pos)
{
errlHndl_t l_errl = NULL;
ReturnCode l_rc;
TARGETING::Target * l_pTarget = NULL;
// Get the Targeting Target
l_errl = getTargetingTarget(i_pFapiTarget, l_pTarget);
if (l_errl)
{
FAPI_ERR("platGetTargetPos: Error from getTargetingTarget");
l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
}
else
{
uint16_t l_pos = l_pTarget->getAttr<TARGETING::ATTR_FAPI_POS>();
//@todo-RTC:161594-ATTR_POS is defined as per-drawer, so need to
// mod the value down appropriately
o_pos = l_pos;
}
return l_rc;
}
//******************************************************************************
// fapi::platAttrSvc::platErrorOnSet function
//******************************************************************************
ReturnCode platErrorOnSet( TARGETING::Target * i_pTargTarget,
const fapi2::AttributeId i_fapiAttrId )
{
// Just create an error to return back
FAPI_ERR("platErrorOnSet: Set not valid for Attribute %X on Target %.8X",
i_fapiAttrId, TARGETING::get_huid(i_pTargTarget) );
/*@
* @errortype
* @moduleid fapi2::MOD_FAPI2_PLAT_ERROR_ON_SET
* @reasoncode fapi2::RC_SET_ATTR_NOT_VALID
* @userdata1 Target HUID
* @userdata2 FAPI Attribute Id
* @devdesc platErrorOnSet> Set operation not valid
* @custdesc Firmware error
*/
errlHndl_t l_errl = new ERRORLOG::ErrlEntry(
ERRORLOG::ERRL_SEV_UNRECOVERABLE,
fapi2::MOD_FAPI2_PLAT_ERROR_ON_SET,
fapi2::RC_SET_ATTR_NOT_VALID,
TARGETING::get_huid(i_pTargTarget),
i_fapiAttrId,
ERRORLOG::ErrlEntry::ADD_SW_CALLOUT);
l_errl->collectTrace(FAPI_TRACE_NAME);
l_errl->collectTrace(FAPI_IMP_TRACE_NAME);
// attach our log to the fapi RC and return it
ReturnCode l_rc;
l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
return l_rc;
}
//******************************************************************************
// fapi::platAttrSvc::platGetFusedCoreMode function
//******************************************************************************
ReturnCode platGetFusedCoreMode(uint8_t & o_isFused)
{
o_isFused = TARGETING::is_fused_mode();
return fapi2::ReturnCode();
}
//******************************************************************************
// fapi2::platAttrSvc::platGetPoundVBucketData function
//******************************************************************************
ReturnCode platGetPoundVBucketData(const Target<TARGET_TYPE_ALL>& i_fapiTarget,
uint8_t * o_poundVData)
{
fapi2::ReturnCode rc;
// Don't need to check the type here, the FAPI_ATTR_GET macro clause
// "fapi2::Target<ID##_TargetType>(TARGET)" does it for us. However,
// to enable a streamlined dump of the attributes, all plat code must use
// the generic TARGET_TYPE_ALL -- so convert back to the correct type
// manually
TARGETING::Target * l_pTarget = NULL;
errlHndl_t l_errl = getTargetingTarget(i_fapiTarget, l_pTarget);
if (l_errl)
{
FAPI_ERR("platGetPoundVBucketData: Error from getTargetingTarget");
rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
}
else
{
fapi2::Target<TARGET_TYPE_EQ> l_fapiTarget( l_pTarget);
rc = p9_pm_get_poundv_bucket_attr(l_fapiTarget,o_poundVData);
}
return rc;
}
//******************************************************************************
// fapi2::platAttrSvc::platGetPoundWBucketData function
//******************************************************************************
ReturnCode platGetPoundWBucketData(const Target<TARGET_TYPE_ALL>& i_fapiTarget,
uint8_t * o_poundWData)
{
fapi2::ReturnCode rc;
// Don't need to check the type here, the FAPI_ATTR_GET macro clause
// "fapi2::Target<ID##_TargetType>(TARGET)" does it for us. However,
// to enable a streamlined dump of the attributes, all plat code must use
// the generic TARGET_TYPE_ALL -- so convert back to the correct type
// manually
TARGETING::Target * l_pTarget = NULL;
errlHndl_t l_errl = getTargetingTarget(i_fapiTarget, l_pTarget);
if (l_errl)
{
FAPI_ERR("platGetPoundWBucketData: Error from getTargetingTarget");
rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
}
else
{
fapi2::Target<TARGET_TYPE_EQ> l_fapiTarget( l_pTarget);
rc = p9_pm_get_poundw_bucket_attr(l_fapiTarget,o_poundWData);
}
return rc;
}
ReturnCode platParseWOFTables(uint8_t* o_wofData);
//******************************************************************************
// fapi2::platAttrSvc::platGetWOFTableData function
//******************************************************************************
ReturnCode platGetWOFTableData(const Target<TARGET_TYPE_ALL>& i_fapiTarget,
uint8_t * o_wofTableData)
{
fapi2::ReturnCode rc;
// Parse the tables and return a single wof table
rc = platParseWOFTables(o_wofTableData);
return rc;
}
//******************************************************************************
// ATTR_BAD_DQ_BITMAP getter/setter constant definitions
//******************************************************************************
// define structure for the format of DIMM_BAD_DQ_DATA
struct dimmBadDqDataFormat
{
uint32_t iv_magicNumber;
uint8_t iv_version;
uint8_t iv_reserved1;
uint8_t iv_reserved2;
uint8_t iv_reserved3;
uint8_t iv_bitmaps[mss::MAX_RANK_PER_DIMM][mss::BAD_DQ_BYTE_COUNT];
uint8_t iv_rowRepairData[mss::MAX_RANK_PER_DIMM]
[mss::ROW_REPAIR_BYTE_COUNT];
uint8_t iv_unused[16];
};
// constant definitions
const uint8_t SPARE_DRAM_DQ_BYTE_NUMBER_INDEX = 9;
const uint32_t DIMM_BAD_DQ_MAGIC_NUMBER = 0xbadd4471;
const uint8_t DIMM_BAD_DQ_VERSION = 1;
const uint8_t DIMM_BAD_DQ_NUM_BYTES = 80;
size_t DIMM_BAD_DQ_SIZE_BYTES = 0x50;
union wiringData
{
uint8_t nimbus[mss::PORTS_PER_MCS][mss::MAX_DQ_BITS];
uint8_t cumulus[MAX_PORTS_PER_CEN][DIMM_BAD_DQ_NUM_BYTES];
uint8_t memport[mss::MAX_DQ_BITS];
};
//******************************************************************************
// fapi2::platAttrSvc::__getChipModel function
//******************************************************************************
TARGETING::ATTR_MODEL_type __getChipModel()
{
// determine the chip's model
TARGETING::Target * masterProc = nullptr;
TARGETING::targetService().masterProcChipTargetHandle(masterProc);
return masterProc->getAttr<TARGETING::ATTR_MODEL>();
}
//******************************************************************************
// fapi2::platAttrSvc::__getTranslationPortSlct function
//******************************************************************************
ReturnCode __getTranslationPortSlct( const Target<TARGET_TYPE_DIMM>& i_fapiDimm,
uint8_t &o_ps )
{
// NOTE: this function returns the port select we need for the translation
// attribute. This means, for Cumulus it returns the MBA port from the
// centaur perspective (0-3), and for Nimbus it returns the port select from
// an MCS perspective (0-1).
o_ps = 0;
TARGETING::ATTR_MODEL_type l_procType = __getChipModel();
// If the proc is Cumulus, we need to get the MBA.
if ( TARGETING::MODEL_CUMULUS == l_procType )
{
Target<TARGET_TYPE_MBA> l_fapiMba =
i_fapiDimm.getParent<TARGET_TYPE_MBA>();
// Get the MBA's position
uint8_t mbaPos = 0;
FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_CHIP_UNIT_POS, l_fapiMba, mbaPos) );
mbaPos = mbaPos % MAX_MBA_PER_CEN; // 0-1
// Get the port select from the MBA perspective
uint8_t mbaPort = 0;
FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_CEN_MBA_PORT, i_fapiDimm, mbaPort));
mbaPort = mbaPort % MAX_PORTS_PER_MBA; // 0-1
// Find the port select from the Centaur perspective
o_ps = (mbaPos*MAX_PORTS_PER_MBA)+mbaPort; // 0-3
}
// If the proc is Nimbus, we need to get the MCA.
else if ( TARGETING::MODEL_NIMBUS == l_procType )
{
Target<TARGET_TYPE_MCA> l_fapiMca =
i_fapiDimm.getParent<TARGET_TYPE_MCA>();
// Get the port select from the MCS perspective
FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_CHIP_UNIT_POS, l_fapiMca, o_ps) );
o_ps = o_ps % mss::PORTS_PER_MCS; // 0-1
}
else
{
// In the generic case, the translation attribute exists on the MEM_PORT
// trgt so there's no need to know the port slct, so just set it to 0.
o_ps = 0;
}
fapi_try_exit:
return fapi2::current_err;
}
//******************************************************************************
// fapi2::platAttrSvc::__badDqBitmapGetHelperAttrs function
//******************************************************************************
ReturnCode __badDqBitmapGetHelperAttrs(
const Target<TARGET_TYPE_DIMM>& i_fapiDimm,
wiringData &o_wiringData, uint64_t &o_allMnfgFlags, uint8_t &o_ps )
{
TARGETING::ATTR_MODEL_type procType = __getChipModel();
FAPI_TRY( __getTranslationPortSlct(i_fapiDimm, o_ps) );
// Get the DQ to DIMM Connector DQ Wiring attribute.
// Note that for C-DIMMs, this will return a simple 1:1 mapping.
// This code cannot tell the difference between C-DIMMs and IS-DIMMs.
if ( TARGETING::MODEL_NIMBUS == procType )
{
// memset to avoid known syntax issue with previous compiler
// versions and ensure zero initialized array.
memset( o_wiringData.nimbus, 0, sizeof(o_wiringData.nimbus) );
Target<TARGET_TYPE_MCA> l_fapiMca =
i_fapiDimm.getParent<TARGET_TYPE_MCA>();
// Get the MCS.
Target<TARGET_TYPE_MCS> l_fapiMcs;
l_fapiMcs = l_fapiMca.getParent<TARGET_TYPE_MCS>();
FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_MSS_VPD_DQ_MAP, l_fapiMcs,
o_wiringData.nimbus) );
}
else if ( TARGETING::MODEL_CUMULUS == procType )
{
// memset to avoid known syntax issue with previous compiler
// versions and ensure zero initialized array.
memset( o_wiringData.cumulus, 0, sizeof(o_wiringData.cumulus) );
// Check DIMM type
uint8_t l_dimmType = 0;
Target<TARGET_TYPE_MBA> l_fapiMba =
i_fapiDimm.getParent<TARGET_TYPE_MBA>();
FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_CEN_EFF_CUSTOM_DIMM, l_fapiMba,
l_dimmType) );
// C-DIMMs return a direct 1:1 mapping
if ( fapi2::ENUM_ATTR_CEN_EFF_CUSTOM_DIMM_YES == l_dimmType )
{
for ( uint8_t port = 0; port < MAX_PORTS_PER_CEN; port++ )
{
for ( uint8_t i = 0; i < DIMM_BAD_DQ_NUM_BYTES; i++ )
{
o_wiringData.cumulus[port][i] = i;
}
}
}
// ISDIMMs require the mapping from ATTR_CEN_VPD_ISDIMMTOC4DQ
else
{
Target<TARGET_TYPE_MEMBUF_CHIP> l_fapiMembuf =
l_fapiMba.getParent<TARGET_TYPE_MEMBUF_CHIP>();
FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_CEN_VPD_ISDIMMTOC4DQ,
l_fapiMembuf, o_wiringData.cumulus) );
}
}
else
{
// memset to avoid known syntax issue with previous compiler
// versions and ensure zero initialized array.
memset( o_wiringData.memport, 0, sizeof(o_wiringData.memport) );
// Get the MEM_PORT target
Target<TARGET_TYPE_MEM_PORT> l_fapiMemPort =
i_fapiDimm.getParent<TARGET_TYPE_MEM_PORT>();
FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_MEM_VPD_DQ_MAP, l_fapiMemPort,
o_wiringData.memport) );
}
// Manufacturing flags attribute
o_allMnfgFlags = 0;
// Get the manufacturing flags bitmap to be used in both get and set
FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_MNFG_FLAGS,
fapi2::Target<fapi2::TARGET_TYPE_SYSTEM>(),
o_allMnfgFlags) );
fapi_try_exit:
return fapi2::current_err;
}
//******************************************************************************
// fapi2::platAttrSvc::__dimmUpdateDqBitmapEccByte function
//******************************************************************************
ReturnCode __dimmUpdateDqBitmapEccByte(
const Target<TARGET_TYPE_DIMM>& i_fapiDimm,
uint8_t (&o_data)[mss::MAX_RANK_PER_DIMM][mss::BAD_DQ_BYTE_COUNT] )
{
ReturnCode l_rc;
errlHndl_t l_errl = nullptr;
const uint8_t ECC_DQ_BYTE_NUMBER_INDEX = 8;
const uint8_t ENUM_ATTR_SPD_MODULE_MEMORY_BUS_WIDTH_WE8 = 0x08;
size_t MEM_BUS_WIDTH_SIZE = 0x01;
uint8_t *l_eccBits = static_cast<uint8_t*>(malloc(MEM_BUS_WIDTH_SIZE));
do
{
TARGETING::TargetHandle_t l_dimm = nullptr;
l_errl = getTargetingTarget( i_fapiDimm, l_dimm );
if ( l_errl )
{
FAPI_ERR( "__dimmUpdateDqBitmapEccByte: Error from "
"getTargetingTarget" );
l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
break;
}
l_errl = deviceRead( l_dimm, l_eccBits, MEM_BUS_WIDTH_SIZE,
DEVICE_SPD_ADDRESS(SPD::MODULE_MEMORY_BUS_WIDTH) );
if ( l_errl )
{
FAPI_ERR( "__dimmUpdateDqBitmapEccByte: Failed to get "
"SPD::MODULE_MEMORY_BUS_WIDTH." );
l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
break;
}
// The ATTR_SPD_MODULE_MEMORY_BUS_WIDTH contains ENUM values
// for bus widths of 8, 16, 32, and 64 bits both with ECC
// and without ECC. WExx ENUMS denote the ECC extension
// is present, and all have bit 3 set. Therefore,
// it is only required to check against the WE8 = 0x08 ENUM
// value in order to determine if ECC lines are present.
if ( !(ENUM_ATTR_SPD_MODULE_MEMORY_BUS_WIDTH_WE8 & *l_eccBits) )
{
// Iterate through each rank and set DQ bits in
// caller's data.
for ( uint8_t i = 0; i < mss::MAX_RANK_PER_DIMM; i++ )
{
// Set DQ bits in caller's data
o_data[i][ECC_DQ_BYTE_NUMBER_INDEX] = 0xFF;
}
}
}while(0);
if ( l_eccBits != nullptr )
{
free( l_eccBits );
l_eccBits = nullptr;
}
return l_rc;
}
//******************************************************************************
// fapi2::platAttrSvc::__dimmGetDqBitmapSpareByte function
//******************************************************************************
ReturnCode __dimmGetDqBitmapSpareByte(
const Target<TARGET_TYPE_DIMM>& i_fapiDimm,
uint8_t (&o_spareByte)[mss::MAX_RANK_PER_DIMM])
{
ReturnCode l_rc;
TARGETING::ATTR_MODEL_type procType = __getChipModel();
uint8_t l_ps = 0;
// Spare DRAM Attribute: Returns spare DRAM availability for
// all DIMMs associated with the target MCS.
uint8_t l_dramSpare[mss::PORTS_PER_MCS][mss::MAX_DIMM_PER_PORT]
[mss::MAX_RANK_PER_DIMM] = {};
uint32_t l_ds = 0;
FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_FAPI_POS, i_fapiDimm, l_ds) );
l_ds = l_ds % mss::MAX_DIMM_PER_PORT;
if ( TARGETING::MODEL_NIMBUS == procType )
{
// We need the port select from the MCS perspective here so we
// can just use __getTranslationPortSlct.
__getTranslationPortSlct( i_fapiDimm, l_ps );
Target<TARGET_TYPE_MCA> l_fapiMca =
i_fapiDimm.getParent<TARGET_TYPE_MCA>();
// Get the MCS.
Target<TARGET_TYPE_MCS> l_fapiMcs;
l_fapiMcs = l_fapiMca.getParent<TARGET_TYPE_MCS>();
FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_EFF_DIMM_SPARE, l_fapiMcs,
l_dramSpare) );
}
else if ( TARGETING::MODEL_CUMULUS == procType )
{
// In this case we need the port select from the MBA perspective
// not the centaur perspective that __getTranslationPortSlct gives
// us, so we can't use that function.
FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_CEN_MBA_PORT, i_fapiDimm, l_ps));
l_ps = l_ps % MAX_PORTS_PER_MBA;
Target<TARGET_TYPE_MBA> l_fapiMba =
i_fapiDimm.getParent<TARGET_TYPE_MBA>();
FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_CEN_VPD_DIMM_SPARE, l_fapiMba,
l_dramSpare) );
}
else
{
// Get the MEM_PORT target
Target<TARGET_TYPE_MEM_PORT> l_fapiMemPort =
i_fapiDimm.getParent<TARGET_TYPE_MEM_PORT>();
// The attribute exists on the MEM_PORT so we don't need to worry about
// the port slct, just set the attribute in the space for port slct 0.
FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_MEM_EFF_DIMM_SPARE, l_fapiMemPort,
l_dramSpare[0]) );
l_ps = 0;
}
// Iterate through each rank of this DIMM
for ( uint8_t i = 0; i < mss::MAX_RANK_PER_DIMM; i++ )
{
// Handle spare DRAM configuration cases
switch ( l_dramSpare[l_ps][l_ds][i] )
{
case fapi2::ENUM_ATTR_EFF_DIMM_SPARE_NO_SPARE:
// Set DQ bits reflecting unconnected
// spare DRAM in caller's data
o_spareByte[i] = 0xFF;
break;
case fapi2::ENUM_ATTR_EFF_DIMM_SPARE_LOW_NIBBLE:
o_spareByte[i] = 0x0F;
break;
case fapi2::ENUM_ATTR_EFF_DIMM_SPARE_HIGH_NIBBLE:
o_spareByte[i] = 0xF0;
break;
// As erroneous value will not be encountered.
case fapi2::ENUM_ATTR_EFF_DIMM_SPARE_FULL_BYTE:
default:
o_spareByte[i] = 0x0;
break;
}
}
fapi_try_exit:
return fapi2::current_err;
}
//******************************************************************************
// fapi2::platAttrSvc::__dimmUpdateDqBitmapSpareByte function
//******************************************************************************
ReturnCode __dimmUpdateDqBitmapSpareByte(
const Target<TARGET_TYPE_DIMM>& i_fapiDimm,
uint8_t (&o_data)[mss::MAX_RANK_PER_DIMM][mss::BAD_DQ_BYTE_COUNT] )
{
ReturnCode l_rc;
uint8_t spareByte[mss::MAX_RANK_PER_DIMM];
memset( spareByte, 0, sizeof(spareByte) );
FAPI_TRY( __dimmGetDqBitmapSpareByte(i_fapiDimm, spareByte) );
for ( uint32_t i = 0; i < mss::MAX_RANK_PER_DIMM; i++ )
{
o_data[i][SPARE_DRAM_DQ_BYTE_NUMBER_INDEX] |= spareByte[i];
}