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
|
#if 0
/* second.S - LILO second stage boot loader */
Copyright 1992-1998 Werner Almesberger.
Copyright 1999-2001 John Coffman.
All rights reserved.
Licensed under the terms contained in the file 'COPYING' in the
source directory.
#endif
#define RAID_NEW
#define PIXADDRESS
#define MEMORY_CHECK
#define LOCK_BSS
#define VAR_LOAD
#define LILO_ASM
#include "lilo.h"
get common.s /* as86 "include" will bypass the CPP */
#if 0
DESCR0 = DESCR+2
#else
DESCR0 = DESCR
#endif
#ifdef DEBUG
#define DEBUG_NEW 1
#else
/* the following gets changed to 0 for release: */
#if VERSION_MINOR<50
#define DEBUG_NEW 0
#else
#define DEBUG_NEW 1
#ifndef MEMORY_CHECK
#define MEMORY_CHECK
#endif
#endif /* VERSION_MINOR */
#endif /* DEBUG */
#ifdef LCF_M386
#define BEG_FS
#define SEG_FS seg fs
#define END_FS
#define HIGHMEM_MAX 0x38000000
#else
#define BEG_FS db 0x1e,0x2e,0x8e,0x1e,0x02,0x00
/* push ds; \
seg cs; \
mov ds,firstseg */
#define SEG_FS
#define END_FS pop ds
#endif
#define UI_MAGIC 0xff /* take input from keyboard */
#ifdef MENU
STAGE_MENU = STAGE_FLAG_MENU
#else
STAGE_MENU = 0
#endif
#ifdef BITMAP
STAGE_BITMAP = STAGE_FLAG_BMP4
#if 0
#ifndef LCF_NOSERIAL
#define LCF_NOSERIAL
#endif
#endif
#else
STAGE_BITMAP = 0
#endif
#ifdef LCF_NOSERIAL
STAGE_SERIAL = 0
#else
STAGE_SERIAL = STAGE_FLAG_SERIAL
#endif
.text
.globl _main
.org 0
_main: jmp start
#ifndef LCF_M386
firstseg: dw 0
#endif
.org 6
! Boot device parameters. They are set by the installer.
sig: .ascii "LILO"
stage: .word STAGE_SECOND|STAGE_SERIAL|STAGE_MENU|STAGE_BITMAP
version:.word VERSION
;;; .org CODE_START_2
start: cld ! only CLD in the code; there is no STD
#ifdef LCF_M386
push ds
pop fs ! address parameters from here
#else
seg cs
mov firstseg,ds ! save DS here
#endif
#ifndef LCF_NOSERIAL
;;; seg ss
mov dx,par1_port+SSDIFF ! use a COM port ?
! watch out, loads par1_ser_param
dec dl
js nocom ! no -> go on
xor ax,ax ! initialize the serial port
xchg al,dh
push ax
push dx
;;; or al,#0x06 ! stop bits = 2, nbits = 7 or 8
! this OR is not needed yet (21.7)
int 0x14 ! Communications Port INIT
push #0x40
pop ds
pop bx ! was DX
shl bx,#1
mov dx,(bx) ! get the port address from the BIOS
seg cs ! keep it
mov slbase,dx
pop bx ! special baud rate test -- was AX
test bl,#0x04 ! stop bits == 2?
cli ! do not disturb any code below
jz stdbps ! standard BPS
shr bx,#5 ! index divisor array
seg cs
mov bl,divisor(bx)
spcbps: ! CLI: do not disturb ...
push dx ! save base address
add dx,#3 ! enable divisor latch access
in al,dx
or al,#0x80
out dx,al
pop dx ! set new divisor
push dx
xchg ax,bx
out dx,al
inc dx
mov al,ah
out dx,al
inc dx ! disable divisor latch access
inc dx
xchg ax,bx
and al,#0x7f
out dx,al
pop dx ! restore base address
stdbps: ! CLI: redundant if fell in from above
push dx
add dx,#4 ! address Modem Control Reg.
#if 0
in al,dx
or al,#3 ! turn on DTR and RTS
#else
mov al,#3 ! turn on DTR and RTS
#endif
out dx,al
pop dx
sti ! done
mov cx,#32 ! drain the queue (if any)
drain: in al,dx
loop drain
add dx,#5 ! clear the status register
in al,dx
! send "\r\nLI" to the serial port
mov si,#serLI
mov cx,#4
ser1: seg cs
lodsb
call serdisp
loop ser1
jmp comcom ! proceed with the rest of "LILO"
serLI: .byte 13,10,0x4c,0x49 ! cr,lf,"LI"
BAUD_BASE = 115200 ! divisor == 1
divisor:
.byte BAUD_BASE / 19200 ! must be same as bsect.c table
.byte BAUD_BASE / 38400
.byte BAUD_BASE / 57600
.byte BAUD_BASE / 115200
.byte BAUD_BASE / 2400
.byte BAUD_BASE / 2400
.byte BAUD_BASE / 2400
.byte BAUD_BASE / 2400
#endif /* LCF_NOSERIAL */
nocom:
#ifndef LCF_NODRAIN
mov cx,#32 ! drain type-ahead buffer ?
drkbd: mov ah,#1 ! is a key pressed ?
int 0x16
jz comcom ! no -> done
xor ah,ah ! get the key
int 0x16
loop drkbd
#endif
comcom:
mov al,#0x4c ! display an 'L'
call display
push #0 ! get pointer to disk parameter table in DS:SI
pop ds
lds si,[0x78] ! 0x78 = 4*0x1E
#ifndef LCF_XL_SECS
cmp byte ptr (si+4),#9 ! okay ?
ja dskok ! yes -> do not patch
#endif
push cs ! get pointer to new area in ES:DI
pop es
mov di,#dskprm
mov cx,#6 ! copy 12 bytes
rep
movsw
seg es ! patch number of sectors
#ifndef LCF_XL_SECS
mov byte ptr (di-8),#18
#else
mov byte ptr (di-8),#LCF_XL_SECS
#endif
push #0
pop ds
cli ! paranoia
mov [0x78],#dskprm
mov [0x7a],es
sti
dskok:
#ifndef LCF_NOSERIAL
seg cs ! clear the break flag
mov byte ptr break,#0
#endif
call instto ! get timer interrupt
;;; jmp restrt ! get going
! Restart here after a boot error
restrt: mov bx,cs ! adjust segment registers
mov ds,bx
mov es,bx
#ifdef VAR_LOAD
sub bx,#MAX_SETUPSECS*0x20+0x20 ! segment for setup code &
! bootsect
mov cx,#INITSEG
cmp bx,cx
jbe restrt1
mov bx,cx ! BX is the smaller segment #
restrt1:
mov [initseg],bx ! set up INITSEG (was 0x9000)
lea cx,(bx+0x20)
mov [setupseg],cx ! set up SETUPSEG (was 0x9020)
mov cx,cs
sub cx,bx ! subtract [initseg]
shl cx,#4 ! get stack size
mov ss,bx ! must lock with move to SP below
#else
mov cx,bx
shl cx,#4
mov ax,#STACKSEG
mov ss,ax
#endif
mov sp,cx ! data on the stack)
#ifndef LCF_M386
cmp word [sig],#EX_MAG_L ! check that this is really loaded at the
! right place ... "LI"
jne crshbrn2
cmp word [sig+2],#EX_MAG_H ! "LO"
jne crshbrn
cmp word [mcmdbeg+6],#0x414d ! "MA"
jne crshbrn
cmp word [mcmdbeg+8],#0x4547 ! "GE"
#else
cmp dword [sig],#EX_MAG_HL ! "LILO"
jne crshbrn
cmp dword [mcmdbeg+6],#0x4547414d ; "MAGE" from BOOT_IMAGE
#endif
jne crshbrn
cmp BYTE stage,#STAGE_SECOND
jne crshbrn
cmp WORD version,#VERSION
crshbrn2: jne crshbrn
mov cmdbeg,#acmdbeg ! probably unattended boot
ldsc:
mov bx,#DESCR
#ifdef RAID_NEW
call raid_search
#endif
#if 0
BEG_FS
SEG_FS
mov cx,par1_descr+SSDIFF
SEG_FS
mov dx,par1_descr+2+SSDIFF
SEG_FS
mov al,par1_descr+4+SSDIFF
END_FS
call cread
jc fdnok1 ! error -> retry
mov bx,#DESCR+SECTOR_SIZE
BEG_FS
SEG_FS
mov cx,par1_descr+sa_size+SSDIFF
SEG_FS
mov dx,par1_descr+sa_size+2+SSDIFF
SEG_FS
mov al,par1_descr+sa_size+4+SSDIFF
END_FS
call cread
jc fdnok1 ! error -> retry
#else
mov si,#par1_descr+SSDIFF ! load the entire descriptor table
descr_more:
BEG_FS
SEG_FS
lodsw
xchg cx,ax
SEG_FS
lodsw
xchg dx,ax
SEG_FS
lodsb
END_FS
call cread
jc fdnok1 ! error -> retry
add bh,#2 ! increment address
cmp si,#par1_descr+sa_size*MAX_DESCR_SECS_asm+SSDIFF
jb descr_more
#endif
mov si,#DESCR ! compute a checksum of the descriptor table
mov di,#SECTOR_SIZE*MAX_DESCR_SECS-4
#ifdef LCF_M386
push dword #CRC_POLY1
#else
push #CRC_POLY1>>16
push #CRC_POLY1&0xFFFF
#endif
call crc32
add di,si
#ifdef LCF_M386
cmp eax,dword (di)
#else
cmp ax,word (di)
jne chkerr
cmp dx,word (di+2)
#endif
jz nochkerr
! Checksum error
chkerr:
mov bx,#msg_chkerr
jmp zz ! go wait
! Die
crshbrn:
mov bx,#msg_sigerr ! signature not found
zz: call say
zzz: hlt ! wait for interrupt
jmp zzz ! sit here forever
nochkerr:
#ifdef DEBUG
pusha
mov bx,#nochker_msg
call say
popa
jmp nochkerr1
nochker_msg:
.ascii "Descriptor checksum okay\n"
.byte 0
nochkerr1:
#endif
#if defined(MENU) || defined(BITMAP)
xor bx,bx ! defaults are all zero
mov [dimage],bx ! set default image to boot
mov [abs_cx],bx ! upper left of scroll area
! means screen is not cleared
#endif
call kt_read ! load the KEYTABLE
fdnok1: jc fdnok2
mov al,[KEYTABLE+256+mt_flag]
BEG_FS
SEG_FS ! get possible FLAG_NOBD
or byte ptr par1_prompt+SSDIFF,al
END_FS
#ifdef MENU
inc bh ; bx -> KEYTABLE+256
#ifdef LCF_M386
cmp dword (bx),#0x554e454d ; "MENU"
jne noschema
mov edx,(bx+4)
mov [mn_attrib],edx
#else
cmp (bx),#0x454d
jne noschema
cmp (bx+2),#0x554e
jne noschema
mov dx,(bx+4)
mov [mn_attrib],dx
mov cx,(bx+6)
mov [mn_attrib+2],dx
#endif
noschema:
add bx,#9 ; point at possible title
mov al,(bx-1) ; get length stored by installer
or al,al
jz notitle ; no title if supplied length is 0
cbw
xchg ax,cx ; supplied length to CX
call strlen
cmp ax,cx
jne notitle
cmp ax,#str_title_len
jae notitle
push di
mov di,#str_title ;
titlemov:
mov al,(bx)
inc bx
seg ds
stosb
or al,al
jnz titlemov
pop di
notitle:
#endif
mov bx,#DFLCMD
BEG_FS
SEG_FS
mov cx,par1_dflcmd+SSDIFF ;DFCMD_OFF
SEG_FS
mov dx,par1_dflcmd+2+SSDIFF
SEG_FS
mov al,par1_dflcmd+4+SSDIFF
END_FS
call cread
fdnok2: jc fdnok ! error -> retry
mov bx,#DFLCMD
cmp word ptr (bx),#DC_MAGIC ! okay ?
jne bdcmag ! no -> do not write
#ifndef LCF_READONLY
mov word ptr (bx),#DC_MGOFF ! erase the magic number
call cmd_write ! write out the command line
#endif
jmp dokay ! continue
bdcmag: mov byte ptr (bx+2),#0 ! disable the command line
jmp dokay ! go on
fdnok:
#if 0
xor ax,ax ! reset FDC
mov dl,al
int 0x13
#endif
br ldsc ! retry
! List all known boot images
list: mov byte ptr (bx),#0 ! set EOL marker
call crlf
#ifdef MENU
inc word [suppress] ! suppress console output
#endif
mov si,#DESCR0 ! list all images
mov cx,#IMAGES
xor dl,dl ! DL counts the images
lloop: testb (si),#0xff ! done ?
jz ldone ! yes
mov bx,si ! display the name
call say
add si,#MAX_IMAGE_NAME
inc dl ! count the image
test dl,#3 ! inside line -> go on
jnz fill
call crlf
jmp imgdne ! next image
fill: push bx ! fill with spaces
mov al,#0x20
call display
pop bx
inc bx
cmp bx,si
jbe fill
imgdne: add si,#id_size-MAX_IMAGE_NAME
loop lloop ! next image
ldone: test dl,#3 ! already at BOL ?
jz atbol ! yes -> no CRLF
call crlf
atbol:
#ifdef MENU
dec word [suppress]
#endif
br iloop ! done
! Ready to process user input
dokay: mov bx,#ospc ! display 'O '
call say
#ifdef HIGHMEM_MAX
xor eax,eax
mov dword ptr hma,eax
#else
xor ax,ax ! get the delay and disable further delays
#endif
mov ospc,al ! disable the message
mov word ptr vgaovr,#VGA_NOCOVR ! disable VGA override
mov word ptr memlim,ax ! no memory limit
BEG_FS
SEG_FS
xchg ax,par1_delay+SSDIFF ;DSC_OFF-8+SSDIFF
END_FS
or old_del,ax ! remember delay
mov nodfl,#iloop ! interactive prompt if falling through
BEG_FS
SEG_FS ! enter boot prompt ?
test byte ptr par1_prompt+SSDIFF,#FLAG_PROMPT ;DSC_OFF+15+SSDIFF,#0
END_FS
jnz extp ! yes -> check for external parameters
mov nodfl,#bfirst ! boot first image if falling through
call waitsh ! wait for a shifting key
jc iloop ! key pressed -> enter interactive mode
! Check for external parameters
extp: BEG_FS
SEG_FS ! external parameters ?
cmp byte ptr EX_OFF+6,#EX_DL_MAG
END_FS
jne noex ! no -> go on
BEG_FS
SEG_FS ! clear flag
mov byte ptr EX_OFF+6,#0
SEG_FS ! load the signature pointer
les bx,EX_OFF
END_FS
#ifndef LCF_M386
seg es ! "LI" ?
cmp word ptr (bx),#EX_MAG_L
jne noex ! no -> go on
seg es ! "LO" ?
cmp word ptr (bx+2),#EX_MAG_H
#else
seg es
cmp dword ptr (bx),#EX_MAG_HL ! "LILO"
#endif
jne noex ! no -> go on
BEG_FS
SEG_FS
mov si,EX_OFF+4 ! pointer to the command line
END_FS
seg es
cmp byte ptr (si),#0 ! empty ?
je iloop ! yes -> enter interactive mode
jmp niloop ! enter non-interactive mode
! No external parameters after timeout -> boot first image
noex: push cs ! restore ES
pop es
mov si,#DFLCMD+2 ! default command line ?
cmp byte ptr (si),#0
jne niloop ! yes -> use it
mov ax,nodfl ! no idea how to tell as86 to do jmp (addr) :-(
jmp ax ! fall through
! Command input processor
iloop:
#if defined(MENU) || defined(BITMAP)
call menu_setup
#endif
#ifndef BITMAP
BEG_FS
SEG_FS ! message disabled ?
cmp word ptr par1_msg_len+SSDIFF,#0 ;MSG_OFF+SSDIFF,#0
END_FS
je nomsg ! yes -> skip this
call crlf
BEG_FS
SEG_FS ! load the message file
mov cx,par1_msg+SSDIFF ;MSG_OFF+SSDIFF+2
SEG_FS
mov dx,par1_msg+2+SSDIFF
SEG_FS
mov al,par1_msg+4+SSDIFF
END_FS
mov bx,#MAP
call sread
call loadfile
push #SYSSEG
pop ds
xor bx,bx ! set the terminating NUL and disable further
! messages
BEG_FS
SEG_FS
xchg bx,par1_msg_len+SSDIFF ;MSG_OFF+SSDIFF
END_FS
mov byte ptr (bx),#0
xor bx,bx ! display the message
call say
push cs ! restore segment registers
pop ds
push cs
pop es
#endif
nomsg: mov cmdbeg,#acmdbeg ! probably unattended boot
mov si,#usrinpm ! interactive mode
niloop: ! ES may point to external params
mov bx,#msg_p ! display boot prompt
call say
mov bx,#cmdline ! move cursor to the end of the line
clend: mov al,(bx)
or al,al ! at end ?
jz cledne ! yes -> go on
push bx ! display the character
call display
pop bx
inc bx ! next one
jne clend
cledne: mov byte ptr prechr,#32 ! character before command line is a space
! Input loop
input: seg es ! interactive mode ?
cmp byte ptr (si),#UI_MAGIC
je kbinp ! yes -> get keyboard input
seg es ! get non-interactive input
mov al,(si)
inc si
jmp gotinp ! go on
tolist:
#ifdef BITMAP
call menu_exit
#endif
br list ! ...
kbinp: mov cx,#brto ! get a key
call getkey
#ifdef BITMAP
cmp byte [abs_cx+1],#0
je noNull ! skip cursor keys after Tab
#endif
#if defined(MENU) || defined(BITMAP)
cmp al,#0xE0 ! extended keyboard
je toNull
or al,al !
#ifdef LCF_M386
toNull: je near null ! cursor control
#else
jne gotinp
toNull: br null ! null: in crt.S or bitmap.S
#endif
#endif
#ifndef MENU
noNull: or al,al ! keyboard NUL input?
je input ! yes, skip Keyboard NUL
; stored command line NUL is handled differently
#endif
gotinp: cmp al,#9 ! TAB ?
je tolist ! yes -> list images
cmp al,#63 ! "?" ?
je tolist ! yes -> list images
or al,al ! NUL ?
je nul ! yes -> go on
cmp al,#8 ! BS ?
je todelch ! yes -> erase one character
cmp al,#13 ! CR ?
je cr ! yes -> go on
cmp al,#127 ! DEL ?
je todelch ! yes -> erase one character
ja input ! non-printable -> ignore it
cmp al,#21 ! ^U ?
je todell ! yes -> erase the line
cmp al,#24 ! ^X ?
je todell ! yes -> erase the line
cmp al,#32 ! ignore non-printable characters except space
jb input
ja noblnk ! no space -> go on
cmp (bx-1),al ! second space in a row ?
je input ! yes -> ignore it
noblnk: cmp bx,#cmdline+CL_LENGTH ! at end of buffer ?
je input ! yes -> ignore
xor ah,ah ! cmdline is always NUL terminated
mov (bx),ax ! store in the buffer
inc bx ! increment pointer
push bx
call display ! echo
#if defined(MENU) || defined(BITMAP)
push ax
call find_image ! we want the side effect of the hilite
pop ax
#endif
pop bx
cmp bx,#cmdline+1 ! first character ?
jne input ! no -> next input
#ifdef LCF_IGNORECASE
call upcase ! convert to upper case
#endif
mov cx,#IMAGES ! check if we have a single-key entry
mov di,#DESCR0
mov ah,al
sklp: test word ptr (di+id_flags),#FLAG_SINGLE ! single-key entry ?
jz sknext ! no -> try next
mov al,(di) ! get first character
#ifdef LCF_IGNORECASE
call upcase ! convert to upper case
#endif
cmp al,ah ! do we have a match ?
jne sknext ! no -> try next
cmp byte ptr (di+1),#0 ! at end ?
je cr ! yes -> run it
sknext: add di,#id_size ! test next entry
loop sklp ! next one
br input ! done -> get more input
todelch:br delch ! ...
todell: br delline ! ...
! End of input, process the command line
nul: push bx ! automatic boot - wait for timeout
mov ax,old_del
call waitsh
pop bx
jnc crnul ! no key pressed -> continue
mov bx,#msg_int ! interrupted -> display a message
call say
br iloop ! return to interactive prompt
cr:
#ifdef LCF_HP_TTRC
push ax ! HP TTRC boot fail workaround.
mov ax, #3 ! 2000/10 <yumoto@jpn.hp.com>
call setto ! reload timer
short_wait:
test byte ptr timeout,#1 ! timed out ?
jz short_wait ! No, remain loop..
pop ax
#endif
mov cmdbeg,#mcmdbeg ! probably manual boot
crnul:
#ifndef LCF_NOSERIAL
mov byte ptr break,#0 ! clear the break flag
#endif
push cs ! set ES to CS
pop es
xor al,al ! mark end
mov (bx),al
mov si,#cmdline ! copy command line to save buffer
mov di,#lkcbuf
mov byte ptr dolock,#0 ! disable locking
cpsav: lodsb ! copy one byte
stosb
or al,al ! at end ?
jnz cpsav ! no -> go on
cmp bx,#cmdline ! empty line ?
je notrspc ! yes -> boot first image
cmp byte ptr (bx-1),#32 ! trailing space ?
jne notrspc ! no -> go on
dec bx ! remove the space
mov byte ptr (bx),al
notrspc:mov si,#cmdline ! scan the command line for "vga=", "kbd=",
mov di,si ! "lock" or "mem="
chkvga:
#ifdef LCF_BDATA
vsktnbd:
#ifndef LCF_M386
cmp word ptr (si),#0x6f6e ! "nobd"
jne vsktv
cmp word ptr (si+2),#0x6462
#else
cmp dword ptr (si),#0x64626f6e ! "nobd"
#endif
jne vsktv
cmp byte (si+4),#32 ! terminated with SP or NUL?
jnbe vsktv
BEG_FS
SEG_FS ! enter boot prompt ?
or byte ptr par1_prompt+SSDIFF,#FLAG_NOBD ; suppress BIOS data collection
END_FS
jmp vskwd ; skip word
#endif
vsktv:
#ifndef LCF_M386
cmp word ptr (si),#0x6776 ! "vga=" ?
jne vsktk ! no -> try "kbd="
cmp word ptr (si+2),#0x3d61
#else
cmp dword ptr (si),#0x3d616776 ! "vga="
#endif
jne vsktk
call setvga ! set VGA mode
jc toiloop ! error -> get next command
jmp vskdb ! proceed by discarding last blank
vsktk:
#ifndef LCF_M386
cmp word ptr (si),#0x626b ! "kbd=" ?
jne vsktl ! no -> try "lock"
cmp word ptr (si+2),#0x3d64
#else
cmp dword ptr (si),#0x3d64626b ! "kbd="
#endif
jne vsktl
call putkbd ! pre-load keyboard buffer
jmp vskdb ! proceed by discarding last blank
vsktl:
#ifndef LCF_M386
cmp word ptr (si),#0x6f6c ! "lock" ?
jne vsktm ! no -> skip to next blank
cmp word ptr (si+2),#0x6b63
#else
cmp dword ptr (si),#0x6b636f6c ! "lock"
#endif
jne vsktm
cmp byte (si+4),#32 ! space?
jnbe vsktm
mov byte ptr dolock,#1 ! enable locking
vskwd: add si,#4 ! skip word
vskdb: dec di ! discard last blank
jmp vsknb ! continue
vsktm:
#ifndef LCF_M386
cmp word ptr (si),#0x656d ! "mem=" ?
jne vsknb ! no -> skip to next blank
cmp word ptr (si+2),#0x3d6d
#else
cmp dword ptr (si),#0x3d6d656d ! "mem="
#endif
jne vsknb
call getmem ! get the user-provided memory limit
vsknb: lodsb ! copy one byte
stosb
cmp al,#32 ! space ?
je chkvga ! yes -> look for options again
or al,al ! at end ?
jnz vsknb ! no -> go on
call crlf ! write CR/LF
cmp di,#cmdline+1 ! empty line ?
emptyl: je bfirst ! yes -> boot first image
jmp bcmd ! boot the specified image
toiloop:br iloop ! ...
toinput:br input ! ...
! Find the boot image and start it
bcmd:
#if !defined(MENU) && !defined(BITMAP)
mov cx,#IMAGES ! test all names
mov bx,#DESCR0
nextn: mov si,bx ! compare the names
mov di,#cmdline
nextc: mov al,(si) ! get next character
or al,al ! NUL ?
jz dscend ! yes -> possible match
! get the character
#ifdef LCF_IGNORECASE
call upcase
#endif
mov ah,al
mov al,(di)
#ifdef LCF_IGNORECASE
call upcase
#endif
cmp al,ah ! character equal ?
jne skipn ! no -> try next one
inc si ! test next character
inc di
jmp nextc
dscend: cmp byte ptr (di),#32 ! space or NUL -> boot
je boot
cmp byte ptr (di),#0
je boot
skipn: add bx,#id_size ! test next name
loop nextn
#else
call find_image
jc boot ! eureka, it was found
#endif
mov bx,#msg_nf ! not found -> display a message
call say
br iloop ! get more input
! Delete one character
delch: cmp bx,#cmdline ! at the beginning ?
je toinput ! yes -> do nothing
dec bx ! move the pointer
push bx ! display[B BS,SPC,BS
mov bx,#bs
call say
#if defined(MENU) || defined(BITMAP)
pop bx
push bx
mov byte (bx),#0 ! NUL terminate the line
mov ax,#cmdline
sub ax,bx
jz delch6
delch4: call find_image
jnc delch9
delch6: mov bx,[dimage]
cmp ax,bx
je delch9
xchg ax,bx
call lowlite
xchg ax,bx
call hilite
delch9:
#endif
pop bx
jmp toinput ! go on
! Delete the entire line
delline:
#if !defined(MENU) && !defined(BITMAP)
cmp bx,#cmdline ! done ?
je toinput ! yes -> go on
push bx ! display BS,SPC,BS
mov bx,#bs
call say
pop bx
dec bx ! move the pointer
jmp delline ! next one
#else
call menu_delline
push bx ! delch will do a pop
xor ax,ax
jmp delch6
#endif
! Boot first after timeout
brto: call crlf ! display a CRLF
jmp brfrst ! boot
! Boot the first image
bfirst: mov byte ptr lkcbuf,#0 ! clear default
cmp byte ptr cmdline,#0 ! is there a default ?
jne bcmd ! yes -> boot that image
brfrst:
#if defined(MENU) || defined(BITMAP)
mov bx,[dimage]
imul bx,#id_size
add bx,#DESCR0 ! boot the selected image
#else
mov bx,#DESCR0 ! boot the first image
#endif
mov si,bx ! copy the name to the command line
mov di,#cmdline
bfcpl: lodsb ! copy one character
mov (di),al
inc di
or al,al ! NUL ?
jnz bfcpl ! no -> next one
! Boot the image BX points to (with password check)
boot: mov si,#cmdline ! locate start of options
locopt: lodsb
or al,al ! NUL ?
je optfnd ! yes -> no options
cmp al,#32 ! space ?
jne locopt ! no -> continue searching
cmp (si),#0 ! followed by NUL ?
jne optfnd ! no -> go on
mov byte ptr (si-1),#0 ! discard trailing space
optfnd: dec si ! adjust pointer
mov options,si ! store pointer for later use
#ifdef BITMAP
call menu_exit
#endif
test byte ptr (bx+id_flags),#FLAG_PASSWORD ! use a password
jz toboot ! no -> boot
test byte ptr (bx+id_flags),#FLAG_RESTR ! restricted ?
jz dopw ! no -> get the password
cmp byte ptr (si),#0! are there any options ?
jne dopw ! yes -> password required
toboot: br doboot ! ...
dopw:
#if defined(CRC_PASSWORDS) || defined(SHS_PASSWORDS)
push bx ; save the image descriptor
BEG_FS
SEG_FS
mov word ptr par1_timeout+SSDIFF,#0xffff ; cancel timeout
END_FS
mov bx,#msg_pw ! display a prompt
call say
push bp ; save BP
mov bp,sp ; save SP in BP
sub sp,#CL_LENGTH ; allocate space for PW string
mov si,sp ; si points at string
xor di,di ; di counts characters
pwloop:
#ifdef DEBUG
pusha
mov ax,si
call wout
mov al,#32
call display
mov ax,di
call wout
call crlf
popa
#endif
mov cx,#pwtime ; get timeout exit
call getkey
cmp al,#13 ! CR ?
je pwcr ! yes -> handle it
cmp al,#21 ! ^U ?
je pwdell ! yes -> erase line
cmp al,#24 ! ^X
je pwdell
cmp al,#8 ! BS ?
je pwdelch ! yes -> erase one character
cmp al,#127 ! DEL
je pwdelch
ja pwloop ! ignore other non-printable characters
cmp al,#32
jb pwloop
cmp di,#CL_LENGTH ; check for buffer overflow
jae pwloop ; ingnore further input
seg ss
mov (si),al ; store char in buffer
inc si
inc di
mov al,#42 ; echo '*'
call display
jmp pwloop ; loop back for more
pwdelch: or di,di
jz pwloop
call pwbs
dec si
dec di
jmp pwloop
pwdell: inc di
pwdel: dec di
jz pwloop
call pwbs
dec si
jmp pwdel
pwbs: mov bx,#bs
call say
ret
pwcr:
xor cx,cx ; signal okay
pwtime: ; CX != 0 if enter here
inc cx
call crlf
sub si,di ; point SI at start of buffer
push es ; save ES
#if !defined(SHS_PASSWORDS)
mov bx,(bp+2) ; restore image descriptor pointer
push ss
pop es ; ES:SI points at char string
#if MAX_PW_CRC>=1
#ifdef LCF_M386
push dword #CRC_POLY1
#else
push #CRC_POLY1>>16
push #CRC_POLY1&0xFFFF
#endif
call crc32
#ifdef DEBUG
pusha
push ax
mov ax,di
call wout
mov al,#32
call display
pop ax
#ifdef LCF_M386
push eax
#else
push dx
push ax
#endif
call dout
call crlf
popa
#endif
#ifdef LCF_M386
cmp eax,(bx+id_password_crc)
#else
cmp ax,(bx+id_password_crc)
jne pwcleanup
cmp dx,(bx+id_password_crc+2)
#endif
jne pwcleanup
#endif
; insert other checks in here
#if MAX_PW_CRC>=2
#ifdef LCF_M386
push dword #CRC_POLY2
#else
push #CRC_POLY2>>16
push #CRC_POLY2&0xFFFF
#endif
call crc32
#ifdef LCF_M386
cmp eax,(bx+id_password_crc+4)
#else
cmp ax,(bx+id_password_crc+4)
jne pwcleanup
cmp dx,(bx+id_password_crc+4+2)
#endif
jne pwcleanup
#endif
#if MAX_PW_CRC>=3
#ifdef LCF_M386
push dword #CRC_POLY3
#else
push #CRC_POLY3>>16
push #CRC_POLY3&0xFFFF
#endif
call crc32
#ifdef LCF_M386
cmp eax,(bx+id_password_crc+8)
#else
cmp ax,(bx+id_password_crc+8)
jne pwcleanup
cmp dx,(bx+id_password_crc+8+2)
#endif
jne pwcleanup
#endif
#if MAX_PW_CRC>=4
#ifdef LCF_M386
push dword #CRC_POLY4
#else
push #CRC_POLY4>>16
push #CRC_POLY4&0xFFFF
#endif
call crc32
#ifdef LCF_M386
cmp eax,(bx+id_password_crc+12)
#else
cmp ax,(bx+id_password_crc+12)
jne pwcleanup
cmp dx,(bx+id_password_crc+12+2)
#endif
jne pwcleanup
#endif
#if MAX_PW_CRC>=5
#ifdef LCF_M386
push dword #CRC_POLY5
#else
push #CRC_POLY5>>16
push #CRC_POLY5&0xFFFF
#endif
call crc32
#ifdef LCF_M386
cmp eax,(bx+id_password_crc+16)
#else
cmp ax,(bx+id_password_crc+16)
jne pwcleanup
cmp dx,(bx+id_password_crc+16+2)
#endif
jne pwcleanup
#endif
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dec cx ; signal all okay
#else /* SHS_PASSWORDS */
; DI is the count
; SS:SI is the password string
push di
push si
call _shsInit
call _shsUpdate
call _shsFinal
mov bx,(bp+2) ; restore image descriptor pointer
lea di,(bx+id_password_crc)
mov si,#shs_digest
mov cx,#MAX_PW_CRC*4
; ES==DS
repe
cmpsb
pop si ; restore buffer ptr
pop di ; clear stack
push ss
pop es ; ES=SS
je pwcleanup ; CX will be 0
inc cx ; CX is > 0
#endif /* !defined(SHS_PASSWORDS) */
pwcleanup:
push cx
mov cx,#CL_LENGTH
mov di,si
xor ax,ax
rep ; wipe out password in memory
stosb
pop cx
pop es ; restore the saved ES
mov sp,bp
pop bp
pop bx
or cx,cx ; test CX==0 means all okay
jz doboot
; fall into pwfail
#else
push bx ! save the image descriptor
lea si,(bx+MAX_IMAGE_NAME+1) ! get a pointer to the password string
mov bx,#msg_pw ! display a prompt
call say
pwagain:xor cl,cl ! CL counts characters after a mismatch
pwloop: push cx ! get a key
mov cx,#pwtime
call getkey
pop cx
cmp al,#13 ! CR ?
je pwcr ! yes -> handle it
cmp al,#21 ! ^U ?
je pwdell ! yes -> erase line
cmp al,#24 ! ^X
je pwdell
cmp al,#8 ! BS ?
je pwdelch ! yes -> erase one character
cmp al,#127 ! DEL
je pwdelch
ja pwloop ! ignore other non-printable characters
cmp al,#32
jb pwloop
or cl,cl ! counting bad input ?
jnz pwbad ! yes -> do it
cmp al,(si) ! correct input ?
je pwgood ! yes -> go on
pwbad: inc cl ! count error
jnz pwgood ! no overflow -> go on
dec cl ! adjust it
jmp pwcr ! terminate input
pwgood: inc si ! good character -> go on
jmp pwloop
pwdell: pop si ! reset the pointer
push si
add si,#MAX_IMAGE_NAME+1
jmp pwagain ! get password again
pwdelch:pop bx ! at the beginning of the line ?
push bx
add bx,#MAX_IMAGE_NAME+1
cmp si,bx
je pwloop ! yes -> ignore it
dec si ! remove one character
sub cl,#1
jnc pwloop ! no underflow -> go on
inc cl ! adjust it
jmp pwloop ! next character
pwtime: pop cx ! drop CX ...
mov cl,#1 ! ... and fail
pwcr: call crlf
pop bx ! restore the image descriptor
or cl,cl ! no errors ?
jnz pwfail ! no -> fail
cmp byte ptr (si),#0 ! at end ?
je doboot ! yes -> continue booting
#endif /* CRC_PASSWORDS */
pwfail: mov bx,#msg_pf ! display an error message
call say
br iloop ! get next input
! Boot the image BX points to
doboot: mov byte ptr prechr,#61 ! switch to equal sign
push bx ! save image descr
mov bx,#msg_l ! say hi
call say
pop bx ! display the image name
push bx
call say
pop si
add si,#id_rd_size ! point at ramdisk size long
! take care of the RAM disk first
#ifdef LCF_M386
xor eax,eax
mov (rdbeg),eax ! clear address
lodsd
mov (rdszl),eax ! set rdszl+rdszh
add eax,#4095 ! round up &
shr eax,#12 ! convert to pages
xchg bx,ax ! copy to BX
#else
xor ax,ax
mov word ptr (rdbeg),ax ! clear address
mov word ptr (rdbeg+2),ax
lodsw ! number of bytes to load (low word)
mov dx,ax
mov (rdszl),ax
lodsw ! high word
mov (rdszh),ax
xchg ax,dx ! convert to pages
add ax,#4095
adc dx,#0
mov bx,#4096
div bx
mov bx,ax
#endif
lodsw ! address of the first map sector
xchg cx,ax
lodsw
xchg dx,ax
lodsb
or bx,bx ! no RAM disk ?
jz noramd ! yes -> skip it
push si ! save SI, ES, and BX (RD size)
push es
push bx
mov bx,#MAP ! load the first map sector
call sread
mov moff,#0
#ifdef DEBUG
mov bx,#stepa
call say
#endif
#ifdef HIGHMEM_MAX
pop bx
call rd_setup
#else
mov ah,#0x88 ! okay, compute load address now
int 0x15 ! get amount of memory ...
cmp word ptr memlim,#0 ! limit set by user ?
je noulim ! no -> continue
mov ax,memlim ! use user limit (minus 1M already)
noulim: cmp ax,#14*1024 ! more than 15 MB ?
jbe no16mb ! no -> go ahead
#if 1
cmp ax,#63*1024 ! more than 64Mb ?
ja no16mb
#endif
mov ax,#14*1024 ! avoid the memory hole at 15M-16M
! (kernel can still use "high" memory)
no16mb: shr ax,2 ! round to pages
pop bx ! subtract RAM disk size
sub ax,bx
jnc rdokay ! panic if not enough space
;;; cmp ax,#128 ! we probably need more than 512 kB for the
cmp ax,#256 ! we probably need more than 1M for the
ja rdokay ! kernel to be useful ...
mov bx,#msg_rd ! complain
call say
br restrt ! ... and restart if we can
rdokay:
#if 1
add ax,#256 ! start is at first MB ...
mov bx,ax ! copy to BX
shl ax,#4 ! *16
shr bx,#12 ! hi 4 bits
mov (rdbeg+1),ax ! ... and remember that for patching setup
mov (gdt+0x1b),ax ! set up GDT
mov (rdbeg+3),bl ! store hi part of address
mov (gdt+0x1f),bl ! store hi part of address
#else
and eax,#0xFFFF ; clear hi part of eax
add eax,#256 ; start is at first MB, add 256 pages
shl eax,#4 ; convert to address / 256
mov (rdbeg+1),ax ; save address
mov (gdt+0x1b),ax
shr eax,#16 ; get hi part of EAX
mov (rdbeg+3),al ; store hi part of address
mov (gdt+0x1f),al ; store hi byte
#endif
#endif
push #0 ! ES=0 is our secret code to load via GDT
pop es
mov bx,#gdt
call lfile ! load it
pop es ! restore ES and SI
pop si
noramd:
; Now load the kernel sectors
lodsw ! address of the first map sector
xchg cx,ax
lodsw
xchg dx,ax
lodsb
push ax
mov word ptr (gdt+0x1b),#0 ! set GDT to "load low"
mov byte ptr (gdt+0x1f),#0
lodsw ! get the start page
or ax,ax ! load low ?
jz nohigh ! yup -> do it
shl ax,4 ! *16
mov (gdt+0x1b),ax ! set up GDT
;; mov byte ptr (gdt+0x1a),#0
nohigh:
pop ax ;
push si ! save SI
#ifdef DEBUG
push ax ;
mov bx,#step0
call say
pop ax ;
#endif
mov bx,#MAP ! load the first map sector
call sread
mov moff,#0 ! reset the pointer
#ifdef DEBUG
mov bx,#step0b
call say
#endif
mov bx,#DFLCMD ! load the default command line
BEG_FS
SEG_FS
mov cx,par1_dflcmd+SSDIFF
SEG_FS
mov dx,par1_dflcmd+2+SSDIFF
SEG_FS
mov al,par1_dflcmd+4+SSDIFF
END_FS
call cread
push word ptr (DFLCMD) ! push magic number
mov bx,#DFLCMD ! load the fallback sector
call load1
pop ax ! valid magic number ?
#ifndef LCF_READONLY
cmp ax,#DC_MAGIC
je dclok ! yes -> can write
cmp ax,#DC_MGOFF
jne nofbck ! invalid -> must not write
dclok: mov bx,#DFLCMD ! fallback data present ?
cmp word ptr (bx),#DC_MAGIC
jne nofbck ! no -> go on
call cmd_write ! write out the command line
nofbck:
#endif
#ifdef DEBUG
mov bx,#step1
call say
#endif
mov bx,#DFLCMD ! load the options sector
call load1
mov si,cmdbeg ! copy non-options part of command line
mov di,#PARMLINE
cpnocl: cmp si,options ! at beginning of options ?
je cpnodn ! yes -> go on
movsb ! copy one byte
jmp cpnocl ! next one
cpnodn: mov si,#DFLCMD ! constant options ?
cmp byte ptr (si),#0
je nocopt ! no -> go on
mov al,#32 ! add a space
stosb
cpcodsp:lodsb ! fetch next byte
cmp al,#32 ! space ?
je cpcodsp ! yes -> discard it
cpcolp: or al,al ! NUL ?
jz cpcodn ! yes -> done
stosb ! store byte
cmp al,#32 ! a space ?
je cpcodsp ! yes -> discard next
lodsb ! get next byte
jmp cpcolp
cpcodn: seg es
cmp byte ptr (di-1),#32 ! last was space ?
jne nocopt ! no -> go on
dec di ! discard it
nocopt: mov si,options ! append variable options
cpvalp: lodsb ! copy one byte
stosb
or al,al ! NUL ?
jnz cpvalp ! no -> go on
#ifdef DEBUG
mov bx,#step2
call say
#endif
#ifdef VAR_LOAD
mov es,[initseg] ! load the original boot sector
#else
push #INITSEG ! load the original boot sector
pop es
#endif
xor bx,bx ! load now
call load1
pop si ! restore SI
lodsw ! get flags bit map
xchg bx,ax ! move to BX
lodsw ! copy parameters ... VGA mode ... (done)
cmp word ptr vgaovr,#VGA_NOCOVR ! VGA mode not overridden on
! command line ?
je vganorm ! no -> go on
mov ax,vgaovr ! use that value
jmp vgaset
vganorm:test bx,#FLAG_VGA
jz novga
vgaset: seg es
mov 506,ax ! magic offset in the boot sector
novga: push bx ! use flags (BX) later
test bx,#FLAG_LOCK ! ... lock target ?
jnz lockit ! yup -> do it
cmp byte ptr dolock,#0 ! did user ask to lock new target ?
je nolock ! no -> go on
lockit:
#ifndef LCF_READONLY
mov bx,#lkwbuf ! save the command line
#ifdef LOCK_BSS
mov word (bx),#DC_MAGIC ;
#endif
push es
push si
push ds ;
pop es ;
call cmd_write ; write out the command line
pop si
pop es
#endif
nolock:
#ifdef DEBUG
mov bx,#step3
call say
#endif
#if 0
mov cx,#SETUPSECS ! default is to load four sectors
#ifdef LCF_VARSETUP
seg es ! variable number of sectors ?
cmp byte ptr VSS_NUM,#0
je lsetup ! no -> use default
seg es ! use that number
mov cl,VSS_NUM
#endif
#else
xor cx,cx
#ifdef LCF_VARSETUP
seg es
mov cl,VSS_NUM
or cx,cx
jnz lsetup
#endif
mov cl,#SETUPSECS ! default is to load four sectors
#endif
lsetup:
#ifdef VAR_LOAD
mov es,[setupseg] ! load the setup codes
#else
push #SETUPSEG ! load the setup (might meet EOF in the
pop es ! process of loading the boot sector of an
! other operating system)
#endif
#ifdef MEMORY_CHECK
mov ax,cx ! number of sectors to AX
shl ax,5 ! convert to paragraphs (9-4)
mov bx,es
add bx,ax
add bx,#STACK>>4 ! allow for stack space in paragraphs
mov ax,cs !
cmp bx,ax
jbe enough_mem
mov bx,#msg_mem ! we are very short on memory
call say
enough_mem:
#endif
xor bx,bx ! other operating system)
lsloop: push cx
call loadopt
pop cx
loop lsloop
#ifdef DEBUG
mov bx,#step4
call say
#endif
pop bx ! get flags
test bx,#FLAG_MODKRN ! "modern" kernel ?
#if DEBUG_NEW
beq loadlow
#else
jz loadlow ! no -> avoid all patching and such
#endif
seg es ! set loader version
mov byte ptr (16),#LOADER_VERSION
seg es ! version >= 1 ?
cmp word ptr (6),#NEW_HDR_VERSION
jbe noheap ! no -> do not patch heap
mov ax,cs
#ifdef VAR_LOAD
sub ax,[initseg] ! find no. of paragraphs available
#endif
shl ax,4
add ax,#SLA_SIZE_DYN
seg es
mov word ptr (36),ax
seg es ! patch flags
or byte ptr (17),#LFLAG_USE_HEAP
noheap:
#ifdef LCF_M386
cmp dword ptr (rdbeg),#0
#else
cmp byte ptr (rdbeg+3),#0 ! initial RAM disk?
jne setrdp
cmp word ptr (rdbeg+1),#0 ! initial RAM disk ?
#endif
je nordpt ! no -> no need to patch header for that
setrdp:
#if DEBUG_NEW
push dword (rdbeg) ! print RAM disk address
mov bx,#msg_rd2
call say
call dout
call crlf
jmp rd2_over
msg_rd2: .byte 10
.ascii "RAM disk loaded at: "
.byte 0
rd2_over:
#endif
#ifdef LCF_M386
mov eax,(rdbeg) ! get RAM disk start address
seg es
mov (24),eax ! store in header
mov eax,rdszl
seg es
mov (28),eax ! set RAM disk size
#else
mov ax,(rdbeg) ! store RAM disk start address
seg es
mov (24),ax
mov ax,(rdbeg+2)
seg es
mov (26),ax
mov ax,rdszl ! RAM disk size
seg es
mov (28),ax
mov ax,rdszh
seg es
mov (30),ax
#endif
nordpt:
;;; cmp word ptr (gdt+0x1b),#0 ! load low ?
mov al,(gdt+0x1f)
cbw
or ax,(gdt+0x1b) ! load low ?
je loadlow ! yes -> do it
xor ax,ax ! GDT is already set up ...
mov es,ax
mov bx,#gdt
call lfile ! load the system ...
jmp launch ! ... and run it
loadlow:call loadfile ! load the system
jmp launch ! go !
loadfile:
push #SYSSEG ! load a file at SYSSEG:0000
pop es
xor bx,bx
lfile: call load
jmp lfile
! Load one sector. Issue an error at EOF.
load1: call loadit ! load the sector
mov bx,#msg_eof ! we only get here at EOF
call say
br restrt
loadit: call load ! load it
pop ax ! drop return address of load1
ret
! Load one sector. Start the system at EOF.
loadopt:call loadit ! load the sector
jmp launch ! go
! Load one sequence of sectors. Leave outer function at EOF.
load: push es ! save ES:BX
push bx
lfetch: mov si,moff ! get map offset
mov cx,MAP(si) ! get address
mov dx,MAP+2(si)
mov al,MAP+4(si)
or cx,cx ! at EOF ?
jnz noteof ! no -> go on
or dx,dx
jnz noteof
pop bx ! restore ES:BX
pop es
pop ax ! pop return address
ret ! return to outer function
noteof: add si,#sa_size ! increment pointer
mov moff,si
cmp si,#SECTOR_SIZE - sa_size + 1 ! page end ?
#ifndef LCF_M386
bcs doload ! no -> load it
#else
jb near doload
#endif
mov moff,#0 ! reset pointer
push cs ! adjust ES
pop es
mov bl,hinib ; this might get clobbered
push bx ; so save it
mov bx,#MAP ! load map page
call sread
pop ax ; restore the hi-nibble
mov hinib,al ;
mov al,#0x2e ! print a dot
call display
jmp lfetch ! try again
! Start the kernel
launch:
;;; push es ! save ES:BX (why ???)
;;; push bx
#ifdef MENU
call menu_exit ! make the menu area vanish
#endif
call crlf ! display a CRLF
mov dx,#0x3f2 ! stop the floppy motor
xor al,al
outb
xor ax,ax ! reset the FDC
mov dl,al
int 0x13
#ifdef VAR_LOAD
mov es,[initseg] ! adjust segment registers
#else
push #INITSEG ! adjust segment registers
pop es
#endif
mov di,#PARMLINE ! set parameter line offset
mov ax,cs ! find where we are loaded
#ifdef VAR_LOAD
sub ax,[initseg] ! find no. of paragraphs available
#endif
shl ax,4 ! convert para. to bytes
add di,ax
#ifndef LCF_M386
seg es
cmp word ptr CL_HEADER_ID,#0x6448 ! "Hd"
jne mbchain
seg es
cmp word ptr CL_HEADER_ID+2,#0x5372 ! "rS"
#else
seg es
cmp dword ptr CL_HEADER_ID,#0x53726448 ! "HdrS" (reversed)
#endif
je chkver ! go check header version
mbchain:
! it must be the chain loader
#ifdef LCF_BDATA
BEG_FS
SEG_FS ! supptess BIOS data collection
or byte ptr par1_prompt+SSDIFF,#FLAG_NOBD ; suppress BIOS data collection
END_FS
#endif
#if DEBUG_NEW
mov bx,#nohdrs
call say
jmp cl_wait
nohdrs: .ascii "\nNo cmdline passed"
.byte 0
#else
jmp start_setup2
#endif
chkver:
#if DEBUG_NEW
mov bx,#hdr1
call say
seg es
mov ax,CL_HDRS_VERSION
call wout
mov bx,#hdr2
call say
#endif
seg es
cmp word ptr CL_HDRS_VERSION,#NEW_VERSION ! check for
! new cmdline protocol
jb protocol201
! and now the new protocol
mov ax,es ! form long address
#ifndef LCF_M386
xor dx,dx ! in DX:AX
mov cx,#4
chkver11:
shl ax,1
rcl dx,1
loop chkver11
add ax,di ! add in offset
adc dx,#0
seg es
mov CL_POINTER,ax ! set the long, absolute pointer
seg es
mov CL_POINTER+2,dx
#if DEBUG_NEW
push dx
push ax
#endif
#else
movzx edx,ax ! zero extend segment part to EDX
movzx edi,di ! zero extend offset
shl edx,4 ! make segment into address
add edx,edi ! form long absolute address
seg es
mov CL_POINTER,edx ! and pass the address
#if DEBUG_NEW
push edx
#endif
#endif /* LCF_M386 */
#if DEBUG_NEW
call dout
jmp cl_wait
#else
jmp start_setup
#endif
! the old command line passing protocol
protocol201:
seg es
mov CL_MAGIC_ADDR,#CL_MAGIC ! set magic number
seg es
mov word ptr CL_OFFSET,di
#if DEBUG_NEW
mov ax,es
call wout
mov al,#0x3A ! issue colon
call display
mov ax,di
call wout
cl_wait:
call crlf
call crlf
jmp start_setup
hdr1: .ascii "\nHeader 0x"
.byte 0
hdr2: .ascii " cmdline at "
.byte 0
#endif
start_setup: ! kernel boot comes here
#ifdef LCF_BDATA
BEG_FS
SEG_FS ! suppress BIOS data collection?
test byte ptr par1_prompt+SSDIFF,#FLAG_NOBD ; suppress?
END_FS
jnz start_setup2
#ifndef LCF_READONLY
or byte ptr [KEYTABLE+256+mt_flag],#FLAG_NOBD ; suppress
call kt_write
#endif
#if DEBUG_NEW
call ss3
.ascii "BIOS check\ns"
.byte 0
ss3: pop bx
call say
#else
mov al,#0x73 ! display an 's'
call display
#endif
#if DEBUG_NEW
call pause
mov ah,#2 ! get keyboard flags
int 0x16
and al,#0x70 ! Caps, Num, Scroll Lock flags
cmp al,#0x70
beq zzz ! fail with all 3 on
#endif
call io_biosdata
mov bx,#bs
call say
#ifndef LCF_READONLY
; if the BIOS data collection was successful, do not suppress it on future boots
and byte ptr [KEYTABLE+256+mt_flag],#~FLAG_NOBD ; no suppress
call kt_write
#endif
#endif
start_setup2: ! chain loader boot comes here
#if DEBUG_NEW
call pause ! last chance to use the timer
#endif
call remto ! free timer interrupt
push es
pop ds
#if 0
push es
pop fs
push es
pop gs
#endif
#ifdef VAR_LOAD
add sp,#SETUP_STACK_DYN ! increase stack size over this code
seg cs
push [setupseg]
push #0
retf ! start the kernel setup code
#else
mov ax,cs
shl ax,4
add ax,#SETUP_STACK_DYN
mov sp,ax
jmpi 0,SETUPSEG ! start the setup
#endif
! Load one sector (called from load)
doload: pop bx ! restore ES:BX
pop es
! Load a sequence of sectors, possibly moving into "high memory" (> 1 MB)
! afterwards.
xread: push ax ! ES == 0 ?
mov ax,es
or ax,ax
pop ax
jz rdhigh ! yes -> read into high memory
#ifdef DEBUG
br sread
#else
jmp sread
#endif
rdhigh: push bx ! okay - DS:BX points to GDT in this case
mov bx,#SYSSEG ! adjust ES:BX
mov es,bx
xor bx,bx
call sread ! load the sector(s)
mov tempal,al
pop bx ! get pointer to GDT
push ax ! just in case ...
push cx
push si
mov si,bx ! turn ES:SI into pointer to GDT
push ds
pop es
xor cx,cx ! number of words to move
mov ch,tempal
#ifdef DEBUG
push si
push bx
push cx
mov al,(si+0x14)
call bout
mov ax,(si+0x12)
call wout
mov bx,#mov_ar
call say
mov ah,(si+0x1f)
mov al,(si+0x1c)
call wout
mov ax,(si+0x1a)
call wout
mov bx,#mov_sz
call say
pop ax
push ax
call wout
call crlf
pop cx
pop bx
pop si
#endif
push bx ! do the transfer. (save BX, CX and SI because
push cx ! we are paranoid)
push si
mov ah,#0x87
int 0x15
pop si
pop cx
pop bx
jc badmov ! failed ...
shr cx,#8-1 ! convert words to bytes/256
sub ax,ax ! put ES back to 0
add (si+0x1b),cx
adc (si+0x1f),al
mov es,ax ! put ES back to 0
pop si
pop cx
pop ax
ret ! done
badmov: push ax ! save the error code
mov bx,#msg_bm ! tell the user ...
jmp reset ! (standard procedure)
! Load a sequence of sectors
sread: push bx ! save registers
push cx
push dx
call cread
mov di,ax ! save AL return count
jc rerror ! error -> complain
pop dx ! restore registers
pop cx
rokay: pop bx
shl ax,8 ; convert sectors to bytes
add ah,ah
jc dowrap ! loaded an entire segment -> advance ES
add bx,ax ! move BX
jnc nowrap ! same segment -> go on
dowrap: mov ax,es ! move ES
add ax,#0x1000
mov es,ax
nowrap:
mov ax,di ! restore the block count in AL
aret: ret ! done
! Read error - try a second time and give up if that fails too
rerror:
#if 0 /* we now have 5 tries down in cread */
xor ax,ax ! reset the disk
mov dl,al
int 0x13
pop dx ! try again
pop cx
pop bx
push bx
mov al,tempal
call cread
jnc rokay ! okay -> go on
#endif
push ax
mov bx,#msg_re ! say something
reset: call say
pop ax ! display the error code
mov al,ah
call bout
call crlf ! a CR/LF
mov moff,#0 ! restore initial state
br restrt
! Convert character in AL to upper case
upcase: cmp al,#0x61 ! lower case character ? ('a')
jb nolower ! no -> go on
cmp al,#0x7a ! 'z'
ja nolower
sub al,#0x20 ! convert to upper case
nolower:ret ! done
#if DEBUG_NEW
pause: push ax
mov ax,#3000/55 ! delay 3 seconds
call setto
delay1: test byte ptr timeout,#-1
jz delay1
pop ax
ret
#endif
#if DEBUG_NEW
! display a double word, pushed into the stack
dout: push bp
mov bp,sp
push ax
mov ax,(bp+6) ! get high order
call wout
mov ax,(bp+4) ! get low order
call wout
pop ax
leave
ret 4
! Display a hexadecimal word/byte/nibble
wout: push ax
xchg al,ah
call bout
pop ax
; must fall into bout
#endif
bout: push ax ! save byte
shr al,#4 ! display upper nibble
call nout
pop ax
nout: and al,#0x0F ! lower nible only
daa ! smaller conversion routine
add al,#0xF0
adc al,#0x40 ! AL is hex char [0..9A..F]
jmp display ! display it
! part of the 'say' routine
! actual entry point is below at 'say:'
say_loop:
cmp al,#10 ! \n ?
jne nonl ! no -> go on
mov al,#13 ! display a CRLF
call display
mov al,#10
nonl:
cmp al,#12 ! ^L ?
jne nocls ! no -> go on
#ifdef MENU
call menu_form_feed ! simulate a FF
#else
#ifdef BITMAP
cmp BYTE [abs_cx+1],#0 ; graphic screen on?
jne tosnext
#endif
mov ah,#0xf ! clear the local screen
int 0x10
xor ah,ah
int 0x10
#endif
tosnext: jmp snext ! next character
nocls: call display ! display, tty-style
snext:
inc bx ! next one
! fall into say ! process next character
! Display a NUL-terminated string on the console
say: mov al,(bx) ! get byte
or al,al ! NUL ?
jnz say_loop ! not the end
ret
! Display CR/LF
crlf: mov al,#13 ! CR
call display
mov al,#10 ! LF
;;; jmp display
; fall into display
! Display one character on the console
display:
push bx ! save BX
#ifndef LCF_NOSERIAL
call serdisp
#endif
#if defined(MENU) || defined(BITMAP)
seg cs
cmp word [suppress],#0
jnz dispret
#ifdef MENU
push ds
push cs
pop ds
push dx
cmp byte [abs_cx+1],#0 ! is special scrolling in effect?
je goshowit ! jump if no special handling
call mn_getcursor ! get cursor pos. in DX
cmp al,#8 ! is it BS
jne scroll1
or dl,dl ! at col. 0?
jne goshowit
; must simulate a BS
mov dl,[mn_max_row_col] ! move to EOL
mov al,#0x0a ! change to LF
dec dh ! back up first of two lines
jmp scroll_set ! set new cursor pos. & ring BEL
scroll1:
cmp al,#0x0a ! test for LF / NL
jne scroll2
cmp dh,[mn_max_row_col+1] ! bottom row
jae scrollit
scroll2:
cmp al,#0x20 ! printing char?
jb goshowit
cmp dx,[mn_max_row_col] ! bottom corner
jne goshowit
scrollit:
pusha
mov ax,#0x601 ! scroll up 1 line
mov bh,[mn_at_mono]
mov cx,[abs_cx]
mov dx,[mn_max_row_col]
int 0x10 ! do the scroll
popa
scroll_set:
dec dh
call mn_setcursor ! set cursor up 1 row
goshowit:
pop dx
pop ds
#endif
#endif
xor bh,bh ! display on screen
mov ah,#14
int 0x10
dispret:
pop bx ! restore BX
ret
#ifndef LCF_NOSERIAL
serdisp:push dx ! wait for space in the send buffer
seg cs
mov dx,slbase
or dx,dx
jz serret
add dx,#5
push ax
serwait:in al,dx
test al,#0x10 ! break -> set break flag
jz nobrk
seg cs
mov byte ptr break,#1
nobrk: test al,#0x20 ! ready to send ?
jz serwait ! no -> wait
sub dx,#5 ! send the character
pop ax
out dx,al
serret: pop dx ! done
ret
#endif
! Get a key (CX = timeout exit)
getkey: BEG_FS
SEG_FS ! set the timeout
mov ax,par1_timeout+SSDIFF ;DSC_OFF-10+SSDIFF
END_FS
call setto
gwtkey: mov ah,#1 ! is a key pressed ?
int 0x16
jnz gotkey ! yes -> get it
#ifndef LCF_NOSERIAL
mov dx,slbase ! using a serial port ?
or dx,dx
jz gnokey ! no -> wait
add dx,#5 ! character ready ?
in al,dx
test al,#1
jz gnokey ! no -> wait
sub dx,#5 ! get it
in al,dx
and al,#0x7f ! strip 8th bit
jnz gotch ! ignore NULs
#endif
gnokey:
#if defined(MENU) || defined(BITMAP)
#ifdef BITMAP
cmp byte [abs_cx+1],#0
je no_timer_display
#endif
call timer_display
no_timer_display:
#endif
test byte ptr timeout,#1 ! timed out ?
jz gwtkey ! no -> wait
pop ax ! discard return address
jmp cx ! jump to timeout handler
gotkey: xor ah,ah ! read a key
int 0x16
push bx ! keyboard translation (preserve BX)
mov bx,#KEYTABLE
xlatb
pop bx
gotch:
#ifdef LCF_ONE_SHOT
BEG_FS
SEG_FS ! always enter prompt ?
test byte ptr par1_prompt+SSDIFF,#FLAG_PROMPT
;;; END_FS
jz noosht ! yes -> do not disable timeout
;;; BEG_FS
SEG_FS ! disable timeout
mov word ptr par1_timeout+SSDIFF,#0xffff
;;; END_FS
noosht:
END_FS ;;;
#endif
ret ! done
! Shift wait loop (AX = timeout, returns CY set if interrupred)
waitsh: call setto ! set timeout
actlp: mov ah,#2 ! get shift keys
int 0x16
and al,#0x5f ! anything set ? (except NumLock)
jnz shpress ! yes -> return with CY set
#ifndef LCF_NOSERIAL
mov dx,slbase ! using a serial port ?
or dx,dx
jz acnosp ! no -> go on
cmp byte ptr break,#0 ! break received ?
jnz shpress ! yes -> return with CY set
add dx,#5 ! check for pending break
in al,dx
test al,#0x10
jnz shpress ! break received -> return with CY set
#endif
acnosp: test byte ptr timeout,#1 ! timed out ?
jz actlp ! no -> wait
clc ! clear carry
ret ! done
shpress:stc ! set carry
ret ! done
! Timeout handling
instto: push ds ! install the timeout handler
push #0
pop ds
cli ! no interrupts
#ifdef LCF_M386
mov eax,[0x1c*4] ! get the old vector
seg cs
mov [int1c_l],eax ! save H & L parts
#else
mov ax,[0x1c*4] ! get the old vector
seg cs
mov int1c_l,ax
mov ax,[0x1c*4+2]
seg cs
mov int1c_h,ax
#endif
mov [0x1c*4],#tick ! install new vector
mov [0x1c*4+2],cs
sti ! done
pop ds
ret
remto: push es ! remove the interrupt handler
push #0
pop es
#ifdef LCF_M386
mov eax,[int1c_l] ! restore the old vector
seg es
mov [0x1c*4],eax ! **
#else
cli
mov ax,int1c_l ! restore the old vector
seg es
mov [0x1c*4],ax
mov ax,int1c_h
seg es
mov [0x1c*4+2],ax
sti ! done
#endif
pop es
ret
! AX = ticks, 0xffff = no timeout
setto: or ax,ax ! time out immediately ?
jz toimmed ! yes -> do it
cli ! set timeout value
mov cntdown,ax
mov byte ptr timeout,#0 ! clear timed-out flag
sti ! done
ret
toimmed:mov byte ptr timeout,#0xff ! set the timed-out flag
ret ! done
tick: pushf ! save flags
seg cs ! no timeout ?
cmp cntdown,#0xffff
je notzro ! yes -> go on
seg cs ! decrement counter
dec cntdown
jnz notzro ! not zero -> go on
seg cs ! set timeout flag
mov byte ptr timeout,#0xff
notzro:
#if 0
popf ! done
seg cs
jmpi (int1c_l) ! continue with old interrupt
#else
#ifdef LCF_M386
seg cs
push dword [int1c_l]
#else
seg cs
push word [int1c_h]
seg cs
push word [int1c_l]
#endif
iret ! continue with old interrupt
#endif
kt_set:
BEG_FS
SEG_FS ! load the keyboard translation table
mov cx,par1_keytab+SSDIFF ;MSG_OFF+SSDIFF+7
SEG_FS
mov dx,par1_keytab+2+SSDIFF ;MSG_OFF+SSDIFF+9
SEG_FS
mov al,par1_keytab+4+SSDIFF ;MSG_OFF+SSDIFF+11
END_FS
mov bx,#KEYTABLE
ret
#ifndef LCF_READONLY
! Sector write; used for the keytable only
kt_write:
push es
push ds
pop es
call kt_set ; set for KEYTABLE i/o
call cwrite
pop es
ret
! Sector write; used for the stored command line only
cmd_write:
BEG_FS
SEG_FS
mov cx,par1_dflcmd+SSDIFF
SEG_FS
mov dx,par1_dflcmd+2+SSDIFF
SEG_FS
mov al,par1_dflcmd+4+SSDIFF
END_FS
; fall into cwrite
;
; General sector write
;
cwrite:
#ifdef RAID_NEW
BEG_FS
SEG_FS
test byte ptr par1_prompt+SSDIFF,#FLAG_RAID_NOWRITE ; no writes?
END_FS
jnz cwok ; jump if no writing allowed
BEG_FS
SEG_FS
test byte ptr par1_prompt+SSDIFF,#FLAG_RAID ; is it a RAID write
END_FS
jnz cmd_raid_wrt
#endif
mov byte ptr (dsk_wrflag),#1 ! flag write operation
call cread
mov byte ptr (dsk_wrflag),#0 ! flag read operation
jnc cwok ! no error - return
cnok: push ax ! leave no traces
push bx
mov al,#87 ! "W"
push ax ! display clobbers AH
call display
pop ax
mov al,ah ! error code
call bout
call crlf ! leave space
pop bx
pop ax
stc ! flag error JRC
cwok:
#if DEBUG_NEW
pushf
call pause
popf
#endif
ret ! done
#ifdef RAID_NEW
; We know it is RAID, so CHS is not in effect
cmd_raid_wrt:
mov di,#raid_tt ; point at RAID translation table
xor ah,ah ;will be zero for LINEAR
xchg al,dh ;AX is possible address
test dl,#LBA32_FLAG ;test for pure LINEAR *****
jz lnwrt ;jump if pure LINEAR *****
test dl,#LBA32_NOCOUNT
jz lnwrt
mov ah,dh ;former count is really hi-nibble
lnwrt: ; address is AX:CX, DH=1, DL=device+flags, ES:BX=buffer
mov dh,#1 ;set count to 1
push ax
push cx
push di
mov byte ptr (dsk_wrflag),#1 ! flag write operation
#if DEBUG_NEW
pusha
push ax ! save high order
push cx ! save low order
push dx
mov bx,#cmdwr
call say
pop ax
call bout ! device+flags
mov bx,#rs_reloc
call say
call dout
call crlf
popa
#endif
call lnread
mov byte ptr (dsk_wrflag),#0 ! flag read operation
pop di
pop cx
jc cmdwerr
pop ax
mov dh,(di) ! get next raid device
or dh,dh
jz cwok
and dl,#0xFF-DEV_MASK ! save flags
or dl,dh
add cx,(di+1) ! apply low order translation
adc ax,(di+3) ! apply high order translation
add di,#5
jmp lnwrt
cmdwerr:
pop cx ! was AX
jmp cnok ! write dumb error message
#if DEBUG_NEW
cmdwr: .ascii "RAID: write to device "
.byte 0
#endif
#endif
#endif
kt_read: ; KEYTABLE read
call kt_set ; set for KEYTABLE i/o
;;; jmp cread
! Sector read
! trashes CX and DI
cread:
test dl,#LINEAR_FLAG|LBA32_FLAG
jnz use_linear
push ax ;save the count
mov ah,#2 ;read command
call dsk_do_rw ; int 0x13 with retries
pop cx ;Carry Set means error on read
mov al,cl ;count in AL, error code in AH
ret
use_linear:
mov ah,hinib ;will be zero for LINEAR
xchg al,dh ;AX is possible address
test dl,#LBA32_FLAG ;test for LBA32/LINEAR *****
jz lnread ;pure LINEAR *****
test dl,#LBA32_NOCOUNT
jz lnread
mov ah,dh ;former count is really hi-nibble
mov hinib,ah
mov dh,#1 ;set count to 1
lnread:
xchg di,ax ;hi-address to DI
mov al,dh ;count to AL
test dl,#RAID_REL_FLAG ; ******
jz ln_do_read ; ******
BEG_FS
SEG_FS
add cx,par1_raid_offset+SSDIFF ; ***** RAID ******
SEG_FS
adc di,par1_raid_offset+2+SSDIFF ; ***** RAID ******
END_FS
ln_do_read:
call lba_read
mov al,cl ;count returned in AL, error code in AH
ret ;Carry Set means error on read
#ifdef RAID_NEW
; raid_search -- search for other raid disks which parallel this one
;
; enter with DS:BX pointing to buffer to use (DESCR) for searches
; and with ES=DS=CS
;
; side effect is to set up the raid translation table for writes
;
;
raid_search:
push es
#if DEBUG_NEW
mov byte ptr raid_nn,#0 ;set number of raid disks to 0
call crlf
#endif
BEG_FS
SEG_FS
mov dl,par1_descr+sa_device+SSDIFF ; get map file drive
; enable matching RAID boot blocks by clearing the DEFEAT flag
SEG_FS
and byte ptr par1_prompt+SSDIFF,#0xFF-FLAG_RAID_DEFEAT
SEG_FS
test byte ptr par1_prompt+SSDIFF,#FLAG_RAID
END_FS
#if DEBUG_NEW
#ifdef LCF_M386
jz near rs_ret
#else
beq rs_ret
#endif
#else
jz rs_ret
#endif
and dx,#0xF0 ; save LINEAR/LBA32/LBA32_NOCOUNT
#if 0
cmp dl,#0x80 ; must be 0x80 for this to be raid
#if DEBUG_NEW
#ifdef LCF_M386
jne near rs_ret
#else
bne rs_ret
#endif
#else
jne rs_ret
#endif
#endif
mov bp,#16 ; test 16 bios devices
push #raid_tt ; set pointer
rs_next:
push ds
pop es
mov cx,#1
#if DEBUG_NEW
pusha
push dx
mov bx,#rs_test
call say
pop ax
call bout
popa
#endif
push dx ; protect LBA32/LINEAR flags
and dx,#DEV_MASK ; mask flag bits; clear DH, too (0x008F)
mov al,cl ; read 1 sector
call cread ; read the boot sector (MBR)
; no RAID relocation will happen
; because we use CHS addressing
pop dx
jc rs_done
pop di
call raid_compare ; watch out for DI - raid ptr in
; the stack
#ifdef RAID_NEW
push bx
mov cx,#4
lea si,(bx+PART_TABLE_OFFSET)
add bh,#SECTOR_SIZE>>8
rs_chk_pri:
#if 0
cmp byte ptr (si+4),#0xFD ; check for raid partition
jne rs_chk_pri_next
#endif
cmp byte ptr (si+4),#0 ; check for empty entry
je rs_chk_pri_next
push cx
push di
#if DEBUG_NEW
push bx
mov bx,#rsckpar
call say
mov al,#5
sub al,cl
call nout
pop bx
#endif
mov al,#1
mov cx,(si+8)
mov di,(si+8+2)
call lba_read
pop di
call raid_compare
pop cx
rs_chk_pri_next:
add si,#16 ; next partition table entry
loop rs_chk_pri
pop bx
push di
#endif /* CHECK_PRI_TOO */
inc dl ; move to next drive
dec bp
jnz rs_next ; try next device code
rs_done:
pop di
mov byte ptr (di),#0 ; mark zero on end
#if DEBUG_NEW
pusha
call crlf
mov bx,#rs_found
call say
mov si,#raid_nn
lodsb
call nout
mov bx,#rs_found2
call say
rs_debug1:
mov bx,#rs_dev
call say
lodsb
call bout
mov bx,#rs_reloc
call say
#ifdef LCF_M386
lodsd
push eax
call dout
#else
lodsw
push ax
lodsw
call wout
pop ax
call wout
#endif
call crlf
test byte ptr (si),#0xFF
jnz rs_debug1
call pause
popa
#endif
rs_ret:
pop es
ret
; raid compare
;
; enter with DI = raid pointer
; DS:BX points at the buffer that was read
; DL is device code
;
raid_compare:
push es
push si
push di
mov si,bx ; compare what is read
xor di,di ; to our first stage loader
#ifdef LCF_M386
push fs
pop es
#else
seg cs
mov es,firstseg
#endif
mov cx,#par1_raid_offset-par1_cli ; signature
repe
cmpsb
jne rs_skip2
add si,#8
add di,#8 ; skip raid_reloc & timestamp
mov cx,#par1_size - par1_raid_offset - 8
repe
cmpsb
rs_skip2:
#if DEBUG_NEW
pushf
pusha
mov bx,#rs_nomatch
jne rs_nm
mov bx,#rs_match
rs_nm: call say
popa
popf
#endif
jne rs_skip
; we found two boot records that are identical
#if DEBUG_NEW
inc raid_nn
#endif
#ifdef LCF_M386
mov eax,(bx+par1_raid_offset)
#else
mov ax,(bx+par1_raid_offset)
mov cx,(bx+par1_raid_offset+2)
#endif
#ifdef LCF_M386
seg fs
sub eax,par1_raid_offset
#else
seg es ; ES == FS
sub ax,par1_raid_offset
seg es
sbb cx,par1_raid_offset+2
push ax
or ax,cx ; do the zero test
pop ax
#endif
jnz rs_insert
seg es ; ES == FS
cmp dl,par1_dflcmd+sa_device
#if DEBUG_NEW
jne rs_insert
pusha
mov bx,#rs_omitted
call say
popa
jmp rs_skip
#else
je rs_skip
#endif
rs_insert:
pop di
mov (di),dl ; save device
#ifdef LCF_M386
mov (di+1),eax ; save offset
#else
mov (di+1),ax ; save offset lo
mov (di+1+2),cx ; save offset hi
#endif
add di,#5
push di
rs_skip:
pop di
pop si
pop es
ret
#if DEBUG_NEW
raid_nn: .byte 0 ; must precede raid_tt for printout
#endif
raid_tt: .blkb 5*16 ; format is drive: .byte
; translate: .long
.byte 0
#if DEBUG_NEW
rs_test: .ascii "RAID: Testing"
rs_dev: .ascii " device "
.byte 0
rs_nomatch: .ascii " no"
rs_match: .ascii " match"
.byte 10,0
rs_omitted: .ascii " omitted"
.byte 10,0
rs_found: .ascii "RAID: found "
.byte 0
rs_found2: .ascii " matching MBR(s)"
.byte 10,0
rs_reloc: .ascii " reloc "
.byte 0
rsckpar: .ascii " Checking partition "
.byte 0
#endif
#endif
#if 1
; crc32 -- calculate CRC-32 checksum
;
; call:
; push dword #POLYNOMIAL
;
; ES:SI char string pointer
; DI count of characters
;
; call crc32
;
; CRC-32 is returned in EAX or DX:AX
; the arguments are popped from the stack
;
crc32:
push bp
mov bp,sp
push si
push di
push bx
push cx
#ifdef LCF_M386
mov eax,#-1 ; initialize CRC
#else
mov ax,#-1
cwd
#endif
inc di
crc32a:
dec di
jz crc32d
mov cx,#8 ; count 8 bits
seg es
mov bl,(si) ; get next character
inc si
crc32b: shl bx,#1 ; get hi bit of char in BH
#ifdef LCF_M386
shl eax,#1 ; shift hi bit out of CRC
#else
shl ax,#1
rcl dx,#1
#endif
adc bh,#0 ; add carry to BH
shr bh,#1 ; put bit in carry
jnc crc32c ; skip the xor
#ifdef LCF_M386
xor eax,(bp+4) ; xor in the polynomial
#else
xor ax,(bp+4)
xor dx,(bp+6)
#endif
crc32c:
loop crc32b ; loop back for 8 bits
jmp crc32a
crc32d:
#ifdef LCF_M386
not eax ; finialize CRC
#else
not ax
not dx
#endif
pop cx
pop bx
pop di
pop si
leave
ret 4
#endif
#ifdef HIGHMEM_MAX
; enter with BX == Ramdisk size (in 4k pages)
;
rd_setup:
push bx ; save Ramdisk size in pages
mov eax,hma ; user specified?
or eax,eax
jnz rd_have_hma1
; try the E820 memory map first
xor ebx,ebx
jmp e8go
e8go2: or ebx,ebx ; test for end
jz no_e820
e8go: mov eax,#0xe820
mov edx,#0x534d4150 ;'SMAP'
mov ecx,#20
mov di,#memmap
int 0x15 ; get memory map
jc no_e820
cmp eax,#0x534d4150 ;'SMAP'
jne no_e820
cmp ecx,#20
jne no_e820
mov eax,memmap+4 ; high part of address
or eax,memmap+8+4 ; high part of size
jnz no_e820
cmp word memmap+16,#1 ; available?
jne e8go2 ; go on to next
mov eax,memmap ; get start
cmp eax,#0x100000 ; compare to 1Mb
ja e8go2
add eax,memmap+8 ; get final address
cmp eax,#0x400000 ; compare to 4Mb
jb e8go2
shr eax,10 ; convert to 1k blocks (legacy)
rd_have_hma1:
jmp rd_have_hma
no_e820:
; above failed, try the older E801 block count interface
xor cx,cx ; some BIOSs are buggy
xor dx,dx
mov ax,#0xe801 ; call
stc
int 0x15
jc no_e801
or cx,cx
jz e801cx
mov ax,cx
e801cx: or dx,dx
jz e801dx
mov bx,dx
e801dx:
movzx ebx,bx
;;; cwde
movzx eax,ax
shl ebx,6 ; convert to 1k
add eax,#1024 ; add 1M to address
add eax,ebx
jmp rd_have_hma
no_e801:
; above two methods failed, try the old 0x88 function
mov ah,#0x88 ; get count of extended memory blocks
int 0x15
movzx eax,ax ; extend to dword
add eax,#1024 ; add in base 1M
;
rd_have_hma: ; have the HMA / 1k in EAX
mov ebx,#15*1024 ; 15Mb
cmp eax,ebx ; compare to 15M
jbe rd_use_eax ; use lower value
cmp eax,#64*1024
jbe rd_use_smaller ; use 15Mb if mem<=64M (older systems)
mov ebx,#HIGHMEM_MAX/1024
cmp eax,ebx
jb rd_use_eax
rd_use_smaller:
xchg eax,ebx ; must use the smaller
rd_use_eax:
pop bx ; get size in pages
shr eax,2 ; convert to pages
movzx ebx,bx ; zero high part of size
sub eax,ebx ; start address of ramdisk to EAX
cmp eax,#256 ! we probably need more than 1M for the
ja rd_okay ! kernel to be useful ...
foo: mov bx,#msg_rd ! complain
;;; call say ! is at zz
br zz ! and halt
rd_okay:
shl eax,4 ! shift (12-8) -> 4
mov [rdbeg+1],ax ! set up beginning address
mov [gdt+0x1b],ax ! set the GDT for the moves
shr eax,16 ! get hi-byte of address
mov [rdbeg+3],al ! set rest of address
mov [gdt+0x1f],al ! and in the GDT, too
ret
#endif
#ifdef SHS_PASSWORDS
#include "shs3.S"
#endif
#include "read.S"
#ifdef LCF_BDATA
#include "bdata.h"
#include "biosdata.S"
#endif
#ifdef MENU
#include "graph.S"
#include "menu.S"
#include "strlen.S"
#include "crt.S"
#endif
#ifdef BITMAP
#include "bitmap.S"
#include "strlen.S"
#include "display4.S"
#endif
! Put tokens into keyboard buffer
putkbd: add si,#4 ! skip over "kbd="
push es
xor ax,ax ! set ES to zero
mov es,ax
pknext: lodsb ! get next byte
or al,al ! NUL ?
jz pkdone ! yes -> done
cmp al,#32 ! blank ?
jne pkrd ! no -> read scan code
pkdone: dec si ! return last character
pop es ! done
ret
pkrd: xor cx,cx ! clear accumulator
pkrdlp: cmp al,#97 ! lower case character ?
jb pknol ! no -> go on
sub al,#32 ! make upper case
pknol: sub al,#48 ! normalize
cmp al,#10 ! >"9" ?
jb pkok ! no -> okay
cmp al,#17 ! <"A" ?
jb pksyn ! yes -> syntax error
sub al,#7 ! adjust
cmp al,#16 ! >"F" ?
jae pksyn ! yes -> syntax error
pkok: shl cx,1 ! shift CX
jc pksyn ! carry means trouble
shl cx,1
jc pksyn
shl cx,1
jc pksyn
shl cx,1
jc pksyn
add cl,al ! put in lowest nibble
lodsb ! get next byte
or al,al ! NUL ?
jz pkend ! yes -> at end
cmp al,#32 ! space ?
je pkend ! yes -> at end
cmp al,#44 ! comma ?
je pkmore ! yes -> end of token
jmp pkrdlp ! token continues
pksyn: mov bx,#msg_pks ! complain
call say
pkfls: lodsb ! flush to end of option
or al,al
jz pkdone
cmp al,#32
je pkdone
jmp pkfls
pkend: call pkput ! store token
jmp pkdone ! ... and return
pkmore: call pkput ! store token
jmp pknext ! handle next token
pkput: seg es ! get buffer pointer
mov bx,[KBEND]
mov dx,bx
add dx,#2 ! increment it
cmp dx,#KBHIGH ! (wrap around end)
jb pknadj
mov dx,#KBLOW
pknadj: seg es ! buffer full ?
cmp dx,[KBBEG]
je pkfull ! yes -> error
seg es ! store scan code
mov (bx+0x400),cx
seg es ! store new pointer
mov [KBEND],dx
ret ! done
pkfull: mov bx,#msg_pkf ! complain
call say
pop ax ! discard return address
jmp pkfls ! abort
! Set VGA mode
setvga: add si,#4 ! skip over "vga="
push si ! save SI
mov bx,#vgatab ! scan VGA table
svgatb: pop si ! get pointer to option value
push si
mov cx,(bx) ! get VGA code
or cx,cx ! at end ?
jz vganum ! yes -> must be numeric
add bx,#2 ! compare the strings
vgacmp: lodsb
call upcase ! (case-insensitive)
mov ah,(bx)
inc bx
or ah,ah ! at end ?
jnz vgamore ! no -> go on
or al,al ! at end of line ?
jz vgafnd ! yes -> found it
cmp al,#32 ! space ?
je vgafnd ! yes -> found it
jmp svgatb ! try next entry otherwise
vgamore:cmp al,ah
je vgacmp ! equal -> next character
vgaskp: mov al,(bx) ! skip to end of reference string
inc bx
or al,al
jnz vgaskp
jmp svgatb ! try next entry
vgafnd: pop ax ! drop SI
vgaput: mov vgaovr,cx ! set VGA mode
dec si ! read last character again
clc ! okay, done
ret
vganum: pop si ! get SI
xor cx,cx
mov ah,cl
test byte ptr (si),#0xff ! no value ?
jz vgaerr ! yes -> error
vgadig: lodsb ! get the next character
or al,al ! at end ?
jz vgaput ! yes -> done
cmp al,#32
je vgaput
cmp al,#48 ! is it a digit ? (0x30=48="0")
jb vgaerr ! no -> error
cmp al,#57 ! 57=0x39="9"
ja vgaerr
sub al,#48 ! cx = cx*10+al-'0'
#if 0
mov bx,cx
shl cx,1
shl cx,1
add cx,bx
shl cx,1
#else
imul cx,#10
#endif
add cx,ax
jnc vgadig ! next one
vgaerr: mov bx,#msg_v ! display an error message
call say
stc ! return an error
ret
vgatab:
#ifdef NORMAL_VGA
.word ASK_VGA
.ascii "ASK"
.byte 0
.word EXTENDED_VGA
.ascii "EXTENDED"
.byte 0
.word EXTENDED_VGA
.ascii "EXT"
.byte 0
.word NORMAL_VGA
.ascii "NORMAL"
.byte 0
#endif
.word 0
! Set memory limit
getmem: cmp byte ptr (si+4),#0x6e ! 'n' like 'nopentium' ?
jne mlreal ! no -> proceed
ret ! nice try
mlreal: push si ! save SI for copying
add si,#4 ! advance SI to beginning of number
call strtoul ! get number in DX:AX
#if 0
push ax
push dx
push ax
mov ax,dx
call wout
pop ax
call wout
pop dx
pop ax
#endif
mov bl,(si) ! get next character
cmp bl,#0x4b ! 'K' or 'k' ?
je mlthis ! yes -> do not change
cmp bl,#0x6b
je mlthis
mov cx,#20 ! divide or multiply by 2^20
cmp bl,#0x47 ! 'G' or 'g' ?
je mlmul ! yes-> multiply
cmp bl,#0x67
je mlmul
mov cx,#10 ! divide or multiply by 2^10
cmp bl,#0x4d ! 'M' or 'm' ?
je mlmul ! yes-> multiply
cmp bl,#0x6d
je mlmul
cmp byte ptr (si),#0 ! NUL ?
je mldivl ! yes -> divide
cmp byte ptr (si),#32
jne s2lbad2 ! trouble
mldivl: shr dx,1 ! shr DX:AX,1
rcr ax,1
loop mldivl ! ten times
jmp mlthis ! done
mlmul:
;;; or dx,dx ! too big already ?
;;; jnz mlbig ! yes -> set to 0xffff
mlmull: shl ax,1 ! shl DX:AX,1
rcl dx,1
jc mlvbig ! very big if overflow
loop mlmull ! ten times
mlthis:
#ifdef HIGHMEM_MAX
mov hma,ax
mov hma+2,dx ! set Highest Memory Address
#endif
sub ax,#1024 ! subtract 1M
sbb dx,#0
jz mlnbig ! no -> use AX
#ifdef HIGHMEM_MAX
jmp mlbig
#endif
mlvbig:
#ifdef HIGHMEM_MAX
mov dword ptr hma,#HIGHMEM_MAX/1024
#endif
mlbig: mov ax,#0xffff ! use maximum
mlnbig: mov memlim,ax ! set memory limit
pop si ! restore SI
ret ! done
strtoul: /* string to unsigned long in DX:AX */
xor ax,ax
xor dx,dx
mov cx,#10 ! default radix is decimal
cmp byte ptr (si),#0x30 ! == '0'?
jne s2lnext
inc si
dec cx
dec cx ! assume octal : CX = 8
cmp byte ptr (si),#0x58 ! == 'X'?
je s2lhex
cmp byte ptr (si),#0x78 ! == 'x'?
jne s2lnext
s2lhex: add cx,cx ! it is hexadecimal
inc si
s2lnext:
xor bx,bx
mov bl,(si) ! get next character
sub bx,#0x30 ! - '0'
jb s2ldone
cmp bl,cl ! compare to radix
jb s2lmul
add bx,#0x30
and bl,#0xFF-0x20 ! convert to Upper Case
sub bx,#0x41 ! - 'A'
cmp bl,#6
jnb s2ldone
add bl,#10
s2lmul:
push dx ! save high order
mul cx ! multiply by radix
add ax,bx
adc dx,#0 ! carry possible only in radix 10
pop bx
push dx
xchg ax,bx
mul cx
or dx,dx
s2lbad2: jnz s2lbad
pop dx
add dx,ax
jc s2lbad
xchg ax,bx
inc si
jmp s2lnext
s2lbad: mov bx,#msg_s2l ! complain
call say
br restrt ! start over again
s2ldone: ret
msg_s2l:.byte 10
.ascii "Invalid number"
.byte 10,0
! GDT for "high" loading
gdt: ! space for BIOS
.blkb 0x10
! source
.word 0xffff ! no limits
.word 0 ! start: 0x10000
.byte 1
.byte 0x93 ! permissions
.word 0 ! padding for 80286 mode :-(
! destination
.word 0xffff ! no limits
.word 0 ! start - filled in by user
.byte 0
.byte 0x93 ! permissions
.word 0 ! padding for 80286 mode :-(
! space for BIOS
.blkb 0x10
! Some messages
msg_p: .ascii "boot: "
.byte 0
msg_l: .ascii "Loading "
.byte 0
msg_re: .byte 10
.ascii "Error 0x"
.byte 0
msg_nf: .ascii "No such image. [Tab] shows a list."
.byte 10,0
msg_chkerr:
.ascii "O - Descriptor checksum error\n"
.byte 0
msg_sigerr:
.ascii "O - Signature not found\n"
.byte 0
#ifdef MEMORY_CHECK
msg_mem: .ascii "EBDA too big"
.byte 10,0
#endif
msg_int:.byte 10
.ascii "*Interrupted*"
.byte 10,0
msg_eof:.byte 10
.ascii "Unexpected EOF"
.byte 10,0
msg_pw: .ascii "Password: "
.byte 0
msg_pf: .ascii "Sorry."
.byte 10,0
msg_v: .byte 10
.ascii "Valid vga values are ASK, NORMAL, EXTENDED or a "
.ascii "decimal number."
.byte 10,0
msg_pks:.byte 10
.ascii "Invalid hexadecimal number. - Ignoring remaining items."
.byte 10,0
msg_pkf:.byte 10
.ascii "Keyboard buffer is full. - Ignoring remaining items."
.byte 10,0
msg_bm: .byte 10
.ascii "Block move error 0x"
.byte 0
msg_rd: .byte 10
.ascii "Not enough memory for RAM disk"
.byte 10,0
ospc: .ascii "O"
#ifdef LCF_BEEP
.byte 7
#endif
#ifdef LCF_VERSION
.ascii " "
.ascii S(VERSION_MAJOR)
.ascii "."
.ascii S(VERSION_MINOR)
.ascii VERSION_EDIT
#endif
.byte 32,0
bs: .byte 8,32,8,0
#ifdef DEBUG
stepa: .ascii " RAM disk,"
.byte 0
step0: .ascii " map page,"
.byte 0
step0b: .ascii " fallback,"
.byte 0
step1: .ascii " options,"
.byte 0
step1b: .ascii " fallback,"
.byte 0
step2: .ascii " boot,"
.byte 0
step3: .ascii " setup,"
.byte 0
step4: .ascii " system "
.byte 0
sax: .ascii "AX="
.byte 0
sbx: .ascii " BX="
.byte 0
scx: .ascii " CX="
.byte 0
sdx: .ascii " DX="
.byte 0
ses: .ascii " ES="
.byte 0
sdone: .byte 10
.byte 0
mov_ar: .ascii " -> "
.byte 0
mov_sz: .ascii ", words "
.byte 0
#endif
.even
#ifdef VAR_LOAD
stackseg:
initseg: .word INITSEG
setupseg: .word SETUPSEG
#endif
#if defined(MENU) || defined(BITMAP)
suppress:.word 0 ! suppress console output (MUST be word)
#endif
hinib: .byte 0 ; hi-nibble of address
tempal: .byte 0
moff: .word 0 ! map offset
cntdown:.word 0 ! count-down
timeout:.byte 0 ! timed out
int1c_l:.word 0 ! old timer interrupt
int1c_h:.word 0
old_del:.word 0 ! delay before booting
nodfl: .word 0 ! action if no defaults are present
#ifndef LCF_NOSERIAL
slbase: .word 0 ! serial port base (or 0 if unused)
break: .byte 0 ! break received flag
#endif
usrinpm:.byte UI_MAGIC
cmdbeg: .word 0
options:.word 0
rdbeg: .word 0,0 ! RAM dist begin address (dword)
rdszl: .word 0 ! RAM disk size
rdszh: .word 0
vgaovr: .word 0 ! VGA mode overwrite
memlim: .word 0 ! memory limit
#ifdef HIGHMEM_MAX
hma: .word 0,0 ! Highest Memory Address
memmap: .word 0,0,0,0,0,0,0,0,0,0
#endif
dskprm: .word 0,0,0,0,0,0
#ifndef LOCK_BSS
lkwbuf: .word DC_MAGIC
lkcbuf: .blkb 256
#endif
dolock: .byte 0
.even ! control alignment from here down
acmdbeg:.ascii "auto "
mcmdbeg:.ascii "BOOT_IMAGE"
prechr: .byte 32 ! space: guard double blank supression
! equal sign: variable assignment
cmdline:.byte 0
#ifdef BITMAP
_line: ! must be 640 bytes long
#endif
theend:
#ifdef LOCK_BSS
lkwbuf = cmdline+CL_LENGTH+2 ; this is a word
lkcbuf = lkwbuf+2
theend2 = lkcbuf+CL_LENGTH ; lkcbuf is 256
#endif
the_end1 = theend+511
theends = the_end1/512
|