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
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/occ_405/main.c $ */
/* */
/* OpenPOWER OnChipController Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2011,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 */
#include "ssx.h"
#include "ssx_io.h"
#include "ipc_api.h" //ipc base interfaces
#include "occhw_async.h" //async (GPE, OCB, etc) interfaces
#include "simics_stdio.h"
//#include "heartbeat.h"
#include <thread.h>
#include <sensor.h>
#include <threadSch.h>
#include <errl.h>
#include <apss.h>
#include <trac.h>
#include <occ_service_codes.h>
#include <occ_sys_config.h>
#include <timer.h>
#include <dcom.h>
#include <rtls.h>
#include <proc_data.h>
#include <centaur_data.h>
#include <dpss.h>
#include <state.h>
#include <amec_sys.h>
#include <cmdh_fsp.h>
#include <proc_pstate.h>
//#include <vrm.h>
#include <chom.h>
#include <homer.h>
#include <amec_health.h>
#include <amec_freq.h>
#include "scom.h"
//#include <fir_data_collect.h>
#include <pss_service_codes.h>
#include <dimm.h>
#include "occhw_shared_data.h"
#include <pgpe_shared.h>
#include <gpe_register_addresses.h>
#include <p9_pstates_occ.h>
#include <wof.h>
#include "pgpe_service_codes.h"
extern uint32_t __ssx_boot; // Function address is 32 bits
extern uint32_t G_occ_phantom_critical_count;
extern uint32_t G_occ_phantom_noncritical_count;
extern uint8_t G_occ_interrupt_type;
extern uint8_t G_occ_role;
extern pstateStatus G_proc_pstate_status;
extern GpeRequest G_meas_start_request;
extern GpeRequest G_meas_cont_request;
extern GpeRequest G_meas_complete_request;
extern apss_start_args_t G_gpe_start_pwr_meas_read_args;
extern apss_continue_args_t G_gpe_continue_pwr_meas_read_args;
extern apss_complete_args_t G_gpe_complete_pwr_meas_read_args;
extern uint32_t G_proc_fmin_khz;
extern uint32_t G_proc_fmax_khz;
extern wof_header_data_t G_wof_header;
extern uint32_t G_khz_per_pstate;
extern uint8_t G_proc_pmin;
extern uint8_t G_proc_pmax;
IMAGE_HEADER (G_mainAppImageHdr,__ssx_boot,MAIN_APP_ID,ID_NUM_INVALID);
ppmr_header_t G_ppmr_header; // PPMR Header layout format
pgpe_header_data_t G_pgpe_header; // Selected fields from PGPE Header
OCCPstateParmBlock G_oppb; // OCC Pstate Parameters Block Structure
extern uint16_t G_proc_fmax_mhz; // max(turbo,uturbo) frequencies
extern int G_ss_pgpe_rc;
// Set main thread timer for one second
#define MAIN_THRD_TIMER_SLICE ((SsxInterval) SSX_SECONDS(1))
// Size of "Reserved" section in OCC-PGPE shared SRAM
#define OCC_PGPE_SRAM_RESERVED_SZ 7
// Define location for data shared with GPEs
gpe_shared_data_t G_shared_gpe_data __attribute__ ((section (".gpe_shared")));
// SIMICS printf/printk
SimicsStdio G_simics_stdout;
SimicsStdio G_simics_stderr;
// Critical /non Critical Stacks
uint8_t G_noncritical_stack[NONCRITICAL_STACK_SIZE];
uint8_t G_critical_stack[CRITICAL_STACK_SIZE];
//NOTE: Three semaphores are used so that if in future it is decided
// to move health monitor and FFDC into it's own threads, then
// it can be done easily without more changes.
// Semaphores for the health monitor functions
SsxSemaphore G_hmonSem;
// Semaphores for the FFDC functions
SsxSemaphore G_ffdcSem;
// Timer for posting health monitor and FFDC semaphore
SsxTimer G_mainThrdTimer;
// Variable holding main thread loop count
uint32_t G_mainThreadLoopCounter = 0x0;
// Global flag indicating FIR collection is required
bool G_fir_collection_required = FALSE;
// Global flag indicating we are running on Simics
bool G_simics_environment = FALSE;
// Nest frequency in MHz
uint32_t G_nest_frequency_mhz;
extern uint8_t g_trac_inf_buffer[];
extern uint8_t g_trac_imp_buffer[];
extern uint8_t g_trac_err_buffer[];
void pmc_hw_error_isr(void *private, SsxIrqId irq, int priority);
void create_tlb_entry(uint32_t address, uint32_t size);
//Macro creates a 'bridge' handler that converts the initial fast-mode to full
//mode interrupt handler
SSX_IRQ_FAST2FULL(pmc_hw_error_fast, pmc_hw_error_isr);
/*
* Function Specification
*
* Name: check_runtime_environment
*
* Description: Determines whether we are running in Simics or on real HW.
*
* End Function Specification
*/
void check_runtime_environment(void)
{
uint64_t flags;
flags = in64(OCB_OCCFLG);
// NOTE: The lower 32 bits of this register have no latches on
// physical hardware and will return 0s, so we can use
// a backdoor hack in Simics to set bit 63, telling the
// firmware what environment it's running in.
G_simics_environment = ( 0 != (flags & 0x0000000000000001) ) ? TRUE : FALSE;
if (G_simics_environment)
{
// slow down RTL for Simics
G_mics_per_tick = SIMICS_MICS_PER_TICK;
G_dcom_tx_apss_wait_time = SIMICS_MICS_PER_TICK * 6 / 10;
// Same comment as above about lower 32-bits. Bit 62 can be toggled
// on or off (in Simics) to indicate for which APSS specification the
// model is configured.
G_shared_gpe_data.spipss_spec_p9 =
(0 != (flags & 0x0000000000000002) ) ? FALSE : TRUE;
}
else
{
G_shared_gpe_data.spipss_spec_p9 = 0;
}
}
/*
* Function Specification
*
* Name: pmc_hw_error_isr
*
* Description: Handles IRQ for PMCLFIR bit being set. Only bits that are
* unmasked (0x1010843) and have action0 (0x1010846) set to 1
* and action1 (0x1010847) set to 0 will cause this interupt
* (OISR0[9]) to fire. This runs in a non critical context
* (tracing allowed).
*
*
* End Function Specification
*/
void pmc_hw_error_isr(void *private, SsxIrqId irq, int priority)
{
// TODO: RTC 134619; enable Interrupt handlers for HW errors
// -- uncomment currently unused vars upon implementation
//errlHndl_t l_err;
//pmc_ffdc_data_t l_pmc_ffdc;
SsxMachineContext ctx;
// Mask this interrupt
ssx_irq_disable(irq);
// disable critical interrupts
ssx_critical_section_enter( SSX_NONCRITICAL, &ctx );
// clear this irq status in OISR0
ssx_irq_status_clear(irq);
// dump a bunch of FFDC registers
//fill_pmc_ffdc_buffer(&l_pmc_ffdc);
MAIN_TRAC_ERR("PMC Failure detected through OISR0[9]!!!");
/* @
* @moduleid PMC_HW_ERROR_ISR
* @reasonCode PMC_FAILURE
* @severity ERRL_SEV_PREDICTIVE
* @userdata1 0
* @userdata2 0
* @userdata4 OCC_NO_EXTENDED_RC
* @devdesc Failure detected in processor
* power management controller (PMC)
*/
/* TEMP NO MORE PMC - RTC 161456
l_err = createErrl( PMC_HW_ERROR_ISR, // i_modId,
PMC_FAILURE, // i_reasonCode,
OCC_NO_EXTENDED_RC,
ERRL_SEV_PREDICTIVE,
NULL, // tracDesc_t i_trace,
DEFAULT_TRACE_SIZE, // i_traceSz,
0, // i_userData1,
0); // i_userData2
//Add our register dump to the error log
addUsrDtlsToErrl(l_err,
(uint8_t*) &l_pmc_ffdc,
sizeof(l_pmc_ffdc),
ERRL_USR_DTL_STRUCT_VERSION_1,
ERRL_USR_DTL_BINARY_DATA);
//Add firmware callout
addCalloutToErrl(l_err,
ERRL_CALLOUT_TYPE_COMPONENT_ID,
ERRL_COMPONENT_ID_FIRMWARE,
ERRL_CALLOUT_PRIORITY_HIGH);
//Add processor callout
addCalloutToErrl(l_err,
ERRL_CALLOUT_TYPE_HUID,
G_sysConfigData.proc_huid,
ERRL_CALLOUT_PRIORITY_MED);
//Add planar callout
addCalloutToErrl(l_err,
ERRL_CALLOUT_TYPE_HUID,
G_sysConfigData.backplane_huid,
ERRL_CALLOUT_PRIORITY_LOW);
REQUEST_RESET(l_err);
*/
// Unmask this interrupt
ssx_irq_enable(irq);
// re-enable non-critical interrupts
ssx_critical_section_exit( &ctx );
}
/*
* Function Specification
*
* Name: occ_hw_error_isr
*
* Description: Handles IRQ for OCCLFIR bit being set. Only bits
* that are unmasked (0x1010803) and have action0 (0x1010806)
* set to 1 and action1 (0x1010807) set to 0 will cause this
* interupt (OISR0[2]) to fire. This runs in a critical
* context (no tracing!).
*
* End Function Specification
*/
//NOTE: use "putscom pu 6B111 0 3 101 -ib -p1" to inject the error.
#define OCC_LFIR_SPARE_BIT50 0x0000000000002000ull
void occ_hw_error_isr(void *private, SsxIrqId irq, int priority)
{
//set bit 50 of the OCC LFIR so that the PRDF component will log an error and callout the processor
//TMGT will also see a problem and log an error but it will be informational.
// TODO: Determine how to set this without a SCOM.
//Halt occ so that hardware will enter safe mode
OCC_HALT(ERRL_RC_OCC_HW_ERROR);
}
// Enable and register any ISR's that need to be set up as early as possible.
void occ_irq_setup()
{
int l_rc;
errlHndl_t l_err;
do
{
// ------------- OCC Error IRQ Setup ------------------
// Disable the IRQ while we work on it
ssx_irq_disable(OCCHW_IRQ_OCC_ERROR);
// Set up the IRQ
l_rc = ssx_irq_setup(OCCHW_IRQ_OCC_ERROR,
SSX_IRQ_POLARITY_ACTIVE_HIGH,
SSX_IRQ_TRIGGER_EDGE_SENSITIVE);
if(l_rc)
{
MAIN_TRAC_ERR("occ_irq_setup: ssx_irq_setup(OCCHW_IRQ_OCC_ERROR) failed with rc=0x%08x", l_rc);
break;
}
// Register the IRQ handler with SSX
l_rc = ssx_irq_handler_set(OCCHW_IRQ_OCC_ERROR,
occ_hw_error_isr,
NULL,
SSX_CRITICAL);
if(l_rc)
{
MAIN_TRAC_ERR("occ_irq_setup: ssx_irq_handler_set(OCCHW_IRQ_OCC_ERROR) failed with rc=0x%08x", l_rc);
break;
}
//enable the IRQ
ssx_irq_status_clear(OCCHW_IRQ_OCC_ERROR);
ssx_irq_enable(OCCHW_IRQ_OCC_ERROR);
// ------------- PMC Error IRQ Setup ------------------
/* TODO - RTC: 134619 -- IS THIS NO LONGER A THING IN P9??
// Disable the IRQ while we work on it
ssx_irq_disable(OCCHW_IRQ_PMC_ERROR);
// Set up the IRQ
l_rc = ssx_irq_setup(OCCHW_IRQ_PMC_ERROR,
SSX_IRQ_POLARITY_ACTIVE_HIGH,
SSX_IRQ_TRIGGER_EDGE_SENSITIVE);
if(l_rc)
{
MAIN_TRAC_ERR("occ_irq_setup: ssx_irq_setup(OCCHW_IRQ_PMC_ERROR) failed with rc=0x%08x", l_rc);
break;
}
// Register the IRQ handler with SSX
l_rc = ssx_irq_handler_set(OCCHW_IRQ_PMC_ERROR,
pmc_hw_error_fast,
NULL,
SSX_NONCRITICAL);
if(l_rc)
{
MAIN_TRAC_ERR("occ_irq_setup: ssx_irq_handler_set(OCCHW_IRQ_PMC_ERROR) failed with rc=0x%08x", l_rc);
break;
}
//enable the IRQ
ssx_irq_status_clear(OCCHW_IRQ_PMC_ERROR);
ssx_irq_enable(OCCHW_IRQ_PMC_ERROR);
END TODO */
}while(0);
if(l_rc)
{
//single error for all error cases, just look at trace to see where it failed.
/* @
* @moduleid OCC_IRQ_SETUP
* @reasonCode SSX_GENERIC_FAILURE
* @severity ERRL_SEV_UNRECOVERABLE
* @userdata1 SSX return code
* @userdata4 OCC_NO_EXTENDED_RC
* @devdesc Firmware failure initializing IRQ
*/
l_err = createErrl( OCC_IRQ_SETUP, // i_modId,
SSX_GENERIC_FAILURE, // i_reasonCode,
OCC_NO_EXTENDED_RC,
ERRL_SEV_UNRECOVERABLE,
NULL, // tracDesc_t i_trace,
DEFAULT_TRACE_SIZE, //Trace Size
l_rc, // i_userData1,
0); // i_userData2
//Callout firmware
addCalloutToErrl(l_err,
ERRL_CALLOUT_TYPE_COMPONENT_ID,
ERRL_COMPONENT_ID_FIRMWARE,
ERRL_CALLOUT_PRIORITY_HIGH);
commitErrl(&l_err);
}
}
/*
* Function Specification
*
* Name: create_tlb_entry
*
* Description: Creates a TLB entry in the 405 processor to access PGPE space.
* The TLB entry has read only access, and is cache-inhibited.
* This call takes care of pages alignment
* and adds additional pages in case the requested
* space crosses page boundaries.
*
* will result in panic if the TLB entry allocation
* fails.
*
* End Function Specification
*/
#define PAGE_SIZE PPC405_PAGE_SIZE_MIN
#define PAGE_ALIGNED_ADDRESS(addr) (addr & ~((uint32_t)(PAGE_SIZE-1)))
#define PAGE_ALIGNED_SIZE(sz) ((uint32_t)PAGE_SIZE*(((uint32_t)sz/PAGE_SIZE)+1))
void create_tlb_entry(uint32_t address, uint32_t size)
{
#if PPC405_MMU_SUPPORT
int l_rc = SSX_OK;
uint32_t tlb_entry_address, tlb_entry_size; // address and size that guarantee page alignment
tlb_entry_address = PAGE_ALIGNED_ADDRESS(address);
if ((address + (size%PPC405_PAGE_SIZE_MIN)) >=
(tlb_entry_address + PPC405_PAGE_SIZE_MIN))
{
tlb_entry_size = PAGE_ALIGNED_SIZE(size+PPC405_PAGE_SIZE_MIN);
}
else
{
tlb_entry_size = PAGE_ALIGNED_SIZE(size);
}
// define DTLB for page aligned address and size
l_rc = ppc405_mmu_map(tlb_entry_address,
tlb_entry_address,
tlb_entry_size,
0,
TLBLO_I, //Read-only, Cache-inhibited
NULL);
if(l_rc == SSX_OK)
{
MAIN_TRAC_IMP("Created TLB entry for Address[0x%08x]"
"TLB Page Address[0x%08x], TLB Entry size[0x%08x]",
address, tlb_entry_address, tlb_entry_size);
}
else
{
MAIN_TRAC_ERR("Failed to create TLB entry,"
"TLB Page Address[0x%08x], TLB Entry size[0x%08x], rc[0x%08x]",
tlb_entry_address, tlb_entry_size, l_rc);
/* @
* @errortype
* @moduleid CREATE_TLB_ENTRY
* @reasoncode SSX_GENERIC_FAILURE
* @userdata1 ppc405_mmu_map return code
* @userdata2 address for which a TLB entry is created
* @userdata4 ERC_TLB_ENTRY_CREATION_FAILURE
* @devdesc SSX semaphore related failure
*/
errlHndl_t l_err = createErrl(CREATE_TLB_ENTRY, //modId
SSX_GENERIC_FAILURE, //reasoncode
ERC_TLB_ENTRY_CREATION_FAILURE, //Extended reason code
ERRL_SEV_UNRECOVERABLE, //Severity
NULL, //Trace Buf
DEFAULT_TRACE_SIZE, //Trace Size
l_rc, //userdata1
address); //userdata2
REQUEST_RESET(l_err);
}
#endif
}
/*
* Function Specification
*
* Name: read_wof_header
*
* Description: Read WOF Tables header and populate global variables
* needed for WOF. Must be called after pgpe header is read.
*
* End Function Specification
*/
void read_wof_header(void)
{
int l_ssxrc = SSX_OK;
uint32_t l_reasonCode = 0;
uint32_t l_extReasonCode = OCC_NO_EXTENDED_RC;
uint32_t userdata1 = 0;
uint32_t userdata2 = 0;
// Skip reading wof header until WOF is enabled
// TODO RTC: 131186 - remove when WOF is up
g_amec->wof.wof_disabled |= WOF_RC_DRIVER_WOF_DISABLED;
if( g_amec->wof.wof_disabled )
{
MAIN_TRAC_INFO("WOF has not been enabled. Skipping read_wof_header");
return;
}
MAIN_TRAC_INFO("read_wof_header() 0x%08X", G_pgpe_header.wof_tables_addr);
// Read active quads address, wof tables address, and wof tables len
g_amec->wof.req_active_quads_addr = G_pgpe_header.requested_active_quad_sram_addr;
g_amec->wof.vfrt_tbls_main_mem_addr = G_pgpe_header.wof_tables_addr;
g_amec->wof.vfrt_tbls_len = G_pgpe_header.wof_tables_length;
g_amec->wof.pgpe_wof_state_addr = G_pgpe_header.wof_state_address;
// Read in quad state addresses here once
g_amec->wof.quad_state_0_addr = G_pgpe_header.actual_quad_status_sram_addr;
g_amec->wof.quad_state_1_addr = g_amec->wof.quad_state_0_addr +
sizeof(uint64_t); //skip quad state 0
if (G_pgpe_header.wof_tables_addr != 0 &&
G_pgpe_header.wof_tables_addr%128 == 0)
{
do
{
// use block copy engine to read WOF header
BceRequest l_wof_header_req;
// 128 byte aligned buffer to read the data
temp_bce_request_buffer_t l_temp_bce_buff = {{0}};
// Create request
l_ssxrc = bce_request_create(&l_wof_header_req, // block copy object
&G_pba_bcde_queue, // main to sram copy engine
G_pgpe_header.wof_tables_addr, // mainstore address
(uint32_t) &l_temp_bce_buff, // SRAM start address
MIN_BCE_REQ_SIZE, // size of copy
SSX_WAIT_FOREVER, // no timeout
NULL, // no call back
NULL, // no call back args
ASYNC_REQUEST_BLOCKING);// blocking request
if(l_ssxrc != SSX_OK)
{
MAIN_TRAC_ERR("read_wof_header: BCDE request create failure rc=[%08X]", -l_ssxrc);
/*
* @errortype
* @moduleid READ_WOF_HEADER
* @reasoncode SSX_GENERIC_FAILURE
* @userdata1 RC for BCE block-copy engine
* @userdata4 ERC_BCE_REQUEST_CREATE_FAILURE
* @devdesc Failed to create BCDE request
*/
l_reasonCode = SSX_GENERIC_FAILURE;
l_extReasonCode = ERC_BCE_REQUEST_CREATE_FAILURE;
userdata1 = -l_ssxrc;
break;
}
// Do the actual copy
l_ssxrc = bce_request_schedule(&l_wof_header_req);
if(l_ssxrc != SSX_OK)
{
MAIN_TRAC_ERR("read_wof_header: BCE request schedule failure rc=[%08X]", -l_ssxrc);
/*
* @errortype
* @moduleid READ_WOF_HEADER
* @reasoncode SSX_GENERIC_FAILURE
* @userdata1 RC for BCE block-copy engine
* @userdata4 ERC_BCE_REQUEST_SCHEDULE_FAILURE
* @devdesc Failed to read WOF data using BCDE
*/
l_reasonCode = SSX_GENERIC_FAILURE;
l_extReasonCode = ERC_BCE_REQUEST_SCHEDULE_FAILURE;
userdata1 = -l_ssxrc;
break;
}
// Copy the data into Global WOF header struct
memcpy(&G_wof_header,
l_temp_bce_buff.data,
sizeof(wof_header_data_t));
// verify the validity of the magic number
uint32_t magic_number = in32(G_pgpe_header.wof_tables_addr);
MAIN_TRAC_INFO("read_wof_header() Magic No: 0x%08X", magic_number);
if(WOF_MAGIC_NUMBER == magic_number)
{
// Make sure the header is reporting a valid number of quads i.e. 1 or 6
if( (G_wof_header.active_quads_size != ACTIVE_QUAD_SZ_MIN) &&
(G_wof_header.active_quads_size != ACTIVE_QUAD_SZ_MAX) )
{
MAIN_TRAC_ERR("read_wof_header: Invalid number of active quads!"
" Expected: 1 or 6, Actual %d, WOF disabled",
G_wof_header.active_quads_size );
/*
* @errortype
* @moduleid READ_WOF_HEADER
* @reasoncode INVALID_ACTIVE_QUAD_COUNT
* @userdata1 Reported active quad count
* @userdata4 ERC_WOF_QUAD_COUNT_FAILURE
* @devdesc Read an invalid number of active quads
*/
l_reasonCode = INVALID_ACTIVE_QUAD_COUNT;
l_extReasonCode = ERC_WOF_QUAD_COUNT_FAILURE;
userdata1 = G_wof_header.active_quads_size;
break;
}
}
else
{
MAIN_TRAC_ERR("read_wof_header: Invalid WOF Magic number. Address[0x%08X], Magic Number[0x%08X], WOF disabled",
G_pgpe_header.wof_tables_addr, magic_number);
/* @
* @errortype
* @moduleid READ_WOF_HEADER
* @reasoncode INVALID_MAGIC_NUMBER
* @userdata1 WOF header sram address
* @userdata2 read WOF magic number
* @userdata4 OCC_NO_EXTENDED_RC
* @devdesc Invalid WOF magic number, WOF disabled
*/
l_reasonCode = INVALID_MAGIC_NUMBER;
userdata1 = G_pgpe_header.wof_tables_addr;
userdata2 = magic_number;
break;
}
// Make wof header data visible to amester
g_amec->wof.version = G_wof_header.version;
g_amec->wof.vfrt_block_size = G_wof_header.vfrt_block_size;
g_amec->wof.vfrt_blck_hdr_sz = G_wof_header.vfrt_blck_hdr_sz;
g_amec->wof.vfrt_data_size = G_wof_header.vfrt_data_size;
g_amec->wof.active_quads_size = G_wof_header.active_quads_size;
g_amec->wof.core_count = G_wof_header.core_count;
g_amec->wof.vdn_start = G_wof_header.vdn_start;
g_amec->wof.vdn_step = G_wof_header.vdn_step;
g_amec->wof.vdn_size = G_wof_header.vdn_size;
g_amec->wof.vdd_start = G_wof_header.vdd_start;
g_amec->wof.vdd_step = G_wof_header.vdd_step;
g_amec->wof.vdd_size = G_wof_header.vdd_size;
g_amec->wof.vratio_start = G_wof_header.vratio_start;
g_amec->wof.vratio_step = G_wof_header.vratio_step;
g_amec->wof.vratio_size = G_wof_header.vratio_size;
g_amec->wof.fratio_start = G_wof_header.fratio_start;
g_amec->wof.fratio_step = G_wof_header.fratio_step;
g_amec->wof.fratio_size = G_wof_header.fratio_size;
memcpy(g_amec->wof.vdn_percent, G_wof_header.vdn_percent, 16);
g_amec->wof.socket_power_w = G_wof_header.socket_power_w;
g_amec->wof.nest_freq_mhz = G_wof_header.nest_freq_mhz;
g_amec->wof.nom_freq_mhz = G_wof_header.nom_freq_mhz;
g_amec->wof.rdp_capacity = G_wof_header.rdp_capacity;
g_amec->wof.wof_tbls_src_tag = G_wof_header.wof_tbls_src_tag;
g_amec->wof.package_name_hi = G_wof_header.package_name_hi;
g_amec->wof.package_name_lo = G_wof_header.package_name_lo;
// Initialize wof init state to zero
g_amec->wof.wof_init_state = WOF_DISABLED;
}while( 0 );
// Check for errors and log, if any
if (l_reasonCode)
{
errlHndl_t l_errl = createErrl(READ_WOF_HEADER, //modId
l_reasonCode, //reasoncode
l_extReasonCode, //Extended reason code
ERRL_SEV_UNRECOVERABLE, //Severity
NULL, //Trace Buf
DEFAULT_TRACE_SIZE, //Trace Size
userdata1, //userdata1
userdata2); //userdata2
// Callout firmware
addCalloutToErrl(l_errl,
ERRL_CALLOUT_TYPE_COMPONENT_ID,
ERRL_COMPONENT_ID_FIRMWARE,
ERRL_CALLOUT_PRIORITY_HIGH);
// Commit error log
commitErrl(&l_errl);
// We were unable to get the WOF header thus it should not be run.
g_amec->wof.wof_disabled |= WOF_RC_NO_WOF_HEADER_MASK;
}
}
else
{
// We were unable to get the WOF header thus it should not be run.
MAIN_TRAC_INFO("read_wof_header(): WOF header address is 0 or NOT"
" 128-byte aligned, WOF is disabled");
g_amec->wof.wof_disabled |= WOF_RC_NO_WOF_HEADER_MASK;
}
} // end read_wof_header()
/*
* Function Specification
*
* Name: read_pgpe_header
*
* Description: Initialize PGPE image header entry in DTLB,
* Read PGPE image header, lookup shared SRAM address and size,
* Initialize OCC/PGPE shared SRAM entry in the DTLB,
* Populate global variables, including G_pgpe_peacon_address.
*
* Returns: TRUE if read was successful, else FALSE
*
* End Function Specification
*/
bool read_pgpe_header(void)
{
uint32_t l_reasonCode = 0;
uint32_t l_extReasonCode = OCC_NO_EXTENDED_RC;
uint32_t userdata1 = 0;
uint32_t userdata2 = 0;
uint64_t magic_number = 0;
MAIN_TRAC_INFO("read_pgpe_header(0x%08X)", PGPE_HEADER_ADDR);
do
{
// verify the validity of the magic number
magic_number = in64(PGPE_HEADER_ADDR);
if (PGPE_MAGIC_NUMBER_10 == magic_number)
{
G_pgpe_header.shared_sram_addr = in32(PGPE_HEADER_ADDR + PGPE_SHARED_SRAM_ADDR_OFFSET);
G_pgpe_header.shared_sram_length = in32(PGPE_HEADER_ADDR + PGPE_SHARED_SRAM_LEN_OFFSET);
G_pgpe_header.occ_pstate_table_sram_addr = in32(PGPE_HEADER_ADDR + PGPE_OCC_PSTATE_TBL_ADDR_OFFSET);
G_pgpe_header.occ_pstate_table_length = in32(PGPE_HEADER_ADDR + PGPE_OCC_PSTATE_TBL_SZ_OFFSET);
G_pgpe_header.beacon_sram_addr = in32(PGPE_HEADER_ADDR + PGPE_BEACON_ADDR_OFFSET);
G_pgpe_header.actual_quad_status_sram_addr = in32(PGPE_HEADER_ADDR + PGPE_ACTUAL_QUAD_STATUS_ADDR_OFFSET);
G_pgpe_header.wof_state_address = in32(PGPE_HEADER_ADDR + PGPE_WOF_STATE_ADDR_OFFSET);
G_pgpe_header.requested_active_quad_sram_addr = in32(PGPE_HEADER_ADDR + PGPE_REQUESTED_ACTIVE_QUAD_ADDR_OFFSET);
G_pgpe_header.wof_tables_addr = in32(PGPE_HEADER_ADDR + PGPE_WOF_TBLS_ADDR_OFFSET);
G_pgpe_header.wof_tables_length = in32(PGPE_HEADER_ADDR + PGPE_WOF_TBLS_LEN_OFFSET);
MAIN_TRAC_IMP("Shared SRAM Address[0x%08x], PGPE Beacon Address[0x%08x]",
G_pgpe_header.shared_sram_addr, G_pgpe_header.beacon_sram_addr);
MAIN_TRAC_IMP("WOF Tables Main Memory Address[0x%08x], Len[0x%08x], "
"Req Active Quads Address[0x%08x]",
G_pgpe_header.wof_tables_addr,
G_pgpe_header.wof_tables_length,
G_pgpe_header.requested_active_quad_sram_addr);
if ((G_pgpe_header.beacon_sram_addr == 0) ||
(G_pgpe_header.shared_sram_addr == 0))
{
/*
* @errortype
* @moduleid READ_PGPE_HEADER
* @reasoncode SSX_GENERIC_FAILURE
* @userdata1 lower word of beacon sram address
* @userdata2 lower word of shared sram address
* @userdata4 ERC_PGPE_INVALID_ADDRESS
* @devdesc Invalid sram addresses from PGPE header
*/
l_reasonCode = SSX_GENERIC_FAILURE;
l_extReasonCode = ERC_PGPE_INVALID_ADDRESS;
userdata1 = WORD_LOW(G_pgpe_header.beacon_sram_addr);
userdata2 = WORD_LOW(G_pgpe_header.shared_sram_addr);
break;
}
}
else
{
// The Magic number is invalid .. Invalid or corrupt PGPE image header
MAIN_TRAC_ERR("read_pgpe_header: Invalid PGPE Magic number. Address[0x%08X], Magic Number[0x%08X%08X]",
PGPE_HEADER_ADDR, WORD_HIGH(magic_number), WORD_LOW(magic_number));
/* @
* @errortype
* @moduleid READ_PGPE_HEADER
* @reasoncode INVALID_MAGIC_NUMBER
* @userdata1 High order 32 bits of retrieved PGPE magic number
* @userdata2 Low order 32 bits of retrieved PGPE magic number
* @userdata4 OCC_NO_EXTENDED_RC
* @devdesc Invalid magic number in PGPE header
*/
l_reasonCode = INVALID_MAGIC_NUMBER;
userdata1 = WORD_HIGH(magic_number);
userdata2 = WORD_LOW(magic_number);
break;
}
} while (0);
if ( l_reasonCode )
{
errlHndl_t l_errl = createErrl(READ_PGPE_HEADER, //modId
l_reasonCode, //reasoncode
l_extReasonCode, //Extended reason code
ERRL_SEV_UNRECOVERABLE, //Severity
NULL, //Trace Buf
DEFAULT_TRACE_SIZE, //Trace Size
userdata1, //userdata1
userdata2); //userdata2
// Callout firmware
addCalloutToErrl(l_errl,
ERRL_CALLOUT_TYPE_COMPONENT_ID,
ERRL_COMPONENT_ID_FIRMWARE,
ERRL_CALLOUT_PRIORITY_HIGH);
REQUEST_RESET(l_errl);
return FALSE;
}
// Success
return TRUE;
} // end read_pgpe_header()
/*
* Function Specification
*
* Name: read_ppmr_header
*
* Description: read PPMR image header and validate magic number
*
* Returns: TRUE if read was successful, else FALSE
*
* End Function Specification
*/
bool read_ppmr_header(void)
{
int l_ssxrc = SSX_OK;
uint32_t l_reasonCode = 0;
uint32_t l_extReasonCode = OCC_NO_EXTENDED_RC;
uint32_t userdata1 = 0;
uint32_t userdata2 = 0;
MAIN_TRAC_INFO("read_ppmr_header(0x%08X)", PPMR_ADDRESS_HOMER);
// create a DTLB entry for the PPMR image header
create_tlb_entry(PPMR_ADDRESS_HOMER, sizeof(ppmr_header_t));
do{
// use block copy engine to read the PPMR header
BceRequest pba_copy;
// Set up a copy request
l_ssxrc = bce_request_create(&pba_copy, // block copy object
&G_pba_bcde_queue, // mainstore to sram copy engine
PPMR_ADDRESS_HOMER, // mainstore address
(uint32_t) &G_ppmr_header, // sram starting address
(size_t) sizeof(G_ppmr_header), // size of copy
SSX_WAIT_FOREVER, // no timeout
NULL, // no call back
NULL, // no call back arguments
ASYNC_REQUEST_BLOCKING); // blocking request
if(l_ssxrc != SSX_OK)
{
MAIN_TRAC_ERR("read_ppmr_header: BCDE request create failure rc=[%08X]", -l_ssxrc);
/*
* @errortype
* @moduleid READ_PPMR_HEADER
* @reasoncode SSX_GENERIC_FAILURE
* @userdata1 RC for BCE block-copy engine
* @userdata2 Internal function checkpoint
* @userdata4 ERC_BCE_REQUEST_CREATE_FAILURE
* @devdesc Failed to create BCDE request
*/
l_reasonCode = SSX_GENERIC_FAILURE;
l_extReasonCode = ERC_BCE_REQUEST_CREATE_FAILURE;
userdata1 = (uint32_t)(-l_ssxrc);
break;
}
// Do actual copying
l_ssxrc = bce_request_schedule(&pba_copy);
if(l_ssxrc != SSX_OK)
{
MAIN_TRAC_ERR("read_ppmr_header: BCE request schedule failure rc=[%08X]", -l_ssxrc);
/*
* @errortype
* @moduleid READ_PPMR_HEADER
* @reasoncode SSX_GENERIC_FAILURE
* @userdata1 RC for BCE block-copy engine
* @userdata4 ERC_BCE_REQUEST_SCHEDULE_FAILURE
* @devdesc Failed to read PPMR data by using BCDE
*/
l_reasonCode = SSX_GENERIC_FAILURE;
l_extReasonCode = ERC_BCE_REQUEST_SCHEDULE_FAILURE;
userdata1 = (uint32_t)(-l_ssxrc);
break;
}
if (PPMR_MAGIC_NUMBER_10 != G_ppmr_header.magic_number)
{
MAIN_TRAC_ERR("read_ppmr_header: Invalid PPMR Magic number: 0x%08X%08X",
WORD_HIGH(G_ppmr_header.magic_number), WORD_LOW(G_ppmr_header.magic_number));
/* @
* @errortype
* @moduleid READ_PPMR_HEADER
* @reasoncode INVALID_MAGIC_NUMBER
* @userdata1 High order 32 bits of retrieved PPMR magic number
* @userdata2 Low order 32 bits of retrieved PPMR magic number
* @userdata4 OCC_NO_EXTENDED_RC
* @devdesc Invalid magic number in PPMR header
*/
l_reasonCode = INVALID_MAGIC_NUMBER;
userdata1 = WORD_HIGH(G_ppmr_header.magic_number);
userdata2 = WORD_LOW(G_ppmr_header.magic_number);
break;
}
} while (0);
if ( l_reasonCode )
{
errlHndl_t l_errl = createErrl(READ_PPMR_HEADER, //modId
l_reasonCode, //reasoncode
l_extReasonCode, //Extended reason code
ERRL_SEV_UNRECOVERABLE, //Severity
NULL, //Trace Buf
DEFAULT_TRACE_SIZE, //Trace Size
userdata1, //userdata1
userdata2); //userdata2
// Callout firmware
addCalloutToErrl(l_errl,
ERRL_CALLOUT_TYPE_COMPONENT_ID,
ERRL_COMPONENT_ID_FIRMWARE,
ERRL_CALLOUT_PRIORITY_HIGH);
REQUEST_RESET(l_errl);
return FALSE;
}
// Success
return TRUE;
}
/*
* Function Specification
*
* Name: read_oppb_params
*
* Description: Read the OCC Pstates Parameter Block,
* and initializa Pstates Global Variables.
*
* Returns: TRUE if read was successful, else FALSE
*
* End Function Specification
*/
bool read_oppb_params()
{
int l_ssxrc = SSX_OK;
uint32_t l_reasonCode = 0;
uint32_t l_extReasonCode = OCC_NO_EXTENDED_RC;
uint32_t userdata1 = 0;
uint32_t userdata2 = 0;
const uint32_t oppb_address = PPMR_ADDRESS_HOMER + G_ppmr_header.oppb_offset;
MAIN_TRAC_INFO("read_oppb_params(0x%08X)", oppb_address);
create_tlb_entry(oppb_address, sizeof(OCCPstateParmBlock));
do{
// use block copy engine to read the OPPB header
BceRequest pba_copy;
// Set up a copy request
l_ssxrc = bce_request_create(&pba_copy, // block copy object
&G_pba_bcde_queue, // mainstore to sram copy engine
oppb_address, // mainstore address
(uint32_t) &G_oppb, // sram starting address
(size_t) sizeof(OCCPstateParmBlock), // size of copy
SSX_WAIT_FOREVER, // no timeout
NULL, // no call back
NULL, // no call back arguments
ASYNC_REQUEST_BLOCKING); // blocking request
if(l_ssxrc != SSX_OK)
{
MAIN_TRAC_ERR("read_oppb_params: BCDE request create failure rc=[%08X]", -l_ssxrc);
/*
* @errortype
* @moduleid READ_OPPB_PARAMS
* @reasoncode SSX_GENERIC_FAILURE
* @userdata1 RC for BCE block-copy engine
* @userdata4 ERC_BCE_REQUEST_CREATE_FAILURE
* @devdesc Failed to create BCDE request
*/
l_reasonCode = SSX_GENERIC_FAILURE;
l_extReasonCode = ERC_BCE_REQUEST_CREATE_FAILURE;
userdata1 = (uint32_t)(-l_ssxrc);
break;
}
// Do actual copying
l_ssxrc = bce_request_schedule(&pba_copy);
if(l_ssxrc != SSX_OK)
{
MAIN_TRAC_ERR("read_oppb_params: BCE request schedule failure rc=[%08X]", -l_ssxrc);
/*
* @errortype
* @moduleid READ_OPPB_PARAMS
* @reasoncode SSX_GENERIC_FAILURE
* @userdata1 RC for BCE block-copy engine
* @userdata4 ERC_BCE_REQUEST_SCHEDULE_FAILURE
* @devdesc Failed to read OPPB data by using BCDE
*/
l_reasonCode = SSX_GENERIC_FAILURE;
l_extReasonCode = ERC_BCE_REQUEST_SCHEDULE_FAILURE;
userdata1 = (uint32_t)(-l_ssxrc);
break;
}
if (OPPB_MAGIC_NUMBER_10 != G_oppb.magic)
{
// The magic number is invalid .. Invalid or corrupt OPPB image header
MAIN_TRAC_ERR("read_oppb_header: Invalid OPPB magic number: 0x%08X%08X",
WORD_HIGH(G_oppb.magic), WORD_LOW(G_oppb.magic));
/* @
* @errortype
* @moduleid READ_OPPB_PARAMS
* @reasoncode INVALID_MAGIC_NUMBER
* @userdata1 High order 32 bits of retrieved OPPB magic number
* @userdata2 Low order 32 bits of retrieved OPPB magic number
* @userdata4 OCC_NO_EXTENDED_RC
* @devdesc Invalid magic number in OPPB header
*/
l_reasonCode = INVALID_MAGIC_NUMBER;
userdata1 = WORD_HIGH(G_oppb.magic);
userdata2 = WORD_LOW(G_oppb.magic);
break;
}
// Validate frequencies
// frequency_min_khz frequency_max_khz frequency_step_khz pstate_min
if ((G_oppb.frequency_min_khz == 0) || (G_oppb.frequency_max_khz == 0) ||
(G_oppb.frequency_step_khz == 0) || (G_oppb.pstate_min == 0) ||
(G_oppb.frequency_min_khz > G_oppb.frequency_max_khz))
{
// The magic number is invalid .. Invalid or corrupt OPPB image header
MAIN_TRAC_ERR("read_oppb_header: Invalid frequency data: min[%d], max[%d], step[%d], pmin[%d] kHz",
G_oppb.frequency_min_khz, G_oppb.frequency_max_khz,
G_oppb.frequency_step_khz, G_oppb.pstate_min);
/* @
* @errortype
* @moduleid READ_OPPB_PARAMS
* @reasoncode INVALID_FREQUENCY
* @userdata1 min / max frequency (MHz)
* @userdata2 step freq (MHz) / pstate min
* @userdata4 OCC_NO_EXTENDED_RC
* @devdesc Invalid frequency in OPPB header
*/
l_reasonCode = INVALID_FREQUENCY;
userdata1 = ((G_oppb.frequency_min_khz/1000) << 16) | (G_oppb.frequency_max_khz/1000);
userdata2 = ((G_oppb.frequency_step_khz/1000) << 16) | G_oppb.pstate_min;
break;
}
} while (0);
if (l_reasonCode)
{
errlHndl_t l_errl = createErrl(READ_OPPB_PARAMS, //modId
l_reasonCode, //reasoncode
l_extReasonCode, //Extended reason code
ERRL_SEV_UNRECOVERABLE, //Severity
NULL, //Trace Buf
DEFAULT_TRACE_SIZE, //Trace Size
userdata1, //userdata1
userdata2); //userdata2
// Callout firmware
addCalloutToErrl(l_errl,
ERRL_CALLOUT_TYPE_COMPONENT_ID,
ERRL_COMPONENT_ID_FIRMWARE,
ERRL_CALLOUT_PRIORITY_HIGH);
REQUEST_RESET(l_errl);
return FALSE;
}
// Copy over max frequency into G_proc_fmax_mhz
G_proc_fmax_mhz = G_oppb.frequency_max_khz / 1000;
// Used by amec for pcap calculation could use G_oppb.frequency_step_khz
// in PCAP calculationsinstead, but using a separate varaible speeds
// up PCAP relatedcalculations significantly, by eliminating slow
// division operations.
G_mhz_per_pstate = G_oppb.frequency_step_khz/1000;
TRAC_INFO("read_oppb_params: OCC Pstates Parameter Block read successfully");
// Success
return TRUE;
}
/*
* Function Specification
*
* Name: read_hcode_headers
*
* Description: Read and save hcode header data
*
* End Function Specification
*/
void read_hcode_headers()
{
do
{
CHECKPOINT(READ_HCODE_HEADERS);
if (read_ppmr_header() == FALSE) break;
CHECKPOINT(PPMR_IMAGE_HEADER_READ);
// Read OCC pstates parameter block
if (read_oppb_params() == FALSE) break;
CHECKPOINT(OPPB_IMAGE_HEADER_READ);
// Read PGPE header file, extract OCC/PGPE Shared SRAM address and size,
if (read_pgpe_header() == FALSE) break;
CHECKPOINT(PGPE_IMAGE_HEADER_READ);
// Extract important WOF data into global space
read_wof_header();
CHECKPOINT(WOF_IMAGE_HEADER_READ);
// PGPE Beacon is not implemented in simics
if (!G_simics_environment)
{
// define DTLB for OCC/PGPE shared SRAM, which enables access
// to OCC-PGPE Shared SRAM space, including pgpe_beacon
create_tlb_entry(G_pgpe_header.shared_sram_addr, G_pgpe_header.shared_sram_length);
}
} while(0);
}
/*
* Function Specification
*
* Name: gpe_reset
*
* Description: Force a GPE to start executing instructions at the reset vector
*
* End Function Specification
*/
void gpe_reset(uint32_t instance_id)
{
#define XCR_CMD_HRESET 0x60000000
#define XCR_CMD_TOGGLE_XSR 0x40000000
#define XCR_CMD_RESUME 0x20000000
#define GPE_SRAM_BASE 0xFFF00000
uint32_t l_gpe_sram_addr = (instance_id * 0x10000) + GPE_SRAM_BASE;
// GPE0 is at 0xFFF01000
// GPE1 is at 0xFFF10000
// GPE2 is at 0xFFF20000
// GPE3 is at 0xFFF30000
if(0 == instance_id)
{
l_gpe_sram_addr += 0x1000;
}
out32(GPE_GPENIVPR(instance_id), l_gpe_sram_addr);
out32(GPE_GPENXIXCR(instance_id), XCR_CMD_HRESET);
out32(GPE_GPENXIXCR(instance_id), XCR_CMD_TOGGLE_XSR);
out32(GPE_GPENXIXCR(instance_id), XCR_CMD_TOGGLE_XSR);
out32(GPE_GPENXIXCR(instance_id), XCR_CMD_RESUME);
}
/*
* Function Specification
*
* Name: occ_ipc_setup
*
* Description: Initialzes IPC (Inter Process Communication) that is used
* to communicate with GPEs.
* This will also start GPE0 and GPE1.
* NOTE: SGPE and PGPE are started prior to the OCC 405 during the IPL.
*
* End Function Specification
*/
void occ_ipc_setup()
{
int l_rc;
errlHndl_t l_err;
do
{
// install our IPC interrupt handler (this disables our cbufs)
l_rc = ipc_init();
if(l_rc)
{
MAIN_TRAC_ERR("ipc_init failed with rc=0x%08x", l_rc);
break;
}
// enable IPC's
l_rc = ipc_enable();
if(l_rc)
{
MAIN_TRAC_ERR("ipc_enable failed with rc = 0x%08x", l_rc);
break;
}
MAIN_TRAC_INFO("Calling IPC disable on all GPE's");
// disable all of the GPE cbufs. They will enable them once
// they are ready to communicate.
ipc_disable(OCCHW_INST_ID_GPE0);
ipc_disable(OCCHW_INST_ID_GPE1);
MAIN_TRAC_INFO("IPC initialization completed");
// start GPE's 0 and 1
MAIN_TRAC_INFO("Starting GPE0");
gpe_reset(OCCHW_INST_ID_GPE0);
MAIN_TRAC_INFO("Starting GPE1");
gpe_reset(OCCHW_INST_ID_GPE1);
MAIN_TRAC_INFO("GPE's taken out of reset");
}while(0);
if(l_rc)
{
// Log single error for all error cases, just look at trace to see where it failed.
/* @
* @moduleid OCC_IPC_SETUP
* @reasonCode IPC_GENERIC_FAILURE
* @severity ERRL_SEV_UNRECOVERABLE
* @userdata1 IPC return code
* @userdata4 OCC_NO_EXTENDED_RC
* @devdesc Firmware failure initializing IPC
*/
l_err = createErrl( OCC_IRQ_SETUP, // i_modId,
SSX_GENERIC_FAILURE, // i_reasonCode,
OCC_NO_EXTENDED_RC,
ERRL_SEV_UNRECOVERABLE,
NULL, // tracDesc_t i_trace,
DEFAULT_TRACE_SIZE, //Trace Size
l_rc, // i_userData1,
0); // i_userData2
//Callout firmware
addCalloutToErrl(l_err,
ERRL_CALLOUT_TYPE_COMPONENT_ID,
ERRL_COMPONENT_ID_FIRMWARE,
ERRL_CALLOUT_PRIORITY_HIGH);
commitErrl(&l_err);
}
}
/*
* Function Specification
*
* Name: hmon_routine
*
* Description: Runs various routines that check the health of the OCC
*
* End Function Specification
*/
void hmon_routine()
{
static uint32_t L_critical_phantom_count = 0;
static uint32_t L_noncritical_phantom_count = 0;
static bool L_c_phantom_logged = FALSE;
static bool L_nc_phantom_logged = FALSE;
bool l_log_phantom_error = FALSE;
//use MAIN debug traces
MAIN_DBG("HMON routine processing...");
//Check if we've had any phantom interrupts
if(L_critical_phantom_count != G_occ_phantom_critical_count)
{
L_critical_phantom_count = G_occ_phantom_critical_count;
MAIN_TRAC_INFO("hmon_routine: critical phantom irq occurred! count[%d]", L_critical_phantom_count);
//log a critical phantom error once
if(!L_c_phantom_logged)
{
L_c_phantom_logged = TRUE;
l_log_phantom_error = TRUE;
}
}
if(L_noncritical_phantom_count != G_occ_phantom_noncritical_count)
{
L_noncritical_phantom_count = G_occ_phantom_noncritical_count;
MAIN_TRAC_INFO("hmon_routine: non-critical phantom irq occurred! count[%d]", L_noncritical_phantom_count);
//log a non-critical phantom error once
if(!L_nc_phantom_logged)
{
L_nc_phantom_logged = TRUE;
l_log_phantom_error = TRUE;
}
}
if(l_log_phantom_error)
{
/* @
* @errortype
* @moduleid HMON_ROUTINE_MID
* @reasoncode INTERNAL_FAILURE
* @userdata1 critical count
* @userdata2 non-critical count
* @userdata4 OCC_NO_EXTENDED_RC
* @devdesc interrupt with unknown source was detected
*/
errlHndl_t l_err = createErrl(HMON_ROUTINE_MID, //modId
INTERNAL_FAILURE, //reasoncode
OCC_NO_EXTENDED_RC, //Extended reason code
ERRL_SEV_INFORMATIONAL, //Severity
NULL, //Trace Buf
DEFAULT_TRACE_SIZE, //Trace Size
L_critical_phantom_count, //userdata1
L_noncritical_phantom_count); //userdata2
// Commit Error
commitErrl(&l_err);
}
//if we are in observation, characterization, or activate state, then monitor the processor
//temperature for timeout conditions and the processor VRHOT signal.
if (IS_OCC_STATE_OBSERVATION() || IS_OCC_STATE_ACTIVE() || IS_OCC_STATE_CHARACTERIZATION())
{
amec_health_check_proc_timeout();
}
//if we are in observation, characterization, or active state with memory temperature data
// being collected then monitor the temperature collections for overtemp and timeout conditions
if((IS_OCC_STATE_OBSERVATION() || IS_OCC_STATE_ACTIVE() || IS_OCC_STATE_CHARACTERIZATION()) &&
rtl_task_is_runnable(TASK_ID_DIMM_SM))
{
// For Cumulus systems only, check for centaur timeout and overtemp errors
if (MEM_TYPE_CUMULUS == G_sysConfigData.mem_type)
{
amec_health_check_cent_timeout();
amec_health_check_cent_temp();
}
// For both Nimbus and Cumulus systems, check for rdimm-modules/centaur-dimm
// timeout and overtemp
amec_health_check_dimm_timeout();
amec_health_check_dimm_temp();
}
}
/*
* Function Specification
*
* Name: master_occ_init
*
* Description: Master OCC specific initialization.
*
* End Function Specification
*/
void master_occ_init()
{
errlHndl_t l_err = NULL;
l_err = initialize_apss();
if( (NULL != l_err))
{
MAIN_TRAC_ERR("master_occ_init: Error initializing APSS");
// commit & delete. CommitErrl handles NULL error log handle
REQUEST_RESET(l_err);
}
// Reinitialize the PBAX Queues
dcom_initialize_pbax_queues();
}
/*
* Function Specification
*
* Name: slave_occ_init
*
* Description: Slave OCC specific initialization.
*
* End Function Specification
*/
void slave_occ_init()
{
// Init the DPSS oversubscription IRQ handler
MAIN_DBG("Initializing Oversubscription IRQ...");
errlHndl_t l_errl = dpss_oversubscription_irq_initialize();
if( l_errl )
{
// Trace and commit error
MAIN_TRAC_ERR("Initialization of Oversubscription IRQ handler failed");
// commit log
commitErrl( &l_errl );
}
else
{
MAIN_TRAC_INFO("Oversubscription IRQ initialized");
}
//Set up doorbell queues
dcom_initialize_pbax_queues();
// Run AMEC Slave Init Code
amec_slave_init();
// Initialize SMGR State Semaphores
extern SsxSemaphore G_smgrModeChangeSem;
ssx_semaphore_create(&G_smgrModeChangeSem, 1, 1);
// Initialize SMGR Mode Semaphores
extern SsxSemaphore G_smgrStateChangeSem;
ssx_semaphore_create(&G_smgrStateChangeSem, 1, 1);
}
/*
* Function Specification
*
* Name: mainThrdTimerCallback
*
* Description: Main thread timer to post semaphores handled by main thread
*
* End Function Specification
*/
void mainThrdTimerCallback(void * i_argPtr)
{
int l_rc = SSX_OK;
do
{
// Post health monitor semaphore
l_rc = ssx_semaphore_post( &G_hmonSem );
if ( l_rc != SSX_OK )
{
MAIN_TRAC_ERR("Failure posting HlTH monitor semaphore: rc: 0x%x", l_rc);
break;
}
MAIN_DBG("posted hmonSem");
// Post FFDC semaphore
l_rc = ssx_semaphore_post( &G_ffdcSem );
if ( l_rc != SSX_OK )
{
MAIN_TRAC_ERR("Failure posting FFDC semaphore: rc: 0x%x", l_rc);
break;
}
MAIN_DBG("posted ffdcSem");
}while(FALSE);
// create error on failure posting semaphore
if( l_rc != SSX_OK)
{
/* @
* @errortype
* @moduleid MAIN_THRD_TIMER_MID
* @reasoncode SSX_GENERIC_FAILURE
* @userdata1 Create hmon and ffdc semaphore rc
* @userdata4 OCC_NO_EXTENDED_RC
* @devdesc SSX semaphore related failure
*/
errlHndl_t l_err = createErrl(MAIN_THRD_TIMER_MID, //modId
SSX_GENERIC_FAILURE, //reasoncode
OCC_NO_EXTENDED_RC, //Extended reason code
ERRL_SEV_UNRECOVERABLE, //Severity
NULL, //Trace Buf
DEFAULT_TRACE_SIZE, //Trace Size
l_rc, //userdata1
0); //userdata2
// Commit Error
REQUEST_RESET(l_err);
}
}
/*
* Function Specification
*
* Name: initMainThrdSemAndTimer
*
* Description: Helper function to create semaphores handled by main thread. It also
* creates and schedules timer used for posting main thread semaphores
*
*
* End Function Specification
*/
void initMainThrdSemAndTimer()
{
// create the health monitor Semaphore, starting at 0 with a max count of 0
// NOTE: Max count of 0 is used becuase there is possibility that
// semaphore can be posted more than once without any semaphore activity
int l_hmonSemRc = ssx_semaphore_create(&G_hmonSem, 0, 0);
// create FFDC Semaphore, starting at 0 with a max count of 0
// NOTE: Max count of 0 is used becuase there is possibility that
// semaphore can be posted more than once without any semaphore activity
int l_ffdcSemRc = ssx_semaphore_create(&G_ffdcSem, 0, 0);
//create main thread timer
int l_timerRc = ssx_timer_create(&G_mainThrdTimer,mainThrdTimerCallback,0);
//check for errors creating the timer
if(l_timerRc == SSX_OK)
{
//schedule the timer so that it runs every MAIN_THRD_TIMER_SLICE
l_timerRc = ssx_timer_schedule(&G_mainThrdTimer, // Timer
1, // time base
MAIN_THRD_TIMER_SLICE);// Timer period
}
else
{
MAIN_TRAC_ERR("Error creating main thread timer: RC: %d", l_timerRc);
}
// Failure creating semaphore or creating/scheduling timer, create
// and log error.
if (( l_hmonSemRc != SSX_OK ) ||
( l_ffdcSemRc != SSX_OK ) ||
( l_timerRc != SSX_OK))
{
MAIN_TRAC_ERR("Semaphore/timer create failure: "
"hmonSemRc: 0x08%x, ffdcSemRc: 0x%08x, l_timerRc: 0x%08x",
-l_hmonSemRc,-l_ffdcSemRc, l_timerRc );
/* @
* @errortype
* @moduleid MAIN_THRD_SEM_INIT_MID
* @reasoncode SSX_GENERIC_FAILURE
* @userdata1 Create health monitor semaphore rc
* @userdata2 Timer create/schedule rc
* @userdata4 OCC_NO_EXTENDED_RC
* @devdesc SSX semaphore related failure
*/
errlHndl_t l_err = createErrl(MAIN_THRD_SEM_INIT_MID, //modId
SSX_GENERIC_FAILURE, //reasoncode
OCC_NO_EXTENDED_RC, //Extended reason code
ERRL_SEV_UNRECOVERABLE, //Severity
NULL, //Trace Buf
DEFAULT_TRACE_SIZE, //Trace Size
l_hmonSemRc, //userdata1
l_timerRc); //userdata2
CHECKPOINT_FAIL_AND_HALT(l_err);
}
}
/*
* Function Specification
*
* Name: Main_thread_routine
*
* Description: Main thread handling OCC initialization and thernal, health
* monitor and FFDC function semaphores
*
* End Function Specification
*/
void Main_thread_routine(void *private)
{
CHECKPOINT(MAIN_THREAD_STARTED);
MAIN_TRAC_INFO("Main Thread Started ... " );
// NOTE: At present, we are not planning to use any config data from
// mainstore. OCC Role will be provided by FSP after FSP communication
// So instead of doing config_data_init, we will directly use
// dcom_initialize_roles. If in future design changes, we will make
// change to use config_data_init at that time.
// Default role initialization and determine OCC/Chip Id
dcom_initialize_roles();
CHECKPOINT(ROLES_INITIALIZED);
// Sensor Initialization
// All Master & Slave Sensor are initialized here, it is up to the
// rest of the firmware if it uses them or not.
sensor_init_all();
CHECKPOINT(SENSORS_INITIALIZED);
// SPIVID Initialization must be done before Pstates
// All SPIVID inits are done by Hostboot, remove this section.
//Initialize structures for collecting core data.
//It needs to run before RTLoop starts, as gpe request initialization
//needs to be done before task to collect core data starts.
proc_core_init();
CHECKPOINT(PROC_CORE_INITIALIZED);
// Initialize structures for collecting nest dts data.
// Needs to run before RTL to initialize the gpe request
nest_dts_init();
CHECKPOINT(NEST_DTS_INITIALIZED);
// Run slave OCC init on all OCCs. Master-only initialization will be
// done after determining actual role. By default all OCCs are slave.
slave_occ_init();
CHECKPOINT(SLAVE_OCC_INITIALIZED);
if (G_simics_environment)
{
extern pstateStatus G_proc_pstate_status;
// TEMP Hack to enable Active State, until PGPE is ready
G_proc_pstate_status = PSTATES_ENABLED;
// Temp hack to Set up Key Globals for use by proc_freq2pstate functions
//G_oppb.frequency_max_khz = 4322500;
//G_oppb.frequency_min_khz = 2028250;
G_oppb.frequency_max_khz = 2600000;
G_oppb.frequency_min_khz = 2000000;
G_oppb.frequency_step_khz = 16667;
G_oppb.pstate_min = PMAX +
((G_oppb.frequency_max_khz - G_oppb.frequency_min_khz)/G_oppb.frequency_step_khz);
G_proc_fmax_mhz = G_oppb.frequency_max_khz / 1000;
// Set globals used by amec for pcap calculation
// could have used G_oppb.frequency_step_khz in PCAP calculations
// instead, but using a separate varaible speeds up PCAP related
// calculations significantly, by eliminating division operations.
G_mhz_per_pstate = G_oppb.frequency_step_khz/1000;
TRAC_INFO("Main_thread_routine: Pstate Key globals initialized to default values");
}
else
{
// Read hcode headers (PPMR, OCC pstate parameter block, PGPE, WOF)
read_hcode_headers();
}
// Initialize watchdog timers. This needs to be right before
// start rtl to make sure timer doesn't timeout. This timer is being
// reset from the rtl task.
MAIN_TRAC_INFO("Initializing watchdog timers.");
initWatchdogTimers();
CHECKPOINT(WATCHDOG_INITIALIZED);
// Initialize Real time Loop Timer Interrupt
rtl_ocb_init();
CHECKPOINT(RTL_TIMER_INITIALIZED);
// Initialize semaphores and timer for handling health monitor and
// FFDC functions.
initMainThrdSemAndTimer();
CHECKPOINT(SEMS_AND_TIMERS_INITIALIZED);
//Initialize the thread scheduler.
//Other thread initialization is done here so that don't have to handle
// blocking commnad handler thread as FSP might start communicating
// through cmd handler thread in middle of the initialization.
initThreadScheduler();
int l_ssxrc = SSX_OK;
// initWatchdogTimers called before will start running the timer but
// the interrupt handler will just restart the timer until we use this
// enable switch to actually start the watchdog function.
// ENABLE_WDOG;
while (TRUE)
{
// Count each loop so the watchdog can tell the main thread is
// running.
G_mainThreadLoopCounter++;
// Flush the loop counter and trace buffers on each loop, this makes
// debug easier if the cmd interface doesn't respond
dcache_flush_line(&G_mainThreadLoopCounter);
dcache_flush(g_trac_inf_buffer, TRACE_BUFFER_SIZE);
dcache_flush(g_trac_imp_buffer, TRACE_BUFFER_SIZE);
dcache_flush(g_trac_err_buffer, TRACE_BUFFER_SIZE);
/* RTC 130203 -- FIR DATA IS NOT SUPPORTED IN PHASE1
static bool L_fir_collection_completed = FALSE;
// Look for FIR collection flag and status
if (G_fir_collection_required && !L_fir_collection_completed)
{
// If this OCC is the FIR master and PNOR access is allowed perform
// FIR collection
if (OCC_IS_FIR_MASTER() && pnor_access_allowed())
{
fir_data_collect();
L_fir_collection_completed = TRUE;
}
G_fir_collection_required = FALSE;
// Error reporting is skipped while FIR collection is required so we
// don't get reset in flight. If anyone is listening send the
// error alert now.
// If this system is using PSIHB complex, send an interrupt to Host so that
// Host can inform HTMGT to collect the error log
if (G_occ_interrupt_type == PSIHB_INTERRUPT)
{
notify_host(INTR_REASON_HTMGT_SERVICE_REQUIRED);
}
}
*/
if( l_ssxrc == SSX_OK)
{
// Wait for health monitor semaphore
l_ssxrc = ssx_semaphore_pend(&G_hmonSem,SSX_WAIT_FOREVER);
if( l_ssxrc != SSX_OK)
{
MAIN_TRAC_ERR("health monitor Semaphore pending failure RC[0x%08X]",
-l_ssxrc );
}
else
{
// call health monitor routine
hmon_routine();
}
}
if( l_ssxrc == SSX_OK)
{
// Wait for FFDC semaphore
l_ssxrc = ssx_semaphore_pend(&G_ffdcSem,SSX_WAIT_FOREVER);
if( l_ssxrc != SSX_OK)
{
MAIN_TRAC_ERR("FFDC Semaphore pending failure RC[0x%08X]",-l_ssxrc );
}
else
{
// Only Master OCC will log call home data
if (OCC_MASTER == G_occ_role)
{
chom_main();
}
}
}
if( l_ssxrc != SSX_OK)
{
/* @
* @errortype
* @moduleid MAIN_THRD_ROUTINE_MID
* @reasoncode SSX_GENERIC_FAILURE
* @userdata1 semaphore pending return code
* @userdata4 OCC_NO_EXTENDED_RC
* @devdesc SSX semaphore related failure
*/
errlHndl_t l_err = createErrl(MAIN_THRD_ROUTINE_MID, //modId
SSX_GENERIC_FAILURE, //reasoncode
OCC_NO_EXTENDED_RC, //Extended reason code
ERRL_SEV_UNRECOVERABLE, //Severity
NULL, //Trace Buf
DEFAULT_TRACE_SIZE, //Trace Size
-l_ssxrc, //userdata1
0); //userdata2
REQUEST_RESET(l_err);
}
// Check to make sure that the start_suspend PGPE job did not fail
if( (G_proc_pstate_status == PSTATES_FAILED) &&
(FALSE == isSafeStateRequested()) &&
(CURRENT_STATE() != OCC_STATE_SAFE) &&
(CURRENT_STATE() != OCC_STATE_STANDBY) )
{
/* @
* @errortype
* @moduleid MAIN_THRD_ROUTINE_MID
* @reasoncode PGPE_FAILURE
* @userdata1 start_suspend rc
* @userdata2 0
* @userdata4 ERC_PGPE_UNSUCCESSFULL
* @devdesc PGPE returned an error in response to start_suspend
*/
errlHndl_t l_err = createErrl(
MAIN_THRD_ROUTINE_MID, // modId
PGPE_FAILURE, // reasoncode
ERC_PGPE_UNSUCCESSFULL, // Extended reason code
ERRL_SEV_UNRECOVERABLE, // Severity
NULL, // Trace Buf
DEFAULT_TRACE_SIZE, // Trace Size
G_ss_pgpe_rc, // userdata1
0 // userdata2
);
REQUEST_RESET(l_err);
}
} // while loop
}
/*
* Function Specification
*
* Name: main
*
* Description: Entry point of the OCC application
*
* End Function Specification
*/
int main(int argc, char **argv)
{
int l_ssxrc = 0;
int l_ssxrc2 = 0;
// First, check what environment we are running on (Simics vs. HW).
check_runtime_environment();
// ----------------------------------------------------
// Initialize TLB for Linear Window access here so we
// can write checkpoints into the fsp response buffer.
// ----------------------------------------------------
#if PPC405_MMU_SUPPORT
l_ssxrc = ppc405_mmu_map(
OSD_ADDR,
OSD_ADDR,
// OSD_ADDR | 0x18000000,
OSD_TOTAL_SHARED_DATA_BYTES,
0,
TLBLO_WR | TLBLO_I,
NULL
);
if(l_ssxrc != SSX_OK)
{
//failure means we can't talk to FSP.
SSX_PANIC(0x01000001);
}
#if TRAC_TO_SIMICS
l_ssxrc = ppc405_mmu_map(
SIMICS_STDIO_BASE,
SIMICS_STDIO_BASE,
1024,
0,
TLBLO_WR | TLBLO_I,
NULL
);
if(l_ssxrc != SSX_OK)
{
//failure means we can't talk to FSP.
SSX_PANIC(0x01000001);
}
#endif /* TRAC_TO_SIMICS */
l_ssxrc = ppc405_mmu_map(
CMDH_OCC_RESPONSE_BASE_ADDRESS,
CMDH_OCC_RESPONSE_BASE_ADDRESS,
CMDH_FSP_RSP_SIZE,
0,
TLBLO_WR | TLBLO_I,
NULL
);
if(l_ssxrc != SSX_OK)
{
//failure means we can't talk to FSP.
SSX_PANIC(0x01000001);
}
l_ssxrc = ppc405_mmu_map(
CMDH_LINEAR_WINDOW_BASE_ADDRESS,
CMDH_LINEAR_WINDOW_BASE_ADDRESS,
CMDH_FSP_CMD_SIZE,
0,
TLBLO_I,
NULL
);
if(l_ssxrc != SSX_OK)
{
//failure means we can't talk to FSP.
SSX_PANIC(0x01000002);
}
l_ssxrc = ppc405_mmu_map(
TRACE_BUFFERS_START_ADDR,
TRACE_BUFFERS_START_ADDR,
ALL_TRACE_BUFFERS_SZ,
0,
TLBLO_WR | TLBLO_I,
NULL
);
if(l_ssxrc != SSX_OK)
{
//failure means there will be no trace data for debug
SSX_PANIC(0x01000003);
}
#endif /* PPC405_MMU_SUPPORT */
/* RTC 130203: TEMP -- NO FIR SUPPORT IN PHASE1
// Setup the TLB for writing to the FIR parms section
l_ssxrc = ppc405_mmu_map(FIR_PARMS_SECTION_BASE_ADDRESS,
FIR_PARMS_SECTION_BASE_ADDRESS,
FIR_PARMS_SECTION_SIZE,
0,
TLBLO_WR | TLBLO_I,
NULL);
if (l_ssxrc != SSX_OK)
{
// Panic, this section is required for FIR collection on checkstops
SSX_PANIC(0x01000003);
}
// Setup the TLB for writing to the FIR heap section
l_ssxrc = ppc405_mmu_map(FIR_HEAP_SECTION_BASE_ADDRESS,
FIR_HEAP_SECTION_BASE_ADDRESS,
FIR_HEAP_SECTION_SIZE,
0,
TLBLO_WR | TLBLO_I,
NULL);
if (l_ssxrc != SSX_OK)
{
// Panic, this section is required for FIR collection on checkstops
SSX_PANIC(0x01000004);
}
*/
CHECKPOINT_INIT();
CHECKPOINT(MAIN_STARTED);
homer_rc_t l_homerrc = HOMER_SUCCESS;
homer_rc_t l_homerrc2 = HOMER_SUCCESS;
// Get the homer version
uint32_t l_homer_version = 0;
l_homerrc = homer_hd_map_read_unmap(HOMER_VERSION,
&l_homer_version,
&l_ssxrc);
// Get proc_pb_frequency from HOMER host data and calculate the timebase
// frequency for the OCC. Pass the timebase frequency to ssx_initialize.
// The passed value must be in Hz. The occ 405 runs at 1/4 the proc
// frequency so the passed value is 1/4 of the proc_pb_frequency from the
// HOMER, ie. if the MRW says that proc_pb_frequency is 2400 MHz, then
// pass 600000000 (600MHz)
// The offset from the start of the HOMER is 0x000C0000, we will need to
// create a temporary mapping to this section of the HOMER with ppc405_mmu_map
// (at address 0x800C0000) read the value, convert it, and then unmap.
// Don't do a version check before reading the nest freq, it's present in
// all HOMER versions.
uint32_t l_tb_freq_hz = 0;
l_homerrc2 = homer_hd_map_read_unmap(HOMER_NEST_FREQ,
&G_nest_frequency_mhz,
&l_ssxrc2);
if ((HOMER_SUCCESS == l_homerrc2) || (HOMER_SSX_UNMAP_ERR == l_homerrc2))
{
// Data is in Mhz upon return and needs to be converted to Hz and then
// quartered.
l_tb_freq_hz = G_nest_frequency_mhz * (1000000 / 4);
}
else
{
l_tb_freq_hz = PPC405_TIMEBASE_HZ;
G_nest_frequency_mhz = (l_tb_freq_hz * 4) / 1000000;
}
CHECKPOINT(SSX_STARTING);
// Initialize SSX Stacks. This also reinitializes the time base to 0
ssx_initialize((SsxAddress)G_noncritical_stack,
NONCRITICAL_STACK_SIZE,
(SsxAddress)G_critical_stack,
CRITICAL_STACK_SIZE,
0,
l_tb_freq_hz);
// Store the nest / 4 frequency in shared SRAM so the GPEs
// can be initialized with the correct timebase as well.
G_shared_gpe_data.nest_freq_div = l_tb_freq_hz;
CHECKPOINT(SSX_INITIALIZED);
// TRAC_XXX needs ssx services, traces can only be done after ssx_initialize
TRAC_init_buffers();
CHECKPOINT(TRACE_INITIALIZED);
MAIN_TRAC_INFO("Inside OCC Main");
if (G_simics_environment == FALSE)
{
MAIN_TRAC_INFO("Currently not running in Simics environment");
}
else
{
MAIN_TRAC_INFO("Currently running in Simics environment");
if(G_shared_gpe_data.spipss_spec_p9)
{
MAIN_TRAC_INFO("Using P9 Spec for APSS data gathering");
}
else
{
MAIN_TRAC_INFO("Using P8 Spec for APSS data gathering");
}
}
// Trace what happened before ssx initialization
MAIN_TRAC_INFO("HOMER accessed, rc=%d, version=%d, ssx_rc=%d",
l_homerrc, l_homer_version, l_ssxrc);
MAIN_TRAC_INFO("HOMER accessed, rc=%d, nest_freq=%d, ssx_rc=%d",
l_homerrc2, l_tb_freq_hz, l_ssxrc2);
// Handle any errors from the version access
homer_log_access_error(l_homerrc,
l_ssxrc,
l_homer_version);
// Handle any errors from the nest freq access
homer_log_access_error(l_homerrc2,
l_ssxrc2,
l_tb_freq_hz);
// Time to access any initialization data needed from the HOMER (besides the
// nest frequency which was required above to enable SSX and tracing).
CHECKPOINT(HOMER_ACCESS_INITS);
// Get OCC interrupt type from HOMER host data area. This will tell OCC
// which interrupt to Host it should be using.
uint32_t l_occ_int_type = 0;
l_homerrc = homer_hd_map_read_unmap(HOMER_INT_TYPE,
&l_occ_int_type,
&l_ssxrc);
if ((HOMER_SUCCESS == l_homerrc) || (HOMER_SSX_UNMAP_ERR == l_homerrc))
{
G_occ_interrupt_type = (uint8_t) l_occ_int_type;
}
else
{
// if HOMER host data read fails, assume the FSP communication
// path as the default
G_occ_interrupt_type = FSP_SUPPORTED_OCC;
//G_occ_interrupt_type = PSIHB_INTERRUPT;
}
MAIN_TRAC_INFO("HOMER accessed, rc=%d, host interrupt type=%d, ssx_rc=%d",
l_homerrc, l_occ_int_type, l_ssxrc);
// Handle any errors from the interrupt type access
homer_log_access_error(l_homerrc,
l_ssxrc,
l_occ_int_type);
/*
//RTC 130203: TEMP -- NO FIR SUPPORT
if (l_homer_version >= HOMER_VERSION_3)
{
// Get the FIR Master indicator
uint32_t l_fir_master = FIR_OCC_NOT_FIR_MASTER;
l_homerrc = homer_hd_map_read_unmap(HOMER_FIR_MASTER,
&l_fir_master,
&l_ssxrc);
if (((HOMER_SUCCESS == l_homerrc) || (HOMER_SSX_UNMAP_ERR == l_homerrc))
&&
(FIR_OCC_IS_FIR_MASTER == l_fir_master))
{
OCC_SET_FIR_MASTER(FIR_OCC_IS_FIR_MASTER);
}
else
{
OCC_SET_FIR_MASTER(FIR_OCC_NOT_FIR_MASTER);
}
MAIN_TRAC_INFO("HOMER accessed, rc=%d, FIR master=%d, ssx_rc=%d",
l_homerrc, l_fir_master, l_ssxrc);
// Handle any errors from the FIR master access
homer_log_access_error(l_homerrc,
l_ssxrc,
l_fir_master);
// If this OCC is the FIR master read in the FIR collection parms
if (OCC_IS_FIR_MASTER())
{
MAIN_TRAC_IMP("I am the FIR master");
// Read the FIR parms buffer
l_homerrc = homer_hd_map_read_unmap(HOMER_FIR_PARMS,
&G_fir_data_parms[0],
&l_ssxrc);
MAIN_TRAC_INFO("HOMER accessed, rc=%d, FIR parms buffer 0x%x, ssx_rc=%d",
l_homerrc, &G_fir_data_parms[0], l_ssxrc);
// Handle any errors from the FIR master access
homer_log_access_error(l_homerrc,
l_ssxrc,
(uint32_t)&G_fir_data_parms[0]);
}
}
*/
//TODO: RTC 134619: Currently causes an SSX Panic due to SSX believing the
// interrupt is not owned by the 405. The fix is to update
// both occhw_interrupts.h and ssx_app_cfg.h. The change
// in occhw_interrupts.h is to change the owner. The change
// in ssx_app_cfg.h is to add OCCHW_IRQ_OCC_ERROR to the
// APPCFG_EXT_IRQS_CONFIG irq setup table.
/*
// enable and register additional interrupt handlers
CHECKPOINT(INITIALIZING_IRQS);
occ_irq_setup();
CHECKPOINT(IRQS_INITIALIZED);
*/
// enable IPC and start GPEs
CHECKPOINT(INITIALIZING_IPC);
occ_ipc_setup();
CHECKPOINT(IPC_INITIALIZED);
// Create and resume main thread
int l_rc = createAndResumeThreadHelper(&Main_thread,
Main_thread_routine,
(void *)0,
(SsxAddress)main_thread_stack,
THREAD_STACK_SIZE,
THREAD_PRIORITY_2);
if( SSX_OK != l_rc)
{
MAIN_TRAC_ERR("Failure creating/resuming main thread: rc: 0x%x", -l_rc);
/* @
* @errortype
* @moduleid MAIN_MID
* @reasoncode SSX_GENERIC_FAILURE
* @userdata1 return code
* @userdata4 OCC_NO_EXTENDED_RC
* @devdesc Firmware internal error creating thread
*/
errlHndl_t l_err = createErrl(MAIN_MID, //modId
SSX_GENERIC_FAILURE, //reasoncode
OCC_NO_EXTENDED_RC, //Extended reason code
ERRL_SEV_UNRECOVERABLE, //Severity
NULL, //Trace Buf
DEFAULT_TRACE_SIZE, //Trace Size
-l_rc, //userdata1
0); //userdata2
// Commit Error log
REQUEST_RESET(l_err);
}
// Enter SSX Kernel
ssx_start_threads();
return 0;
}
|