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
|
/*
* DMI Decode
*
* (C) 2000-2002 Alan Cox <alan@redhat.com>
* (C) 2002-2007 Jean Delvare <khali@linux-fr.org>
*
* 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 2.5" 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 31
* "Intel Processor Identification and the CPUID Instruction"
* http://developer.intel.com/design/xeon/applnots/241618.htm
* - DMTF Master MIF version 040707
* "DMTF approved standard groups"
* http://www.dmtf.org/standards/dmi
* - 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.18
* "CPUID Specification"
* http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/25481.pdf
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "version.h"
#include "config.h"
#include "types.h"
#include "util.h"
#include "dmidecode.h"
#include "dmiopt.h"
#include "dmioem.h"
static const char *out_of_spec = "<OUT OF SPEC>";
static const char *bad_index = "<BAD INDEX>";
/*
* Type-independant Stuff
*/
const char *dmi_string(struct dmi_header *dm, u8 s)
{
char *bp=(char *)dm->data;
size_t i, len;
if(s==0)
return "Not Specified";
bp+=dm->length;
while(s>1 && *bp)
{
bp+=strlen(bp);
bp++;
s--;
}
if(!*bp)
return bad_index;
/* ASCII filtering */
len=strlen(bp);
for(i=0; i<len; i++)
if(bp[i]<32 || bp[i]==127)
bp[i]='.';
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" /* 39 */
};
if(code<=39)
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(struct dmi_header *h, const char *prefix)
{
int row, i;
const char *s;
printf("%sHeader and Data:\n", prefix);
for(row=0; row<((h->length-1)>>4)+1; row++)
{
printf("%s\t", prefix);
for(i=0; i<16 && i<h->length-(row<<4); i++)
printf("%s%02X", i?" ":"", (h->data)[(row<<4)+i]);
printf("\n");
}
if((h->data)[h->length] || (h->data)[h->length+1])
{
printf("%sStrings:\n", prefix);
i=1;
while((s=dmi_string(h, i++))!=bad_index)
{
if(opt.flags & FLAG_DUMP)
{
int j, l = strlen(s)+1;
for(row=0; row<((l-1)>>4)+1; row++)
{
printf("%s\t", prefix);
for(j=0; j<16 && j<l-(row<<4); j++)
printf("%s%02X", j?" ":"",
s[(row<<4)+j]);
printf("\n");
}
printf("%s\t\"%s\"\n", prefix, s);
}
else
printf("%s\t%s\n", prefix, s);
}
}
}
/*
* 3.3.1 BIOS Information (Type 0)
*/
static void dmi_bios_runtime_size(u32 code)
{
if(code&0x000003FF)
printf(" %u bytes", code);
else
printf(" %u kB", code>>10);
}
static void dmi_bios_characteristics(u64 code, const char *prefix)
{
/* 3.3.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))
{
printf("%s%s\n",
prefix, characteristics[0]);
return;
}
for(i=4; i<=31; i++)
if(code.l&(1<<i))
printf("%s%s\n",
prefix, characteristics[i-3]);
}
static void dmi_bios_characteristics_x1(u8 code, const char *prefix)
{
/* 3.3.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))
printf("%s%s\n",
prefix, characteristics[i]);
}
static void dmi_bios_characteristics_x2(u8 code, const char *prefix)
{
/* 3.3.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" /* 2 */
};
int i;
for(i=0; i<=2; i++)
if(code&(1<<i))
printf("%s%s\n",
prefix, characteristics[i]);
}
/*
* 3.3.2 System Information (Type 1)
*/
void dmi_system_uuid(u8 *p)
{
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)
{
printf("Not Present");
return;
}
if(only0x00)
{
printf("Not Settable");
return;
}
printf("%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]);
}
static const char *dmi_system_wake_up_type(u8 code)
{
/* 3.3.2.1 */
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;
}
/*
* 3.3.3 Base Board Information (Type 2)
*/
static void dmi_base_board_features(u8 code, const char *prefix)
{
/* 3.3.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)
printf(" None\n");
else
{
int i;
printf("\n");
for(i=0; i<=4; i++)
if(code&(1<<i))
printf("%s%s\n",
prefix, features[i]);
}
}
static const char *dmi_base_board_type(u8 code)
{
/* 3.3.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, u8 *p, const char *prefix)
{
int i;
printf("%sContained Object Handles: %u\n",
prefix, count);
for(i=0; i<count; i++)
printf("%s\t0x%04X\n",
prefix, WORD(p+sizeof(u16)*i));
}
/*
* 3.3.4 Chassis Information (Type 3)
*/
const char *dmi_chassis_type(u8 code)
{
/* 3.3.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", /* master.mif says System */
"Expansion Chassis",
"Sub Chassis",
"Bus Expansion Chassis",
"Peripheral Chassis",
"RAID Chassis",
"Rack Mount Chassis",
"Sealed-case PC",
"Multi-system",
"CompactPCI",
"AdvancedTCA" /* 0x1B */
};
if(code>=0x01 && code<=0x1B)
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)
{
/* 3.3.4.2 */
static const char *state[]={
"Other", /* 0x01 */
"Unknown",
"Safe", /* master.mif says OK */
"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)
{
/* 3.3.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)
printf(" Unspecified");
else
printf(" %u U", code);
}
static void dmi_chassis_power_cords(u8 code)
{
if(code==0x00)
printf(" Unspecified");
else
printf(" %u", code);
}
static void dmi_chassis_elements(u8 count, u8 len, u8 *p, const char *prefix)
{
int i;
printf("%sContained Elements: %u\n",
prefix, count);
for(i=0; i<count; i++)
{
if(len>=0x03)
{
printf("%s\t%s (",
prefix, 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])
printf("%u", p[1+i*len]);
else
printf("%u-%u", p[1+i*len], p[2+i*len]);
printf(")\n");
}
}
}
/*
* 3.3.5 Processor Information (Type 4)
*/
static const char *dmi_processor_type(u8 code)
{
/* 3.3.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;
}
const char *dmi_processor_family(u8 code)
{
/* 3.3.5.2 */
static const char *family[256]={
NULL, /* 0x00 */
"Other",
"Unknown",
"8086",
"80286",
"80386",
"80486",
"8087",
"80287",
"80387",
"80487",
"Pentium",
"Pentium Pro",
"Pentium II",
"Pentium MMX",
"Celeron",
"Pentium II Xeon",
"Pentium III",
"M1",
"M2",
NULL, /* 0x14 */
NULL,
NULL,
NULL, /* 0x17 */
"Duron",
"K5",
"K6",
"K6-2",
"K6-3",
"Athlon",
"AMD2900",
"K6-2+",
"Power PC",
"Power PC 601",
"Power PC 603",
"Power PC 603+",
"Power PC 604",
"Power PC 620",
"Power PC x704",
"Power PC 750",
NULL, /* 0x28 */
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,/* 0x2F */
"Alpha",
"Alpha 21064",
"Alpha 21066",
"Alpha 21164",
"Alpha 21164PC",
"Alpha 21164a",
"Alpha 21264",
"Alpha 21364",
NULL, /* 0x38 */
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL, /* 0x3F */
"MIPS",
"MIPS R4000",
"MIPS R4200",
"MIPS R4400",
"MIPS R4600",
"MIPS R10000",
NULL, /* 0x46 */
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL, /* 0x4F */
"SPARC",
"SuperSPARC",
"MicroSPARC II",
"MicroSPARC IIep",
"UltraSPARC",
"UltraSPARC II",
"UltraSPARC IIi",
"UltraSPARC III",
"UltraSPARC IIIi",
NULL, /* 0x59 */
NULL,
NULL,
NULL,
NULL,
NULL,
NULL, /* 0x5F */
"68040",
"68xxx",
"68000",
"68010",
"68020",
"68030",
NULL, /* 0x66 */
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL, /* 0x6F */
"Hobbit",
NULL, /* 0x71 */
NULL,
NULL,
NULL,
NULL,
NULL,
NULL, /* 0x77 */
"Crusoe TM5000",
"Crusoe TM3000",
"Efficeon TM8000",
NULL, /* 0x7B */
NULL,
NULL,
NULL,
NULL, /* 0x7F */
"Weitek",
NULL, /* 0x81 */
"Itanium",
"Athlon 64",
"Opteron",
"Sempron",
"Turion 64",
"Dual-Core Opteron",
"Athlon 64 X2",
NULL, /* 0x89 */
NULL,
NULL,
NULL,
NULL,
NULL,
NULL, /* 0x8F */
"PA-RISC",
"PA-RISC 8500",
"PA-RISC 8000",
"PA-RISC 7300LC",
"PA-RISC 7200",
"PA-RISC 7100LC",
"PA-RISC 7100",
NULL, /* 0x97 */
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL, /* 0x9F */
"V30",
NULL, /* 0xA1 */
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL, /* 0xAF */
"Pentium III Xeon",
"Pentium III Speedstep",
"Pentium 4",
"Xeon",
"AS400",
"Xeon MP",
"Athlon XP",
"Athlon MP",
"Itanium 2",
"Pentium M",
"Celeron D",
"Pentium D",
"Pentium EE",
NULL, /* 0xBD */
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL, /* 0xC7 */
"IBM390",
"G4",
"G5",
NULL, /* 0xCB */
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL, /* 0xF9 */
"i860",
"i960",
NULL, /* 0xFC */
NULL,
NULL,
NULL /* 0xFF */
/* master.mif has values beyond that, but they can't be used for DMI */
};
if(family[code]!=NULL)
return family[code];
return out_of_spec;
}
static void dmi_processor_id(u8 type, u8 *p, const char *version, const char *prefix)
{
/* Intel AP-485 revision 31, table 3-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 (Fast floating-point save and restore)",
"SSE (Streaming SIMD extensions)",
"SSE2 (Streaming SIMD extensions 2)",
"SS (Self-snoop)",
"HTT (Hyper-threading technology)",
"TM (Thermal monitor supported)",
"IA64 (IA64 capabilities)",
"PBE (Pending break enabled)" /* 31 */
};
/*
* 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.
*/
u32 eax, edx;
int sig=0;
/*
* This might help learn about new processors supporting the
* CPUID instruction or another form of identification.
*/
printf("%sID: %02X %02X %02X %02X %02X %02X %02X %02X\n",
prefix, p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
if(type==0x05) /* 80386 */
{
u16 dx=WORD(p);
/*
* 80386 have a different signature.
*/
printf("%sSignature: Type %u, Family %u, Major Stepping %u, Minor Stepping %u\n",
prefix, dx>>12, (dx>>8)&0xF, (dx>>4)&0xF, dx&0xF);
return;
}
if(type==0x06) /* 80486 */
{
u16 dx=WORD(p);
/*
* Not all 80486 CPU support the CPUID instruction, we have to find
* wether 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))
sig=1;
else
{
printf("%sSignature: Type %u, Family %u, Model %u, Stepping %u\n",
prefix, (dx>>12)&0x3, (dx>>8)&0xF, (dx>>4)&0xF, dx&0xF);
return;
}
}
else if((type>=0x0B && type<=0x13) /* Intel, Cyrix */
|| (type>=0xB0 && type<=0xB3) /* Intel */
|| type==0xB5 /* Intel */
|| (type>=0xB9 && type<=0xBC)) /* Intel */
sig=1;
else if((type>=0x18 && type<=0x1D) /* AMD */
|| type==0x1F /* AMD */
|| (type>=0xB6 && type<=0xB7) /* AMD */
|| (type>=0x83 && type<=0x88)) /* AMD */
sig=2;
else if(type==0x01 || type==0x02)
{
/*
* Some X86-class CPU have family "Other" or "Unknown". In this case,
* we use the version string to determine if they are known to
* support the CPUID instruction.
*/
if(strncmp(version, "Pentium III MMX", 15)==0)
sig=1;
else if(strncmp(version, "AMD Athlon(TM)", 14)==0
|| strncmp(version, "AMD Opteron(tm)", 15)==0)
sig=2;
else
return;
}
else /* not X86-class */
return;
eax=DWORD(p);
edx=DWORD(p+4);
switch(sig)
{
case 1: /* Intel */
printf("%sSignature: Type %u, Family %u, Model %u, Stepping %u\n",
prefix, (eax>>12)&0x3, ((eax>>20)&0xFF)+((eax>>8)&0x0F),
((eax>>12)&0xF0)+((eax>>4)&0x0F), eax&0xF);
break;
case 2: /* AMD */
printf("%sSignature: Family %u, Model %u, Stepping %u\n",
prefix,
((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;
}
edx=DWORD(p+4);
printf("%sFlags:", prefix);
if((edx&0xFFEFFBFF)==0)
printf(" None\n");
else
{
int i;
printf("\n");
for(i=0; i<=31; i++)
if(flags[i]!=NULL && edx&(1<<i))
printf("%s\t%s\n", prefix, flags[i]);
}
}
static void dmi_processor_voltage(u8 code)
{
/* 3.3.5.4 */
static const char *voltage[]={
"5.0 V", /* 0 */
"3.3 V",
"2.9 V" /* 2 */
};
int i;
if(code&0x80)
printf(" %.1f V", (float)(code&0x7f)/10);
else
{
for(i=0; i<=2; i++)
if(code&(1<<i))
printf(" %s", voltage[i]);
if(code==0x00)
printf(" Unknown");
}
}
void dmi_processor_frequency(u8 *p)
{
u16 code = WORD(p);
if(code)
printf("%u MHz", code);
else
printf("Unknown");
}
static const char *dmi_processor_status(u8 code)
{
static const char *status[]={
"Unknown", /* 0x00 */
"Enabled",
"Disabled By User",
"Disabled By BIOS",
"Idle", /* 0x04 */
"Other" /* 0x07 */
};
if(code<=0x04)
return status[code];
if(code==0x07)
return status[0x05];
return out_of_spec;
}
static const char *dmi_processor_upgrade(u8 code)
{
/* 3.3.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" /* 0x15 */
};
if(code>=0x01 && code<=0x15)
return upgrade[code-0x01];
return out_of_spec;
}
static void dmi_processor_cache(u16 code, const char *level, u16 ver)
{
if(code==0xFFFF)
{
if(ver>=0x0203)
printf(" Not Provided");
else
printf(" No %s Cache", level);
}
else
printf(" 0x%04X", code);
}
static void dmi_processor_characteristics(u16 code, const char *prefix)
{
/* 3.3.5.9 */
static const char *characteristics[]={
"64-bit capable" /* 2 */
};
if((code&0x0004)==0)
printf(" None\n");
else
{
int i;
printf("\n");
for(i=2; i<=2; i++)
if(code&(1<<i))
printf("%s%s\n", prefix, characteristics[i-2]);
}
}
/*
* 3.3.6 Memory Controller Information (Type 5)
*/
static const char *dmi_memory_controller_ed_method(u8 code)
{
/* 3.3.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(u8 code, const char *prefix)
{
/* 3.3.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)
printf(" None\n");
else
{
int i;
printf("\n");
for(i=0; i<=5; i++)
if(code&(1<<i))
printf("%s%s\n", prefix, capabilities[i]);
}
}
static const char* dmi_memory_controller_interleave(u8 code)
{
/* 3.3.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(u16 code, const char *prefix)
{
/* 3.3.6.4 */
const char *speeds[]={
"Other", /* 0 */
"Unknown",
"70 ns",
"60 ns",
"50 ns" /* 4 */
};
if((code&0x001F)==0)
printf(" None\n");
else
{
int i;
printf("\n");
for(i=0; i<=4; i++)
if(code&(1<<i))
printf("%s%s\n", prefix, speeds[i]);
}
}
static void dmi_memory_controller_slots(u8 count, u8 *p, const char *prefix)
{
int i;
printf("%sAssociated Memory Slots: %u\n",
prefix, count);
for(i=0; i<count; i++)
printf("%s\t0x%04X\n",
prefix, WORD(p+sizeof(u16)*i));
}
/*
* 3.3.7 Memory Module Information (Type 6)
*/
static void dmi_memory_module_types(u16 code, const char *sep)
{
/* 3.3.7.1 */
static const char *types[]={
"Other", /* 0 */
"Unknown",
"Standard",
"FPM",
"EDO",
"Parity",
"ECC",
"SIMM",
"DIMM",
"Burst EDO",
"SDRAM" /* 10 */
};
if((code&0x07FF)==0)
printf(" None");
else
{
int i;
for(i=0; i<=10; i++)
if(code&(1<<i))
printf("%s%s", sep, types[i]);
}
}
static void dmi_memory_module_connections(u8 code)
{
if(code==0xFF)
printf(" None");
else
{
if((code&0xF0)!=0xF0)
printf(" %u", code>>4);
if((code&0x0F)!=0x0F)
printf(" %u", code&0x0F);
}
}
static void dmi_memory_module_speed(u8 code)
{
if(code==0)
printf(" Unknown");
else
printf(" %u ns", code);
}
static void dmi_memory_module_size(u8 code)
{
/* 3.3.7.2 */
switch(code&0x7F)
{
case 0x7D:
printf(" Not Determinable");
break;
case 0x7E:
printf(" Disabled");
break;
case 0x7F:
printf(" Not Installed");
return;
default:
printf(" %u MB", 1<<(code&0x7F));
}
if(code&0x80)
printf(" (Double-bank Connection)");
else
printf(" (Single-bank Connection)");
}
static void dmi_memory_module_error(u8 code, const char *prefix)
{
if(code&(1<<2))
printf(" See Event Log\n");
else
{ if((code&0x03)==0)
printf(" OK\n");
if(code&(1<<0))
printf("%sUncorrectable Errors\n", prefix);
if(code&(1<<1))
printf("%sCorrectable Errors\n", prefix);
}
}
/*
* 3.3.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];
}
static const char *dmi_cache_location(u8 code)
{
static const char *location[4]={
"Internal", /* 0x00 */
"External",
NULL, /* 0x02 */
"Unknown" /* 0x03 */
};
if(location[code]!=NULL)
return location[code];
return out_of_spec;
}
static void dmi_cache_size(u16 code)
{
if(code&0x8000)
printf(" %u KB", (code&0x7FFF)<<6);
else
printf(" %u KB", code);
}
static void dmi_cache_types(u16 code, const char *sep)
{
/* 3.3.8.2 */
static const char *types[]={
"Other", /* 0 */
"Unknown",
"Non-burst",
"Burst",
"Pipeline Burst",
"Synchronous",
"Asynchronous" /* 6 */
};
if((code&0x007F)==0)
printf(" None");
else
{
int i;
for(i=0; i<=6; i++)
if(code&(1<<i))
printf("%s%s", sep, types[i]);
}
}
static const char *dmi_cache_ec_type(u8 code)
{
/* 3.3.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)
{
/* 3.3.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)
{
/* 3.3.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" /* 0x08 */
};
if(code>=0x01 && code<=0x08)
return type[code-0x01];
return out_of_spec;
}
/*
* 3.3.9 Port Connector Information (Type 8)
*/
static const char *dmi_port_connector_type(u8 code)
{
/* 3.3.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" /* 0x22 */
};
static const char *type_0xA0[]={
"PC-98", /* 0xA0 */
"PC-98 Hireso",
"PC-H98",
"PC-98 Note",
"PC-98 Full" /* 0xA4 */
};
if(code<=0x22)
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)
{
/* 3.3.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" /* 0x21 */
};
static const char *type_0xA0[]={
"8251 Compatible", /* 0xA0 */
"8251 FIFO Compatible" /* 0xA1 */
};
if(code<=0x21)
return type[code];
if(code>=0xA0 && code<=0xA1)
return type_0xA0[code-0xA0];
if(code==0xFF)
return "Other";
return out_of_spec;
}
/*
* 3.3.10 System Slots (Type 9)
*/
static const char *dmi_slot_type(u8 code)
{
/* 3.3.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" /* 0x13 */
};
static const char *type_0xA0[]={
"PC-98/C20", /* 0xA0 */
"PC-98/C24",
"PC-98/E",
"PC-98/Local Bus",
"PC-98/Card",
"PCI Express" /* 0xA5 */
};
if(code>=0x01 && code<=0x13)
return type[code-0x01];
if(code>=0xA0 && code<=0xA5)
return type_0xA0[code-0xA0];
return out_of_spec;
}
static const char *dmi_slot_bus_width(u8 code)
{
/* 3.3.10.2 */
static const char *width[]={
"", /* 0x01, "Other" */
"", /* "Unknown" */
"8-bit ",
"16-bit ",
"32-bit ",
"64-bit ",
"128-bit ",
"x1 ",
"x2 ",
"x4 ",
"x8 ",
"x12 ",
"x16 ",
"x32 " /* 0x0E */
};
if(code>=0x01 && code<=0x0E)
return width[code-0x01];
return out_of_spec;
}
static const char *dmi_slot_current_usage(u8 code)
{
/* 3.3.10.3 */
static const char *usage[]={
"Other", /* 0x01 */
"Unknown",
"Available",
"In Use" /* 0x04 */
};
if(code>=0x01 && code<=0x04)
return usage[code-0x01];
return out_of_spec;
}
static const char *dmi_slot_length(u8 code)
{
/* 3.3.1O.4 */
static const char *length[]={
"Other", /* 0x01 */
"Unknown",
"Short",
"Long" /* 0x04 */
};
if(code>=0x01 && code<=0x04)
return length[code-0x01];
return out_of_spec;
}
static void dmi_slot_id(u8 code1, u8 code2, u8 type, const char *prefix)
{
/* 3.3.10.5 */
switch(type)
{
case 0x04: /* MCA */
printf("%sID: %u\n", prefix, code1);
break;
case 0x05: /* EISA */
printf("%sID: %u\n", prefix, 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 0xA5: /* PCI Express */
printf("%sID: %u\n", prefix, code1);
break;
case 0x07: /* PCMCIA */
printf("%sID: Adapter %u, Socket %u\n", prefix, code1, code2);
break;
}
}
static void dmi_slot_characteristics(u8 code1, u8 code2, const char *prefix)
{
/* 3.3.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 */
};
/* 3.3.10.7 */
static const char *characteristics2[]={
"PME signal is supported", /* 0 */
"Hot-plug devices are supported",
"SMBus signal is supported" /* 2 */
};
if(code1&(1<<0))
printf(" Unknown\n");
else if((code1&0xFE)==0 && (code2&0x07)==0)
printf(" None\n");
else
{
int i;
printf("\n");
for(i=1; i<=7; i++)
if(code1&(1<<i))
printf("%s%s\n", prefix, characteristics1[i-1]);
for(i=0; i<=2; i++)
if(code2&(1<<i))
printf("%s%s\n", prefix, characteristics2[i]);
}
}
/*
* 3.3.11 On Board Devices Information (Type 10)
*/
static const char *dmi_on_board_devices_type(u8 code)
{
/* 3.3.11.1 */
static const char *type[]={
"Other", /* 0x01 */
"Unknown",
"Video",
"SCSI Controller",
"Ethernet",
"Token Ring",
"Sound",
"PATA Controller",
"SATA Controller",
"SAS Controller" /* 0x0A */
};
if(code>=0x01 && code<=0x0A)
return type[code-0x01];
return out_of_spec;
}
static void dmi_on_board_devices(struct dmi_header *h, const char *prefix)
{
u8 *p=h->data+4;
u8 count=(h->length-0x04)/2;
int i;
for(i=0; i<count; i++)
{
if(count==1)
printf("%sOn Board Device Information\n",
prefix);
else
printf("%sOn Board Device %d Information\n",
prefix, i+1);
printf("%s\tType: %s\n",
prefix, dmi_on_board_devices_type(p[2*i]&0x7F));
printf("%s\tStatus: %s\n",
prefix, p[2*i]&0x80?"Enabled":"Disabled");
printf("%s\tDescription: %s\n",
prefix, dmi_string(h, p[2*i+1]));
}
}
/*
* 3.3.12 OEM Strings (Type 11)
*/
static void dmi_oem_strings(struct dmi_header *h, const char *prefix)
{
u8 *p=h->data+4;
u8 count=p[0x00];
int i;
for(i=1; i<=count; i++)
printf("%sString %d: %s\n",
prefix, i, dmi_string(h, i));
}
/*
* 3.3.13 System Configuration Options (Type 12)
*/
static void dmi_system_configuration_options(struct dmi_header *h, const char *prefix)
{
u8 *p=h->data+4;
u8 count=p[0x00];
int i;
for(i=1; i<=count; i++)
printf("%sOption %d: %s\n",
prefix, i, dmi_string(h, i));
}
/*
* 3.3.14 BIOS Language Information (Type 13)
*/
static void dmi_bios_languages(struct dmi_header *h, const char *prefix)
{
u8 *p=h->data+4;
u8 count=p[0x00];
int i;
for(i=1; i<=count; i++)
printf("%s%s\n",
prefix, dmi_string(h, i));
}
/*
* 3.3.15 Group Associations (Type 14)
*/
static void dmi_group_associations_items(u8 count, u8 *p, const char *prefix)
{
int i;
for(i=0; i<count; i++)
{
printf("%s0x%04X (%s)\n",
prefix, WORD(p+3*i+1),
dmi_smbios_structure_type(p[3*i]));
}
}
/*
* 3.3.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 */
};
printf(" %s, %s",
valid[(code>>0)&1], full[(code>>1)&1]);
}
static void dmi_event_log_address(u8 method, u8 *p)
{
/* 3.3.16.3 */
switch(method)
{
case 0x00:
case 0x01:
case 0x02:
printf(" Index 0x%04X, Data 0x%04X", WORD(p), WORD(p+2));
break;
case 0x03:
printf(" 0x%08X", DWORD(p));
break;
case 0x04:
printf(" 0x%04X", WORD(p));
break;
default:
printf(" 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)
{
/* 3.3.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)
{
/* 3.3.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, u8 *p, const char *prefix)
{
/* 3.3.16.1 */
int i;
for(i=0; i<count; i++)
{
if(len>=0x02)
{
printf("%sDescriptor %u: %s\n",
prefix, i+1, dmi_event_log_descriptor_type(p[i*len]));
printf("%sData Format %u: %s\n",
prefix, i+1, dmi_event_log_descriptor_format(p[i*len+1]));
}
}
}
/*
* 3.3.17 Physical Memory Array (Type 16)
*/
static const char *dmi_memory_array_location(u8 code)
{
/* 3.3.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, master.mif says 16 */
};
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",
"PC-98/Card Slot Add-on Card" /* 0xA4, from master.mif */
};
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)
{
/* 3.3.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)
{
/* 3.3.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_capacity(u32 code)
{
if(code==0x8000000)
printf(" Unknown");
else
{
if((code&0x000FFFFF)==0)
printf(" %u GB", code>>20);
else if((code&0x000003FF)==0)
printf(" %u MB", code>>10);
else
printf(" %u kB", code);
}
}
static void dmi_memory_array_error_handle(u16 code)
{
if(code==0xFFFE)
printf(" Not Provided");
else if(code==0xFFFF)
printf(" No Error");
else
printf(" 0x%04X", code);
}
/*
* 3.3.18 Memory Device (Type 17)
*/
static void dmi_memory_device_width(u16 code)
{
/*
* If no memory module is present, width may be 0
*/
if(code==0xFFFF || code==0)
printf(" Unknown");
else
printf(" %u bits", code);
}
static void dmi_memory_device_size(u16 code)
{
if(code==0)
printf(" No Module Installed");
else if(code==0xFFFF)
printf(" Unknown");
else
{
if(code&0x8000)
printf(" %u kB", code&0x7FFF);
else
printf(" %u MB", code);
}
}
static const char *dmi_memory_device_form_factor(u8 code)
{
/* 3.3.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" /* 0x0F */
};
if(code>=0x01 && code<=0x0F)
return form_factor[code-0x01];
return out_of_spec;
}
static void dmi_memory_device_set(u8 code)
{
if(code==0)
printf(" None");
else if(code==0xFF)
printf(" Unknown");
else
printf(" %u", code);
}
static const char *dmi_memory_device_type(u8 code)
{
/* 3.3.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" /* 0x14 */
};
if(code>=0x01 && code<=0x14)
return type[code-0x01];
return out_of_spec;
}
static void dmi_memory_device_type_detail(u16 code)
{
/* 3.3.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" /* 12 */
};
if((code&0x1FFE)==0)
printf(" None");
else
{
int i;
for(i=1; i<=12; i++)
if(code&(1<<i))
printf(" %s", detail[i-1]);
}
}
static void dmi_memory_device_speed(u16 code)
{
if(code==0)
printf(" Unknown");
else
printf(" %u MHz (%.1f ns)", code, (float)1000/code);
}
/*
* 3.3.19 32-bit Memory Error Information (Type 18)
*/
static const char *dmi_memory_error_type(u8 code)
{
/* 3.3.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)
{
/* 3.3.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)
{
/* 3.3.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)
printf(" Unknown");
else
printf(" 0x%08X", code);
}
static void dmi_32bit_memory_error_address(u32 code)
{
if(code==0x80000000)
printf(" Unknown");
else
printf(" 0x%08X", code);
}
/*
* 3.3.20 Memory Array Mapped Address (Type 19)
*/
static void dmi_mapped_address_size(u32 code)
{
if(code==0)
printf(" Invalid");
else if((code&0x000FFFFF)==0)
printf(" %u GB", code>>20);
else if((code&0x000003FF)==0)
printf(" %u MB", code>>10);
else
printf(" %u kB", code);
}
/*
* 3.3.21 Memory Device Mapped Address (Type 20)
*/
static void dmi_mapped_address_row_position(u8 code)
{
if(code==0)
printf(" %s", out_of_spec);
else if(code==0xFF)
printf(" Unknown");
else
printf(" %u", code);
}
static void dmi_mapped_address_interleave_position(u8 code, const char *prefix)
{
if(code!=0)
{
printf("%sInterleave Position:", prefix);
if(code==0xFF)
printf(" Unknown");
else
printf(" %u", code);
printf("\n");
}
}
static void dmi_mapped_address_interleaved_data_depth(u8 code, const char *prefix)
{
if(code!=0)
{
printf("%sInterleaved Data Depth:", prefix);
if(code==0xFF)
printf(" Unknown");
else
printf(" %u", code);
printf("\n");
}
}
/*
* 3.3.22 Built-in Pointing Device (Type 21)
*/
static const char *dmi_pointing_device_type(u8 code)
{
/* 3.3.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)
{
/* 3.3.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" /* 0xA2 */
};
if(code>=0x01 && code<=0x08)
return interface[code-0x01];
if(code>=0xA0 && code<=0xA2)
return interface_0xA0[code-0xA0];
return out_of_spec;
}
/*
* 3.3.23 Portable Battery (Type 22)
*/
static const char *dmi_battery_chemistry(u8 code)
{
/* 3.3.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)
printf(" Unknown");
else
printf(" %u mWh", code*multiplier);
}
static void dmi_battery_voltage(u16 code)
{
if(code==0)
printf(" Unknown");
else
printf(" %u mV", code);
}
static void dmi_battery_maximum_error(u8 code)
{
if(code==0xFF)
printf(" Unknown");
else
printf(" %u%%", code);
}
/*
* 3.3.24 System Reset (Type 23)
*/
static const char *dmi_system_reset_boot_option(u8 code)
{
static const char *option[]={
"Operating System", /* 0x1 */
"System Utilities",
"Do Not Reboot" /* 0x3 */
};
if(code>=0x1)
return option[code-0x1];
return out_of_spec;
}
static void dmi_system_reset_count(u16 code)
{
if(code==0xFFFF)
printf(" Unknown");
else
printf(" %u", code);
}
static void dmi_system_reset_timer(u16 code)
{
if(code==0xFFFF)
printf(" Unknown");
else
printf(" %u min", code);
}
/*
* 3.3.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];
}
/*
* 3.3.26 System Power Controls (Type 25)
*/
static void dmi_power_controls_power_on(u8 *p)
{
/* 3.3.26.1 */
if(dmi_bcd_range(p[0], 0x01, 0x12))
printf(" %02X", p[0]);
else
printf(" *");
if(dmi_bcd_range(p[1], 0x01, 0x31))
printf("-%02X", p[1]);
else
printf("-*");
if(dmi_bcd_range(p[2], 0x00, 0x23))
printf(" %02X", p[2]);
else
printf(" *");
if(dmi_bcd_range(p[3], 0x00, 0x59))
printf(":%02X", p[3]);
else
printf(":*");
if(dmi_bcd_range(p[4], 0x00, 0x59))
printf(":%02X", p[4]);
else
printf(":*");
}
/*
* 3.3.27 Voltage Probe (Type 26)
*/
static const char *dmi_voltage_probe_location(u8 code)
{
/* 3.3.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)
{
/* 3.3.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(u16 code)
{
if(code==0x8000)
printf(" Unknown");
else
printf(" %.3f V", (float)(i16)code/1000);
}
static void dmi_voltage_probe_resolution(u16 code)
{
if(code==0x8000)
printf(" Unknown");
else
printf(" %.1f mV", (float)code/10);
}
static void dmi_probe_accuracy(u16 code)
{
if(code==0x8000)
printf(" Unknown");
else
printf(" %.2f%%", (float)code/100);
}
/*
* 3.3.28 Cooling Device (Type 27)
*/
static const char *dmi_cooling_device_type(u8 code)
{
/* 3.3.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, master.mif says 32 */
"Passive Cooling" /* 0x11, master.mif says 33 */
};
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)
printf(" Unknown Or Non-rotating");
else
printf(" %u rpm", code);
}
/*
* 3.3.29 Temperature Probe (Type 28)
*/
static const char *dmi_temperature_probe_location(u8 code)
{
/* 3.3.29.1 */
static const char *location[]={
"Other", /* 0x01 */
"Unknown",
"Processor",
"Disk",
"Peripheral Bay",
"System Management Module", /* master.mif says SMB Master */
"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(u16 code)
{
if(code==0x8000)
printf(" Unknown");
else
printf(" %.1f deg C", (float)(i16)code/10);
}
static void dmi_temperature_probe_resolution(u16 code)
{
if(code==0x8000)
printf(" Unknown");
else
printf(" %.3f deg C", (float)code/1000);
}
/*
* 3.3.30 Electrical Current Probe (Type 29)
*/
static void dmi_current_probe_value(u16 code)
{
if(code==0x8000)
printf(" Unknown");
else
printf(" %.3f A", (float)(i16)code/1000);
}
static void dmi_current_probe_resolution(u16 code)
{
if(code==0x8000)
printf(" Unknown");
else
printf(" %.1f mA", (float)code/10);
}
/*
* 3.3.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;
}
/*
* 3.3.34 64-bit Memory Error Information (Type 33)
*/
static void dmi_64bit_memory_error_address(u64 code)
{
if(code.h==0x80000000 && code.l==0x00000000)
printf(" Unknown");
else
printf(" 0x%08X%08X", code.h, code.l);
}
/*
* 3.3.35 Management Device (Type 34)
*/
static const char *dmi_management_device_type(u8 code)
{
/* 3.3.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)
{
/* 3.3.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;
}
/*
* 3.3.38 Memory Channel (Type 37)
*/
static const char *dmi_memory_channel_type(u8 code)
{
/* 3.3.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, u8 *p, const char *prefix)
{
int i;
for(i=1; i<=count; i++)
{
printf("%sDevice %u Load: %u\n",
prefix, i, p[3*i]);
if(!(opt.flags & FLAG_QUIET))
printf("%sDevice %u Handle: 0x%04X\n",
prefix, i, WORD(p+3*i+1));
}
}
/*
* 3.3.39 IPMI Device Information (Type 38)
*/
static const char *dmi_ipmi_interface_type(u8 code)
{
/* 3.3.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, u8 *p, u8 lsb)
{
if(type==0x04) /* SSIF */
{
printf("0x%02X (SMBus)", (*p)>>1);
}
else
{
u64 address=QWORD(p);
printf("0x%08X%08X (%s)", address.h, (address.l&~1)|lsb,
address.l&1?"I/O":"Memory-mapped");
}
}
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 */
};
if(code<=0x02)
return spacing[code];
return out_of_spec;
}
/*
* 3.3.40 System Power Supply (Type 39)
*/
static void dmi_power_supply_power(u16 code)
{
if(code==0x8000)
printf(" Unknown");
else
printf(" %.3f W", (float)code/1000);
}
static const char *dmi_power_supply_type(u8 code)
{
/* 3.3.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)
{
/* 3.3.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)
{
/* 3.3.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;
}
/*
* Main
*/
static void dmi_decode(struct dmi_header *h, u16 ver)
{
u8 *data=h->data;
/*
* Note: DMI types 37 and 39 are untested
*/
switch(h->type)
{
case 0: /* 3.3.1 BIOS Information */
printf("BIOS Information\n");
if(h->length<0x12) break;
printf("\tVendor: %s\n",
dmi_string(h, data[0x04]));
printf("\tVersion: %s\n",
dmi_string(h, data[0x05]));
printf("\tRelease Date: %s\n",
dmi_string(h, data[0x08]));
/*
* On IA-64, 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)
{
printf("\tAddress: 0x%04X0\n",
WORD(data+0x06));
printf("\tRuntime Size:");
dmi_bios_runtime_size((0x10000-WORD(data+0x06))<<4);
printf("\n");
}
printf("\tROM Size: %u kB\n",
(data[0x09]+1)<<6);
printf("\tCharacteristics:\n");
dmi_bios_characteristics(QWORD(data+0x0A), "\t\t");
if(h->length<0x13) break;
dmi_bios_characteristics_x1(data[0x12], "\t\t");
if(h->length<0x14) break;
dmi_bios_characteristics_x2(data[0x13], "\t\t");
if(h->length<0x18) break;
if(data[0x14]!=0xFF && data[0x15]!=0xFF)
printf("\tBIOS Revision: %u.%u\n",
data[0x14], data[0x15]);
if(data[0x16]!=0xFF && data[0x17]!=0xFF)
printf("\tFirmware Revision: %u.%u\n",
data[0x16], data[0x17]);
break;
case 1: /* 3.3.2 System Information */
printf("System Information\n");
if(h->length<0x08) break;
printf("\tManufacturer: %s\n",
dmi_string(h, data[0x04]));
printf("\tProduct Name: %s\n",
dmi_string(h, data[0x05]));
printf("\tVersion: %s\n",
dmi_string(h, data[0x06]));
printf("\tSerial Number: %s\n",
dmi_string(h, data[0x07]));
if(h->length<0x19) break;
printf("\tUUID: ");
dmi_system_uuid(data+0x08);
printf("\n");
printf("\tWake-up Type: %s\n",
dmi_system_wake_up_type(data[0x18]));
if(h->length<0x1B) break;
printf("\tSKU Number: %s\n",
dmi_string(h, data[0x19]));
printf("\tFamily: %s\n",
dmi_string(h, data[0x1A]));
break;
case 2: /* 3.3.3 Base Board Information */
printf("Base Board Information\n");
if(h->length<0x08) break;
printf("\tManufacturer: %s\n",
dmi_string(h, data[0x04]));
printf("\tProduct Name: %s\n",
dmi_string(h, data[0x05]));
printf("\tVersion: %s\n",
dmi_string(h, data[0x06]));
printf("\tSerial Number: %s\n",
dmi_string(h, data[0x07]));
if(h->length<0x0F) break;
printf("\tAsset Tag: %s\n",
dmi_string(h, data[0x08]));
printf("\tFeatures:");
dmi_base_board_features(data[0x09], "\t\t");
printf("\tLocation In Chassis: %s\n",
dmi_string(h, data[0x0A]));
if(!(opt.flags & FLAG_QUIET))
printf("\tChassis Handle: 0x%04X\n",
WORD(data+0x0B));
printf("\tType: %s\n",
dmi_base_board_type(data[0x0D]));
if(h->length<0x0F+data[0x0E]*sizeof(u16)) break;
if(!(opt.flags & FLAG_QUIET))
dmi_base_board_handles(data[0x0E], data+0x0F, "\t");
break;
case 3: /* 3.3.4 Chassis Information */
printf("Chassis Information\n");
if(h->length<0x09) break;
printf("\tManufacturer: %s\n",
dmi_string(h, data[0x04]));
printf("\tType: %s\n",
dmi_chassis_type(data[0x05]&0x7F));
printf("\tLock: %s\n",
dmi_chassis_lock(data[0x05]>>7));
printf("\tVersion: %s\n",
dmi_string(h, data[0x06]));
printf("\tSerial Number: %s\n",
dmi_string(h, data[0x07]));
printf("\tAsset Tag: %s\n",
dmi_string(h, data[0x08]));
if(h->length<0x0D) break;
printf("\tBoot-up State: %s\n",
dmi_chassis_state(data[0x09]));
printf("\tPower Supply State: %s\n",
dmi_chassis_state(data[0x0A]));
printf("\tThermal State: %s\n",
dmi_chassis_state(data[0x0B]));
printf("\tSecurity Status: %s\n",
dmi_chassis_security_status(data[0x0C]));
if(h->length<0x11) break;
printf("\tOEM Information: 0x%08X\n",
DWORD(data+0x0D));
if(h->length<0x15) break;
printf("\tHeight:");
dmi_chassis_height(data[0x11]);
printf("\n");
printf("\tNumber Of Power Cords:");
dmi_chassis_power_cords(data[0x12]);
printf("\n");
if(h->length<0x15+data[0x13]*data[0x14]) break;
dmi_chassis_elements(data[0x13], data[0x14], data+0x15, "\t");
break;
case 4: /* 3.3.5 Processor Information */
printf("Processor Information\n");
if(h->length<0x1A) break;
printf("\tSocket Designation: %s\n",
dmi_string(h, data[0x04]));
printf("\tType: %s\n",
dmi_processor_type(data[0x05]));
printf("\tFamily: %s\n",
dmi_processor_family(data[0x06]));
printf("\tManufacturer: %s\n",
dmi_string(h, data[0x07]));
dmi_processor_id(data[0x06], data+8, dmi_string(h, data[0x10]), "\t");
printf("\tVersion: %s\n",
dmi_string(h, data[0x10]));
printf("\tVoltage:");
dmi_processor_voltage(data[0x11]);
printf("\n");
printf("\tExternal Clock: ");
dmi_processor_frequency(data+0x12);
printf("\n");
printf("\tMax Speed: ");
dmi_processor_frequency(data+0x14);
printf("\n");
printf("\tCurrent Speed: ");
dmi_processor_frequency(data+0x16);
printf("\n");
if(data[0x18]&(1<<6))
printf("\tStatus: Populated, %s\n",
dmi_processor_status(data[0x18]&0x07));
else
printf("\tStatus: Unpopulated\n");
printf("\tUpgrade: %s\n",
dmi_processor_upgrade(data[0x19]));
if(h->length<0x20) break;
if(!(opt.flags & FLAG_QUIET))
{
printf("\tL1 Cache Handle:");
dmi_processor_cache(WORD(data+0x1A), "L1", ver);
printf("\n");
printf("\tL2 Cache Handle:");
dmi_processor_cache(WORD(data+0x1C), "L2", ver);
printf("\n");
printf("\tL3 Cache Handle:");
dmi_processor_cache(WORD(data+0x1E), "L3", ver);
printf("\n");
}
if(h->length<0x23) break;
printf("\tSerial Number: %s\n",
dmi_string(h, data[0x20]));
printf("\tAsset Tag: %s\n",
dmi_string(h, data[0x21]));
printf("\tPart Number: %s\n",
dmi_string(h, data[0x22]));
if(h->length<0x28) break;
if(data[0x23]!=0)
printf("\tCore Count: %u\n", data[0x23]);
if(data[0x24]!=0)
printf("\tCore Enabled: %u\n", data[0x24]);
if(data[0x25]!=0)
printf("\tThread Count: %u\n", data[0x25]);
printf("\tCharacteristics:");
dmi_processor_characteristics(WORD(data+0x26), "\t\t");
break;
case 5: /* 3.3.6 Memory Controller Information */
printf("Memory Controller Information\n");
if(h->length<0x0F) break;
printf("\tError Detecting Method: %s\n",
dmi_memory_controller_ed_method(data[0x04]));
printf("\tError Correcting Capabilities:");
dmi_memory_controller_ec_capabilities(data[0x05], "\t\t");
printf("\tSupported Interleave: %s\n",
dmi_memory_controller_interleave(data[0x06]));
printf("\tCurrent Interleave: %s\n",
dmi_memory_controller_interleave(data[0x07]));
printf("\tMaximum Memory Module Size: %u MB\n",
1<<data[0x08]);
printf("\tMaximum Total Memory Size: %u MB\n",
data[0x0E]*(1<<data[0x08]));
printf("\tSupported Speeds:");
dmi_memory_controller_speeds(WORD(data+0x09), "\t\t");
printf("\tSupported Memory Types:");
dmi_memory_module_types(WORD(data+0x0B), "\n\t\t");
printf("\n");
printf("\tMemory Module Voltage:");
dmi_processor_voltage(data[0x0D]);
printf("\n");
if(h->length<0x0F+data[0x0E]*sizeof(u16)) break;
dmi_memory_controller_slots(data[0x0E], data+0x0F, "\t");
if(h->length<0x10+data[0x0E]*sizeof(u16)) break;
printf("\tEnabled Error Correcting Capabilities:");
dmi_memory_controller_ec_capabilities(data[0x0F+data[0x0E]*sizeof(u16)], "\t\t");
break;
case 6: /* 3.3.7 Memory Module Information */
printf("Memory Module Information\n");
if(h->length<0x0C) break;
printf("\tSocket Designation: %s\n",
dmi_string(h, data[0x04]));
printf("\tBank Connections:");
dmi_memory_module_connections(data[0x05]);
printf("\n");
printf("\tCurrent Speed:");
dmi_memory_module_speed(data[0x06]);
printf("\n");
printf("\tType:");
dmi_memory_module_types(WORD(data+0x07), " ");
printf("\n");
printf("\tInstalled Size:");
dmi_memory_module_size(data[0x09]);
printf("\n");
printf("\tEnabled Size:");
dmi_memory_module_size(data[0x0A]);
printf("\n");
printf("\tError Status:");
dmi_memory_module_error(data[0x0B], "\t\t");
break;
case 7: /* 3.3.8 Cache Information */
printf("Cache Information\n");
if(h->length<0x0F) break;
printf("\tSocket Designation: %s\n",
dmi_string(h, data[0x04]));
printf("\tConfiguration: %s, %s, Level %u\n",
WORD(data+0x05)&0x0080?"Enabled":"Disabled",
WORD(data+0x05)&0x0008?"Socketed":"Not Socketed",
(WORD(data+0x05)&0x0007)+1);
printf("\tOperational Mode: %s\n",
dmi_cache_mode((WORD(data+0x05)>>8)&0x0003));
printf("\tLocation: %s\n",
dmi_cache_location((WORD(data+0x05)>>5)&0x0003));
printf("\tInstalled Size:");
dmi_cache_size(WORD(data+0x09));
printf("\n");
printf("\tMaximum Size:");
dmi_cache_size(WORD(data+0x07));
printf("\n");
printf("\tSupported SRAM Types:");
dmi_cache_types(WORD(data+0x0B), "\n\t\t");
printf("\n");
printf("\tInstalled SRAM Type:");
dmi_cache_types(WORD(data+0x0D), " ");
printf("\n");
if(h->length<0x13) break;
printf("\tSpeed:");
dmi_memory_module_speed(data[0x0F]);
printf("\n");
printf("\tError Correction Type: %s\n",
dmi_cache_ec_type(data[0x10]));
printf("\tSystem Type: %s\n",
dmi_cache_type(data[0x11]));
printf("\tAssociativity: %s\n",
dmi_cache_associativity(data[0x12]));
break;
case 8: /* 3.3.9 Port Connector Information */
printf("Port Connector Information\n");
if(h->length<0x09) break;
printf("\tInternal Reference Designator: %s\n",
dmi_string(h, data[0x04]));
printf("\tInternal Connector Type: %s\n",
dmi_port_connector_type(data[0x05]));
printf("\tExternal Reference Designator: %s\n",
dmi_string(h, data[0x06]));
printf("\tExternal Connector Type: %s\n",
dmi_port_connector_type(data[0x07]));
printf("\tPort Type: %s\n",
dmi_port_type(data[0x08]));
break;
case 9: /* 3.3.10 System Slots */
printf("System Slot Information\n");
if(h->length<0x0C) break;
printf("\tDesignation: %s\n",
dmi_string(h, data[0x04]));
printf("\tType: %s%s\n",
dmi_slot_bus_width(data[0x06]),
dmi_slot_type(data[0x05]));
printf("\tCurrent Usage: %s\n",
dmi_slot_current_usage(data[0x07]));
printf("\tLength: %s\n",
dmi_slot_length(data[0x08]));
dmi_slot_id(data[0x09], data[0x0A], data[0x05], "\t");
printf("\tCharacteristics:");
if(h->length<0x0D)
dmi_slot_characteristics(data[0x0B], 0x00, "\t\t");
else
dmi_slot_characteristics(data[0x0B], data[0x0C], "\t\t");
break;
case 10: /* 3.3.11 On Board Devices Information */
dmi_on_board_devices(h, "");
break;
case 11: /* 3.3.12 OEM Strings */
printf("OEM Strings\n");
if(h->length<0x05) break;
dmi_oem_strings(h, "\t");
break;
case 12: /* 3.3.13 System Configuration Options */
printf("System Configuration Options\n");
if(h->length<0x05) break;
dmi_system_configuration_options(h, "\t");
break;
case 13: /* 3.3.14 BIOS Language Information */
printf("BIOS Language Information\n");
if(h->length<0x16) break;
printf("\tInstallable Languages: %u\n", data[0x04]);
dmi_bios_languages(h, "\t\t");
printf("\tCurrently Installed Language: %s\n",
dmi_string(h, data[0x15]));
break;
case 14: /* 3.3.15 Group Associations */
printf("Group Associations\n");
if(h->length<0x05) break;
printf("\tName: %s\n",
dmi_string(h, data[0x04]));
printf("\tItems: %u\n",
(h->length-0x05)/3);
dmi_group_associations_items((h->length-0x05)/3, data+0x05, "\t\t");
break;
case 15: /* 3.3.16 System Event Log */
printf("System Event Log\n");
if(h->length<0x14) break;
printf("\tArea Length: %u bytes\n",
WORD(data+0x04));
printf("\tHeader Start Offset: 0x%04X\n",
WORD(data+0x06));
if(WORD(data+0x08)-WORD(data+0x06))
printf("\tHeader Length: %u byte%s\n",
WORD(data+0x08)-WORD(data+0x06),
WORD(data+0x08)-WORD(data+0x06)>1?"s":"");
printf("\tData Start Offset: 0x%04X\n",
WORD(data+0x08));
printf("\tAccess Method: %s\n",
dmi_event_log_method(data[0x0A]));
printf("\tAccess Address:");
dmi_event_log_address(data[0x0A], data+0x10);
printf("\n");
printf("\tStatus:");
dmi_event_log_status(data[0x0B]);
printf("\n");
printf("\tChange Token: 0x%08X\n",
DWORD(data+0x0C));
if(h->length<0x17) break;
printf("\tHeader Format: %s\n",
dmi_event_log_header_type(data[0x14]));
printf("\tSupported Log Type Descriptors: %u\n",
data[0x15]);
if(h->length<0x17+data[0x15]*data[0x16]) break;
dmi_event_log_descriptors(data[0x15], data[0x16], data+0x17, "\t");
break;
case 16: /* 3.3.17 Physical Memory Array */
printf("Physical Memory Array\n");
if(h->length<0x0F) break;
printf("\tLocation: %s\n",
dmi_memory_array_location(data[0x04]));
printf("\tUse: %s\n",
dmi_memory_array_use(data[0x05]));
printf("\tError Correction Type: %s\n",
dmi_memory_array_ec_type(data[0x06]));
printf("\tMaximum Capacity:");
dmi_memory_array_capacity(DWORD(data+0x07));
printf("\n");
if(!(opt.flags & FLAG_QUIET))
{
printf("\tError Information Handle:");
dmi_memory_array_error_handle(WORD(data+0x0B));
printf("\n");
}
printf("\tNumber Of Devices: %u\n",
WORD(data+0x0D));
break;
case 17: /* 3.3.18 Memory Device */
printf("Memory Device\n");
if(h->length<0x15) break;
if(!(opt.flags & FLAG_QUIET))
{
printf("\tArray Handle: 0x%04X\n",
WORD(data+0x04));
printf("\tError Information Handle:");
dmi_memory_array_error_handle(WORD(data+0x06));
printf("\n");
}
printf("\tTotal Width:");
dmi_memory_device_width(WORD(data+0x08));
printf("\n");
printf("\tData Width:");
dmi_memory_device_width(WORD(data+0x0A));
printf("\n");
printf("\tSize:");
dmi_memory_device_size(WORD(data+0x0C));
printf("\n");
printf("\tForm Factor: %s\n",
dmi_memory_device_form_factor(data[0x0E]));
printf("\tSet:");
dmi_memory_device_set(data[0x0F]);
printf("\n");
printf("\tLocator: %s\n",
dmi_string(h, data[0x10]));
printf("\tBank Locator: %s\n",
dmi_string(h, data[0x11]));
printf("\tType: %s\n",
dmi_memory_device_type(data[0x12]));
printf("\tType Detail:");
dmi_memory_device_type_detail(WORD(data+0x13));
printf("\n");
if(h->length<0x17) break;
printf("\tSpeed:");
dmi_memory_device_speed(WORD(data+0x15));
printf("\n");
if(h->length<0x1B) break;
printf("\tManufacturer: %s\n",
dmi_string(h, data[0x17]));
printf("\tSerial Number: %s\n",
dmi_string(h, data[0x18]));
printf("\tAsset Tag: %s\n",
dmi_string(h, data[0x19]));
printf("\tPart Number: %s\n",
dmi_string(h, data[0x1A]));
break;
case 18: /* 3.3.19 32-bit Memory Error Information */
printf("32-bit Memory Error Information\n");
if(h->length<0x17) break;
printf("\tType: %s\n",
dmi_memory_error_type(data[0x04]));
printf("\tGranularity: %s\n",
dmi_memory_error_granularity(data[0x05]));
printf("\tOperation: %s\n",
dmi_memory_error_operation(data[0x06]));
printf("\tVendor Syndrome:");
dmi_memory_error_syndrome(DWORD(data+0x07));
printf("\n");
printf("\tMemory Array Address:");
dmi_32bit_memory_error_address(DWORD(data+0x0B));
printf("\n");
printf("\tDevice Address:");
dmi_32bit_memory_error_address(DWORD(data+0x0F));
printf("\n");
printf("\tResolution:");
dmi_32bit_memory_error_address(DWORD(data+0x13));
printf("\n");
break;
case 19: /* 3.3.20 Memory Array Mapped Address */
printf("Memory Array Mapped Address\n");
if(h->length<0x0F) break;
printf("\tStarting Address: 0x%08X%03X\n",
DWORD(data+0x04)>>2, (DWORD(data+0x04)&0x3)<<10);
printf("\tEnding Address: 0x%08X%03X\n",
DWORD(data+0x08)>>2, ((DWORD(data+0x08)&0x3)<<10)+0x3FF);
printf("\tRange Size:");
dmi_mapped_address_size(DWORD(data+0x08)-DWORD(data+0x04)+1);
printf("\n");
if(!(opt.flags & FLAG_QUIET))
printf("\tPhysical Array Handle: 0x%04X\n",
WORD(data+0x0C));
printf("\tPartition Width: %u\n",
data[0x0F]);
break;
case 20: /* 3.3.21 Memory Device Mapped Address */
printf("Memory Device Mapped Address\n");
if(h->length<0x13) break;
printf("\tStarting Address: 0x%08X%03X\n",
DWORD(data+0x04)>>2, (DWORD(data+0x04)&0x3)<<10);
printf("\tEnding Address: 0x%08X%03X\n",
DWORD(data+0x08)>>2, ((DWORD(data+0x08)&0x3)<<10)+0x3FF);
printf("\tRange Size:");
dmi_mapped_address_size(DWORD(data+0x08)-DWORD(data+0x04)+1);
printf("\n");
if(!(opt.flags & FLAG_QUIET))
{
printf("\tPhysical Device Handle: 0x%04X\n",
WORD(data+0x0C));
printf("\tMemory Array Mapped Address Handle: 0x%04X\n",
WORD(data+0x0E));
}
printf("\tPartition Row Position:");
dmi_mapped_address_row_position(data[0x10]);
printf("\n");
dmi_mapped_address_interleave_position(data[0x11], "\t");
dmi_mapped_address_interleaved_data_depth(data[0x12], "\t");
break;
case 21: /* 3.3.22 Built-in Pointing Device */
printf("Built-in Pointing Device\n");
if(h->length<0x07) break;
printf("\tType: %s\n",
dmi_pointing_device_type(data[0x04]));
printf("\tInterface: %s\n",
dmi_pointing_device_interface(data[0x05]));
printf("\tButtons: %u\n",
data[0x06]);
break;
case 22: /* 3.3.23 Portable Battery */
printf("Portable Battery\n");
if(h->length<0x10) break;
printf("\tLocation: %s\n",
dmi_string(h, data[0x04]));
printf("\tManufacturer: %s\n",
dmi_string(h, data[0x05]));
if(data[0x06] || h->length<0x1A)
printf("\tManufacture Date: %s\n",
dmi_string(h, data[0x06]));
if(data[0x07] || h->length<0x1A)
printf("\tSerial Number: %s\n",
dmi_string(h, data[0x07]));
printf("\tName: %s\n",
dmi_string(h, data[0x08]));
if(data[0x09]!=0x02 || h->length<0x1A)
printf("\tChemistry: %s\n",
dmi_battery_chemistry(data[0x09]));
printf("\tDesign Capacity:");
if(h->length<0x1A)
dmi_battery_capacity(WORD(data+0x0A), 1);
else
dmi_battery_capacity(WORD(data+0x0A), data[0x15]);
printf("\n");
printf("\tDesign Voltage:");
dmi_battery_voltage(WORD(data+0x0C));
printf("\n");
printf("\tSBDS Version: %s\n",
dmi_string(h, data[0x0E]));
printf("\tMaximum Error:");
dmi_battery_maximum_error(data[0x0F]);
printf("\n");
if(h->length<0x1A) break;
if(data[0x07]==0)
printf("\tSBDS Serial Number: %04X\n",
WORD(data+0x10));
if(data[0x06]==0)
printf("\tSBDS Manufacture Date: %u-%02u-%02u\n",
1980+(WORD(data+0x12)>>9), (WORD(data+0x12)>>5)&0x0F,
WORD(data+0x12)&0x1F);
if(data[0x09]==0x02)
printf("\tSBDS Chemistry: %s\n",
dmi_string(h, data[0x14]));
printf("\tOEM-specific Information: 0x%08X\n",
DWORD(data+0x16));
break;
case 23: /* 3.3.24 System Reset */
printf("System Reset\n");
if(h->length<0x0D) break;
printf("\tStatus: %s\n",
data[0x04]&(1<<0)?"Enabled":"Disabled");
printf("\tWatchdog Timer: %s\n",
data[0x04]&(1<<5)?"Present":"Not Present");
if(!(data[0x04]&(1<<5)))
break;
printf("\tBoot Option: %s\n",
dmi_system_reset_boot_option((data[0x04]>>1)&0x3));
printf("\tBoot Option On Limit: %s\n",
dmi_system_reset_boot_option((data[0x04]>>3)&0x3));
printf("\tReset Count:");
dmi_system_reset_count(WORD(data+0x05));
printf("\n");
printf("\tReset Limit:");
dmi_system_reset_count(WORD(data+0x07));
printf("\n");
printf("\tTimer Interval:");
dmi_system_reset_timer(WORD(data+0x09));
printf("\n");
printf("\tTimeout:");
dmi_system_reset_timer(WORD(data+0x0B));
printf("\n");
break;
case 24: /* 3.3.25 Hardware Security */
printf("Hardware Security\n");
if(h->length<0x05) break;
printf("\tPower-On Password Status: %s\n",
dmi_hardware_security_status(data[0x04]>>6));
printf("\tKeyboard Password Status: %s\n",
dmi_hardware_security_status((data[0x04]>>4)&0x3));
printf("\tAdministrator Password Status: %s\n",
dmi_hardware_security_status((data[0x04]>>2)&0x3));
printf("\tFront Panel Reset Status: %s\n",
dmi_hardware_security_status(data[0x04]&0x3));
break;
case 25: /* 3.3.26 System Power Controls */
printf("\tSystem Power Controls\n");
if(h->length<0x09) break;
printf("\tNext Scheduled Power-on:");
dmi_power_controls_power_on(data+0x04);
printf("\n");
break;
case 26: /* 3.3.27 Voltage Probe */
printf("Voltage Probe\n");
if(h->length<0x14) break;
printf("\tDescription: %s\n",
dmi_string(h, data[0x04]));
printf("\tLocation: %s\n",
dmi_voltage_probe_location(data[0x05]&0x1f));
printf("\tStatus: %s\n",
dmi_probe_status(data[0x05]>>5));
printf("\tMaximum Value:");
dmi_voltage_probe_value(WORD(data+0x06));
printf("\n");
printf("\tMinimum Value:");
dmi_voltage_probe_value(WORD(data+0x08));
printf("\n");
printf("\tResolution:");
dmi_voltage_probe_resolution(WORD(data+0x0A));
printf("\n");
printf("\tTolerance:");
dmi_voltage_probe_value(WORD(data+0x0C));
printf("\n");
printf("\tAccuracy:");
dmi_probe_accuracy(WORD(data+0x0E));
printf("\n");
printf("\tOEM-specific Information: 0x%08X\n",
DWORD(data+0x10));
if(h->length<0x16) break;
printf("\tNominal Value:");
dmi_voltage_probe_value(WORD(data+0x14));
printf("\n");
break;
case 27: /* 3.3.28 Cooling Device */
printf("Cooling Device\n");
if(h->length<0x0C) break;
if(!(opt.flags & FLAG_QUIET) && WORD(data+0x04)!=0xFFFF)
printf("\tTemperature Probe Handle: 0x%04X\n",
WORD(data+0x04));
printf("\tType: %s\n",
dmi_cooling_device_type(data[0x06]&0x1f));
printf("\tStatus: %s\n",
dmi_probe_status(data[0x06]>>5));
if(data[0x07]!=0x00)
printf("\tCooling Unit Group: %u\n",
data[0x07]);
printf("\tOEM-specific Information: 0x%08X\n",
DWORD(data+0x08));
if(h->length<0x0E) break;
printf("\tNominal Speed:");
dmi_cooling_device_speed(WORD(data+0x0C));
printf("\n");
break;
case 28: /* 3.3.29 Temperature Probe */
printf("Temperature Probe\n");
if(h->length<0x14) break;
printf("\tDescription: %s\n",
dmi_string(h, data[0x04]));
printf("\tLocation: %s\n",
dmi_temperature_probe_location(data[0x05]&0x1F));
printf("\tStatus: %s\n",
dmi_probe_status(data[0x05]>>5));
printf("\tMaximum Value:");
dmi_temperature_probe_value(WORD(data+0x06));
printf("\n");
printf("\tMinimum Value");
dmi_temperature_probe_value(WORD(data+0x08));
printf("\n");
printf("\tResolution:");
dmi_temperature_probe_resolution(WORD(data+0x0A));
printf("\n");
printf("\tTolerance:");
dmi_temperature_probe_value(WORD(data+0x0C));
printf("\n");
printf("\tAccuracy:");
dmi_probe_accuracy(WORD(data+0x0E));
printf("\n");
printf("\tOEM-specific Information: 0x%08X\n",
DWORD(data+0x10));
if(h->length<0x16) break;
printf("\tNominal Value:");
dmi_temperature_probe_value(WORD(data+0x14));
printf("\n");
break;
case 29: /* 3.3.30 Electrical Current Probe */
printf("Electrical Current Probe\n");
if(h->length<0x14) break;
printf("\tDescription: %s\n",
dmi_string(h, data[0x04]));
printf("\tLocation: %s\n",
dmi_voltage_probe_location(data[5]&0x1F));
printf("\tStatus: %s\n",
dmi_probe_status(data[0x05]>>5));
printf("\tMaximum Value:");
dmi_current_probe_value(WORD(data+0x06));
printf("\n");
printf("\tMinimum Value:");
dmi_current_probe_value(WORD(data+0x08));
printf("\n");
printf("\tResolution:");
dmi_current_probe_resolution(WORD(data+0x0A));
printf("\n");
printf("\tTolerance:");
dmi_current_probe_value(WORD(data+0x0C));
printf("\n");
printf("\tAccuracy:");
dmi_probe_accuracy(WORD(data+0x0E));
printf("\n");
printf("\tOEM-specific Information: 0x%08X\n",
DWORD(data+0x10));
if(h->length<0x16) break;
printf("\tNominal Value:");
dmi_current_probe_value(WORD(data+0x14));
printf("\n");
break;
case 30: /* 3.3.31 Out-of-band Remote Access */
printf("Out-of-band Remote Access\n");
if(h->length<0x06) break;
printf("\tManufacturer Name: %s\n",
dmi_string(h, data[0x04]));
printf("\tInbound Connection: %s\n",
data[0x05]&(1<<0)?"Enabled":"Disabled");
printf("\tOutbound Connection: %s\n",
data[0x05]&(1<<1)?"Enabled":"Disabled");
break;
case 31: /* 3.3.32 Boot Integrity Services Entry Point */
printf("Boot Integrity Services Entry Point\n");
break;
case 32: /* 3.3.33 System Boot Information */
printf("System Boot Information\n");
if(h->length<0x0B) break;
printf("\tStatus: %s\n",
dmi_system_boot_status(data[0x0A]));
break;
case 33: /* 3.3.34 64-bit Memory Error Information */
if(h->length<0x1F) break;
printf("64-bit Memory Error Information\n");
printf("\tType: %s\n",
dmi_memory_error_type(data[0x04]));
printf("\tGranularity: %s\n",
dmi_memory_error_granularity(data[0x05]));
printf("\tOperation: %s\n",
dmi_memory_error_operation(data[0x06]));
printf("\tVendor Syndrome:");
dmi_memory_error_syndrome(DWORD(data+0x07));
printf("\n");
printf("\tMemory Array Address:");
dmi_64bit_memory_error_address(QWORD(data+0x0B));
printf("\n");
printf("\tDevice Address:");
dmi_64bit_memory_error_address(QWORD(data+0x13));
printf("\n");
printf("\tResolution:");
dmi_32bit_memory_error_address(DWORD(data+0x1B));
printf("\n");
break;
case 34: /* 3.3.35 Management Device */
printf("Management Device\n");
if(h->length<0x0B) break;
printf("\tDescription: %s\n",
dmi_string(h, data[0x04]));
printf("\tType: %s\n",
dmi_management_device_type(data[0x05]));
printf("\tAddress: 0x%08X\n",
DWORD(data+0x06));
printf("\tAddress Type: %s\n",
dmi_management_device_address_type(data[0x0A]));
break;
case 35: /* 3.3.36 Management Device Component */
printf("Management Device Component\n");
if(h->length<0x0B) break;
printf("\tDescription: %s\n",
dmi_string(h, data[0x04]));
if(!(opt.flags & FLAG_QUIET))
{
printf("\tManagement Device Handle: 0x%04X\n",
WORD(data+0x05));
printf("\tComponent Handle: 0x%04X\n",
WORD(data+0x07));
if(WORD(data+0x09)!=0xFFFF)
printf("\tThreshold Handle: 0x%04X\n",
WORD(data+0x09));
}
break;
case 36: /* 3.3.37 Management Device Threshold Data */
printf("Management Device Threshold Data\n");
if(h->length<0x10) break;
if(WORD(data+0x04)!=0x8000)
printf("\tLower Non-critical Threshold: %d\n",
(i16)WORD(data+0x04));
if(WORD(data+0x06)!=0x8000)
printf("\tUpper Non-critical Threshold: %d\n",
(i16)WORD(data+0x06));
if(WORD(data+0x08)!=0x8000)
printf("\tLower Critical Threshold: %d\n",
(i16)WORD(data+0x08));
if(WORD(data+0x0A)!=0x8000)
printf("\tUpper Critical Threshold: %d\n",
(i16)WORD(data+0x0A));
if(WORD(data+0x0C)!=0x8000)
printf("\tLower Non-recoverable Threshold: %d\n",
(i16)WORD(data+0x0C));
if(WORD(data+0x0E)!=0x8000)
printf("\tUpper Non-recoverable Threshold: %d\n",
(i16)WORD(data+0x0E));
break;
case 37: /* 3.3.38 Memory Channel */
printf("Memory Channel\n");
if(h->length<0x07) break;
printf("\tType: %s\n",
dmi_memory_channel_type(data[0x04]));
printf("\tMaximal Load: %u\n",
data[0x05]);
printf("\tDevices: %u\n",
data[0x06]);
if(h->length<0x07+3*data[0x06]) break;
dmi_memory_channel_devices(data[0x06], data+0x07, "\t");
break;
case 38: /* 3.3.39 IPMI Device Information */
/*
* We use the word "Version" instead of "Revision", conforming to
* the IPMI specification.
*/
printf("IPMI Device Information\n");
if(h->length<0x10) break;
printf("\tInterface Type: %s\n",
dmi_ipmi_interface_type(data[0x04]));
printf("\tSpecification Version: %u.%u\n",
data[0x05]>>4, data[0x05]&0x0F);
printf("\tI2C Slave Address: 0x%02x\n",
data[0x06]>>1);
if(data[0x07]!=0xFF)
printf("\tNV Storage Device Address: %u\n",
data[0x07]);
else
printf("\tNV Storage Device: Not Present\n");
printf("\tBase Address: ");
dmi_ipmi_base_address(data[0x04], data+0x08,
h->length<0x12?0:(data[0x10]>>5)&1);
printf("\n");
if(h->length<0x12) break;
if(data[0x04]!=0x04)
{
printf("\tRegister Spacing: %s\n",
dmi_ipmi_register_spacing(data[0x10]>>6));
if(data[0x10]&(1<<3))
{
printf("\tInterrupt Polarity: %s\n",
data[0x10]&(1<<1)?"Active High":"Active Low");
printf("\tInterrupt Trigger Mode: %s\n",
data[0x10]&(1<<0)?"Level":"Edge");
}
}
if(data[0x11]!=0x00)
{
printf("\tInterrupt Number: %x\n",
data[0x11]);
}
break;
case 39: /* 3.3.40 System Power Supply */
printf("System Power Supply\n");
if(h->length<0x10) break;
if(data[0x04]!=0x00)
printf("\tPower Unit Group: %u\n",
data[0x04]);
printf("\tLocation: %s\n",
dmi_string(h, data[0x05]));
printf("\tName: %s\n",
dmi_string(h, data[0x06]));
printf("\tManufacturer: %s\n",
dmi_string(h, data[0x07]));
printf("\tSerial Number: %s\n",
dmi_string(h, data[0x08]));
printf("\tAsset Tag: %s\n",
dmi_string(h, data[0x09]));
printf("\tModel Part Number: %s\n",
dmi_string(h, data[0x0A]));
printf("\tRevision: %s\n",
dmi_string(h, data[0x0B]));
printf("\tMax Power Capacity:");
dmi_power_supply_power(WORD(data+0x0C));
printf("\n");
printf("\tStatus:");
if(WORD(data+0x0E)&(1<<1))
printf(" Present, %s",
dmi_power_supply_status((WORD(data+0x0E)>>7)&0x07));
else
printf(" Not Present");
printf("\n");
printf("\tType: %s\n",
dmi_power_supply_type((WORD(data+0x0E)>>10)&0x0F));
printf("\tInput Voltage Range Switching: %s\n",
dmi_power_supply_range_switching((WORD(data+0x0E)>>3)&0x0F));
printf("\tPlugged: %s\n",
WORD(data+0x0E)&(1<<2)?"No":"Yes");
printf("\tHot Replaceable: %s\n",
WORD(data+0x0E)&(1<<0)?"Yes":"No");
if(h->length<0x16) break;
if(!(opt.flags & FLAG_QUIET))
{
if(WORD(data+0x10)!=0xFFFF)
printf("\tInput Voltage Probe Handle: 0x%04X\n",
WORD(data+0x10));
if(WORD(data+0x12)!=0xFFFF)
printf("\tCooling Device Handle: 0x%04X\n",
WORD(data+0x12));
if(WORD(data+0x14)!=0xFFFF)
printf("\tInput Current Probe Handle: 0x%04X\n",
WORD(data+0x14));
}
break;
case 126: /* 3.3.41 Inactive */
printf("Inactive\n");
break;
case 127: /* 3.3.42 End Of Table */
printf("End Of Table\n");
break;
default:
if(dmi_decode_oem(h))
break;
if(opt.flags & FLAG_QUIET)
return;
printf("%s Type\n",
h->type>=128?"OEM-specific":"Unknown");
dmi_dump(h, "\t");
}
printf("\n");
}
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(u32 base, u16 len, u16 num, u16 ver, const char *devmem)
{
u8 *buf;
u8 *data;
int i=0;
if(!(opt.flags & FLAG_QUIET))
{
if(opt.type==NULL)
printf("%u structures occupying %u bytes.\n"
"Table at 0x%08X.\n",
num, len, base);
printf("\n");
}
if((buf=mem_chunk(base, len, devmem))==NULL)
{
#ifndef USE_MMAP
printf("Table is unreachable, sorry. Try compiling dmidecode with -DUSE_MMAP.\n");
#endif
return;
}
data=buf;
while(i<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.flags & FLAG_QUIET) && (h.type>39 && 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)
{
printf("Invalid entry length (%u). DMI table is "
"broken! Stop.\n\n", (unsigned int)h.length);
opt.flags |= FLAG_QUIET;
break;
}
/* 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))
printf("Handle 0x%04X, DMI type %d, %d bytes\n",
h.handle, h.type, h.length);
/* assign vendor for vendor-specific decodes later */
if(h.type==0 && h.length>=5)
dmi_set_vendor(dmi_string(&h, data[0x04]));
/* look for the next handle */
next=data+h.length;
while(next-buf+1<len && (next[0]!=0 || next[1]!=0))
next++;
next+=2;
if(display)
{
if(next-buf<=len)
{
if(opt.flags & FLAG_DUMP)
{
dmi_dump(&h, "\t");
printf("\n");
}
else
dmi_decode(&h, ver);
}
else if(!(opt.flags & FLAG_QUIET))
printf("\t<TRUNCATED>\n\n");
}
else if(opt.string!=NULL
&& opt.string->type==h.type
&& opt.string->offset<h.length)
{
if (opt.string->lookup!=NULL)
printf("%s\n", opt.string->lookup(data[opt.string->offset]));
else if (opt.string->print!=NULL) {
opt.string->print(data+opt.string->offset);
printf("\n");
}
else
printf("%s\n", dmi_string(&h, data[opt.string->offset]));
}
data=next;
i++;
}
if(!(opt.flags & FLAG_QUIET))
{
if(i!=num)
printf("Wrong DMI structures count: %d announced, "
"only %d decoded.\n", num, i);
if(data-buf!=len)
printf("Wrong DMI structures length: %d bytes "
"announced, structures occupy %d bytes.\n",
len, (unsigned int)(data-buf));
}
free(buf);
}
static int smbios_decode(u8 *buf, const char *devmem)
{
if(checksum(buf, buf[0x05])
&& memcmp(buf+0x10, "_DMI_", 5)==0
&& checksum(buf+0x10, 0x0F))
{
if(!(opt.flags & FLAG_QUIET))
printf("SMBIOS %u.%u present.\n",
buf[0x06], buf[0x07]);
dmi_table(DWORD(buf+0x18), WORD(buf+0x16), WORD(buf+0x1C),
(buf[0x06]<<8)+buf[0x07], devmem);
return 1;
}
return 0;
}
static int legacy_decode(u8 *buf, const char *devmem)
{
if(checksum(buf, 0x0F))
{
if(!(opt.flags & FLAG_QUIET))
printf("Legacy DMI %u.%u present.\n",
buf[0x0E]>>4, buf[0x0E]&0x0F);
dmi_table(DWORD(buf+0x08), WORD(buf+0x06), WORD(buf+0x0C),
((buf[0x0E]&0xF0)<<4)+(buf[0x0E]&0x0F), devmem);
return 1;
}
return 0;
}
/*
* Probe for EFI interface
*/
#define EFI_NOT_FOUND (-1)
#define EFI_NO_SMBIOS (-2)
static int address_from_efi(size_t *address)
{
FILE *efi_systab;
const char *filename;
char linebuf[64];
int ret;
*address=0; /* Prevent compiler warning */
/*
* 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, "SMBIOS")==0)
{
*address=strtoul(addrp, NULL, 0);
if(!(opt.flags & FLAG_QUIET))
printf("# SMBIOS entry point at 0x%08lx\n",
(unsigned long)*address);
ret=0;
break;
}
}
if(fclose(efi_systab)!=0)
perror(filename);
if(ret==EFI_NO_SMBIOS)
fprintf(stderr, "%s: SMBIOS entry point missing\n", filename);
return ret;
}
int main(int argc, char * const argv[])
{
int ret=0; /* Returned value */
int found=0;
size_t fp;
int efi;
u8 *buf;
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;
if(parse_command_line(argc, argv)<0)
{
ret=2;
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))
printf("# dmidecode %s\n", VERSION);
/* First try EFI (ia64, Intel-based Mac) */
efi=address_from_efi(&fp);
switch(efi)
{
case EFI_NOT_FOUND:
goto memory_scan;
case EFI_NO_SMBIOS:
ret=1;
goto exit_free;
}
if((buf=mem_chunk(fp, 0x20, opt.devmem))==NULL)
{
ret=1;
goto exit_free;
}
if(smbios_decode(buf, opt.devmem))
found++;
goto done;
memory_scan:
/* Fallback to memory scan (x86, x86_64) */
if((buf=mem_chunk(0xF0000, 0x10000, opt.devmem))==NULL)
{
ret=1;
goto exit_free;
}
for(fp=0; fp<=0xFFF0; fp+=16)
{
if(memcmp(buf+fp, "_SM_", 4)==0 && fp<=0xFFE0)
{
if(smbios_decode(buf+fp, opt.devmem))
found++;
fp+=16;
}
else if(memcmp(buf+fp, "_DMI_", 5)==0)
{
if (legacy_decode(buf+fp, opt.devmem))
found++;
}
}
done:
free(buf);
if(!found && !(opt.flags & FLAG_QUIET))
printf("# No SMBIOS nor DMI entry point found, sorry.\n");
exit_free:
free(opt.type);
return ret;
}
|