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
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
|
/* $NetBSD: pci_subr.c,v 1.137 2015/10/03 15:22:14 joerg Exp $ */
/*
* Copyright (c) 1997 Zubin D. Dittia. All rights reserved.
* Copyright (c) 1995, 1996, 1998, 2000
* Christopher G. Demetriou. All rights reserved.
* Copyright (c) 1994 Charles M. Hannum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Charles M. Hannum.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__minix) && defined(_PCI_SERVER)
/* This is a quick hack, simple copy of the file, until we can use it as is. */
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <pci.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pci_verbose.h>
#include <dev/pci/pcidevs.h>
#include <dev/pci/pcidevs_data.h>
const char *pci_baseclass_name(pcireg_t reg);
const char *pci_subclass_name(pcireg_t reg);
#else
/*
* PCI autoconfiguration support functions.
*
* Note: This file is also built into a userland library (libpci).
* Pay attention to this when you make modifications.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.137 2015/10/03 15:22:14 joerg Exp $");
#ifdef _KERNEL_OPT
#include "opt_pci.h"
#endif
#include <sys/param.h>
#ifdef _KERNEL
#include <sys/systm.h>
#include <sys/intr.h>
#include <sys/module.h>
#else
#include <pci.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#endif
#include <dev/pci/pcireg.h>
#ifdef _KERNEL
#include <dev/pci/pcivar.h>
#else
#include <dev/pci/pci_verbose.h>
#include <dev/pci/pcidevs.h>
#include <dev/pci/pcidevs_data.h>
#endif
#endif /* defined(__minix) && defined(_PCI_SERVER) */
/*
* Descriptions of known PCI classes and subclasses.
*
* Subclasses are described in the same way as classes, but have a
* NULL subclass pointer.
*/
struct pci_class {
const char *name;
u_int val; /* as wide as pci_{,sub}class_t */
const struct pci_class *subclasses;
};
/*
* Class 0x00.
* Before rev. 2.0.
*/
static const struct pci_class pci_subclass_prehistoric[] = {
{ "miscellaneous", PCI_SUBCLASS_PREHISTORIC_MISC, NULL, },
{ "VGA", PCI_SUBCLASS_PREHISTORIC_VGA, NULL, },
{ NULL, 0, NULL, },
};
/*
* Class 0x01.
* Mass storage controller
*/
/* ATA programming interface */
static const struct pci_class pci_interface_ata[] = {
{ "with single DMA", PCI_INTERFACE_ATA_SINGLEDMA, NULL, },
{ "with chained DMA", PCI_INTERFACE_ATA_CHAINEDDMA, NULL, },
{ NULL, 0, NULL, },
};
/* SATA programming interface */
static const struct pci_class pci_interface_sata[] = {
{ "vendor specific", PCI_INTERFACE_SATA_VND, NULL, },
{ "AHCI 1.0", PCI_INTERFACE_SATA_AHCI10, NULL, },
{ "Serial Storage Bus Interface", PCI_INTERFACE_SATA_SSBI, NULL, },
{ NULL, 0, NULL, },
};
/* Flash programming interface */
static const struct pci_class pci_interface_nvm[] = {
{ "vendor specific", PCI_INTERFACE_NVM_VND, NULL, },
{ "NVMHCI 1.0", PCI_INTERFACE_NVM_NVMHCI10, NULL, },
{ "NVMe", PCI_INTERFACE_NVM_NVME, NULL, },
{ NULL, 0, NULL, },
};
/* Subclasses */
static const struct pci_class pci_subclass_mass_storage[] = {
{ "SCSI", PCI_SUBCLASS_MASS_STORAGE_SCSI, NULL, },
{ "IDE", PCI_SUBCLASS_MASS_STORAGE_IDE, NULL, },
{ "floppy", PCI_SUBCLASS_MASS_STORAGE_FLOPPY, NULL, },
{ "IPI", PCI_SUBCLASS_MASS_STORAGE_IPI, NULL, },
{ "RAID", PCI_SUBCLASS_MASS_STORAGE_RAID, NULL, },
{ "ATA", PCI_SUBCLASS_MASS_STORAGE_ATA,
pci_interface_ata, },
{ "SATA", PCI_SUBCLASS_MASS_STORAGE_SATA,
pci_interface_sata, },
{ "SAS", PCI_SUBCLASS_MASS_STORAGE_SAS, NULL, },
{ "Flash", PCI_SUBCLASS_MASS_STORAGE_NVM,
pci_interface_nvm, },
{ "miscellaneous", PCI_SUBCLASS_MASS_STORAGE_MISC, NULL, },
{ NULL, 0, NULL, },
};
/*
* Class 0x02.
* Network controller.
*/
static const struct pci_class pci_subclass_network[] = {
{ "ethernet", PCI_SUBCLASS_NETWORK_ETHERNET, NULL, },
{ "token ring", PCI_SUBCLASS_NETWORK_TOKENRING, NULL, },
{ "FDDI", PCI_SUBCLASS_NETWORK_FDDI, NULL, },
{ "ATM", PCI_SUBCLASS_NETWORK_ATM, NULL, },
{ "ISDN", PCI_SUBCLASS_NETWORK_ISDN, NULL, },
{ "WorldFip", PCI_SUBCLASS_NETWORK_WORLDFIP, NULL, },
{ "PCMIG Multi Computing", PCI_SUBCLASS_NETWORK_PCIMGMULTICOMP, NULL, },
{ "miscellaneous", PCI_SUBCLASS_NETWORK_MISC, NULL, },
{ NULL, 0, NULL, },
};
/*
* Class 0x03.
* Display controller.
*/
/* VGA programming interface */
static const struct pci_class pci_interface_vga[] = {
{ "", PCI_INTERFACE_VGA_VGA, NULL, },
{ "8514-compat", PCI_INTERFACE_VGA_8514, NULL, },
{ NULL, 0, NULL, },
};
/* Subclasses */
static const struct pci_class pci_subclass_display[] = {
{ "VGA", PCI_SUBCLASS_DISPLAY_VGA, pci_interface_vga,},
{ "XGA", PCI_SUBCLASS_DISPLAY_XGA, NULL, },
{ "3D", PCI_SUBCLASS_DISPLAY_3D, NULL, },
{ "miscellaneous", PCI_SUBCLASS_DISPLAY_MISC, NULL, },
{ NULL, 0, NULL, },
};
/*
* Class 0x04.
* Multimedia device.
*/
static const struct pci_class pci_subclass_multimedia[] = {
{ "video", PCI_SUBCLASS_MULTIMEDIA_VIDEO, NULL, },
{ "audio", PCI_SUBCLASS_MULTIMEDIA_AUDIO, NULL, },
{ "telephony", PCI_SUBCLASS_MULTIMEDIA_TELEPHONY, NULL,},
{ "mixed mode", PCI_SUBCLASS_MULTIMEDIA_HDAUDIO, NULL, },
{ "miscellaneous", PCI_SUBCLASS_MULTIMEDIA_MISC, NULL, },
{ NULL, 0, NULL, },
};
/*
* Class 0x05.
* Memory controller.
*/
static const struct pci_class pci_subclass_memory[] = {
{ "RAM", PCI_SUBCLASS_MEMORY_RAM, NULL, },
{ "flash", PCI_SUBCLASS_MEMORY_FLASH, NULL, },
{ "miscellaneous", PCI_SUBCLASS_MEMORY_MISC, NULL, },
{ NULL, 0, NULL, },
};
/*
* Class 0x06.
* Bridge device.
*/
/* PCI bridge programming interface */
static const struct pci_class pci_interface_pcibridge[] = {
{ "", PCI_INTERFACE_BRIDGE_PCI_PCI, NULL, },
{ "subtractive decode", PCI_INTERFACE_BRIDGE_PCI_SUBDEC, NULL, },
{ NULL, 0, NULL, },
};
/* Semi-transparent PCI-to-PCI bridge programming interface */
static const struct pci_class pci_interface_stpci[] = {
{ "primary side facing host", PCI_INTERFACE_STPCI_PRIMARY, NULL, },
{ "secondary side facing host", PCI_INTERFACE_STPCI_SECONDARY, NULL, },
{ NULL, 0, NULL, },
};
/* Advanced Switching programming interface */
static const struct pci_class pci_interface_advsw[] = {
{ "custom interface", PCI_INTERFACE_ADVSW_CUSTOM, NULL, },
{ "ASI-SIG", PCI_INTERFACE_ADVSW_ASISIG, NULL, },
{ NULL, 0, NULL, },
};
/* Subclasses */
static const struct pci_class pci_subclass_bridge[] = {
{ "host", PCI_SUBCLASS_BRIDGE_HOST, NULL, },
{ "ISA", PCI_SUBCLASS_BRIDGE_ISA, NULL, },
{ "EISA", PCI_SUBCLASS_BRIDGE_EISA, NULL, },
{ "MicroChannel", PCI_SUBCLASS_BRIDGE_MC, NULL, },
{ "PCI", PCI_SUBCLASS_BRIDGE_PCI,
pci_interface_pcibridge, },
{ "PCMCIA", PCI_SUBCLASS_BRIDGE_PCMCIA, NULL, },
{ "NuBus", PCI_SUBCLASS_BRIDGE_NUBUS, NULL, },
{ "CardBus", PCI_SUBCLASS_BRIDGE_CARDBUS, NULL, },
{ "RACEway", PCI_SUBCLASS_BRIDGE_RACEWAY, NULL, },
{ "Semi-transparent PCI", PCI_SUBCLASS_BRIDGE_STPCI,
pci_interface_stpci, },
{ "InfiniBand", PCI_SUBCLASS_BRIDGE_INFINIBAND, NULL, },
{ "advanced switching", PCI_SUBCLASS_BRIDGE_ADVSW,
pci_interface_advsw, },
{ "miscellaneous", PCI_SUBCLASS_BRIDGE_MISC, NULL, },
{ NULL, 0, NULL, },
};
/*
* Class 0x07.
* Simple communications controller.
*/
/* Serial controller programming interface */
static const struct pci_class pci_interface_serial[] = {
{ "generic XT-compat", PCI_INTERFACE_SERIAL_XT, NULL, },
{ "16450-compat", PCI_INTERFACE_SERIAL_16450, NULL, },
{ "16550-compat", PCI_INTERFACE_SERIAL_16550, NULL, },
{ "16650-compat", PCI_INTERFACE_SERIAL_16650, NULL, },
{ "16750-compat", PCI_INTERFACE_SERIAL_16750, NULL, },
{ "16850-compat", PCI_INTERFACE_SERIAL_16850, NULL, },
{ "16950-compat", PCI_INTERFACE_SERIAL_16950, NULL, },
{ NULL, 0, NULL, },
};
/* Parallel controller programming interface */
static const struct pci_class pci_interface_parallel[] = {
{ "", PCI_INTERFACE_PARALLEL, NULL,},
{ "bi-directional", PCI_INTERFACE_PARALLEL_BIDIRECTIONAL, NULL,},
{ "ECP 1.X-compat", PCI_INTERFACE_PARALLEL_ECP1X, NULL,},
{ "IEEE1284 controller", PCI_INTERFACE_PARALLEL_IEEE1284_CNTRL, NULL,},
{ "IEEE1284 target", PCI_INTERFACE_PARALLEL_IEEE1284_TGT, NULL,},
{ NULL, 0, NULL,},
};
/* Modem programming interface */
static const struct pci_class pci_interface_modem[] = {
{ "", PCI_INTERFACE_MODEM, NULL,},
{ "Hayes&16450-compat", PCI_INTERFACE_MODEM_HAYES16450, NULL,},
{ "Hayes&16550-compat", PCI_INTERFACE_MODEM_HAYES16550, NULL,},
{ "Hayes&16650-compat", PCI_INTERFACE_MODEM_HAYES16650, NULL,},
{ "Hayes&16750-compat", PCI_INTERFACE_MODEM_HAYES16750, NULL,},
{ NULL, 0, NULL,},
};
/* Subclasses */
static const struct pci_class pci_subclass_communications[] = {
{ "serial", PCI_SUBCLASS_COMMUNICATIONS_SERIAL,
pci_interface_serial, },
{ "parallel", PCI_SUBCLASS_COMMUNICATIONS_PARALLEL,
pci_interface_parallel, },
{ "multi-port serial", PCI_SUBCLASS_COMMUNICATIONS_MPSERIAL, NULL,},
{ "modem", PCI_SUBCLASS_COMMUNICATIONS_MODEM,
pci_interface_modem, },
{ "GPIB", PCI_SUBCLASS_COMMUNICATIONS_GPIB, NULL,},
{ "smartcard", PCI_SUBCLASS_COMMUNICATIONS_SMARTCARD, NULL,},
{ "miscellaneous", PCI_SUBCLASS_COMMUNICATIONS_MISC, NULL,},
{ NULL, 0, NULL,},
};
/*
* Class 0x08.
* Base system peripheral.
*/
/* PIC programming interface */
static const struct pci_class pci_interface_pic[] = {
{ "generic 8259", PCI_INTERFACE_PIC_8259, NULL, },
{ "ISA PIC", PCI_INTERFACE_PIC_ISA, NULL, },
{ "EISA PIC", PCI_INTERFACE_PIC_EISA, NULL, },
{ "IO APIC", PCI_INTERFACE_PIC_IOAPIC, NULL, },
{ "IO(x) APIC", PCI_INTERFACE_PIC_IOXAPIC, NULL, },
{ NULL, 0, NULL, },
};
/* DMA programming interface */
static const struct pci_class pci_interface_dma[] = {
{ "generic 8237", PCI_INTERFACE_DMA_8237, NULL, },
{ "ISA", PCI_INTERFACE_DMA_ISA, NULL, },
{ "EISA", PCI_INTERFACE_DMA_EISA, NULL, },
{ NULL, 0, NULL, },
};
/* Timer programming interface */
static const struct pci_class pci_interface_tmr[] = {
{ "generic 8254", PCI_INTERFACE_TIMER_8254, NULL, },
{ "ISA", PCI_INTERFACE_TIMER_ISA, NULL, },
{ "EISA", PCI_INTERFACE_TIMER_EISA, NULL, },
{ "HPET", PCI_INTERFACE_TIMER_HPET, NULL, },
{ NULL, 0, NULL, },
};
/* RTC programming interface */
static const struct pci_class pci_interface_rtc[] = {
{ "generic", PCI_INTERFACE_RTC_GENERIC, NULL, },
{ "ISA", PCI_INTERFACE_RTC_ISA, NULL, },
{ NULL, 0, NULL, },
};
/* Subclasses */
static const struct pci_class pci_subclass_system[] = {
{ "interrupt", PCI_SUBCLASS_SYSTEM_PIC, pci_interface_pic,},
{ "DMA", PCI_SUBCLASS_SYSTEM_DMA, pci_interface_dma,},
{ "timer", PCI_SUBCLASS_SYSTEM_TIMER, pci_interface_tmr,},
{ "RTC", PCI_SUBCLASS_SYSTEM_RTC, pci_interface_rtc,},
{ "PCI Hot-Plug", PCI_SUBCLASS_SYSTEM_PCIHOTPLUG, NULL, },
{ "SD Host Controller", PCI_SUBCLASS_SYSTEM_SDHC, NULL, },
{ "IOMMU", PCI_SUBCLASS_SYSTEM_IOMMU, NULL, },
{ "Root Complex Event Collector", PCI_SUBCLASS_SYSTEM_RCEC, NULL, },
{ "miscellaneous", PCI_SUBCLASS_SYSTEM_MISC, NULL, },
{ NULL, 0, NULL, },
};
/*
* Class 0x09.
* Input device.
*/
/* Gameport programming interface */
static const struct pci_class pci_interface_game[] = {
{ "generic", PCI_INTERFACE_GAMEPORT_GENERIC, NULL, },
{ "legacy", PCI_INTERFACE_GAMEPORT_LEGACY, NULL, },
{ NULL, 0, NULL, },
};
/* Subclasses */
static const struct pci_class pci_subclass_input[] = {
{ "keyboard", PCI_SUBCLASS_INPUT_KEYBOARD, NULL, },
{ "digitizer", PCI_SUBCLASS_INPUT_DIGITIZER, NULL, },
{ "mouse", PCI_SUBCLASS_INPUT_MOUSE, NULL, },
{ "scanner", PCI_SUBCLASS_INPUT_SCANNER, NULL, },
{ "game port", PCI_SUBCLASS_INPUT_GAMEPORT,
pci_interface_game, },
{ "miscellaneous", PCI_SUBCLASS_INPUT_MISC, NULL, },
{ NULL, 0, NULL, },
};
/*
* Class 0x0a.
* Docking station.
*/
static const struct pci_class pci_subclass_dock[] = {
{ "generic", PCI_SUBCLASS_DOCK_GENERIC, NULL, },
{ "miscellaneous", PCI_SUBCLASS_DOCK_MISC, NULL, },
{ NULL, 0, NULL, },
};
/*
* Class 0x0b.
* Processor.
*/
static const struct pci_class pci_subclass_processor[] = {
{ "386", PCI_SUBCLASS_PROCESSOR_386, NULL, },
{ "486", PCI_SUBCLASS_PROCESSOR_486, NULL, },
{ "Pentium", PCI_SUBCLASS_PROCESSOR_PENTIUM, NULL, },
{ "Alpha", PCI_SUBCLASS_PROCESSOR_ALPHA, NULL, },
{ "PowerPC", PCI_SUBCLASS_PROCESSOR_POWERPC, NULL, },
{ "MIPS", PCI_SUBCLASS_PROCESSOR_MIPS, NULL, },
{ "Co-processor", PCI_SUBCLASS_PROCESSOR_COPROC, NULL, },
{ "miscellaneous", PCI_SUBCLASS_PROCESSOR_MISC, NULL, },
{ NULL, 0, NULL, },
};
/*
* Class 0x0c.
* Serial bus controller.
*/
/* IEEE1394 programming interface */
static const struct pci_class pci_interface_ieee1394[] = {
{ "Firewire", PCI_INTERFACE_IEEE1394_FIREWIRE, NULL,},
{ "OpenHCI", PCI_INTERFACE_IEEE1394_OPENHCI, NULL,},
{ NULL, 0, NULL,},
};
/* USB programming interface */
static const struct pci_class pci_interface_usb[] = {
{ "UHCI", PCI_INTERFACE_USB_UHCI, NULL, },
{ "OHCI", PCI_INTERFACE_USB_OHCI, NULL, },
{ "EHCI", PCI_INTERFACE_USB_EHCI, NULL, },
{ "xHCI", PCI_INTERFACE_USB_XHCI, NULL, },
{ "other HC", PCI_INTERFACE_USB_OTHERHC, NULL, },
{ "device", PCI_INTERFACE_USB_DEVICE, NULL, },
{ NULL, 0, NULL, },
};
/* IPMI programming interface */
static const struct pci_class pci_interface_ipmi[] = {
{ "SMIC", PCI_INTERFACE_IPMI_SMIC, NULL,},
{ "keyboard", PCI_INTERFACE_IPMI_KBD, NULL,},
{ "block transfer", PCI_INTERFACE_IPMI_BLOCKXFER, NULL,},
{ NULL, 0, NULL,},
};
/* Subclasses */
static const struct pci_class pci_subclass_serialbus[] = {
{ "IEEE1394", PCI_SUBCLASS_SERIALBUS_FIREWIRE,
pci_interface_ieee1394, },
{ "ACCESS.bus", PCI_SUBCLASS_SERIALBUS_ACCESS, NULL, },
{ "SSA", PCI_SUBCLASS_SERIALBUS_SSA, NULL, },
{ "USB", PCI_SUBCLASS_SERIALBUS_USB,
pci_interface_usb, },
/* XXX Fiber Channel/_FIBRECHANNEL */
{ "Fiber Channel", PCI_SUBCLASS_SERIALBUS_FIBER, NULL, },
{ "SMBus", PCI_SUBCLASS_SERIALBUS_SMBUS, NULL, },
{ "InfiniBand", PCI_SUBCLASS_SERIALBUS_INFINIBAND, NULL,},
{ "IPMI", PCI_SUBCLASS_SERIALBUS_IPMI,
pci_interface_ipmi, },
{ "SERCOS", PCI_SUBCLASS_SERIALBUS_SERCOS, NULL, },
{ "CANbus", PCI_SUBCLASS_SERIALBUS_CANBUS, NULL, },
{ "miscellaneous", PCI_SUBCLASS_SERIALBUS_MISC, NULL, },
{ NULL, 0, NULL, },
};
/*
* Class 0x0d.
* Wireless Controller.
*/
static const struct pci_class pci_subclass_wireless[] = {
{ "IrDA", PCI_SUBCLASS_WIRELESS_IRDA, NULL, },
{ "Consumer IR",/*XXX*/ PCI_SUBCLASS_WIRELESS_CONSUMERIR, NULL, },
{ "RF", PCI_SUBCLASS_WIRELESS_RF, NULL, },
{ "bluetooth", PCI_SUBCLASS_WIRELESS_BLUETOOTH, NULL, },
{ "broadband", PCI_SUBCLASS_WIRELESS_BROADBAND, NULL, },
{ "802.11a (5 GHz)", PCI_SUBCLASS_WIRELESS_802_11A, NULL, },
{ "802.11b (2.4 GHz)", PCI_SUBCLASS_WIRELESS_802_11B, NULL, },
{ "miscellaneous", PCI_SUBCLASS_WIRELESS_MISC, NULL, },
{ NULL, 0, NULL, },
};
/*
* Class 0x0e.
* Intelligent IO controller.
*/
/* Intelligent IO programming interface */
static const struct pci_class pci_interface_i2o[] = {
{ "FIFO at offset 0x40", PCI_INTERFACE_I2O_FIFOAT40, NULL,},
{ NULL, 0, NULL,},
};
/* Subclasses */
static const struct pci_class pci_subclass_i2o[] = {
{ "standard", PCI_SUBCLASS_I2O_STANDARD, pci_interface_i2o,},
{ "miscellaneous", PCI_SUBCLASS_I2O_MISC, NULL, },
{ NULL, 0, NULL, },
};
/*
* Class 0x0f.
* Satellite communication controller.
*/
static const struct pci_class pci_subclass_satcom[] = {
{ "TV", PCI_SUBCLASS_SATCOM_TV, NULL, },
{ "audio", PCI_SUBCLASS_SATCOM_AUDIO, NULL, },
{ "voice", PCI_SUBCLASS_SATCOM_VOICE, NULL, },
{ "data", PCI_SUBCLASS_SATCOM_DATA, NULL, },
{ "miscellaneous", PCI_SUBCLASS_SATCOM_MISC, NULL, },
{ NULL, 0, NULL, },
};
/*
* Class 0x10.
* Encryption/Decryption controller.
*/
static const struct pci_class pci_subclass_crypto[] = {
{ "network/computing", PCI_SUBCLASS_CRYPTO_NETCOMP, NULL, },
{ "entertainment", PCI_SUBCLASS_CRYPTO_ENTERTAINMENT, NULL,},
{ "miscellaneous", PCI_SUBCLASS_CRYPTO_MISC, NULL, },
{ NULL, 0, NULL, },
};
/*
* Class 0x11.
* Data aquuisition and signal processing controller.
*/
static const struct pci_class pci_subclass_dasp[] = {
{ "DPIO", PCI_SUBCLASS_DASP_DPIO, NULL, },
{ "performance counters", PCI_SUBCLASS_DASP_TIMEFREQ, NULL, },
{ "synchronization", PCI_SUBCLASS_DASP_SYNC, NULL, },
{ "management", PCI_SUBCLASS_DASP_MGMT, NULL, },
{ "miscellaneous", PCI_SUBCLASS_DASP_MISC, NULL, },
{ NULL, 0, NULL, },
};
/* List of classes */
static const struct pci_class pci_class[] = {
{ "prehistoric", PCI_CLASS_PREHISTORIC,
pci_subclass_prehistoric, },
{ "mass storage", PCI_CLASS_MASS_STORAGE,
pci_subclass_mass_storage, },
{ "network", PCI_CLASS_NETWORK,
pci_subclass_network, },
{ "display", PCI_CLASS_DISPLAY,
pci_subclass_display, },
{ "multimedia", PCI_CLASS_MULTIMEDIA,
pci_subclass_multimedia, },
{ "memory", PCI_CLASS_MEMORY,
pci_subclass_memory, },
{ "bridge", PCI_CLASS_BRIDGE,
pci_subclass_bridge, },
{ "communications", PCI_CLASS_COMMUNICATIONS,
pci_subclass_communications, },
{ "system", PCI_CLASS_SYSTEM,
pci_subclass_system, },
{ "input", PCI_CLASS_INPUT,
pci_subclass_input, },
{ "dock", PCI_CLASS_DOCK,
pci_subclass_dock, },
{ "processor", PCI_CLASS_PROCESSOR,
pci_subclass_processor, },
{ "serial bus", PCI_CLASS_SERIALBUS,
pci_subclass_serialbus, },
{ "wireless", PCI_CLASS_WIRELESS,
pci_subclass_wireless, },
{ "I2O", PCI_CLASS_I2O,
pci_subclass_i2o, },
{ "satellite comm", PCI_CLASS_SATCOM,
pci_subclass_satcom, },
{ "crypto", PCI_CLASS_CRYPTO,
pci_subclass_crypto, },
{ "DASP", PCI_CLASS_DASP,
pci_subclass_dasp, },
{ "undefined", PCI_CLASS_UNDEFINED,
NULL, },
{ NULL, 0,
NULL, },
};
#if defined(__minix) && defined(_PCI_SERVER)
const char *
pci_baseclass_name(pcireg_t reg)
{
const struct pci_class *classp = pci_class;
while (classp->name != NULL) {
if (PCI_CLASS(reg) == classp->val)
break;
classp++;
}
return classp->name;
}
const char *
pci_subclass_name(pcireg_t reg)
{
const struct pci_class *classp = pci_class;
const struct pci_class *subclassp;
while (classp->name != NULL) {
if (PCI_CLASS(reg) == classp->val)
break;
classp++;
}
subclassp = (classp->name != NULL) ? classp->subclasses : NULL;
while (subclassp && subclassp->name != NULL) {
if (PCI_SUBCLASS(reg) == subclassp->val)
break;
subclassp++;
}
if (subclassp) {
return subclassp->name;
} else {
return NULL;
}
}
#endif /* defined(__minix) && defined(_PCI_SERVER) */
DEV_VERBOSE_DEFINE(pci);
#if defined(__minix) && !defined(_PCI_SERVER)
void
pci_devinfo(pcireg_t id_reg, pcireg_t class_reg, int showclass, char *cp,
size_t l)
{
pci_class_t pciclass;
pci_subclass_t subclass;
pci_interface_t interface;
pci_revision_t revision;
char vendor[PCI_VENDORSTR_LEN], product[PCI_PRODUCTSTR_LEN];
const struct pci_class *classp, *subclassp, *interfacep;
char *ep;
ep = cp + l;
pciclass = PCI_CLASS(class_reg);
subclass = PCI_SUBCLASS(class_reg);
interface = PCI_INTERFACE(class_reg);
revision = PCI_REVISION(class_reg);
pci_findvendor(vendor, sizeof(vendor), PCI_VENDOR(id_reg));
pci_findproduct(product, sizeof(product), PCI_VENDOR(id_reg),
PCI_PRODUCT(id_reg));
classp = pci_class;
while (classp->name != NULL) {
if (pciclass == classp->val)
break;
classp++;
}
subclassp = (classp->name != NULL) ? classp->subclasses : NULL;
while (subclassp && subclassp->name != NULL) {
if (subclass == subclassp->val)
break;
subclassp++;
}
interfacep = (subclassp && subclassp->name != NULL) ?
subclassp->subclasses : NULL;
while (interfacep && interfacep->name != NULL) {
if (interface == interfacep->val)
break;
interfacep++;
}
cp += snprintf(cp, ep - cp, "%s %s", vendor, product);
if (showclass) {
cp += snprintf(cp, ep - cp, " (");
if (classp->name == NULL)
cp += snprintf(cp, ep - cp,
"class 0x%02x, subclass 0x%02x", pciclass, subclass);
else {
if (subclassp == NULL || subclassp->name == NULL)
cp += snprintf(cp, ep - cp,
"%s, subclass 0x%02x",
classp->name, subclass);
else
cp += snprintf(cp, ep - cp, "%s %s",
subclassp->name, classp->name);
}
if ((interfacep == NULL) || (interfacep->name == NULL)) {
if (interface != 0)
cp += snprintf(cp, ep - cp,
", interface 0x%02x", interface);
} else if (strncmp(interfacep->name, "", 1) != 0)
cp += snprintf(cp, ep - cp, ", %s",
interfacep->name);
if (revision != 0)
cp += snprintf(cp, ep - cp, ", revision 0x%02x",
revision);
cp += snprintf(cp, ep - cp, ")");
}
}
#ifdef _KERNEL
void
pci_aprint_devinfo_fancy(const struct pci_attach_args *pa, const char *naive,
const char *known, int addrev)
{
char devinfo[256];
if (known) {
aprint_normal(": %s", known);
if (addrev)
aprint_normal(" (rev. 0x%02x)",
PCI_REVISION(pa->pa_class));
aprint_normal("\n");
} else {
pci_devinfo(pa->pa_id, pa->pa_class, 0,
devinfo, sizeof(devinfo));
aprint_normal(": %s (rev. 0x%02x)\n", devinfo,
PCI_REVISION(pa->pa_class));
}
if (naive)
aprint_naive(": %s\n", naive);
else
aprint_naive("\n");
}
#endif
/*
* Print out most of the PCI configuration registers. Typically used
* in a device attach routine like this:
*
* #ifdef MYDEV_DEBUG
* printf("%s: ", device_xname(sc->sc_dev));
* pci_conf_print(pa->pa_pc, pa->pa_tag, NULL);
* #endif
*/
#define i2o(i) ((i) * 4)
#define o2i(o) ((o) / 4)
#define onoff2(str, rval, bit, onstr, offstr) \
printf(" %s: %s\n", (str), ((rval) & (bit)) ? onstr : offstr);
#define onoff(str, rval, bit) onoff2(str, rval, bit, "on", "off")
static void
pci_conf_print_common(
#ifdef _KERNEL
pci_chipset_tag_t pc, pcitag_t tag,
#endif
const pcireg_t *regs)
{
const char *name;
const struct pci_class *classp, *subclassp;
char vendor[PCI_VENDORSTR_LEN];
char product[PCI_PRODUCTSTR_LEN];
pcireg_t rval;
unsigned int num;
rval = regs[o2i(PCI_ID_REG)];
name = pci_findvendor(vendor, sizeof(vendor), PCI_VENDOR(rval));
if (name)
printf(" Vendor Name: %s (0x%04x)\n", name,
PCI_VENDOR(rval));
else
printf(" Vendor ID: 0x%04x\n", PCI_VENDOR(rval));
name = pci_findproduct(product, sizeof(product), PCI_VENDOR(rval),
PCI_PRODUCT(rval));
if (name)
printf(" Device Name: %s (0x%04x)\n", name,
PCI_PRODUCT(rval));
else
printf(" Device ID: 0x%04x\n", PCI_PRODUCT(rval));
rval = regs[o2i(PCI_COMMAND_STATUS_REG)];
printf(" Command register: 0x%04x\n", rval & 0xffff);
onoff("I/O space accesses", rval, PCI_COMMAND_IO_ENABLE);
onoff("Memory space accesses", rval, PCI_COMMAND_MEM_ENABLE);
onoff("Bus mastering", rval, PCI_COMMAND_MASTER_ENABLE);
onoff("Special cycles", rval, PCI_COMMAND_SPECIAL_ENABLE);
onoff("MWI transactions", rval, PCI_COMMAND_INVALIDATE_ENABLE);
onoff("Palette snooping", rval, PCI_COMMAND_PALETTE_ENABLE);
onoff("Parity error checking", rval, PCI_COMMAND_PARITY_ENABLE);
onoff("Address/data stepping", rval, PCI_COMMAND_STEPPING_ENABLE);
onoff("System error (SERR)", rval, PCI_COMMAND_SERR_ENABLE);
onoff("Fast back-to-back transactions", rval,
PCI_COMMAND_BACKTOBACK_ENABLE);
onoff("Interrupt disable", rval, PCI_COMMAND_INTERRUPT_DISABLE);
printf(" Status register: 0x%04x\n", (rval >> 16) & 0xffff);
onoff2("Interrupt status", rval, PCI_STATUS_INT_STATUS, "active",
"inactive");
onoff("Capability List support", rval, PCI_STATUS_CAPLIST_SUPPORT);
onoff("66 MHz capable", rval, PCI_STATUS_66MHZ_SUPPORT);
onoff("User Definable Features (UDF) support", rval,
PCI_STATUS_UDF_SUPPORT);
onoff("Fast back-to-back capable", rval,
PCI_STATUS_BACKTOBACK_SUPPORT);
onoff("Data parity error detected", rval, PCI_STATUS_PARITY_ERROR);
printf(" DEVSEL timing: ");
switch (rval & PCI_STATUS_DEVSEL_MASK) {
case PCI_STATUS_DEVSEL_FAST:
printf("fast");
break;
case PCI_STATUS_DEVSEL_MEDIUM:
printf("medium");
break;
case PCI_STATUS_DEVSEL_SLOW:
printf("slow");
break;
default:
printf("unknown/reserved"); /* XXX */
break;
}
printf(" (0x%x)\n", (rval & PCI_STATUS_DEVSEL_MASK) >> 25);
onoff("Slave signaled Target Abort", rval,
PCI_STATUS_TARGET_TARGET_ABORT);
onoff("Master received Target Abort", rval,
PCI_STATUS_MASTER_TARGET_ABORT);
onoff("Master received Master Abort", rval, PCI_STATUS_MASTER_ABORT);
onoff("Asserted System Error (SERR)", rval, PCI_STATUS_SPECIAL_ERROR);
onoff("Parity error detected", rval, PCI_STATUS_PARITY_DETECT);
rval = regs[o2i(PCI_CLASS_REG)];
for (classp = pci_class; classp->name != NULL; classp++) {
if (PCI_CLASS(rval) == classp->val)
break;
}
subclassp = (classp->name != NULL) ? classp->subclasses : NULL;
while (subclassp && subclassp->name != NULL) {
if (PCI_SUBCLASS(rval) == subclassp->val)
break;
subclassp++;
}
if (classp->name != NULL) {
printf(" Class Name: %s (0x%02x)\n", classp->name,
PCI_CLASS(rval));
if (subclassp != NULL && subclassp->name != NULL)
printf(" Subclass Name: %s (0x%02x)\n",
subclassp->name, PCI_SUBCLASS(rval));
else
printf(" Subclass ID: 0x%02x\n",
PCI_SUBCLASS(rval));
} else {
printf(" Class ID: 0x%02x\n", PCI_CLASS(rval));
printf(" Subclass ID: 0x%02x\n", PCI_SUBCLASS(rval));
}
printf(" Interface: 0x%02x\n", PCI_INTERFACE(rval));
printf(" Revision ID: 0x%02x\n", PCI_REVISION(rval));
rval = regs[o2i(PCI_BHLC_REG)];
printf(" BIST: 0x%02x\n", PCI_BIST(rval));
printf(" Header Type: 0x%02x%s (0x%02x)\n", PCI_HDRTYPE_TYPE(rval),
PCI_HDRTYPE_MULTIFN(rval) ? "+multifunction" : "",
PCI_HDRTYPE(rval));
printf(" Latency Timer: 0x%02x\n", PCI_LATTIMER(rval));
num = PCI_CACHELINE(rval);
printf(" Cache Line Size: %ubytes (0x%02x)\n", num * 4, num);
}
static int
pci_conf_print_bar(
#ifdef _KERNEL
pci_chipset_tag_t pc, pcitag_t tag,
#endif
const pcireg_t *regs, int reg, const char *name
#ifdef _KERNEL
, int sizebar
#endif
)
{
int width;
pcireg_t rval, rval64h;
#ifdef _KERNEL
int s;
pcireg_t mask, mask64h;
#endif
width = 4;
/*
* Section 6.2.5.1, `Address Maps', tells us that:
*
* 1) The builtin software should have already mapped the
* device in a reasonable way.
*
* 2) A device which wants 2^n bytes of memory will hardwire
* the bottom n bits of the address to 0. As recommended,
* we write all 1s and see what we get back.
*/
rval = regs[o2i(reg)];
if (PCI_MAPREG_TYPE(rval) == PCI_MAPREG_TYPE_MEM &&
PCI_MAPREG_MEM_TYPE(rval) == PCI_MAPREG_MEM_TYPE_64BIT) {
rval64h = regs[o2i(reg + 4)];
width = 8;
} else
rval64h = 0;
#ifdef _KERNEL
/* XXX don't size unknown memory type? */
if (rval != 0 && sizebar) {
/*
* The following sequence seems to make some devices
* (e.g. host bus bridges, which don't normally
* have their space mapped) very unhappy, to
* the point of crashing the system.
*
* Therefore, if the mapping register is zero to
* start out with, don't bother trying.
*/
s = splhigh();
pci_conf_write(pc, tag, reg, 0xffffffff);
mask = pci_conf_read(pc, tag, reg);
pci_conf_write(pc, tag, reg, rval);
if (PCI_MAPREG_TYPE(rval) == PCI_MAPREG_TYPE_MEM &&
PCI_MAPREG_MEM_TYPE(rval) == PCI_MAPREG_MEM_TYPE_64BIT) {
pci_conf_write(pc, tag, reg + 4, 0xffffffff);
mask64h = pci_conf_read(pc, tag, reg + 4);
pci_conf_write(pc, tag, reg + 4, rval64h);
} else
mask64h = 0;
splx(s);
} else
mask = mask64h = 0;
#endif /* _KERNEL */
printf(" Base address register at 0x%02x", reg);
if (name)
printf(" (%s)", name);
printf("\n ");
if (rval == 0) {
printf("not implemented(?)\n");
return width;
}
printf("type: ");
if (PCI_MAPREG_TYPE(rval) == PCI_MAPREG_TYPE_MEM) {
const char *type, *prefetch;
switch (PCI_MAPREG_MEM_TYPE(rval)) {
case PCI_MAPREG_MEM_TYPE_32BIT:
type = "32-bit";
break;
case PCI_MAPREG_MEM_TYPE_32BIT_1M:
type = "32-bit-1M";
break;
case PCI_MAPREG_MEM_TYPE_64BIT:
type = "64-bit";
break;
default:
type = "unknown (XXX)";
break;
}
if (PCI_MAPREG_MEM_PREFETCHABLE(rval))
prefetch = "";
else
prefetch = "non";
printf("%s %sprefetchable memory\n", type, prefetch);
switch (PCI_MAPREG_MEM_TYPE(rval)) {
case PCI_MAPREG_MEM_TYPE_64BIT:
printf(" base: 0x%016llx, ",
PCI_MAPREG_MEM64_ADDR(
((((long long) rval64h) << 32) | rval)));
#ifdef _KERNEL
if (sizebar)
printf("size: 0x%016llx",
PCI_MAPREG_MEM64_SIZE(
((((long long) mask64h) << 32) | mask)));
else
#endif /* _KERNEL */
printf("not sized");
printf("\n");
break;
case PCI_MAPREG_MEM_TYPE_32BIT:
case PCI_MAPREG_MEM_TYPE_32BIT_1M:
default:
printf(" base: 0x%08x, ",
PCI_MAPREG_MEM_ADDR(rval));
#ifdef _KERNEL
if (sizebar)
printf("size: 0x%08x",
PCI_MAPREG_MEM_SIZE(mask));
else
#endif /* _KERNEL */
printf("not sized");
printf("\n");
break;
}
} else {
#ifdef _KERNEL
if (sizebar)
printf("%d-bit ", mask & ~0x0000ffff ? 32 : 16);
#endif /* _KERNEL */
printf("i/o\n");
printf(" base: 0x%08x, ", PCI_MAPREG_IO_ADDR(rval));
#ifdef _KERNEL
if (sizebar)
printf("size: 0x%08x", PCI_MAPREG_IO_SIZE(mask));
else
#endif /* _KERNEL */
printf("not sized");
printf("\n");
}
return width;
}
static void
pci_conf_print_regs(const pcireg_t *regs, int first, int pastlast)
{
int off, needaddr, neednl;
needaddr = 1;
neednl = 0;
for (off = first; off < pastlast; off += 4) {
if ((off % 16) == 0 || needaddr) {
printf(" 0x%02x:", off);
needaddr = 0;
}
printf(" 0x%08x", regs[o2i(off)]);
neednl = 1;
if ((off % 16) == 12) {
printf("\n");
neednl = 0;
}
}
if (neednl)
printf("\n");
}
static void
pci_conf_print_agp_cap(const pcireg_t *regs, int capoff)
{
pcireg_t rval;
printf("\n AGP Capabilities Register\n");
rval = regs[o2i(capoff)];
printf(" Revision: %d.%d\n",
PCI_CAP_AGP_MAJOR(rval), PCI_CAP_AGP_MINOR(rval));
/* XXX need more */
}
static const char *
pci_conf_print_pcipm_cap_aux(uint16_t caps)
{
switch ((caps >> 6) & 7) {
case 0: return "self-powered";
case 1: return "55 mA";
case 2: return "100 mA";
case 3: return "160 mA";
case 4: return "220 mA";
case 5: return "270 mA";
case 6: return "320 mA";
case 7:
default: return "375 mA";
}
}
static const char *
pci_conf_print_pcipm_cap_pmrev(uint8_t val)
{
static const char unk[] = "unknown";
static const char *pmrev[8] = {
unk, "1.0", "1.1", "1.2", unk, unk, unk, unk
};
if (val > 7)
return unk;
return pmrev[val];
}
static void
pci_conf_print_pcipm_cap(const pcireg_t *regs, int capoff)
{
uint16_t caps, pmcsr;
pcireg_t reg;
caps = regs[o2i(capoff)] >> PCI_PMCR_SHIFT;
reg = regs[o2i(capoff + PCI_PMCSR)];
pmcsr = reg & 0xffff;
printf("\n PCI Power Management Capabilities Register\n");
printf(" Capabilities register: 0x%04x\n", caps);
printf(" Version: %s\n",
pci_conf_print_pcipm_cap_pmrev(caps & PCI_PMCR_VERSION_MASK));
onoff("PME# clock", caps, PCI_PMCR_PME_CLOCK);
onoff("Device specific initialization", caps, PCI_PMCR_DSI);
printf(" 3.3V auxiliary current: %s\n",
pci_conf_print_pcipm_cap_aux(caps));
onoff("D1 power management state support", caps, PCI_PMCR_D1SUPP);
onoff("D2 power management state support", caps, PCI_PMCR_D2SUPP);
onoff("PME# support D0", caps, PCI_PMCR_PME_D0);
onoff("PME# support D1", caps, PCI_PMCR_PME_D1);
onoff("PME# support D2", caps, PCI_PMCR_PME_D2);
onoff("PME# support D3 hot", caps, PCI_PMCR_PME_D3HOT);
onoff("PME# support D3 cold", caps, PCI_PMCR_PME_D3COLD);
printf(" Control/status register: 0x%04x\n", pmcsr);
printf(" Power state: D%d\n", pmcsr & PCI_PMCSR_STATE_MASK);
onoff("PCI Express reserved", (pmcsr >> 2), 1);
onoff("No soft reset", pmcsr, PCI_PMCSR_NO_SOFTRST);
printf(" PME# assertion: %sabled\n",
(pmcsr & PCI_PMCSR_PME_EN) ? "en" : "dis");
onoff("PME# status", pmcsr, PCI_PMCSR_PME_STS);
printf(" Bridge Support Extensions register: 0x%02x\n",
(reg >> 16) & 0xff);
onoff("B2/B3 support", reg, PCI_PMCSR_B2B3_SUPPORT);
onoff("Bus Power/Clock Control Enable", reg, PCI_PMCSR_BPCC_EN);
printf(" Data register: 0x%02x\n", (reg >> 24) & 0xff);
}
/* XXX pci_conf_print_vpd_cap */
/* XXX pci_conf_print_slotid_cap */
static void
pci_conf_print_msi_cap(const pcireg_t *regs, int capoff)
{
uint32_t ctl, mmc, mme;
regs += o2i(capoff);
ctl = *regs++;
mmc = __SHIFTOUT(ctl, PCI_MSI_CTL_MMC_MASK);
mme = __SHIFTOUT(ctl, PCI_MSI_CTL_MME_MASK);
printf("\n PCI Message Signaled Interrupt\n");
printf(" Message Control register: 0x%04x\n", ctl >> 16);
onoff("MSI Enabled", ctl, PCI_MSI_CTL_MSI_ENABLE);
printf(" Multiple Message Capable: %s (%d vector%s)\n",
mmc > 0 ? "yes" : "no", 1 << mmc, mmc > 0 ? "s" : "");
printf(" Multiple Message Enabled: %s (%d vector%s)\n",
mme > 0 ? "on" : "off", 1 << mme, mme > 0 ? "s" : "");
onoff("64 Bit Address Capable", ctl, PCI_MSI_CTL_64BIT_ADDR);
onoff("Per-Vector Masking Capable", ctl, PCI_MSI_CTL_PERVEC_MASK);
printf(" Message Address %sregister: 0x%08x\n",
ctl & PCI_MSI_CTL_64BIT_ADDR ? "(lower) " : "", *regs++);
if (ctl & PCI_MSI_CTL_64BIT_ADDR) {
printf(" Message Address %sregister: 0x%08x\n",
"(upper) ", *regs++);
}
printf(" Message Data register: 0x%08x\n", *regs++);
if (ctl & PCI_MSI_CTL_PERVEC_MASK) {
printf(" Vector Mask register: 0x%08x\n", *regs++);
printf(" Vector Pending register: 0x%08x\n", *regs++);
}
}
/* XXX pci_conf_print_cpci_hostwap_cap */
/*
* For both command register and status register.
* The argument "idx" is index number (0 to 7).
*/
static int
pcix_split_trans(unsigned int idx)
{
static int table[8] = {
1, 2, 3, 4, 8, 12, 16, 32
};
if (idx >= __arraycount(table))
return -1;
return table[idx];
}
static void
pci_conf_print_pcix_cap(const pcireg_t *regs, int capoff)
{
pcireg_t reg;
int isbridge;
int i;
isbridge = (PCI_HDRTYPE_TYPE(regs[o2i(PCI_BHLC_REG)])
& PCI_HDRTYPE_PPB) != 0 ? 1 : 0;
printf("\n PCI-X %s Capabilities Register\n",
isbridge ? "Bridge" : "Non-bridge");
reg = regs[o2i(capoff)];
if (isbridge != 0) {
printf(" Secondary status register: 0x%04x\n",
(reg & 0xffff0000) >> 16);
onoff("64bit device", reg, PCIX_STATUS_64BIT);
onoff("133MHz capable", reg, PCIX_STATUS_133);
onoff("Split completion discarded", reg, PCIX_STATUS_SPLDISC);
onoff("Unexpected split completion", reg, PCIX_STATUS_SPLUNEX);
onoff("Split completion overrun", reg, PCIX_BRIDGE_ST_SPLOVRN);
onoff("Split request delayed", reg, PCIX_BRIDGE_ST_SPLRQDL);
printf(" Secondary clock frequency: 0x%x\n",
(reg & PCIX_BRIDGE_2NDST_CLKF)
>> PCIX_BRIDGE_2NDST_CLKF_SHIFT);
printf(" Version: 0x%x\n",
(reg & PCIX_BRIDGE_2NDST_VER_MASK)
>> PCIX_BRIDGE_2NDST_VER_SHIFT);
onoff("266MHz capable", reg, PCIX_BRIDGE_ST_266);
onoff("533MHz capable", reg, PCIX_BRIDGE_ST_533);
} else {
printf(" Command register: 0x%04x\n",
(reg & 0xffff0000) >> 16);
onoff("Data Parity Error Recovery", reg,
PCIX_CMD_PERR_RECOVER);
onoff("Enable Relaxed Ordering", reg, PCIX_CMD_RELAXED_ORDER);
printf(" Maximum Burst Read Count: %u\n",
PCIX_CMD_BYTECNT(reg));
printf(" Maximum Split Transactions: %d\n",
pcix_split_trans((reg & PCIX_CMD_SPLTRANS_MASK)
>> PCIX_CMD_SPLTRANS_SHIFT));
}
reg = regs[o2i(capoff+PCIX_STATUS)]; /* Or PCIX_BRIDGE_PRI_STATUS */
printf(" %sStatus register: 0x%08x\n",
isbridge ? "Bridge " : "", reg);
printf(" Function: %d\n", PCIX_STATUS_FN(reg));
printf(" Device: %d\n", PCIX_STATUS_DEV(reg));
printf(" Bus: %d\n", PCIX_STATUS_BUS(reg));
onoff("64bit device", reg, PCIX_STATUS_64BIT);
onoff("133MHz capable", reg, PCIX_STATUS_133);
onoff("Split completion discarded", reg, PCIX_STATUS_SPLDISC);
onoff("Unexpected split completion", reg, PCIX_STATUS_SPLUNEX);
if (isbridge != 0) {
onoff("Split completion overrun", reg, PCIX_BRIDGE_ST_SPLOVRN);
onoff("Split request delayed", reg, PCIX_BRIDGE_ST_SPLRQDL);
} else {
onoff2("Device Complexity", reg, PCIX_STATUS_DEVCPLX,
"bridge device", "simple device");
printf(" Designed max memory read byte count: %d\n",
512 << ((reg & PCIX_STATUS_MAXB_MASK)
>> PCIX_STATUS_MAXB_SHIFT));
printf(" Designed max outstanding split transaction: %d\n",
pcix_split_trans((reg & PCIX_STATUS_MAXST_MASK)
>> PCIX_STATUS_MAXST_SHIFT));
printf(" MAX cumulative Read Size: %u\n",
8 << ((reg & 0x1c000000) >> PCIX_STATUS_MAXRS_SHIFT));
onoff("Received split completion error", reg,
PCIX_STATUS_SCERR);
}
onoff("266MHz capable", reg, PCIX_STATUS_266);
onoff("533MHz capable", reg, PCIX_STATUS_533);
if (isbridge == 0)
return;
/* Only for bridge */
for (i = 0; i < 2; i++) {
reg = regs[o2i(capoff+PCIX_BRIDGE_UP_STCR + (4 * i))];
printf(" %s split transaction control register: 0x%08x\n",
(i == 0) ? "Upstream" : "Downstream", reg);
printf(" Capacity: %d\n", reg & PCIX_BRIDGE_STCAP);
printf(" Commitment Limit: %d\n",
(reg & PCIX_BRIDGE_STCLIM) >> PCIX_BRIDGE_STCLIM_SHIFT);
}
}
/* XXX pci_conf_print_ldt_cap */
static void
pci_conf_print_vendspec_cap(const pcireg_t *regs, int capoff)
{
uint16_t caps;
caps = regs[o2i(capoff)] >> PCI_VENDORSPECIFIC_SHIFT;
printf("\n PCI Vendor Specific Capabilities Register\n");
printf(" Capabilities length: 0x%02x\n", caps & 0xff);
}
static void
pci_conf_print_debugport_cap(const pcireg_t *regs, int capoff)
{
pcireg_t val;
val = regs[o2i(capoff + PCI_DEBUG_BASER)];
printf("\n Debugport Capability Register\n");
printf(" Debug base Register: 0x%04x\n",
val >> PCI_DEBUG_BASER_SHIFT);
printf(" port offset: 0x%04x\n",
(val & PCI_DEBUG_PORTOFF_MASK) >> PCI_DEBUG_PORTOFF_SHIFT);
printf(" BAR number: %u\n",
(val & PCI_DEBUG_BARNUM_MASK) >> PCI_DEBUG_BARNUM_SHIFT);
}
/* XXX pci_conf_print_cpci_rsrcctl_cap */
/* XXX pci_conf_print_hotplug_cap */
static void
pci_conf_print_subsystem_cap(const pcireg_t *regs, int capoff)
{
pcireg_t reg;
reg = regs[o2i(capoff + PCI_CAP_SUBSYS_ID)];
printf("\n Subsystem ID Capability Register\n");
printf(" Subsystem ID : 0x%08x\n", reg);
}
/* XXX pci_conf_print_agp8_cap */
/* XXX pci_conf_print_secure_cap */
static void
pci_print_pcie_L0s_latency(uint32_t val)
{
switch (val) {
case 0x0:
printf("Less than 64ns\n");
break;
case 0x1:
case 0x2:
case 0x3:
printf("%dns to less than %dns\n", 32 << val, 32 << (val + 1));
break;
case 0x4:
printf("512ns to less than 1us\n");
break;
case 0x5:
printf("1us to less than 2us\n");
break;
case 0x6:
printf("2us - 4us\n");
break;
case 0x7:
printf("More than 4us\n");
break;
}
}
static void
pci_print_pcie_L1_latency(uint32_t val)
{
switch (val) {
case 0x0:
printf("Less than 1us\n");
break;
case 0x6:
printf("32us - 64us\n");
break;
case 0x7:
printf("More than 64us\n");
break;
default:
printf("%dus to less than %dus\n", 1 << (val - 1), 1 << val);
break;
}
}
static void
pci_print_pcie_compl_timeout(uint32_t val)
{
switch (val) {
case 0x0:
printf("50us to 50ms\n");
break;
case 0x5:
printf("16ms to 55ms\n");
break;
case 0x6:
printf("65ms to 210ms\n");
break;
case 0x9:
printf("260ms to 900ms\n");
break;
case 0xa:
printf("1s to 3.5s\n");
break;
default:
printf("unknown %u value\n", val);
break;
}
}
static void
pci_conf_print_pcie_cap(const pcireg_t *regs, int capoff)
{
pcireg_t reg; /* for each register */
pcireg_t val; /* for each bitfield */
bool check_link = false;
bool check_slot = false;
bool check_rootport = false;
unsigned int pciever;
static const char * const linkspeeds[] = {"2.5", "5.0", "8.0"};
int i;
printf("\n PCI Express Capabilities Register\n");
/* Capability Register */
reg = regs[o2i(capoff)];
printf(" Capability register: %04x\n", reg >> 16);
pciever = (unsigned int)((reg & 0x000f0000) >> 16);
printf(" Capability version: %u\n", pciever);
printf(" Device type: ");
switch ((reg & 0x00f00000) >> 20) {
case 0x0:
printf("PCI Express Endpoint device\n");
check_link = true;
break;
case 0x1:
printf("Legacy PCI Express Endpoint device\n");
check_link = true;
break;
case 0x4:
printf("Root Port of PCI Express Root Complex\n");
check_link = true;
check_slot = true;
check_rootport = true;
break;
case 0x5:
printf("Upstream Port of PCI Express Switch\n");
break;
case 0x6:
printf("Downstream Port of PCI Express Switch\n");
check_slot = true;
check_rootport = true;
break;
case 0x7:
printf("PCI Express to PCI/PCI-X Bridge\n");
break;
case 0x8:
printf("PCI/PCI-X to PCI Express Bridge\n");
break;
case 0x9:
printf("Root Complex Integrated Endpoint\n");
break;
case 0xa:
check_rootport = true;
printf("Root Complex Event Collector\n");
break;
default:
printf("unknown\n");
break;
}
onoff("Slot implemented", reg, PCIE_XCAP_SI);
printf(" Interrupt Message Number: %x\n",
(unsigned int)((reg & PCIE_XCAP_IRQ) >> 27));
/* Device Capability Register */
reg = regs[o2i(capoff + PCIE_DCAP)];
printf(" Device Capabilities Register: 0x%08x\n", reg);
printf(" Max Payload Size Supported: %u bytes max\n",
128 << (unsigned int)(reg & PCIE_DCAP_MAX_PAYLOAD));
printf(" Phantom Functions Supported: ");
switch ((reg & PCIE_DCAP_PHANTOM_FUNCS) >> 3) {
case 0x0:
printf("not available\n");
break;
case 0x1:
printf("MSB\n");
break;
case 0x2:
printf("two MSB\n");
break;
case 0x3:
printf("All three bits\n");
break;
}
printf(" Extended Tag Field Supported: %dbit\n",
(reg & PCIE_DCAP_EXT_TAG_FIELD) == 0 ? 5 : 8);
printf(" Endpoint L0 Acceptable Latency: ");
pci_print_pcie_L0s_latency((reg & PCIE_DCAP_L0S_LATENCY) >> 6);
printf(" Endpoint L1 Acceptable Latency: ");
pci_print_pcie_L1_latency((reg & PCIE_DCAP_L1_LATENCY) >> 9);
onoff("Attention Button Present", reg, PCIE_DCAP_ATTN_BUTTON);
onoff("Attention Indicator Present", reg, PCIE_DCAP_ATTN_IND);
onoff("Power Indicator Present", reg, PCIE_DCAP_PWR_IND);
onoff("Role-Based Error Report", reg, PCIE_DCAP_ROLE_ERR_RPT);
printf(" Captured Slot Power Limit Value: %d\n",
(unsigned int)(reg & PCIE_DCAP_SLOT_PWR_LIM_VAL) >> 18);
printf(" Captured Slot Power Limit Scale: %d\n",
(unsigned int)(reg & PCIE_DCAP_SLOT_PWR_LIM_SCALE) >> 26);
onoff("Function-Level Reset Capability", reg, PCIE_DCAP_FLR);
/* Device Control Register */
reg = regs[o2i(capoff + PCIE_DCSR)];
printf(" Device Control Register: 0x%04x\n", reg & 0xffff);
onoff("Correctable Error Reporting Enable", reg,
PCIE_DCSR_ENA_COR_ERR);
onoff("Non Fatal Error Reporting Enable", reg, PCIE_DCSR_ENA_NFER);
onoff("Fatal Error Reporting Enable", reg, PCIE_DCSR_ENA_FER);
onoff("Unsupported Request Reporting Enable", reg, PCIE_DCSR_ENA_URR);
onoff("Enable Relaxed Ordering", reg, PCIE_DCSR_ENA_RELAX_ORD);
printf(" Max Payload Size: %d byte\n",
128 << (((unsigned int)(reg & PCIE_DCSR_MAX_PAYLOAD) >> 5)));
onoff("Extended Tag Field Enable", reg, PCIE_DCSR_EXT_TAG_FIELD);
onoff("Phantom Functions Enable", reg, PCIE_DCSR_PHANTOM_FUNCS);
onoff("Aux Power PM Enable", reg, PCIE_DCSR_AUX_POWER_PM);
onoff("Enable No Snoop", reg, PCIE_DCSR_ENA_NO_SNOOP);
printf(" Max Read Request Size: %d byte\n",
128 << ((unsigned int)(reg & PCIE_DCSR_MAX_READ_REQ) >> 12));
/* Device Status Register */
reg = regs[o2i(capoff + PCIE_DCSR)];
printf(" Device Status Register: 0x%04x\n", reg >> 16);
onoff("Correctable Error Detected", reg, PCIE_DCSR_CED);
onoff("Non Fatal Error Detected", reg, PCIE_DCSR_NFED);
onoff("Fatal Error Detected", reg, PCIE_DCSR_FED);
onoff("Unsupported Request Detected", reg, PCIE_DCSR_URD);
onoff("Aux Power Detected", reg, PCIE_DCSR_AUX_PWR);
onoff("Transaction Pending", reg, PCIE_DCSR_TRANSACTION_PND);
if (check_link) {
/* Link Capability Register */
reg = regs[o2i(capoff + PCIE_LCAP)];
printf(" Link Capabilities Register: 0x%08x\n", reg);
printf(" Maximum Link Speed: ");
val = reg & PCIE_LCAP_MAX_SPEED;
if (val < 1 || val > 3) {
printf("unknown %u value\n", val);
} else {
printf("%sGT/s\n", linkspeeds[val - 1]);
}
printf(" Maximum Link Width: x%u lanes\n",
(unsigned int)(reg & PCIE_LCAP_MAX_WIDTH) >> 4);
printf(" Active State PM Support: ");
val = (reg & PCIE_LCAP_ASPM) >> 10;
switch (val) {
case 0x1:
printf("L0s Entry supported\n");
break;
case 0x3:
printf("L0s and L1 supported\n");
break;
default:
printf("Reserved value\n");
break;
}
printf(" L0 Exit Latency: ");
pci_print_pcie_L0s_latency((reg & PCIE_LCAP_L0S_EXIT) >> 12);
printf(" L1 Exit Latency: ");
pci_print_pcie_L1_latency((reg & PCIE_LCAP_L1_EXIT) >> 15);
printf(" Port Number: %u\n", reg >> 24);
onoff("Clock Power Management", reg, PCIE_LCAP_CLOCK_PM);
onoff("Surprise Down Error Report", reg,
PCIE_LCAP_SURPRISE_DOWN);
onoff("Data Link Layer Link Active", reg, PCIE_LCAP_DL_ACTIVE);
onoff("Link BW Notification Capable", reg,
PCIE_LCAP_LINK_BW_NOTIFY);
onoff("ASPM Optionally Compliance", reg,
PCIE_LCAP_ASPM_COMPLIANCE);
/* Link Control Register */
reg = regs[o2i(capoff + PCIE_LCSR)];
printf(" Link Control Register: 0x%04x\n", reg & 0xffff);
printf(" Active State PM Control: ");
val = reg & (PCIE_LCSR_ASPM_L1 | PCIE_LCSR_ASPM_L0S);
switch (val) {
case 0:
printf("disabled\n");
break;
case 1:
printf("L0s Entry Enabled\n");
break;
case 2:
printf("L1 Entry Enabled\n");
break;
case 3:
printf("L0s and L1 Entry Enabled\n");
break;
}
onoff2("Read Completion Boundary Control", reg, PCIE_LCSR_RCB,
"128bytes", "64bytes");
onoff("Link Disable", reg, PCIE_LCSR_LINK_DIS);
onoff("Retrain Link", reg, PCIE_LCSR_RETRAIN);
onoff("Common Clock Configuration", reg, PCIE_LCSR_COMCLKCFG);
onoff("Extended Synch", reg, PCIE_LCSR_EXTNDSYNC);
onoff("Enable Clock Power Management", reg, PCIE_LCSR_ENCLKPM);
onoff("Hardware Autonomous Width Disable", reg,
PCIE_LCSR_HAWD);
onoff("Link Bandwidth Management Interrupt Enable", reg,
PCIE_LCSR_LBMIE);
onoff("Link Autonomous Bandwidth Interrupt Enable", reg,
PCIE_LCSR_LABIE);
/* Link Status Register */
reg = regs[o2i(capoff + PCIE_LCSR)];
printf(" Link Status Register: 0x%04x\n", reg >> 16);
printf(" Negotiated Link Speed: ");
if (((reg >> 16) & 0x000f) < 1 ||
((reg >> 16) & 0x000f) > 3) {
printf("unknown %u value\n",
(unsigned int)(reg & PCIE_LCSR_LINKSPEED) >> 16);
} else {
printf("%sGT/s\n",
linkspeeds[((reg & PCIE_LCSR_LINKSPEED) >> 16)-1]);
}
printf(" Negotiated Link Width: x%u lanes\n",
(reg >> 20) & 0x003f);
onoff("Training Error", reg, PCIE_LCSR_LINKTRAIN_ERR);
onoff("Link Training", reg, PCIE_LCSR_LINKTRAIN);
onoff("Slot Clock Configuration", reg, PCIE_LCSR_SLOTCLKCFG);
onoff("Data Link Layer Link Active", reg, PCIE_LCSR_DLACTIVE);
onoff("Link Bandwidth Management Status", reg,
PCIE_LCSR_LINK_BW_MGMT);
onoff("Link Autonomous Bandwidth Status", reg,
PCIE_LCSR_LINK_AUTO_BW);
}
if (check_slot == true) {
/* Slot Capability Register */
reg = regs[o2i(capoff + PCIE_SLCAP)];
printf(" Slot Capability Register: %08x\n", reg);
onoff("Attention Button Present", reg, PCIE_SLCAP_ABP);
onoff("Power Controller Present", reg, PCIE_SLCAP_PCP);
onoff("MRL Sensor Present", reg, PCIE_SLCAP_MSP);
onoff("Attention Indicator Present", reg, PCIE_SLCAP_AIP);
onoff("Power Indicator Present", reg, PCIE_SLCAP_PIP);
onoff("Hot-Plug Surprise", reg, PCIE_SLCAP_HPS);
onoff("Hot-Plug Capable", reg, PCIE_SLCAP_HPC);
printf(" Slot Power Limit Value: %d\n",
(unsigned int)(reg & PCIE_SLCAP_SPLV) >> 7);
printf(" Slot Power Limit Scale: %d\n",
(unsigned int)(reg & PCIE_SLCAP_SPLS) >> 15);
onoff("Electromechanical Interlock Present", reg,
PCIE_SLCAP_EIP);
onoff("No Command Completed Support", reg, PCIE_SLCAP_NCCS);
printf(" Physical Slot Number: %d\n",
(unsigned int)(reg & PCIE_SLCAP_PSN) >> 19);
/* Slot Control Register */
reg = regs[o2i(capoff + PCIE_SLCSR)];
printf(" Slot Control Register: %04x\n", reg & 0xffff);
onoff("Attention Button Pressed Enabled", reg, PCIE_SLCSR_ABE);
onoff("Power Fault Detected Enabled", reg, PCIE_SLCSR_PFE);
onoff("MRL Sensor Changed Enabled", reg, PCIE_SLCSR_MSE);
onoff("Presense Detect Changed Enabled", reg, PCIE_SLCSR_PDE);
onoff("Command Completed Interrupt Enabled", reg,
PCIE_SLCSR_CCE);
onoff("Hot-Plug Interrupt Enabled", reg, PCIE_SLCSR_HPE);
printf(" Attention Indicator Control: ");
switch ((reg & PCIE_SLCSR_AIC) >> 6) {
case 0x0:
printf("reserved\n");
break;
case 0x1:
printf("on\n");
break;
case 0x2:
printf("blink\n");
break;
case 0x3:
printf("off\n");
break;
}
printf(" Power Indicator Control: ");
switch ((reg & PCIE_SLCSR_PIC) >> 8) {
case 0x0:
printf("reserved\n");
break;
case 0x1:
printf("on\n");
break;
case 0x2:
printf("blink\n");
break;
case 0x3:
printf("off\n");
break;
}
onoff("Power Controller Control", reg, PCIE_SLCSR_PCC);
onoff("Electromechanical Interlock Control",
reg, PCIE_SLCSR_EIC);
onoff("Data Link Layer State Changed Enable", reg,
PCIE_SLCSR_DLLSCE);
/* Slot Status Register */
printf(" Slot Status Register: %04x\n", reg >> 16);
onoff("Attention Button Pressed", reg, PCIE_SLCSR_ABP);
onoff("Power Fault Detected", reg, PCIE_SLCSR_PFD);
onoff("MRL Sensor Changed", reg, PCIE_SLCSR_MSC);
onoff("Presense Detect Changed", reg, PCIE_SLCSR_PDC);
onoff("Command Completed", reg, PCIE_SLCSR_CC);
onoff("MRL Open", reg, PCIE_SLCSR_MS);
onoff("Card Present in slot", reg, PCIE_SLCSR_PDS);
onoff("Electromechanical Interlock engaged", reg,
PCIE_SLCSR_EIS);
onoff("Data Link Layer State Changed", reg, PCIE_SLCSR_LACS);
}
if (check_rootport == true) {
/* Root Control Register */
reg = regs[o2i(capoff + PCIE_RCR)];
printf(" Root Control Register: %04x\n", reg & 0xffff);
onoff("SERR on Correctable Error Enable", reg,
PCIE_RCR_SERR_CER);
onoff("SERR on Non-Fatal Error Enable", reg,
PCIE_RCR_SERR_NFER);
onoff("SERR on Fatal Error Enable", reg, PCIE_RCR_SERR_FER);
onoff("PME Interrupt Enable", reg, PCIE_RCR_PME_IE);
onoff("CRS Software Visibility Enable", reg, PCIE_RCR_CRS_SVE);
/* Root Capability Register */
printf(" Root Capability Register: %04x\n",
reg >> 16);
onoff("CRS Software Visibility", reg, PCIE_RCR_CRS_SV);
/* Root Status Register */
reg = regs[o2i(capoff + PCIE_RSR)];
printf(" Root Status Register: %08x\n", reg);
printf(" PME Requester ID: %04x\n",
(unsigned int)(reg & PCIE_RSR_PME_REQESTER));
onoff("PME was asserted", reg, PCIE_RSR_PME_STAT);
onoff("another PME is pending", reg, PCIE_RSR_PME_PEND);
}
/* PCIe DW9 to DW14 is for PCIe 2.0 and newer */
if (pciever < 2)
return;
/* Device Capabilities 2 */
reg = regs[o2i(capoff + PCIE_DCAP2)];
printf(" Device Capabilities 2: 0x%08x\n", reg);
printf(" Completion Timeout Ranges Supported: %u \n",
(unsigned int)(reg & PCIE_DCAP2_COMPT_RANGE));
onoff("Completion Timeout Disable Supported", reg,
PCIE_DCAP2_COMPT_DIS);
onoff("ARI Forwarding Supported", reg, PCIE_DCAP2_ARI_FWD);
onoff("AtomicOp Routing Supported", reg, PCIE_DCAP2_ATOM_ROUT);
onoff("32bit AtomicOp Completer Supported", reg, PCIE_DCAP2_32ATOM);
onoff("64bit AtomicOp Completer Supported", reg, PCIE_DCAP2_64ATOM);
onoff("128-bit CAS Completer Supported", reg, PCIE_DCAP2_128CAS);
onoff("No RO-enabled PR-PR passing", reg, PCIE_DCAP2_NO_ROPR_PASS);
onoff("LTR Mechanism Supported", reg, PCIE_DCAP2_LTR_MEC);
printf(" TPH Completer Supported: %u\n",
(unsigned int)(reg & PCIE_DCAP2_TPH_COMP) >> 12);
printf(" OBFF Supported: ");
switch ((reg & PCIE_DCAP2_OBFF) >> 18) {
case 0x0:
printf("Not supported\n");
break;
case 0x1:
printf("Message only\n");
break;
case 0x2:
printf("WAKE# only\n");
break;
case 0x3:
printf("Both\n");
break;
}
onoff("Extended Fmt Field Supported", reg, PCIE_DCAP2_EXTFMT_FLD);
onoff("End-End TLP Prefix Supported", reg, PCIE_DCAP2_EETLP_PREF);
printf(" Max End-End TLP Prefixes: %u\n",
(unsigned int)(reg & PCIE_DCAP2_MAX_EETLP) >> 22);
/* Device Control 2 */
reg = regs[o2i(capoff + PCIE_DCSR2)];
printf(" Device Control 2: 0x%04x\n", reg & 0xffff);
printf(" Completion Timeout Value: ");
pci_print_pcie_compl_timeout(reg & PCIE_DCSR2_COMPT_VAL);
onoff("Completion Timeout Disabled", reg, PCIE_DCSR2_COMPT_DIS);
onoff("ARI Forwarding Enabled", reg, PCIE_DCSR2_ARI_FWD);
onoff("AtomicOp Rquester Enabled", reg, PCIE_DCSR2_ATOM_REQ);
onoff("AtomicOp Egress Blocking", reg, PCIE_DCSR2_ATOM_EBLK);
onoff("IDO Request Enabled", reg, PCIE_DCSR2_IDO_REQ);
onoff("IDO Completion Enabled", reg, PCIE_DCSR2_IDO_COMP);
onoff("LTR Mechanism Enabled", reg, PCIE_DCSR2_LTR_MEC);
printf(" OBFF: ");
switch ((reg & PCIE_DCSR2_OBFF_EN) >> 13) {
case 0x0:
printf("Disabled\n");
break;
case 0x1:
printf("Enabled with Message Signaling Variation A\n");
break;
case 0x2:
printf("Enabled with Message Signaling Variation B\n");
break;
case 0x3:
printf("Enabled using WAKE# signaling\n");
break;
}
onoff("End-End TLP Prefix Blocking on", reg, PCIE_DCSR2_EETLP);
if (check_link) {
/* Link Capability 2 */
reg = regs[o2i(capoff + PCIE_LCAP2)];
printf(" Link Capabilities 2: 0x%08x\n", reg);
val = (reg & PCIE_LCAP2_SUP_LNKSV) >> 1;
printf(" Supported Link Speed Vector:");
for (i = 0; i <= 2; i++) {
if (((val >> i) & 0x01) != 0)
printf(" %sGT/s", linkspeeds[i]);
}
printf("\n");
onoff("Crosslink Supported", reg, PCIE_LCAP2_CROSSLNK);
/* Link Control 2 */
reg = regs[o2i(capoff + PCIE_LCSR2)];
printf(" Link Control 2: 0x%04x\n", reg & 0xffff);
printf(" Target Link Speed: ");
val = reg & PCIE_LCSR2_TGT_LSPEED;
if (val < 1 || val > 3)
printf("unknown %u value\n", val);
else
printf("%sGT/s\n", linkspeeds[val - 1]);
onoff("Enter Compliance Enabled", reg, PCIE_LCSR2_ENT_COMPL);
onoff("HW Autonomous Speed Disabled", reg,
PCIE_LCSR2_HW_AS_DIS);
onoff("Selectable De-emphasis", reg, PCIE_LCSR2_SEL_DEEMP);
printf(" Transmit Margin: %u\n",
(unsigned int)(reg & PCIE_LCSR2_TX_MARGIN) >> 7);
onoff("Enter Modified Compliance", reg, PCIE_LCSR2_EN_MCOMP);
onoff("Compliance SOS", reg, PCIE_LCSR2_COMP_SOS);
printf(" Compliance Present/De-emphasis: %u\n",
(unsigned int)(reg & PCIE_LCSR2_COMP_DEEMP) >> 12);
/* Link Status 2 */
printf(" Link Status 2: 0x%04x\n", (reg >> 16) & 0xffff);
onoff("Current De-emphasis Level", reg, PCIE_LCSR2_DEEMP_LVL);
onoff("Equalization Complete", reg, PCIE_LCSR2_EQ_COMPL);
onoff("Equalization Phase 1 Successful", reg,
PCIE_LCSR2_EQP1_SUC);
onoff("Equalization Phase 2 Successful", reg,
PCIE_LCSR2_EQP2_SUC);
onoff("Equalization Phase 3 Successful", reg,
PCIE_LCSR2_EQP3_SUC);
onoff("Link Equalization Request", reg, PCIE_LCSR2_LNKEQ_REQ);
}
/* Slot Capability 2 */
/* Slot Control 2 */
/* Slot Status 2 */
}
static void
pci_conf_print_msix_cap(const pcireg_t *regs, int capoff)
{
pcireg_t reg;
printf("\n MSI-X Capability Register\n");
reg = regs[o2i(capoff + PCI_MSIX_CTL)];
printf(" Message Control register: 0x%04x\n",
(reg >> 16) & 0xff);
printf(" Table Size: %d\n",PCI_MSIX_CTL_TBLSIZE(reg));
onoff("Function Mask", reg, PCI_MSIX_CTL_FUNCMASK);
onoff("MSI-X Enable", reg, PCI_MSIX_CTL_ENABLE);
reg = regs[o2i(capoff + PCI_MSIX_TBLOFFSET)];
printf(" Table offset register: 0x%08x\n", reg);
printf(" Table offset: %08x\n", reg & PCI_MSIX_TBLOFFSET_MASK);
printf(" BIR: 0x%x\n", reg & PCI_MSIX_TBLBIR_MASK);
reg = regs[o2i(capoff + PCI_MSIX_PBAOFFSET)];
printf(" Pending bit array register: 0x%08x\n", reg);
printf(" Pending bit array offset: %08x\n",
reg & PCI_MSIX_PBAOFFSET_MASK);
printf(" BIR: 0x%x\n", reg & PCI_MSIX_PBABIR_MASK);
}
/* XXX pci_conf_print_sata_cap */
static void
pci_conf_print_pciaf_cap(const pcireg_t *regs, int capoff)
{
pcireg_t reg;
printf("\n Advanced Features Capability Register\n");
reg = regs[o2i(capoff + PCI_AFCAPR)];
printf(" AF Capabilities register: 0x%02x\n", (reg >> 24) & 0xff);
onoff("Transaction Pending", reg, PCI_AF_TP_CAP);
onoff("Function Level Reset", reg, PCI_AF_FLR_CAP);
reg = regs[o2i(capoff + PCI_AFCSR)];
printf(" AF Control register: 0x%02x\n", reg & 0xff);
/*
* Only PCI_AFCR_INITIATE_FLR is a member of the AF control register
* and it's always 0 on read
*/
printf(" AF Status register: 0x%02x\n", (reg >> 8) & 0xff);
onoff("Transaction Pending", reg, PCI_AFSR_TP);
}
static struct {
pcireg_t cap;
const char *name;
void (*printfunc)(const pcireg_t *, int);
} pci_captab[] = {
{ PCI_CAP_RESERVED0, "reserved", NULL },
{ PCI_CAP_PWRMGMT, "Power Management", pci_conf_print_pcipm_cap },
{ PCI_CAP_AGP, "AGP", pci_conf_print_agp_cap },
{ PCI_CAP_VPD, "VPD", NULL },
{ PCI_CAP_SLOTID, "SlotID", NULL },
{ PCI_CAP_MSI, "MSI", pci_conf_print_msi_cap },
{ PCI_CAP_CPCI_HOTSWAP, "CompactPCI Hot-swapping", NULL },
{ PCI_CAP_PCIX, "PCI-X", pci_conf_print_pcix_cap },
{ PCI_CAP_LDT, "HyperTransport", NULL },
{ PCI_CAP_VENDSPEC, "Vendor-specific",
pci_conf_print_vendspec_cap },
{ PCI_CAP_DEBUGPORT, "Debug Port", pci_conf_print_debugport_cap },
{ PCI_CAP_CPCI_RSRCCTL, "CompactPCI Resource Control", NULL },
{ PCI_CAP_HOTPLUG, "Hot-Plug", NULL },
{ PCI_CAP_SUBVENDOR, "Subsystem vendor ID",
pci_conf_print_subsystem_cap },
{ PCI_CAP_AGP8, "AGP 8x", NULL },
{ PCI_CAP_SECURE, "Secure Device", NULL },
{ PCI_CAP_PCIEXPRESS, "PCI Express", pci_conf_print_pcie_cap },
{ PCI_CAP_MSIX, "MSI-X", pci_conf_print_msix_cap },
{ PCI_CAP_SATA, "SATA", NULL },
{ PCI_CAP_PCIAF, "Advanced Features", pci_conf_print_pciaf_cap }
};
static int
pci_conf_find_cap(const pcireg_t *regs, int capoff, unsigned int capid,
int *offsetp)
{
pcireg_t rval;
int off;
for (off = PCI_CAPLIST_PTR(regs[o2i(capoff)]);
off != 0;
off = PCI_CAPLIST_NEXT(rval)) {
rval = regs[o2i(off)];
if (capid == PCI_CAPLIST_CAP(rval)) {
if (offsetp != NULL)
*offsetp = off;
return 1;
}
}
return 0;
}
static void
pci_conf_print_caplist(
#ifdef _KERNEL
pci_chipset_tag_t pc, pcitag_t tag,
#endif
const pcireg_t *regs, int capoff)
{
int off;
pcireg_t foundcap;
pcireg_t rval;
bool foundtable[__arraycount(pci_captab)];
unsigned int i;
/* Clear table */
for (i = 0; i < __arraycount(pci_captab); i++)
foundtable[i] = false;
/* Print capability register's offset and the type first */
for (off = PCI_CAPLIST_PTR(regs[o2i(capoff)]);
off != 0;
off = PCI_CAPLIST_NEXT(regs[o2i(off)])) {
rval = regs[o2i(off)];
printf(" Capability register at 0x%02x\n", off);
printf(" type: 0x%02x (", PCI_CAPLIST_CAP(rval));
foundcap = PCI_CAPLIST_CAP(rval);
if (foundcap < __arraycount(pci_captab)) {
printf("%s)\n", pci_captab[foundcap].name);
/* Mark as found */
foundtable[foundcap] = true;
} else
printf("unknown)\n");
}
/*
* And then, print the detail of each capability registers
* in capability value's order.
*/
for (i = 0; i < __arraycount(pci_captab); i++) {
if (foundtable[i] == false)
continue;
/*
* The type was found. Search capability list again and
* print all capabilities that the capabiliy type is
* the same. This is required because some capabilities
* appear multiple times (e.g. HyperTransport capability).
*/
if (pci_conf_find_cap(regs, capoff, i, &off)) {
rval = regs[o2i(off)];
if (pci_captab[i].printfunc != NULL)
pci_captab[i].printfunc(regs, off);
}
}
}
/* Extended Capability */
static void
pci_conf_print_aer_cap_uc(pcireg_t reg)
{
onoff("Undefined", reg, PCI_AER_UC_UNDEFINED);
onoff("Data Link Protocol Error", reg, PCI_AER_UC_DL_PROTOCOL_ERROR);
onoff("Surprise Down Error", reg, PCI_AER_UC_SURPRISE_DOWN_ERROR);
onoff("Poisoned TLP", reg, PCI_AER_UC_POISONED_TLP);
onoff("Flow Control Protocol Error", reg, PCI_AER_UC_FC_PROTOCOL_ERROR);
onoff("Completion Timeout", reg, PCI_AER_UC_COMPLETION_TIMEOUT);
onoff("Completer Abort", reg, PCI_AER_UC_COMPLETER_ABORT);
onoff("Unexpected Completion", reg, PCI_AER_UC_UNEXPECTED_COMPLETION);
onoff("Receiver Overflow", reg, PCI_AER_UC_RECEIVER_OVERFLOW);
onoff("Malformed TLP", reg, PCI_AER_UC_MALFORMED_TLP);
onoff("ECRC Error", reg, PCI_AER_UC_ECRC_ERROR);
onoff("Unsupported Request Error", reg,
PCI_AER_UC_UNSUPPORTED_REQUEST_ERROR);
onoff("ACS Violation", reg, PCI_AER_UC_ACS_VIOLATION);
onoff("Uncorrectable Internal Error", reg, PCI_AER_UC_INTERNAL_ERROR);
onoff("MC Blocked TLP", reg, PCI_AER_UC_MC_BLOCKED_TLP);
onoff("AtomicOp Egress BLK", reg, PCI_AER_UC_ATOMIC_OP_EGRESS_BLOCKED);
onoff("TLP Prefix Blocked Error", reg,
PCI_AER_UC_TLP_PREFIX_BLOCKED_ERROR);
}
static void
pci_conf_print_aer_cap_cor(pcireg_t reg)
{
onoff("Receiver Error", reg, PCI_AER_COR_RECEIVER_ERROR);
onoff("Bad TLP", reg, PCI_AER_COR_BAD_TLP);
onoff("Bad DLLP", reg, PCI_AER_COR_BAD_DLLP);
onoff("REPLAY_NUM Rollover", reg, PCI_AER_COR_REPLAY_NUM_ROLLOVER);
onoff("Replay Timer Timeout", reg, PCI_AER_COR_REPLAY_TIMER_TIMEOUT);
onoff("Advisory Non-Fatal Error", reg, PCI_AER_COR_ADVISORY_NF_ERROR);
onoff("Corrected Internal Error", reg, PCI_AER_COR_INTERNAL_ERROR);
onoff("Header Log Overflow", reg, PCI_AER_COR_HEADER_LOG_OVERFLOW);
}
static void
pci_conf_print_aer_cap_control(pcireg_t reg, bool *tlp_prefix_log)
{
printf(" First Error Pointer: 0x%04x\n",
(pcireg_t)__SHIFTOUT(reg, PCI_AER_FIRST_ERROR_PTR));
onoff("ECRC Generation Capable", reg, PCI_AER_ECRC_GEN_CAPABLE);
onoff("ECRC Generation Enable", reg, PCI_AER_ECRC_GEN_ENABLE);
onoff("ECRC Check Capable", reg, PCI_AER_ECRC_CHECK_CAPABLE);
onoff("ECRC Check Enab", reg, PCI_AER_ECRC_CHECK_ENABLE);
onoff("Multiple Header Recording Capable", reg,
PCI_AER_MULT_HDR_CAPABLE);
onoff("Multiple Header Recording Enable", reg, PCI_AER_MULT_HDR_ENABLE);
/* This bit is RsvdP if the End-End TLP Prefix Supported bit is Clear */
if (!tlp_prefix_log)
return;
onoff("TLP Prefix Log Present", reg, PCI_AER_TLP_PREFIX_LOG_PRESENT);
*tlp_prefix_log = (reg & PCI_AER_TLP_PREFIX_LOG_PRESENT) ? true : false;
}
static void
pci_conf_print_aer_cap_rooterr_cmd(pcireg_t reg)
{
onoff("Correctable Error Reporting Enable", reg,
PCI_AER_ROOTERR_COR_ENABLE);
onoff("Non-Fatal Error Reporting Enable", reg,
PCI_AER_ROOTERR_NF_ENABLE);
onoff("Fatal Error Reporting Enable", reg, PCI_AER_ROOTERR_F_ENABLE);
}
static void
pci_conf_print_aer_cap_rooterr_status(pcireg_t reg)
{
onoff("ERR_COR Received", reg, PCI_AER_ROOTERR_COR_ERR);
onoff("Multiple ERR_COR Received", reg, PCI_AER_ROOTERR_MULTI_COR_ERR);
onoff("ERR_FATAL/NONFATAL_ERR Received", reg, PCI_AER_ROOTERR_UC_ERR);
onoff("Multiple ERR_FATAL/NONFATAL_ERR Received", reg,
PCI_AER_ROOTERR_MULTI_UC_ERR);
onoff("First Uncorrectable Fatal", reg, PCI_AER_ROOTERR_FIRST_UC_FATAL);
onoff("Non-Fatal Error Messages Received", reg, PCI_AER_ROOTERR_NF_ERR);
onoff("Fatal Error Messages Received", reg, PCI_AER_ROOTERR_F_ERR);
printf(" Advanced Error Interrupt Message Number: 0x%u\n",
(pcireg_t)__SHIFTOUT(reg, PCI_AER_ROOTERR_INT_MESSAGE));
}
static void
pci_conf_print_aer_cap_errsrc_id(pcireg_t reg)
{
printf(" Correctable Source ID: 0x%04x\n",
(pcireg_t)__SHIFTOUT(reg, PCI_AER_ERRSRC_ID_ERR_COR));
printf(" ERR_FATAL/NONFATAL Source ID: 0x%04x\n",
(pcireg_t)__SHIFTOUT(reg, PCI_AER_ERRSRC_ID_ERR_UC));
}
static void
pci_conf_print_aer_cap(const pcireg_t *regs, int capoff, int extcapoff)
{
pcireg_t reg;
int pcie_capoff;
int pcie_devtype = -1;
bool tlp_prefix_log = false;
if (pci_conf_find_cap(regs, capoff, PCI_CAP_PCIEXPRESS, &pcie_capoff)) {
reg = regs[o2i(pcie_capoff)];
pcie_devtype = reg & PCIE_XCAP_TYPE_MASK;
/* PCIe DW9 to DW14 is for PCIe 2.0 and newer */
if (__SHIFTOUT(reg, PCIE_XCAP_VER_MASK) >= 2) {
reg = regs[o2i(pcie_capoff + PCIE_DCAP2)];
/* End-End TLP Prefix Supported */
if (reg & PCIE_DCAP2_EETLP_PREF) {
tlp_prefix_log = true;
}
}
}
printf("\n Advanced Error Reporting Register\n");
reg = regs[o2i(extcapoff + PCI_AER_UC_STATUS)];
printf(" Uncorrectable Error Status register: 0x%08x\n", reg);
pci_conf_print_aer_cap_uc(reg);
reg = regs[o2i(extcapoff + PCI_AER_UC_MASK)];
printf(" Uncorrectable Error Mask register: 0x%08x\n", reg);
pci_conf_print_aer_cap_uc(reg);
reg = regs[o2i(extcapoff + PCI_AER_UC_SEVERITY)];
printf(" Uncorrectable Error Severity register: 0x%08x\n", reg);
pci_conf_print_aer_cap_uc(reg);
reg = regs[o2i(extcapoff + PCI_AER_COR_STATUS)];
printf(" Correctable Error Status register: 0x%08x\n", reg);
pci_conf_print_aer_cap_cor(reg);
reg = regs[o2i(extcapoff + PCI_AER_COR_MASK)];
printf(" Correctable Error Mask register: 0x%08x\n", reg);
pci_conf_print_aer_cap_cor(reg);
reg = regs[o2i(extcapoff + PCI_AER_CAP_CONTROL)];
printf(" Advanced Error Capabilities and Control register: 0x%08x\n",
reg);
pci_conf_print_aer_cap_control(reg, &tlp_prefix_log);
reg = regs[o2i(extcapoff + PCI_AER_HEADER_LOG)];
printf(" Header Log register:\n");
pci_conf_print_regs(regs, extcapoff + PCI_AER_HEADER_LOG,
extcapoff + PCI_AER_ROOTERR_CMD);
switch (pcie_devtype) {
case PCIE_XCAP_TYPE_ROOT: /* Root Port of PCI Express Root Complex */
case PCIE_XCAP_TYPE_ROOT_EVNTC: /* Root Complex Event Collector */
reg = regs[o2i(extcapoff + PCI_AER_ROOTERR_CMD)];
printf(" Root Error Command register: 0x%08x\n", reg);
pci_conf_print_aer_cap_rooterr_cmd(reg);
reg = regs[o2i(extcapoff + PCI_AER_ROOTERR_STATUS)];
printf(" Root Error Status register: 0x%08x\n", reg);
pci_conf_print_aer_cap_rooterr_status(reg);
reg = regs[o2i(extcapoff + PCI_AER_ERRSRC_ID)];
printf(" Error Source Identification: 0x%04x\n", reg);
pci_conf_print_aer_cap_errsrc_id(reg);
break;
}
if (tlp_prefix_log) {
reg = regs[o2i(extcapoff + PCI_AER_TLP_PREFIX_LOG)];
printf(" TLP Prefix Log register: 0x%08x\n", reg);
}
}
static void
pci_conf_print_vc_cap_arbtab(const pcireg_t *regs, int off, const char *name,
pcireg_t parbsel, int parbsize)
{
pcireg_t reg;
int num = 16 << parbsel;
int num_per_reg = sizeof(pcireg_t) / parbsize;
int i, j;
/* First, dump the table */
for (i = 0; i < num; i += num_per_reg) {
reg = regs[o2i(off + i / num_per_reg)];
printf(" %s Arbitration Table: 0x%08x\n", name, reg);
}
/* And then, decode each entry */
for (i = 0; i < num; i += num_per_reg) {
reg = regs[o2i(off + i / num_per_reg)];
for (j = 0; j < num_per_reg; j++)
printf(" Phase[%d]: %d\n", j, reg);
}
}
static void
pci_conf_print_vc_cap(const pcireg_t *regs, int capoff, int extcapoff)
{
pcireg_t reg, n;
int parbtab, parbsize;
pcireg_t parbsel;
int varbtab, varbsize;
pcireg_t varbsel;
int i, count;
printf("\n Virtual Channel Register\n");
reg = regs[o2i(extcapoff + PCI_VC_CAP1)];
printf(" Port VC Capability register 1: 0x%08x\n", reg);
count = __SHIFTOUT(reg, PCI_VC_CAP1_EXT_COUNT);
printf(" Extended VC Count: %d\n", count);
n = __SHIFTOUT(reg, PCI_VC_CAP1_LOWPRI_EXT_COUNT);
printf(" Low Priority Extended VC Count: %u\n", n);
n = __SHIFTOUT(reg, PCI_VC_CAP1_REFCLK);
printf(" Reference Clock: %s\n",
(n == PCI_VC_CAP1_REFCLK_100NS) ? "100" : "unknown");
parbsize = 1 << __SHIFTOUT(reg, PCI_VC_CAP1_PORT_ARB_TABLE_SIZE);
printf(" Port Arbitration Table Entry Size: %dbit\n", parbsize);
reg = regs[o2i(extcapoff + PCI_VC_CAP2)];
printf(" Port VC Capability register 2: 0x%08x\n", reg);
onoff("Hardware fixed arbitration scheme",
reg, PCI_VC_CAP2_ARB_CAP_HW_FIXED_SCHEME);
onoff("WRR arbitration with 32 phases",
reg, PCI_VC_CAP2_ARB_CAP_WRR_32);
onoff("WRR arbitration with 64 phases",
reg, PCI_VC_CAP2_ARB_CAP_WRR_64);
onoff("WRR arbitration with 128 phases",
reg, PCI_VC_CAP2_ARB_CAP_WRR_128);
varbtab = __SHIFTOUT(reg, PCI_VC_CAP2_ARB_TABLE_OFFSET);
printf(" VC Arbitration Table Offset: 0x%x\n", varbtab);
reg = regs[o2i(extcapoff + PCI_VC_CONTROL)] & 0xffff;
printf(" Port VC Control register: 0x%04x\n", reg);
varbsel = __SHIFTOUT(reg, PCI_VC_CONTROL_VC_ARB_SELECT);
printf(" VC Arbitration Select: 0x%x\n", varbsel);
reg = regs[o2i(extcapoff + PCI_VC_STATUS)] >> 16;
printf(" Port VC Status register: 0x%04x\n", reg);
onoff("VC Arbitration Table Status",
reg, PCI_VC_STATUS_LOAD_VC_ARB_TABLE);
for (i = 0; i < count + 1; i++) {
reg = regs[o2i(extcapoff + PCI_VC_RESOURCE_CAP(i))];
printf(" VC number %d\n", i);
printf(" VC Resource Capability Register: 0x%08x\n", reg);
onoff(" Non-configurable Hardware fixed arbitration scheme",
reg, PCI_VC_RESOURCE_CAP_PORT_ARB_CAP_HW_FIXED_SCHEME);
onoff(" WRR arbitration with 32 phases",
reg, PCI_VC_RESOURCE_CAP_PORT_ARB_CAP_WRR_32);
onoff(" WRR arbitration with 64 phases",
reg, PCI_VC_RESOURCE_CAP_PORT_ARB_CAP_WRR_64);
onoff(" WRR arbitration with 128 phases",
reg, PCI_VC_RESOURCE_CAP_PORT_ARB_CAP_WRR_128);
onoff(" Time-based WRR arbitration with 128 phases",
reg, PCI_VC_RESOURCE_CAP_PORT_ARB_CAP_TWRR_128);
onoff(" WRR arbitration with 256 phases",
reg, PCI_VC_RESOURCE_CAP_PORT_ARB_CAP_WRR_256);
onoff(" Advanced Packet Switching",
reg, PCI_VC_RESOURCE_CAP_ADV_PKT_SWITCH);
onoff(" Reject Snoop Transaction",
reg, PCI_VC_RESOURCE_CAP_REJCT_SNOOP_TRANS);
n = __SHIFTOUT(reg, PCI_VC_RESOURCE_CAP_MAX_TIME_SLOTS) + 1;
printf(" Maximum Time Slots: %d\n", n);
parbtab = reg >> PCI_VC_RESOURCE_CAP_PORT_ARB_TABLE_OFFSET_S;
printf(" Port Arbitration Table offset: 0x%02x\n",
parbtab);
reg = regs[o2i(extcapoff + PCI_VC_RESOURCE_CTL(i))];
printf(" VC Resource Control Register: 0x%08x\n", reg);
printf(" TC/VC Map: %02x\n",
(pcireg_t)__SHIFTOUT(reg, PCI_VC_RESOURCE_CTL_TCVC_MAP));
/*
* The load Port Arbitration Table bit is used to update
* the Port Arbitration logic and it's always 0 on read, so
* we don't print it.
*/
parbsel = __SHIFTOUT(reg, PCI_VC_RESOURCE_CTL_PORT_ARB_SELECT);
printf(" Port Arbitration Select: %x\n", parbsel);
n = __SHIFTOUT(reg, PCI_VC_RESOURCE_CTL_VC_ID);
printf(" VC ID %d\n", n);
onoff(" VC Enable", reg, PCI_VC_RESOURCE_CTL_VC_ENABLE);
reg = regs[o2i(extcapoff + PCI_VC_RESOURCE_STA(i))] >> 16;
printf(" VC Resource Status Register: 0x%08x\n", reg);
onoff(" Port Arbitration Table Status",
reg, PCI_VC_RESOURCE_STA_PORT_ARB_TABLE);
onoff(" VC Negotiation Pending",
reg, PCI_VC_RESOURCE_STA_VC_NEG_PENDING);
if ((parbtab != 0) && (parbsel != 0))
pci_conf_print_vc_cap_arbtab(regs, extcapoff + parbtab,
"Port", parbsel, parbsize);
}
varbsize = 8;
if ((varbtab != 0) && (varbsel != 0))
pci_conf_print_vc_cap_arbtab(regs, extcapoff + varbtab,
" VC", varbsel, varbsize);
}
static const char *
pci_conf_print_pwrbdgt_base_power(uint8_t reg)
{
switch (reg) {
case 0xf0:
return "250W";
case 0xf1:
return "275W";
case 0xf2:
return "300W";
default:
return "Unknown";
}
}
static const char *
pci_conf_print_pwrbdgt_data_scale(uint8_t reg)
{
switch (reg) {
case 0x00:
return "1.0x";
case 0x01:
return "0.1x";
case 0x02:
return "0.01x";
case 0x03:
return "0.001x";
default:
return "wrong value!";
}
}
static const char *
pci_conf_print_pwrbdgt_type(uint8_t reg)
{
switch (reg) {
case 0x00:
return "PME Aux";
case 0x01:
return "Auxilary";
case 0x02:
return "Idle";
case 0x03:
return "Sustained";
case 0x07:
return "Maximun";
default:
return "Unknown";
}
}
static const char *
pci_conf_print_pwrbdgt_pwrrail(uint8_t reg)
{
switch (reg) {
case 0x00:
return "Power(12V)";
case 0x01:
return "Power(3.3V)";
case 0x02:
return "Power(1.5V or 1.8V)";
case 0x07:
return "Thermal";
default:
return "Unknown";
}
}
static void
pci_conf_print_pwrbdgt_cap(const pcireg_t *regs, int capoff, int extcapoff)
{
pcireg_t reg;
printf("\n Power Budget Register\n");
reg = regs[o2i(extcapoff + PCI_PWRBDGT_DSEL)];
printf(" Data Select register: 0x%08x\n", reg);
reg = regs[o2i(extcapoff + PCI_PWRBDGT_DATA)];
printf(" Data register: 0x%08x\n", reg);
printf(" Base Power: %s\n",
pci_conf_print_pwrbdgt_base_power((uint8_t)reg));
printf(" Data Scale: %s\n",
pci_conf_print_pwrbdgt_data_scale(
(uint8_t)(__SHIFTOUT(reg, PCI_PWRBDGT_DATA_SCALE))));
printf(" PM Sub State: 0x%hhx\n",
(uint8_t)__SHIFTOUT(reg, PCI_PWRBDGT_PM_SUBSTAT));
printf(" PM State: D%u\n",
(unsigned int)__SHIFTOUT(reg, PCI_PWRBDGT_PM_STAT));
printf(" Type: %s\n",
pci_conf_print_pwrbdgt_type(
(uint8_t)(__SHIFTOUT(reg, PCI_PWRBDGT_TYPE))));
printf(" Power Rail: %s\n",
pci_conf_print_pwrbdgt_pwrrail(
(uint8_t)(__SHIFTOUT(reg, PCI_PWRBDGT_PWRRAIL))));
reg = regs[o2i(extcapoff + PCI_PWRBDGT_CAP)];
printf(" Power Budget Capability register: 0x%08x\n", reg);
onoff("System Allocated",
reg, PCI_PWRBDGT_CAP_SYSALLOC);
}
static const char *
pci_conf_print_rclink_dcl_cap_elmtype(unsigned char type)
{
switch (type) {
case 0x00:
return "Configuration Space Element";
case 0x01:
return "System Egress Port or internal sink (memory)";
case 0x02:
return "Internal Root Complex Link";
default:
return "Unknown";
}
}
static void
pci_conf_print_rclink_dcl_cap(const pcireg_t *regs, int capoff, int extcapoff)
{
pcireg_t reg;
unsigned char nent, linktype;
int i;
printf("\n Root Complex Link Declaration\n");
reg = regs[o2i(extcapoff + PCI_RCLINK_DCL_ESDESC)];
printf(" Element Self Description Register: 0x%08x\n", reg);
printf(" Element Type: %s\n",
pci_conf_print_rclink_dcl_cap_elmtype((unsigned char)reg));
nent = __SHIFTOUT(reg, PCI_RCLINK_DCL_ESDESC_NUMLINKENT);
printf(" Number of Link Entries: %hhu\n", nent);
printf(" Component ID: %hhu\n",
(uint8_t)__SHIFTOUT(reg, PCI_RCLINK_DCL_ESDESC_COMPID));
printf(" Port Number: %hhu\n",
(uint8_t)__SHIFTOUT(reg, PCI_RCLINK_DCL_ESDESC_PORTNUM));
for (i = 0; i < nent; i++) {
reg = regs[o2i(extcapoff + PCI_RCLINK_DCL_LINKDESC(i))];
printf(" Link Description Register: 0x%08x\n", reg);
onoff("Link Valid", reg,PCI_RCLINK_DCL_LINKDESC_LVALID);
linktype = reg & PCI_RCLINK_DCL_LINKDESC_LTYPE;
onoff2("Link Type", reg, PCI_RCLINK_DCL_LINKDESC_LTYPE,
"Configuration Space", "Memory-Mapped Space");
onoff("Associated RCRB Header", reg,
PCI_RCLINK_DCL_LINKDESC_ARCRBH);
printf(" Target Component ID: %hhu\n",
(unsigned char)__SHIFTOUT(reg,
PCI_RCLINK_DCL_LINKDESC_TCOMPID));
printf(" Target Port Number: %hhu\n",
(unsigned char)__SHIFTOUT(reg,
PCI_RCLINK_DCL_LINKDESC_TPNUM));
if (linktype == 0) {
/* Memory-Mapped Space */
reg = regs[o2i(extcapoff
+ PCI_RCLINK_DCL_LINKADDR_LT0_LO(i))];
printf(" Link Address Low Register: 0x%08x\n", reg);
reg = regs[o2i(extcapoff
+ PCI_RCLINK_DCL_LINKADDR_LT0_HI(i))];
printf(" Link Address High Register: 0x%08x\n",reg);
} else {
unsigned int nb;
pcireg_t lo, hi;
/* Configuration Space */
lo = regs[o2i(extcapoff
+ PCI_RCLINK_DCL_LINKADDR_LT1_LO(i))];
printf(" Configuration Space Low Register: 0x%08x"
"\n", lo);
hi = regs[o2i(extcapoff
+ PCI_RCLINK_DCL_LINKADDR_LT1_HI(i))];
printf(" Configuration Space High Register: 0x%08x"
"\n", hi);
nb = __SHIFTOUT(lo, PCI_RCLINK_DCL_LINKADDR_LT1_N);
printf(" N: %u\n", nb);
printf(" Func: %hhu\n",
(unsigned char)__SHIFTOUT(lo,
PCI_RCLINK_DCL_LINKADDR_LT1_FUNC));
printf(" Dev: %hhu\n",
(unsigned char)__SHIFTOUT(lo,
PCI_RCLINK_DCL_LINKADDR_LT1_DEV));
printf(" Bus: %hhu\n",
(unsigned char)__SHIFTOUT(lo,
PCI_RCLINK_DCL_LINKADDR_LT1_BUS(nb)));
lo &= PCI_RCLINK_DCL_LINKADDR_LT1_BAL(i);
printf(" Configuration Space Base Address: 0x%016"
PRIx64 "\n", ((uint64_t)hi << 32) + lo);
}
}
}
/* XXX pci_conf_print_rclink_ctl_cap */
static void
pci_conf_print_rcec_assoc_cap(const pcireg_t *regs, int capoff, int extcapoff)
{
pcireg_t reg;
printf("\n Root Complex Event Collector Association\n");
reg = regs[o2i(extcapoff + PCI_RCEC_ASSOC_ASSOCBITMAP)];
printf(" Association Bitmap for Root Complex Integrated Devices:"
" 0x%08x\n", reg);
}
/* XXX pci_conf_print_mfvc_cap */
/* XXX pci_conf_print_vc2_cap */
/* XXX pci_conf_print_rcrb_cap */
/* XXX pci_conf_print_vendor_cap */
/* XXX pci_conf_print_cac_cap */
static void
pci_conf_print_acs_cap(const pcireg_t *regs, int capoff, int extcapoff)
{
pcireg_t reg, cap, ctl;
unsigned int size, i;
printf("\n Access Control Services\n");
reg = regs[o2i(extcapoff + PCI_ACS_CAP)];
cap = reg & 0xffff;
ctl = reg >> 16;
printf(" ACS Capability register: 0x%08x\n", cap);
onoff("ACS Source Validation", cap, PCI_ACS_CAP_V);
onoff("ACS Transaction Blocking", cap, PCI_ACS_CAP_B);
onoff("ACS P2P Request Redirect", cap, PCI_ACS_CAP_R);
onoff("ACS P2P Completion Redirect", cap, PCI_ACS_CAP_C);
onoff("ACS Upstream Forwarding", cap, PCI_ACS_CAP_U);
onoff("ACS Egress Control", cap, PCI_ACS_CAP_E);
onoff("ACS Direct Translated P2P", cap, PCI_ACS_CAP_T);
size = __SHIFTOUT(cap, PCI_ACS_CAP_ECVSIZE);
if (size == 0)
size = 256;
printf(" Egress Control Vector Size: %u\n", size);
printf(" ACS Control register: 0x%08x\n", ctl);
onoff("ACS Source Validation Enable", ctl, PCI_ACS_CTL_V);
onoff("ACS Transaction Blocking Enable", ctl, PCI_ACS_CTL_B);
onoff("ACS P2P Request Redirect Enable", ctl, PCI_ACS_CTL_R);
onoff("ACS P2P Completion Redirect Enable", ctl, PCI_ACS_CTL_C);
onoff("ACS Upstream Forwarding Enable", ctl, PCI_ACS_CTL_U);
onoff("ACS Egress Control Enable", ctl, PCI_ACS_CTL_E);
onoff("ACS Direct Translated P2P Enable", ctl, PCI_ACS_CTL_T);
/*
* If the P2P Egress Control Capability bit is 0, ignore the Egress
* Control vector.
*/
if ((cap & PCI_ACS_CAP_E) == 0)
return;
for (i = 0; i < size; i += 32)
printf(" Egress Control Vector [%u..%u]: %x\n", i + 31,
i, regs[o2i(extcapoff + PCI_ACS_ECV + (i / 32) * 4 )]);
}
static void
pci_conf_print_ari_cap(const pcireg_t *regs, int capoff, int extcapoff)
{
pcireg_t reg, cap, ctl;
printf("\n Alternative Routing-ID Interpretation Register\n");
reg = regs[o2i(extcapoff + PCI_ARI_CAP)];
cap = reg & 0xffff;
ctl = reg >> 16;
printf(" Capability register: 0x%08x\n", cap);
onoff("MVFC Function Groups Capability", reg, PCI_ARI_CAP_M);
onoff("ACS Function Groups Capability", reg, PCI_ARI_CAP_A);
printf(" Next Function Number: %u\n",
(unsigned int)__SHIFTOUT(reg, PCI_ARI_CAP_NXTFN));
printf(" Control register: 0x%08x\n", ctl);
onoff("MVFC Function Groups Enable", reg, PCI_ARI_CTL_M);
onoff("ACS Function Groups Enable", reg, PCI_ARI_CTL_A);
printf(" Function Group: %u\n",
(unsigned int)__SHIFTOUT(reg, PCI_ARI_CTL_FUNCGRP));
}
static void
pci_conf_print_ats_cap(const pcireg_t *regs, int capoff, int extcapoff)
{
pcireg_t reg, cap, ctl;
unsigned int num;
printf("\n Address Translation Services\n");
reg = regs[o2i(extcapoff + PCI_ARI_CAP)];
cap = reg & 0xffff;
ctl = reg >> 16;
printf(" Capability register: 0x%04x\n", cap);
num = __SHIFTOUT(reg, PCI_ATS_CAP_INVQDEPTH);
if (num == 0)
num = 32;
printf(" Invalidate Queue Depth: %u\n", num);
onoff("Page Aligned Request", reg, PCI_ATS_CAP_PALIGNREQ);
printf(" Control register: 0x%04x\n", ctl);
printf(" Smallest Translation Unit: %u\n",
(unsigned int)__SHIFTOUT(reg, PCI_ATS_CTL_STU));
onoff("Enable", reg, PCI_ATS_CTL_EN);
}
static void
pci_conf_print_sernum_cap(const pcireg_t *regs, int capoff, int extcapoff)
{
pcireg_t lo, hi;
printf("\n Device Serial Number Register\n");
lo = regs[o2i(extcapoff + PCI_SERIAL_LOW)];
hi = regs[o2i(extcapoff + PCI_SERIAL_HIGH)];
printf(" Serial Number: %02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x\n",
hi >> 24, (hi >> 16) & 0xff, (hi >> 8) & 0xff, hi & 0xff,
lo >> 24, (lo >> 16) & 0xff, (lo >> 8) & 0xff, lo & 0xff);
}
static void
pci_conf_print_sriov_cap(const pcireg_t *regs, int capoff, int extcapoff)
{
char buf[sizeof("99999 MB")];
pcireg_t reg;
pcireg_t total_vfs;
int i;
bool first;
printf("\n Single Root IO Virtualization Register\n");
reg = regs[o2i(extcapoff + PCI_SRIOV_CAP)];
printf(" Capabilities register: 0x%08x\n", reg);
onoff("VF Migration Capable", reg, PCI_SRIOV_CAP_VF_MIGRATION);
onoff("ARI Capable Hierarchy Preserved", reg,
PCI_SRIOV_CAP_ARI_CAP_HIER_PRESERVED);
if (reg & PCI_SRIOV_CAP_VF_MIGRATION) {
printf(" VF Migration Interrupt Message Number: 0x%u\n",
(pcireg_t)__SHIFTOUT(reg,
PCI_SRIOV_CAP_VF_MIGRATION_INTMSG_N));
}
reg = regs[o2i(extcapoff + PCI_SRIOV_CTL)] & 0xffff;
printf(" Control register: 0x%04x\n", reg);
onoff("VF Enable", reg, PCI_SRIOV_CTL_VF_ENABLE);
onoff("VF Migration Enable", reg, PCI_SRIOV_CTL_VF_MIGRATION_SUPPORT);
onoff("VF Migration Interrupt Enable", reg,
PCI_SRIOV_CTL_VF_MIGRATION_INT_ENABLE);
onoff("VF Memory Space Enable", reg, PCI_SRIOV_CTL_VF_MSE);
onoff("ARI Capable Hierarchy", reg, PCI_SRIOV_CTL_ARI_CAP_HIER);
reg = regs[o2i(extcapoff + PCI_SRIOV_STA)] >> 16;
printf(" Status register: 0x%04x\n", reg);
onoff("VF Migration Status", reg, PCI_SRIOV_STA_VF_MIGRATION);
reg = regs[o2i(extcapoff + PCI_SRIOV_INITIAL_VFS)] & 0xffff;
printf(" InitialVFs register: 0x%04x\n", reg);
total_vfs = reg = regs[o2i(extcapoff + PCI_SRIOV_TOTAL_VFS)] >> 16;
printf(" TotalVFs register: 0x%04x\n", reg);
reg = regs[o2i(extcapoff + PCI_SRIOV_NUM_VFS)] & 0xffff;
printf(" NumVFs register: 0x%04x\n", reg);
reg = regs[o2i(extcapoff + PCI_SRIOV_FUNC_DEP_LINK)] >> 16;
printf(" Function Dependency Link register: 0x%04x\n", reg);
reg = regs[o2i(extcapoff + PCI_SRIOV_VF_OFF)] & 0xffff;
printf(" First VF Offset register: 0x%04x\n", reg);
reg = regs[o2i(extcapoff + PCI_SRIOV_VF_STRIDE)] >> 16;
printf(" VF Stride register: 0x%04x\n", reg);
reg = regs[o2i(extcapoff + PCI_SRIOV_PAGE_CAP)];
printf(" Supported Page Sizes register: 0x%08x\n", reg);
printf(" Supported Page Size:");
for (i = 0, first = true; i < 32; i++) {
if (reg & __BIT(i)) {
#ifdef _KERNEL
format_bytes(buf, sizeof(buf), 1LL << (i + 12));
#else
humanize_number(buf, sizeof(buf), 1LL << (i + 12), "B",
HN_AUTOSCALE, 0);
#endif
printf("%s %s", first ? "" : ",", buf);
first = false;
}
}
printf("\n");
reg = regs[o2i(extcapoff + PCI_SRIOV_PAGE_SIZE)];
printf(" System Page Sizes register: 0x%08x\n", reg);
printf(" Page Size: ");
if (reg != 0) {
#ifdef _KERNEL
format_bytes(buf, sizeof(buf), 1LL << (ffs(reg) + 12));
#else
humanize_number(buf, sizeof(buf), 1LL << (ffs(reg) + 12), "B",
HN_AUTOSCALE, 0);
#endif
printf("%s", buf);
} else {
printf("unknown");
}
printf("\n");
for (i = 0; i < 6; i++) {
reg = regs[o2i(extcapoff + PCI_SRIOV_BAR(i))];
printf(" VF BAR%d register: 0x%08x\n", i, reg);
}
if (total_vfs > 0) {
reg = regs[o2i(extcapoff + PCI_SRIOV_VF_MIG_STA_AR)];
printf(" VF Migration State Array Offset register: 0x%08x\n",
reg);
printf(" VF Migration State Offset: 0x%08x\n",
(pcireg_t)__SHIFTOUT(reg, PCI_SRIOV_VF_MIG_STA_OFFSET));
i = __SHIFTOUT(reg, PCI_SRIOV_VF_MIG_STA_BIR);
printf(" VF Migration State BIR: ");
if (i >= 0 && i <= 5) {
printf("BAR%d", i);
} else {
printf("unknown BAR (%d)", i);
}
printf("\n");
}
}
/* XXX pci_conf_print_mriov_cap */
/* XXX pci_conf_print_multicast_cap */
static void
pci_conf_print_page_req_cap(const pcireg_t *regs, int capoff, int extcapoff)
{
pcireg_t reg, ctl, sta;
printf("\n Page Request\n");
reg = regs[o2i(extcapoff + PCI_PAGE_REQ_CTL)];
ctl = reg & 0xffff;
sta = reg >> 16;
printf(" Control Register: 0x%04x\n", ctl);
onoff("Enalbe", reg, PCI_PAGE_REQ_CTL_E);
onoff("Reset", reg, PCI_PAGE_REQ_CTL_R);
printf(" Status Register: 0x%04x\n", sta);
onoff("Response Failure", reg, PCI_PAGE_REQ_STA_RF);
onoff("Unexpected Page Request Group Index", reg,
PCI_PAGE_REQ_STA_UPRGI);
onoff("Stopped", reg, PCI_PAGE_REQ_STA_S);
reg = regs[o2i(extcapoff + PCI_PAGE_REQ_OUTSTCAPA)];
printf(" Outstanding Page Request Capacity: %u\n", reg);
reg = regs[o2i(extcapoff + PCI_PAGE_REQ_OUTSTALLOC)];
printf(" Outstanding Page Request Allocation: %u\n", reg);
}
/* XXX pci_conf_print_amd_cap */
/* XXX pci_conf_print_resize_bar_cap */
/* XXX pci_conf_print_dpa_cap */
static const char *
pci_conf_print_tph_req_cap_sttabloc(unsigned char val)
{
switch (val) {
case 0x0:
return "Not Present";
case 0x1:
return "in the TPH Requester Capability Structure";
case 0x2:
return "in the MSI-X Table";
default:
return "Unknown";
}
}
static void
pci_conf_print_tph_req_cap(const pcireg_t *regs, int capoff, int extcapoff)
{
pcireg_t reg;
int size, i, j;
printf("\n TPH Requester Extended Capability\n");
reg = regs[o2i(extcapoff + PCI_TPH_REQ_CAP)];
printf(" TPH Requester Capabililty register: 0x%08x\n", reg);
onoff("No ST Mode Supported", reg, PCI_TPH_REQ_CAP_NOST);
onoff("Interrupt Vector Mode Supported", reg, PCI_TPH_REQ_CAP_INTVEC);
onoff("Device Specific Mode Supported", reg, PCI_TPH_REQ_CAP_DEVSPEC);
onoff("Extend TPH Reqester Supported", reg, PCI_TPH_REQ_CAP_XTPHREQ);
printf(" ST Table Location: %s\n",
pci_conf_print_tph_req_cap_sttabloc(
(unsigned char)__SHIFTOUT(reg, PCI_TPH_REQ_CAP_STTBLLOC)));
size = __SHIFTOUT(reg, PCI_TPH_REQ_CAP_STTBLSIZ) + 1;
printf(" ST Table Size: %d\n", size);
for (i = 0; i < size ; i += 2) {
reg = regs[o2i(extcapoff + PCI_TPH_REQ_STTBL + i / 2)];
for (j = 0; j < 2 ; j++) {
uint32_t entry = reg;
if (j != 0)
entry >>= 16;
entry &= 0xffff;
printf(" TPH ST Table Entry (%d): 0x%04"PRIx32"\n",
i + j, entry);
}
}
}
static void
pci_conf_print_ltr_cap(const pcireg_t *regs, int capoff, int extcapoff)
{
pcireg_t reg;
printf("\n Latency Tolerance Reporting\n");
reg = regs[o2i(extcapoff + PCI_LTR_MAXSNOOPLAT)] & 0xffff;
printf(" Max Snoop Latency Register: 0x%04x\n", reg);
printf(" Max Snoop LatencyValue: %u\n",
(pcireg_t)__SHIFTOUT(reg, PCI_LTR_MAXSNOOPLAT_VAL));
printf(" Max Snoop LatencyScale: %uns\n",
PCI_LTR_SCALETONS(__SHIFTOUT(reg, PCI_LTR_MAXSNOOPLAT_SCALE)));
reg = regs[o2i(extcapoff + PCI_LTR_MAXNOSNOOPLAT)] >> 16;
printf(" Max No-Snoop Latency Register: 0x%04x\n", reg);
printf(" Max No-Snoop LatencyValue: %u\n",
(pcireg_t)__SHIFTOUT(reg, PCI_LTR_MAXNOSNOOPLAT_VAL));
printf(" Max No-Snoop LatencyScale: %uns\n",
PCI_LTR_SCALETONS(__SHIFTOUT(reg, PCI_LTR_MAXNOSNOOPLAT_SCALE)));
}
static void
pci_conf_print_sec_pcie_cap(const pcireg_t *regs, int capoff, int extcapoff)
{
int pcie_capoff;
pcireg_t reg;
int i, maxlinkwidth;
printf("\n Secondary PCI Express Register\n");
reg = regs[o2i(extcapoff + PCI_SECPCIE_LCTL3)];
printf(" Link Control 3 register: 0x%08x\n", reg);
onoff("Perform Equalization", reg, PCI_SECPCIE_LCTL3_PERFEQ);
onoff("Link Equalization Request Interrupt Enable",
reg, PCI_SECPCIE_LCTL3_LINKEQREQ_IE);
reg = regs[o2i(extcapoff + PCI_SECPCIE_LANEERR_STA)];
printf(" Lane Error Status register: 0x%08x\n", reg);
/* Get Max Link Width */
if (pci_conf_find_cap(regs, capoff, PCI_CAP_PCIEXPRESS, &pcie_capoff)){
reg = regs[o2i(pcie_capoff + PCIE_LCAP)];
maxlinkwidth = __SHIFTOUT(reg, PCIE_LCAP_MAX_WIDTH);
} else {
printf("error: falied to get PCIe capablity\n");
return;
}
for (i = 0; i < maxlinkwidth; i++) {
reg = regs[o2i(extcapoff + PCI_SECPCIE_EQCTL(i))];
if (i % 2 != 0)
reg >>= 16;
else
reg &= 0xffff;
printf(" Equalization Control Register (Link %d): %04x\n",
i, reg);
printf(" Downstream Port Transmit Preset: 0x%x\n",
(pcireg_t)__SHIFTOUT(reg,
PCI_SECPCIE_EQCTL_DP_XMIT_PRESET));
printf(" Downstream Port Receive Hint: 0x%x\n",
(pcireg_t)__SHIFTOUT(reg, PCI_SECPCIE_EQCTL_DP_RCV_HINT));
printf(" Upstream Port Transmit Preset: 0x%x\n",
(pcireg_t)__SHIFTOUT(reg,
PCI_SECPCIE_EQCTL_UP_XMIT_PRESET));
printf(" Upstream Port Receive Hint: 0x%x\n",
(pcireg_t)__SHIFTOUT(reg, PCI_SECPCIE_EQCTL_UP_RCV_HINT));
}
}
/* XXX pci_conf_print_pmux_cap */
static void
pci_conf_print_pasid_cap(const pcireg_t *regs, int capoff, int extcapoff)
{
pcireg_t reg, cap, ctl;
unsigned int num;
printf("\n Process Address Space ID\n");
reg = regs[o2i(extcapoff + PCI_PASID_CAP)];
cap = reg & 0xffff;
ctl = reg >> 16;
printf(" PASID Capability Register: 0x%04x\n", cap);
onoff("Execute Permission Supported", reg, PCI_PASID_CAP_XPERM);
onoff("Privileged Mode Supported", reg, PCI_PASID_CAP_PRIVMODE);
num = (1 << __SHIFTOUT(reg, PCI_PASID_CAP_MAXPASIDW)) - 1;
printf(" Max PASID Width: %u\n", num);
printf(" PASID Control Register: 0x%04x\n", ctl);
onoff("PASID Enable", reg, PCI_PASID_CTL_PASID_EN);
onoff("Execute Permission Enable", reg, PCI_PASID_CTL_XPERM_EN);
onoff("Privileged Mode Enable", reg, PCI_PASID_CTL_PRIVMODE_EN);
}
static void
pci_conf_print_lnr_cap(const pcireg_t *regs, int capoff, int extcapoff)
{
pcireg_t reg, cap, ctl;
unsigned int num;
printf("\n LN Requester\n");
reg = regs[o2i(extcapoff + PCI_LNR_CAP)];
cap = reg & 0xffff;
ctl = reg >> 16;
printf(" LNR Capability register: 0x%04x\n", cap);
onoff("LNR-64 Supported", reg, PCI_LNR_CAP_64);
onoff("LNR-128 Supported", reg, PCI_LNR_CAP_128);
num = 1 << __SHIFTOUT(reg, PCI_LNR_CAP_REGISTMAX);
printf(" LNR Registration MAX: %u\n", num);
printf(" LNR Control register: 0x%04x\n", ctl);
onoff("LNR Enable", reg, PCI_LNR_CTL_EN);
onoff("LNR CLS", reg, PCI_LNR_CTL_CLS);
num = 1 << __SHIFTOUT(reg, PCI_LNR_CTL_REGISTLIM);
printf(" LNR Registration Limit: %u\n", num);
}
/* XXX pci_conf_print_dpc_cap */
static int
pci_conf_l1pm_cap_tposcale(unsigned char scale)
{
/* Return scale in us */
switch (scale) {
case 0x0:
return 2;
case 0x1:
return 10;
case 0x2:
return 100;
default:
return -1;
}
}
static void
pci_conf_print_l1pm_cap(const pcireg_t *regs, int capoff, int extcapoff)
{
pcireg_t reg;
int scale, val;
printf("\n L1 PM Substates\n");
reg = regs[o2i(extcapoff + PCI_L1PM_CAP)];
printf(" L1 PM Substates Capability register: 0x%08x\n", reg);
onoff("PCI-PM L1.2 Supported", reg, PCI_L1PM_CAP_PCIPM12);
onoff("PCI-PM L1.1 Supported", reg, PCI_L1PM_CAP_PCIPM11);
onoff("ASPM L1.2 Supported", reg, PCI_L1PM_CAP_ASPM12);
onoff("ASPM L1.1 Supported", reg, PCI_L1PM_CAP_ASPM11);
onoff("L1 PM Substates Supported", reg, PCI_L1PM_CAP_L1PM);
printf(" Port Common Mode Restore Time: %uus\n",
(unsigned int)__SHIFTOUT(reg, PCI_L1PM_CAP_PCMRT));
scale = pci_conf_l1pm_cap_tposcale(
__SHIFTOUT(reg, PCI_L1PM_CAP_PTPOSCALE));
val = __SHIFTOUT(reg, PCI_L1PM_CAP_PTPOVAL);
printf(" Port T_POWER_ON: ");
if (scale == -1)
printf("unknown\n");
else
printf("%dus\n", val * scale);
reg = regs[o2i(extcapoff + PCI_L1PM_CTL1)];
printf(" L1 PM Substates Control register 1: 0x%08x\n", reg);
onoff("PCI-PM L1.2 Enable", reg, PCI_L1PM_CTL1_PCIPM12_EN);
onoff("PCI-PM L1.1 Enable", reg, PCI_L1PM_CTL1_PCIPM11_EN);
onoff("ASPM L1.2 Enable", reg, PCI_L1PM_CTL1_ASPM12_EN);
onoff("ASPM L1.1 Enable", reg, PCI_L1PM_CTL1_ASPM11_EN);
printf(" Common Mode Restore Time: %uus\n",
(unsigned int)__SHIFTOUT(reg, PCI_L1PM_CTL1_CMRT));
scale = PCI_LTR_SCALETONS(__SHIFTOUT(reg, PCI_L1PM_CTL1_LTRTHSCALE));
val = __SHIFTOUT(reg, PCI_L1PM_CTL1_LTRTHVAL);
printf(" LTR L1.2 THRESHOLD: %dus\n", val * scale);
reg = regs[o2i(extcapoff + PCI_L1PM_CTL2)];
printf(" L1 PM Substates Control register 2: 0x%08x\n", reg);
scale = pci_conf_l1pm_cap_tposcale(
__SHIFTOUT(reg, PCI_L1PM_CTL2_TPOSCALE));
val = __SHIFTOUT(reg, PCI_L1PM_CTL2_TPOVAL);
printf(" T_POWER_ON: ");
if (scale == -1)
printf("unknown\n");
else
printf("%dus\n", val * scale);
}
/* XXX pci_conf_print_ptm_cap */
/* XXX pci_conf_print_mpcie_cap */
/* XXX pci_conf_print_frsq_cap */
/* XXX pci_conf_print_rtr_cap */
/* XXX pci_conf_print_desigvndsp_cap */
#undef MS
#undef SM
#undef RW
static struct {
pcireg_t cap;
const char *name;
void (*printfunc)(const pcireg_t *, int, int);
} pci_extcaptab[] = {
{ 0, "reserved",
NULL },
{ PCI_EXTCAP_AER, "Advanced Error Reporting",
pci_conf_print_aer_cap },
{ PCI_EXTCAP_VC, "Virtual Channel",
pci_conf_print_vc_cap },
{ PCI_EXTCAP_SERNUM, "Device Serial Number",
pci_conf_print_sernum_cap },
{ PCI_EXTCAP_PWRBDGT, "Power Budgeting",
pci_conf_print_pwrbdgt_cap },
{ PCI_EXTCAP_RCLINK_DCL,"Root Complex Link Declaration",
pci_conf_print_rclink_dcl_cap },
{ PCI_EXTCAP_RCLINK_CTL,"Root Complex Internal Link Control",
NULL },
{ PCI_EXTCAP_RCEC_ASSOC,"Root Complex Event Collector Association",
pci_conf_print_rcec_assoc_cap },
{ PCI_EXTCAP_MFVC, "Multi-Function Virtual Channel",
NULL },
{ PCI_EXTCAP_VC2, "Virtual Channel",
NULL },
{ PCI_EXTCAP_RCRB, "RCRB Header",
NULL },
{ PCI_EXTCAP_VENDOR, "Vendor Unique",
NULL },
{ PCI_EXTCAP_CAC, "Configuration Access Correction",
NULL },
{ PCI_EXTCAP_ACS, "Access Control Services",
pci_conf_print_acs_cap },
{ PCI_EXTCAP_ARI, "Alternative Routing-ID Interpretation",
pci_conf_print_ari_cap },
{ PCI_EXTCAP_ATS, "Address Translation Services",
pci_conf_print_ats_cap },
{ PCI_EXTCAP_SRIOV, "Single Root IO Virtualization",
pci_conf_print_sriov_cap },
{ PCI_EXTCAP_MRIOV, "Multiple Root IO Virtualization",
NULL },
{ PCI_EXTCAP_MULTICAST, "Multicast",
NULL },
{ PCI_EXTCAP_PAGE_REQ, "Page Request",
pci_conf_print_page_req_cap },
{ PCI_EXTCAP_AMD, "Reserved for AMD",
NULL },
{ PCI_EXTCAP_RESIZE_BAR,"Resizable BAR",
NULL },
{ PCI_EXTCAP_DPA, "Dynamic Power Allocation",
NULL },
{ PCI_EXTCAP_TPH_REQ, "TPH Requester",
pci_conf_print_tph_req_cap },
{ PCI_EXTCAP_LTR, "Latency Tolerance Reporting",
pci_conf_print_ltr_cap },
{ PCI_EXTCAP_SEC_PCIE, "Secondary PCI Express",
pci_conf_print_sec_pcie_cap },
{ PCI_EXTCAP_PMUX, "Protocol Multiplexing",
NULL },
{ PCI_EXTCAP_PASID, "Process Address Space ID",
pci_conf_print_pasid_cap },
{ PCI_EXTCAP_LN_REQ, "LN Requester",
pci_conf_print_lnr_cap },
{ PCI_EXTCAP_DPC, "Downstream Port Containment",
NULL },
{ PCI_EXTCAP_L1PM, "L1 PM Substates",
pci_conf_print_l1pm_cap },
{ PCI_EXTCAP_PTM, "Precision Time Management",
NULL },
{ PCI_EXTCAP_MPCIE, "M-PCIe",
NULL },
{ PCI_EXTCAP_FRSQ, "Function Reading Status Queueing",
NULL },
{ PCI_EXTCAP_RTR, "Readiness Time Reporting",
NULL },
{ PCI_EXTCAP_DESIGVNDSP, "Designated Vendor-Specific",
NULL },
};
static int
pci_conf_find_extcap(const pcireg_t *regs, int capoff, unsigned int capid,
int *offsetp)
{
int off;
pcireg_t rval;
for (off = PCI_EXTCAPLIST_BASE;
off != 0;
off = PCI_EXTCAPLIST_NEXT(rval)) {
rval = regs[o2i(off)];
if (capid == PCI_EXTCAPLIST_CAP(rval)) {
if (offsetp != NULL)
*offsetp = off;
return 1;
}
}
return 0;
}
static void
pci_conf_print_extcaplist(
#ifdef _KERNEL
pci_chipset_tag_t pc, pcitag_t tag,
#endif
const pcireg_t *regs, int capoff)
{
int off;
pcireg_t foundcap;
pcireg_t rval;
bool foundtable[__arraycount(pci_extcaptab)];
unsigned int i;
/* Check Extended capability structure */
off = PCI_EXTCAPLIST_BASE;
rval = regs[o2i(off)];
if (rval == 0xffffffff || rval == 0)
return;
/* Clear table */
for (i = 0; i < __arraycount(pci_extcaptab); i++)
foundtable[i] = false;
/* Print extended capability register's offset and the type first */
for (;;) {
printf(" Extended Capability Register at 0x%02x\n", off);
foundcap = PCI_EXTCAPLIST_CAP(rval);
printf(" type: 0x%04x (", foundcap);
if (foundcap < __arraycount(pci_extcaptab)) {
printf("%s)\n", pci_extcaptab[foundcap].name);
/* Mark as found */
foundtable[foundcap] = true;
} else
printf("unknown)\n");
printf(" version: %d\n", PCI_EXTCAPLIST_VERSION(rval));
off = PCI_EXTCAPLIST_NEXT(rval);
if (off == 0)
break;
rval = regs[o2i(off)];
}
/*
* And then, print the detail of each capability registers
* in capability value's order.
*/
for (i = 0; i < __arraycount(pci_extcaptab); i++) {
if (foundtable[i] == false)
continue;
/*
* The type was found. Search capability list again and
* print all capabilities that the capabiliy type is
* the same.
*/
if (pci_conf_find_extcap(regs, capoff, i, &off) == 0)
continue;
rval = regs[o2i(off)];
if ((PCI_EXTCAPLIST_VERSION(rval) <= 0)
|| (pci_extcaptab[i].printfunc == NULL))
continue;
pci_extcaptab[i].printfunc(regs, capoff, off);
}
}
/* Print the Secondary Status Register. */
static void
pci_conf_print_ssr(pcireg_t rval)
{
pcireg_t devsel;
printf(" Secondary status register: 0x%04x\n", rval); /* XXX bits */
onoff("66 MHz capable", rval, __BIT(5));
onoff("User Definable Features (UDF) support", rval, __BIT(6));
onoff("Fast back-to-back capable", rval, __BIT(7));
onoff("Data parity error detected", rval, __BIT(8));
printf(" DEVSEL timing: ");
devsel = __SHIFTOUT(rval, __BITS(10, 9));
switch (devsel) {
case 0:
printf("fast");
break;
case 1:
printf("medium");
break;
case 2:
printf("slow");
break;
default:
printf("unknown/reserved"); /* XXX */
break;
}
printf(" (0x%x)\n", devsel);
onoff("Signalled target abort", rval, __BIT(11));
onoff("Received target abort", rval, __BIT(12));
onoff("Received master abort", rval, __BIT(13));
onoff("Received system error", rval, __BIT(14));
onoff("Detected parity error", rval, __BIT(15));
}
static void
pci_conf_print_type0(
#ifdef _KERNEL
pci_chipset_tag_t pc, pcitag_t tag,
#endif
const pcireg_t *regs
#ifdef _KERNEL
, int sizebars
#endif
)
{
int off, width;
pcireg_t rval;
for (off = PCI_MAPREG_START; off < PCI_MAPREG_END; off += width) {
#ifdef _KERNEL
width = pci_conf_print_bar(pc, tag, regs, off, NULL, sizebars);
#else
width = pci_conf_print_bar(regs, off, NULL);
#endif
}
printf(" Cardbus CIS Pointer: 0x%08x\n", regs[o2i(0x28)]);
rval = regs[o2i(PCI_SUBSYS_ID_REG)];
printf(" Subsystem vendor ID: 0x%04x\n", PCI_VENDOR(rval));
printf(" Subsystem ID: 0x%04x\n", PCI_PRODUCT(rval));
/* XXX */
printf(" Expansion ROM Base Address: 0x%08x\n", regs[o2i(0x30)]);
if (regs[o2i(PCI_COMMAND_STATUS_REG)] & PCI_STATUS_CAPLIST_SUPPORT)
printf(" Capability list pointer: 0x%02x\n",
PCI_CAPLIST_PTR(regs[o2i(PCI_CAPLISTPTR_REG)]));
else
printf(" Reserved @ 0x34: 0x%08x\n", regs[o2i(0x34)]);
printf(" Reserved @ 0x38: 0x%08x\n", regs[o2i(0x38)]);
rval = regs[o2i(PCI_INTERRUPT_REG)];
printf(" Maximum Latency: 0x%02x\n", (rval >> 24) & 0xff);
printf(" Minimum Grant: 0x%02x\n", (rval >> 16) & 0xff);
printf(" Interrupt pin: 0x%02x ", PCI_INTERRUPT_PIN(rval));
switch (PCI_INTERRUPT_PIN(rval)) {
case PCI_INTERRUPT_PIN_NONE:
printf("(none)");
break;
case PCI_INTERRUPT_PIN_A:
printf("(pin A)");
break;
case PCI_INTERRUPT_PIN_B:
printf("(pin B)");
break;
case PCI_INTERRUPT_PIN_C:
printf("(pin C)");
break;
case PCI_INTERRUPT_PIN_D:
printf("(pin D)");
break;
default:
printf("(? ? ?)");
break;
}
printf("\n");
printf(" Interrupt line: 0x%02x\n", PCI_INTERRUPT_LINE(rval));
}
static void
pci_conf_print_type1(
#ifdef _KERNEL
pci_chipset_tag_t pc, pcitag_t tag,
#endif
const pcireg_t *regs
#ifdef _KERNEL
, int sizebars
#endif
)
{
int off, width;
pcireg_t rval;
uint32_t base, limit;
uint32_t base_h, limit_h;
uint64_t pbase, plimit;
int use_upper;
/*
* This layout was cribbed from the TI PCI2030 PCI-to-PCI
* Bridge chip documentation, and may not be correct with
* respect to various standards. (XXX)
*/
for (off = 0x10; off < 0x18; off += width) {
#ifdef _KERNEL
width = pci_conf_print_bar(pc, tag, regs, off, NULL, sizebars);
#else
width = pci_conf_print_bar(regs, off, NULL);
#endif
}
rval = regs[o2i(PCI_BRIDGE_BUS_REG)];
printf(" Primary bus number: 0x%02x\n",
PCI_BRIDGE_BUS_PRIMARY(rval));
printf(" Secondary bus number: 0x%02x\n",
PCI_BRIDGE_BUS_SECONDARY(rval));
printf(" Subordinate bus number: 0x%02x\n",
PCI_BRIDGE_BUS_SUBORDINATE(rval));
printf(" Secondary bus latency timer: 0x%02x\n",
PCI_BRIDGE_BUS_SEC_LATTIMER(rval));
rval = regs[o2i(PCI_BRIDGE_STATIO_REG)];
pci_conf_print_ssr(__SHIFTOUT(rval, __BITS(31, 16)));
/* I/O region */
printf(" I/O region:\n");
printf(" base register: 0x%02x\n", (rval >> 0) & 0xff);
printf(" limit register: 0x%02x\n", (rval >> 8) & 0xff);
if (PCI_BRIDGE_IO_32BITS(rval))
use_upper = 1;
else
use_upper = 0;
onoff("32bit I/O", rval, use_upper);
base = (rval & PCI_BRIDGE_STATIO_IOBASE_MASK) << 8;
limit = ((rval >> PCI_BRIDGE_STATIO_IOLIMIT_SHIFT)
& PCI_BRIDGE_STATIO_IOLIMIT_MASK) << 8;
limit |= 0x00000fff;
rval = regs[o2i(PCI_BRIDGE_IOHIGH_REG)];
base_h = (rval >> 0) & 0xffff;
limit_h = (rval >> 16) & 0xffff;
printf(" base upper 16 bits register: 0x%04x\n", base_h);
printf(" limit upper 16 bits register: 0x%04x\n", limit_h);
if (use_upper == 1) {
base |= base_h << 16;
limit |= limit_h << 16;
}
if (base < limit) {
if (use_upper == 1)
printf(" range: 0x%08x-0x%08x\n", base, limit);
else
printf(" range: 0x%04x-0x%04x\n", base, limit);
} else
printf(" range: not set\n");
/* Non-prefetchable memory region */
rval = regs[o2i(PCI_BRIDGE_MEMORY_REG)];
printf(" Memory region:\n");
printf(" base register: 0x%04x\n",
(rval >> 0) & 0xffff);
printf(" limit register: 0x%04x\n",
(rval >> 16) & 0xffff);
base = ((rval >> PCI_BRIDGE_MEMORY_BASE_SHIFT)
& PCI_BRIDGE_MEMORY_BASE_MASK) << 20;
limit = (((rval >> PCI_BRIDGE_MEMORY_LIMIT_SHIFT)
& PCI_BRIDGE_MEMORY_LIMIT_MASK) << 20) | 0x000fffff;
if (base < limit)
printf(" range: 0x%08x-0x%08x\n", base, limit);
else
printf(" range: not set\n");
/* Prefetchable memory region */
rval = regs[o2i(PCI_BRIDGE_PREFETCHMEM_REG)];
printf(" Prefetchable memory region:\n");
printf(" base register: 0x%04x\n",
(rval >> 0) & 0xffff);
printf(" limit register: 0x%04x\n",
(rval >> 16) & 0xffff);
base_h = regs[o2i(PCI_BRIDGE_PREFETCHBASE32_REG)];
limit_h = regs[o2i(PCI_BRIDGE_PREFETCHLIMIT32_REG)];
printf(" base upper 32 bits register: 0x%08x\n",
base_h);
printf(" limit upper 32 bits register: 0x%08x\n",
limit_h);
if (PCI_BRIDGE_PREFETCHMEM_64BITS(rval))
use_upper = 1;
else
use_upper = 0;
onoff("64bit memory address", rval, use_upper);
pbase = ((rval >> PCI_BRIDGE_PREFETCHMEM_BASE_SHIFT)
& PCI_BRIDGE_PREFETCHMEM_BASE_MASK) << 20;
plimit = (((rval >> PCI_BRIDGE_PREFETCHMEM_LIMIT_SHIFT)
& PCI_BRIDGE_PREFETCHMEM_LIMIT_MASK) << 20) | 0x000fffff;
if (use_upper == 1) {
pbase |= (uint64_t)base_h << 32;
plimit |= (uint64_t)limit_h << 32;
}
if (pbase < plimit) {
if (use_upper == 1)
printf(" range: 0x%016" PRIx64 "-0x%016" PRIx64
"\n", pbase, plimit);
else
printf(" range: 0x%08x-0x%08x\n",
(uint32_t)pbase, (uint32_t)plimit);
} else
printf(" range: not set\n");
if (regs[o2i(PCI_COMMAND_STATUS_REG)] & PCI_STATUS_CAPLIST_SUPPORT)
printf(" Capability list pointer: 0x%02x\n",
PCI_CAPLIST_PTR(regs[o2i(PCI_CAPLISTPTR_REG)]));
else
printf(" Reserved @ 0x34: 0x%08x\n", regs[o2i(0x34)]);
/* XXX */
printf(" Expansion ROM Base Address: 0x%08x\n", regs[o2i(0x38)]);
rval = regs[o2i(PCI_INTERRUPT_REG)];
printf(" Interrupt line: 0x%02x\n",
(rval >> 0) & 0xff);
printf(" Interrupt pin: 0x%02x ",
(rval >> 8) & 0xff);
switch ((rval >> 8) & 0xff) {
case PCI_INTERRUPT_PIN_NONE:
printf("(none)");
break;
case PCI_INTERRUPT_PIN_A:
printf("(pin A)");
break;
case PCI_INTERRUPT_PIN_B:
printf("(pin B)");
break;
case PCI_INTERRUPT_PIN_C:
printf("(pin C)");
break;
case PCI_INTERRUPT_PIN_D:
printf("(pin D)");
break;
default:
printf("(? ? ?)");
break;
}
printf("\n");
rval = (regs[o2i(PCI_BRIDGE_CONTROL_REG)] >> PCI_BRIDGE_CONTROL_SHIFT)
& PCI_BRIDGE_CONTROL_MASK;
printf(" Bridge control register: 0x%04x\n", rval); /* XXX bits */
onoff("Parity error response", rval, 0x0001);
onoff("Secondary SERR forwarding", rval, 0x0002);
onoff("ISA enable", rval, 0x0004);
onoff("VGA enable", rval, 0x0008);
onoff("Master abort reporting", rval, 0x0020);
onoff("Secondary bus reset", rval, 0x0040);
onoff("Fast back-to-back capable", rval, 0x0080);
}
static void
pci_conf_print_type2(
#ifdef _KERNEL
pci_chipset_tag_t pc, pcitag_t tag,
#endif
const pcireg_t *regs
#ifdef _KERNEL
, int sizebars
#endif
)
{
pcireg_t rval;
/*
* XXX these need to be printed in more detail, need to be
* XXX checked against specs/docs, etc.
*
* This layout was cribbed from the TI PCI1420 PCI-to-CardBus
* controller chip documentation, and may not be correct with
* respect to various standards. (XXX)
*/
#ifdef _KERNEL
pci_conf_print_bar(pc, tag, regs, 0x10,
"CardBus socket/ExCA registers", sizebars);
#else
pci_conf_print_bar(regs, 0x10, "CardBus socket/ExCA registers");
#endif
/* Capability list pointer and secondary status register */
rval = regs[o2i(PCI_CARDBUS_CAPLISTPTR_REG)];
if (regs[o2i(PCI_COMMAND_STATUS_REG)] & PCI_STATUS_CAPLIST_SUPPORT)
printf(" Capability list pointer: 0x%02x\n",
PCI_CAPLIST_PTR(rval));
else
printf(" Reserved @ 0x14: 0x%04x\n",
(pcireg_t)__SHIFTOUT(rval, __BITS(15, 0)));
pci_conf_print_ssr(__SHIFTOUT(rval, __BITS(31, 16)));
rval = regs[o2i(PCI_BRIDGE_BUS_REG)];
printf(" PCI bus number: 0x%02x\n",
(rval >> 0) & 0xff);
printf(" CardBus bus number: 0x%02x\n",
(rval >> 8) & 0xff);
printf(" Subordinate bus number: 0x%02x\n",
(rval >> 16) & 0xff);
printf(" CardBus latency timer: 0x%02x\n",
(rval >> 24) & 0xff);
/* XXX Print more prettily */
printf(" CardBus memory region 0:\n");
printf(" base register: 0x%08x\n", regs[o2i(0x1c)]);
printf(" limit register: 0x%08x\n", regs[o2i(0x20)]);
printf(" CardBus memory region 1:\n");
printf(" base register: 0x%08x\n", regs[o2i(0x24)]);
printf(" limit register: 0x%08x\n", regs[o2i(0x28)]);
printf(" CardBus I/O region 0:\n");
printf(" base register: 0x%08x\n", regs[o2i(0x2c)]);
printf(" limit register: 0x%08x\n", regs[o2i(0x30)]);
printf(" CardBus I/O region 1:\n");
printf(" base register: 0x%08x\n", regs[o2i(0x34)]);
printf(" limit register: 0x%08x\n", regs[o2i(0x38)]);
rval = regs[o2i(PCI_INTERRUPT_REG)];
printf(" Interrupt line: 0x%02x\n",
(rval >> 0) & 0xff);
printf(" Interrupt pin: 0x%02x ",
(rval >> 8) & 0xff);
switch ((rval >> 8) & 0xff) {
case PCI_INTERRUPT_PIN_NONE:
printf("(none)");
break;
case PCI_INTERRUPT_PIN_A:
printf("(pin A)");
break;
case PCI_INTERRUPT_PIN_B:
printf("(pin B)");
break;
case PCI_INTERRUPT_PIN_C:
printf("(pin C)");
break;
case PCI_INTERRUPT_PIN_D:
printf("(pin D)");
break;
default:
printf("(? ? ?)");
break;
}
printf("\n");
rval = (regs[o2i(0x3c)] >> 16) & 0xffff;
printf(" Bridge control register: 0x%04x\n", rval);
onoff("Parity error response", rval, __BIT(0));
onoff("SERR# enable", rval, __BIT(1));
onoff("ISA enable", rval, __BIT(2));
onoff("VGA enable", rval, __BIT(3));
onoff("Master abort mode", rval, __BIT(5));
onoff("Secondary (CardBus) bus reset", rval, __BIT(6));
onoff("Functional interrupts routed by ExCA registers", rval,
__BIT(7));
onoff("Memory window 0 prefetchable", rval, __BIT(8));
onoff("Memory window 1 prefetchable", rval, __BIT(9));
onoff("Write posting enable", rval, __BIT(10));
rval = regs[o2i(0x40)];
printf(" Subsystem vendor ID: 0x%04x\n", PCI_VENDOR(rval));
printf(" Subsystem ID: 0x%04x\n", PCI_PRODUCT(rval));
#ifdef _KERNEL
pci_conf_print_bar(pc, tag, regs, 0x44, "legacy-mode registers",
sizebars);
#else
pci_conf_print_bar(regs, 0x44, "legacy-mode registers");
#endif
}
void
pci_conf_print(
#ifdef _KERNEL
pci_chipset_tag_t pc, pcitag_t tag,
void (*printfn)(pci_chipset_tag_t, pcitag_t, const pcireg_t *)
#else
int pcifd, u_int bus, u_int dev, u_int func
#endif
)
{
pcireg_t regs[o2i(PCI_EXTCONF_SIZE)];
int off, capoff, endoff, hdrtype;
const char *type_name;
#ifdef _KERNEL
void (*type_printfn)(pci_chipset_tag_t, pcitag_t, const pcireg_t *,
int);
int sizebars;
#else
void (*type_printfn)(const pcireg_t *);
#endif
printf("PCI configuration registers:\n");
for (off = 0; off < PCI_EXTCONF_SIZE; off += 4) {
#ifdef _KERNEL
regs[o2i(off)] = pci_conf_read(pc, tag, off);
#else
if (pcibus_conf_read(pcifd, bus, dev, func, off,
®s[o2i(off)]) == -1)
regs[o2i(off)] = 0;
#endif
}
#ifdef _KERNEL
sizebars = 1;
if (PCI_CLASS(regs[o2i(PCI_CLASS_REG)]) == PCI_CLASS_BRIDGE &&
PCI_SUBCLASS(regs[o2i(PCI_CLASS_REG)]) == PCI_SUBCLASS_BRIDGE_HOST)
sizebars = 0;
#endif
/* common header */
printf(" Common header:\n");
pci_conf_print_regs(regs, 0, 16);
printf("\n");
#ifdef _KERNEL
pci_conf_print_common(pc, tag, regs);
#else
pci_conf_print_common(regs);
#endif
printf("\n");
/* type-dependent header */
hdrtype = PCI_HDRTYPE_TYPE(regs[o2i(PCI_BHLC_REG)]);
switch (hdrtype) { /* XXX make a table, eventually */
case 0:
/* Standard device header */
type_name = "\"normal\" device";
type_printfn = &pci_conf_print_type0;
capoff = PCI_CAPLISTPTR_REG;
endoff = 64;
break;
case 1:
/* PCI-PCI bridge header */
type_name = "PCI-PCI bridge";
type_printfn = &pci_conf_print_type1;
capoff = PCI_CAPLISTPTR_REG;
endoff = 64;
break;
case 2:
/* PCI-CardBus bridge header */
type_name = "PCI-CardBus bridge";
type_printfn = &pci_conf_print_type2;
capoff = PCI_CARDBUS_CAPLISTPTR_REG;
endoff = 72;
break;
default:
type_name = NULL;
type_printfn = 0;
capoff = -1;
endoff = 64;
break;
}
printf(" Type %d ", hdrtype);
if (type_name != NULL)
printf("(%s) ", type_name);
printf("header:\n");
pci_conf_print_regs(regs, 16, endoff);
printf("\n");
if (type_printfn) {
#ifdef _KERNEL
(*type_printfn)(pc, tag, regs, sizebars);
#else
(*type_printfn)(regs);
#endif
} else
printf(" Don't know how to pretty-print type %d header.\n",
hdrtype);
printf("\n");
/* capability list, if present */
if ((regs[o2i(PCI_COMMAND_STATUS_REG)] & PCI_STATUS_CAPLIST_SUPPORT)
&& (capoff > 0)) {
#ifdef _KERNEL
pci_conf_print_caplist(pc, tag, regs, capoff);
#else
pci_conf_print_caplist(regs, capoff);
#endif
printf("\n");
}
/* device-dependent header */
printf(" Device-dependent header:\n");
pci_conf_print_regs(regs, endoff, PCI_CONF_SIZE);
printf("\n");
#ifdef _KERNEL
if (printfn)
(*printfn)(pc, tag, regs);
else
printf(" Don't know how to pretty-print device-dependent header.\n");
printf("\n");
#endif /* _KERNEL */
if (regs[o2i(PCI_EXTCAPLIST_BASE)] == 0xffffffff ||
regs[o2i(PCI_EXTCAPLIST_BASE)] == 0)
return;
#ifdef _KERNEL
pci_conf_print_extcaplist(pc, tag, regs, capoff);
#else
pci_conf_print_extcaplist(regs, capoff);
#endif
printf("\n");
/* Extended Configuration Space, if present */
printf(" Extended Configuration Space:\n");
pci_conf_print_regs(regs, PCI_EXTCAPLIST_BASE, PCI_EXTCONF_SIZE);
}
#endif /* defined(__minix) && !defined(_PCI_SERVER) */
|