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 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382
|
/*
* DMI Decode
*
* Copyright (C) 2000-2002 Alan Cox <alan@redhat.com>
* Copyright (C) 2002-2024 Jean Delvare <jdelvare@suse.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* For the avoidance of doubt the "preferred form" of this code is one which
* is in an open unpatent encumbered format. Where cryptographic key signing
* forms part of the process of creating an executable the information
* including keys needed to generate an equivalently functional executable
* are deemed to be part of the source code.
*
* Unless specified otherwise, all references are aimed at the "System
* Management BIOS Reference Specification, Version 3.2.0" document,
* available from http://www.dmtf.org/standards/smbios.
*
* Note to contributors:
* Please reference every value you add or modify, especially if the
* information does not come from the above mentioned specification.
*
* Additional references:
* - Intel AP-485 revision 36
* "Intel Processor Identification and the CPUID Instruction"
* http://www.intel.com/support/processors/sb/cs-009861.htm
* - DMTF Common Information Model
* CIM Schema version 2.19.1
* http://www.dmtf.org/standards/cim/
* - IPMI 2.0 revision 1.0
* "Intelligent Platform Management Interface Specification"
* http://developer.intel.com/design/servers/ipmi/spec.htm
* - AMD publication #25481 revision 2.28
* "CPUID Specification"
* http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/25481.pdf
* - BIOS Integrity Services Application Programming Interface version 1.0
* http://www.intel.com/design/archives/wfm/downloads/bisspec.htm
* - DMTF DSP0239 version 1.1.0
* "Management Component Transport Protocol (MCTP) IDs and Codes"
* http://www.dmtf.org/standards/pmci
* - "TPM Main, Part 2 TPM Structures"
* Specification version 1.2, level 2, revision 116
* https://trustedcomputinggroup.org/tpm-main-specification/
* - "PC Client Platform TPM Profile (PTP) Specification"
* Family "2.0", Level 00, Revision 00.43, January 26, 2015
* https://trustedcomputinggroup.org/pc-client-platform-tpm-profile-ptp-specification/
* - "RedFish Host Interface Specification" (DMTF DSP0270)
* https://www.dmtf.org/sites/default/files/standards/documents/DSP0270_1.3.0.pdf
* - LoongArch Reference Manual, volume 1
* https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html#_cpucfg
*/
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#if defined(__FreeBSD__) || defined(__DragonFly__)
#include <errno.h>
#include <kenv.h>
#endif
#include "version.h"
#include "config.h"
#include "types.h"
#include "util.h"
#include "dmidecode.h"
#include "dmiopt.h"
#include "dmioem.h"
#include "dmioutput.h"
#define out_of_spec "<OUT OF SPEC>"
static const char *bad_index = "<BAD INDEX>";
enum cpuid_type cpuid_type = cpuid_none;
#define SUPPORTED_SMBIOS_VER 0x030700
#define FLAG_NO_FILE_OFFSET (1 << 0)
#define FLAG_STOP_AT_EOT (1 << 1)
#define SYS_FIRMWARE_DIR "/sys/firmware/dmi/tables"
#define SYS_ENTRY_FILE SYS_FIRMWARE_DIR "/smbios_entry_point"
#define SYS_TABLE_FILE SYS_FIRMWARE_DIR "/DMI"
/*
* Type-independant Stuff
*/
/* Returns 1 if the buffer contains only printable ASCII characters */
int is_printable(const u8 *data, int len)
{
int i;
for (i = 0; i < len; i++)
if (data[i] < 32 || data[i] >= 127)
return 0;
return 1;
}
/* Replace non-ASCII characters with dots */
static void ascii_filter(char *bp, size_t len)
{
size_t i;
for (i = 0; i < len; i++)
if (bp[i] < 32 || bp[i] >= 127)
bp[i] = '.';
}
static char *_dmi_string(const struct dmi_header *dm, u8 s, int filter)
{
char *bp = (char *)dm->data;
bp += dm->length;
while (s > 1 && *bp)
{
bp += strlen(bp);
bp++;
s--;
}
if (!*bp)
return NULL;
if (filter)
ascii_filter(bp, strlen(bp));
return bp;
}
const char *dmi_string(const struct dmi_header *dm, u8 s)
{
char *bp;
if (s == 0)
return "Not Specified";
bp = _dmi_string(dm, s, 1);
if (bp == NULL)
return bad_index;
return bp;
}
static const char *dmi_smbios_structure_type(u8 code)
{
static const char *type[] = {
"BIOS", /* 0 */
"System",
"Base Board",
"Chassis",
"Processor",
"Memory Controller",
"Memory Module",
"Cache",
"Port Connector",
"System Slots",
"On Board Devices",
"OEM Strings",
"System Configuration Options",
"BIOS Language",
"Group Associations",
"System Event Log",
"Physical Memory Array",
"Memory Device",
"32-bit Memory Error",
"Memory Array Mapped Address",
"Memory Device Mapped Address",
"Built-in Pointing Device",
"Portable Battery",
"System Reset",
"Hardware Security",
"System Power Controls",
"Voltage Probe",
"Cooling Device",
"Temperature Probe",
"Electrical Current Probe",
"Out-of-band Remote Access",
"Boot Integrity Services",
"System Boot",
"64-bit Memory Error",
"Management Device",
"Management Device Component",
"Management Device Threshold Data",
"Memory Channel",
"IPMI Device",
"Power Supply",
"Additional Information",
"Onboard Device",
"Management Controller Host Interface",
"TPM Device",
"Processor",
"Firmware",
"String Property" /* 46 */
};
if (code >= 128)
return "OEM-specific";
if (code <= 46)
return type[code];
return out_of_spec;
}
static int dmi_bcd_range(u8 value, u8 low, u8 high)
{
if (value > 0x99 || (value & 0x0F) > 0x09)
return 0;
if (value < low || value > high)
return 0;
return 1;
}
static void dmi_dump(const struct dmi_header *h)
{
static char raw_data[48];
int row, i;
unsigned int off;
char *s;
pr_list_start("Header and Data", NULL);
for (row = 0; row < ((h->length - 1) >> 4) + 1; row++)
{
off = 0;
for (i = 0; i < 16 && i < h->length - (row << 4); i++)
off += sprintf(raw_data + off, i ? " %02X" : "%02X",
(h->data)[(row << 4) + i]);
pr_list_item(raw_data);
}
pr_list_end();
if ((h->data)[h->length] || (h->data)[h->length + 1])
{
pr_list_start("Strings", NULL);
i = 1;
while ((s = _dmi_string(h, i++, !(opt.flags & FLAG_DUMP))))
{
if (opt.flags & FLAG_DUMP)
{
int j, l = strlen(s) + 1;
for (row = 0; row < ((l - 1) >> 4) + 1; row++)
{
off = 0;
for (j = 0; j < 16 && j < l - (row << 4); j++)
off += sprintf(raw_data + off,
j ? " %02X" : "%02X",
(unsigned char)s[(row << 4) + j]);
pr_list_item(raw_data);
}
/* String isn't filtered yet so do it now */
ascii_filter(s, l - 1);
}
pr_list_item("%s", s);
}
pr_list_end();
}
}
/* shift is 0 if the value is in bytes, 1 if it is in kilobytes */
void dmi_print_memory_size(const char *attr, u64 code, int shift)
{
unsigned long capacity;
u16 split[7];
static const char *unit[8] = {
"bytes", "kB", "MB", "GB", "TB", "PB", "EB", "ZB"
};
int i;
/*
* We split the overall size in powers of thousand: EB, PB, TB, GB,
* MB, kB and B. In practice, it is expected that only one or two
* (consecutive) of these will be non-zero.
*/
split[0] = code.l & 0x3FFUL;
split[1] = (code.l >> 10) & 0x3FFUL;
split[2] = (code.l >> 20) & 0x3FFUL;
split[3] = ((code.h << 2) & 0x3FCUL) | (code.l >> 30);
split[4] = (code.h >> 8) & 0x3FFUL;
split[5] = (code.h >> 18) & 0x3FFUL;
split[6] = code.h >> 28;
/*
* Now we find the highest unit with a non-zero value. If the following
* is also non-zero, we use that as our base. If the following is zero,
* we simply display the highest unit.
*/
for (i = 6; i > 0; i--)
{
if (split[i])
break;
}
if (i > 0 && split[i - 1])
{
i--;
capacity = split[i] + (split[i + 1] << 10);
}
else
capacity = split[i];
pr_attr(attr, "%lu %s", capacity, unit[i + shift]);
}
/*
* 7.1 BIOS Information (Type 0)
*/
static void dmi_bios_runtime_size(u32 code)
{
const char *format;
if (code & 0x000003FF)
{
format = "%u bytes";
}
else
{
format = "%u kB";
code >>= 10;
}
pr_attr("Runtime Size", format, code);
}
static void dmi_bios_rom_size(u8 code1, u16 code2)
{
static const char *unit[4] = {
"MB", "GB", out_of_spec, out_of_spec
};
if (code1 != 0xFF)
{
u64 s = { .l = (code1 + 1) << 6 };
dmi_print_memory_size("ROM Size", s, 1);
}
else
pr_attr("ROM Size", "%u %s", code2 & 0x3FFF, unit[code2 >> 14]);
}
static void dmi_bios_characteristics(u64 code)
{
/* 7.1.1 */
static const char *characteristics[] = {
"BIOS characteristics not supported", /* 3 */
"ISA is supported",
"MCA is supported",
"EISA is supported",
"PCI is supported",
"PC Card (PCMCIA) is supported",
"PNP is supported",
"APM is supported",
"BIOS is upgradeable",
"BIOS shadowing is allowed",
"VLB is supported",
"ESCD support is available",
"Boot from CD is supported",
"Selectable boot is supported",
"BIOS ROM is socketed",
"Boot from PC Card (PCMCIA) is supported",
"EDD is supported",
"Japanese floppy for NEC 9800 1.2 MB is supported (int 13h)",
"Japanese floppy for Toshiba 1.2 MB is supported (int 13h)",
"5.25\"/360 kB floppy services are supported (int 13h)",
"5.25\"/1.2 MB floppy services are supported (int 13h)",
"3.5\"/720 kB floppy services are supported (int 13h)",
"3.5\"/2.88 MB floppy services are supported (int 13h)",
"Print screen service is supported (int 5h)",
"8042 keyboard services are supported (int 9h)",
"Serial services are supported (int 14h)",
"Printer services are supported (int 17h)",
"CGA/mono video services are supported (int 10h)",
"NEC PC-98" /* 31 */
};
int i;
/*
* This isn't very clear what this bit is supposed to mean
*/
if (code.l & (1 << 3))
{
pr_list_item("%s", characteristics[0]);
return;
}
for (i = 4; i <= 31; i++)
if (code.l & (1 << i))
pr_list_item("%s", characteristics[i - 3]);
}
static void dmi_bios_characteristics_x1(u8 code)
{
/* 7.1.2.1 */
static const char *characteristics[] = {
"ACPI is supported", /* 0 */
"USB legacy is supported",
"AGP is supported",
"I2O boot is supported",
"LS-120 boot is supported",
"ATAPI Zip drive boot is supported",
"IEEE 1394 boot is supported",
"Smart battery is supported" /* 7 */
};
int i;
for (i = 0; i <= 7; i++)
if (code & (1 << i))
pr_list_item("%s", characteristics[i]);
}
static void dmi_bios_characteristics_x2(u8 code)
{
/* 37.1.2.2 */
static const char *characteristics[] = {
"BIOS boot specification is supported", /* 0 */
"Function key-initiated network boot is supported",
"Targeted content distribution is supported",
"UEFI is supported",
"System is a virtual machine",
"Manufacturing mode is supported",
"Manufacturing mode is enabled" /* 6 */
};
int i;
for (i = 0; i <= 6; i++)
if (code & (1 << i))
pr_list_item("%s", characteristics[i]);
}
/*
* 7.2 System Information (Type 1)
*/
static void dmi_system_uuid(void (*print_cb)(const char *name, const char *format, ...),
const char *attr, const u8 *p, u16 ver)
{
int only0xFF = 1, only0x00 = 1;
int i;
for (i = 0; i < 16 && (only0x00 || only0xFF); i++)
{
if (p[i] != 0x00) only0x00 = 0;
if (p[i] != 0xFF) only0xFF = 0;
}
if (only0xFF)
{
if (print_cb)
print_cb(attr, "Not Present");
else
printf("Not Present\n");
return;
}
if (only0x00)
{
if (print_cb)
print_cb(attr, "Not Settable");
else
printf("Not Settable\n");
return;
}
/*
* As of version 2.6 of the SMBIOS specification, the first 3
* fields of the UUID are supposed to be encoded on little-endian.
* The specification says that this is the defacto standard,
* however I've seen systems following RFC 4122 instead and use
* network byte order, so I am reluctant to apply the byte-swapping
* for older versions.
*/
if (ver >= 0x0206)
{
if (print_cb)
print_cb(attr,
"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
p[3], p[2], p[1], p[0], p[5], p[4], p[7], p[6],
p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]);
else
printf("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
p[3], p[2], p[1], p[0], p[5], p[4], p[7], p[6],
p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]);
}
else
{
if (print_cb)
print_cb(attr,
"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7],
p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]);
else
printf("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7],
p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]);
}
}
static const char *dmi_system_wake_up_type(u8 code)
{
/* 7.2.2 */
static const char *type[] = {
"Reserved", /* 0x00 */
"Other",
"Unknown",
"APM Timer",
"Modem Ring",
"LAN Remote",
"Power Switch",
"PCI PME#",
"AC Power Restored" /* 0x08 */
};
if (code <= 0x08)
return type[code];
return out_of_spec;
}
/*
* 7.3 Base Board Information (Type 2)
*/
static void dmi_base_board_features(u8 code)
{
/* 7.3.1 */
static const char *features[] = {
"Board is a hosting board", /* 0 */
"Board requires at least one daughter board",
"Board is removable",
"Board is replaceable",
"Board is hot swappable" /* 4 */
};
if ((code & 0x1F) == 0)
pr_list_start("Features", "%s", "None");
else
{
int i;
pr_list_start("Features", NULL);
for (i = 0; i <= 4; i++)
if (code & (1 << i))
pr_list_item("%s", features[i]);
}
pr_list_end();
}
static const char *dmi_base_board_type(u8 code)
{
/* 7.3.2 */
static const char *type[] = {
"Unknown", /* 0x01 */
"Other",
"Server Blade",
"Connectivity Switch",
"System Management Module",
"Processor Module",
"I/O Module",
"Memory Module",
"Daughter Board",
"Motherboard",
"Processor+Memory Module",
"Processor+I/O Module",
"Interconnect Board" /* 0x0D */
};
if (code >= 0x01 && code <= 0x0D)
return type[code - 0x01];
return out_of_spec;
}
static void dmi_base_board_handles(u8 count, const u8 *p)
{
int i;
pr_list_start("Contained Object Handles", "%u", count);
for (i = 0; i < count; i++)
pr_list_item("0x%04X", WORD(p + sizeof(u16) * i));
pr_list_end();
}
/*
* 7.4 Chassis Information (Type 3)
*/
static const char *dmi_chassis_type(u8 code)
{
/* 7.4.1 */
static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"Desktop",
"Low Profile Desktop",
"Pizza Box",
"Mini Tower",
"Tower",
"Portable",
"Laptop",
"Notebook",
"Hand Held",
"Docking Station",
"All In One",
"Sub Notebook",
"Space-saving",
"Lunch Box",
"Main Server Chassis", /* CIM_Chassis.ChassisPackageType says "Main System Chassis" */
"Expansion Chassis",
"Sub Chassis",
"Bus Expansion Chassis",
"Peripheral Chassis",
"RAID Chassis",
"Rack Mount Chassis",
"Sealed-case PC",
"Multi-system",
"CompactPCI",
"AdvancedTCA",
"Blade",
"Blade Enclosing",
"Tablet",
"Convertible",
"Detachable",
"IoT Gateway",
"Embedded PC",
"Mini PC",
"Stick PC" /* 0x24 */
};
code &= 0x7F; /* bits 6:0 are chassis type, 7th bit is the lock bit */
if (code >= 0x01 && code <= 0x24)
return type[code - 0x01];
return out_of_spec;
}
static const char *dmi_chassis_lock(u8 code)
{
static const char *lock[] = {
"Not Present", /* 0x00 */
"Present" /* 0x01 */
};
return lock[code];
}
static const char *dmi_chassis_state(u8 code)
{
/* 7.4.2 */
static const char *state[] = {
"Other", /* 0x01 */
"Unknown",
"Safe",
"Warning",
"Critical",
"Non-recoverable" /* 0x06 */
};
if (code >= 0x01 && code <= 0x06)
return state[code - 0x01];
return out_of_spec;
}
static const char *dmi_chassis_security_status(u8 code)
{
/* 7.4.3 */
static const char *status[] = {
"Other", /* 0x01 */
"Unknown",
"None",
"External Interface Locked Out",
"External Interface Enabled" /* 0x05 */
};
if (code >= 0x01 && code <= 0x05)
return status[code - 0x01];
return out_of_spec;
}
static void dmi_chassis_height(u8 code)
{
if (code == 0x00)
pr_attr("Height", "Unspecified");
else
pr_attr("Height", "%u U", code);
}
static void dmi_chassis_power_cords(u8 code)
{
if (code == 0x00)
pr_attr("Number Of Power Cords", "Unspecified");
else
pr_attr("Number Of Power Cords", "%u", code);
}
static void dmi_chassis_elements(u8 count, u8 len, const u8 *p)
{
int i;
pr_list_start("Contained Elements", "%u", count);
for (i = 0; i < count; i++)
{
if (len >= 0x03)
{
const char *type;
type = (p[i * len] & 0x80) ?
dmi_smbios_structure_type(p[i * len] & 0x7F) :
dmi_base_board_type(p[i * len] & 0x7F);
if (p[1 + i * len] == p[2 + i * len])
pr_list_item("%s (%u)", type, p[1 + i * len]);
else
pr_list_item("%s (%u-%u)", type, p[1 + i * len],
p[2 + i * len]);
}
}
pr_list_end();
}
/*
* 7.5 Processor Information (Type 4)
*/
static const char *dmi_processor_type(u8 code)
{
/* 7.5.1 */
static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"Central Processor",
"Math Processor",
"DSP Processor",
"Video Processor" /* 0x06 */
};
if (code >= 0x01 && code <= 0x06)
return type[code - 0x01];
return out_of_spec;
}
static const char *dmi_processor_family(const struct dmi_header *h, u16 ver)
{
const u8 *data = h->data;
unsigned int i, low, high;
u16 code;
/* 7.5.2 */
static struct {
int value;
const char *name;
} family2[] = {
{ 0x01, "Other" },
{ 0x02, "Unknown" },
{ 0x03, "8086" },
{ 0x04, "80286" },
{ 0x05, "80386" },
{ 0x06, "80486" },
{ 0x07, "8087" },
{ 0x08, "80287" },
{ 0x09, "80387" },
{ 0x0A, "80487" },
{ 0x0B, "Pentium" },
{ 0x0C, "Pentium Pro" },
{ 0x0D, "Pentium II" },
{ 0x0E, "Pentium MMX" },
{ 0x0F, "Celeron" },
{ 0x10, "Pentium II Xeon" },
{ 0x11, "Pentium III" },
{ 0x12, "M1" },
{ 0x13, "M2" },
{ 0x14, "Celeron M" },
{ 0x15, "Pentium 4 HT" },
{ 0x16, "Intel" },
{ 0x18, "Duron" },
{ 0x19, "K5" },
{ 0x1A, "K6" },
{ 0x1B, "K6-2" },
{ 0x1C, "K6-3" },
{ 0x1D, "Athlon" },
{ 0x1E, "AMD29000" },
{ 0x1F, "K6-2+" },
{ 0x20, "Power PC" },
{ 0x21, "Power PC 601" },
{ 0x22, "Power PC 603" },
{ 0x23, "Power PC 603+" },
{ 0x24, "Power PC 604" },
{ 0x25, "Power PC 620" },
{ 0x26, "Power PC x704" },
{ 0x27, "Power PC 750" },
{ 0x28, "Core Duo" },
{ 0x29, "Core Duo Mobile" },
{ 0x2A, "Core Solo Mobile" },
{ 0x2B, "Atom" },
{ 0x2C, "Core M" },
{ 0x2D, "Core m3" },
{ 0x2E, "Core m5" },
{ 0x2F, "Core m7" },
{ 0x30, "Alpha" },
{ 0x31, "Alpha 21064" },
{ 0x32, "Alpha 21066" },
{ 0x33, "Alpha 21164" },
{ 0x34, "Alpha 21164PC" },
{ 0x35, "Alpha 21164a" },
{ 0x36, "Alpha 21264" },
{ 0x37, "Alpha 21364" },
{ 0x38, "Turion II Ultra Dual-Core Mobile M" },
{ 0x39, "Turion II Dual-Core Mobile M" },
{ 0x3A, "Athlon II Dual-Core M" },
{ 0x3B, "Opteron 6100" },
{ 0x3C, "Opteron 4100" },
{ 0x3D, "Opteron 6200" },
{ 0x3E, "Opteron 4200" },
{ 0x3F, "FX" },
{ 0x40, "MIPS" },
{ 0x41, "MIPS R4000" },
{ 0x42, "MIPS R4200" },
{ 0x43, "MIPS R4400" },
{ 0x44, "MIPS R4600" },
{ 0x45, "MIPS R10000" },
{ 0x46, "C-Series" },
{ 0x47, "E-Series" },
{ 0x48, "A-Series" },
{ 0x49, "G-Series" },
{ 0x4A, "Z-Series" },
{ 0x4B, "R-Series" },
{ 0x4C, "Opteron 4300" },
{ 0x4D, "Opteron 6300" },
{ 0x4E, "Opteron 3300" },
{ 0x4F, "FirePro" },
{ 0x50, "SPARC" },
{ 0x51, "SuperSPARC" },
{ 0x52, "MicroSPARC II" },
{ 0x53, "MicroSPARC IIep" },
{ 0x54, "UltraSPARC" },
{ 0x55, "UltraSPARC II" },
{ 0x56, "UltraSPARC IIi" },
{ 0x57, "UltraSPARC III" },
{ 0x58, "UltraSPARC IIIi" },
{ 0x60, "68040" },
{ 0x61, "68xxx" },
{ 0x62, "68000" },
{ 0x63, "68010" },
{ 0x64, "68020" },
{ 0x65, "68030" },
{ 0x66, "Athlon X4" },
{ 0x67, "Opteron X1000" },
{ 0x68, "Opteron X2000" },
{ 0x69, "Opteron A-Series" },
{ 0x6A, "Opteron X3000" },
{ 0x6B, "Zen" },
{ 0x70, "Hobbit" },
{ 0x78, "Crusoe TM5000" },
{ 0x79, "Crusoe TM3000" },
{ 0x7A, "Efficeon TM8000" },
{ 0x80, "Weitek" },
{ 0x82, "Itanium" },
{ 0x83, "Athlon 64" },
{ 0x84, "Opteron" },
{ 0x85, "Sempron" },
{ 0x86, "Turion 64" },
{ 0x87, "Dual-Core Opteron" },
{ 0x88, "Athlon 64 X2" },
{ 0x89, "Turion 64 X2" },
{ 0x8A, "Quad-Core Opteron" },
{ 0x8B, "Third-Generation Opteron" },
{ 0x8C, "Phenom FX" },
{ 0x8D, "Phenom X4" },
{ 0x8E, "Phenom X2" },
{ 0x8F, "Athlon X2" },
{ 0x90, "PA-RISC" },
{ 0x91, "PA-RISC 8500" },
{ 0x92, "PA-RISC 8000" },
{ 0x93, "PA-RISC 7300LC" },
{ 0x94, "PA-RISC 7200" },
{ 0x95, "PA-RISC 7100LC" },
{ 0x96, "PA-RISC 7100" },
{ 0xA0, "V30" },
{ 0xA1, "Quad-Core Xeon 3200" },
{ 0xA2, "Dual-Core Xeon 3000" },
{ 0xA3, "Quad-Core Xeon 5300" },
{ 0xA4, "Dual-Core Xeon 5100" },
{ 0xA5, "Dual-Core Xeon 5000" },
{ 0xA6, "Dual-Core Xeon LV" },
{ 0xA7, "Dual-Core Xeon ULV" },
{ 0xA8, "Dual-Core Xeon 7100" },
{ 0xA9, "Quad-Core Xeon 5400" },
{ 0xAA, "Quad-Core Xeon" },
{ 0xAB, "Dual-Core Xeon 5200" },
{ 0xAC, "Dual-Core Xeon 7200" },
{ 0xAD, "Quad-Core Xeon 7300" },
{ 0xAE, "Quad-Core Xeon 7400" },
{ 0xAF, "Multi-Core Xeon 7400" },
{ 0xB0, "Pentium III Xeon" },
{ 0xB1, "Pentium III Speedstep" },
{ 0xB2, "Pentium 4" },
{ 0xB3, "Xeon" },
{ 0xB4, "AS400" },
{ 0xB5, "Xeon MP" },
{ 0xB6, "Athlon XP" },
{ 0xB7, "Athlon MP" },
{ 0xB8, "Itanium 2" },
{ 0xB9, "Pentium M" },
{ 0xBA, "Celeron D" },
{ 0xBB, "Pentium D" },
{ 0xBC, "Pentium EE" },
{ 0xBD, "Core Solo" },
/* 0xBE handled as a special case */
{ 0xBF, "Core 2 Duo" },
{ 0xC0, "Core 2 Solo" },
{ 0xC1, "Core 2 Extreme" },
{ 0xC2, "Core 2 Quad" },
{ 0xC3, "Core 2 Extreme Mobile" },
{ 0xC4, "Core 2 Duo Mobile" },
{ 0xC5, "Core 2 Solo Mobile" },
{ 0xC6, "Core i7" },
{ 0xC7, "Dual-Core Celeron" },
{ 0xC8, "IBM390" },
{ 0xC9, "G4" },
{ 0xCA, "G5" },
{ 0xCB, "ESA/390 G6" },
{ 0xCC, "z/Architecture" },
{ 0xCD, "Core i5" },
{ 0xCE, "Core i3" },
{ 0xCF, "Core i9" },
{ 0xD2, "C7-M" },
{ 0xD3, "C7-D" },
{ 0xD4, "C7" },
{ 0xD5, "Eden" },
{ 0xD6, "Multi-Core Xeon" },
{ 0xD7, "Dual-Core Xeon 3xxx" },
{ 0xD8, "Quad-Core Xeon 3xxx" },
{ 0xD9, "Nano" },
{ 0xDA, "Dual-Core Xeon 5xxx" },
{ 0xDB, "Quad-Core Xeon 5xxx" },
{ 0xDD, "Dual-Core Xeon 7xxx" },
{ 0xDE, "Quad-Core Xeon 7xxx" },
{ 0xDF, "Multi-Core Xeon 7xxx" },
{ 0xE0, "Multi-Core Xeon 3400" },
{ 0xE4, "Opteron 3000" },
{ 0xE5, "Sempron II" },
{ 0xE6, "Embedded Opteron Quad-Core" },
{ 0xE7, "Phenom Triple-Core" },
{ 0xE8, "Turion Ultra Dual-Core Mobile" },
{ 0xE9, "Turion Dual-Core Mobile" },
{ 0xEA, "Athlon Dual-Core" },
{ 0xEB, "Sempron SI" },
{ 0xEC, "Phenom II" },
{ 0xED, "Athlon II" },
{ 0xEE, "Six-Core Opteron" },
{ 0xEF, "Sempron M" },
{ 0xFA, "i860" },
{ 0xFB, "i960" },
{ 0x100, "ARMv7" },
{ 0x101, "ARMv8" },
{ 0x102, "ARMv9" },
{ 0x103, "ARM" },
{ 0x104, "SH-3" },
{ 0x105, "SH-4" },
{ 0x118, "ARM" },
{ 0x119, "StrongARM" },
{ 0x12C, "6x86" },
{ 0x12D, "MediaGX" },
{ 0x12E, "MII" },
{ 0x140, "WinChip" },
{ 0x15E, "DSP" },
{ 0x1F4, "Video Processor" },
{ 0x200, "RV32" },
{ 0x201, "RV64" },
{ 0x202, "RV128" },
{ 0x258, "LoongArch" },
{ 0x259, "Loongson 1" },
{ 0x25A, "Loongson 2" },
{ 0x25B, "Loongson 3" },
{ 0x25C, "Loongson 2K" },
{ 0x25D, "Loongson 3A" },
{ 0x25E, "Loongson 3B" },
{ 0x25F, "Loongson 3C" },
{ 0x260, "Loongson 3D" },
{ 0x261, "Loongson 3E" },
{ 0x262, "Dual-Core Loongson 2K 2xxx" },
{ 0x26C, "Quad-Core Loongson 3A 5xxx" },
{ 0x26D, "Multi-Core Loongson 3A 5xxx" },
{ 0x26E, "Quad-Core Loongson 3B 5xxx" },
{ 0x26F, "Multi-Core Loongson 3B 5xxx" },
{ 0x270, "Multi-Core Loongson 3C 5xxx" },
{ 0x271, "Multi-Core Loongson 3D 5xxx" },
};
/*
* Note to developers: when adding entries to this list, check if
* function dmi_processor_id below needs updating too.
*/
/* Special case for ambiguous value 0x30 (SMBIOS 2.0 only) */
if (ver == 0x0200 && data[0x06] == 0x30 && h->length >= 0x08)
{
const char *manufacturer = dmi_string(h, data[0x07]);
if (strstr(manufacturer, "Intel") != NULL
|| strncasecmp(manufacturer, "Intel", 5) == 0)
return "Pentium Pro";
}
code = (data[0x06] == 0xFE && h->length >= 0x2A) ?
WORD(data + 0x28) : data[0x06];
/* Special case for ambiguous value 0xBE */
if (code == 0xBE)
{
if (h->length >= 0x08)
{
const char *manufacturer = dmi_string(h, data[0x07]);
/* Best bet based on manufacturer string */
if (strstr(manufacturer, "Intel") != NULL
|| strncasecmp(manufacturer, "Intel", 5) == 0)
return "Core 2";
if (strstr(manufacturer, "AMD") != NULL
|| strncasecmp(manufacturer, "AMD", 3) == 0)
return "K7";
}
return "Core 2 or K7";
}
/* Perform a binary search */
low = 0;
high = ARRAY_SIZE(family2) - 1;
while (1)
{
i = (low + high) / 2;
if (family2[i].value == code)
return family2[i].name;
if (low == high) /* Not found */
return out_of_spec;
if (code < family2[i].value)
high = i;
else
low = i + 1;
}
}
static enum cpuid_type dmi_get_cpuid_type(const struct dmi_header *h)
{
const u8 *data = h->data;
const u8 *p = data + 0x08;
u16 type;
type = (data[0x06] == 0xFE && h->length >= 0x2A) ?
WORD(data + 0x28) : data[0x06];
if (type == 0x05) /* 80386 */
{
return cpuid_80386;
}
else if (type == 0x06) /* 80486 */
{
u16 dx = WORD(p);
/*
* Not all 80486 CPU support the CPUID instruction, we have to find
* whether the one we have here does or not. Note that this trick
* works only because we know that 80486 must be little-endian.
*/
if ((dx & 0x0F00) == 0x0400
&& ((dx & 0x00F0) == 0x0040 || (dx & 0x00F0) >= 0x0070)
&& ((dx & 0x000F) >= 0x0003))
return cpuid_x86_intel;
else
return cpuid_80486;
}
else if ((type >= 0x100 && type <= 0x102) /* ARM */
|| (type >= 0x118 && type <= 0x119)) /* ARM */
{
/*
* The field's format depends on the processor's support of
* the SMCCC_ARCH_SOC_ID architectural call. Software can determine
* the support for SoC ID by examining the Processor Characteristics field
* for "Arm64 SoC ID" bit.
*/
if (h->length >= 0x28
&& (WORD(data + 0x26) & (1 << 9)))
return cpuid_arm_soc_id;
else
return cpuid_arm_legacy;
}
else if ((type >= 0x0B && type <= 0x15) /* Intel, Cyrix */
|| (type >= 0x28 && type <= 0x2F) /* Intel */
|| (type >= 0xA1 && type <= 0xB3) /* Intel */
|| type == 0xB5 /* Intel */
|| (type >= 0xB9 && type <= 0xC7) /* Intel */
|| (type >= 0xCD && type <= 0xCF) /* Intel */
|| (type >= 0xD2 && type <= 0xDB) /* VIA, Intel */
|| (type >= 0xDD && type <= 0xE0)) /* Intel */
return cpuid_x86_intel;
else if ((type >= 0x18 && type <= 0x1D) /* AMD */
|| type == 0x1F /* AMD */
|| (type >= 0x38 && type <= 0x3F) /* AMD */
|| (type >= 0x46 && type <= 0x4F) /* AMD */
|| (type >= 0x66 && type <= 0x6B) /* AMD */
|| (type >= 0x83 && type <= 0x8F) /* AMD */
|| (type >= 0xB6 && type <= 0xB7) /* AMD */
|| (type >= 0xE4 && type <= 0xEF)) /* AMD */
return cpuid_x86_amd;
else if ((type >= 0x258 && type <= 0x262) /* Loongarch */
|| (type >= 0x26C && type <= 0x271)) /* Loongarch */
return cpuid_loongarch;
/* neither X86 nor ARM */
return cpuid_none;
}
void dmi_print_cpuid(void (*print_cb)(const char *name, const char *format, ...),
const char *label, enum cpuid_type sig, const u8 *p)
{
u32 eax, midr, jep106, soc_revision;
u16 dx;
switch (sig)
{
case cpuid_80386:
dx = WORD(p);
/*
* 80386 have a different signature.
*/
print_cb(label,
"Type %u, Family %u, Major Stepping %u, Minor Stepping %u",
dx >> 12, (dx >> 8) & 0xF,
(dx >> 4) & 0xF, dx & 0xF);
return;
case cpuid_80486:
dx = WORD(p);
print_cb(label,
"Type %u, Family %u, Model %u, Stepping %u",
(dx >> 12) & 0x3, (dx >> 8) & 0xF,
(dx >> 4) & 0xF, dx & 0xF);
return;
case cpuid_arm_legacy: /* ARM before SOC ID */
midr = DWORD(p);
/*
* The format of this field was not defined for ARM processors
* before version 3.1.0 of the SMBIOS specification, so we
* silently skip it if it reads all zeroes.
*/
if (midr == 0)
return;
print_cb(label,
"Implementor 0x%02x, Variant 0x%x, Architecture %u, Part 0x%03x, Revision %u",
midr >> 24, (midr >> 20) & 0xF,
(midr >> 16) & 0xF, (midr >> 4) & 0xFFF, midr & 0xF);
return;
case cpuid_arm_soc_id: /* ARM with SOC ID */
/*
* If Soc ID is supported, the first DWORD is the JEP-106 code;
* the second DWORD is the SoC revision value.
*/
jep106 = DWORD(p);
soc_revision = DWORD(p + 4);
/*
* According to SMC Calling Convention (SMCCC) v1.3 specification
* (https://developer.arm.com/documentation/den0028/d/), the format
* of the values returned by the SMCCC_ARCH_SOC_ID call is as follows:
*
* JEP-106 code for the SiP (SoC_ID_type == 0)
* Bit[31] must be zero
* Bits[30:24] JEP-106 bank index for the SiP
* Bits[23:16] JEP-106 identification code with parity bit for the SiP
* Bits[15:0] Implementation defined SoC ID
*
* SoC revision (SoC_ID_type == 1)
* Bit[31] must be zero
* Bits[30:0] SoC revision
*/
pr_attr("Signature",
"JEP-106 Bank 0x%02x Manufacturer 0x%02x, SoC ID 0x%04x, SoC Revision 0x%08x",
(jep106 >> 24) & 0x7F, (jep106 >> 16) & 0x7F, jep106 & 0xFFFF, soc_revision);
return;
case cpuid_x86_intel: /* Intel */
eax = DWORD(p);
/*
* Extra flags are now returned in the ECX register when
* one calls the CPUID instruction. Their meaning is
* explained in table 3-5, but DMI doesn't support this
* yet.
*/
print_cb(label,
"Type %u, Family %u, Model %u, Stepping %u",
(eax >> 12) & 0x3,
((eax >> 20) & 0xFF) + ((eax >> 8) & 0x0F),
((eax >> 12) & 0xF0) + ((eax >> 4) & 0x0F),
eax & 0xF);
break;
case cpuid_x86_amd: /* AMD, publication #25481 revision 2.28 */
eax = DWORD(p);
print_cb(label, "Family %u, Model %u, Stepping %u",
((eax >> 8) & 0xF) + (((eax >> 8) & 0xF) == 0xF ? (eax >> 20) & 0xFF : 0),
((eax >> 4) & 0xF) | (((eax >> 8) & 0xF) == 0xF ? (eax >> 12) & 0xF0 : 0),
eax & 0xF);
break;
case cpuid_loongarch: /* LoongArch Reference Manual, volume 1 */
eax = DWORD(p);
print_cb(label, "Processor Identity 0x%08x\n", eax);
break;
default:
return;
}
}
static void dmi_processor_id(const struct dmi_header *h)
{
/* Intel AP-485 revision 36, table 2-4 */
static const char *flags[32] = {
"FPU (Floating-point unit on-chip)", /* 0 */
"VME (Virtual mode extension)",
"DE (Debugging extension)",
"PSE (Page size extension)",
"TSC (Time stamp counter)",
"MSR (Model specific registers)",
"PAE (Physical address extension)",
"MCE (Machine check exception)",
"CX8 (CMPXCHG8 instruction supported)",
"APIC (On-chip APIC hardware supported)",
NULL, /* 10 */
"SEP (Fast system call)",
"MTRR (Memory type range registers)",
"PGE (Page global enable)",
"MCA (Machine check architecture)",
"CMOV (Conditional move instruction supported)",
"PAT (Page attribute table)",
"PSE-36 (36-bit page size extension)",
"PSN (Processor serial number present and enabled)",
"CLFSH (CLFLUSH instruction supported)",
NULL, /* 20 */
"DS (Debug store)",
"ACPI (ACPI supported)",
"MMX (MMX technology supported)",
"FXSR (FXSAVE and FXSTOR instructions supported)",
"SSE (Streaming SIMD extensions)",
"SSE2 (Streaming SIMD extensions 2)",
"SS (Self-snoop)",
"HTT (Multi-threading)",
"TM (Thermal monitor supported)",
NULL, /* 30 */
"PBE (Pending break enabled)" /* 31 */
};
const u8 *data = h->data;
const u8 *p = data + 0x08;
enum cpuid_type sig = dmi_get_cpuid_type(h);
u32 edx;
/*
* This might help learn about new processors supporting the
* CPUID instruction or another form of identification.
*/
if (!(opt.flags & FLAG_QUIET))
pr_attr("ID", "%02X %02X %02X %02X %02X %02X %02X %02X",
p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
dmi_print_cpuid(pr_attr, "Signature", sig, p);
if (sig != cpuid_x86_intel && sig != cpuid_x86_amd)
return;
edx = DWORD(p + 4);
if ((edx & 0xBFEFFBFF) == 0)
pr_list_start("Flags", "None");
else
{
int i;
pr_list_start("Flags", NULL);
for (i = 0; i <= 31; i++)
if (flags[i] != NULL && edx & (1 << i))
pr_list_item("%s", flags[i]);
}
pr_list_end();
}
static void dmi_processor_voltage(const char *attr, u8 code)
{
/* 7.5.4 */
static const char *voltage[] = {
"5.0 V", /* 0 */
"3.3 V",
"2.9 V" /* 2 */
};
int i;
if (code & 0x80)
pr_attr(attr, "%.1f V", (float)(code & 0x7f) / 10);
else if ((code & 0x07) == 0x00)
pr_attr(attr, "Unknown");
else
{
char voltage_str[18];
int off = 0;
for (i = 0; i <= 2; i++)
{
if (code & (1 << i))
{
/* Insert space if not the first value */
off += sprintf(voltage_str + off,
off ? " %s" :"%s",
voltage[i]);
}
}
if (off)
pr_attr(attr, voltage_str);
}
}
static void dmi_processor_frequency(const char *attr, const u8 *p)
{
u16 code = WORD(p);
if (code)
{
if (attr)
pr_attr(attr, "%u MHz", code);
else
printf("%u MHz\n", code);
}
else
{
if (attr)
pr_attr(attr, "Unknown");
else
printf("Unknown\n");
}
}
/* code is assumed to be a 3-bit value */
static const char *dmi_processor_status(u8 code)
{
static const char *status[] = {
"Unknown", /* 0x00 */
"Enabled",
"Disabled By User",
"Disabled By BIOS",
"Idle", /* 0x04 */
out_of_spec,
out_of_spec,
"Other" /* 0x07 */
};
return status[code];
}
static const char *dmi_processor_upgrade(u8 code)
{
/* 7.5.5 */
static const char *upgrade[] = {
"Other", /* 0x01 */
"Unknown",
"Daughter Board",
"ZIF Socket",
"Replaceable Piggy Back",
"None",
"LIF Socket",
"Slot 1",
"Slot 2",
"370-pin Socket",
"Slot A",
"Slot M",
"Socket 423",
"Socket A (Socket 462)",
"Socket 478",
"Socket 754",
"Socket 940",
"Socket 939",
"Socket mPGA604",
"Socket LGA771",
"Socket LGA775",
"Socket S1",
"Socket AM2",
"Socket F (1207)",
"Socket LGA1366",
"Socket G34",
"Socket AM3",
"Socket C32",
"Socket LGA1156",
"Socket LGA1567",
"Socket PGA988A",
"Socket BGA1288",
"Socket rPGA988B",
"Socket BGA1023",
"Socket BGA1224",
"Socket BGA1155",
"Socket LGA1356",
"Socket LGA2011",
"Socket FS1",
"Socket FS2",
"Socket FM1",
"Socket FM2",
"Socket LGA2011-3",
"Socket LGA1356-3",
"Socket LGA1150",
"Socket BGA1168",
"Socket BGA1234",
"Socket BGA1364",
"Socket AM4",
"Socket LGA1151",
"Socket BGA1356",
"Socket BGA1440",
"Socket BGA1515",
"Socket LGA3647-1",
"Socket SP3",
"Socket SP3r2",
"Socket LGA2066",
"Socket BGA1392",
"Socket BGA1510",
"Socket BGA1528",
"Socket LGA4189",
"Socket LGA1200",
"Socket LGA4677",
"Socket LGA1700",
"Socket BGA1744",
"Socket BGA1781",
"Socket BGA1211",
"Socket BGA2422",
"Socket LGA1211",
"Socket LGA2422",
"Socket LGA5773",
"Socket BGA5773",
"Socket AM5",
"Socket SP5",
"Socket SP6",
"Socket BGA883",
"Socket BGA1190",
"Socket BGA4129",
"Socket LGA4710",
"Socket LGA7529" /* 0x50 */
};
if (code >= 0x01 && code <= 0x50)
return upgrade[code - 0x01];
return out_of_spec;
}
static void dmi_processor_cache(const char *attr, u16 code, const char *level,
u16 ver)
{
if (code == 0xFFFF)
{
if (ver >= 0x0203)
pr_attr(attr, "Not Provided");
else
pr_attr(attr, "No %s Cache", level);
}
else
pr_attr(attr, "0x%04X", code);
}
static void dmi_processor_characteristics(const char *attr, u16 code)
{
/* 7.5.9 */
static const char *characteristics[] = {
"64-bit capable", /* 2 */
"Multi-Core",
"Hardware Thread",
"Execute Protection",
"Enhanced Virtualization",
"Power/Performance Control",
"128-bit Capable",
"Arm64 SoC ID" /* 9 */
};
if ((code & 0x00FC) == 0)
pr_attr(attr, "None");
else
{
int i;
pr_list_start(attr, NULL);
for (i = 2; i <= 9; i++)
if (code & (1 << i))
pr_list_item("%s", characteristics[i - 2]);
pr_list_end();
}
}
/*
* 7.6 Memory Controller Information (Type 5)
*/
static const char *dmi_memory_controller_ed_method(u8 code)
{
/* 7.6.1 */
static const char *method[] = {
"Other", /* 0x01 */
"Unknown",
"None",
"8-bit Parity",
"32-bit ECC",
"64-bit ECC",
"128-bit ECC",
"CRC" /* 0x08 */
};
if (code >= 0x01 && code <= 0x08)
return method[code - 0x01];
return out_of_spec;
}
static void dmi_memory_controller_ec_capabilities(const char *attr, u8 code)
{
/* 7.6.2 */
static const char *capabilities[] = {
"Other", /* 0 */
"Unknown",
"None",
"Single-bit Error Correcting",
"Double-bit Error Correcting",
"Error Scrubbing" /* 5 */
};
if ((code & 0x3F) == 0)
pr_attr(attr, "None");
else
{
int i;
pr_list_start(attr, NULL);
for (i = 0; i <= 5; i++)
if (code & (1 << i))
pr_list_item("%s", capabilities[i]);
pr_list_end();
}
}
static const char *dmi_memory_controller_interleave(u8 code)
{
/* 7.6.3 */
static const char *interleave[] = {
"Other", /* 0x01 */
"Unknown",
"One-way Interleave",
"Two-way Interleave",
"Four-way Interleave",
"Eight-way Interleave",
"Sixteen-way Interleave" /* 0x07 */
};
if (code >= 0x01 && code <= 0x07)
return interleave[code - 0x01];
return out_of_spec;
}
static void dmi_memory_controller_speeds(const char *attr, u16 code)
{
/* 7.6.4 */
const char *speeds[] = {
"Other", /* 0 */
"Unknown",
"70 ns",
"60 ns",
"50 ns" /* 4 */
};
if ((code & 0x001F) == 0)
pr_attr(attr, "None");
else
{
int i;
pr_list_start(attr, NULL);
for (i = 0; i <= 4; i++)
if (code & (1 << i))
pr_list_item("%s", speeds[i]);
pr_list_end();
}
}
static void dmi_memory_controller_slots(u8 count, const u8 *p)
{
int i;
pr_list_start("Associated Memory Slots", "%u", count);
for (i = 0; i < count; i++)
pr_list_item("0x%04X", WORD(p + sizeof(u16) * i));
pr_list_end();
}
/*
* 7.7 Memory Module Information (Type 6)
*/
static void dmi_memory_module_types(const char *attr, u16 code, int flat)
{
/* 7.7.1 */
static const char *types[] = {
"Other", /* 0 */
"Unknown",
"Standard",
"FPM",
"EDO",
"Parity",
"ECC",
"SIMM",
"DIMM",
"Burst EDO",
"SDRAM" /* 10 */
};
if ((code & 0x07FF) == 0)
pr_attr(attr, "None");
else if (flat)
{
char type_str[68];
int i, off = 0;
for (i = 0; i <= 10; i++)
{
if (code & (1 << i))
{
/* Insert space if not the first value */
off += sprintf(type_str + off,
off ? " %s" :"%s",
types[i]);
}
}
if (off)
pr_attr(attr, type_str);
}
else
{
int i;
pr_list_start(attr, NULL);
for (i = 0; i <= 10; i++)
if (code & (1 << i))
pr_list_item("%s", types[i]);
pr_list_end();
}
}
static void dmi_memory_module_connections(u8 code)
{
if (code == 0xFF)
pr_attr("Bank Connections", "None");
else if ((code & 0xF0) == 0xF0)
pr_attr("Bank Connections", "%u", code & 0x0F);
else if ((code & 0x0F) == 0x0F)
pr_attr("Bank Connections", "%u", code >> 4);
else
pr_attr("Bank Connections", "%u %u", code >> 4, code & 0x0F);
}
static void dmi_memory_module_speed(const char *attr, u8 code)
{
if (code == 0)
pr_attr(attr, "Unknown");
else
pr_attr(attr, "%u ns", code);
}
static void dmi_memory_module_size(const char *attr, u8 code)
{
const char *connection;
/* 7.7.2 */
if (code & 0x80)
connection = " (Double-bank Connection)";
else
connection = " (Single-bank Connection)";
switch (code & 0x7F)
{
case 0x7D:
pr_attr(attr, "Not Determinable%s", connection);
break;
case 0x7E:
pr_attr(attr, "Disabled%s", connection);
break;
case 0x7F:
pr_attr(attr, "Not Installed");
return;
default:
pr_attr(attr, "%u MB%s", 1 << (code & 0x7F),
connection);
}
}
static void dmi_memory_module_error(u8 code)
{
static const char *status[] = {
"OK", /* 0x00 */
"Uncorrectable Errors",
"Correctable Errors",
"Correctable and Uncorrectable Errors" /* 0x03 */
};
if (code & (1 << 2))
pr_attr("Error Status", "See Event Log");
else
pr_attr("Error Status", "%s", status[code & 0x03]);
}
/*
* 7.8 Cache Information (Type 7)
*/
static const char *dmi_cache_mode(u8 code)
{
static const char *mode[] = {
"Write Through", /* 0x00 */
"Write Back",
"Varies With Memory Address",
"Unknown" /* 0x03 */
};
return mode[code];
}
/* code is assumed to be a 2-bit value */
static const char *dmi_cache_location(u8 code)
{
static const char *location[4] = {
"Internal", /* 0x00 */
"External",
out_of_spec, /* 0x02 */
"Unknown" /* 0x03 */
};
return location[code];
}
static void dmi_cache_size_2(const char *attr, u32 code)
{
u64 size;
if (code & 0x80000000)
{
code &= 0x7FFFFFFFLU;
size.l = code << 6;
size.h = code >> 26;
}
else
{
size.l = code;
size.h = 0;
}
/* Use a more convenient unit for large cache size */
dmi_print_memory_size(attr, size, 1);
}
static void dmi_cache_size(const char *attr, u16 code)
{
dmi_cache_size_2(attr,
(((u32)code & 0x8000LU) << 16) | (code & 0x7FFFLU));
}
static void dmi_cache_types(const char *attr, u16 code, int flat)
{
/* 7.8.2 */
static const char *types[] = {
"Other", /* 0 */
"Unknown",
"Non-burst",
"Burst",
"Pipeline Burst",
"Synchronous",
"Asynchronous" /* 6 */
};
if ((code & 0x007F) == 0)
pr_attr(attr, "None");
else if (flat)
{
char type_str[70];
int i, off = 0;
for (i = 0; i <= 6; i++)
{
if (code & (1 << i))
{
/* Insert space if not the first value */
off += sprintf(type_str + off,
off ? " %s" :"%s",
types[i]);
}
}
if (off)
pr_attr(attr, type_str);
}
else
{
int i;
pr_list_start(attr, NULL);
for (i = 0; i <= 6; i++)
if (code & (1 << i))
pr_list_item("%s", types[i]);
pr_list_end();
}
}
static const char *dmi_cache_ec_type(u8 code)
{
/* 7.8.3 */
static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"None",
"Parity",
"Single-bit ECC",
"Multi-bit ECC" /* 0x06 */
};
if (code >= 0x01 && code <= 0x06)
return type[code - 0x01];
return out_of_spec;
}
static const char *dmi_cache_type(u8 code)
{
/* 7.8.4 */
static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"Instruction",
"Data",
"Unified" /* 0x05 */
};
if (code >= 0x01 && code <= 0x05)
return type[code - 0x01];
return out_of_spec;
}
static const char *dmi_cache_associativity(u8 code)
{
/* 7.8.5 */
static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"Direct Mapped",
"2-way Set-associative",
"4-way Set-associative",
"Fully Associative",
"8-way Set-associative",
"16-way Set-associative",
"12-way Set-associative",
"24-way Set-associative",
"32-way Set-associative",
"48-way Set-associative",
"64-way Set-associative",
"20-way Set-associative" /* 0x0E */
};
if (code >= 0x01 && code <= 0x0E)
return type[code - 0x01];
return out_of_spec;
}
/*
* 7.9 Port Connector Information (Type 8)
*/
static const char *dmi_port_connector_type(u8 code)
{
/* 7.9.2 */
static const char *type[] = {
"None", /* 0x00 */
"Centronics",
"Mini Centronics",
"Proprietary",
"DB-25 male",
"DB-25 female",
"DB-15 male",
"DB-15 female",
"DB-9 male",
"DB-9 female",
"RJ-11",
"RJ-45",
"50 Pin MiniSCSI",
"Mini DIN",
"Micro DIN",
"PS/2",
"Infrared",
"HP-HIL",
"Access Bus (USB)",
"SSA SCSI",
"Circular DIN-8 male",
"Circular DIN-8 female",
"On Board IDE",
"On Board Floppy",
"9 Pin Dual Inline (pin 10 cut)",
"25 Pin Dual Inline (pin 26 cut)",
"50 Pin Dual Inline",
"68 Pin Dual Inline",
"On Board Sound Input From CD-ROM",
"Mini Centronics Type-14",
"Mini Centronics Type-26",
"Mini Jack (headphones)",
"BNC",
"IEEE 1394",
"SAS/SATA Plug Receptacle",
"USB Type-C Receptacle" /* 0x23 */
};
static const char *type_0xA0[] = {
"PC-98", /* 0xA0 */
"PC-98 Hireso",
"PC-H98",
"PC-98 Note",
"PC-98 Full" /* 0xA4 */
};
if (code <= 0x23)
return type[code];
if (code >= 0xA0 && code <= 0xA4)
return type_0xA0[code - 0xA0];
if (code == 0xFF)
return "Other";
return out_of_spec;
}
static const char *dmi_port_type(u8 code)
{
/* 7.9.3 */
static const char *type[] = {
"None", /* 0x00 */
"Parallel Port XT/AT Compatible",
"Parallel Port PS/2",
"Parallel Port ECP",
"Parallel Port EPP",
"Parallel Port ECP/EPP",
"Serial Port XT/AT Compatible",
"Serial Port 16450 Compatible",
"Serial Port 16550 Compatible",
"Serial Port 16550A Compatible",
"SCSI Port",
"MIDI Port",
"Joystick Port",
"Keyboard Port",
"Mouse Port",
"SSA SCSI",
"USB",
"Firewire (IEEE P1394)",
"PCMCIA Type I",
"PCMCIA Type II",
"PCMCIA Type III",
"Cardbus",
"Access Bus Port",
"SCSI II",
"SCSI Wide",
"PC-98",
"PC-98 Hireso",
"PC-H98",
"Video Port",
"Audio Port",
"Modem Port",
"Network Port",
"SATA",
"SAS",
"MFDP (Multi-Function Display Port)",
"Thunderbolt" /* 0x23 */
};
static const char *type_0xA0[] = {
"8251 Compatible", /* 0xA0 */
"8251 FIFO Compatible" /* 0xA1 */
};
if (code <= 0x23)
return type[code];
if (code >= 0xA0 && code <= 0xA1)
return type_0xA0[code - 0xA0];
if (code == 0xFF)
return "Other";
return out_of_spec;
}
/*
* 7.10 System Slots (Type 9)
*/
static const char *dmi_slot_type(u8 code)
{
/* 7.10.1 */
static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"ISA",
"MCA",
"EISA",
"PCI",
"PC Card (PCMCIA)",
"VLB",
"Proprietary",
"Processor Card",
"Proprietary Memory Card",
"I/O Riser Card",
"NuBus",
"PCI-66",
"AGP",
"AGP 2x",
"AGP 4x",
"PCI-X",
"AGP 8x",
"M.2 Socket 1-DP",
"M.2 Socket 1-SD",
"M.2 Socket 2",
"M.2 Socket 3",
"MXM Type I",
"MXM Type II",
"MXM Type III",
"MXM Type III-HE",
"MXM Type IV",
"MXM 3.0 Type A",
"MXM 3.0 Type B",
"PCI Express 2 SFF-8639 (U.2)",
"PCI Express 3 SFF-8639 (U.2)",
"PCI Express Mini 52-pin with bottom-side keep-outs",
"PCI Express Mini 52-pin without bottom-side keep-outs",
"PCI Express Mini 76-pin",
"PCI Express 4 SFF-8639 (U.2)",
"PCI Express 5 SFF-8639 (U.2)",
"OCP NIC 3.0 Small Form Factor (SFF)",
"OCP NIC 3.0 Large Form Factor (LFF)",
"OCP NIC Prior to 3.0" /* 0x28 */
};
static const char *type_0x30[] = {
"CXL FLexbus 1.0" /* 0x30 */
};
static const char *type_0xA0[] = {
"PC-98/C20", /* 0xA0 */
"PC-98/C24",
"PC-98/E",
"PC-98/Local Bus",
"PC-98/Card",
"PCI Express",
"PCI Express x1",
"PCI Express x2",
"PCI Express x4",
"PCI Express x8",
"PCI Express x16",
"PCI Express 2",
"PCI Express 2 x1",
"PCI Express 2 x2",
"PCI Express 2 x4",
"PCI Express 2 x8",
"PCI Express 2 x16",
"PCI Express 3",
"PCI Express 3 x1",
"PCI Express 3 x2",
"PCI Express 3 x4",
"PCI Express 3 x8",
"PCI Express 3 x16",
out_of_spec, /* 0xB7 */
"PCI Express 4",
"PCI Express 4 x1",
"PCI Express 4 x2",
"PCI Express 4 x4",
"PCI Express 4 x8",
"PCI Express 4 x16",
"PCI Express 5",
"PCI Express 5 x1",
"PCI Express 5 x2",
"PCI Express 5 x4",
"PCI Express 5 x8",
"PCI Express 5 x16",
"PCI Express 6+",
"EDSFF E1",
"EDSFF E3" /* 0xC6 */
};
/*
* Note to developers: when adding entries to these lists, check if
* function dmi_slot_id below needs updating too.
*/
if (code >= 0x01 && code <= 0x28)
return type[code - 0x01];
if (code == 0x30)
return type_0x30[code - 0x30];
if (code >= 0xA0 && code <= 0xC6)
return type_0xA0[code - 0xA0];
return out_of_spec;
}
static const char *dmi_slot_bus_width(u8 code)
{
/* 7.10.2 */
static const char *width[] = {
"Other", /* 0x01 */
"Unknown",
"8 bit",
"16 bit",
"32 bit",
"64 bit",
"128 bit",
"1x or x1",
"2x or x2",
"4x or x4",
"8x or x8",
"12x or x12",
"16x or x16",
"32x or x32" /* 0x0E */
};
if (code >= 0x01 && code <= 0x0E)
return width[code - 0x01];
return out_of_spec;
}
static const char *dmi_slot_current_usage(u8 code)
{
/* 7.10.3 */
static const char *usage[] = {
"Other", /* 0x01 */
"Unknown",
"Available",
"In Use",
"Unavailable" /* 0x05 */
};
if (code >= 0x01 && code <= 0x05)
return usage[code - 0x01];
return out_of_spec;
}
static const char *dmi_slot_length(u8 code)
{
/* 7.10.4 */
static const char *length[] = {
"Other", /* 0x01 */
"Unknown",
"Short",
"Long",
"2.5\" drive form factor",
"3.5\" drive form factor" /* 0x06 */
};
if (code >= 0x01 && code <= 0x06)
return length[code - 0x01];
return out_of_spec;
}
static void dmi_slot_id(u8 code1, u8 code2, u8 type)
{
/* 7.10.5 */
switch (type)
{
case 0x04: /* MCA */
pr_attr("ID", "%u", code1);
break;
case 0x05: /* EISA */
pr_attr("ID", "%u", code1);
break;
case 0x06: /* PCI */
case 0x0E: /* PCI */
case 0x0F: /* AGP */
case 0x10: /* AGP */
case 0x11: /* AGP */
case 0x12: /* PCI-X */
case 0x13: /* AGP */
case 0x1F: /* PCI Express 2 */
case 0x20: /* PCI Express 3 */
case 0x21: /* PCI Express Mini */
case 0x22: /* PCI Express Mini */
case 0x23: /* PCI Express Mini */
case 0xA5: /* PCI Express */
case 0xA6: /* PCI Express */
case 0xA7: /* PCI Express */
case 0xA8: /* PCI Express */
case 0xA9: /* PCI Express */
case 0xAA: /* PCI Express */
case 0xAB: /* PCI Express 2 */
case 0xAC: /* PCI Express 2 */
case 0xAD: /* PCI Express 2 */
case 0xAE: /* PCI Express 2 */
case 0xAF: /* PCI Express 2 */
case 0xB0: /* PCI Express 2 */
case 0xB1: /* PCI Express 3 */
case 0xB2: /* PCI Express 3 */
case 0xB3: /* PCI Express 3 */
case 0xB4: /* PCI Express 3 */
case 0xB5: /* PCI Express 3 */
case 0xB6: /* PCI Express 3 */
case 0xB8: /* PCI Express 4 */
case 0xB9: /* PCI Express 4 */
case 0xBA: /* PCI Express 4 */
case 0xBB: /* PCI Express 4 */
case 0xBC: /* PCI Express 4 */
case 0xBD: /* PCI Express 4 */
case 0xBE: /* PCI Express 5 */
case 0xBF: /* PCI Express 5 */
case 0xC0: /* PCI Express 5 */
case 0xC1: /* PCI Express 5 */
case 0xC2: /* PCI Express 5 */
case 0xC3: /* PCI Express 5 */
case 0xC4: /* PCI Express 6+ */
pr_attr("ID", "%u", code1);
break;
case 0x07: /* PCMCIA */
pr_attr("ID", "Adapter %u, Socket %u", code1, code2);
break;
}
}
static void dmi_slot_characteristics(const char *attr, u8 code1, u8 code2)
{
/* 7.10.6 */
static const char *characteristics1[] = {
"5.0 V is provided", /* 1 */
"3.3 V is provided",
"Opening is shared",
"PC Card-16 is supported",
"Cardbus is supported",
"Zoom Video is supported",
"Modem ring resume is supported" /* 7 */
};
/* 7.10.7 */
static const char *characteristics2[] = {
"PME signal is supported", /* 0 */
"Hot-plug devices are supported",
"SMBus signal is supported",
"PCIe slot bifurcation is supported",
"Async/surprise removal is supported",
"Flexbus slot, CXL 1.0 capable",
"Flexbus slot, CXL 2.0 capable",
"Flexbus slot, CXL 3.0 capable" /* 7 */
};
if (code1 & (1 << 0))
pr_attr(attr, "Unknown");
else if ((code1 & 0xFE) == 0 && code2 == 0)
pr_attr(attr, "None");
else
{
int i;
pr_list_start(attr, NULL);
for (i = 1; i <= 7; i++)
if (code1 & (1 << i))
pr_list_item("%s", characteristics1[i - 1]);
for (i = 0; i <= 7; i++)
if (code2 & (1 << i))
pr_list_item("%s", characteristics2[i]);
pr_list_end();
}
}
static void dmi_slot_segment_bus_func(u16 code1, u8 code2, u8 code3)
{
/* 7.10.8 */
if (!(code1 == 0xFFFF && code2 == 0xFF && code3 == 0xFF))
pr_attr("Bus Address", "%04x:%02x:%02x.%x",
code1, code2, code3 >> 3, code3 & 0x7);
}
static void dmi_slot_peers(u8 n, const u8 *data)
{
char attr[16];
int i;
for (i = 1; i <= n; i++, data += 5)
{
sprintf(attr, "Peer Device %hhu", (u8)i);
pr_attr(attr, "%04x:%02x:%02x.%x (Width %u)",
WORD(data), data[2], data[3] >> 3, data[3] & 0x07,
data[4]);
}
}
static void dmi_slot_information(u8 type, u8 code)
{
switch (type)
{
case 0x1F: /* PCI Express 2 */
case 0x20: /* PCI Express 3 */
case 0x21: /* PCI Express Mini */
case 0x22: /* PCI Express Mini */
case 0x23: /* PCI Express Mini */
case 0xA5: /* PCI Express */
case 0xA6: /* PCI Express */
case 0xA7: /* PCI Express */
case 0xA8: /* PCI Express */
case 0xA9: /* PCI Express */
case 0xAA: /* PCI Express */
case 0xAB: /* PCI Express 2 */
case 0xAC: /* PCI Express 2 */
case 0xAD: /* PCI Express 2 */
case 0xAE: /* PCI Express 2 */
case 0xAF: /* PCI Express 2 */
case 0xB0: /* PCI Express 2 */
case 0xB1: /* PCI Express 3 */
case 0xB2: /* PCI Express 3 */
case 0xB3: /* PCI Express 3 */
case 0xB4: /* PCI Express 3 */
case 0xB5: /* PCI Express 3 */
case 0xB6: /* PCI Express 3 */
case 0xB8: /* PCI Express 4 */
case 0xB9: /* PCI Express 4 */
case 0xBA: /* PCI Express 4 */
case 0xBB: /* PCI Express 4 */
case 0xBC: /* PCI Express 4 */
case 0xBD: /* PCI Express 4 */
case 0xBE: /* PCI Express 5 */
case 0xBF: /* PCI Express 5 */
case 0xC0: /* PCI Express 5 */
case 0xC1: /* PCI Express 5 */
case 0xC2: /* PCI Express 5 */
case 0xC3: /* PCI Express 5 */
case 0xC4: /* PCI Express 6+ */
if (code)
pr_attr("PCI Express Generation", "%u", code);
break;
}
}
static void dmi_slot_physical_width(u8 code)
{
if (code)
pr_attr("Slot Physical Width", "%s",
dmi_slot_bus_width(code));
}
static void dmi_slot_pitch(u16 code)
{
if (code)
pr_attr("Pitch", "%u.%02u mm", code / 100, code % 100);
}
static const char *dmi_slot_height(u8 code)
{
/* 7.10.3 */
static const char *height[] = {
"Not applicable", /* 0x00 */
"Other",
"Unknown",
"Full height",
"Low-profile" /* 0x04 */
};
if (code <= 0x04)
return height[code];
return out_of_spec;
}
/*
* 7.11 On Board Devices Information (Type 10)
*/
static const char *dmi_on_board_devices_type(u8 code)
{
/* 7.11.1 and 7.42.2 */
static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"Video",
"SCSI Controller",
"Ethernet",
"Token Ring",
"Sound",
"PATA Controller",
"SATA Controller",
"SAS Controller",
"Wireless LAN",
"Bluetooth",
"WWAN",
"eMMC",
"NVMe Controller",
"UFS Controller" /* 0x10 */
};
if (code >= 0x01 && code <= 0x10)
return type[code - 0x01];
return out_of_spec;
}
static void dmi_on_board_devices(const struct dmi_header *h)
{
u8 *p = h->data + 4;
u8 count = (h->length - 0x04) / 2;
int i;
for (i = 0; i < count; i++)
{
if (count == 1)
pr_handle_name("On Board Device Information");
else
pr_handle_name("On Board Device %d Information",
i + 1);
pr_attr("Type", "%s",
dmi_on_board_devices_type(p[2 * i] & 0x7F));
pr_attr("Status", "%s",
p[2 * i] & 0x80 ? "Enabled" : "Disabled");
pr_attr("Description", "%s", dmi_string(h, p[2 * i + 1]));
}
}
/*
* 7.12 OEM Strings (Type 11)
*/
static void dmi_oem_strings(const struct dmi_header *h)
{
char attr[11];
u8 *p = h->data + 4;
u8 count = p[0x00];
int i;
for (i = 1; i <= count; i++)
{
sprintf(attr, "String %hhu", (u8)i);
pr_attr(attr, "%s",dmi_string(h, i));
}
}
/*
* 7.13 System Configuration Options (Type 12)
*/
static void dmi_system_configuration_options(const struct dmi_header *h)
{
char attr[11];
u8 *p = h->data + 4;
u8 count = p[0x00];
int i;
for (i = 1; i <= count; i++)
{
sprintf(attr, "Option %hhu", (u8)i);
pr_attr(attr, "%s",dmi_string(h, i));
}
}
/*
* 7.14 BIOS Language Information (Type 13)
*/
static void dmi_bios_languages(const struct dmi_header *h)
{
u8 *p = h->data + 4;
u8 count = p[0x00];
int i;
for (i = 1; i <= count; i++)
pr_list_item("%s", dmi_string(h, i));
}
static const char *dmi_bios_language_format(u8 code)
{
if (code & 0x01)
return "Abbreviated";
else
return "Long";
}
/*
* 7.15 Group Associations (Type 14)
*/
static void dmi_group_associations_items(u8 count, const u8 *p)
{
int i;
for (i = 0; i < count; i++)
{
pr_list_item("0x%04X (%s)",
WORD(p + 3 * i + 1),
dmi_smbios_structure_type(p[3 * i]));
}
}
/*
* 7.16 System Event Log (Type 15)
*/
static const char *dmi_event_log_method(u8 code)
{
static const char *method[] = {
"Indexed I/O, one 8-bit index port, one 8-bit data port", /* 0x00 */
"Indexed I/O, two 8-bit index ports, one 8-bit data port",
"Indexed I/O, one 16-bit index port, one 8-bit data port",
"Memory-mapped physical 32-bit address",
"General-purpose non-volatile data functions" /* 0x04 */
};
if (code <= 0x04)
return method[code];
if (code >= 0x80)
return "OEM-specific";
return out_of_spec;
}
static void dmi_event_log_status(u8 code)
{
static const char *valid[] = {
"Invalid", /* 0 */
"Valid" /* 1 */
};
static const char *full[] = {
"Not Full", /* 0 */
"Full" /* 1 */
};
pr_attr("Status", "%s, %s",
valid[(code >> 0) & 1], full[(code >> 1) & 1]);
}
static void dmi_event_log_address(u8 method, const u8 *p)
{
/* 7.16.3 */
switch (method)
{
case 0x00:
case 0x01:
case 0x02:
pr_attr("Access Address", "Index 0x%04X, Data 0x%04X",
WORD(p), WORD(p + 2));
break;
case 0x03:
pr_attr("Access Address", "0x%08X", DWORD(p));
break;
case 0x04:
pr_attr("Access Address", "0x%04X", WORD(p));
break;
default:
pr_attr("Access Address", "Unknown");
}
}
static const char *dmi_event_log_header_type(u8 code)
{
static const char *type[] = {
"No Header", /* 0x00 */
"Type 1" /* 0x01 */
};
if (code <= 0x01)
return type[code];
if (code >= 0x80)
return "OEM-specific";
return out_of_spec;
}
static const char *dmi_event_log_descriptor_type(u8 code)
{
/* 7.16.6.1 */
static const char *type[] = {
NULL, /* 0x00 */
"Single-bit ECC memory error",
"Multi-bit ECC memory error",
"Parity memory error",
"Bus timeout",
"I/O channel block",
"Software NMI",
"POST memory resize",
"POST error",
"PCI parity error",
"PCI system error",
"CPU failure",
"EISA failsafe timer timeout",
"Correctable memory log disabled",
"Logging disabled",
NULL, /* 0x0F */
"System limit exceeded",
"Asynchronous hardware timer expired",
"System configuration information",
"Hard disk information",
"System reconfigured",
"Uncorrectable CPU-complex error",
"Log area reset/cleared",
"System boot" /* 0x17 */
};
if (code <= 0x17 && type[code] != NULL)
return type[code];
if (code >= 0x80 && code <= 0xFE)
return "OEM-specific";
if (code == 0xFF)
return "End of log";
return out_of_spec;
}
static const char *dmi_event_log_descriptor_format(u8 code)
{
/* 7.16.6.2 */
static const char *format[] = {
"None", /* 0x00 */
"Handle",
"Multiple-event",
"Multiple-event handle",
"POST results bitmap",
"System management",
"Multiple-event system management" /* 0x06 */
};
if (code <= 0x06)
return format[code];
if (code >= 0x80)
return "OEM-specific";
return out_of_spec;
}
static void dmi_event_log_descriptors(u8 count, u8 len, const u8 *p)
{
/* 7.16.1 */
char attr[16];
int i;
for (i = 0; i < count; i++)
{
if (len >= 0x02)
{
sprintf(attr, "Descriptor %d", i + 1);
pr_attr(attr, "%s",
dmi_event_log_descriptor_type(p[i * len]));
sprintf(attr, "Data Format %d", i + 1);
pr_attr(attr, "%s",
dmi_event_log_descriptor_format(p[i * len + 1]));
}
}
}
/*
* 7.17 Physical Memory Array (Type 16)
*/
static const char *dmi_memory_array_location(u8 code)
{
/* 7.17.1 */
static const char *location[] = {
"Other", /* 0x01 */
"Unknown",
"System Board Or Motherboard",
"ISA Add-on Card",
"EISA Add-on Card",
"PCI Add-on Card",
"MCA Add-on Card",
"PCMCIA Add-on Card",
"Proprietary Add-on Card",
"NuBus" /* 0x0A */
};
static const char *location_0xA0[] = {
"PC-98/C20 Add-on Card", /* 0xA0 */
"PC-98/C24 Add-on Card",
"PC-98/E Add-on Card",
"PC-98/Local Bus Add-on Card",
"CXL Add-on Card" /* 0xA4 */
};
if (code >= 0x01 && code <= 0x0A)
return location[code - 0x01];
if (code >= 0xA0 && code <= 0xA4)
return location_0xA0[code - 0xA0];
return out_of_spec;
}
static const char *dmi_memory_array_use(u8 code)
{
/* 7.17.2 */
static const char *use[] = {
"Other", /* 0x01 */
"Unknown",
"System Memory",
"Video Memory",
"Flash Memory",
"Non-volatile RAM",
"Cache Memory" /* 0x07 */
};
if (code >= 0x01 && code <= 0x07)
return use[code - 0x01];
return out_of_spec;
}
static const char *dmi_memory_array_ec_type(u8 code)
{
/* 7.17.3 */
static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"None",
"Parity",
"Single-bit ECC",
"Multi-bit ECC",
"CRC" /* 0x07 */
};
if (code >= 0x01 && code <= 0x07)
return type[code - 0x01];
return out_of_spec;
}
static void dmi_memory_array_error_handle(u16 code)
{
if (code == 0xFFFE)
pr_attr("Error Information Handle", "Not Provided");
else if (code == 0xFFFF)
pr_attr("Error Information Handle", "No Error");
else
pr_attr("Error Information Handle", "0x%04X", code);
}
/*
* 7.18 Memory Device (Type 17)
*/
static void dmi_memory_device_width(const char *attr, u16 code)
{
/*
* If no memory module is present, width may be 0
*/
if (code == 0xFFFF || (code == 0 && !(opt.flags & FLAG_NO_QUIRKS)))
pr_attr(attr, "Unknown");
else
pr_attr(attr, "%u bits", code);
}
static void dmi_memory_device_size(u16 code)
{
if (code == 0)
pr_attr("Size", "No Module Installed");
else if (code == 0xFFFF)
pr_attr("Size", "Unknown");
else
{
u64 s = { .l = code & 0x7FFF };
if (!(code & 0x8000))
s.l <<= 10;
dmi_print_memory_size("Size", s, 1);
}
}
static void dmi_memory_device_extended_size(u32 code)
{
code &= 0x7FFFFFFFUL;
/*
* Use the greatest unit for which the exact value can be displayed
* as an integer without rounding
*/
if (code & 0x3FFUL)
pr_attr("Size", "%lu MB", (unsigned long)code);
else if (code & 0xFFC00UL)
pr_attr("Size", "%lu GB", (unsigned long)code >> 10);
else
pr_attr("Size", "%lu TB", (unsigned long)code >> 20);
}
static void dmi_memory_voltage_value(const char *attr, u16 code)
{
if (code == 0)
pr_attr(attr, "Unknown");
else
pr_attr(attr, code % 100 ? "%g V" : "%.1f V",
(float)code / 1000);
}
static const char *dmi_memory_device_form_factor(u8 code)
{
/* 7.18.1 */
static const char *form_factor[] = {
"Other", /* 0x01 */
"Unknown",
"SIMM",
"SIP",
"Chip",
"DIP",
"ZIP",
"Proprietary Card",
"DIMM",
"TSOP",
"Row Of Chips",
"RIMM",
"SODIMM",
"SRIMM",
"FB-DIMM",
"Die" /* 0x10 */
};
if (code >= 0x01 && code <= 0x10)
return form_factor[code - 0x01];
return out_of_spec;
}
static void dmi_memory_device_set(u8 code)
{
if (code == 0)
pr_attr("Set", "None");
else if (code == 0xFF)
pr_attr("Set", "Unknown");
else
pr_attr("Set", "%u", code);
}
static const char *dmi_memory_device_type(u8 code)
{
/* 7.18.2 */
static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"DRAM",
"EDRAM",
"VRAM",
"SRAM",
"RAM",
"ROM",
"Flash",
"EEPROM",
"FEPROM",
"EPROM",
"CDRAM",
"3DRAM",
"SDRAM",
"SGRAM",
"RDRAM",
"DDR",
"DDR2",
"DDR2 FB-DIMM",
"Reserved",
"Reserved",
"Reserved",
"DDR3",
"FBD2",
"DDR4",
"LPDDR",
"LPDDR2",
"LPDDR3",
"LPDDR4",
"Logical non-volatile device",
"HBM",
"HBM2",
"DDR5",
"LPDDR5",
"HBM3" /* 0x24 */
};
if (code >= 0x01 && code <= 0x24)
return type[code - 0x01];
return out_of_spec;
}
static void dmi_memory_device_type_detail(u16 code)
{
/* 7.18.3 */
static const char *detail[] = {
"Other", /* 1 */
"Unknown",
"Fast-paged",
"Static Column",
"Pseudo-static",
"RAMBus",
"Synchronous",
"CMOS",
"EDO",
"Window DRAM",
"Cache DRAM",
"Non-Volatile",
"Registered (Buffered)",
"Unbuffered (Unregistered)",
"LRDIMM" /* 15 */
};
char list[172]; /* Update length if you touch the array above */
if ((code & 0xFFFE) == 0)
pr_attr("Type Detail", "None");
else
{
int i, off = 0;
list[0] = '\0';
for (i = 1; i <= 15; i++)
if (code & (1 << i))
off += sprintf(list + off, off ? " %s" : "%s",
detail[i - 1]);
pr_attr("Type Detail", list);
}
}
static void dmi_memory_device_speed(const char *attr, u16 code1, u32 code2)
{
if (code1 == 0xFFFF)
{
if (code2 == 0)
pr_attr(attr, "Unknown");
else
pr_attr(attr, "%lu MT/s", code2);
}
else
{
if (code1 == 0)
pr_attr(attr, "Unknown");
else
pr_attr(attr, "%u MT/s", code1);
}
}
static void dmi_memory_technology(u8 code)
{
/* 7.18.6 */
static const char * const technology[] = {
"Other", /* 0x01 */
"Unknown",
"DRAM",
"NVDIMM-N",
"NVDIMM-F",
"NVDIMM-P",
"Intel Optane DC persistent memory" /* 0x07 */
};
if (code >= 0x01 && code <= 0x07)
pr_attr("Memory Technology", "%s", technology[code - 0x01]);
else
pr_attr("Memory Technology", "%s", out_of_spec);
}
static void dmi_memory_operating_mode_capability(u16 code)
{
/* 7.18.7 */
static const char * const mode[] = {
"Other", /* 1 */
"Unknown",
"Volatile memory",
"Byte-accessible persistent memory",
"Block-accessible persistent memory" /* 5 */
};
char list[99]; /* Update length if you touch the array above */
if ((code & 0xFFFE) == 0)
pr_attr("Memory Operating Mode Capability", "None");
else {
int i, off = 0;
list[0] = '\0';
for (i = 1; i <= 5; i++)
if (code & (1 << i))
off += sprintf(list + off, off ? " %s" : "%s",
mode[i - 1]);
pr_attr("Memory Operating Mode Capability", list);
}
}
static void dmi_memory_manufacturer_id(const char *attr, u16 code)
{
/* 7.18.8 */
/* 7.18.10 */
/* 7.18.15 */
/* 7.17.17 */
/* LSB is 7-bit Odd Parity number of continuation codes */
if (code == 0)
pr_attr(attr, "Unknown");
else
pr_attr(attr, "Bank %d, Hex 0x%02X",
(code & 0x7F) + 1, code >> 8);
}
static void dmi_memory_product_id(const char *attr, u16 code)
{
/* 7.18.9 */
/* 7.18.11 */
if (code == 0)
pr_attr(attr, "Unknown");
else
pr_attr(attr, "0x%04X", code);
}
static void dmi_memory_size(const char *attr, u64 code)
{
/* 7.18.12 */
/* 7.18.13 */
if (code.h == 0xFFFFFFFF && code.l == 0xFFFFFFFF)
pr_attr(attr, "Unknown");
else if (code.h == 0x0 && code.l == 0x0)
pr_attr(attr, "None");
else
dmi_print_memory_size(attr, code, 0);
}
static void dmi_memory_revision(const char *attr_type, u16 code, u8 mem_type)
{
/* 7.18.16 */
/* 7.18.18 */
char attr[22];
if (code == 0xFF00)
{
snprintf(attr, sizeof(attr), "%s Revision Number", attr_type);
pr_attr(attr, "Unknown");
}
else if (mem_type == 0x22 || mem_type == 0x23) /* DDR5 */
{
u8 dev_type = (code >> 8) & 0x0F;
u8 dev_rev = code & 0xFF;
if (code & 0x8000) /* Installed */
{
snprintf(attr, sizeof(attr), "%s Device Type",
attr_type);
pr_attr(attr, "%hu", dev_type);
snprintf(attr, sizeof(attr), "%s Device Revision",
attr_type);
pr_attr(attr, "%hu.%hu", dev_rev >> 4, dev_rev & 0x0F);
}
else
{
snprintf(attr, sizeof(attr), "%s Device Type",
attr_type);
pr_attr(attr, "Not Installed");
}
}
else /* Generic fallback */
{
snprintf(attr, sizeof(attr), "%s Revision Number", attr_type);
pr_attr(attr, "0x%04x", code);
}
}
/*
* 7.19 32-bit Memory Error Information (Type 18)
*/
static const char *dmi_memory_error_type(u8 code)
{
/* 7.19.1 */
static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"OK",
"Bad Read",
"Parity Error",
"Single-bit Error",
"Double-bit Error",
"Multi-bit Error",
"Nibble Error",
"Checksum Error",
"CRC Error",
"Corrected Single-bit Error",
"Corrected Error",
"Uncorrectable Error" /* 0x0E */
};
if (code >= 0x01 && code <= 0x0E)
return type[code - 0x01];
return out_of_spec;
}
static const char *dmi_memory_error_granularity(u8 code)
{
/* 7.19.2 */
static const char *granularity[] = {
"Other", /* 0x01 */
"Unknown",
"Device Level",
"Memory Partition Level" /* 0x04 */
};
if (code >= 0x01 && code <= 0x04)
return granularity[code - 0x01];
return out_of_spec;
}
static const char *dmi_memory_error_operation(u8 code)
{
/* 7.19.3 */
static const char *operation[] = {
"Other", /* 0x01 */
"Unknown",
"Read",
"Write",
"Partial Write" /* 0x05 */
};
if (code >= 0x01 && code <= 0x05)
return operation[code - 0x01];
return out_of_spec;
}
static void dmi_memory_error_syndrome(u32 code)
{
if (code == 0x00000000)
pr_attr("Vendor Syndrome", "Unknown");
else
pr_attr("Vendor Syndrome", "0x%08X", code);
}
static void dmi_32bit_memory_error_address(const char *attr, u32 code)
{
if (code == 0x80000000)
pr_attr(attr, "Unknown");
else
pr_attr(attr, "0x%08X", code);
}
/*
* 7.20 Memory Array Mapped Address (Type 19)
*/
static void dmi_mapped_address_size(u32 code)
{
if (code == 0)
pr_attr("Range Size", "Invalid");
else
{
u64 size;
size.h = 0;
size.l = code;
dmi_print_memory_size("Range Size", size, 1);
}
}
static void dmi_mapped_address_extended_size(u64 start, u64 end)
{
if (start.h == end.h && start.l == end.l)
pr_attr("Range Size", "Invalid");
else
dmi_print_memory_size("Range Size", u64_range(start, end), 0);
}
/*
* 7.21 Memory Device Mapped Address (Type 20)
*/
static void dmi_mapped_address_row_position(u8 code)
{
if (code == 0)
pr_attr("Partition Row Position", "%s", out_of_spec);
else if (code == 0xFF)
pr_attr("Partition Row Position", "Unknown");
else
pr_attr("Partition Row Position", "%u", code);
}
static void dmi_mapped_address_interleave_position(u8 code)
{
if (code != 0)
{
if (code == 0xFF)
pr_attr("Interleave Position", "Unknown");
else
pr_attr("Interleave Position", "%u", code);
}
}
static void dmi_mapped_address_interleaved_data_depth(u8 code)
{
if (code != 0)
{
if (code == 0xFF)
pr_attr("Interleaved Data Depth", "Unknown");
else
pr_attr("Interleaved Data Depth", "%u", code);
}
}
/*
* 7.22 Built-in Pointing Device (Type 21)
*/
static const char *dmi_pointing_device_type(u8 code)
{
/* 7.22.1 */
static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"Mouse",
"Track Ball",
"Track Point",
"Glide Point",
"Touch Pad",
"Touch Screen",
"Optical Sensor" /* 0x09 */
};
if (code >= 0x01 && code <= 0x09)
return type[code - 0x01];
return out_of_spec;
}
static const char *dmi_pointing_device_interface(u8 code)
{
/* 7.22.2 */
static const char *interface[] = {
"Other", /* 0x01 */
"Unknown",
"Serial",
"PS/2",
"Infrared",
"HIP-HIL",
"Bus Mouse",
"ADB (Apple Desktop Bus)" /* 0x08 */
};
static const char *interface_0xA0[] = {
"Bus Mouse DB-9", /* 0xA0 */
"Bus Mouse Micro DIN",
"USB",
"I2C",
"SPI" /* 0xA4 */
};
if (code >= 0x01 && code <= 0x08)
return interface[code - 0x01];
if (code >= 0xA0 && code <= 0xA4)
return interface_0xA0[code - 0xA0];
return out_of_spec;
}
/*
* 7.23 Portable Battery (Type 22)
*/
static const char *dmi_battery_chemistry(u8 code)
{
/* 7.23.1 */
static const char *chemistry[] = {
"Other", /* 0x01 */
"Unknown",
"Lead Acid",
"Nickel Cadmium",
"Nickel Metal Hydride",
"Lithium Ion",
"Zinc Air",
"Lithium Polymer" /* 0x08 */
};
if (code >= 0x01 && code <= 0x08)
return chemistry[code - 0x01];
return out_of_spec;
}
static void dmi_battery_capacity(u16 code, u8 multiplier)
{
if (code == 0)
pr_attr("Design Capacity", "Unknown");
else
pr_attr("Design Capacity", "%u mWh", code * multiplier);
}
static void dmi_battery_voltage(u16 code)
{
if (code == 0)
pr_attr("Design Voltage", "Unknown");
else
pr_attr("Design Voltage", "%u mV", code);
}
static void dmi_battery_maximum_error(u8 code)
{
if (code == 0xFF)
pr_attr("Maximum Error", "Unknown");
else
pr_attr("Maximum Error", "%u%%", code);
}
/*
* 7.24 System Reset (Type 23)
*/
/* code is assumed to be a 2-bit value */
static const char *dmi_system_reset_boot_option(u8 code)
{
static const char *option[] = {
out_of_spec, /* 0x0 */
"Operating System", /* 0x1 */
"System Utilities",
"Do Not Reboot" /* 0x3 */
};
return option[code];
}
static void dmi_system_reset_count(const char *attr, u16 code)
{
if (code == 0xFFFF)
pr_attr(attr, "Unknown");
else
pr_attr(attr, "%u", code);
}
static void dmi_system_reset_timer(const char *attr, u16 code)
{
if (code == 0xFFFF)
pr_attr(attr, "Unknown");
else
pr_attr(attr, "%u min", code);
}
/*
* 7.25 Hardware Security (Type 24)
*/
static const char *dmi_hardware_security_status(u8 code)
{
static const char *status[] = {
"Disabled", /* 0x00 */
"Enabled",
"Not Implemented",
"Unknown" /* 0x03 */
};
return status[code];
}
/*
* 7.26 System Power Controls (Type 25)
*/
static void dmi_power_controls_power_on(const u8 *p)
{
char time[15];
int off = 0;
/* 7.26.1 */
if (dmi_bcd_range(p[0], 0x01, 0x12))
off += sprintf(time + off, "%02X", p[0]);
else
off += sprintf(time + off, "*");
if (dmi_bcd_range(p[1], 0x01, 0x31))
off += sprintf(time + off, "-%02X", p[1]);
else
off += sprintf(time + off, "-*");
if (dmi_bcd_range(p[2], 0x00, 0x23))
off += sprintf(time + off, " %02X", p[2]);
else
off += sprintf(time + off, " *");
if (dmi_bcd_range(p[3], 0x00, 0x59))
off += sprintf(time + off, ":%02X", p[3]);
else
off += sprintf(time + off, ":*");
if (dmi_bcd_range(p[4], 0x00, 0x59))
off += sprintf(time + off, ":%02X", p[4]);
else
off += sprintf(time + off, ":*");
pr_attr("Next Scheduled Power-on", time);
}
/*
* 7.27 Voltage Probe (Type 26)
*/
static const char *dmi_voltage_probe_location(u8 code)
{
/* 7.27.1 */
static const char *location[] = {
"Other", /* 0x01 */
"Unknown",
"Processor",
"Disk",
"Peripheral Bay",
"System Management Module",
"Motherboard",
"Memory Module",
"Processor Module",
"Power Unit",
"Add-in Card" /* 0x0B */
};
if (code >= 0x01 && code <= 0x0B)
return location[code - 0x01];
return out_of_spec;
}
static const char *dmi_probe_status(u8 code)
{
/* 7.27.1 */
static const char *status[] = {
"Other", /* 0x01 */
"Unknown",
"OK",
"Non-critical",
"Critical",
"Non-recoverable" /* 0x06 */
};
if (code >= 0x01 && code <= 0x06)
return status[code - 0x01];
return out_of_spec;
}
static void dmi_voltage_probe_value(const char *attr, u16 code)
{
if (code == 0x8000)
pr_attr(attr, "Unknown");
else
pr_attr(attr, "%.3f V", (float)(i16)code / 1000);
}
static void dmi_voltage_probe_resolution(u16 code)
{
if (code == 0x8000)
pr_attr("Resolution", "Unknown");
else
pr_attr("Resolution", "%.1f mV", (float)code / 10);
}
static void dmi_probe_accuracy(u16 code)
{
if (code == 0x8000)
pr_attr("Accuracy", "Unknown");
else
pr_attr("Accuracy", "%.2f%%", (float)code / 100);
}
/*
* 7.28 Cooling Device (Type 27)
*/
static const char *dmi_cooling_device_type(u8 code)
{
/* 7.28.1 */
static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"Fan",
"Centrifugal Blower",
"Chip Fan",
"Cabinet Fan",
"Power Supply Fan",
"Heat Pipe",
"Integrated Refrigeration" /* 0x09 */
};
static const char *type_0x10[] = {
"Active Cooling", /* 0x10 */
"Passive Cooling" /* 0x11 */
};
if (code >= 0x01 && code <= 0x09)
return type[code - 0x01];
if (code >= 0x10 && code <= 0x11)
return type_0x10[code - 0x10];
return out_of_spec;
}
static void dmi_cooling_device_speed(u16 code)
{
if (code == 0x8000)
pr_attr("Nominal Speed", "Unknown Or Non-rotating");
else
pr_attr("Nominal Speed", "%u rpm", code);
}
/*
* 7.29 Temperature Probe (Type 28)
*/
static const char *dmi_temperature_probe_location(u8 code)
{
/* 7.29.1 */
static const char *location[] = {
"Other", /* 0x01 */
"Unknown",
"Processor",
"Disk",
"Peripheral Bay",
"System Management Module",
"Motherboard",
"Memory Module",
"Processor Module",
"Power Unit",
"Add-in Card",
"Front Panel Board",
"Back Panel Board",
"Power System Board",
"Drive Back Plane" /* 0x0F */
};
if (code >= 0x01 && code <= 0x0F)
return location[code - 0x01];
return out_of_spec;
}
static void dmi_temperature_probe_value(const char *attr, u16 code)
{
if (code == 0x8000)
pr_attr(attr, "Unknown");
else
pr_attr(attr, "%.1f deg C", (float)(i16)code / 10);
}
static void dmi_temperature_probe_resolution(u16 code)
{
if (code == 0x8000)
pr_attr("Resolution", "Unknown");
else
pr_attr("Resolution", "%.3f deg C", (float)code / 1000);
}
/*
* 7.30 Electrical Current Probe (Type 29)
*/
static void dmi_current_probe_value(const char *attr, u16 code)
{
if (code == 0x8000)
pr_attr(attr, "Unknown");
else
pr_attr(attr, "%.3f A", (float)(i16)code / 1000);
}
static void dmi_current_probe_resolution(u16 code)
{
if (code == 0x8000)
pr_attr("Resolution", "Unknown");
else
pr_attr("Resolution", "%.1f mA", (float)code / 10);
}
/*
* 7.33 System Boot Information (Type 32)
*/
static const char *dmi_system_boot_status(u8 code)
{
static const char *status[] = {
"No errors detected", /* 0 */
"No bootable media",
"Operating system failed to load",
"Firmware-detected hardware failure",
"Operating system-detected hardware failure",
"User-requested boot",
"System security violation",
"Previously-requested image",
"System watchdog timer expired" /* 8 */
};
if (code <= 8)
return status[code];
if (code >= 128 && code <= 191)
return "OEM-specific";
if (code >= 192)
return "Product-specific";
return out_of_spec;
}
/*
* 7.34 64-bit Memory Error Information (Type 33)
*/
static void dmi_64bit_memory_error_address(const char *attr, u64 code)
{
if (code.h == 0x80000000 && code.l == 0x00000000)
pr_attr(attr, "Unknown");
else
pr_attr(attr, "0x%08X%08X", code.h, code.l);
}
/*
* 7.35 Management Device (Type 34)
*/
/*
* Several boards have a bug where some type 34 structures have their
* length incorrectly set to 0x10 instead of 0x0B. This causes the
* first 5 characters of the device name to be trimmed. It's easy to
* check and fix, so do it, but warn.
*/
static void dmi_fixup_type_34(struct dmi_header *h, int display)
{
u8 *p = h->data;
/* Make sure the hidden data is ASCII only */
if (h->length == 0x10
&& is_printable(p + 0x0B, 0x10 - 0x0B))
{
if (!(opt.flags & FLAG_QUIET) && display)
fprintf(stderr,
"Invalid entry length (%u). Fixed up to %u.\n",
0x10, 0x0B);
h->length = 0x0B;
}
}
static const char *dmi_management_device_type(u8 code)
{
/* 7.35.1 */
static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"LM75",
"LM78",
"LM79",
"LM80",
"LM81",
"ADM9240",
"DS1780",
"MAX1617",
"GL518SM",
"W83781D",
"HT82H791" /* 0x0D */
};
if (code >= 0x01 && code <= 0x0D)
return type[code - 0x01];
return out_of_spec;
}
static const char *dmi_management_device_address_type(u8 code)
{
/* 7.35.2 */
static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"I/O Port",
"Memory",
"SMBus" /* 0x05 */
};
if (code >= 0x01 && code <= 0x05)
return type[code - 0x01];
return out_of_spec;
}
/*
* 7.38 Memory Channel (Type 37)
*/
static const char *dmi_memory_channel_type(u8 code)
{
/* 7.38.1 */
static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"RamBus",
"SyncLink" /* 0x04 */
};
if (code >= 0x01 && code <= 0x04)
return type[code - 0x01];
return out_of_spec;
}
static void dmi_memory_channel_devices(u8 count, const u8 *p)
{
char attr[18];
int i;
for (i = 1; i <= count; i++)
{
sprintf(attr, "Device %hhu Load", (u8)i);
pr_attr(attr, "%u", p[3 * i]);
if (!(opt.flags & FLAG_QUIET))
{
sprintf(attr, "Device %hhu Handle", (u8)i);
pr_attr(attr, "0x%04X", WORD(p + 3 * i + 1));
}
}
}
/*
* 7.39 IPMI Device Information (Type 38)
*/
static const char *dmi_ipmi_interface_type(u8 code)
{
/* 7.39.1 and IPMI 2.0, appendix C1, table C1-2 */
static const char *type[] = {
"Unknown", /* 0x00 */
"KCS (Keyboard Control Style)",
"SMIC (Server Management Interface Chip)",
"BT (Block Transfer)",
"SSIF (SMBus System Interface)" /* 0x04 */
};
if (code <= 0x04)
return type[code];
return out_of_spec;
}
static void dmi_ipmi_base_address(u8 type, const u8 *p, u8 lsb)
{
if (type == 0x04) /* SSIF */
{
pr_attr("Base Address", "0x%02X (SMBus)", (*p) >> 1);
}
else
{
u64 address = QWORD(p);
pr_attr("Base Address", "0x%08X%08X (%s)",
address.h, (address.l & ~1) | lsb,
address.l & 1 ? "I/O" : "Memory-mapped");
}
}
/* code is assumed to be a 2-bit value */
static const char *dmi_ipmi_register_spacing(u8 code)
{
/* IPMI 2.0, appendix C1, table C1-1 */
static const char *spacing[] = {
"Successive Byte Boundaries", /* 0x00 */
"32-bit Boundaries",
"16-byte Boundaries", /* 0x02 */
out_of_spec /* 0x03 */
};
return spacing[code];
}
/*
* 7.40 System Power Supply (Type 39)
*/
static void dmi_power_supply_power(u16 code)
{
if (code == 0x8000)
pr_attr("Max Power Capacity", "Unknown");
else
pr_attr("Max Power Capacity", "%u W", (unsigned int)code);
}
static const char *dmi_power_supply_type(u8 code)
{
/* 7.40.1 */
static const char *type[] = {
"Other", /* 0x01 */
"Unknown",
"Linear",
"Switching",
"Battery",
"UPS",
"Converter",
"Regulator" /* 0x08 */
};
if (code >= 0x01 && code <= 0x08)
return type[code - 0x01];
return out_of_spec;
}
static const char *dmi_power_supply_status(u8 code)
{
/* 7.40.1 */
static const char *status[] = {
"Other", /* 0x01 */
"Unknown",
"OK",
"Non-critical",
"Critical" /* 0x05 */
};
if (code >= 0x01 && code <= 0x05)
return status[code - 0x01];
return out_of_spec;
}
static const char *dmi_power_supply_range_switching(u8 code)
{
/* 7.40.1 */
static const char *switching[] = {
"Other", /* 0x01 */
"Unknown",
"Manual",
"Auto-switch",
"Wide Range",
"N/A" /* 0x06 */
};
if (code >= 0x01 && code <= 0x06)
return switching[code - 0x01];
return out_of_spec;
}
/*
* 7.41 Additional Information (Type 40)
*
* Proper support of this entry type would require redesigning a large part of
* the code, so I am waiting to see actual implementations of it to decide
* whether it's worth the effort.
*/
static void dmi_additional_info(const struct dmi_header *h)
{
u8 *p = h->data + 4;
u8 count = *p++;
u8 length;
int i, offset = 5;
for (i = 0; i < count; i++)
{
pr_handle_name("Additional Information %d", i + 1);
/* Check for short entries */
if (h->length < offset + 1) break;
length = p[0x00];
if (length < 0x05 || h->length < offset + length) break;
pr_attr("Referenced Handle", "0x%04x",
WORD(p + 0x01));
pr_attr("Referenced Offset", "0x%02x",
p[0x03]);
pr_attr("String", "%s",
dmi_string(h, p[0x04]));
switch (length - 0x05)
{
case 1:
pr_attr("Value", "0x%02x", p[0x05]);
break;
case 2:
pr_attr("Value", "0x%04x", WORD(p + 0x05));
break;
case 4:
pr_attr("Value", "0x%08x", DWORD(p + 0x05));
break;
default:
pr_attr("Value", "Unexpected size");
break;
}
p += length;
offset += length;
}
}
/*
* 7.43 Management Controller Host Interface (Type 42)
*/
static const char *dmi_management_controller_host_type(u8 code)
{
/* DMTF DSP0239 (MCTP) version 1.1.0 */
static const char *type[] = {
"KCS: Keyboard Controller Style", /* 0x02 */
"8250 UART Register Compatible",
"16450 UART Register Compatible",
"16550/16550A UART Register Compatible",
"16650/16650A UART Register Compatible",
"16750/16750A UART Register Compatible",
"16850/16850A UART Register Compatible" /* 0x08 */
};
if (code >= 0x02 && code <= 0x08)
return type[code - 0x02];
if (code <= 0x3F)
return "MCTP";
if (code == 0x40)
return "Network";
if (code == 0xF0)
return "OEM";
return out_of_spec;
}
/*
* 7.43.2: Protocol Record Types
*/
static const char *dmi_protocol_record_type(u8 type)
{
const char *protocol[] = {
"Reserved", /* 0x0 */
"Reserved",
"IPMI",
"MCTP",
"Redfish over IP", /* 0x4 */
};
if (type <= 0x4)
return protocol[type];
if (type == 0xF0)
return "OEM";
return out_of_spec;
}
/*
* DSP0270: 8.4.2: Protocol IP Assignment types
*/
static const char *dmi_protocol_assignment_type(u8 type)
{
const char *assignment[] = {
"Unknown", /* 0x0 */
"Static",
"DHCP",
"AutoConf",
"Host Selected", /* 0x4 */
};
if (type <= 0x4)
return assignment[type];
return out_of_spec;
}
/*
* DSP0270: 8.4.3: Protocol IP Address type
*/
static const char *dmi_address_type(u8 type)
{
const char *addressformat[] = {
"Unknown", /* 0x0 */
"IPv4",
"IPv6", /* 0x2 */
};
if (type <= 0x2)
return addressformat[type];
return out_of_spec;
}
/*
* DSP0270: 8.4.3 Protocol Address decode
*/
static const char *dmi_address_decode(u8 *data, char *storage, u8 addrtype)
{
if (addrtype == 0x1) /* IPv4 */
return inet_ntop(AF_INET, data, storage, 64);
if (addrtype == 0x2) /* IPv6 */
return inet_ntop(AF_INET6, data, storage, 64);
return out_of_spec;
}
/*
* DSP0270: 8.4: Parse the protocol record format
*/
static void dmi_parse_protocol_record(u8 *rec)
{
u8 rid;
u8 rlen;
u8 *rdata;
char buf[64];
u8 assign_val;
u8 addrtype;
u8 hlen;
const char *addrstr;
const char *hname;
char attr[38];
/* DSP0270: 8.4: Protocol Identifier */
rid = rec[0x0];
/* DSP0270: 8.4: Protocol Record Length */
rlen = rec[0x1];
/* DSP0270: 8.4: Protocol Record Data */
rdata = &rec[0x2];
pr_attr("Protocol ID", "%02x (%s)", rid,
dmi_protocol_record_type(rid));
/*
* Don't decode anything other than Redfish for now
* Note 0x4 is Redfish over IP in 7.43.2
* and DSP0270: 8.4
*/
if (rid != 0x4)
return;
/*
* Ensure that the protocol record is of sufficient length
* For RedFish that means rlen must be at least 91 bytes
* other protcols will need different length checks
*/
if (rlen < 91)
return;
/*
* DSP0270: 8.4.1: Redfish Over IP Service UUID
* Note: ver is hardcoded to 0x311 here just for
* convenience. It could get passed from the SMBIOS
* header, but that's a lot of passing of pointers just
* to get that info, and the only thing it is used for is
* to determine the endianness of the field. Since we only
* do this parsing on versions of SMBIOS after 3.1.1, and the
* endianness of the field is always little after version 2.6.0
* we can just pick a sufficiently recent version here.
*/
dmi_system_uuid(pr_subattr, "Service UUID", &rdata[0], 0x311);
/*
* DSP0270: 8.4.1: Redfish Over IP Host IP Assignment Type
* Note, using decimal indices here, as the DSP0270
* uses decimal, so as to make it more comparable
*/
assign_val = rdata[16];
pr_subattr("Host IP Assignment Type", "%s",
dmi_protocol_assignment_type(assign_val));
/* DSP0270: 8.4.1: Redfish Over IP Host Address format */
addrtype = rdata[17];
addrstr = dmi_address_type(addrtype);
pr_subattr("Host IP Address Format", "%s",
addrstr);
/* DSP0270: 8.4.1 IP Assignment types */
/* We only use the Host IP Address and Mask if the assignment type is static */
if (assign_val == 0x1 || assign_val == 0x3)
{
/* DSP0270: 8.4.1: the Host IPv[4|6] Address */
sprintf(attr, "%s Address", addrstr);
pr_subattr(attr, "%s",
dmi_address_decode(&rdata[18], buf, addrtype));
/* DSP0270: 8.4.1: Prints the Host IPv[4|6] Mask */
sprintf(attr, "%s Mask", addrstr);
pr_subattr(attr, "%s",
dmi_address_decode(&rdata[34], buf, addrtype));
}
/* DSP0270: 8.4.1: Get the Redfish Service IP Discovery Type */
assign_val = rdata[50];
/* Redfish Service IP Discovery type mirrors Host IP Assignment type */
pr_subattr("Redfish Service IP Discovery Type", "%s",
dmi_protocol_assignment_type(assign_val));
/* DSP0270: 8.4.1: Get the Redfish Service IP Address Format */
addrtype = rdata[51];
addrstr = dmi_address_type(addrtype);
pr_subattr("Redfish Service IP Address Format", "%s",
addrstr);
if (assign_val == 0x1 || assign_val == 0x3)
{
u16 port;
u32 vlan;
/* DSP0270: 8.4.1: Prints the Redfish IPv[4|6] Service Address */
sprintf(attr, "%s Redfish Service Address", addrstr);
pr_subattr(attr, "%s",
dmi_address_decode(&rdata[52], buf,
addrtype));
/* DSP0270: 8.4.1: Prints the Redfish IPv[4|6] Service Mask */
sprintf(attr, "%s Redfish Service Mask", addrstr);
pr_subattr(attr, "%s",
dmi_address_decode(&rdata[68], buf,
addrtype));
/* DSP0270: 8.4.1: Redfish vlan and port info */
port = WORD(&rdata[84]);
vlan = DWORD(&rdata[86]);
pr_subattr("Redfish Service Port", "%hu", port);
pr_subattr("Redfish Service Vlan", "%u", vlan);
}
/* DSP0270: 8.4.1: Redfish host length and name */
hlen = rdata[90];
/*
* DSP0270: 8.4.1: The length of the host string + 91 (the minimum
* size of a protocol record) cannot exceed the record length
* (rec[0x1])
*/
hname = (const char *)&rdata[91];
if (hlen + 91 > rlen)
{
hname = out_of_spec;
hlen = strlen(out_of_spec);
}
pr_subattr("Redfish Service Hostname", "%.*s", hlen, hname);
}
/*
* DSP0270: 8.3: Device type ennumeration
*/
static const char *dmi_parse_device_type(u8 type)
{
const char *devname[] = {
"USB", /* 0x2 */
"PCI/PCIe", /* 0x3 */
"USB v2", /* 0x4 */
"PCI/PCIe v2", /* 0x5 */
};
if (type >= 0x2 && type <= 0x5)
return devname[type - 0x2];
if (type >= 0x80)
return "OEM";
return out_of_spec;
}
/*
* DSP0270: 8.3.7: Device Characteristics
*/
static void dmi_device_characteristics(u16 code)
{
const char *characteristics[] = {
"Credential bootstrapping via IPMI is supported", /* 0 */
/* Reserved */
};
if ((code & 0x1) == 0)
pr_list_item("None");
else
{
int i;
for (i = 0; i < 1; i++)
if (code & (1 << i))
pr_list_item("%s", characteristics[i]);
}
}
static void dmi_parse_controller_structure(const struct dmi_header *h)
{
int i;
u8 *data = h->data;
/* Host interface type */
u8 type;
/* Host Interface specific data length */
u8 len;
u8 count;
u32 total_read;
/*
* Minimum length of this struct is 0xB bytes
*/
if (h->length < 0xB)
return;
/*
* Also need to ensure that the interface specific data length
* plus the size of the structure to that point don't exceed
* the defined length of the structure, or we will overrun its
* bounds
*/
len = data[0x5];
total_read = len + 0x6;
if (total_read > h->length)
return;
type = data[0x4];
pr_attr("Host Interface Type", "%s",
dmi_management_controller_host_type(type));
/*
* The following decodes are code for Network interface host types only
* As defined in DSP0270
*/
if (type != 0x40)
return;
if (len != 0)
{
/* DSP0270: 8.3.1 Table 3: Device Type values */
type = data[0x6];
pr_attr("Device Type", "%s",
dmi_parse_device_type(type));
if (type == 0x2 && len >= 5)
{
/* USB Device Type - need at least 6 bytes */
u8 *usbdata = &data[0x7];
/* USB Device Descriptor: idVendor */
pr_attr("idVendor", "0x%04x",
WORD(&usbdata[0x0]));
/* USB Device Descriptor: idProduct */
pr_attr("idProduct", "0x%04x",
WORD(&usbdata[0x2]));
/*
* USB Serial number is here, but its useless, don't
* bother decoding it
*/
}
else if (type == 0x3 && len >= 9)
{
/* PCI Device Type - Need at least 8 bytes */
u8 *pcidata = &data[0x7];
/* PCI Device Descriptor: VendorID */
pr_attr("VendorID", "0x%04x",
WORD(&pcidata[0x0]));
/* PCI Device Descriptor: DeviceID */
pr_attr("DeviceID", "0x%04x",
WORD(&pcidata[0x2]));
/* PCI Device Descriptor: PCI SubvendorID */
pr_attr("SubVendorID", "0x%04x",
WORD(&pcidata[0x4]));
/* PCI Device Descriptor: PCI SubdeviceID */
pr_attr("SubDeviceID", "0x%04x",
WORD(&pcidata[0x6]));
}
else if (type == 0x4 && len >= 0x0d)
{
/* USB Device Type v2 - need at least 12 bytes */
u8 *usbdata = &data[7];
/* USB Device Descriptor v2: idVendor */
pr_attr("idVendor", "0x%04x",
WORD(&usbdata[0x1]));
/* USB Device Descriptor v2: idProduct */
pr_attr("idProduct", "0x%04x",
WORD(&usbdata[0x3]));
/*
* USB Serial number is here, but its useless, don't
* bother decoding it
*/
/* USB Device Descriptor v2: MAC Address */
pr_attr("MAC Address", "%02x:%02x:%02x:%02x:%02x:%02x",
usbdata[0x6], usbdata[0x7], usbdata[0x8],
usbdata[0x9], usbdata[0xa], usbdata[0xb]);
/* DSP0270 v1.3.0 support */
if (len >= 0x11)
{
/* USB Device Descriptor v2: Device Characteristics */
pr_list_start("Device Characteristics", NULL);
dmi_device_characteristics(WORD(&usbdata[0xc]));
pr_list_end();
/* USB Device Descriptor v2: Credential Bootstrapping Handle */
if (WORD(&usbdata[0x0c]) & 0x1)
{
pr_attr("Credential Bootstrapping Handle", "0x%04x",
WORD(&usbdata[0xe]));
}
}
}
else if (type == 0x5 && len >= 0x14)
{
/* PCI Device Type v2 - Need at least 19 bytes */
u8 *pcidata = &data[0x7];
/* PCI Device Descriptor v2: VendorID */
pr_attr("VendorID", "0x%04x",
WORD(&pcidata[0x1]));
/* PCI Device Descriptor v2: DeviceID */
pr_attr("DeviceID", "0x%04x",
WORD(&pcidata[0x3]));
/* PCI Device Descriptor v2: PCI SubvendorID */
pr_attr("SubVendorID", "0x%04x",
WORD(&pcidata[0x5]));
/* PCI Device Descriptor v2: PCI SubdeviceID */
pr_attr("SubDeviceID", "0x%04x",
WORD(&pcidata[0x7]));
/* PCI Device Descriptor v2: MAC Address */
pr_attr("MAC Address", "%02x:%02x:%02x:%02x:%02x:%02x",
pcidata[0x9], pcidata[0xa], pcidata[0xb],
pcidata[0xc], pcidata[0xd], pcidata[0xe]);
/* PCI Device Descriptor v2:
* Segment Group Number, Bus Number, Device/Function Number
*/
dmi_slot_segment_bus_func(WORD(&pcidata[0xf]), pcidata[0x11], pcidata[0x12]);
/* DSP0270 v1.3.0 support */
if (len >= 0x18)
{
/* PCI Device Descriptor v2: Device Characteristics */
pr_list_start("Device Characteristics", NULL);
dmi_device_characteristics(WORD(&pcidata[0x13]) );
pr_list_end();
/* PCI Device Descriptor v2: Credential Bootstrapping Handle */
if (WORD(&pcidata[0x13]) & 0x1)
{
pr_attr("Credential Bootstrapping Handle", "0x%04x",
WORD(&pcidata[0x15]));
}
}
}
else if (type >= 0x80 && len >= 5)
{
/* OEM Device Type - Need at least 4 bytes */
u8 *oemdata = &data[0x7];
/* OEM Device Descriptor: IANA */
pr_attr("Vendor ID", "0x%02x:0x%02x:0x%02x:0x%02x",
oemdata[0x0], oemdata[0x1],
oemdata[0x2], oemdata[0x3]);
}
/* Don't mess with unknown types for now */
}
/*
* DSP0270: 8.2 and 8.4: Protocol record count and protocol records
* Move to the Protocol Count.
*/
data = &data[total_read];
/*
* We've validated up to 0x6 + len bytes, but we need to validate
* the next byte below, the count value.
*/
total_read++;
if (total_read > h->length)
{
fprintf(stderr,
"Total read length %d exceeds total structure length %d (handle 0x%04hx)\n",
total_read, h->length, h->handle);
return;
}
/* Get the protocol records count */
count = data[0x0];
if (count)
{
u8 *rec = &data[0x1];
for (i = 0; i < count; i++)
{
/*
* Need to ensure that this record doesn't overrun
* the total length of the type 42 struct. Note the +2
* is added for the two leading bytes of a protocol
* record representing the type and length bytes.
*/
total_read += rec[1] + 2;
if (total_read > h->length)
{
fprintf(stderr,
"Total read length %d exceeds total structure length %d (handle 0x%04hx, record %d)\n",
total_read, h->length, h->handle, i + 1);
return;
}
dmi_parse_protocol_record(rec);
/*
* DSP0270: 8.4.1
* Each record is rec[1] bytes long, starting at the
* data byte immediately following the length field.
* That means we need to add the byte for the rec id,
* the byte for the length field, and the value of the
* length field itself.
*/
rec += rec[1] + 2;
}
}
}
/*
* 7.44 TPM Device (Type 43)
*/
static void dmi_tpm_vendor_id(const u8 *p)
{
char vendor_id[5];
int i;
/* ASCII filtering */
for (i = 0; i < 4 && p[i] != 0; i++)
{
if (p[i] < 32 || p[i] >= 127)
vendor_id[i] = '.';
else
vendor_id[i] = p[i];
}
/* Terminate the string */
vendor_id[i] = '\0';
pr_attr("Vendor ID", "%s", vendor_id);
}
static void dmi_tpm_characteristics(u64 code)
{
/* 7.1.1 */
static const char *characteristics[] = {
"TPM Device characteristics not supported", /* 2 */
"Family configurable via firmware update",
"Family configurable via platform software support",
"Family configurable via OEM proprietary mechanism" /* 5 */
};
int i;
/*
* This isn't very clear what this bit is supposed to mean
*/
if (code.l & (1 << 2))
{
pr_list_item("%s", characteristics[0]);
return;
}
for (i = 3; i <= 5; i++)
if (code.l & (1 << i))
pr_list_item("%s", characteristics[i - 2]);
}
/*
* 7.46 Firmware Inventory Information (Type 45)
*/
static void dmi_firmware_characteristics(u16 code)
{
/* 7.46.3 */
static const char *characteristics[] = {
"Updatable", /* 0 */
"Write-Protect" /* 1 */
};
int i;
for (i = 0; i <= 1; i++)
pr_list_item("%s: %s", characteristics[i],
(code & (1 << i)) ? "Yes" : "No");
}
static const char *dmi_firmware_state(u8 code)
{
/* 7.46.4 */
static const char *state[] = {
"Other", /* 0x01 */
"Unknown",
"Disabled",
"Enabled",
"Absent",
"Stand-by Offline",
"Stand-by Spare",
"Unavailable Offline" /* 0x08 */
};
if (code >= 0x01 && code <= 0x08)
return state[code - 0x01];
return out_of_spec;
}
static void dmi_firmware_components(u8 count, const u8 *p)
{
int i;
pr_list_start("Associated Components", "%u", count);
for (i = 0; i < count; i++)
pr_list_item("0x%04X", WORD(p + sizeof(u16) * i));
pr_list_end();
}
/*
* Main
*/
static void dmi_decode(const struct dmi_header *h, u16 ver)
{
const u8 *data = h->data;
/*
* Note: DMI types 37 and 42 are untested
*/
switch (h->type)
{
case 0: /* 7.1 BIOS Information */
pr_handle_name("BIOS Information");
if (h->length < 0x12) break;
pr_attr("Vendor", "%s",
dmi_string(h, data[0x04]));
pr_attr("Version", "%s",
dmi_string(h, data[0x05]));
pr_attr("Release Date", "%s",
dmi_string(h, data[0x08]));
/*
* On IA-64 and UEFI-based systems, the BIOS base
* address will read 0 because there is no BIOS. Skip
* the base address and the runtime size in this case.
*/
if (WORD(data + 0x06) != 0)
{
pr_attr("Address", "0x%04X0",
WORD(data + 0x06));
dmi_bios_runtime_size((0x10000 - WORD(data + 0x06)) << 4);
}
dmi_bios_rom_size(data[0x09], h->length < 0x1A ? 16 : WORD(data + 0x18));
pr_list_start("Characteristics", NULL);
dmi_bios_characteristics(QWORD(data + 0x0A));
pr_list_end();
if (h->length < 0x13) break;
dmi_bios_characteristics_x1(data[0x12]);
if (h->length < 0x14) break;
dmi_bios_characteristics_x2(data[0x13]);
if (h->length < 0x18) break;
if (data[0x14] != 0xFF && data[0x15] != 0xFF)
pr_attr("BIOS Revision", "%u.%u",
data[0x14], data[0x15]);
if (data[0x16] != 0xFF && data[0x17] != 0xFF)
pr_attr("Firmware Revision", "%u.%u",
data[0x16], data[0x17]);
break;
case 1: /* 7.2 System Information */
pr_handle_name("System Information");
if (h->length < 0x08) break;
pr_attr("Manufacturer", "%s",
dmi_string(h, data[0x04]));
pr_attr("Product Name", "%s",
dmi_string(h, data[0x05]));
pr_attr("Version", "%s",
dmi_string(h, data[0x06]));
pr_attr("Serial Number", "%s",
dmi_string(h, data[0x07]));
if (h->length < 0x19) break;
dmi_system_uuid(pr_attr, "UUID", data + 0x08, ver);
pr_attr("Wake-up Type", "%s",
dmi_system_wake_up_type(data[0x18]));
if (h->length < 0x1B) break;
pr_attr("SKU Number", "%s",
dmi_string(h, data[0x19]));
pr_attr("Family", "%s",
dmi_string(h, data[0x1A]));
break;
case 2: /* 7.3 Base Board Information */
pr_handle_name("Base Board Information");
if (h->length < 0x08) break;
pr_attr("Manufacturer", "%s",
dmi_string(h, data[0x04]));
pr_attr("Product Name", "%s",
dmi_string(h, data[0x05]));
pr_attr("Version", "%s",
dmi_string(h, data[0x06]));
pr_attr("Serial Number", "%s",
dmi_string(h, data[0x07]));
if (h->length < 0x09) break;
pr_attr("Asset Tag", "%s",
dmi_string(h, data[0x08]));
if (h->length < 0x0A) break;
dmi_base_board_features(data[0x09]);
if (h->length < 0x0E) break;
pr_attr("Location In Chassis", "%s",
dmi_string(h, data[0x0A]));
if (!(opt.flags & FLAG_QUIET))
pr_attr("Chassis Handle", "0x%04X",
WORD(data + 0x0B));
pr_attr("Type", "%s",
dmi_base_board_type(data[0x0D]));
if (h->length < 0x0F) break;
if (h->length < 0x0F + data[0x0E] * sizeof(u16)) break;
if (!(opt.flags & FLAG_QUIET))
dmi_base_board_handles(data[0x0E], data + 0x0F);
break;
case 3: /* 7.4 Chassis Information */
pr_handle_name("Chassis Information");
if (h->length < 0x09) break;
pr_attr("Manufacturer", "%s",
dmi_string(h, data[0x04]));
pr_attr("Type", "%s",
dmi_chassis_type(data[0x05]));
pr_attr("Lock", "%s",
dmi_chassis_lock(data[0x05] >> 7));
pr_attr("Version", "%s",
dmi_string(h, data[0x06]));
pr_attr("Serial Number", "%s",
dmi_string(h, data[0x07]));
pr_attr("Asset Tag", "%s",
dmi_string(h, data[0x08]));
if (h->length < 0x0D) break;
pr_attr("Boot-up State", "%s",
dmi_chassis_state(data[0x09]));
pr_attr("Power Supply State", "%s",
dmi_chassis_state(data[0x0A]));
pr_attr("Thermal State", "%s",
dmi_chassis_state(data[0x0B]));
pr_attr("Security Status", "%s",
dmi_chassis_security_status(data[0x0C]));
if (h->length < 0x11) break;
pr_attr("OEM Information", "0x%08X",
DWORD(data + 0x0D));
if (h->length < 0x13) break;
dmi_chassis_height(data[0x11]);
dmi_chassis_power_cords(data[0x12]);
if (h->length < 0x15) break;
if (h->length < 0x15 + data[0x13] * data[0x14]) break;
dmi_chassis_elements(data[0x13], data[0x14], data + 0x15);
if (h->length < 0x16 + data[0x13] * data[0x14]) break;
pr_attr("SKU Number", "%s",
dmi_string(h, data[0x15 + data[0x13] * data[0x14]]));
break;
case 4: /* 7.5 Processor Information */
pr_handle_name("Processor Information");
if (h->length < 0x1A) break;
pr_attr("Socket Designation", "%s",
dmi_string(h, data[0x04]));
pr_attr("Type", "%s",
dmi_processor_type(data[0x05]));
pr_attr("Family", "%s",
dmi_processor_family(h, ver));
pr_attr("Manufacturer", "%s",
dmi_string(h, data[0x07]));
dmi_processor_id(h);
pr_attr("Version", "%s",
dmi_string(h, data[0x10]));
dmi_processor_voltage("Voltage", data[0x11]);
dmi_processor_frequency("External Clock", data + 0x12);
dmi_processor_frequency("Max Speed", data + 0x14);
dmi_processor_frequency("Current Speed", data + 0x16);
if (data[0x18] & (1 << 6))
pr_attr("Status", "Populated, %s",
dmi_processor_status(data[0x18] & 0x07));
else
pr_attr("Status", "Unpopulated");
pr_attr("Upgrade", "%s",
dmi_processor_upgrade(data[0x19]));
if (h->length < 0x20) break;
if (!(opt.flags & FLAG_QUIET))
{
dmi_processor_cache("L1 Cache Handle",
WORD(data + 0x1A), "L1", ver);
dmi_processor_cache("L2 Cache Handle",
WORD(data + 0x1C), "L2", ver);
dmi_processor_cache("L3 Cache Handle",
WORD(data + 0x1E), "L3", ver);
}
if (h->length < 0x23) break;
pr_attr("Serial Number", "%s",
dmi_string(h, data[0x20]));
pr_attr("Asset Tag", "%s",
dmi_string(h, data[0x21]));
pr_attr("Part Number", "%s",
dmi_string(h, data[0x22]));
if (h->length < 0x28) break;
if (data[0x23] != 0)
pr_attr("Core Count", "%u",
h->length >= 0x2C && data[0x23] == 0xFF ?
WORD(data + 0x2A) : data[0x23]);
if (data[0x24] != 0)
pr_attr("Core Enabled", "%u",
h->length >= 0x2E && data[0x24] == 0xFF ?
WORD(data + 0x2C) : data[0x24]);
if (data[0x25] != 0)
pr_attr("Thread Count", "%u",
h->length >= 0x30 && data[0x25] == 0xFF ?
WORD(data + 0x2E) : data[0x25]);
if (h->length >= 0x32 && WORD(data + 0x30) != 0)
pr_attr("Thread Enabled", "%u",
WORD(data + 0x30));
dmi_processor_characteristics("Characteristics",
WORD(data + 0x26));
break;
case 5: /* 7.6 Memory Controller Information */
pr_handle_name("Memory Controller Information");
if (h->length < 0x0F) break;
pr_attr("Error Detecting Method", "%s",
dmi_memory_controller_ed_method(data[0x04]));
dmi_memory_controller_ec_capabilities("Error Correcting Capabilities",
data[0x05]);
pr_attr("Supported Interleave", "%s",
dmi_memory_controller_interleave(data[0x06]));
pr_attr("Current Interleave", "%s",
dmi_memory_controller_interleave(data[0x07]));
pr_attr("Maximum Memory Module Size", "%u MB",
1 << data[0x08]);
pr_attr("Maximum Total Memory Size", "%u MB",
data[0x0E] * (1 << data[0x08]));
dmi_memory_controller_speeds("Supported Speeds",
WORD(data + 0x09));
dmi_memory_module_types("Supported Memory Types",
WORD(data + 0x0B), 0);
dmi_processor_voltage("Memory Module Voltage", data[0x0D]);
if (h->length < 0x0F + data[0x0E] * sizeof(u16)) break;
dmi_memory_controller_slots(data[0x0E], data + 0x0F);
if (h->length < 0x10 + data[0x0E] * sizeof(u16)) break;
dmi_memory_controller_ec_capabilities("Enabled Error Correcting Capabilities",
data[0x0F + data[0x0E] * sizeof(u16)]);
break;
case 6: /* 7.7 Memory Module Information */
pr_handle_name("Memory Module Information");
if (h->length < 0x0C) break;
pr_attr("Socket Designation", "%s",
dmi_string(h, data[0x04]));
dmi_memory_module_connections(data[0x05]);
dmi_memory_module_speed("Current Speed", data[0x06]);
dmi_memory_module_types("Type", WORD(data + 0x07), 1);
dmi_memory_module_size("Installed Size", data[0x09]);
dmi_memory_module_size("Enabled Size", data[0x0A]);
dmi_memory_module_error(data[0x0B]);
break;
case 7: /* 7.8 Cache Information */
pr_handle_name("Cache Information");
if (h->length < 0x0F) break;
pr_attr("Socket Designation", "%s",
dmi_string(h, data[0x04]));
pr_attr("Configuration", "%s, %s, Level %u",
WORD(data + 0x05) & 0x0080 ? "Enabled" : "Disabled",
WORD(data + 0x05) & 0x0008 ? "Socketed" : "Not Socketed",
(WORD(data + 0x05) & 0x0007) + 1);
pr_attr("Operational Mode", "%s",
dmi_cache_mode((WORD(data + 0x05) >> 8) & 0x0003));
pr_attr("Location", "%s",
dmi_cache_location((WORD(data + 0x05) >> 5) & 0x0003));
if (h->length >= 0x1B)
dmi_cache_size_2("Installed Size", DWORD(data + 0x17));
else
dmi_cache_size("Installed Size", WORD(data + 0x09));
if (h->length >= 0x17)
dmi_cache_size_2("Maximum Size", DWORD(data + 0x13));
else
dmi_cache_size("Maximum Size", WORD(data + 0x07));
dmi_cache_types("Supported SRAM Types", WORD(data + 0x0B), 0);
dmi_cache_types("Installed SRAM Type", WORD(data + 0x0D), 1);
if (h->length < 0x13) break;
dmi_memory_module_speed("Speed", data[0x0F]);
pr_attr("Error Correction Type", "%s",
dmi_cache_ec_type(data[0x10]));
pr_attr("System Type", "%s",
dmi_cache_type(data[0x11]));
pr_attr("Associativity", "%s",
dmi_cache_associativity(data[0x12]));
break;
case 8: /* 7.9 Port Connector Information */
pr_handle_name("Port Connector Information");
if (h->length < 0x09) break;
pr_attr("Internal Reference Designator", "%s",
dmi_string(h, data[0x04]));
pr_attr("Internal Connector Type", "%s",
dmi_port_connector_type(data[0x05]));
pr_attr("External Reference Designator", "%s",
dmi_string(h, data[0x06]));
pr_attr("External Connector Type", "%s",
dmi_port_connector_type(data[0x07]));
pr_attr("Port Type", "%s",
dmi_port_type(data[0x08]));
break;
case 9: /* 7.10 System Slots */
pr_handle_name("System Slot Information");
if (h->length < 0x0C) break;
pr_attr("Designation", "%s",
dmi_string(h, data[0x04]));
pr_attr("Type", "%s", dmi_slot_type(data[0x05]));
pr_attr("Data Bus Width", "%s", dmi_slot_bus_width(data[0x06]));
pr_attr("Current Usage", "%s",
dmi_slot_current_usage(data[0x07]));
pr_attr("Length", "%s",
dmi_slot_length(data[0x08]));
dmi_slot_id(data[0x09], data[0x0A], data[0x05]);
if (h->length < 0x0D)
dmi_slot_characteristics("Characteristics", data[0x0B], 0x00);
else
dmi_slot_characteristics("Characteristics", data[0x0B], data[0x0C]);
if (h->length < 0x11) break;
dmi_slot_segment_bus_func(WORD(data + 0x0D), data[0x0F], data[0x10]);
if (h->length < 0x13) break;
pr_attr("Data Bus Width (Base)", "%u", data[0x11]);
pr_attr("Peer Devices", "%u", data[0x12]);
if (h->length < 0x13 + data[0x12] * 5) break;
dmi_slot_peers(data[0x12], data + 0x13);
if (h->length < 0x17 + data[0x12] * 5) break;
dmi_slot_information(data[0x05], data[0x13 + data[0x12] * 5]);
dmi_slot_physical_width(data[0x14 + data[0x12] * 5]);
dmi_slot_pitch(WORD(data + 0x15 + data[0x12] * 5));
if (h->length < 0x18 + data[0x12] * 5) break;
pr_attr("Height", "%s",
dmi_slot_height(data[0x17 + data[0x12] * 5]));
break;
case 10: /* 7.11 On Board Devices Information */
dmi_on_board_devices(h);
break;
case 11: /* 7.12 OEM Strings */
pr_handle_name("OEM Strings");
if (h->length < 0x05) break;
dmi_oem_strings(h);
break;
case 12: /* 7.13 System Configuration Options */
pr_handle_name("System Configuration Options");
if (h->length < 0x05) break;
dmi_system_configuration_options(h);
break;
case 13: /* 7.14 BIOS Language Information */
pr_handle_name("BIOS Language Information");
if (h->length < 0x16) break;
if (ver >= 0x0201)
{
pr_attr("Language Description Format", "%s",
dmi_bios_language_format(data[0x05]));
}
pr_list_start("Installable Languages", "%u", data[0x04]);
dmi_bios_languages(h);
pr_list_end();
pr_attr("Currently Installed Language", "%s",
dmi_string(h, data[0x15]));
break;
case 14: /* 7.15 Group Associations */
pr_handle_name("Group Associations");
if (h->length < 0x05) break;
pr_attr("Name", "%s",
dmi_string(h, data[0x04]));
pr_list_start("Items", "%u",
(h->length - 0x05) / 3);
dmi_group_associations_items((h->length - 0x05) / 3, data + 0x05);
pr_list_end();
break;
case 15: /* 7.16 System Event Log */
pr_handle_name("System Event Log");
if (h->length < 0x14) break;
pr_attr("Area Length", "%u bytes",
WORD(data + 0x04));
pr_attr("Header Start Offset", "0x%04X",
WORD(data + 0x06));
if (WORD(data + 0x08) - WORD(data + 0x06))
pr_attr("Header Length", "%u byte%s",
WORD(data + 0x08) - WORD(data + 0x06),
WORD(data + 0x08) - WORD(data + 0x06) > 1 ? "s" : "");
pr_attr("Data Start Offset", "0x%04X",
WORD(data + 0x08));
pr_attr("Access Method", "%s",
dmi_event_log_method(data[0x0A]));
dmi_event_log_address(data[0x0A], data + 0x10);
dmi_event_log_status(data[0x0B]);
pr_attr("Change Token", "0x%08X",
DWORD(data + 0x0C));
if (h->length < 0x17) break;
pr_attr("Header Format", "%s",
dmi_event_log_header_type(data[0x14]));
pr_attr("Supported Log Type Descriptors", "%u",
data[0x15]);
if (h->length < 0x17 + data[0x15] * data[0x16]) break;
dmi_event_log_descriptors(data[0x15], data[0x16], data + 0x17);
break;
case 16: /* 7.17 Physical Memory Array */
pr_handle_name("Physical Memory Array");
if (h->length < 0x0F) break;
pr_attr("Location", "%s",
dmi_memory_array_location(data[0x04]));
pr_attr("Use", "%s",
dmi_memory_array_use(data[0x05]));
pr_attr("Error Correction Type", "%s",
dmi_memory_array_ec_type(data[0x06]));
if (DWORD(data + 0x07) == 0x80000000)
{
if (h->length < 0x17)
pr_attr("Maximum Capacity", "Unknown");
else
dmi_print_memory_size("Maximum Capacity",
QWORD(data + 0x0F), 0);
}
else
{
u64 capacity;
capacity.h = 0;
capacity.l = DWORD(data + 0x07);
dmi_print_memory_size("Maximum Capacity",
capacity, 1);
}
if (!(opt.flags & FLAG_QUIET))
dmi_memory_array_error_handle(WORD(data + 0x0B));
pr_attr("Number Of Devices", "%u",
WORD(data + 0x0D));
break;
case 17: /* 7.18 Memory Device */
pr_handle_name("Memory Device");
if (h->length < 0x15) break;
if (!(opt.flags & FLAG_QUIET))
{
pr_attr("Array Handle", "0x%04X",
WORD(data + 0x04));
dmi_memory_array_error_handle(WORD(data + 0x06));
}
dmi_memory_device_width("Total Width", WORD(data + 0x08));
dmi_memory_device_width("Data Width", WORD(data + 0x0A));
if (h->length >= 0x20 && WORD(data + 0x0C) == 0x7FFF)
dmi_memory_device_extended_size(DWORD(data + 0x1C));
else
dmi_memory_device_size(WORD(data + 0x0C));
pr_attr("Form Factor", "%s",
dmi_memory_device_form_factor(data[0x0E]));
dmi_memory_device_set(data[0x0F]);
pr_attr("Locator", "%s",
dmi_string(h, data[0x10]));
pr_attr("Bank Locator", "%s",
dmi_string(h, data[0x11]));
pr_attr("Type", "%s",
dmi_memory_device_type(data[0x12]));
dmi_memory_device_type_detail(WORD(data + 0x13));
if (h->length < 0x17) break;
/* If no module is present, the remaining fields are irrelevant */
if (WORD(data + 0x0C) == 0 && !(opt.flags & FLAG_NO_QUIRKS))
break;
dmi_memory_device_speed("Speed", WORD(data + 0x15),
h->length >= 0x5C ?
DWORD(data + 0x54) : 0);
if (h->length < 0x1B) break;
pr_attr("Manufacturer", "%s",
dmi_string(h, data[0x17]));
pr_attr("Serial Number", "%s",
dmi_string(h, data[0x18]));
pr_attr("Asset Tag", "%s",
dmi_string(h, data[0x19]));
pr_attr("Part Number", "%s",
dmi_string(h, data[0x1A]));
if (h->length < 0x1C) break;
if ((data[0x1B] & 0x0F) == 0)
pr_attr("Rank", "Unknown");
else
pr_attr("Rank", "%u", data[0x1B] & 0x0F);
if (h->length < 0x22) break;
dmi_memory_device_speed("Configured Memory Speed",
WORD(data + 0x20),
h->length >= 0x5C ?
DWORD(data + 0x58) : 0);
if (h->length < 0x28) break;
dmi_memory_voltage_value("Minimum Voltage",
WORD(data + 0x22));
dmi_memory_voltage_value("Maximum Voltage",
WORD(data + 0x24));
dmi_memory_voltage_value("Configured Voltage",
WORD(data + 0x26));
if (h->length < 0x34) break;
dmi_memory_technology(data[0x28]);
dmi_memory_operating_mode_capability(WORD(data + 0x29));
pr_attr("Firmware Version", "%s",
dmi_string(h, data[0x2B]));
dmi_memory_manufacturer_id("Module Manufacturer ID",
WORD(data + 0x2C));
dmi_memory_product_id("Module Product ID",
WORD(data + 0x2E));
dmi_memory_manufacturer_id("Memory Subsystem Controller Manufacturer ID",
WORD(data + 0x30));
dmi_memory_product_id("Memory Subsystem Controller Product ID",
WORD(data + 0x32));
if (h->length < 0x3C) break;
dmi_memory_size("Non-Volatile Size", QWORD(data + 0x34));
if (h->length < 0x44) break;
dmi_memory_size("Volatile Size", QWORD(data + 0x3C));
if (h->length < 0x4C) break;
dmi_memory_size("Cache Size", QWORD(data + 0x44));
if (h->length < 0x54) break;
dmi_memory_size("Logical Size", QWORD(data + 0x4C));
if (h->length < 0x64) break;
dmi_memory_manufacturer_id("PMIC0 Manufacturer ID",
WORD(data + 0x5C));
dmi_memory_revision("PMIC0", WORD(data + 0x5E),
data[0x12]);
dmi_memory_manufacturer_id("RCD Manufacturer ID",
WORD(data + 0x60));
dmi_memory_revision("RCD", WORD(data + 0x62),
data[0x12]);
break;
case 18: /* 7.19 32-bit Memory Error Information */
pr_handle_name("32-bit Memory Error Information");
if (h->length < 0x17) break;
pr_attr("Type", "%s",
dmi_memory_error_type(data[0x04]));
pr_attr("Granularity", "%s",
dmi_memory_error_granularity(data[0x05]));
pr_attr("Operation", "%s",
dmi_memory_error_operation(data[0x06]));
dmi_memory_error_syndrome(DWORD(data + 0x07));
dmi_32bit_memory_error_address("Memory Array Address",
DWORD(data + 0x0B));
dmi_32bit_memory_error_address("Device Address",
DWORD(data + 0x0F));
dmi_32bit_memory_error_address("Resolution",
DWORD(data + 0x13));
break;
case 19: /* 7.20 Memory Array Mapped Address */
pr_handle_name("Memory Array Mapped Address");
if (h->length < 0x0F) break;
if (h->length >= 0x1F && DWORD(data + 0x04) == 0xFFFFFFFF)
{
u64 start, end;
start = QWORD(data + 0x0F);
end = QWORD(data + 0x17);
pr_attr("Starting Address", "0x%08X%08Xk",
start.h, start.l);
pr_attr("Ending Address", "0x%08X%08Xk",
end.h, end.l);
dmi_mapped_address_extended_size(start, end);
}
else
{
pr_attr("Starting Address", "0x%08X%03X",
DWORD(data + 0x04) >> 2,
(DWORD(data + 0x04) & 0x3) << 10);
pr_attr("Ending Address", "0x%08X%03X",
DWORD(data + 0x08) >> 2,
((DWORD(data + 0x08) & 0x3) << 10) + 0x3FF);
dmi_mapped_address_size(DWORD(data + 0x08) - DWORD(data + 0x04) + 1);
}
if (!(opt.flags & FLAG_QUIET))
pr_attr("Physical Array Handle", "0x%04X",
WORD(data + 0x0C));
pr_attr("Partition Width", "%u",
data[0x0E]);
break;
case 20: /* 7.21 Memory Device Mapped Address */
pr_handle_name("Memory Device Mapped Address");
if (h->length < 0x13) break;
if (h->length >= 0x23 && DWORD(data + 0x04) == 0xFFFFFFFF)
{
u64 start, end;
start = QWORD(data + 0x13);
end = QWORD(data + 0x1B);
pr_attr("Starting Address", "0x%08X%08Xk",
start.h, start.l);
pr_attr("Ending Address", "0x%08X%08Xk",
end.h, end.l);
dmi_mapped_address_extended_size(start, end);
}
else
{
pr_attr("Starting Address", "0x%08X%03X",
DWORD(data + 0x04) >> 2,
(DWORD(data + 0x04) & 0x3) << 10);
pr_attr("Ending Address", "0x%08X%03X",
DWORD(data + 0x08) >> 2,
((DWORD(data + 0x08) & 0x3) << 10) + 0x3FF);
dmi_mapped_address_size(DWORD(data + 0x08) - DWORD(data + 0x04) + 1);
}
if (!(opt.flags & FLAG_QUIET))
{
pr_attr("Physical Device Handle", "0x%04X",
WORD(data + 0x0C));
pr_attr("Memory Array Mapped Address Handle", "0x%04X",
WORD(data + 0x0E));
}
dmi_mapped_address_row_position(data[0x10]);
dmi_mapped_address_interleave_position(data[0x11]);
dmi_mapped_address_interleaved_data_depth(data[0x12]);
break;
case 21: /* 7.22 Built-in Pointing Device */
pr_handle_name("Built-in Pointing Device");
if (h->length < 0x07) break;
pr_attr("Type", "%s",
dmi_pointing_device_type(data[0x04]));
pr_attr("Interface", "%s",
dmi_pointing_device_interface(data[0x05]));
pr_attr("Buttons", "%u",
data[0x06]);
break;
case 22: /* 7.23 Portable Battery */
pr_handle_name("Portable Battery");
if (h->length < 0x10) break;
pr_attr("Location", "%s",
dmi_string(h, data[0x04]));
pr_attr("Manufacturer", "%s",
dmi_string(h, data[0x05]));
if (data[0x06] || h->length < 0x1A)
pr_attr("Manufacture Date", "%s",
dmi_string(h, data[0x06]));
if (data[0x07] || h->length < 0x1A)
pr_attr("Serial Number", "%s",
dmi_string(h, data[0x07]));
pr_attr("Name", "%s",
dmi_string(h, data[0x08]));
if (data[0x09] != 0x02 || h->length < 0x1A)
pr_attr("Chemistry", "%s",
dmi_battery_chemistry(data[0x09]));
if (h->length < 0x16)
dmi_battery_capacity(WORD(data + 0x0A), 1);
else
dmi_battery_capacity(WORD(data + 0x0A), data[0x15]);
dmi_battery_voltage(WORD(data + 0x0C));
pr_attr("SBDS Version", "%s",
dmi_string(h, data[0x0E]));
dmi_battery_maximum_error(data[0x0F]);
if (h->length < 0x1A) break;
if (data[0x07] == 0)
pr_attr("SBDS Serial Number", "%04X",
WORD(data + 0x10));
if (data[0x06] == 0)
pr_attr("SBDS Manufacture Date", "%u-%02u-%02u",
1980 + (WORD(data + 0x12) >> 9),
(WORD(data + 0x12) >> 5) & 0x0F,
WORD(data + 0x12) & 0x1F);
if (data[0x09] == 0x02)
pr_attr("SBDS Chemistry", "%s",
dmi_string(h, data[0x14]));
pr_attr("OEM-specific Information", "0x%08X",
DWORD(data + 0x16));
break;
case 23: /* 7.24 System Reset */
pr_handle_name("System Reset");
if (h->length < 0x0D) break;
pr_attr("Status", "%s",
data[0x04] & (1 << 0) ? "Enabled" : "Disabled");
pr_attr("Watchdog Timer", "%s",
data[0x04] & (1 << 5) ? "Present" : "Not Present");
if (!(data[0x04] & (1 << 5)))
break;
pr_attr("Boot Option", "%s",
dmi_system_reset_boot_option((data[0x04] >> 1) & 0x3));
pr_attr("Boot Option On Limit", "%s",
dmi_system_reset_boot_option((data[0x04] >> 3) & 0x3));
dmi_system_reset_count("Reset Count", WORD(data + 0x05));
dmi_system_reset_count("Reset Limit", WORD(data + 0x07));
dmi_system_reset_timer("Timer Interval", WORD(data + 0x09));
dmi_system_reset_timer("Timeout", WORD(data + 0x0B));
break;
case 24: /* 7.25 Hardware Security */
pr_handle_name("Hardware Security");
if (h->length < 0x05) break;
pr_attr("Power-On Password Status", "%s",
dmi_hardware_security_status(data[0x04] >> 6));
pr_attr("Keyboard Password Status", "%s",
dmi_hardware_security_status((data[0x04] >> 4) & 0x3));
pr_attr("Administrator Password Status", "%s",
dmi_hardware_security_status((data[0x04] >> 2) & 0x3));
pr_attr("Front Panel Reset Status", "%s",
dmi_hardware_security_status(data[0x04] & 0x3));
break;
case 25: /* 7.26 System Power Controls */
pr_handle_name("System Power Controls");
if (h->length < 0x09) break;
dmi_power_controls_power_on(data + 0x04);
break;
case 26: /* 7.27 Voltage Probe */
pr_handle_name("Voltage Probe");
if (h->length < 0x14) break;
pr_attr("Description", "%s",
dmi_string(h, data[0x04]));
pr_attr("Location", "%s",
dmi_voltage_probe_location(data[0x05] & 0x1f));
pr_attr("Status", "%s",
dmi_probe_status(data[0x05] >> 5));
dmi_voltage_probe_value("Maximum Value", WORD(data + 0x06));
dmi_voltage_probe_value("Minimum Value", WORD(data + 0x08));
dmi_voltage_probe_resolution(WORD(data + 0x0A));
dmi_voltage_probe_value("Tolerance", WORD(data + 0x0C));
dmi_probe_accuracy(WORD(data + 0x0E));
pr_attr("OEM-specific Information", "0x%08X",
DWORD(data + 0x10));
if (h->length < 0x16) break;
dmi_voltage_probe_value("Nominal Value", WORD(data + 0x14));
break;
case 27: /* 7.28 Cooling Device */
pr_handle_name("Cooling Device");
if (h->length < 0x0C) break;
if (!(opt.flags & FLAG_QUIET) && WORD(data + 0x04) != 0xFFFF)
pr_attr("Temperature Probe Handle", "0x%04X",
WORD(data + 0x04));
pr_attr("Type", "%s",
dmi_cooling_device_type(data[0x06] & 0x1f));
pr_attr("Status", "%s",
dmi_probe_status(data[0x06] >> 5));
if (data[0x07] != 0x00)
pr_attr("Cooling Unit Group", "%u",
data[0x07]);
pr_attr("OEM-specific Information", "0x%08X",
DWORD(data + 0x08));
if (h->length < 0x0E) break;
dmi_cooling_device_speed(WORD(data + 0x0C));
if (h->length < 0x0F) break;
pr_attr("Description", "%s", dmi_string(h, data[0x0E]));
break;
case 28: /* 7.29 Temperature Probe */
pr_handle_name("Temperature Probe");
if (h->length < 0x14) break;
pr_attr("Description", "%s",
dmi_string(h, data[0x04]));
pr_attr("Location", "%s",
dmi_temperature_probe_location(data[0x05] & 0x1F));
pr_attr("Status", "%s",
dmi_probe_status(data[0x05] >> 5));
dmi_temperature_probe_value("Maximum Value",
WORD(data + 0x06));
dmi_temperature_probe_value("Minimum Value",
WORD(data + 0x08));
dmi_temperature_probe_resolution(WORD(data + 0x0A));
dmi_temperature_probe_value("Tolerance",
WORD(data + 0x0C));
dmi_probe_accuracy(WORD(data + 0x0E));
pr_attr("OEM-specific Information", "0x%08X",
DWORD(data + 0x10));
if (h->length < 0x16) break;
dmi_temperature_probe_value("Nominal Value",
WORD(data + 0x14));
break;
case 29: /* 7.30 Electrical Current Probe */
pr_handle_name("Electrical Current Probe");
if (h->length < 0x14) break;
pr_attr("Description", "%s",
dmi_string(h, data[0x04]));
pr_attr("Location", "%s",
dmi_voltage_probe_location(data[5] & 0x1F));
pr_attr("Status", "%s",
dmi_probe_status(data[0x05] >> 5));
dmi_current_probe_value("Maximum Value",
WORD(data + 0x06));
dmi_current_probe_value("Minimum Value",
WORD(data + 0x08));
dmi_current_probe_resolution(WORD(data + 0x0A));
dmi_current_probe_value("Tolerance",
WORD(data + 0x0C));
dmi_probe_accuracy(WORD(data + 0x0E));
pr_attr("OEM-specific Information", "0x%08X",
DWORD(data + 0x10));
if (h->length < 0x16) break;
dmi_current_probe_value("Nominal Value",
WORD(data + 0x14));
break;
case 30: /* 7.31 Out-of-band Remote Access */
pr_handle_name("Out-of-band Remote Access");
if (h->length < 0x06) break;
pr_attr("Manufacturer Name", "%s",
dmi_string(h, data[0x04]));
pr_attr("Inbound Connection", "%s",
data[0x05] & (1 << 0) ? "Enabled" : "Disabled");
pr_attr("Outbound Connection", "%s",
data[0x05] & (1 << 1) ? "Enabled" : "Disabled");
break;
case 31: /* 7.32 Boot Integrity Services Entry Point */
pr_handle_name("Boot Integrity Services Entry Point");
if (h->length < 0x1C) break;
pr_attr("Checksum", "%s",
checksum(data, h->length) ? "OK" : "Invalid");
pr_attr("16-bit Entry Point Address", "%04X:%04X",
DWORD(data + 0x08) >> 16,
DWORD(data + 0x08) & 0xFFFF);
pr_attr("32-bit Entry Point Address", "0x%08X",
DWORD(data + 0x0C));
break;
case 32: /* 7.33 System Boot Information */
pr_handle_name("System Boot Information");
if (h->length < 0x0B) break;
pr_attr("Status", "%s",
dmi_system_boot_status(data[0x0A]));
break;
case 33: /* 7.34 64-bit Memory Error Information */
pr_handle_name("64-bit Memory Error Information");
if (h->length < 0x1F) break;
pr_attr("Type", "%s",
dmi_memory_error_type(data[0x04]));
pr_attr("Granularity", "%s",
dmi_memory_error_granularity(data[0x05]));
pr_attr("Operation", "%s",
dmi_memory_error_operation(data[0x06]));
dmi_memory_error_syndrome(DWORD(data + 0x07));
dmi_64bit_memory_error_address("Memory Array Address",
QWORD(data + 0x0B));
dmi_64bit_memory_error_address("Device Address",
QWORD(data + 0x13));
dmi_32bit_memory_error_address("Resolution",
DWORD(data + 0x1B));
break;
case 34: /* 7.35 Management Device */
pr_handle_name("Management Device");
if (h->length < 0x0B) break;
pr_attr("Description", "%s",
dmi_string(h, data[0x04]));
pr_attr("Type", "%s",
dmi_management_device_type(data[0x05]));
pr_attr("Address", "0x%08X",
DWORD(data + 0x06));
pr_attr("Address Type", "%s",
dmi_management_device_address_type(data[0x0A]));
break;
case 35: /* 7.36 Management Device Component */
pr_handle_name("Management Device Component");
if (h->length < 0x0B) break;
pr_attr("Description", "%s",
dmi_string(h, data[0x04]));
if (!(opt.flags & FLAG_QUIET))
{
pr_attr("Management Device Handle", "0x%04X",
WORD(data + 0x05));
pr_attr("Component Handle", "0x%04X",
WORD(data + 0x07));
if (WORD(data + 0x09) != 0xFFFF)
pr_attr("Threshold Handle", "0x%04X",
WORD(data + 0x09));
}
break;
case 36: /* 7.37 Management Device Threshold Data */
pr_handle_name("Management Device Threshold Data");
if (h->length < 0x10) break;
if (WORD(data + 0x04) != 0x8000)
pr_attr("Lower Non-critical Threshold", "%d",
(i16)WORD(data + 0x04));
if (WORD(data + 0x06) != 0x8000)
pr_attr("Upper Non-critical Threshold", "%d",
(i16)WORD(data + 0x06));
if (WORD(data + 0x08) != 0x8000)
pr_attr("Lower Critical Threshold", "%d",
(i16)WORD(data + 0x08));
if (WORD(data + 0x0A) != 0x8000)
pr_attr("Upper Critical Threshold", "%d",
(i16)WORD(data + 0x0A));
if (WORD(data + 0x0C) != 0x8000)
pr_attr("Lower Non-recoverable Threshold", "%d",
(i16)WORD(data + 0x0C));
if (WORD(data + 0x0E) != 0x8000)
pr_attr("Upper Non-recoverable Threshold", "%d",
(i16)WORD(data + 0x0E));
break;
case 37: /* 7.38 Memory Channel */
pr_handle_name("Memory Channel");
if (h->length < 0x07) break;
pr_attr("Type", "%s",
dmi_memory_channel_type(data[0x04]));
pr_attr("Maximal Load", "%u",
data[0x05]);
pr_attr("Devices", "%u",
data[0x06]);
if (h->length < 0x07 + 3 * data[0x06]) break;
dmi_memory_channel_devices(data[0x06], data + 0x07);
break;
case 38: /* 7.39 IPMI Device Information */
/*
* We use the word "Version" instead of "Revision", conforming to
* the IPMI specification.
*/
pr_handle_name("IPMI Device Information");
if (h->length < 0x10) break;
pr_attr("Interface Type", "%s",
dmi_ipmi_interface_type(data[0x04]));
pr_attr("Specification Version", "%u.%u",
data[0x05] >> 4, data[0x05] & 0x0F);
pr_attr("I2C Slave Address", "0x%02x",
data[0x06] >> 1);
if (data[0x07] != 0xFF)
pr_attr("NV Storage Device Address", "%u",
data[0x07]);
else
pr_attr("NV Storage Device", "Not Present");
dmi_ipmi_base_address(data[0x04], data + 0x08,
h->length < 0x11 ? 0 : (data[0x10] >> 4) & 1);
if (h->length < 0x12) break;
if (data[0x04] != 0x04)
{
pr_attr("Register Spacing", "%s",
dmi_ipmi_register_spacing(data[0x10] >> 6));
if (data[0x10] & (1 << 3))
{
pr_attr("Interrupt Polarity", "%s",
data[0x10] & (1 << 1) ? "Active High" : "Active Low");
pr_attr("Interrupt Trigger Mode", "%s",
data[0x10] & (1 << 0) ? "Level" : "Edge");
}
}
if (data[0x11] != 0x00)
{
pr_attr("Interrupt Number", "%u",
data[0x11]);
}
break;
case 39: /* 7.40 System Power Supply */
pr_handle_name("System Power Supply");
if (h->length < 0x10) break;
if (data[0x04] != 0x00)
pr_attr("Power Unit Group", "%u",
data[0x04]);
pr_attr("Location", "%s",
dmi_string(h, data[0x05]));
pr_attr("Name", "%s",
dmi_string(h, data[0x06]));
pr_attr("Manufacturer", "%s",
dmi_string(h, data[0x07]));
pr_attr("Serial Number", "%s",
dmi_string(h, data[0x08]));
pr_attr("Asset Tag", "%s",
dmi_string(h, data[0x09]));
pr_attr("Model Part Number", "%s",
dmi_string(h, data[0x0A]));
pr_attr("Revision", "%s",
dmi_string(h, data[0x0B]));
dmi_power_supply_power(WORD(data + 0x0C));
if (WORD(data + 0x0E) & (1 << 1))
pr_attr("Status", "Present, %s",
dmi_power_supply_status((WORD(data + 0x0E) >> 7) & 0x07));
else
pr_attr("Status", "Not Present");
pr_attr("Type", "%s",
dmi_power_supply_type((WORD(data + 0x0E) >> 10) & 0x0F));
pr_attr("Input Voltage Range Switching", "%s",
dmi_power_supply_range_switching((WORD(data + 0x0E) >> 3) & 0x0F));
pr_attr("Plugged", "%s",
WORD(data + 0x0E) & (1 << 2) ? "No" : "Yes");
pr_attr("Hot Replaceable", "%s",
WORD(data + 0x0E) & (1 << 0) ? "Yes" : "No");
if (h->length < 0x16) break;
if (!(opt.flags & FLAG_QUIET))
{
if (WORD(data + 0x10) != 0xFFFF)
pr_attr("Input Voltage Probe Handle", "0x%04X",
WORD(data + 0x10));
if (WORD(data + 0x12) != 0xFFFF)
pr_attr("Cooling Device Handle", "0x%04X",
WORD(data + 0x12));
if (WORD(data + 0x14) != 0xFFFF)
pr_attr("Input Current Probe Handle", "0x%04X",
WORD(data + 0x14));
}
break;
case 40: /* 7.41 Additional Information */
if (h->length < 0x0B) break;
if (opt.flags & FLAG_QUIET)
return;
dmi_additional_info(h);
break;
case 41: /* 7.42 Onboard Device Extended Information */
pr_handle_name("Onboard Device");
if (h->length < 0x0B) break;
pr_attr("Reference Designation", "%s", dmi_string(h, data[0x04]));
pr_attr("Type", "%s",
dmi_on_board_devices_type(data[0x05] & 0x7F));
pr_attr("Status", "%s",
data[0x05] & 0x80 ? "Enabled" : "Disabled");
pr_attr("Type Instance", "%u", data[0x06]);
dmi_slot_segment_bus_func(WORD(data + 0x07), data[0x09], data[0x0A]);
break;
case 42: /* 7.43 Management Controller Host Interface */
pr_handle_name("Management Controller Host Interface");
if (ver < 0x0302)
{
if (h->length < 0x05) break;
pr_attr("Interface Type", "%s",
dmi_management_controller_host_type(data[0x04]));
/*
* There you have a type-dependent, variable-length
* part in the middle of the structure, with no
* length specifier, so no easy way to decode the
* common, final part of the structure. What a pity.
*/
if (h->length < 0x09) break;
if (data[0x04] == 0xF0) /* OEM */
{
pr_attr("Vendor ID", "0x%02X%02X%02X%02X",
data[0x05], data[0x06], data[0x07],
data[0x08]);
}
}
else
dmi_parse_controller_structure(h);
break;
case 43: /* 7.44 TPM Device */
pr_handle_name("TPM Device");
if (h->length < 0x1B) break;
dmi_tpm_vendor_id(data + 0x04);
pr_attr("Specification Version", "%d.%d", data[0x08], data[0x09]);
switch (data[0x08])
{
case 0x01:
/*
* We skip the first 2 bytes, which are
* redundant with the above, and uncoded
* in a silly way.
*/
pr_attr("Firmware Revision", "%u.%u",
data[0x0C], data[0x0D]);
break;
case 0x02:
pr_attr("Firmware Revision", "%u.%u",
DWORD(data + 0x0A) >> 16,
DWORD(data + 0x0A) & 0xFFFF);
/*
* We skip the next 4 bytes, as their
* format is not standardized and their
* usefulness seems limited anyway.
*/
break;
}
pr_attr("Description", "%s", dmi_string(h, data[0x12]));
pr_list_start("Characteristics", NULL);
dmi_tpm_characteristics(QWORD(data + 0x13));
pr_list_end();
if (h->length < 0x1F) break;
pr_attr("OEM-specific Information", "0x%08X",
DWORD(data + 0x1B));
break;
case 45: /* 7.46 Firmware Inventory Information */
pr_handle_name("Firmware Inventory Information");
if (h->length < 0x18) break;
pr_attr("Firmware Component Name", "%s",
dmi_string(h, data[0x04]));
pr_attr("Firmware Version", "%s",
dmi_string(h, data[0x05]));
pr_attr("Firmware ID", "%s", dmi_string(h, data[0x07]));
pr_attr("Release Date", "%s", dmi_string(h, data[0x09]));
pr_attr("Manufacturer", "%s", dmi_string(h, data[0x0A]));
pr_attr("Lowest Supported Firmware Version", "%s",
dmi_string(h, data[0x0B]));
dmi_memory_size("Image Size", QWORD(data + 0x0C));
pr_list_start("Characteristics", NULL);
dmi_firmware_characteristics(WORD(data + 0x14));
pr_list_end();
pr_attr("State", "%s", dmi_firmware_state(data[0x16]));
if (h->length < 0x18 + data[0x17] * 2) break;
if (!(opt.flags & FLAG_QUIET))
dmi_firmware_components(data[0x17], data + 0x18);
break;
case 126:
pr_handle_name("Inactive");
break;
case 127:
pr_handle_name("End Of Table");
break;
default:
if (dmi_decode_oem(h))
break;
if (opt.flags & FLAG_QUIET)
return;
pr_handle_name("%s Type",
h->type >= 128 ? "OEM-specific" : "Unknown");
dmi_dump(h);
}
pr_sep();
}
static void to_dmi_header(struct dmi_header *h, u8 *data)
{
h->type = data[0];
h->length = data[1];
h->handle = WORD(data + 2);
h->data = data;
}
static void dmi_table_string(const struct dmi_header *h, const u8 *data, u16 ver)
{
int key;
u8 offset = opt.string->offset;
if (opt.string->type == 11) /* OEM strings */
{
if (h->length < 5 || offset > data[4])
{
fprintf(stderr, "No OEM string number %u\n", offset);
return;
}
if (offset)
printf("%s\n", dmi_string(h, offset));
else
printf("%u\n", data[4]); /* count */
return;
}
if (offset >= h->length)
return;
key = (opt.string->type << 8) | offset;
switch (key)
{
case 0x015: /* -s bios-revision */
if (data[offset - 1] != 0xFF && data[offset] != 0xFF)
printf("%u.%u\n", data[offset - 1], data[offset]);
break;
case 0x017: /* -s firmware-revision */
if (data[offset - 1] != 0xFF && data[offset] != 0xFF)
printf("%u.%u\n", data[offset - 1], data[offset]);
break;
case 0x108:
dmi_system_uuid(NULL, NULL, data + offset, ver);
break;
case 0x305:
printf("%s\n", dmi_chassis_type(data[offset]));
break;
case 0x406:
printf("%s\n", dmi_processor_family(h, ver));
break;
case 0x416:
dmi_processor_frequency(NULL, data + offset);
break;
default:
printf("%s\n", dmi_string(h, data[offset]));
}
}
static int dmi_table_dump(const u8 *ep, u32 ep_len, const u8 *table,
u32 table_len)
{
int fd;
FILE *f;
fd = open(opt.dumpfile, O_WRONLY|O_CREAT|O_EXCL, 0666);
if (fd == -1)
{
fprintf(stderr, "%s: ", opt.dumpfile);
perror("open");
return -1;
}
f = fdopen(fd, "wb");
if (!f)
{
fprintf(stderr, "%s: ", opt.dumpfile);
perror("fdopen");
return -1;
}
if (!(opt.flags & FLAG_QUIET))
pr_comment("Writing %d bytes to %s.", ep_len, opt.dumpfile);
if (fwrite(ep, ep_len, 1, f) != 1)
{
fprintf(stderr, "%s: ", opt.dumpfile);
perror("fwrite");
goto err_close;
}
if (fseek(f, 32, SEEK_SET) != 0)
{
fprintf(stderr, "%s: ", opt.dumpfile);
perror("fseek");
goto err_close;
}
if (!(opt.flags & FLAG_QUIET))
pr_comment("Writing %d bytes to %s.", table_len, opt.dumpfile);
if (fwrite(table, table_len, 1, f) != 1)
{
fprintf(stderr, "%s: ", opt.dumpfile);
perror("fwrite");
goto err_close;
}
if (fclose(f))
{
fprintf(stderr, "%s: ", opt.dumpfile);
perror("fclose");
return -1;
}
return 0;
err_close:
fclose(f);
return -1;
}
static void dmi_table_decode(u8 *buf, u32 len, u16 num, u16 ver, u32 flags)
{
u8 *data;
int i = 0;
/* First pass: Save specific values needed to decode OEM types */
data = buf;
while ((i < num || !num)
&& data + 4 <= buf + len) /* 4 is the length of an SMBIOS structure header */
{
u8 *next;
struct dmi_header h;
to_dmi_header(&h, data);
/*
* If a short entry is found (less than 4 bytes), not only it
* is invalid, but we cannot reliably locate the next entry.
* Also stop at end-of-table marker if so instructed.
*/
if (h.length < 4 ||
(h.type == 127 &&
(opt.flags & (FLAG_QUIET | FLAG_STOP_AT_EOT))))
break;
i++;
/* Look for the next handle */
next = data + h.length;
while ((unsigned long)(next - buf + 1) < len
&& (next[0] != 0 || next[1] != 0))
next++;
next += 2;
/* Make sure the whole structure fits in the table */
if ((unsigned long)(next - buf) > len)
break;
/* Assign vendor for vendor-specific decodes later */
if (h.type == 1 && h.length >= 6)
dmi_set_vendor(_dmi_string(&h, data[0x04], 0),
_dmi_string(&h, data[0x05], 0));
/* Remember CPUID type for HPE type 199 */
if (h.type == 4 && h.length >= 0x1A && cpuid_type == cpuid_none)
cpuid_type = dmi_get_cpuid_type(&h);
data = next;
}
/* Second pass: Actually decode the data */
i = 0;
data = buf;
while ((i < num || !num)
&& data + 4 <= buf + len) /* 4 is the length of an SMBIOS structure header */
{
u8 *next;
struct dmi_header h;
int display;
to_dmi_header(&h, data);
display = ((opt.type == NULL || opt.type[h.type])
&& (opt.handle == ~0U || opt.handle == h.handle)
&& !((opt.flags & FLAG_QUIET) && (h.type == 126 || h.type == 127))
&& !opt.string);
/*
* If a short entry is found (less than 4 bytes), not only it
* is invalid, but we cannot reliably locate the next entry.
* Better stop at this point, and let the user know his/her
* table is broken.
*/
if (h.length < 4)
{
if (!(opt.flags & FLAG_QUIET))
{
fprintf(stderr,
"Invalid entry length (%u). DMI table "
"is broken! Stop.\n\n",
(unsigned int)h.length);
opt.flags |= FLAG_QUIET;
}
break;
}
i++;
/* In quiet mode, stop decoding at end of table marker */
if ((opt.flags & FLAG_QUIET) && h.type == 127)
break;
if (display
&& (!(opt.flags & FLAG_QUIET) || (opt.flags & FLAG_DUMP)))
pr_handle(&h);
/* Look for the next handle */
next = data + h.length;
while ((unsigned long)(next - buf + 1) < len
&& (next[0] != 0 || next[1] != 0))
next++;
next += 2;
/* Make sure the whole structure fits in the table */
if ((unsigned long)(next - buf) > len)
{
if (display && !(opt.flags & FLAG_QUIET))
pr_struct_err("<TRUNCATED>");
pr_sep();
data = next;
break;
}
/* Fixup a common mistake */
if (h.type == 34 && !(opt.flags & FLAG_NO_QUIRKS))
dmi_fixup_type_34(&h, display);
if (display)
{
if (opt.flags & FLAG_DUMP)
{
dmi_dump(&h);
pr_sep();
}
else
dmi_decode(&h, ver);
}
else if (opt.string != NULL
&& opt.string->type == h.type)
dmi_table_string(&h, data, ver);
data = next;
/* SMBIOS v3 requires stopping at this marker */
if (h.type == 127 && (flags & FLAG_STOP_AT_EOT))
break;
}
/*
* SMBIOS v3 64-bit entry points do not announce a structures count,
* and only indicate a maximum size for the table.
*/
if (!(opt.flags & FLAG_QUIET))
{
if (num && i != num)
fprintf(stderr, "Wrong DMI structures count: %d announced, "
"only %d decoded.\n", num, i);
if ((unsigned long)(data - buf) > len
|| (num && (unsigned long)(data - buf) < len))
fprintf(stderr, "Wrong DMI structures length: %u bytes "
"announced, structures occupy %lu bytes.\n",
len, (unsigned long)(data - buf));
}
}
/* Allocates a buffer for the table, must be freed by the caller */
static u8 *dmi_table_get(off_t base, u32 *len, u16 num, u32 ver,
const char *devmem, u32 flags)
{
u8 *buf;
if (ver > SUPPORTED_SMBIOS_VER && !(opt.flags & FLAG_QUIET))
{
pr_comment("SMBIOS implementations newer than version %u.%u.%u are not",
SUPPORTED_SMBIOS_VER >> 16,
(SUPPORTED_SMBIOS_VER >> 8) & 0xFF,
SUPPORTED_SMBIOS_VER & 0xFF);
pr_comment("fully supported by this version of dmidecode.");
}
if (!(opt.flags & FLAG_QUIET))
{
if (opt.type == NULL)
{
if (num)
pr_info("%u structures occupying %u bytes.",
num, *len);
if (!(opt.flags & FLAG_FROM_DUMP))
pr_info("Table at 0x%08llX.",
(unsigned long long)base);
}
pr_sep();
}
if ((flags & FLAG_NO_FILE_OFFSET) || (opt.flags & FLAG_FROM_DUMP))
{
/*
* When reading from sysfs or from a dump file, the file may be
* shorter than announced. For SMBIOS v3 this is expcted, as we
* only know the maximum table size, not the actual table size.
* For older implementations (and for SMBIOS v3 too), this
* would be the result of the kernel truncating the table on
* parse error.
*/
size_t size = *len;
buf = read_file(flags & FLAG_NO_FILE_OFFSET ? 0 : base,
&size, devmem);
if (!(opt.flags & FLAG_QUIET) && num && size != (size_t)*len)
{
fprintf(stderr, "Wrong DMI structures length: %u bytes "
"announced, only %lu bytes available.\n",
*len, (unsigned long)size);
}
*len = size;
}
else
buf = mem_chunk(base, *len, devmem);
if (buf == NULL)
{
fprintf(stderr, "Failed to read table, sorry.\n");
#ifndef USE_MMAP
if (!(flags & FLAG_NO_FILE_OFFSET))
fprintf(stderr,
"Try compiling dmidecode with -DUSE_MMAP.\n");
#endif
}
return buf;
}
/*
* Build a crafted entry point with table address hard-coded to 32,
* as this is where we will put it in the output file. We adjust the
* DMI checksum appropriately. The SMBIOS checksum needs no adjustment.
*/
static void overwrite_dmi_address(u8 *buf)
{
buf[0x05] += buf[0x08] + buf[0x09] + buf[0x0A] + buf[0x0B] - 32;
buf[0x08] = 32;
buf[0x09] = 0;
buf[0x0A] = 0;
buf[0x0B] = 0;
}
/* Same thing for SMBIOS3 entry points */
static void overwrite_smbios3_address(u8 *buf)
{
buf[0x05] += buf[0x10] + buf[0x11] + buf[0x12] + buf[0x13]
+ buf[0x14] + buf[0x15] + buf[0x16] + buf[0x17] - 32;
buf[0x10] = 32;
buf[0x11] = 0;
buf[0x12] = 0;
buf[0x13] = 0;
buf[0x14] = 0;
buf[0x15] = 0;
buf[0x16] = 0;
buf[0x17] = 0;
}
static int smbios3_decode(u8 *buf, size_t buf_len, const char *devmem, u32 flags)
{
u32 ver, len;
u64 offset;
u8 *table;
/* Don't let checksum run beyond the buffer */
if (buf[0x06] > buf_len)
{
fprintf(stderr,
"Entry point length too large (%u bytes, expected %u).\n",
(unsigned int)buf[0x06], 0x18U);
return 0;
}
if (buf[0x06] < 0x18
|| !checksum(buf, buf[0x06]))
return 0;
ver = (buf[0x07] << 16) + (buf[0x08] << 8) + buf[0x09];
if (!(opt.flags & FLAG_QUIET))
pr_info("SMBIOS %u.%u.%u present.",
buf[0x07], buf[0x08], buf[0x09]);
offset = QWORD(buf + 0x10);
if (!(flags & FLAG_NO_FILE_OFFSET) && offset.h && sizeof(off_t) < 8)
{
fprintf(stderr, "64-bit addresses not supported, sorry.\n");
return 0;
}
/* Maximum length, may get trimmed */
len = DWORD(buf + 0x0C);
table = dmi_table_get(((off_t)offset.h << 32) | offset.l, &len, 0, ver,
devmem, flags | FLAG_STOP_AT_EOT);
if (table == NULL)
return 1;
if (opt.flags & FLAG_DUMP_BIN)
{
u8 crafted[32];
memcpy(crafted, buf, 32);
overwrite_smbios3_address(crafted);
dmi_table_dump(crafted, crafted[0x06], table, len);
}
else
{
dmi_table_decode(table, len, 0, ver >> 8,
flags | FLAG_STOP_AT_EOT);
}
free(table);
return 1;
}
static void dmi_fixup_version(u16 *ver)
{
/* Some BIOS report weird SMBIOS version, fix that up */
switch (*ver)
{
case 0x021F:
case 0x0221:
if (!(opt.flags & FLAG_QUIET))
fprintf(stderr,
"SMBIOS version fixup (2.%d -> 2.%d).\n",
*ver & 0xFF, 3);
*ver = 0x0203;
break;
case 0x0233:
if (!(opt.flags & FLAG_QUIET))
fprintf(stderr,
"SMBIOS version fixup (2.%d -> 2.%d).\n",
51, 6);
*ver = 0x0206;
break;
}
}
static int smbios_decode(u8 *buf, size_t buf_len, const char *devmem, u32 flags)
{
u16 ver, num;
u32 len;
u8 *table;
/* Don't let checksum run beyond the buffer */
if (buf[0x05] > buf_len)
{
fprintf(stderr,
"Entry point length too large (%u bytes, expected %u).\n",
(unsigned int)buf[0x05], 0x1FU);
return 0;
}
/*
* The size of this structure is 0x1F bytes, but we also accept value
* 0x1E due to a mistake in SMBIOS specification version 2.1.
*/
if (buf[0x05] < 0x1E
|| !checksum(buf, buf[0x05])
|| memcmp(buf + 0x10, "_DMI_", 5) != 0
|| !checksum(buf + 0x10, 0x0F))
return 0;
ver = (buf[0x06] << 8) + buf[0x07];
if (!(opt.flags & FLAG_NO_QUIRKS))
dmi_fixup_version(&ver);
if (!(opt.flags & FLAG_QUIET))
pr_info("SMBIOS %u.%u present.",
ver >> 8, ver & 0xFF);
/* Maximum length, may get trimmed */
len = WORD(buf + 0x16);
num = WORD(buf + 0x1C);
table = dmi_table_get(DWORD(buf + 0x18), &len, num, ver << 8,
devmem, flags);
if (table == NULL)
return 1;
if (opt.flags & FLAG_DUMP_BIN)
{
u8 crafted[32];
memcpy(crafted, buf, 32);
overwrite_dmi_address(crafted + 0x10);
dmi_table_dump(crafted, crafted[0x05], table, len);
}
else
{
dmi_table_decode(table, len, num, ver, flags);
}
free(table);
return 1;
}
static int legacy_decode(u8 *buf, const char *devmem, u32 flags)
{
u16 ver, num;
u32 len;
u8 *table;
if (!checksum(buf, 0x0F))
return 0;
ver = ((buf[0x0E] & 0xF0) << 4) + (buf[0x0E] & 0x0F);
if (!(opt.flags & FLAG_QUIET))
pr_info("Legacy DMI %u.%u present.",
buf[0x0E] >> 4, buf[0x0E] & 0x0F);
/* Maximum length, may get trimmed */
len = WORD(buf + 0x06);
num = WORD(buf + 0x0C);
table = dmi_table_get(DWORD(buf + 0x08), &len, num, ver << 8,
devmem, flags);
if (table == NULL)
return 1;
if (opt.flags & FLAG_DUMP_BIN)
{
u8 crafted[16];
memcpy(crafted, buf, 16);
overwrite_dmi_address(crafted);
dmi_table_dump(crafted, 0x0F, table, len);
}
else
{
dmi_table_decode(table, len, num, ver, flags);
}
free(table);
return 1;
}
/*
* Probe for EFI interface
*/
#define EFI_NOT_FOUND (-1)
#define EFI_NO_SMBIOS (-2)
static int address_from_efi(off_t *address)
{
#if defined(__linux__)
FILE *efi_systab;
const char *filename;
char linebuf[64];
#elif defined(__FreeBSD__) || defined(__DragonFly__)
char addrstr[KENV_MVALLEN + 1];
#endif
const char *eptype;
int ret;
*address = 0; /* Prevent compiler warning */
#if defined(__linux__)
/*
* Linux up to 2.6.6: /proc/efi/systab
* Linux 2.6.7 and up: /sys/firmware/efi/systab
*/
if ((efi_systab = fopen(filename = "/sys/firmware/efi/systab", "r")) == NULL
&& (efi_systab = fopen(filename = "/proc/efi/systab", "r")) == NULL)
{
/* No EFI interface, fallback to memory scan */
return EFI_NOT_FOUND;
}
ret = EFI_NO_SMBIOS;
while ((fgets(linebuf, sizeof(linebuf) - 1, efi_systab)) != NULL)
{
char *addrp = strchr(linebuf, '=');
*(addrp++) = '\0';
if (strcmp(linebuf, "SMBIOS3") == 0
|| strcmp(linebuf, "SMBIOS") == 0)
{
*address = strtoull(addrp, NULL, 0);
eptype = linebuf;
ret = 0;
break;
}
}
if (fclose(efi_systab) != 0)
perror(filename);
if (ret == EFI_NO_SMBIOS)
fprintf(stderr, "%s: SMBIOS entry point missing\n", filename);
#elif defined(__FreeBSD__) || defined(__DragonFly__)
/*
* On FreeBSD, SMBIOS anchor base address in UEFI mode is exposed
* via kernel environment:
* https://svnweb.freebsd.org/base?view=revision&revision=307326
*
* DragonFly BSD adopted the same method as FreeBSD, see commit
* 5e488df32cb01056a5b714a522e51c69ab7b4612
*/
ret = kenv(KENV_GET, "hint.smbios.0.mem", addrstr, sizeof(addrstr));
if (ret == -1)
{
if (errno != ENOENT)
perror("kenv");
return EFI_NOT_FOUND;
}
*address = strtoull(addrstr, NULL, 0);
eptype = "SMBIOS";
ret = 0;
#else
ret = EFI_NOT_FOUND;
#endif
if (ret == 0 && !(opt.flags & FLAG_QUIET))
pr_comment("%s entry point at 0x%08llx",
eptype, (unsigned long long)*address);
return ret;
}
int main(int argc, char * const argv[])
{
int ret = 0; /* Returned value */
int found = 0;
off_t fp;
size_t size;
int efi;
u8 *buf = NULL;
/*
* We don't want stdout and stderr to be mixed up if both are
* redirected to the same file.
*/
setlinebuf(stdout);
setlinebuf(stderr);
if (sizeof(u8) != 1 || sizeof(u16) != 2 || sizeof(u32) != 4 || '\0' != 0)
{
fprintf(stderr, "%s: compiler incompatibility\n", argv[0]);
exit(255);
}
/* Set default option values */
opt.devmem = DEFAULT_MEM_DEV;
opt.flags = 0;
opt.handle = ~0U;
if (parse_command_line(argc, argv)<0)
{
ret = 2;
goto exit_free;
}
if (opt.flags & FLAG_LIST)
{
/* Already handled in parse_command_line() */
goto exit_free;
}
if (opt.flags & FLAG_HELP)
{
print_help();
goto exit_free;
}
if (opt.flags & FLAG_VERSION)
{
printf("%s\n", VERSION);
goto exit_free;
}
if (!(opt.flags & FLAG_QUIET))
pr_comment("dmidecode %s", VERSION);
/* Read from dump if so instructed */
size = 0x20;
if (opt.flags & FLAG_FROM_DUMP)
{
if (!(opt.flags & FLAG_QUIET))
pr_info("Reading SMBIOS/DMI data from file %s.",
opt.dumpfile);
if ((buf = read_file(0, &size, opt.dumpfile)) == NULL)
{
ret = 1;
goto exit_free;
}
/* Truncated entry point can't be processed */
if (size < 0x20)
{
ret = 1;
goto done;
}
if (memcmp(buf, "_SM3_", 5) == 0)
{
if (smbios3_decode(buf, size, opt.dumpfile, 0))
found++;
}
else if (memcmp(buf, "_SM_", 4) == 0)
{
if (smbios_decode(buf, size, opt.dumpfile, 0))
found++;
}
else if (memcmp(buf, "_DMI_", 5) == 0)
{
if (legacy_decode(buf, opt.dumpfile, 0))
found++;
}
goto done;
}
/*
* First try reading from sysfs tables. The entry point file could
* contain one of several types of entry points, so read enough for
* the largest one, then determine what type it contains.
*/
if (!(opt.flags & FLAG_NO_SYSFS)
&& (buf = read_file(0, &size, SYS_ENTRY_FILE)) != NULL)
{
if (!(opt.flags & FLAG_QUIET))
pr_info("Getting SMBIOS data from sysfs.");
if (size >= 24 && memcmp(buf, "_SM3_", 5) == 0)
{
if (smbios3_decode(buf, size, SYS_TABLE_FILE, FLAG_NO_FILE_OFFSET))
found++;
}
else if (size >= 31 && memcmp(buf, "_SM_", 4) == 0)
{
if (smbios_decode(buf, size, SYS_TABLE_FILE, FLAG_NO_FILE_OFFSET))
found++;
}
else if (size >= 15 && memcmp(buf, "_DMI_", 5) == 0)
{
if (legacy_decode(buf, SYS_TABLE_FILE, FLAG_NO_FILE_OFFSET))
found++;
}
if (found)
goto done;
if (!(opt.flags & FLAG_QUIET))
pr_info("Failed to get SMBIOS data from sysfs.");
}
/* Next try EFI (ia64, Intel-based Mac, arm64) */
efi = address_from_efi(&fp);
switch (efi)
{
case EFI_NOT_FOUND:
goto memory_scan;
case EFI_NO_SMBIOS:
ret = 1;
goto exit_free;
}
if (!(opt.flags & FLAG_QUIET))
pr_info("Found SMBIOS entry point in EFI, reading table from %s.",
opt.devmem);
if ((buf = mem_chunk(fp, 0x20, opt.devmem)) == NULL)
{
ret = 1;
goto exit_free;
}
if (memcmp(buf, "_SM3_", 5) == 0)
{
if (smbios3_decode(buf, 0x20, opt.devmem, 0))
found++;
}
else if (memcmp(buf, "_SM_", 4) == 0)
{
if (smbios_decode(buf, 0x20, opt.devmem, 0))
found++;
}
goto done;
memory_scan:
#if defined __i386__ || defined __x86_64__
if (!(opt.flags & FLAG_QUIET))
pr_info("Scanning %s for entry point.", opt.devmem);
/* Fallback to memory scan (x86, x86_64) */
if ((buf = mem_chunk(0xF0000, 0x10000, opt.devmem)) == NULL)
{
ret = 1;
goto exit_free;
}
/* Look for a 64-bit entry point first */
for (fp = 0; fp <= 0xFFE0; fp += 16)
{
if (memcmp(buf + fp, "_SM3_", 5) == 0)
{
if (smbios3_decode(buf + fp, 0x20, opt.devmem, 0))
{
found++;
goto done;
}
}
}
/* If none found, look for a 32-bit entry point */
for (fp = 0; fp <= 0xFFF0; fp += 16)
{
if (memcmp(buf + fp, "_SM_", 4) == 0 && fp <= 0xFFE0)
{
if (smbios_decode(buf + fp, 0x20, opt.devmem, 0))
{
found++;
goto done;
}
}
else if (memcmp(buf + fp, "_DMI_", 5) == 0)
{
if (legacy_decode(buf + fp, opt.devmem, 0))
{
found++;
goto done;
}
}
}
#endif
done:
if (!found && !(opt.flags & FLAG_QUIET))
pr_comment("No SMBIOS nor DMI entry point found, sorry.");
free(buf);
exit_free:
free(opt.type);
return ret;
}
|