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
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/usr/hdat/hdatmsvpd.C $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2016,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 hdatmsvpd.C
*
* @brief This file contains the implementation of the HdatMsVpd class.
*
*/
/*----------------------------------------------------------------------------*/
/* Includes */
/*----------------------------------------------------------------------------*/
#include "hdatmsvpd.H" // HdatMsVpd class definition
#include "hdathdif.H"
#include <sys/mm.h>
#include <sys/mmio.h>
#include <assert.h>
#include <util/align.H>
#include <limits.h>
namespace HDAT
{
/*----------------------------------------------------------------------------*/
/* Global variables */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* Macros */
/*----------------------------------------------------------------------------*/
// macro to compute the address of a main store area
#define HDAT_MS_AREA(_i_idx_) *((HdatMsArea **)((char *)iv_msAreaPtrs + \
_i_idx_ * sizeof(HdatMsArea *)))
/** @brief See the prologue in hdatmsvpd.H
*/
HdatMsVpd::HdatMsVpd(errlHndl_t &o_errlHndl,
const hdatMsAddr_t &i_msAddr
):HdatHdif(o_errlHndl,
HDAT_MSVPD_STRUCT_NAME, HDAT_MS_VPD_LAST, HDAT_START_INSTANCE,
HDAT_MS_CHILD_LAST, HDAT_MS_VPD_VERSION),
iv_actMsAreaCnt(0), iv_maxMsAreaCnt(0), iv_msAreaPtrs(NULL),
iv_IMTaddrRangeArray(NULL), iv_maxIMTAddrRngCnt(0),
iv_UEaddrRangeArray(NULL), iv_maxUEAddrRngCnt(0)
{
memcpy(&iv_msAddr, &i_msAddr, sizeof(hdatMsAddr_t));
}
void HdatMsVpd::hdatInit(hdatMsAddr_t &i_maxMsAddr,
hdatMsAddr_t &i_maxMsCcmAddr,
uint32_t i_msSize,
uint32_t i_msAreaCnt,
uint32_t i_MostSigAffinityDomain,
uint32_t i_ueAreaCnt,
uint64_t i_MirrMemStartAddr)
{
iv_maxUEAddrRngCnt = i_ueAreaCnt;
iv_maxMsAreaCnt = i_msAreaCnt;
iv_maxIMTAddrRngCnt = i_msAreaCnt;
memcpy(&iv_maxAddr.hdatMaxAddr, &i_maxMsAddr, sizeof(hdatMsAddr_t));
memcpy(&iv_maxAddr.hdatMaxCcmAddr, &i_maxMsCcmAddr, sizeof(hdatMsAddr_t));
iv_maxAddr.hdatMstSigAffntyDom = i_MostSigAffinityDomain;
memcpy(&iv_maxAddr.hdatMirrMemStartAddr, &i_MirrMemStartAddr,
sizeof(hdatMsAddr_t));
iv_maxSize.hdatReserved1 = 0;
iv_maxSize.hdatTotSize = i_msSize;
memset(&iv_mover, 0x00, sizeof(hdatMsVpdPageMover_t));
iv_IMTaddrRngArrayHdr.hdatOffset = sizeof(hdatHDIFDataArray_t);
iv_IMTaddrRngArrayHdr.hdatArrayCnt = 0;
iv_IMTaddrRngArrayHdr.hdatAllocSize = sizeof(hdatMsVpdImtAddrRange_t);
iv_IMTaddrRngArrayHdr.hdatActSize = sizeof(hdatMsVpdImtAddrRange_t);
iv_UEaddrRngArrayHdr.hdatOffset = sizeof(hdatHDIFDataArray_t);
iv_UEaddrRngArrayHdr.hdatArrayCnt = 0;
iv_UEaddrRngArrayHdr.hdatAllocSize = sizeof(hdatMsVpdUEAddrRange_t);
iv_UEaddrRngArrayHdr.hdatActSize = sizeof(hdatMsVpdUEAddrRange_t);
iv_RHBaddrRngArrayHdr.hdatOffset = sizeof(hdatHDIFDataArray_t);
iv_RHBaddrRngArrayHdr.hdatArrayCnt = 0;
iv_RHBaddrRngArrayHdr.hdatAllocSize = sizeof(hdatMsVpdRhbAddrRange_t);
iv_RHBaddrRngArrayHdr.hdatActSize = sizeof(hdatMsVpdRhbAddrRange_t);
iv_maxRHBAddrRngCnt = HDAT_RHB_MAX_RANGE_ENTRIES * hdatGetMaxCecNodes();
// Allocate space for the mainstore area entries and IMT Addr Range array
iv_msAreaPtrs = new HdatMsArea*[iv_maxMsAreaCnt];
iv_IMTaddrRangeArray = new hdatMsVpdImtAddrRange_t[iv_maxIMTAddrRngCnt];
iv_UEaddrRangeArray = new hdatMsVpdUEAddrRange_t[iv_maxUEAddrRngCnt];
// Allocate space for the host boot memory reserve range
iv_RHBaddrRangeArray = new hdatMsVpdRhbAddrRange_t[iv_maxRHBAddrRngCnt];
// Update the base class internal data pointers.
// When the data is written to the file by commit(), it must be done in the
// same order as these addData() calls
this->addData(HDAT_MS_VPD_MAX_ADDR, sizeof(hdatMsVpdAddr_t));
this->addData(HDAT_MS_VPD_MAX_SIZE, sizeof(hdatMsVpdSize_t));
this->addData(HDAT_MS_VPD_PAGE_MOVER, sizeof(hdatMsVpdPageMover_t));
this->addData(HDAT_MS_VPD_IMT_ADDR_RNG, (sizeof(hdatHDIFDataArray_t) +
(iv_maxIMTAddrRngCnt * sizeof(hdatMsVpdImtAddrRange_t))));
this->addData(HDAT_MS_VPD_UE_ADDR_RNG, (sizeof(hdatHDIFDataArray_t) +
(iv_maxUEAddrRngCnt * sizeof(hdatMsVpdUEAddrRange_t))));
this->addData(HDAT_MS_VPD_HB_ADDR_RNG, (sizeof(hdatHDIFDataArray_t) +
(iv_maxRHBAddrRngCnt * sizeof(hdatMsVpdRhbAddrRange_t))));
this->align();
return;
}
/** @brief See the prologue in hdatmsvpd.H
*/
HdatMsVpd::~HdatMsVpd()
{
uint32_t l_cnt;
HdatMsArea *l_obj, **l_curPtr;
// Delete mainstore area objects (which in turn delete RAM objects)
l_curPtr = iv_msAreaPtrs;
for (l_cnt = 0; l_cnt < iv_actMsAreaCnt; l_cnt++)
{
l_obj = *l_curPtr;
delete l_obj;
l_curPtr = reinterpret_cast<HdatMsArea**>(reinterpret_cast<char*>
(l_curPtr) + sizeof(HdatMsArea *));
}
delete[] iv_msAreaPtrs;
// Delete IMT Address Range Array
delete[] iv_IMTaddrRangeArray;
// Delete UE Address Range Array
delete[] iv_UEaddrRangeArray;
delete[] iv_RHBaddrRangeArray;
uint64_t l_addr = reinterpret_cast<uint64_t> (iv_virtAddr);
l_addr = ALIGN_PAGE_DOWN(l_addr);
iv_virtAddr = reinterpret_cast<void*>(l_addr);
int rc = mm_block_unmap(iv_virtAddr);
if( rc != 0)
{
errlHndl_t l_errl = NULL;
/*@
* @errortype
* @moduleid HDAT::MOD_MSVPD_DESTRUCTOR
* @reasoncode HDAT::RC_DEV_MAP_FAIL
* @devdesc Unmap a mapped region failed
* @custdesc Firmware encountered an internal error.
*/
hdatBldErrLog(l_errl,
MOD_MSVPD_DESTRUCTOR,
RC_DEV_MAP_FAIL,
0,0,0,0,
ERRORLOG::ERRL_SEV_UNRECOVERABLE,
HDAT_VERSION1,
true);
}
return;
}
/** @brief See the prologue in hdatmsvpd.H
*/
errlHndl_t HdatMsVpd::addIMTAddrRange(hdatMsAddr_t &i_start,
hdatMsAddr_t &i_end)
{
errlHndl_t l_errlHndl = NULL;
hdatMsVpdImtAddrRange_t *l_addr;
if (iv_IMTaddrRngArrayHdr.hdatArrayCnt < iv_maxIMTAddrRngCnt)
{
l_addr = reinterpret_cast<hdatMsVpdImtAddrRange_t*>(reinterpret_cast
<char*>(iv_IMTaddrRangeArray) + (iv_IMTaddrRngArrayHdr.hdatArrayCnt *
sizeof(hdatMsVpdImtAddrRange_t)));
l_addr->hdatImtAddrRngStrAddr = i_start;
l_addr->hdatImtAddrRngEndAddr = i_end;
iv_IMTaddrRngArrayHdr.hdatArrayCnt++;
}
else
{
/*@
* @errortype
* @refcode LIC_REFCODE
* @subsys EPUB_FIRMWARE_SP
* @reasoncode RC_ERC_MAX_EXCEEDED
* @moduleid MOD_ADD_IMT_ADDR_RANGE
* @userdata1 current number of array entries
* @userdata2 maximum number of array entries
* @userdata3 none
* @userdata4 none
* @devdesc Exceeded limit of number of mainstore VPD
* In Memory Trace array entries
*/
hdatBldErrLog(l_errlHndl,
MOD_ADD_IMT_ADDR_RANGE, // SRC module ID
RC_ERC_MAX_EXCEEDED, // SRC extended reference code
iv_IMTaddrRngArrayHdr.hdatArrayCnt, // SRC hex word 1
iv_maxIMTAddrRngCnt); // SRC hex word 2
}
return l_errlHndl;
}
/** @brief See the prologue in hdatmsvpd.H
*/
errlHndl_t HdatMsVpd::addUEAddrRange(hdatMsAddr_t &i_addr)
{
errlHndl_t l_errlHndl = NULL;
hdatMsVpdUEAddrRange_t *l_addr;
if (iv_UEaddrRngArrayHdr.hdatArrayCnt < iv_maxUEAddrRngCnt)
{
l_addr = reinterpret_cast<hdatMsVpdUEAddrRange_t*>(reinterpret_cast
<char*>(iv_UEaddrRangeArray) + (iv_UEaddrRngArrayHdr.hdatArrayCnt *
sizeof(hdatMsVpdUEAddrRange_t)));
l_addr->hdatUEAddr = i_addr;
iv_UEaddrRngArrayHdr.hdatArrayCnt++;
}
else
{
/*@
* @errortype
* @refcode LIC_REFCODE
* @subsys EPUB_FIRMWARE_SP
* @reasoncode RC_ERC_MAX_EXCEEDED
* @moduleid MOD_ADD_UE_ADDR_RANGE
* @userdata1 current number of array entries
* @userdata2 maximum number of array entries
* @userdata3 none
* @userdata4 none
* @devdesc Exceeded limit of number of mainstore
* VPD In Memory Trace array entries
*/
hdatBldErrLog(l_errlHndl,
MOD_ADD_UE_ADDR_RANGE, // SRC module ID
RC_ERC_MAX_EXCEEDED, // SRC extended reference code
iv_UEaddrRngArrayHdr.hdatArrayCnt, // SRC hex word 1
iv_maxUEAddrRngCnt); // SRC hex word 2
}
return l_errlHndl;
}
errlHndl_t HdatMsVpd::addRHBAddrRange(uint32_t i_dbob_id, hdatMsAddr_t &i_start,
hdatMsAddr_t &i_end, uint32_t i_labelSize,
uint8_t* &i_labelStringPtr)
{
errlHndl_t l_errlHndl = NULL;
hdatMsVpdRhbAddrRange_t *l_addr;
if (iv_RHBaddrRngArrayHdr.hdatArrayCnt < iv_maxRHBAddrRngCnt)
{
l_addr = reinterpret_cast<hdatMsVpdRhbAddrRange_t*>(reinterpret_cast
<char*>(iv_RHBaddrRangeArray) + (iv_RHBaddrRngArrayHdr.hdatArrayCnt *
sizeof(hdatMsVpdRhbAddrRange_t)));
l_addr->hdatRhbRngType = HDAT::RHB_TYPE_INVALID;
l_addr->hdatRhbRngId = i_dbob_id;
l_addr->hdatRhbAddrRngStrAddr = i_start;
l_addr->hdatRhbAddrRngEndAddr = i_end;
//TODO : : RTC Story 159684
//Need to verify the correct data for label size and string
if (i_labelSize <= HDAT_MS_RHB_LABEL_LEN)
{
l_addr->hdatRhbLabelSize = i_labelSize;
}
else
{
l_addr->hdatRhbLabelSize = HDAT_MS_RHB_LABEL_LEN;
}
memset(l_addr->hdatRhbLabelString, 0x00, HDAT_MS_RHB_LABEL_LEN);
if (i_labelStringPtr != NULL)
{
for(uint8_t l_idx = 0; l_idx < l_addr->hdatRhbLabelSize; l_idx++)
{
l_addr->hdatRhbLabelString[l_idx] = i_labelStringPtr[l_idx];
}
}
else
{
HDAT_INF("hdatmsvpd:addRHBAddrRange "
"i_labelStringPtr is NULL");
}
iv_RHBaddrRngArrayHdr.hdatArrayCnt++;
}
else
{
/*@
* @errortype
* @refcode LIC_REFCODE
* @subsys EPUB_FIRMWARE_SP
* @reasoncode RC_ERC_MAX_EXCEEDED
* @moduleid MOD_ADD_RES_HB_ADDR_RANGE
* @userdata1 current number of array entries
* @userdata2 maximum number of array entries
* @userdata3 none
* @userdata4 none
* @devdesc Exceeded limit of number of mainstore VPD Reserved
* Hostboot array entries
*/
hdatBldErrLog(l_errlHndl,
MOD_ADD_RES_HB_ADDR_RANGE, // SRC module ID
RC_ERC_MAX_EXCEEDED, // SRC extended reference code
iv_RHBaddrRngArrayHdr.hdatArrayCnt, // SRC hex word 1
iv_maxRHBAddrRngCnt); // SRC hex word 2
}
return l_errlHndl;
}
/** @brief See the prologue in hdatmsvpd.H
*/
void HdatMsVpd::setBSR(const hdatMsAddr_t &i_bsrAddr,
hdatBsrMode i_bsrMode)
{
const uint32_t HDAT_BSR_ENABLED = 0x20000000;
iv_mover.hdatFlags |= (HDAT_BSR_ENABLED | i_bsrMode);
memcpy(&iv_mover.hdatBSRAddr, &i_bsrAddr, sizeof(hdatMsAddr_t));
return;
}
/** @brief See the prologue in hdatmsvpd.H
*/
void HdatMsVpd::setXSCOM(const hdatMsAddr_t &i_xscomAddr)
{
const uint32_t HDAT_XSCOM_ENABLED = 0x10000000;
iv_mover.hdatFlags |= HDAT_XSCOM_ENABLED;
memcpy(&iv_mover.hdatXSCOMAddr, &i_xscomAddr, sizeof(hdatMsAddr_t));
return;
}
/** @brief See the prologue in hdatmsvpd.H
*/
errlHndl_t HdatMsVpd::addMsAreaFru(uint32_t i_resourceId,
uint32_t i_slcaIndex,
TARGETING::Target * i_target,
uint16_t i_msAreaId,
uint32_t i_ramCnt,
uint32_t i_chipEcCnt,
uint32_t i_addrRngCnt)
{
errlHndl_t l_errlHndl = NULL;
HdatMsArea *l_msArea, *l_prevMsArea, **l_arrayEntry;
uint32_t l_slcaIdx, l_kwdSize, l_resourceId, l_prevIdx;
char *l_kwd;
l_msArea = NULL;
l_kwd = NULL;
l_slcaIdx = i_slcaIndex;
l_kwdSize = 0;
// Ensure we are not over max mainstore areas that we were told this object
// could handle on the constructor.
if (iv_actMsAreaCnt < iv_maxMsAreaCnt)
{
// Determine if the resource ID associated with this mainstore area is
// the same as the resoruce id of the previous mainstore area.If it is,
// we can gain a performance advantage (translates into a smaller IPL
// time for the builddata step) by using the ASCII keyword data we
// already have rather than going to svpd to get it again.
if (iv_actMsAreaCnt > 0)
{
l_prevIdx = iv_actMsAreaCnt - 1;
l_prevMsArea = HDAT_MS_AREA(l_prevIdx);
l_prevMsArea->getKwdInfo(l_resourceId, l_slcaIdx, l_kwdSize, l_kwd);
if (l_resourceId != i_resourceId)
{
l_kwd = NULL;
l_slcaIdx = 0;
l_kwdSize = 0;
}
}
// Create a mainstore area object and add it to the array of objects we
// are managing
l_msArea = new HdatMsArea(l_errlHndl,
i_target,
i_msAreaId,
i_ramCnt,
i_chipEcCnt,
i_addrRngCnt,
i_resourceId,
l_slcaIdx,
l_kwdSize,
l_kwd);
if (NULL == l_errlHndl)
{
l_arrayEntry = reinterpret_cast<HdatMsArea**>(reinterpret_cast
<char*>(iv_msAreaPtrs) + iv_actMsAreaCnt * sizeof(HdatMsArea *));
*l_arrayEntry = l_msArea;
iv_actMsAreaCnt++;
}
else
{
delete l_msArea;
}
}
else
{
/*@
* @errortype
* @refcode LIC_REFCODE
* @subsys EPUB_FIRMWARE_SP
* @reasoncode RC_ERC_MAX_EXCEEDED
* @moduleid MOD_ADD_MS_AREA_FRU
* @userdata1 current array entry count
* @userdata2 maximum array entry count
* @userdata3 ID number of mainstore area that wasn't added
* @userdata4 none
* @devdesc Exceeded limit of number of mainstore area array entries
*/
hdatBldErrLog(l_errlHndl,
MOD_ADD_MS_AREA_FRU, // SRC module ID
RC_ERC_MAX_EXCEEDED, // SRC extended reference code
iv_actMsAreaCnt, // SRC hex word 1
iv_maxMsAreaCnt, // SRC hex word 2
i_msAreaId); // SRC hex word 3
}
return l_errlHndl;
}
/** @brief See the prologue in hdatmsvpd.H
*/
void HdatMsVpd::setMsAreaType(uint16_t i_msAreaId,
hdatMemParentType i_type)
{
HdatMsArea *l_obj;
if (i_msAreaId < iv_actMsAreaCnt)
{
l_obj = HDAT_MS_AREA(i_msAreaId);
l_obj->setParentType(i_type);
}
return;
}
/** @brief See the prologue in hdatmsvpd.H
*/
void HdatMsVpd::setMsAreaStat(uint16_t i_msAreaId,
uint16_t i_status)
{
HdatMsArea *l_obj;
if (i_msAreaId < iv_actMsAreaCnt)
{
l_obj = HDAT_MS_AREA(i_msAreaId);
l_obj->setStatus(i_status);
}
else
{
HDAT_ERR( "hdatmsvpd:setMsAreaStat - invalid i_msAreadId parameter");
}
return;
}
/** @brief See the prologue in hdatmsvpd.H
*/
void HdatMsVpd::setMsAreaInterleavedId(uint16_t i_msAreaId,
uint16_t i_id)
{
HdatMsArea *l_obj;
if (i_msAreaId < iv_actMsAreaCnt)
{
l_obj = HDAT_MS_AREA(i_msAreaId);
l_obj->setInterleavedId(i_id);
}
else
{
HDAT_ERR( "hdatmsvpd:setMsAreaInterleavedId-invalid i_msAreadId "
"parameter");
}
return;
}
/** @brief See the prologue in hdatmsvpd.H
*/
void HdatMsVpd::setMsAreaSize(uint16_t i_msAreaId,
uint32_t i_size)
{
HdatMsArea *l_obj;
if (i_msAreaId < iv_actMsAreaCnt)
{
l_obj = HDAT_MS_AREA(i_msAreaId);
l_obj->setSize(i_size);
}
else
{
HDAT_ERR( "hdatmsvpd:setMsAreaSize - invalid i_msAreadId parameter");
}
return;
}
/** @brief See the prologue in hdatmsvpd.H
*/
void HdatMsVpd::setMsAreaModuleId(uint16_t i_msAreaId,
uint32_t i_moduleId)
{
HdatMsArea *l_obj;
if (i_msAreaId < iv_actMsAreaCnt)
{
l_obj = HDAT_MS_AREA(i_msAreaId);
l_obj->setModuleId(i_moduleId);
}
else
{
HDAT_ERR( "hdatmsvpd:setMsAreaModuleId - invalid i_msAreadId"
" parameter");
}
return;
}
/** @brief See the prologue in hdatmsvpd.H
*/
void HdatMsVpd::setMsAreaAffinityDomain(uint16_t i_msAreaId,
uint32_t i_affinityDomain)
{
HdatMsArea *l_obj;
if (i_msAreaId < iv_actMsAreaCnt)
{
l_obj = HDAT_MS_AREA(i_msAreaId);
l_obj->setAffinityDomain(i_affinityDomain);
}
else
{
HDAT_ERR("hdatmsvpd:setMsAreaAffinityDomain-invalid "
"i_msAreadId parameter");
}
return;
}
/** @brief See the prologue in hdatmsvpd.H
*/
errlHndl_t HdatMsVpd::addMsAreaAddr(uint16_t i_msAreaId,
hdatMsAddr_t &i_start,
hdatMsAddr_t &i_end,
uint32_t i_procChipId,
bool i_rangeIsMirrorable,
uint8_t i_mirroringAlgorithm,
uint64_t i_startMirrAddr)
{
errlHndl_t l_errlHndl = NULL;
HdatMsArea *l_obj;
hdatMsAddr_t l_startMirrAddr;
memcpy(&l_startMirrAddr, &i_startMirrAddr, sizeof(hdatMsAddr_t));
if (i_msAreaId < iv_actMsAreaCnt)
{
l_obj = HDAT_MS_AREA(i_msAreaId);
l_errlHndl = l_obj->addAddrRange(i_start, i_end, i_procChipId,
i_rangeIsMirrorable, i_mirroringAlgorithm, l_startMirrAddr);
}
else
{
HDAT_INF( "hdatmsvpd:addMsAreaAddr - invalid i_msAreadId parameter");
}
return l_errlHndl;
}
/** @brief See the prologue in hdatmsvpd.H
*/
errlHndl_t HdatMsVpd::addEcEntry(uint16_t i_msAreaId,
uint32_t i_manfId,
uint32_t i_ecLvl)
{
errlHndl_t l_errlHndl = NULL;
HdatMsArea *l_obj;
if (i_msAreaId < iv_actMsAreaCnt)
{
l_obj = HDAT_MS_AREA(i_msAreaId);
l_errlHndl = l_obj->addEcEntry(i_manfId, i_ecLvl);
}
else
{
HDAT_ERR( "hdatmsvpd:addEcEntry - invalid i_msAreadId parameter");
}
return l_errlHndl;
}
/** @brief See the prologue in hdatmsvpd.H
*/
void HdatMsVpd::setMsaI2cInfo(uint16_t i_msAreaId,
std::vector<hdatI2cData_t>& i_I2cDevEntries)
{
HdatMsArea *l_obj;
if (i_msAreaId < iv_actMsAreaCnt)
{
l_obj = HDAT_MS_AREA(i_msAreaId);
l_obj->setMsaI2cInfo(i_I2cDevEntries);
}
else
{
HDAT_ERR("hdatmsvpd:setMsaI2cInfo - invalid i_msAreadId parametera");
}
}
/** @brief See the prologue in hdatmsvpd.H
*/
errlHndl_t HdatMsVpd::addRamFru(uint16_t i_msAreaId,
TARGETING::Target * i_target,
uint32_t i_resourceId,
uint32_t i_slcaIndex,
uint16_t i_ramId,
uint16_t i_status,
uint32_t i_size)
{
errlHndl_t l_errlHndl = NULL;
HdatMsArea *l_msArea;;
HdatRam *l_ram;
// Ensure we are not over the current mainstore area count
if (i_msAreaId < iv_actMsAreaCnt)
{
l_ram = NULL;
l_msArea = HDAT_MS_AREA(i_msAreaId);
// Create a RAM object
l_ram = new HdatRam(l_errlHndl, i_target, i_resourceId,i_slcaIndex);
if (NULL == l_errlHndl)
{
l_ram->iv_ramArea.hdatRamAreaId = i_ramId;
l_ram->iv_ramArea.hdatRamStatus = i_status;
l_ram->iv_ramSize.hdatRamTotalSize = i_size;
// Add the RAM object to the mainstore area object
if (l_msArea)
{
l_errlHndl = l_msArea->addRam(*l_ram);
}
}
if (NULL != l_errlHndl)
{
delete l_ram;
}
}
else
{
/*@
* @errortype
* @refcode LIC_REFCODE
* @subsys EPUB_FIRMWARE_SP
* @reasoncode RC_ERC_NO_PARENT
* @moduleid MOD_ADD_RAM_FRU
* @userdata1 main store area id
* @userdata2 current count of main store areas
* @userdata3 none
* @userdata4 none
* @devdesc Attempted to add a RAM FRU for an invalid mainstore area
*/
HDAT_INF("Attempted to add a RAM FRU for an invalid mainstore area %d",
i_msAreaId);
hdatBldErrLog(l_errlHndl,
MOD_ADD_RAM_FRU, // SRC module ID
RC_ERC_NO_PARENT, // SRC extended reference code
i_msAreaId, // SRC hex word 1
iv_actMsAreaCnt); // SRC hex word 2
}
return l_errlHndl;
}
/** @brief See the prologue in hdatmsvpd.H
*/
void HdatMsVpd::adjustMsAreaObjects()
{
HdatMsArea *l_msEntry;
uint32_t l_idx, l_maxSize, l_tempSize;
bool l_adjust;
l_maxSize = 0;
l_adjust = false;
// Finalize the object size for each MS area object. Also, determine if
// the objects differ in size. If they do, an extra step is needed to make
// them all the same size.
for (l_idx = 0; l_idx < iv_actMsAreaCnt; l_idx++)
{
l_msEntry = *(reinterpret_cast<HdatMsArea**>(reinterpret_cast
<char*>(iv_msAreaPtrs) + l_idx * sizeof(HdatMsArea *)));
l_msEntry->finalizeObjSize(); // Get the MS area sizes updated before
// size() method is used
l_tempSize = l_msEntry->size();
if (l_maxSize != l_tempSize)
{
if (l_maxSize != 0)
{
l_adjust = true;
}
if (l_maxSize < l_tempSize)
{
l_maxSize = l_tempSize;
}
}
}
// Do we need to adjust some of the MS area objects to make them all the
// same size?
if (l_adjust)
{
for (l_idx = 0; l_idx < iv_actMsAreaCnt; l_idx++)
{
l_msEntry = *(reinterpret_cast<HdatMsArea**>(reinterpret_cast
<char*>(iv_msAreaPtrs) + l_idx * sizeof(HdatMsArea *)));
// If too small, adjust its size
if (l_msEntry->size() < l_maxSize)
{
l_msEntry->maxSiblingSize(l_maxSize);
}
}
}
// Tell the base class about child and grandchild structures.
for (l_idx = 0; l_idx < iv_actMsAreaCnt; l_idx++)
{
l_msEntry = *(reinterpret_cast<HdatMsArea**>(reinterpret_cast
<char*>(iv_msAreaPtrs) + l_idx * sizeof(HdatMsArea *)));
this->addChild(HDAT_MS_AREAS, l_msEntry->size(),1);//1st parm is 0 based
this->addGrandChild(l_msEntry->ramObjSizes());
}
return;
}
/** @brief See the prologue in hdatmsvpd.H
*/
void HdatMsVpd::getTotalSize(uint32_t &o_size)
{
HdatMsArea *l_msEntry;
// Since MS area objects could be different sizes at this point (different
// size for the VPD, for example) and since PHYP traverses the MS areas
// as an array, we may need to adjust the MS areas so they are all the same
// size.
this->adjustMsAreaObjects();
o_size = this->getSize();
o_size += sizeof(hdatMsVpdAddr_t);
o_size += sizeof(hdatMsVpdSize_t);
o_size += sizeof(hdatMsVpdPageMover_t);
o_size += sizeof(hdatHDIFDataArray_t);
o_size += (iv_maxIMTAddrRngCnt * sizeof(hdatMsVpdImtAddrRange_t));
o_size += sizeof(hdatHDIFDataArray_t);
o_size += (iv_maxUEAddrRngCnt * sizeof(hdatMsVpdUEAddrRange_t));
o_size += sizeof(hdatHDIFDataArray_t);
o_size += (iv_maxRHBAddrRngCnt * sizeof(hdatMsVpdRhbAddrRange_t));
o_size += this->endCommitSize();
// Write the MS area structures and RAM structures
if (iv_actMsAreaCnt > 0)
{
// All of the mainstore areas must be written first so that can be
// processed as an array of mainstore areas.
uint32_t l_ramSizes = 0;
uint8_t l_cnt = 0;
uint8_t l_currOffset = 0;
while (l_cnt < iv_actMsAreaCnt)
{
l_msEntry = *(reinterpret_cast<HdatMsArea**>(reinterpret_cast
<char*>(iv_msAreaPtrs) + l_cnt * sizeof(HdatMsArea *)));
// Since we don't know what order mainstore areas and RAM
// areas were created, update the offset in the HdatMsArea
// child structure triple so it points to the first RAM area.
l_currOffset = (iv_actMsAreaCnt - l_cnt) * l_msEntry->size()
+ l_ramSizes;
l_msEntry->chgChildOffset(HDAT_MS_AREA_RAM_AREAS, l_currOffset);
o_size += l_msEntry->getMsAreaSize();
// Now compute the size of the RAM areas associated with this
// mainstore area. These will have to be added to the child offset
// for the next mainstore area to skip over them.
l_ramSizes += l_msEntry->ramObjSizes();
l_cnt++;
}
// Now the children (RAM areas) of each mainstore area must be committed
l_cnt = 0;
while (l_cnt < iv_actMsAreaCnt)
{
l_msEntry = *(reinterpret_cast<HdatMsArea**>(reinterpret_cast
<char*>(iv_msAreaPtrs) + l_cnt * sizeof(HdatMsArea *)));
o_size += l_msEntry->getRamAreaSize();
l_cnt++;
}
}
}
/** @brief See the prologue in hdatmsvpd.H
*/
void HdatMsVpd::prt()
{
uint32_t l_cnt;
HdatMsArea *l_obj;
HDAT_INF(" **** HdatMsVpd start ****");
HDAT_INF(" iv_msAddr = 0X %08X %08X ", iv_msAddr.hi, iv_msAddr.lo);
HDAT_INF(" iv_actMsAreaCnt = %u", iv_actMsAreaCnt);
HDAT_INF(" iv_maxMsAreaCnt = %u", iv_maxMsAreaCnt);
this->print();
HDAT_INF(" **hdatMsVpdAddr_t**");
HDAT_INF(" hdatMaxAddr = 0X %08X %08X ", iv_maxAddr.hdatMaxAddr.hi,
iv_maxAddr.hdatMaxAddr.lo);
HDAT_INF(" hdatMaxCcmAddr = 0X %08X %08X ", iv_maxAddr.hdatMaxCcmAddr.hi,
iv_maxAddr.hdatMaxCcmAddr.lo);
HDAT_INF(" hdatMstSigAffntyDom = 0X %08X ", iv_maxAddr.hdatMstSigAffntyDom);
HDAT_INF(" **hdatMsVpdSize_t**");
HDAT_INF(" hdatReserved1 = %u", iv_maxSize.hdatReserved1);
HDAT_INF(" hdatTotSize = %u", iv_maxSize.hdatTotSize);
HDAT_INF(" **hdatMsVpdPageMover_t**");
HDAT_INF(" hdatFlags = %u", iv_mover.hdatFlags);
HDAT_INF(" hdatLockCnt = %u", iv_mover.hdatLockCnt);
HDAT_INF(" hdatLockAddr = 0X %08X %08X ", iv_mover.hdatLockAddr.hi,
iv_mover.hdatLockAddr.lo);
HDAT_INF(" hdatMoverAddr = 0X %08X %08X ", iv_mover.hdatMoverAddr.hi,
iv_mover.hdatMoverAddr.lo);
HDAT_INF(" hdatBSRAddr = 0X %08X %08X ", iv_mover.hdatBSRAddr.hi,
iv_mover.hdatBSRAddr.lo);
HDAT_INF(" **hdatMsVpdImtAddrRange_t**");
hdatPrintHdrs(NULL, NULL, &iv_IMTaddrRngArrayHdr, NULL);
{
hdatMsVpdImtAddrRange_t *l_addr = iv_IMTaddrRangeArray;
for (l_cnt = 0; l_cnt < iv_IMTaddrRngArrayHdr.hdatArrayCnt; l_cnt++)
{
HDAT_INF(" hdatImtAddrRngStrAddr = 0X %08X %08X ",
l_addr->hdatImtAddrRngStrAddr.hi,
l_addr->hdatImtAddrRngStrAddr.lo);
HDAT_INF(" hdatImtAddrRngEndAddr = 0X %08X %08X ",
l_addr->hdatImtAddrRngEndAddr.hi,
l_addr->hdatImtAddrRngEndAddr.lo);
l_addr++;
l_cnt++;
}
}
HDAT_INF(" **hdatMsVpdUEAddrRange_t**");
hdatPrintHdrs(NULL, NULL, &iv_UEaddrRngArrayHdr, NULL);
{
hdatMsVpdUEAddrRange_t *l_addr = iv_UEaddrRangeArray;
for (l_cnt = 0; l_cnt < iv_UEaddrRngArrayHdr.hdatArrayCnt; l_cnt++)
{
HDAT_INF(" hdatUEAddrRngStrAddr = 0X %08X %08X ",
l_addr->hdatUEAddr.hi,
l_addr->hdatUEAddr.lo);
l_addr++;
l_cnt++;
}
}
HDAT_INF(" **hdatMsVpdRhbAddrRange_t**");
hdatPrintHdrs(NULL, NULL, &iv_RHBaddrRngArrayHdr, NULL);
{
hdatMsVpdRhbAddrRange_t *l_addr = iv_RHBaddrRangeArray;
for (l_cnt = 0; l_cnt < iv_RHBaddrRngArrayHdr.hdatArrayCnt; l_cnt++)
{
HDAT_INF(" hdatRhbAddrRngStrAddr = 0X %08X %08X ",
l_addr->hdatRhbAddrRngStrAddr.hi,
l_addr->hdatRhbAddrRngStrAddr.lo);
HDAT_INF(" hdatRhbAddrRngEndAddr = 0X %08X %08X ",
l_addr->hdatRhbAddrRngEndAddr.hi,
l_addr->hdatRhbAddrRngEndAddr.lo);
l_addr++;
l_cnt++;
}
}
HDAT_INF("");;
HDAT_INF(" **** HdatMsVpd end ****");
HDAT_INF(" **main store areas and their associated RAM areas**");
for (l_cnt = 0; l_cnt < iv_actMsAreaCnt; l_cnt++)
{
l_obj = *(HdatMsArea **)((char *)iv_msAreaPtrs + l_cnt *
sizeof(HdatMsArea *));
l_obj->prt();
}
return;
}
/*******************************************************************************
* hdatLoadMsData
*******************************************************************************/
errlHndl_t HdatMsVpd::hdatLoadMsData(uint32_t &o_size, uint32_t &o_count)
{
errlHndl_t l_err = NULL;
HDAT_ENTER();
do
{
//Find the system target
TARGETING::Target *l_pSysTarget = NULL;
(void) TARGETING::targetService().getTopLevelTarget(l_pSysTarget);
assert(l_pSysTarget != NULL);
hdatMsAddr_t l_addr_range;
hdatMsAddr_t l_end;
l_addr_range.hi = 0x0;
l_addr_range.lo = 0x0;
l_end = l_addr_range;
uint32_t l_sizeConfigured = 0;
uint64_t l_maxMsAddr = hdatGetMaxMemConfiguredAddress();
hdatMsAddr_t l_tmpMaxMsAddr;
l_tmpMaxMsAddr.hi = (l_maxMsAddr & 0xFFFFFFFF00000000ull) >> 32;
l_tmpMaxMsAddr.lo = l_maxMsAddr & 0x00000000FFFFFFFFull;
HDAT_INF("MaxMsAddr high:0x%.8X 0x%.8X",
l_tmpMaxMsAddr.hi,l_tmpMaxMsAddr.lo);
uint32_t l_mostSigAffinityDomain_x = 0;
uint32_t l_ueCount = 1;
TARGETING::ATTR_MIRROR_BASE_ADDRESS_type l_mirroringBaseAddress_x =
l_pSysTarget->getAttr<TARGETING::ATTR_MIRROR_BASE_ADDRESS>();
TARGETING::ATTR_MIRROR_BASE_ADDRESS_type l_mirrorBaseAddress_x =
l_mirroringBaseAddress_x;
l_mirroringBaseAddress_x |= HDAT_REAL_ADDRESS_MASK64;
TARGETING::ATTR_MAX_MCS_PER_SYSTEM_type l_maxMsAreas =
l_pSysTarget->getAttr<TARGETING::ATTR_MAX_MCS_PER_SYSTEM>();
// Initialize the MS vpd class
// TODO : RTC Story 166994 to set the maximum number of Ms Area entries
// from new attribute
hdatInit(l_tmpMaxMsAddr,l_tmpMaxMsAddr,l_sizeConfigured,l_maxMsAreas*2,
l_mostSigAffinityDomain_x,l_ueCount,l_mirroringBaseAddress_x);
TARGETING::ATTR_XSCOM_BASE_ADDRESS_type l_xscomAddr =
l_pSysTarget->getAttr<TARGETING::ATTR_XSCOM_BASE_ADDRESS>();
assert(l_xscomAddr != 0);
{
hdatMsAddr_t l_hdatXscomAddr;
l_hdatXscomAddr.hi = (l_xscomAddr & 0xFFFFFFFF00000000ull) >> 32;
l_hdatXscomAddr.lo = l_xscomAddr & 0x00000000FFFFFFFFull;
l_hdatXscomAddr.hi |= HDAT_REAL_ADDRESS_MASK;
setXSCOM(l_hdatXscomAddr);
}
uint32_t l_index = 0;
//for each proc/ memory controller in the system
TARGETING::PredicateCTM l_procPred(TARGETING::CLASS_CHIP,
TARGETING::TYPE_PROC);
TARGETING::PredicateHwas l_predHwasPresent;
l_predHwasPresent.present(true);
TARGETING::PredicateHwas l_predHwasFunc;
l_predHwasFunc.functional(true);
TARGETING::PredicatePostfixExpr l_funcProc;
l_funcProc.push(&l_procPred).push(&l_predHwasFunc).And();
TARGETING::TargetRangeFilter l_procs(
TARGETING::targetService().begin(),
TARGETING::targetService().end(),
&l_funcProc);
uint32_t l_nxtSharingGroupId = 0;
for(;l_procs;++l_procs)
{
TARGETING::Target *l_pProcTarget = *(l_procs);
TARGETING::ATTR_ORDINAL_ID_type l_procChipId
= l_pProcTarget->getAttr<TARGETING::ATTR_ORDINAL_ID>();
//For each MCA
TARGETING::PredicateCTM l_allMca(TARGETING::CLASS_UNIT,
TARGETING::TYPE_MCA);
TARGETING::PredicateHwas l_funcMca;
l_funcMca.functional(true);
TARGETING::PredicatePostfixExpr l_allFuncMca;
l_allFuncMca.push(&l_allMca).push(&l_funcMca).And();
TARGETING::TargetHandleList l_mcaList;
TARGETING::targetService().
getAssociated(l_mcaList, l_pProcTarget,
TARGETING::TargetService::CHILD,
TARGETING::TargetService::ALL, &l_allFuncMca);
TARGETING::ATTR_PROC_MEM_BASES_type l_procMemBases = {0};
assert(l_pProcTarget->
tryGetAttr<TARGETING::ATTR_PROC_MEM_BASES>(l_procMemBases));
//Sharing count for each group
TARGETING::ATTR_MSS_MEM_MC_IN_GROUP_type l_mcaSharingCount = {0};
//Group ID for each group, group id will be assigned only
//if the group is shared
TARGETING::ATTR_MSS_MEM_MC_IN_GROUP_type l_mcsSharingGrpIds = {0};
//Size configured under each group
TARGETING::ATTR_PROC_MEM_SIZES_type l_procMemSizesBytes = {0};
assert(l_pProcTarget->tryGetAttr<TARGETING::ATTR_PROC_MEM_SIZES>
(l_procMemSizesBytes));
for(uint32_t l_mcaIdx = 0; l_mcaIdx<l_mcaList.size();
++l_mcaIdx)
{
uint32_t l_mcaInGrp = 0;
TARGETING::Target *l_pMcaTarget =
l_mcaList[l_mcaIdx];
if(!hdatFindGroupForMc(l_pProcTarget,
l_pMcaTarget,
l_mcaInGrp))
{
//Skip this MCA is not in any group
continue;
}
//Increment sharing count if mem configured under group.
if(l_procMemSizesBytes[l_mcaInGrp] > 0)
{
l_mcaSharingCount[l_mcaInGrp]++;
//Assign sharing group id only if shared
//And only when first instance of sharing is found
if(l_mcaSharingCount[l_mcaInGrp] ==
HDAT_MIN_NUM_FOR_SHARING)
{
l_mcsSharingGrpIds[l_mcaInGrp] =
l_nxtSharingGroupId;
l_nxtSharingGroupId++;
}
}
}
// TODO : RTC Story 159682
// Further CHTM support needs to be added which contains the trace
// array for 24 cores
hdatMsAddr_t l_hdatNhtmStartAddr;
hdatMsAddr_t l_hdatNhtmEndAddr;
TARGETING::ATTR_PROC_NHTM_BAR_BASE_ADDR_type l_nhtmStartAddr =
l_pProcTarget->getAttr<TARGETING::ATTR_PROC_NHTM_BAR_BASE_ADDR>();
TARGETING::ATTR_PROC_NHTM_BAR_SIZE_type l_nhtmSize =
l_pProcTarget->getAttr<TARGETING::ATTR_PROC_NHTM_BAR_SIZE>();
if( 0 != l_nhtmSize )
{
l_hdatNhtmStartAddr.hi =
(l_nhtmStartAddr & 0xFFFFFFFF00000000ull) >> 32;
l_hdatNhtmStartAddr.lo =
l_nhtmStartAddr & 0x00000000FFFFFFFFull;
l_hdatNhtmStartAddr.hi |= HDAT_REAL_ADDRESS_MASK;
auto l_nhtmEndAddr = l_nhtmStartAddr + l_nhtmSize;
l_hdatNhtmEndAddr.hi =
(l_nhtmEndAddr & 0xFFFFFFFF00000000ull) >> 32;
l_hdatNhtmEndAddr.lo = l_nhtmEndAddr & 0x00000000FFFFFFFFull;
l_hdatNhtmEndAddr.hi |= HDAT_REAL_ADDRESS_MASK;
HDAT_INF("hdatNhtmStartAddr = 0x%08X 0x%08X ",
l_hdatNhtmStartAddr.hi, l_hdatNhtmStartAddr.lo);
HDAT_INF("hdatNhtmEndAddr = 0x%08X 0x%08X ",
l_hdatNhtmEndAddr.hi, l_hdatNhtmEndAddr.lo);
addIMTAddrRange(l_hdatNhtmStartAddr, l_hdatNhtmEndAddr);
}
else
{
HDAT_INF("NHTM Bar size value = 0x%016llX",
l_nhtmSize);
}
TARGETING::PredicateCTM l_mcbistPredicate(TARGETING::CLASS_UNIT,
TARGETING::TYPE_MCBIST);
TARGETING::PredicatePostfixExpr l_presentMcbist;
l_presentMcbist.push(&l_mcbistPredicate).
push(&l_predHwasFunc).And();
TARGETING::TargetHandleList l_mcbistList;
// Find Associated MCBIST list
TARGETING::targetService().getAssociated(l_mcbistList,
l_pProcTarget,
TARGETING::TargetService::CHILD_BY_AFFINITY,
TARGETING::TargetService::ALL,
&l_presentMcbist);
//scan all mcbist in this proc
for(uint32_t l_mcbistIdx =0;
l_mcbistIdx < l_mcbistList.size();
++l_mcbistIdx)
{
TARGETING::Target *l_pMcbistTarget = l_mcbistList[l_mcbistIdx];
TARGETING::PredicateCTM l_mcsPredicate(TARGETING::CLASS_UNIT,
TARGETING::TYPE_MCS);
TARGETING::PredicatePostfixExpr l_funcMcs;
l_funcMcs.push(&l_mcsPredicate).push(&l_predHwasFunc).And();
TARGETING::TargetHandleList l_mcsList;
// Find Associated memory controllers
TARGETING::targetService().getAssociated(l_mcsList,
l_pMcbistTarget,
TARGETING::TargetService::CHILD,
TARGETING::TargetService::ALL,
&l_funcMcs);
//scan all mcs in this proc to get sharing counit
for(uint32_t l_mcsIdx = 0;l_mcsIdx<l_mcsList.size(); ++l_mcsIdx)
{
TARGETING::Target *l_pMcsTarget = l_mcsList[l_mcsIdx];
//for each MCA connected to this this MCS
TARGETING::PredicateCTM l_mcaPredicate(
TARGETING::CLASS_UNIT, TARGETING::TYPE_MCA);
TARGETING::PredicateHwas l_predMca;
l_predMca.present(true);
TARGETING::PredicatePostfixExpr l_presentMca;
l_presentMca.push(&l_mcaPredicate).push(&l_predMca).And();
TARGETING::TargetHandleList l_mcaList;
// Get associated MCAs
TARGETING::targetService().
getAssociated(l_mcaList, l_pMcsTarget,
TARGETING::TargetService::CHILD_BY_AFFINITY,
TARGETING::TargetService::ALL, &l_presentMca);
for(uint32_t l_mcaIdx = 0; l_mcaIdx<l_mcaList.size();
++l_mcaIdx)
{
TARGETING::Target *l_pMcaTarget =
l_mcaList[l_mcaIdx];
//Group which this MCA is belonging
uint32_t l_mcaInGrp = 0;
if(!hdatFindGroupForMc(l_pProcTarget,
l_pMcaTarget,
l_mcaInGrp))
{
HDAT_INF("No group found for MCA");
//Skip this MCS is not under any group
continue;
}
uint32_t l_mcaFruId = 0;
hdatMemParentType l_parentType= HDAT_MEM_PARENT_CEC_FRU;
std::list<hdatRamArea> l_areas;
l_areas.clear();
uint32_t l_areaSizeInMB = 0;
bool l_areaFunctional = false;
uint32_t l_numDimms =0;
l_err = hdatScanDimms(l_pMcaTarget,
l_pMcsTarget,
l_mcaFruId,
l_areas,
l_areaSizeInMB,
l_numDimms,
l_areaFunctional,
l_parentType);
if(NULL != l_err)
{
HDAT_ERR("Error in calling Scan Dimms");
break;
}
HDAT_INF("l_areaSizeInMB:0x%.8X l_numDimms:0x%.8X "
"l_areas.size():0x%.8X", l_areaSizeInMB, l_numDimms,
l_areas.size());
//Skip if no memory configured under this MCS
if(l_areaSizeInMB == 0)
{
continue;
}
uint32_t l_maxMemBlocks = 0;
l_err =
hdatGetMaxMemoryBlocks(l_pMcsTarget,l_maxMemBlocks);
if(NULL != l_err)
{
HDAT_ERR("Error error in get max blocks");
break;
}
TARGETING::ATTR_SLCA_RID_type l_procRid =
l_pProcTarget->getAttr<TARGETING::ATTR_SLCA_RID>();
TARGETING::ATTR_SLCA_INDEX_type l_procSlcaIndex =
l_pProcTarget->getAttr<TARGETING::ATTR_SLCA_INDEX>();
l_err = addMsAreaFru(l_procRid,
l_procSlcaIndex,
l_pProcTarget,
l_index,
l_numDimms,
MAX_CHIP_EC_CNT_PER_MSAREA,
l_maxMemBlocks);
if(NULL != l_err)
{
HDAT_ERR("Error adding MSArea %d"
"Number of Dimms: %d Max Blocks: %d",
l_index,
l_numDimms,l_maxMemBlocks);
break;
}
uint32_t l_memStatus = 0;
//If group is shared with more than one area
if(l_mcaSharingCount[l_mcaInGrp] >=
HDAT_MIN_NUM_FOR_SHARING)
{
l_memStatus = HDAT_MEM_SHARED;
setMsAreaInterleavedId(l_index,
l_mcsSharingGrpIds[l_mcaInGrp]);
}
setMsAreaType(l_index,l_parentType);
setMsAreaSize(l_index,l_areaSizeInMB);
iv_maxSize.hdatTotSize += l_areaSizeInMB;
l_memStatus |= l_areaFunctional ?
(HDAT_MEM_INSTALLED | HDAT_MEM_FUNCTIONAL) :
HDAT_MEM_INSTALLED;
setMsAreaStat(l_index, l_memStatus);
//Add MCS ec level
uint32_t l_mcsEcLevel = 0;
uint32_t l_mcsChipId = 0;
l_err = hdatGetIdEc(l_pMcsTarget,
l_mcsEcLevel,
l_mcsChipId);
if(NULL != l_err)
{
HDAT_ERR("Error in getting MCS ID "
"and EC HUID:[0x%08X]",
l_pMcsTarget->getAttr<TARGETING::ATTR_HUID>());
break;
}
l_err = addEcEntry(l_index,
l_mcsChipId,
l_mcsEcLevel);
if(NULL != l_err)
{
HDAT_ERR("Error in adding"
" ID[0x%08X] and EC[0x%08X] to ms area"
" HUID:[0x%08X]",l_mcsChipId,
l_mcsEcLevel,
l_pMcsTarget->getAttr<TARGETING::ATTR_HUID>());
break;
}
// Need to get i2c Master data correctly
std::vector<hdatI2cData_t> l_i2cDevEntries;
TARGETING::PredicateCTM l_membufPredicate(
TARGETING::CLASS_CHIP, TARGETING::TYPE_MEMBUF);
TARGETING::PredicatePostfixExpr l_presentMemBuf;
l_presentMemBuf.push(&l_membufPredicate).
push(&l_predHwasPresent).And();
TARGETING::TargetHandleList l_membufList;
// Find Associated membuf
TARGETING::targetService().getAssociated(l_membufList,
l_pMcsTarget,
TARGETING::TargetService::CHILD_BY_AFFINITY,
TARGETING::TargetService::ALL,
&l_presentMemBuf);
//Skip is there is no Membuf attached to this MCS
if(l_membufList.size() > 0)
{
TARGETING::Target *l_pMembufTarget =
l_membufList[0];
if (l_pMembufTarget != NULL)
{
hdatGetI2cDeviceInfo(l_pMembufTarget,
l_i2cDevEntries);
}
}
setMsaI2cInfo(l_index, l_i2cDevEntries);
std::list<hdatRamArea>::iterator l_area =
l_areas.begin();
for (uint32_t l_ramId = 0;
l_area != l_areas.end();
++l_ramId, ++l_area)
{
uint32_t l_status = (l_area)->ivFunctional ?
(HDAT_RAM_INSTALLED | HDAT_RAM_FUNCTIONAL)
: HDAT_RAM_INSTALLED;
TARGETING::Target *l_pDimmTarget =
TARGETING::Target::getTargetFromHuid(l_area->ivHuid);
TARGETING::ATTR_SLCA_RID_type l_dimmRid =
l_pDimmTarget->getAttr<TARGETING::ATTR_SLCA_RID>();
TARGETING::ATTR_SLCA_INDEX_type l_dimmSlcaIndex =
l_pDimmTarget->getAttr<TARGETING::ATTR_SLCA_INDEX>();
l_err = addRamFru(l_index,
l_pDimmTarget,
l_dimmRid,
l_dimmSlcaIndex,
l_ramId,
l_status,
(l_area)->ivSize);
if (l_err) // Failed to add ram fru information
{
HDAT_ERR("Error in adding RAM FRU"
"Index:%d Rid:[0x%08X] status:[0x%08X]"
"Size:[0x%08X] RamID:[0x%08X]",
l_index,(l_area)->ivHuid,
l_status,(l_area)->ivSize,l_ramId);
ERRORLOG::errlCommit(l_err,HDAT_COMP_ID);
delete l_err;
l_err = NULL;
continue;
}
}//end of RAM list
l_addr_range.hi = (l_procMemBases[l_mcaInGrp] &
0xFFFFFFFF00000000ull) >> 32;
l_addr_range.lo = l_procMemBases[l_mcaInGrp] &
0x00000000FFFFFFFFull;
l_end = l_addr_range;
//Update the range
l_end.hi += (l_procMemSizesBytes[l_mcaInGrp] &
0xFFFFFFFF00000000ull) >> 32;
l_end.lo += l_procMemSizesBytes[l_mcaInGrp] &
0x00000000FFFFFFFFull;
HDAT_INF("MCS:0x%08X l_addr_range:0x%08X 0x%08X"
" l_end:0x%08X 0x%08X",
l_pMcsTarget->getAttr<TARGETING::ATTR_HUID>(),
l_addr_range.hi, l_addr_range.lo,
l_end.hi,l_end.lo);
uint64_t l_hdatMirrorAddr_x = 0x0ull;
uint64_t l_hdatMirrorAddr = 0x0ull;
uint8_t l_hdatMirrorAlogrithm = 0xFF;
bool l_rangeIsMirrorable = false;
TARGETING::ATTR_PROC_MIRROR_BASES_type
l_MirrorAddr = {0};
assert(l_pProcTarget->tryGetAttr<
TARGETING::ATTR_PROC_MIRROR_BASES>(l_MirrorAddr));
TARGETING::ATTR_PROC_MIRROR_SIZES_type
l_MirrorSize = {0};
assert(l_pProcTarget->tryGetAttr<
TARGETING::ATTR_PROC_MIRROR_SIZES>(l_MirrorSize));
uint64_t l_startAddr =
(((uint64_t)(l_addr_range.hi) << 32 )
| (uint64_t)(l_addr_range.lo));
l_hdatMirrorAddr_x =
(l_startAddr / 2) + l_mirrorBaseAddress_x;
TARGETING::ATTR_PAYLOAD_IN_MIRROR_MEM_type
l_payLoadMirrorMem =
l_pSysTarget->getAttr<
TARGETING::ATTR_PAYLOAD_IN_MIRROR_MEM>();
HDAT_INF(
"Start add : 0x%016llX MirrorBase : 0x%016llX"
" MirrorAddr : 0x%016llX PayLoadMirrorMem : 0x%X",
l_startAddr, l_mirrorBaseAddress_x,
l_hdatMirrorAddr_x, l_payLoadMirrorMem);
if ( 0 != l_payLoadMirrorMem )
{
for ( int idx=0 ; idx <
(int)(sizeof(TARGETING::ATTR_PROC_MIRROR_SIZES_type)
/ sizeof(uint64_t)) ; idx++ )
{
HDAT_INF("Mirror size : 0x%016llX"
" MirrorAddr[idx] : 0x%016llX"
" hdatMirrorAddr_x : 0x%016llX",
l_MirrorSize[idx], l_MirrorAddr[idx],
l_hdatMirrorAddr_x);
if( (0 != l_MirrorSize[idx]) &&
(l_MirrorAddr[idx] == l_hdatMirrorAddr_x) )
{
l_rangeIsMirrorable = true;
l_hdatMirrorAddr = l_MirrorAddr[idx]
| HDAT_REAL_ADDRESS_MASK64;
break;
}
}
}
l_err = addMsAreaAddr(l_index,
l_addr_range,
l_end,
l_procChipId,
l_rangeIsMirrorable,
l_hdatMirrorAlogrithm,
l_hdatMirrorAddr);
if(NULL != l_err)
{
HDAT_ERR("Error in adding addMsAreaAddr"
" to ms area index[%d]",
l_index);
break;
}
// TODO : RTC Story 159682
// Further CHTM support needs to be added which contains
// the trace array for 24 cores
// Reinitializing the NHTM size
//Don't re-init NHTM size -- only one HTM region per proc
uint64_t l_end_hi = l_end.hi;
uint64_t l_end_lo = l_end.lo;
uint64_t l_end_addr = ((l_end_hi << 32 ) | l_end_lo);
uint64_t l_addr_range_hi = l_addr_range.hi;
uint64_t l_addr_range_lo = l_addr_range.lo;
uint64_t l_start_addr =((l_addr_range_hi << 32 )| l_addr_range_lo);
uint64_t l_size_bytes = ((uint64_t)l_areaSizeInMB) * l_mcaSharingCount[l_mcaInGrp] * 1024 * 1024;
if((0 != l_nhtmSize) &&
(l_size_bytes != (l_end_addr - l_start_addr)))
{
HDAT_INF("NHTM Bar size = 0x%016llX "
" MS area size = 0x%016llX"
" l_end_addr = 0x%016llX"
" l_start_addr = 0x%016llX",
l_nhtmSize,l_size_bytes, l_end_addr,
l_start_addr);
l_addr_range.lo = l_hdatNhtmStartAddr.lo;
l_addr_range.hi = l_hdatNhtmStartAddr.hi;
l_end.lo = l_hdatNhtmEndAddr.lo;
l_end.hi = l_hdatNhtmEndAddr.hi;
l_err = addMsAreaAddr(l_index,
l_addr_range,
l_end,
l_procChipId,
false, 0, 0);
if(NULL != l_err)
{
HDAT_ERR("Error in adding "
" addMsAreaAddr to ms area index[%d]",
l_index);
break;
}
l_nhtmSize=0; //only add 1 entry
}
l_addr_range = l_end;
l_index++;
} //end of mca list
} //end of MCS list
} //end of MCBIST list
if(l_err)
{
// Error message recorded above
break;
}
} //end of proc list
TARGETING::PredicateCTM l_nodePred(TARGETING::CLASS_ENC,
TARGETING::TYPE_NODE);
TARGETING::PredicateHwas l_predFunctional;
l_predFunctional.functional(true);
TARGETING::PredicatePostfixExpr l_functionalnode;
l_functionalnode.push(&l_nodePred).push(&l_predFunctional).And();
TARGETING::TargetRangeFilter l_nodes(TARGETING::targetService().begin(),
TARGETING::targetService().end(),
&l_functionalnode);
TARGETING::ATTR_HB_RSV_MEM_SIZE_MB_type l_rhbSize =
l_pSysTarget->getAttr<TARGETING::ATTR_HB_RSV_MEM_SIZE_MB>();
if( 0 != l_rhbSize )
{
for(;l_nodes;++l_nodes)
{
TARGETING::ATTR_HB_HRMOR_NODAL_BASE_type l_rhbStartAddr =
l_pSysTarget->getAttr<TARGETING::ATTR_HB_HRMOR_NODAL_BASE>();
TARGETING::Target *l_pNodeTarget = *(l_nodes);
uint32_t l_dbobId =
l_pNodeTarget->getAttr<TARGETING::ATTR_ORDINAL_ID>();
hdatMsAddr_t l_hdatRhbStartAddr;
hdatMsAddr_t l_hdatRhbEndAddr;
l_rhbStartAddr = l_rhbStartAddr * l_dbobId;
TARGETING::ATTR_PAYLOAD_BASE_type l_payLoadBase =
l_pSysTarget->getAttr<TARGETING::ATTR_PAYLOAD_BASE>();
// Since PAYLOAD_BASE is in MB's, converting it to bytes
l_rhbStartAddr |= ((uint64_t)(l_payLoadBase)) << 20;
l_rhbStartAddr &= 0xFFFFFFFF00000000;
if( l_payLoadBase > 0x100 )
{
l_rhbStartAddr = 0x40000000000; //4TB hardcode for now
}
l_hdatRhbStartAddr.hi =
(l_rhbStartAddr & 0xFFFFFFFF00000000ull) >> 32;
l_hdatRhbStartAddr.lo = l_rhbStartAddr & 0x00000000FFFFFFFFull;
l_hdatRhbStartAddr.hi |= HDAT_REAL_ADDRESS_MASK;
// need to store a 64 bit range
uint64_t l_hbSize=0;
// in bytes
uint64_t l_size_bytes = (l_rhbSize * 1024 * 1024) -1;
l_hbSize = l_rhbStartAddr + l_size_bytes;
l_hdatRhbEndAddr.hi = (l_hbSize & 0xFFFFFFFF00000000ull) >> 32;
l_hdatRhbEndAddr.lo = l_hbSize & 0x00000000FFFFFFFFull;
l_hdatRhbEndAddr.hi |= HDAT_REAL_ADDRESS_MASK;
//TODO : : RTC Story 159684
//Need to populate correct label size and label string
uint32_t l_rhbLabelSize = 0;
uint8_t* l_rhbLabelStringPtr = NULL;
addRHBAddrRange(l_dbobId, l_hdatRhbStartAddr,
l_hdatRhbEndAddr, l_rhbLabelSize,
l_rhbLabelStringPtr);
TARGETING::ATTR_HB_RSV_MEM_SIZE_MB_type l_rhbEntries =
l_pSysTarget->getAttr
<TARGETING::ATTR_HDAT_RSV_MEM_NUM_SECTIONS>();
l_dbobId = 0x0;
l_hdatRhbStartAddr.lo = 0x0;
l_hdatRhbStartAddr.hi = 0x0;
l_hdatRhbEndAddr.lo = 0x0;
l_hdatRhbEndAddr.hi = 0x0;
for(uint32_t l_entry=0; l_entry<l_rhbEntries; l_entry++)
{
addRHBAddrRange(l_dbobId, l_hdatRhbStartAddr,
l_hdatRhbEndAddr, l_rhbLabelSize,
l_rhbLabelStringPtr);
}
}
}
else
{
HDAT_INF("Reserve HB mem size 0x%08X",l_rhbSize);
}
if(l_err)
{
// Error message recorded above
break;
}
o_size = 0;
o_count = 1; // Only 1 of these structures is ever built
getTotalSize (o_size);
uint64_t l_base_addr = ((uint64_t) iv_msAddr.hi << 32) | iv_msAddr.lo;
uint64_t l_base_addr_down = ALIGN_PAGE_DOWN(l_base_addr);
iv_virtAddr = mm_block_map ( reinterpret_cast<void*>(l_base_addr_down),
(ALIGN_PAGE(o_size) + PAGESIZE));
uint64_t l_final_addr = reinterpret_cast<uint64_t>(iv_virtAddr);
l_final_addr += l_base_addr - l_base_addr_down;
iv_virtAddr = reinterpret_cast<void *> (l_final_addr);
commit(iv_virtAddr,o_size);
prt();
}
while(0);
HDAT_EXIT();
return l_err;
}
/** @brief See the prologue in hdatmsvpd.H
*/
void HdatMsVpd::commit(void * i_addr,
uint32_t i_size)
{
uint32_t l_cnt,l_currOffset, l_ramSizes;
HdatMsArea *l_msEntry;
UtilMem l_data(i_addr, i_size);
// Start committing the base class data
this->startCommit(l_data);
l_data.write(&iv_maxAddr, sizeof(hdatMsVpdAddr_t));
l_data.write(&iv_maxSize, sizeof(hdatMsVpdSize_t));
// Page mover is called 'Misc Addr Structure' on OPAL but still exists
l_data.write(&iv_mover, sizeof(hdatMsVpdPageMover_t));
l_data.write(&iv_IMTaddrRngArrayHdr,sizeof(hdatHDIFDataArray_t));
l_data.write(iv_IMTaddrRangeArray,
iv_maxIMTAddrRngCnt * sizeof(hdatMsVpdImtAddrRange_t));
l_data.write(&iv_UEaddrRngArrayHdr, sizeof(hdatHDIFDataArray_t));
l_data.write(iv_UEaddrRangeArray,
iv_maxUEAddrRngCnt * sizeof(hdatMsVpdUEAddrRange_t));
l_data.write(&iv_RHBaddrRngArrayHdr,sizeof(hdatHDIFDataArray_t));
l_data.write (iv_RHBaddrRangeArray,iv_maxRHBAddrRngCnt
* sizeof(hdatMsVpdRhbAddrRange_t));
this->endCommit(l_data);
// Write the MS area structures and RAM structures
if (iv_actMsAreaCnt > 0)
{
// All of the mainstore areas must be written first so that can be
// processed as an array of mainstore areas.
l_ramSizes = 0;
l_cnt = 0;
while (l_cnt < iv_actMsAreaCnt)
{
l_msEntry = *(reinterpret_cast<HdatMsArea **>(
reinterpret_cast<char *>(iv_msAreaPtrs) + l_cnt
* sizeof(HdatMsArea *)));
// Since we don't know what order mainstore areas and RAM
// areas were created, update the offset in the HdatMsArea
// child structure triple so it points to the first RAM area.
l_currOffset = (iv_actMsAreaCnt - l_cnt) * l_msEntry->size()
+ l_ramSizes;
l_msEntry->chgChildOffset(HDAT_MS_AREA_RAM_AREAS, l_currOffset);
l_msEntry->commit(l_data);
// Now compute the size of the RAM areas associated with this
// mainstore area. These will have to be added to the child
// offset for the next mainstore area to skip over them.
l_ramSizes += l_msEntry->ramObjSizes();
l_cnt++;
}
// Now the children (RAM areas) of each mainstore area must be committed
l_cnt = 0;
while (l_cnt < iv_actMsAreaCnt)
{
l_msEntry = *(reinterpret_cast<HdatMsArea **>(reinterpret_cast<char *>
(iv_msAreaPtrs) + l_cnt
* sizeof(HdatMsArea *)));
l_msEntry->commitRamAreas(l_data);
l_cnt++;
}
}
}
/*******************************************************************************
* hdatGetMaxMemConfiguredAddress
*******************************************************************************/
uint64_t HdatMsVpd::hdatGetMaxMemConfiguredAddress()
{
//For each processor in the system
TARGETING::PredicateCTM l_procChipPred(TARGETING::CLASS_CHIP,
TARGETING::TYPE_PROC);
TARGETING::PredicateHwas l_predFunctional;
l_predFunctional.functional(true);
TARGETING::PredicatePostfixExpr l_functionalProc;
l_functionalProc.push(&l_procChipPred).push(&l_predFunctional).And();
TARGETING::TargetRangeFilter l_procs(
TARGETING::targetService().begin(),
TARGETING::targetService().end(),
&l_functionalProc);
uint64_t l_maxBase = 0x0ull;
uint64_t l_maxMsAddress = 0x0ull;
bool l_processedAnyGroup = false;
uint64_t l_hdatMaxImtAddr = 0x0ull;
for(;l_procs;++l_procs)
{
TARGETING::Target *l_pProcTarget = (*l_procs);
TARGETING::ATTR_PROC_MEM_BASES_type l_procMemBases = {0};
TARGETING::ATTR_PROC_MEM_SIZES_type l_procMemSizesBytes = {0};
assert(l_pProcTarget->tryGetAttr<TARGETING::ATTR_PROC_MEM_SIZES>
(l_procMemSizesBytes));
assert(l_pProcTarget->
tryGetAttr<TARGETING::ATTR_PROC_MEM_BASES>(l_procMemBases));
//For each MCA
TARGETING::PredicateCTM l_allMca(TARGETING::CLASS_UNIT,
TARGETING::TYPE_MCA);
TARGETING::PredicateHwas l_funcMca;
l_funcMca.functional(true);
TARGETING::PredicatePostfixExpr l_allFuncMca;
l_allFuncMca.push(&l_allMca).push(&l_funcMca).And();
TARGETING::TargetHandleList l_mcaList;
TARGETING::targetService().
getAssociated(l_mcaList, l_pProcTarget,
TARGETING::TargetService::CHILD,
TARGETING::TargetService::ALL, &l_allFuncMca);
for(uint32_t i=0; i < l_mcaList.size(); i++)
{
TARGETING::Target *l_pMcaTarget = l_mcaList[i];
uint32_t l_mcaInGroup = 0;
if(!hdatFindGroupForMc(l_pProcTarget,
l_pMcaTarget,
l_mcaInGroup))
{
HDAT_INF("Input target is not in group,"
" MCA HUID:[0x%08X]",
l_pMcaTarget->getAttr<TARGETING::ATTR_HUID>());
//Skip this MC not part of any group
continue;
}
if(!l_processedAnyGroup ||
(l_procMemBases[l_mcaInGroup] > l_maxBase))
{
l_maxBase = l_procMemBases[l_mcaInGroup];
l_processedAnyGroup = true;
l_maxMsAddress = l_maxBase + l_procMemSizesBytes[l_mcaInGroup];
HDAT_INF("Max MS Addr l_maxMsAddress: = 0x%016llX,"
"l_maxBase= 0x%016llX,"
"l_procMemSizesBytes[l_mcaInGroup]= 0x%016llX",
l_maxMsAddress, l_maxBase, l_procMemSizesBytes[l_mcaInGroup]);
}
}
// TODO : RTC Story 159682
// Further CHTM support needs to be added which contains the trace array
// for 24 cores
hdatMsAddr_t l_hdatNhtmStartAddr;
hdatMsAddr_t l_hdatNhtmEndAddr;
TARGETING::ATTR_PROC_NHTM_BAR_BASE_ADDR_type l_nhtmStartAddr =
l_pProcTarget->getAttr<TARGETING::ATTR_PROC_NHTM_BAR_BASE_ADDR>();
TARGETING::ATTR_PROC_NHTM_BAR_SIZE_type l_nhtmSize =
l_pProcTarget->getAttr<TARGETING::ATTR_PROC_NHTM_BAR_SIZE>();
if( 0 != l_nhtmSize )
{
l_hdatNhtmStartAddr.hi =
(l_nhtmStartAddr & 0xFFFFFFFF00000000ull) >> 32;
l_hdatNhtmStartAddr.lo = l_nhtmStartAddr & 0x00000000FFFFFFFFull;
l_hdatNhtmStartAddr.hi |= HDAT_REAL_ADDRESS_MASK;
l_nhtmSize = l_nhtmStartAddr + l_nhtmSize;
l_hdatNhtmEndAddr.hi =
(l_nhtmSize & 0xFFFFFFFF00000000ull) >> 32;
l_hdatNhtmEndAddr.lo = l_nhtmSize & 0x00000000FFFFFFFFull;
l_hdatNhtmEndAddr.hi |= HDAT_REAL_ADDRESS_MASK;
if( l_hdatMaxImtAddr <
(((uint64_t)l_hdatNhtmEndAddr.hi << 32) |l_hdatNhtmEndAddr.lo))
{
l_hdatMaxImtAddr =
(((uint64_t)l_hdatNhtmEndAddr.hi << 32) |l_hdatNhtmEndAddr.lo);
HDAT_INF("NHTM Max Addr: = 0x%016llX", l_hdatMaxImtAddr);
}
}
else
{
HDAT_INF("NHTM Bar size value = 0x%016llX ", l_nhtmSize);
}
}
// Set MSB to 1 for PHYP
l_maxMsAddress |= HDAT_REAL_ADDRESS_MASK64;
if(l_hdatMaxImtAddr > l_maxMsAddress)
{
l_maxMsAddress = l_hdatMaxImtAddr;
HDAT_INF("IMT Max MS Addr: = 0x%016llX",l_maxMsAddress);
}
// We now have to subtract 1 since the address range starts at 0
if(l_maxMsAddress != 0)
{
l_maxMsAddress -= 1;
}
return l_maxMsAddress;
}
//******************************************************************************
//* hdatFindGroupForMc
//******************************************************************************
bool HdatMsVpd::hdatFindGroupForMc(const TARGETING::Target *i_pProcTarget,
const TARGETING::Target *i_pMcaTarget,
uint32_t& o_groupOfMc)
{
bool l_foundGroup = false;
TARGETING::ATTR_MSS_MEM_MC_IN_GROUP_type l_mcaGroups = {0};
assert(i_pProcTarget != NULL || i_pMcaTarget != NULL);
assert(!(i_pProcTarget->getAttr<TARGETING::ATTR_TYPE>()
!= TARGETING::TYPE_PROC)||
!(i_pProcTarget->getAttr<TARGETING::ATTR_CLASS>()
!= TARGETING::CLASS_CHIP));
assert(i_pProcTarget->
tryGetAttr<TARGETING::ATTR_MSS_MEM_MC_IN_GROUP>(l_mcaGroups));
assert(!(i_pMcaTarget->getAttr<TARGETING::ATTR_TYPE>()
!= TARGETING::TYPE_MCA)||
!(i_pMcaTarget->getAttr<TARGETING::ATTR_CLASS>()
!= TARGETING::CLASS_UNIT));
TARGETING::ATTR_CHIP_UNIT_type l_chipUnit =
i_pMcaTarget->getAttr<TARGETING::ATTR_CHIP_UNIT>();
uint32_t l_sizeOfArray = sizeof(l_mcaGroups)/sizeof(l_mcaGroups[0]);
assert(!(sizeof( l_mcaGroups[0] ) != sizeof(uint8_t)));
assert(!( l_chipUnit >= ( sizeof( l_mcaGroups[0] ) * HDAT_BITS_PER_BYTE )));
const uint8_t MC_IN_GROUP_MCA_0 = 0x80;
for(uint32_t l_idx =0; l_idx < l_sizeOfArray;++l_idx)
{
//Attribute ATTR_MSS_MEM_MC_IN_GROUP is an array of bitmask
//bit 0 of bitmask corresponds to mca 0, bit 7 to mca7
if((l_mcaGroups[l_idx] & (MC_IN_GROUP_MCA_0 >> l_chipUnit)) ==
(MC_IN_GROUP_MCA_0 >> l_chipUnit))
{
HDAT_INF("hdatFindGroupForMc::: Found group : %d",l_idx);
o_groupOfMc = l_idx;
l_foundGroup = true;
break;
}
}
return l_foundGroup;
}
/*******************************************************************************
* hdatScanDimms
*******************************************************************************/
errlHndl_t HdatMsVpd::hdatScanDimms(const TARGETING::Target *i_pTarget,
const TARGETING::Target *i_pMcsTarget,
uint32_t i_mcaFruid,
std::list<hdatRamArea>& o_areas,
uint32_t& o_areaSize,
uint32_t& o_dimmNum,
bool& o_areaFunctional,
hdatMemParentType& o_parentType)
{
errlHndl_t l_err = NULL;
do
{
if(i_pTarget->getAttr<TARGETING::ATTR_TYPE>() != TARGETING::TYPE_MCA)
{
HDAT_ERR("Input Target is type not MCA");
break;
}
if(i_pMcsTarget->getAttr<TARGETING::ATTR_TYPE>() != TARGETING::TYPE_MCS)
{
HDAT_ERR("Input Target is type not MCA");
break;
}
TARGETING::ATTR_EFF_DIMM_SIZE_type l_dimSizes = {{0}};
//Get configured memory size
if(!i_pMcsTarget->
tryGetAttr<TARGETING::ATTR_EFF_DIMM_SIZE>(l_dimSizes))
{
HDAT_ERR("DIMM size should be available with MCS");
}
uint8_t l_mcaPort = 0;
if(!i_pTarget->
tryGetAttr<TARGETING::ATTR_REL_POS>(l_mcaPort))
{
HDAT_ERR("REL_POS not there in MCA port");
}
else
{
l_mcaPort= l_mcaPort%2;
}
//[TODO RTC: 47148]
//for each DIMM connected to this this MCA
TARGETING::PredicateCTM l_dimmPredicate(TARGETING::
CLASS_LOGICAL_CARD,
TARGETING::TYPE_DIMM);
TARGETING::PredicateHwas l_predDimm;
l_predDimm.present(true);
TARGETING::PredicatePostfixExpr l_presentDimm;
l_presentDimm.push(&l_dimmPredicate).push(&l_predDimm).And();
TARGETING::TargetHandleList l_dimmList;
// Get associated dimms
TARGETING::targetService().
getAssociated(l_dimmList, i_pTarget,
TARGETING::TargetService::CHILD_BY_AFFINITY,
TARGETING::TargetService::ALL, &l_presentDimm);
for(uint32_t j=0; j < l_dimmList.size(); ++j)
{
//fetch each dimm
TARGETING::Target *l_pDimmTarget = l_dimmList[j];
uint32_t l_dimmfru = 0;
l_dimmfru = l_pDimmTarget->getAttr<TARGETING::ATTR_FRU_ID>();
uint8_t l_mcaDimm = 0;
TARGETING::ATTR_REL_POS_type l_dimmRelPos = 0;
if(l_pDimmTarget->
tryGetAttr<TARGETING::ATTR_REL_POS>(l_dimmRelPos))
{
l_mcaDimm = l_dimmRelPos%2; //2 DIMMs per MCA
l_dimmRelPos = 0;
if(!i_pTarget->
tryGetAttr<TARGETING::ATTR_REL_POS>(l_dimmRelPos))
{
HDAT_ERR("Attribute REL_POS in MCA is not "
"present");
}
}
else
{
HDAT_ERR("Attribute REL_POS in DIMM "
"is not present");
}
//Convert GB to MB
uint32_t l_dimmSizeInMB =
l_dimSizes[l_mcaPort][l_mcaDimm] * HDAT_MB_PER_GB;
uint32_t l_huid = TARGETING::get_huid(l_pDimmTarget);
bool foundArea = false;
for (std::list<hdatRamArea>::iterator l_area = o_areas.begin();
l_area != o_areas.end();
++l_area)
{
//we do not need to compare each dimm fru id with mca fru id
//to create ram area, by the below logic
//dimms with same fruid will fall into same ram area
//even if they have fru id same with mca
if (l_area->ivfruId == l_dimmfru)//this means soldered dimms
{
foundArea = true;
l_area->ivFunctional = (l_area)->ivFunctional ||
isFunctional(l_pDimmTarget);
(l_area)->ivFunctional = true;
(l_area)->ivSize += l_dimmSizeInMB;
break;
}
}
//Search in the list of RAM Areas if not
//present create a new ram area
if (!foundArea)
{
o_dimmNum++;
o_areas.push_back(hdatRamArea(l_huid,
isFunctional(l_pDimmTarget),
l_dimmSizeInMB,l_dimmfru));
}
o_areaSize += l_dimmSizeInMB;
o_areaFunctional = o_areaFunctional ||
isFunctional(l_pDimmTarget);
}
o_parentType = HDAT_MEM_PARENT_CEC_FRU;
if(l_err != NULL)
{
//break if error
break;
}
}
while(0);
return l_err;
}
/*******************************************************************************
* hdatGetMaxMemoryBlocks
*******************************************************************************/
errlHndl_t HdatMsVpd::hdatGetMaxMemoryBlocks(const TARGETING::Target *i_pTarget,
uint32_t &o_maxMemoryBlocks)
{
errlHndl_t l_err = NULL;
do
{
//One Memctrl connected to only one membuf in P8
o_maxMemoryBlocks = 1;
}
while(0);
return l_err;
}
} //namespace HDAT
|