Loading...
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 | /*
* linux/arch/m68k/console/fbcon.c -- Low level frame buffer based console
* driver
*
* Copyright (C) 1995 Geert Uytterhoeven
*
*
* This file is based on the original Amiga console driver (amicon.c):
*
* Copyright (C) 1993 Hamish Macdonald
* Greg Harp
* Copyright (C) 1994 David Carter [carter@compsci.bristol.ac.uk]
*
* with work by William Rucklidge (wjr@cs.cornell.edu)
* Geert Uytterhoeven
* Jes Sorensen (jds@kom.auc.dk)
* Martin Apel
*
* and on the original Atari console driver (atacon.c):
*
* Copyright (C) 1993 Bjoern Brauel
* Roman Hodek
*
* with work by Guenther Kelleter
* Martin Schaller
* Andreas Schwab
*
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file README.legal in the main directory of this archive
* for more details.
*/
/*
* To do:
* - Implement 16 plane mode.
* - Add support for 16/24/32 bit packed pixels
* - Hardware cursor
*/
#include <linux/types.h>
#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/tty.h>
#include <linux/console.h>
#include <linux/string.h>
#include <linux/config.h>
#include <linux/kd.h>
#include <linux/malloc.h>
#include <asm/bootinfo.h>
#include <asm/irq.h>
#ifdef CONFIG_AMIGA
#include <asm/amigahw.h>
#include <asm/amigaints.h>
#endif /* CONFIG_AMIGA */
#ifdef CONFIG_ATARI
#include <asm/atariints.h>
#endif
#ifdef CONFIG_FB_CYBER
#include "../amiga/s3blit.h"
#endif /* CONFIG_FB_CYBER */
#include <linux/fb.h>
#include <asm/font.h>
#include <asm/machdep.h>
#include <asm/system.h>
#include "../../../drivers/char/vt_kern.h" /* vt_cons and vc_resize_con() */
/* Import console_blanked from console.c */
extern int console_blanked;
/*
* The following symbols select what modes are supported. They should
* be settable by the user ("make config") later.
*/
/* Clear all definitions */
#undef CONFIG_FBCON_MONO
#undef CONFIG_FBCON_ILBM
#undef CONFIG_FBCON_PLANES
#undef CONFIG_FBCON_2PLANE
#undef CONFIG_FBCON_4PLANE
#undef CONFIG_FBCON_8PLANE
#undef CONFIG_FBCON_8PACKED
#undef CONFIG_FBCON_16PACKED
#undef CONFIG_FBCON_24PACKED
#undef CONFIG_FBCON_32PACKED
#undef CONFIG_FBCON_CYBER
/* Monochrome is default */
#define CONFIG_FBCON_MONO
/* Amiga support */
#ifdef CONFIG_AMIGA
#ifndef CONFIG_FBCON_ILBM
#define CONFIG_FBCON_ILBM
#endif
#ifndef CONFIG_FBCON_PLANES
#define CONFIG_FBCON_PLANES
#endif
/* Cybervision Graphics Board */
#ifdef CONFIG_FB_CYBER
#ifndef CONFIG_FBCON_CYBER
#define CONFIG_FBCON_CYBER
#endif
#endif /* CONFIG_FB_CYBER */
#endif /* CONFIG_AMIGA */
/* Atari support */
#ifdef CONFIG_ATARI
#ifndef CONFIG_FBCON_2PLANE
#define CONFIG_FBCON_2PLANE
#endif
#ifndef CONFIG_FBCON_4PLANE
#define CONFIG_FBCON_4PLANE
#endif
#ifndef CONFIG_FBCON_8PLANE
#define CONFIG_FBCON_8PLANE
#endif
#ifndef CONFIG_FBCON_8PACKED
#define CONFIG_FBCON_8PACKED
#endif
#ifndef CONFIG_FBCON_16PACKED
#define CONFIG_FBCON_16PACKED
#endif
#endif /* CONFIG_ATARI */
/* Extra definitions to make the code more readable */
#if defined(CONFIG_FBCON_2PLANE) || defined(CONFIG_FBCON_4PLANE) || \
defined(CONFIG_FBCON_8PLANE)
#define CONFIG_FBCON_IPLAN2
#else
#undef CONFIG_FBCON_IPLAN2
#endif
#if defined(CONFIG_FBCON_CYBER) || defined(CONFIG_FBCON_8PACKED) || \
defined(CONFIG_FBCON_16PACKED) || defined(CONFIG_FBCON_24PACKED) || \
defined(CONFIG_FBCON_32PACKED)
#define CONFIG_FBCON_PACKED
#else
#undef CONFIG_FBCON_PACKED
#endif
struct fb_info *fb_info;
struct display *disp;
/* ++Geert: Sorry, no hardware cursor support at the moment;
use Atari alike software cursor */
static int cursor_drawn = 0;
#define CURSOR_DRAW_DELAY (2)
/* # VBL ints between cursor state changes */
#define AMIGA_CURSOR_BLINK_RATE (20)
#define ATARI_CURSOR_BLINK_RATE (42)
static int vbl_cursor_cnt = 0;
static int cursor_on = 0;
static int cursor_blink_rate;
static __inline__ int CURSOR_UNDRAWN(void)
{
int cursor_was_drawn;
vbl_cursor_cnt = 0;
cursor_was_drawn = cursor_drawn;
cursor_drawn = 0;
return(cursor_was_drawn);
}
/*
* Attribute Decoding
*/
/* Color */
#define attr_fgcol(p,conp) \
(((conp)->vc_attr >> ((p)->inverse ? 4 : 0)) & 0x0f)
#define attr_bgcol(p,conp) \
(((conp)->vc_attr >> ((p)->inverse ? 0 : 4)) & 0x0f)
#define attr_bgcol_ec(p,conp) \
(((conp)->vc_video_erase_char >> ((p)->inverse ? 8 : 12)) & 0x0f)
/* Monochrome */
#define attr_bold(p,conp) \
(((conp)->vc_attr & 3) == 2)
#define attr_reverse(p,conp) \
(((conp)->vc_attr & 8) ^ ((p)->inverse ? 8 : 0))
#define attr_underline(p,conp) \
(((conp)->vc_attr) & 4)
/*
* Scroll Method
*/
#define SCROLL_YWRAP (0)
#define SCROLL_YPAN (1)
#define SCROLL_YMOVE (2)
#define divides(a, b) ((!(a) || (b)%(a)) ? 0 : 1)
/*
* Interface used by the world
*/
static u_long fbcon_startup(u_long kmem_start, char **display_desc);
static void fbcon_init(struct vc_data *conp);
static int fbcon_deinit(struct vc_data *conp);
static int fbcon_changevar(int con);
static int fbcon_clear(struct vc_data *conp, int sy, int sx, int height,
int width);
static int fbcon_putc(struct vc_data *conp, int c, int y, int x);
static int fbcon_putcs(struct vc_data *conp, const char *s, int count, int y,
int x);
static int fbcon_cursor(struct vc_data *conp, int mode);
static int fbcon_scroll(struct vc_data *conp, int t, int b, int dir, int count);
static int fbcon_bmove(struct vc_data *conp, int sy, int sx, int dy, int dx,
int height, int width);
static int fbcon_switch(struct vc_data *conp);
static int fbcon_blank(int blank);
/*
* Internal routines
*/
static void fbcon_setup(int con, int setcol, int cls);
static __inline__ void *mymemclear_small(void *s, size_t count);
static __inline__ void *mymemclear(void *s, size_t count);
static __inline__ void *mymemset(void *s, size_t count);
static __inline__ void *mymemmove(void *d, void *s, size_t count);
static __inline__ void fast_memmove(char *dst, char *src, size_t size);
static __inline__ void memclear_4p_col(void *d, size_t h, u_long val, int bpr);
static __inline__ void memset_even_4p(void *d, size_t count, u_long val1,
u_long val2);
static __inline__ void memmove_4p_col(void *d, void *s, int h, int bpr);
static __inline__ u_long expand4l(u_char c);
static __inline__ void expand4dl(u_char c, u_long *ret1, u_long *ret2);
static __inline__ u_long dup4l(u_char c);
static __inline__ void memclear_8p_col(void *d, size_t h, u_long val1,
u_long val2, int bpr);
static __inline__ void memset_even_8p(void *d, size_t count, u_long val1,
u_long val2, u_long val3, u_long val4);
static __inline__ void memmove_8p_col(void *d, void *s, int h, int bpr);
static __inline__ void expand8dl(u_char c, u_long *ret1, u_long *ret2);
static __inline__ void memclear_2p_col(void *d, size_t h, u_short val, int bpr);
static __inline__ void memset_even_2p(void *d, size_t count, u_long val);
static __inline__ void memmove_2p_col(void *d, void *s, int h, int bpr);
static __inline__ u_short expand2w(u_char c);
static __inline__ u_long expand2l(u_char c);
static __inline__ u_short dup2w(u_char c);
static __inline__ int real_y(struct display *p, int y);
static void fbcon_vbl_handler(int irq, struct pt_regs *fp, void *dummy);
static void fbcon_bmove_rec(struct display *p, int sy, int sx, int dy, int dx,
int height, int width, u_int y_break);
/*
* Monochrome
*/
#ifdef CONFIG_FBCON_MONO
static void bmove_mono(struct display *p, int sy, int sx, int dy, int dx,
int height, int width);
static void clear_mono(struct vc_data *conp, struct display *p, int sy, int sx,
int height, int width);
static void putc_mono(struct vc_data *conp, struct display *p, int c, int y,
int x);
static void putcs_mono(struct vc_data *conp, struct display *p, const char *s,
int count, int y, int x);
static void rev_char_mono(struct display *p, int x, int y);
#endif /* CONFIG_FBCON_MONO */
/*
* Color Interleaved Planes
*/
#ifdef CONFIG_FBCON_ILBM
static void bmove_ilbm(struct display *p, int sy, int sx, int dy, int dx,
int height, int width);
static void clear_ilbm(struct vc_data *conp, struct display *p, int sy, int sx,
int height, int width);
static void putc_ilbm(struct vc_data *conp, struct display *p, int c, int y,
int x);
static void putcs_ilbm(struct vc_data *conp, struct display *p, const char *s,
int count, int y, int x);
static void rev_char_ilbm(struct display *p, int x, int y);
#endif /* CONFIG_FBCON_ILBM */
/*
* Color Planes
*/
#ifdef CONFIG_FBCON_PLANES
static void bmove_plan(struct display *p, int sy, int sx, int dy, int dx,
int height, int width);
static void clear_plan(struct vc_data *conp, struct display *p, int sy, int sx,
int height, int width);
static void putc_plan(struct vc_data *conp, struct display *p, int c, int y,
int x);
static void putcs_plan(struct vc_data *conp, struct display *p, const char *s,
int count, int y, int x);
static void rev_char_plan(struct display *p, int x, int y);
#endif /* CONFIG_FBCON_PLANES */
/*
* 2 Planes (2-bytes interleave)
*/
#ifdef CONFIG_FBCON_2PLANE
static void bmove_2_plane(struct display *p, int sy, int sx, int dy, int dx,
int height, int width);
static void clear_2_plane(struct vc_data *conp, struct display *p, int sy,
int sx, int height, int width);
static void putc_2_plane(struct vc_data *conp, struct display *p, int c, int y,
int x);
static void putcs_2_plane(struct vc_data *conp, struct display *p,
const char *s, int count, int y, int x);
static void rev_char_2_plane(struct display *display, int x, int y);
#endif /* CONFIG_FBCON_2PLANE */
/*
* 4 Planes (2-bytes interleave)
*/
#ifdef CONFIG_FBCON_4PLANE
static void bmove_4_plane(struct display *p, int sy, int sx, int dy, int dx,
int height, int width);
static void clear_4_plane(struct vc_data *conp, struct display *p, int sy,
int sx, int height, int width);
static void putc_4_plane(struct vc_data *conp, struct display *p, int c, int y,
int x);
static void putcs_4_plane(struct vc_data *conp, struct display *p,
const char *s, int count, int y, int x);
static void rev_char_4_plane(struct display *p, int x, int y);
#endif /* CONFIG_FBCON_4PLANE */
/*
* 8 Planes (2-bytes interleave)
*/
#ifdef CONFIG_FBCON_8PLANE
static void bmove_8_plane(struct display *p, int sy, int sx, int dy, int dx,
int height, int width);
static void clear_8_plane(struct vc_data *conp, struct display *p, int sy,
int sx, int height, int width);
static void putc_8_plane(struct vc_data *conp, struct display *p, int c, int y,
int x);
static void putcs_8_plane(struct vc_data *conp, struct display *p,
const char *s, int count, int y, int x);
static void rev_char_8_plane(struct display *display, int x, int y);
#endif /* CONFIG_FBCON_8PLANE */
/*
* 8 bpp Packed Pixels
*/
#ifdef CONFIG_FBCON_8PACKED
static void bmove_8_packed(struct display *p, int sy, int sx, int dy, int dx,
int height, int width);
static void clear_8_packed(struct vc_data *conp, struct display *p, int sy,
int sx, int height, int width);
static void putc_8_packed(struct vc_data *conp, struct display *p, int c, int y,
int x);
static void putcs_8_packed(struct vc_data *conp, struct display *p,
const char *s, int count, int y, int x);
static void rev_char_8_packed(struct display *p, int x, int y);
#endif /* CONFIG_FBCON_8PACKED */
/*
* 16 bpp Packed Pixels
*/
#ifdef CONFIG_FBCON_16PACKED
static void bmove_16_packed(struct display *p, int sy, int sx, int dy, int dx,
int height, int width);
static void clear_16_packed(struct vc_data *conp, struct display *p, int sy,
int sx, int height, int width);
static void putc_16_packed(struct vc_data *conp, struct display *p, int c,
int y, int x);
static void putcs_16_packed(struct vc_data *conp, struct display *p,
const char *s, int count, int y, int x);
static void rev_char_16_packed(struct display *p, int x, int y);
#endif */ CONFIG_FBCON_8PACKED */
/*
* Cybervision (accelerated)
*/
#ifdef CONFIG_FBCON_CYBER
static void bmove_cyber(struct display *p, int sy, int sx, int dy, int dx,
int height, int width);
static void clear_cyber(struct vc_data *conp, struct display *p, int sy, int sx,
int height, int width);
static void putc_cyber(struct vc_data *conp, struct display *p, int c, int y,
int x);
static void putcs_cyber(struct vc_data *conp, struct display *p, const char *s,
int count, int y, int x);
static void rev_char_cyber(struct display *p, int x, int y);
extern void Cyber_WaitQueue(u_short fifo);
extern void Cyber_WaitBlit(void);
extern void Cyber_BitBLT(u_short curx, u_short cury, u_short destx,
u_short desty, u_short width, u_short height,
u_short mode);
extern void Cyber_RectFill(u_short x, u_short y, u_short width, u_short height,
u_short mode, u_short color);
extern void Cyber_MoveCursor(u_short x, u_short y);
#endif /* CONFIG_FBCON_CYBER */
/*
* `switch' for the Low Level Operations
*/
struct display_switch {
void (*bmove)(struct display *p, int sy, int sx, int dy, int dx, int height,
int width);
void (*clear)(struct vc_data *conp, struct display *p, int sy, int sx,
int height, int width);
void (*putc)(struct vc_data *conp, struct display *p, int c, int y, int x);
void (*putcs)(struct vc_data *conp, struct display *p, const char *s,
int count, int y, int x);
void (*rev_char)(struct display *p, int x, int y);
};
#ifdef CONFIG_FBCON_MONO
struct display_switch dispsw_mono = {
bmove_mono, clear_mono, putc_mono, putcs_mono, rev_char_mono
};
#endif /* CONFIG_FBCON_MONO */
#ifdef CONFIG_FBCON_ILBM
struct display_switch dispsw_ilbm = {
bmove_ilbm, clear_ilbm, putc_ilbm, putcs_ilbm, rev_char_ilbm
};
#endif /* CONFIG_FBCON_ILBM */
#ifdef CONFIG_FBCON_PLANES
struct display_switch dispsw_plan = {
bmove_plan, clear_plan, putc_plan, putcs_plan, rev_char_plan
};
#endif /* CONFIG_FBCON_PLANES */
#ifdef CONFIG_FBCON_2PLANE
struct display_switch dispsw_2_plane = {
bmove_2_plane, clear_2_plane, putc_2_plane, putcs_2_plane, rev_char_2_plane
};
#endif /* CONFIG_FBCON_2PLANE */
#ifdef CONFIG_FBCON_4PLANE
struct display_switch dispsw_4_plane = {
bmove_4_plane, clear_4_plane, putc_4_plane, putcs_4_plane, rev_char_4_plane
};
#endif /* CONFIG_FBCON_4PLANE */
#ifdef CONFIG_FBCON_8PLANE
struct display_switch dispsw_8_plane = {
bmove_8_plane, clear_8_plane, putc_8_plane, putcs_8_plane, rev_char_8_plane
};
#endif /* CONFIG_FBCON_8PLANE */
#ifdef CONFIG_FBCON_8PACKED
struct display_switch dispsw_8_packed = {
bmove_8_packed, clear_8_packed, putc_8_packed, putcs_8_packed, rev_char_8_packed
};
#endif /* CONFIG_FBCON_8PACKED */
#ifdef CONFIG_FBCON_16PACKED
struct display_switch dispsw_16_packed = {
bmove_16_packed, clear_16_packed, putc_16_packed, putcs_16_packed,
rev_char_16_packed
};
#endif /* CONFIG_FBCON_16PACKED */
#ifdef CONFIG_FBCON_CYBER
struct display_switch dispsw_cyber = {
bmove_cyber, clear_cyber, putc_cyber, putcs_cyber, rev_char_cyber
};
#endif /* CONFIG_FBCON_CYBER */
static u_long fbcon_startup(u_long kmem_start, char **display_desc)
{
int irqres = 0;
fb_info = mach_fb_init(&kmem_start);
disp = fb_info->disp;
*display_desc = fb_info->modename;
fb_info->changevar = &fbcon_changevar;
#ifdef CONFIG_AMIGA
if (MACH_IS_AMIGA) {
cursor_blink_rate = AMIGA_CURSOR_BLINK_RATE;
irqres = add_isr(IRQ_AMIGA_VERTB, fbcon_vbl_handler, 0, NULL,
"console/cursor");
}
#endif /* CONFIG_AMIGA */
#ifdef CONFIG_ATARI
if (MACH_IS_ATARI) {
cursor_blink_rate = ATARI_CURSOR_BLINK_RATE;
irqres = add_isr(IRQ_AUTO_4, fbcon_vbl_handler, IRQ_TYPE_PRIO, NULL,
"console/cursor");
}
#endif /* CONFIG_ATARI */
if (!irqres)
panic("fbcon_startup: Couldn't add vblank interrupt");
return(kmem_start);
}
static void fbcon_init(struct vc_data *conp)
{
int unit = conp->vc_num;
if (unit)
disp[unit] = disp[0];
disp[unit].conp = conp;
fbcon_setup(unit, 1, 0);
}
static int fbcon_deinit(struct vc_data *conp)
{
disp[conp->vc_num].conp = 0;
return(0);
}
static int fbcon_changevar(int con)
{
fbcon_setup(con, 1, 1);
return(0);
}
static void fbcon_setup(int con, int setcol, int cls)
{
struct display *p = &disp[con];
struct vc_data *conp = p->conp;
p->var.xoffset = p->var.yoffset = p->yscroll = 0; /* reset wrap/pan */
if (!fb_info->fontname[0] ||
!findsoftfont(fb_info->fontname, &p->fontwidth, &p->fontheight,
&p->fontdata) || p->fontwidth != 8)
getdefaultfont(p->var.xres, p->var.yres, NULL, &p->fontwidth,
&p->fontheight, &p->fontdata);
if (p->fontwidth != 8)
panic("fbcon_setup: No support for fontwidth != 8");
if (divides(p->ywrapstep, p->fontheight) && divides(p->fontheight, p->var.yres_virtual))
p->scrollmode = SCROLL_YWRAP;
else if (divides(p->ypanstep, p->fontheight) &&
p->var.yres_virtual >= p->var.yres+p->fontheight)
p->scrollmode = SCROLL_YPAN;
else
p->scrollmode = SCROLL_YMOVE;
conp->vc_cols = p->var.xres/p->fontwidth;
conp->vc_rows = p->var.yres/p->fontheight;
p->vrows = p->var.yres_virtual/p->fontheight;
conp->vc_can_do_color = p->var.bits_per_pixel != 1;
#ifdef CONFIG_FBCON_MONO
if (p->var.bits_per_pixel == 1) {
if (p->line_length)
p->next_line = p->line_length;
else
p->next_line = p->var.xres_virtual>>3;
p->next_plane = 0;
p->dispsw = &dispsw_mono;
} else
#endif /* CONFIG_FBCON_MONO */
#ifdef CONFIG_FBCON_IPLAN2
if (p->type == FB_TYPE_INTERLEAVED_PLANES && p->type_aux == 2) {
p->next_line = p->var.xres_virtual*p->var.bits_per_pixel>>3;
p->next_plane = 0;
#ifdef CONFIG_FBCON_2PLANE
if (p->var.bits_per_pixel == 2)
p->dispsw = &dispsw_2_plane;
else
#endif /* CONFIG_FBCON_2PLANE */
#ifdef CONFIG_FBCON_4PLANE
if (p->var.bits_per_pixel == 4)
p->dispsw = &dispsw_4_plane;
else
#endif /* CONFIG_FBCON_4PLANE */
#ifdef CONFIG_FBCON_8PLANE
if (p->var.bits_per_pixel == 8)
p->dispsw = &dispsw_8_plane;
else
#endif /* CONFIG_FBCON_8PLANE */
goto fail;
} else
#endif /* CONFIG_FBCON_IPLAN2 */
#ifdef CONFIG_FBCON_ILBM
if (p->type == FB_TYPE_INTERLEAVED_PLANES && p->type_aux != 2) {
if (p->line_length) {
p->next_line = p->line_length*p->var.bits_per_pixel;
p->next_plane = p->line_length;
} else {
p->next_line = p->type_aux;
p->next_plane = p->type_aux/p->var.bits_per_pixel;
}
p->dispsw = &dispsw_ilbm;
} else
#endif /* CONFIG_FBCON_ILBM */
#ifdef CONFIG_FBCON_PLANES
if (p->type == FB_TYPE_PLANES) {
if (p->line_length)
p->next_line = p->line_length;
else
p->next_line = p->var.xres_virtual>>3;
p->next_plane = p->var.yres_virtual*p->next_line;
p->dispsw = &dispsw_plan;
} else
#endif /* CONFIG_FBCON_PLANES */
#ifdef CONFIG_FBCON_PACKED
if (p->type == FB_TYPE_PACKED_PIXELS) {
p->next_line = p->var.xres_virtual*p->var.bits_per_pixel>>3;
p->next_plane = 0;
#ifdef CONFIG_FBCON_CYBER
if (p->var.accel == FB_ACCEL_CYBERVISION)
p->dispsw = &dispsw_cyber;
else
#endif /* CONFIG_FBCON_CYBER */
#ifdef CONFIG_FBCON_8PACKED
if (p->var.bits_per_pixel == 8)
p->dispsw = &dispsw_8_packed;
else
#endif /* CONFIG_FBCON_8PACKED */
#ifdef CONFIG_FBCON_16PACKED
if (p->var.bits_per_pixel == 16)
p->dispsw = &dispsw_16_packed;
else
#endif /* CONFIG_FBCON_16PACKED */
#ifdef CONFIG_FBCON_24PACKED
if (p->var.bits_per_pixel == 24)
p->dispsw = &dispsw_24_packed;
else
#endif /* CONFIG_FBCON_24PACKED */
#ifdef CONFIG_FBCON_32PACKED
if (p->var.bits_per_pixel == 32)
p->dispsw = &dispsw_32_packed;
else
#endif /* CONFIG_FBCON_32PACKED */
goto fail;
} else
#endif /* CONFIG_FBCON_PACKED */
{
fail:
#ifdef CONFIG_FBCON_MONO
printk("fbcon_setup: type %d (aux %d) not supported, trying mono\n",
p->type, p->type_aux);
if (p->line_length)
p->next_line = p->line_length;
else
p->next_line = p->var.xres_virtual>>3;
p->next_plane = 0;
p->var.bits_per_pixel = 1;
p->dispsw = &dispsw_mono;
#else /* CONFIG_FBCON_MONO */
panic("fbcon_setup: no default driver");
#endif /* CONFIG_FBCON_MONO */
}
if (setcol) {
p->fgcol = p->var.bits_per_pixel > 2 ? 7 : (1<<p->var.bits_per_pixel)-1;
p->bgcol = 0;
}
if (cls)
vc_resize_con(conp->vc_rows, conp->vc_cols, con);
}
/* ================================================================= */
/* Utility Assembler Functions */
/* ================================================================= */
/* ====================================================================== */
/* Those of a delicate disposition might like to skip the next couple of
* pages.
*
* These functions are drop in replacements for memmove and
* memset(_, 0, _). However their five instances add at least a kilobyte
* to the object file. You have been warned.
*
* Not a great fan of assembler for the sake of it, but I think
* that these routines are at least 10 times faster than their C
* equivalents for large blits, and that's important to the lowest level of
* a graphics driver. Question is whether some scheme with the blitter
* would be faster. I suspect not for simple text system - not much
* asynchrony.
*
* Code is very simple, just gruesome expansion. Basic strategy is to
* increase data moved/cleared at each step to 16 bytes to reduce
* instruction per data move overhead. movem might be faster still
* For more than 15 bytes, we try to align the write direction on a
* longword boundary to get maximum speed. This is even more gruesome.
* Unaligned read/write used requires 68020+ - think this is a problem?
*
* Sorry!
*/
/* ++roman: I've optimized Robert's original versions in some minor
* aspects, e.g. moveq instead of movel, let gcc choose the registers,
* use movem in some places...
* For other modes than 1 plane, lots of more such assembler functions
* were needed (e.g. the ones using movep or expanding color values).
*/
/* ++andreas: more optimizations:
subl #65536,d0 replaced by clrw d0; subql #1,d0 for dbcc
addal is faster than addaw
movep is rather expensive compared to ordinary move's
some functions rewritten in C for clarity, no speed loss */
static __inline__ void *mymemclear_small(void *s, size_t count)
{
if (!count)
return(0);
__asm__ __volatile__(
"lsrl #1,%1 ; jcc 1f ; moveb %2,%0@-\n\t"
"1: lsrl #1,%1 ; jcc 1f ; movew %2,%0@-\n\t"
"1: lsrl #1,%1 ; jcc 1f ; movel %2,%0@-\n\t"
"1: lsrl #1,%1 ; jcc 1f ; movel %2,%0@- ; movel %2,%0@-\n\t"
"1: subql #1,%1 ; jcs 3f\n\t"
"2: moveml %2/%3/%4/%5,%0@-\n\t"
"dbra %1,2b\n\t"
"3:"
: "=a" (s), "=d" (count)
: "d" (0), "d" (0), "d" (0), "d" (0),
"0" ((char *)s+count), "1" (count)
);
return(0);
}
static __inline__ void *mymemclear(void *s, size_t count)
{
if (!count)
return(0);
if (count < 16) {
__asm__ __volatile__(
"lsrl #1,%1 ; jcc 1f ; clrb %0@+\n\t"
"1: lsrl #1,%1 ; jcc 1f ; clrw %0@+\n\t"
"1: lsrl #1,%1 ; jcc 1f ; clrl %0@+\n\t"
"1: lsrl #1,%1 ; jcc 1f ; clrl %0@+ ; clrl %0@+\n\t"
"1:"
: "=a" (s), "=d" (count)
: "0" (s), "1" (count)
);
} else {
long tmp;
__asm__ __volatile__(
"movel %1,%2\n\t"
"lsrl #1,%2 ; jcc 1f ; clrb %0@+ ; subqw #1,%1\n\t"
"lsrl #1,%2 ; jcs 2f\n\t" /* %0 increased=>bit 2 switched*/
"clrw %0@+ ; subqw #2,%1 ; jra 2f\n\t"
"1: lsrl #1,%2 ; jcc 2f\n\t"
"clrw %0@+ ; subqw #2,%1\n\t"
"2: movew %1,%2; lsrl #2,%1 ; jeq 6f\n\t"
"lsrl #1,%1 ; jcc 3f ; clrl %0@+\n\t"
"3: lsrl #1,%1 ; jcc 4f ; clrl %0@+ ; clrl %0@+\n\t"
"4: subql #1,%1 ; jcs 6f\n\t"
"5: clrl %0@+; clrl %0@+ ; clrl %0@+ ; clrl %0@+\n\t"
"dbra %1,5b ; clrw %1; subql #1,%1; jcc 5b\n\t"
"6: movew %2,%1; btst #1,%1 ; jeq 7f ; clrw %0@+\n\t"
"7: ; btst #0,%1 ; jeq 8f ; clrb %0@+\n\t"
"8:"
: "=a" (s), "=d" (count), "=d" (tmp)
: "0" (s), "1" (count)
);
}
return(0);
}
static __inline__ void *mymemset(void *s, size_t count)
{
if (!count)
return(0);
__asm__ __volatile__(
"lsrl #1,%1 ; jcc 1f ; moveb %2,%0@-\n\t"
"1: lsrl #1,%1 ; jcc 1f ; movew %2,%0@-\n\t"
"1: lsrl #1,%1 ; jcc 1f ; movel %2,%0@-\n\t"
"1: lsrl #1,%1 ; jcc 1f ; movel %2,%0@- ; movel %2,%0@-\n\t"
"1: subql #1,%1 ; jcs 3f\n\t"
"2: moveml %2/%3/%4/%5,%0@-\n\t"
"dbra %1,2b\n\t"
"3:"
: "=a" (s), "=d" (count)
: "d" (-1), "d" (-1), "d" (-1), "d" (-1),
"0" ((char *) s + count), "1" (count)
);
return(0);
}
static __inline__ void *mymemmove(void *d, void *s, size_t count)
{
if (d < s) {
if (count < 16) {
__asm__ __volatile__(
"lsrl #1,%2 ; jcc 1f ; moveb %1@+,%0@+\n\t"
"1: lsrl #1,%2 ; jcc 1f ; movew %1@+,%0@+\n\t"
"1: lsrl #1,%2 ; jcc 1f ; movel %1@+,%0@+\n\t"
"1: lsrl #1,%2 ; jcc 1f ; movel %1@+,%0@+ ; movel %1@+,%0@+\n\t"
"1:"
: "=a" (d), "=a" (s), "=d" (count)
: "0" (d), "1" (s), "2" (count)
);
} else {
long tmp;
__asm__ __volatile__(
"movel %0,%3\n\t"
"lsrl #1,%3 ; jcc 1f ; moveb %1@+,%0@+ ; subqw #1,%2\n\t"
"lsrl #1,%3 ; jcs 2f\n\t" /* %0 increased=>bit 2 switched*/
"movew %1@+,%0@+ ; subqw #2,%2 ; jra 2f\n\t"
"1: lsrl #1,%3 ; jcc 2f\n\t"
"movew %1@+,%0@+ ; subqw #2,%2\n\t"
"2: movew %2,%-; lsrl #2,%2 ; jeq 6f\n\t"
"lsrl #1,%2 ; jcc 3f ; movel %1@+,%0@+\n\t"
"3: lsrl #1,%2 ; jcc 4f ; movel %1@+,%0@+ ; movel %1@+,%0@+\n\t"
"4: subql #1,%2 ; jcs 6f\n\t"
"5: movel %1@+,%0@+;movel %1@+,%0@+\n\t"
"movel %1@+,%0@+;movel %1@+,%0@+\n\t"
"dbra %2,5b ; clrw %2; subql #1,%2; jcc 5b\n\t"
"6: movew %+,%2; btst #1,%2 ; jeq 7f ; movew %1@+,%0@+\n\t"
"7: ; btst #0,%2 ; jeq 8f ; moveb %1@+,%0@+\n\t"
"8:"
: "=a" (d), "=a" (s), "=d" (count), "=d" (tmp)
: "0" (d), "1" (s), "2" (count)
);
}
} else {
if (count < 16) {
__asm__ __volatile__(
"lsrl #1,%2 ; jcc 1f ; moveb %1@-,%0@-\n\t"
"1: lsrl #1,%2 ; jcc 1f ; movew %1@-,%0@-\n\t"
"1: lsrl #1,%2 ; jcc 1f ; movel %1@-,%0@-\n\t"
"1: lsrl #1,%2 ; jcc 1f ; movel %1@-,%0@- ; movel %1@-,%0@-\n\t"
"1:"
: "=a" (d), "=a" (s), "=d" (count)
: "0" ((char *) d + count), "1" ((char *) s + count), "2" (count)
);
} else {
long tmp;
__asm__ __volatile__(
"movel %0,%3\n\t"
"lsrl #1,%3 ; jcc 1f ; moveb %1@-,%0@- ; subqw #1,%2\n\t"
"lsrl #1,%3 ; jcs 2f\n\t" /* %0 increased=>bit 2 switched*/
"movew %1@-,%0@- ; subqw #2,%2 ; jra 2f\n\t"
"1: lsrl #1,%3 ; jcc 2f\n\t"
"movew %1@-,%0@- ; subqw #2,%2\n\t"
"2: movew %2,%-; lsrl #2,%2 ; jeq 6f\n\t"
"lsrl #1,%2 ; jcc 3f ; movel %1@-,%0@-\n\t"
"3: lsrl #1,%2 ; jcc 4f ; movel %1@-,%0@- ; movel %1@-,%0@-\n\t"
"4: subql #1,%2 ; jcs 6f\n\t"
"5: movel %1@-,%0@-;movel %1@-,%0@-\n\t"
"movel %1@-,%0@-;movel %1@-,%0@-\n\t"
"dbra %2,5b ; clrw %2; subql #1,%2; jcc 5b\n\t"
"6: movew %+,%2; btst #1,%2 ; jeq 7f ; movew %1@-,%0@-\n\t"
"7: ; btst #0,%2 ; jeq 8f ; moveb %1@-,%0@-\n\t"
"8:"
: "=a" (d), "=a" (s), "=d" (count), "=d" (tmp)
: "0" ((char *) d + count), "1" ((char *) s + count), "2" (count)
);
}
}
return(0);
}
/* ++andreas: Simple and fast version of memmove, assumes size is
divisible by 16, suitable for moving the whole screen bitplane */
static __inline__ void fast_memmove(char *dst, char *src, size_t size)
{
if (!size)
return;
if (dst < src)
__asm__ __volatile__
("1:"
" moveml %0@+,%/d0/%/d1/%/a0/%/a1\n"
" moveml %/d0/%/d1/%/a0/%/a1,%1@\n"
" addql #8,%1; addql #8,%1\n"
" dbra %2,1b\n"
" clrw %2; subql #1,%2\n"
" jcc 1b"
: "=a" (src), "=a" (dst), "=d" (size)
: "0" (src), "1" (dst), "2" (size / 16 - 1)
: "d0", "d1", "a0", "a1", "memory");
else
__asm__ __volatile__
("1:"
" subql #8,%0; subql #8,%0\n"
" moveml %0@,%/d0/%/d1/%/a0/%/a1\n"
" moveml %/d0/%/d1/%/a0/%/a1,%1@-\n"
" dbra %2,1b\n"
" clrw %2; subql #1,%2\n"
" jcc 1b"
: "=a" (src), "=a" (dst), "=d" (size)
: "0" (src + size), "1" (dst + size), "2" (size / 16 - 1)
: "d0", "d1", "a0", "a1", "memory");
}
/* Sets the bytes in the visible column at d, height h, to the value
* val for a 4 plane screen. The the bis of the color in 'color' are
* moved (8 times) to the respective bytes. This means:
*
* for(h times; d += bpr)
* *d = (color & 1) ? 0xff : 0;
* *(d+2) = (color & 2) ? 0xff : 0;
* *(d+4) = (color & 4) ? 0xff : 0;
* *(d+6) = (color & 8) ? 0xff : 0;
*/
static __inline__ void memclear_4p_col(void *d, size_t h, u_long val, int bpr)
{
__asm__ __volatile__
("1: movepl %4,%0@(0)\n\t"
"addal %5,%0\n\t"
"dbra %1,1b"
: "=a" (d), "=d" (h)
: "0" (d), "1" (h - 1), "d" (val), "r" (bpr)
);
}
/* Sets a 4 plane region from 'd', length 'count' bytes, to the color
* in val1/val2. 'd' has to be an even address and count must be divisible
* by 8, because only whole words and all planes are accessed. I.e.:
*
* for(count/8 times)
* *d = *(d+1) = (color & 1) ? 0xff : 0;
* *(d+2) = *(d+3) = (color & 2) ? 0xff : 0;
* *(d+4) = *(d+5) = (color & 4) ? 0xff : 0;
* *(d+6) = *(d+7) = (color & 8) ? 0xff : 0;
*/
static __inline__ void memset_even_4p(void *d, size_t count, u_long val1,
u_long val2)
{
u_long *dd = d;
count /= 8;
while (count--)
{
*dd++ = val1;
*dd++ = val2;
}
}
/* Copies a 4 plane column from 's', height 'h', to 'd'. */
static __inline__ void memmove_4p_col (void *d, void *s, int h, int bpr)
{
u_char *dd = d, *ss = s;
while (h--)
{
dd[0] = ss[0];
dd[2] = ss[2];
dd[4] = ss[4];
dd[6] = ss[6];
dd += bpr;
ss += bpr;
}
}
/* This expands a 4 bit color into a long for movepl (4 plane) operations. */
static __inline__ u_long expand4l(u_char c)
{
u_long rv;
__asm__ __volatile__
("lsrb #1,%2\n\t"
"scs %0\n\t"
"lsll #8,%0\n\t"
"lsrb #1,%2\n\t"
"scs %0\n\t"
"lsll #8,%0\n\t"
"lsrb #1,%2\n\t"
"scs %0\n\t"
"lsll #8,%0\n\t"
"lsrb #1,%2\n\t"
"scs %0\n\t"
: "=&d" (rv), "=d" (c)
: "1" (c)
);
return(rv);
}
/* This expands a 4 bit color into two longs for two movel operations
* (4 planes).
*/
static __inline__ void expand4dl(u_char c, u_long *ret1, u_long *ret2)
{
u_long rv1, rv2;
__asm__ __volatile__
("lsrb #1,%3\n\t"
"scs %0\n\t"
"extw %0\n\t"
"swap %0\n\t"
"lsrb #1,%3\n\t"
"scs %0\n\t"
"extw %0\n\t"
"lsrb #1,%3\n\t"
"scs %1\n\t"
"extw %1\n\t"
"swap %1\n\t"
"lsrb #1,%3\n\t"
"scs %1\n\t"
"extw %1"
: "=&d" (rv1), "=&d" (rv2), "=d" (c)
: "2" (c)
);
*ret1 = rv1;
*ret2 = rv2;
}
/* This duplicates a byte 4 times into a long. */
static __inline__ u_long dup4l(u_char c)
{
ushort tmp;
ulong rv;
__asm__ __volatile__
("moveb %2,%0\n\t"
"lslw #8,%0\n\t"
"moveb %2,%0\n\t"
"movew %0,%1\n\t"
"swap %0\n\t"
"movew %1,%0"
: "=&d" (rv), "=d" (tmp)
: "d" (c)
);
return(rv);
}
/* Sets the bytes in the visible column at d, height h, to the value
* val1,val2 for a 8 plane screen. The the bis of the color in 'color' are
* moved (8 times) to the respective bytes. This means:
*
* for(h times; d += bpr)
* *d = (color & 1) ? 0xff : 0;
* *(d+2) = (color & 2) ? 0xff : 0;
* *(d+4) = (color & 4) ? 0xff : 0;
* *(d+6) = (color & 8) ? 0xff : 0;
* *(d+8) = (color & 16) ? 0xff : 0;
* *(d+10) = (color & 32) ? 0xff : 0;
* *(d+12) = (color & 64) ? 0xff : 0;
* *(d+14) = (color & 128) ? 0xff : 0;
*/
static __inline__ void memclear_8p_col(void *d, size_t h, u_long val1,
u_long val2, int bpr)
{
__asm__ __volatile__
("1: movepl %4,%0@(0)\n\t"
"movepl %5,%0@(8)\n\t"
"addal %6,%0\n\t"
"dbra %1,1b"
: "=a" (d), "=d" (h)
: "0" (d), "1" (h - 1), "d" (val1), "d" (val2), "r" (bpr)
);
}
/* Sets a 8 plane region from 'd', length 'count' bytes, to the color
* val1..val4. 'd' has to be an even address and count must be divisible
* by 16, because only whole words and all planes are accessed. I.e.:
*
* for(count/16 times)
* *d = *(d+1) = (color & 1) ? 0xff : 0;
* *(d+2) = *(d+3) = (color & 2) ? 0xff : 0;
* *(d+4) = *(d+5) = (color & 4) ? 0xff : 0;
* *(d+6) = *(d+7) = (color & 8) ? 0xff : 0;
* *(d+8) = *(d+9) = (color & 16) ? 0xff : 0;
* *(d+10) = *(d+11) = (color & 32) ? 0xff : 0;
* *(d+12) = *(d+13) = (color & 64) ? 0xff : 0;
* *(d+14) = *(d+15) = (color & 128) ? 0xff : 0;
*/
static __inline__ void memset_even_8p(void *d, size_t count, u_long val1,
u_long val2, u_long val3, u_long val4)
{
u_long *dd = d;
count /= 16;
while (count--)
{
*dd++ = val1;
*dd++ = val2;
*dd++ = val3;
*dd++ = val4;
}
}
/* Copies a 8 plane column from 's', height 'h', to 'd'. */
static __inline__ void memmove_8p_col (void *d, void *s, int h, int bpr)
{
u_char *dd = d, *ss = s;
while (h--)
{
dd[0] = ss[0];
dd[2] = ss[2];
dd[4] = ss[4];
dd[6] = ss[6];
dd[8] = ss[8];
dd[10] = ss[10];
dd[12] = ss[12];
dd[14] = ss[14];
dd += bpr;
ss += bpr;
}
}
/* This expands a 8 bit color into two longs for two movepl (8 plane)
* operations.
*/
static __inline__ void expand8dl(u_char c, u_long *ret1, u_long *ret2)
{
u_long rv1, rv2;
__asm__ __volatile__
("lsrb #1,%3\n\t"
"scs %0\n\t"
"lsll #8,%0\n\t"
"lsrb #1,%3\n\t"
"scs %0\n\t"
"lsll #8,%0\n\t"
"lsrb #1,%3\n\t"
"scs %0\n\t"
"lsll #8,%0\n\t"
"lsrb #1,%3\n\t"
"scs %0\n\t"
"lsrb #1,%3\n\t"
"scs %1\n\t"
"lsll #8,%1\n\t"
"lsrb #1,%3\n\t"
"scs %1\n\t"
"lsll #8,%1\n\t"
"lsrb #1,%3\n\t"
"scs %1\n\t"
"lsll #8,%1\n\t"
"lsrb #1,%3\n\t"
"scs %1"
: "=&d" (rv1), "=&d" (rv2),"=d" (c)
: "2" (c)
);
*ret1 = rv1;
*ret2 = rv2;
}
/* This expands a 8 bit color into four longs for four movel operations
* (8 planes).
*/
/* ++andreas: use macro to avoid taking address of return values */
#define expand8ql(c, rv1, rv2, rv3, rv4) \
do { u_char tmp = c; \
__asm__ __volatile__ \
("lsrb #1,%5\n\t" \
"scs %0\n\t" \
"extw %0\n\t" \
"swap %0\n\t" \
"lsrb #1,%5\n\t" \
"scs %0\n\t" \
"extw %0\n\t" \
"lsrb #1,%5\n\t" \
"scs %1\n\t" \
"extw %1\n\t" \
"swap %1\n\t" \
"lsrb #1,%5\n\t" \
"scs %1\n\t" \
"extw %1\n\t" \
"lsrb #1,%5\n\t" \
"scs %2\n\t" \
"extw %2\n\t" \
"swap %2\n\t" \
"lsrb #1,%5\n\t" \
"scs %2\n\t" \
"extw %2\n\t" \
"lsrb #1,%5\n\t" \
"scs %3\n\t" \
"extw %3\n\t" \
"swap %3\n\t" \
"lsrb #1,%5\n\t" \
"scs %3\n\t" \
"extw %3" \
: "=&d" (rv1), "=&d" (rv2), "=&d" (rv3), \
"=&d" (rv4), "=d" (tmp) \
: "4" (tmp) \
); \
} while (0)
/* Sets the bytes in the visible column at d, height h, to the value
* val for a 2 plane screen. The the bis of the color in 'color' are
* moved (8 times) to the respective bytes. This means:
*
* for(h times; d += bpr)
* *d = (color & 1) ? 0xff : 0;
* *(d+2) = (color & 2) ? 0xff : 0;
*/
static __inline__ void memclear_2p_col(void *d, size_t h, u_short val, int bpr)
{
__asm__ __volatile__
("1: movepw %4,%0@(0)\n\t"
"addal %5,%0\n\t"
"dbra %1,1b"
: "=a" (d), "=d" (h)
: "0" (d), "1" (h - 1), "d" (val), "r" (bpr)
);
}
/* Sets a 2 plane region from 'd', length 'count' bytes, to the color
* in val1. 'd' has to be an even address and count must be divisible
* by 8, because only whole words and all planes are accessed. I.e.:
*
* for(count/4 times)
* *d = *(d+1) = (color & 1) ? 0xff : 0;
* *(d+2) = *(d+3) = (color & 2) ? 0xff : 0;
*/
static __inline__ void memset_even_2p(void *d, size_t count, u_long val)
{
u_long *dd = d;
count /= 4;
while (count--)
*dd++ = val;
}
/* Copies a 2 plane column from 's', height 'h', to 'd'. */
static __inline__ void memmove_2p_col (void *d, void *s, int h, int bpr)
{
u_char *dd = d, *ss = s;
while (h--)
{
dd[0] = ss[0];
dd[2] = ss[2];
dd += bpr;
ss += bpr;
}
}
/* This expands a 2 bit color into a short for movepw (2 plane) operations. */
static __inline__ u_short expand2w(u_char c)
{
u_short rv;
__asm__ __volatile__
("lsrb #1,%2\n\t"
"scs %0\n\t"
"lsll #8,%0\n\t"
"lsrb #1,%2\n\t"
"scs %0\n\t"
: "=&d" (rv), "=d" (c)
: "1" (c)
);
return(rv);
}
/* This expands a 2 bit color into one long for a movel operation
* (2 planes).
*/
static __inline__ u_long expand2l(u_char c)
{
u_long rv;
__asm__ __volatile__
("lsrb #1,%2\n\t"
"scs %0\n\t"
"extw %0\n\t"
"swap %0\n\t"
"lsrb #1,%2\n\t"
"scs %0\n\t"
"extw %0\n\t"
: "=&d" (rv), "=d" (c)
: "1" (c)
);
return rv;
}
/* This duplicates a byte 2 times into a short. */
static __inline__ u_short dup2w(u_char c)
{
ushort rv;
__asm__ __volatile__
( "moveb %1,%0\n\t"
"lslw #8,%0\n\t"
"moveb %1,%0\n\t"
: "=&d" (rv)
: "d" (c)
);
return( rv );
}
/* ====================================================================== */
/* fbcon_XXX routines - interface used by the world
*
* This system is now divided into two levels because of complications
* caused by hardware scrolling. Top level functions:
*
* fbcon_bmove(), fbcon_clear(), fbcon_putc()
*
* handles y values in range [0, scr_height-1] that correspond to real
* screen positions. y_wrap shift means that first line of bitmap may be
* anywhere on this display. These functions convert lineoffsets to
* bitmap offsets and deal with the wrap-around case by splitting blits.
*
* fbcon_bmove_physical_8() -- These functions fast implementations
* fbcon_clear_physical_8() -- of original fbcon_XXX fns.
* fbcon_putc_physical_8() -- (fontwidth != 8) may be added later
*
* WARNING:
*
* At the moment fbcon_putc() cannot blit across vertical wrap boundary
* Implies should only really hardware scroll in rows. Only reason for
* restriction is simplicity & efficiency at the moment.
*/
static __inline__ int real_y(struct display *p, int y)
{
int rows = p->vrows;
y += p->yscroll;
return(y < rows ? y : y-rows);
}
static int fbcon_clear(struct vc_data *conp, int sy, int sx, int height,
int width)
{
int unit = conp->vc_num;
struct display *p = &disp[unit];
u_int y_break;
if (!p->can_soft_blank && console_blanked)
return(0);
if ((sy <= p->cursor_y) && (p->cursor_y < sy+height) &&
(sx <= p->cursor_x) && (p->cursor_x < sx+width))
CURSOR_UNDRAWN();
/* Split blits that cross physical y_wrap boundary */
y_break = p->vrows-p->yscroll;
if (sy < y_break && sy+height-1 >= y_break) {
u_int b = y_break-sy;
p->dispsw->clear(conp, p, real_y(p, sy), sx, b, width);
p->dispsw->clear(conp, p, real_y(p, sy+b), sx, height-b, width);
} else
p->dispsw->clear(conp, p, real_y(p, sy), sx, height, width);
return(0);
}
static int fbcon_putc(struct vc_data *conp, int c, int y, int x)
{
int unit = conp->vc_num;
struct display *p = &disp[unit];
if (!p->can_soft_blank && console_blanked)
return(0);
if ((p->cursor_x == x) && (p->cursor_y == y))
CURSOR_UNDRAWN();
p->dispsw->putc(conp, p, c, real_y(p, y), x);
return(0);
}
static int fbcon_putcs(struct vc_data *conp, const char *s, int count, int y,
int x)
{
int unit = conp->vc_num;
struct display *p = &disp[unit];
if (!p->can_soft_blank && console_blanked)
return(0);
if ((p->cursor_y == y) && (x <= p->cursor_x) && (p->cursor_x < x+count))
CURSOR_UNDRAWN();
p->dispsw->putcs(conp, p, s, count, real_y(p, y), x);
return(0);
}
static int fbcon_cursor(struct vc_data *conp, int mode)
{
int unit = conp->vc_num;
struct display *p = &disp[unit];
if (CURSOR_UNDRAWN ())
p->dispsw->rev_char(p, p->cursor_x, real_y(p, p->cursor_y));
p->cursor_x = conp->vc_x;
p->cursor_y = conp->vc_y;
switch (mode) {
case CM_ERASE:
cursor_on = 0;
break;
case CM_MOVE:
case CM_DRAW:
vbl_cursor_cnt = CURSOR_DRAW_DELAY;
cursor_on = 1;
break;
}
return(0);
}
static void fbcon_vbl_handler(int irq, struct pt_regs *fp, void *dummy)
{
struct display *p;
if (!cursor_on)
return;
if (vbl_cursor_cnt && --vbl_cursor_cnt == 0) {
/* Here no check is possible for console changing. The console
* switching code should set vbl_cursor_cnt to an appropriate value.
*/
p = &disp[fg_console];
p->dispsw->rev_char(p, p->cursor_x, real_y(p, p->cursor_y));
cursor_drawn ^= 1;
vbl_cursor_cnt = cursor_blink_rate;
}
}
static int fbcon_scroll(struct vc_data *conp, int t, int b, int dir, int count)
{
int unit = conp->vc_num;
struct display *p = &disp[unit];
if (!p->can_soft_blank && console_blanked)
return(0);
fbcon_cursor(conp, CM_ERASE);
/*
* ++Geert: Only use ywrap/ypan if the console is in text mode
*/
switch (dir) {
case SM_UP:
if (t == 0 && b == conp->vc_rows &&
vt_cons[unit]->vc_mode == KD_TEXT) {
if (count > conp->vc_rows) /* Maximum realistic size */
count = conp->vc_rows;
switch (p->scrollmode) {
case SCROLL_YWRAP:
p->yscroll += count;
if (p->yscroll >= p->vrows) /* Deal with wrap */
p->yscroll -= p->vrows;
p->var.xoffset = 0;
p->var.yoffset = p->yscroll*p->fontheight;
p->var.vmode |= FB_VMODE_YWRAP;
fb_info->updatevar(unit);
break;
case SCROLL_YPAN:
p->yscroll += count;
if (p->yscroll+conp->vc_rows > p->vrows) {
p->dispsw->bmove(p, p->yscroll, 0, 0, 0, b-count,
conp->vc_cols);
p->yscroll = 0;
}
p->var.xoffset = 0;
p->var.yoffset = p->yscroll*p->fontheight;
p->var.vmode &= ~FB_VMODE_YWRAP;
fb_info->updatevar(unit);
break;
case SCROLL_YMOVE:
p->dispsw->bmove(p, count, 0, 0, 0, b-count, conp->vc_cols);
break;
}
} else
fbcon_bmove(conp, t+count, 0, t, 0, b-t-count, conp->vc_cols);
fbcon_clear(conp, b-count, 0, count, conp->vc_cols);
break;
case SM_DOWN:
if (t == 0 && b == conp->vc_rows &&
vt_cons[unit]->vc_mode == KD_TEXT) {
if (count > conp->vc_rows) /* Maximum realistic size */
count = conp->vc_rows;
switch (p->scrollmode) {
case SCROLL_YWRAP:
p->yscroll -= count;
if (p->yscroll < 0) /* Deal with wrap */
p->yscroll += p->vrows;
p->var.xoffset = 0;
p->var.yoffset = p->yscroll*p->fontheight;
p->var.vmode |= FB_VMODE_YWRAP;
fb_info->updatevar(unit);
break;
case SCROLL_YPAN:
p->yscroll -= count;
if (p->yscroll < 0) {
p->yscroll = p->vrows-conp->vc_rows;
p->dispsw->bmove(p, 0, 0, p->yscroll+count, 0, b-count,
conp->vc_cols);
}
p->var.xoffset = 0;
p->var.yoffset = p->yscroll*p->fontheight;
p->var.vmode &= ~FB_VMODE_YWRAP;
fb_info->updatevar(unit);
break;
case SCROLL_YMOVE:
p->dispsw->bmove(p, 0, 0, count, 0, b-count, conp->vc_cols);
break;
}
} else
fbcon_bmove(conp, t, 0, t+count, 0, b-t-count, conp->vc_cols);
/* Fixed bmove() should end Arno's frustration with copying?
* Confucius says:
* Man who copies in wrong direction, end up with trashed data
*/
fbcon_clear(conp, t, 0, count, conp->vc_cols);
break;
case SM_LEFT:
fbcon_bmove(conp, 0, t+count, 0, t, conp->vc_rows, b-t-count);
fbcon_clear(conp, 0, b-count, conp->vc_rows, count);
break;
case SM_RIGHT:
fbcon_bmove(conp, 0, t, 0, t+count, conp->vc_rows, b-t-count);
fbcon_clear(conp, 0, t, conp->vc_rows, count);
break;
}
return(0);
}
static int fbcon_bmove(struct vc_data *conp, int sy, int sx, int dy, int dx,
int height, int width)
{
int unit = conp->vc_num;
struct display *p = &disp[unit];
if (!p->can_soft_blank && console_blanked)
return(0);
if (((sy <= p->cursor_y) && (p->cursor_y < sy+height) &&
(sx <= p->cursor_x) && (p->cursor_x < sx+width)) ||
((dy <= p->cursor_y) && (p->cursor_y < dy+height) &&
(dx <= p->cursor_x) && (p->cursor_x < dx+width)))
fbcon_cursor(conp, CM_ERASE);
/* Split blits that cross physical y_wrap case.
* Pathological case involves 4 blits, better to use recursive
* code rather than unrolled case
*
* Recursive invocations don't need to erase the cursor over and
* over again, so we use fbcon_bmove_rec()
*/
fbcon_bmove_rec(p, sy, sx, dy, dx, height, width, p->vrows-p->yscroll);
return(0);
}
static void fbcon_bmove_rec(struct display *p, int sy, int sx, int dy, int dx,
int height, int width, u_int y_break)
{
u_int b;
if (sy < y_break && sy+height > y_break) {
b = y_break-sy;
if (dy < sy) { /* Avoid trashing self */
fbcon_bmove_rec(p, sy, sx, dy, dx, b, width, y_break);
fbcon_bmove_rec(p, sy+b, sx, dy+b, dx, height-b, width, y_break);
} else {
fbcon_bmove_rec(p, sy+b, sx, dy+b, dx, height-b, width, y_break);
fbcon_bmove_rec(p, sy, sx, dy, dx, b, width, y_break);
}
return;
}
if (dy < y_break && dy+height > y_break) {
b = y_break-dy;
if (dy < sy) { /* Avoid trashing self */
fbcon_bmove_rec(p, sy, sx, dy, dx, b, width, y_break);
fbcon_bmove_rec(p, sy+b, sx, dy+b, dx, height-b, width, y_break);
} else {
fbcon_bmove_rec(p, sy+b, sx, dy+b, dx, height-b, width, y_break);
fbcon_bmove_rec(p, sy, sx, dy, dx, b, width, y_break);
}
return;
}
p->dispsw->bmove(p, real_y(p, sy), sx, real_y(p, dy), dx, height, width);
}
static int fbcon_switch(struct vc_data *conp)
{
if (fb_info && fb_info->switch_con)
(*fb_info->switch_con)(conp->vc_num);
return(0);
}
static int fbcon_blank(int blank)
{
struct display *p = &disp[fg_console];
fbcon_cursor(p->conp, blank ? CM_ERASE : CM_DRAW);
if (!p->can_soft_blank)
if (blank) {
if (p->visual == FB_VISUAL_MONO01)
mymemset(p->screen_base, p->var.xres_virtual*p->var.yres_virtual*
p->var.bits_per_pixel>>3);
else
mymemclear(p->screen_base, p->var.xres_virtual*p->var.yres_virtual*
p->var.bits_per_pixel>>3);
return(0);
} else {
/* Tell console.c that it has to restore the screen itself */
return(1);
}
(*fb_info->blank)(blank);
return(0);
}
static int fbcon_get_font(struct vc_data *conp, int *w, int *h, char *data)
{
int unit = conp->vc_num;
struct display *p = &disp[unit];
int i, size, alloc;
size = (p->fontwidth+7)/8 * p->fontheight * 256;
alloc = (*w+7)/8 * *h * 256;
*w = p->fontwidth;
*h = p->fontheight;
if (alloc < size)
/* allocation length not sufficient */
return( -ENAMETOOLONG );
if ((i = verify_area( VERIFY_WRITE, (void *)data, size )))
return i;
memcpy_tofs( data, p->fontdata, size );
return( 0 );
}
#define REFCOUNT(fd) (((int *)(fd))[-1])
static int fbcon_set_font(struct vc_data *conp, int w, int h, char *data)
{
int unit = conp->vc_num;
struct display *p = &disp[unit];
int i, size, userspace = 1, resize;
char *old_data = NULL, *new_data;
if (w < 0)
w = p->fontwidth;
if (h < 0)
h = p->fontheight;
if (w == 0) {
/* engage predefined font, name in 'data' */
char name[MAX_FONT_NAME+1];
if ((i = verify_area( VERIFY_READ, (void *)data, MAX_FONT_NAME )))
return i;
memcpy_fromfs( name, data, MAX_FONT_NAME );
name[sizeof(name)-1] = 0;
if (!findsoftfont( name, &w, &h, (u_char **)&data ))
return( -ENOENT );
userspace = 0;
}
else if (w == 1) {
/* copy font from some other console in 'h'*/
struct display *op;
if (h < 0 || !vc_cons_allocated( h ))
return( -ENOTTY );
if (h == unit)
return( 0 ); /* nothing to do */
op = &disp[h];
if (op->fontdata == p->fontdata)
return( 0 ); /* already the same font... */
resize = (op->fontwidth != p->fontwidth) ||
(op->fontheight != p->fontheight);
if (p->userfont)
old_data = p->fontdata;
p->fontdata = op->fontdata;
w = p->fontwidth = op->fontwidth;
h = p->fontheight = op->fontheight;
if ((p->userfont = op->userfont))
REFCOUNT(p->fontdata)++; /* increment usage counter */
goto activate;
}
if (w != 8)
/* Currently only fontwidth == 8 supported */
return( -ENXIO );
resize = (w != p->fontwidth) || (h != p->fontheight);
size = (w+7)/8 * h * 256;
if (p->userfont)
old_data = p->fontdata;
if (userspace) {
if ((i = verify_area( VERIFY_READ, (void *)data, size )))
return i;
if (!(new_data = kmalloc( sizeof(int)+size, GFP_USER )))
return( -ENOMEM );
new_data += sizeof(int);
REFCOUNT(new_data) = 1; /* usage counter */
memcpy_fromfs( new_data, data, size );
p->fontdata = new_data;
p->userfont = 1;
}
else {
p->fontdata = data;
p->userfont = 0;
}
p->fontwidth = w;
p->fontheight = h;
activate:
if (resize) {
p->var.xoffset = p->var.yoffset = p->yscroll = 0; /* reset wrap/pan */
if (divides(p->ywrapstep, p->fontheight))
p->scrollmode = SCROLL_YWRAP;
else if (divides(p->ypanstep, p->fontheight) &&
p->var.yres_virtual >= p->var.yres+p->fontheight)
p->scrollmode = SCROLL_YPAN;
else
p->scrollmode = SCROLL_YMOVE;
vc_resize_con( p->var.yres/h, p->var.xres/w, unit );
}
else if (unit == fg_console)
update_screen( unit );
if (old_data) {
if (--REFCOUNT(old_data) == 0) {
kfree( old_data - sizeof(int) );
}
}
return( 0 );
}
/* ====================================================================== */
/*
* Low Level Operations for the various display memory organizations.
*
* Currently only the following organizations are supported here:
*
* - Monochrome
* - Color Interleaved Planes à la Amiga
* - Color Normal Planes
* - Color Interleaved Planes à la Atari (2, 4 and 8 planes)
* - Color Packed Pixels (8 and 16 bpp)
* - Cybervision Color Packed Pixels (accelerated)
*/
#ifdef CONFIG_FBCON_MONO
/*
* Monochrome
*/
static void bmove_mono(struct display *p, int sy, int sx, int dy, int dx,
int height, int width)
{
u_char *src, *dest;
u_int rows;
if (sx == 0 && sy == 0 && width == p->next_line) {
src = p->screen_base;
dest = p->screen_base+dy*p->fontheight*width;
mymemmove(dest, src, height*p->fontheight*width);
} else if (dy <= sy) {
src = p->screen_base+sy*p->fontheight*p->next_line+sx;
dest = p->screen_base+dy*p->fontheight*p->next_line+dx;
for (rows = height*p->fontheight; rows--;) {
mymemmove(dest, src, width);
src += p->next_line;
dest += p->next_line;
}
} else {
src = p->screen_base+((sy+height)*p->fontheight-1)*p->next_line+sx;
dest = p->screen_base+((dy+height)*p->fontheight-1)*p->next_line+dx;
for (rows = height*p->fontheight; rows--;) {
mymemmove(dest, src, width);
src -= p->next_line;
dest -= p->next_line;
}
}
}
static void clear_mono(struct vc_data *conp, struct display *p, int sy, int sx,
int height, int width)
{
u_char *dest;
u_int rows;
dest = p->screen_base+sy*p->fontheight*p->next_line+sx;
if (sx == 0 && width == p->next_line)
if (attr_reverse(p,conp))
mymemset(dest, height*p->fontheight*width);
else
mymemclear(dest, height*p->fontheight*width);
else
for (rows = height*p->fontheight; rows--; dest += p->next_line)
if (attr_reverse(p,conp))
mymemset(dest, width);
else
mymemclear_small(dest, width);
}
static void putc_mono(struct vc_data *conp, struct display *p, int c, int y,
int x)
{
u_char *dest, *cdat;
u_int rows, bold, reverse, underline;
u_char d;
c &= 0xff;
dest = p->screen_base+y*p->fontheight*p->next_line+x;
cdat = p->fontdata+c*p->fontheight;
bold = attr_bold(p,conp);
reverse = attr_reverse(p,conp);
underline = attr_underline(p,conp);
for (rows = p->fontheight; rows--; dest += p->next_line) {
d = *cdat++;
if (underline && !rows)
d = 0xff;
else if (bold)
d |= d>>1;
if (reverse)
d = ~d;
*dest = d;
}
}
static void putcs_mono(struct vc_data *conp, struct display *p, const char *s,
int count, int y, int x)
{
u_char *dest, *dest0, *cdat;
u_int rows, bold, reverse, underline;
u_char c, d;
dest0 = p->screen_base+y*p->fontheight*p->next_line+x;
bold = attr_bold(p,conp);
reverse = attr_reverse(p,conp);
underline = attr_underline(p,conp);
while (count--) {
c = *s++;
dest = dest0++;
cdat = p->fontdata+c*p->fontheight;
for (rows = p->fontheight; rows--; dest += p->next_line) {
d = *cdat++;
if (underline && !rows)
d = 0xff;
else if (bold)
d |= d>>1;
if (reverse)
d = ~d;
*dest = d;
}
}
}
static void rev_char_mono(struct display *p, int x, int y)
{
u_char *dest;
u_int rows;
dest = p->screen_base+y*p->fontheight*p->next_line+x;
for (rows = p->fontheight; rows--; dest += p->next_line)
*dest = ~*dest;
}
#endif /* CONFIG_FBCON_MONO */
/* ====================================================================== */
#ifdef CONFIG_FBCON_ILBM
/*
* Color Interleaved Planes
*
* This code heavily relies on the fact that
*
* next_line == interleave == next_plane*bits_per_pixel
*
* But maybe it can be merged with the code for normal bitplanes without
* much performance loss?
*/
static void bmove_ilbm(struct display *p, int sy, int sx, int dy, int dx,
int height, int width)
{
if (sx == 0 && sy == 0 && width == p->next_plane)
mymemmove(p->screen_base+dy*p->fontheight*p->next_line, p->screen_base,
height*p->fontheight*p->next_line);
else {
u_char *src, *dest;
u_int i;
if (dy <= sy) {
src = p->screen_base+sy*p->fontheight*p->next_line+sx;
dest = p->screen_base+dy*p->fontheight*p->next_line+dx;
for (i = p->var.bits_per_pixel*height*p->fontheight; i--;) {
mymemmove(dest, src, width);
src += p->next_plane;
dest += p->next_plane;
}
} else {
src = p->screen_base+(sy+height)*p->fontheight*p->next_line+sx;
dest = p->screen_base+(dy+height)*p->fontheight*p->next_line+dx;
for (i = p->var.bits_per_pixel*height*p->fontheight; i--;) {
src -= p->next_plane;
dest -= p->next_plane;
mymemmove(dest, src, width);
}
}
}
}
static void clear_ilbm(struct vc_data *conp, struct display *p, int sy, int sx,
int height, int width)
{
u_char *dest;
u_int i, rows;
int bg, bg0;
dest = p->screen_base+sy*p->fontheight*p->next_line+sx;
bg0 = attr_bgcol_ec(p,conp);
for (rows = height*p->fontheight; rows--;) {
bg = bg0;
for (i = p->var.bits_per_pixel; i--; dest += p->next_plane) {
if (bg & 1)
mymemset(dest, width);
else
mymemclear(dest, width);
bg >>= 1;
}
}
}
static void putc_ilbm(struct vc_data *conp, struct display *p, int c, int y,
int x)
{
u_char *dest, *cdat;
u_int rows, i;
u_char d;
int fg0, bg0, fg, bg;
c &= 0xff;
dest = p->screen_base+y*p->fontheight*p->next_line+x;
cdat = p->fontdata+c*p->fontheight;
fg0 = attr_fgcol(p,conp);
bg0 = attr_bgcol(p,conp);
for (rows = p->fontheight; rows--;) {
d = *cdat++;
fg = fg0;
bg = bg0;
for (i = p->var.bits_per_pixel; i--; dest += p->next_plane) {
if (bg & 1)
if (fg & 1)
*dest = 0xff;
else
*dest = ~d;
else
if (fg & 1)
*dest = d;
else
*dest = 0x00;
bg >>= 1;
fg >>= 1;
}
}
}
/*
* I split the console character loop in two parts:
*
* - slow version: this blits one character at a time
*
* - fast version: this blits 4 characters at a time at a longword aligned
* address, to reduce the number of expensive Chip RAM
* accesses.
*
* Experiments on my A4000/040 revealed that this makes a console switch on a
* 640x400 screen with 256 colors about 3 times faster.
*
* Geert
*/
static void putcs_ilbm(struct vc_data *conp, struct display *p, const char *s,
int count, int y, int x)
{
u_char *dest0, *dest, *cdat1, *cdat2, *cdat3, *cdat4;
u_int rows, i;
u_char c1, c2, c3, c4;
u_long d;
int fg0, bg0, fg, bg;
dest0 = p->screen_base+y*p->fontheight*p->next_line+x;
fg0 = attr_fgcol(p,conp);
bg0 = attr_bgcol(p,conp);
while (count--)
if (x&3 || count < 3) { /* Slow version */
c1 = *s++;
dest = dest0++;
x++;
cdat1 = p->fontdata+c1*p->fontheight;
for (rows = p->fontheight; rows--;) {
d = *cdat1++;
fg = fg0;
bg = bg0;
for (i = p->var.bits_per_pixel; i--; dest += p->next_plane) {
if (bg & 1)
if (fg & 1)
*dest = 0xff;
else
*dest = ~d;
else
if (fg & 1)
*dest = d;
else
*dest = 0x00;
bg >>= 1;
fg >>= 1;
}
}
} else { /* Fast version */
c1 = s[0];
c2 = s[1];
c3 = s[2];
c4 = s[3];
dest = dest0;
cdat1 = p->fontdata+c1*p->fontheight;
cdat2 = p->fontdata+c2*p->fontheight;
cdat3 = p->fontdata+c3*p->fontheight;
cdat4 = p->fontdata+c4*p->fontheight;
for (rows = p->fontheight; rows--;) {
d = *cdat1++<<24 | *cdat2++<<16 | *cdat3++<<8 | *cdat4++;
fg = fg0;
bg = bg0;
for (i = p->var.bits_per_pixel; i--; dest += p->next_plane) {
if (bg & 1)
if (fg & 1)
*(u_long *)dest = 0xffffffff;
else
*(u_long *)dest = ~d;
else
if (fg & 1)
*(u_long *)dest = d;
else
*(u_long *)dest = 0x00000000;
bg >>= 1;
fg >>= 1;
}
}
s += 4;
dest0 += 4;
x += 4;
count -= 3;
}
}
static void rev_char_ilbm(struct display *p, int x, int y)
{
u_char *dest, *dest0;
u_int rows, i;
int mask;
dest0 = p->screen_base+y*p->fontheight*p->next_line+x;
mask = p->fgcol ^ p->bgcol;
/*
* This should really obey the individual character's
* background and foreground colors instead of simply
* inverting.
*/
for (i = p->var.bits_per_pixel; i--; dest0 += p->next_plane) {
if (mask & 1) {
dest = dest0;
for (rows = p->fontheight; rows--; dest += p->next_line)
*dest = ~*dest;
}
mask >>= 1;
}
}
#endif /* CONFIG_FBCON_ILBM */
/* ====================================================================== */
#ifdef CONFIG_FBCON_PLANES
/*
* Color Planes
*/
static void bmove_plan(struct display *p, int sy, int sx, int dy, int dx,
int height, int width)
{
u_char *src, *dest, *src0, *dest0;
u_int i, rows;
if (sx == 0 && sy == 0 && width == p->next_line) {
src = p->screen_base;
dest = p->screen_base+dy*p->fontheight*width;
for (i = p->var.bits_per_pixel; i--;) {
mymemmove(dest, src, height*p->fontheight*width);
src += p->next_plane;
dest += p->next_plane;
}
} else if (dy <= sy) {
src0 = p->screen_base+sy*p->fontheight*p->next_line+sx;
dest0 = p->screen_base+dy*p->fontheight*p->next_line+dx;
for (i = p->var.bits_per_pixel; i--;) {
src = src0;
dest = dest0;
for (rows = height*p->fontheight; rows--;) {
mymemmove(dest, src, width);
src += p->next_line;
dest += p->next_line;
}
src0 += p->next_plane;
dest0 += p->next_plane;
}
} else {
src0 = p->screen_base+(sy+height)*p->fontheight*p->next_line+sx;
dest0 = p->screen_base+(dy+height)*p->fontheight*p->next_line+dx;
for (i = p->var.bits_per_pixel; i--;) {
src = src0;
dest = dest0;
for (rows = height*p->fontheight; rows--;) {
src -= p->next_line;
dest -= p->next_line;
mymemmove(dest, src, width);
}
src0 += p->next_plane;
dest0 += p->next_plane;
}
}
}
static void clear_plan(struct vc_data *conp, struct display *p, int sy, int sx,
int height, int width)
{
u_char *dest, *dest0;
u_int i, rows;
int bg;
dest0 = p->screen_base+sy*p->fontheight*p->next_line+sx;
bg = attr_bgcol_ec(p,conp);
for (i = p->var.bits_per_pixel; i--; dest0 += p->next_plane) {
dest = dest0;
for (rows = height*p->fontheight; rows--; dest += p->next_line)
if (bg & 1)
mymemset(dest, width);
else
mymemclear(dest, width);
bg >>= 1;
}
}
static void putc_plan(struct vc_data *conp, struct display *p, int c, int y,
int x)
{
u_char *dest, *dest0, *cdat, *cdat0;
u_int rows, i;
u_char d;
int fg, bg;
c &= 0xff;
dest0 = p->screen_base+y*p->fontheight*p->next_line+x;
cdat0 = p->fontdata+c*p->fontheight;
fg = attr_fgcol(p,conp);
bg = attr_bgcol(p,conp);
for (i = p->var.bits_per_pixel; i--; dest0 += p->next_plane) {
dest = dest0;
cdat = cdat0;
for (rows = p->fontheight; rows--; dest += p->next_line) {
d = *cdat++;
if (bg & 1)
if (fg & 1)
*dest = 0xff;
else
*dest = ~d;
else
if (fg & 1)
*dest = d;
else
*dest = 0x00;
}
bg >>= 1;
fg >>= 1;
}
}
/*
* I split the console character loop in two parts
* (cfr. fbcon_putcs_ilbm())
*/
static void putcs_plan(struct vc_data *conp, struct display *p, const char *s,
int count, int y, int x)
{
u_char *dest, *dest0, *dest1;
u_char *cdat1, *cdat2, *cdat3, *cdat4, *cdat10, *cdat20, *cdat30, *cdat40;
u_int rows, i;
u_char c1, c2, c3, c4;
u_long d;
int fg0, bg0, fg, bg;
dest0 = p->screen_base+y*p->fontheight*p->next_line+x;
fg0 = attr_fgcol(p,conp);
bg0 = attr_bgcol(p,conp);
while (count--)
if (x&3 || count < 3) { /* Slow version */
c1 = *s++;
dest1 = dest0++;
x++;
cdat10 = p->fontdata+c1*p->fontheight;
fg = fg0;
bg = bg0;
for (i = p->var.bits_per_pixel; i--; dest1 += p->next_plane) {
dest = dest1;
cdat1 = cdat10;
for (rows = p->fontheight; rows--; dest += p->next_line) {
d = *cdat1++;
if (bg & 1)
if (fg & 1)
*dest = 0xff;
else
*dest = ~d;
else
if (fg & 1)
*dest = d;
else
*dest = 0x00;
}
bg >>= 1;
fg >>= 1;
}
} else { /* Fast version */
c1 = s[0];
c2 = s[1];
c3 = s[2];
c4 = s[3];
dest1 = dest0;
cdat10 = p->fontdata+c1*p->fontheight;
cdat20 = p->fontdata+c2*p->fontheight;
cdat30 = p->fontdata+c3*p->fontheight;
cdat40 = p->fontdata+c4*p->fontheight;
fg = fg0;
bg = bg0;
for (i = p->var.bits_per_pixel; i--; dest1 += p->next_plane) {
dest = dest1;
cdat1 = cdat10;
cdat2 = cdat20;
cdat3 = cdat30;
cdat4 = cdat40;
for (rows = p->fontheight; rows--; dest += p->next_line) {
d = *cdat1++<<24 | *cdat2++<<16 | *cdat3++<<8 | *cdat4++;
if (bg & 1)
if (fg & 1)
*(u_long *)dest = 0xffffffff;
else
*(u_long *)dest = ~d;
else
if (fg & 1)
*(u_long *)dest = d;
else
*(u_long *)dest = 0x00000000;
}
bg >>= 1;
fg >>= 1;
}
s += 4;
dest0 += 4;
x += 4;
count -= 3;
}
}
static void rev_char_plan(struct display *p, int x, int y)
{
u_char *dest, *dest0;
u_int rows, i;
int mask;
dest0 = p->screen_base+y*p->fontheight*p->next_line+x;
mask = p->fgcol ^ p->bgcol;
/*
* This should really obey the individual character's
* background and foreground colors instead of simply
* inverting.
*/
for (i = p->var.bits_per_pixel; i--; dest0 += p->next_plane) {
if (mask & 1) {
dest = dest0;
for (rows = p->fontheight; rows--; dest += p->next_line)
*dest = ~*dest;
}
mask >>= 1;
}
}
#endif /* CONFIG_FBCON_PLANES */
/* ====================================================================== */
#ifdef CONFIG_FBCON_2PLANE
/*
* 2 Planes (2-bytes interleave)
*/
/* Increment/decrement 2 plane addresses */
#define INC_2P(p) do { if (!((long)(++(p)) & 1)) (p) += 2; } while(0)
#define DEC_2P(p) do { if ((long)(--(p)) & 1) (p) -= 2; } while(0)
/* Convert a standard 4 bit color to our 2 bit color assignment:
* If at least two RGB channels are active, the low bit is turned on;
* The intensity bit (b3) is shifted into b1.
*/
#define COLOR_2P(c) (((c & 7) >= 3 && (c & 7) != 4) | (c & 8) >> 2)
static void bmove_2_plane(struct display *p, int sy, int sx, int dy, int dx,
int height, int width)
{
/* bmove() has to distinguish two major cases: If both, source and
* destination, start at even addresses or both are at odd
* addresses, just the first odd and last even column (if present)
* require special treatment (memmove_col()). The rest between
* then can be copied by normal operations, because all adjacent
* bytes are affected and are to be stored in the same order.
* The pathological case is when the move should go from an odd
* address to an even or vice versa. Since the bytes in the plane
* words must be assembled in new order, it seems wisest to make
* all movements by memmove_col().
*/
if (sx == 0 && dx == 0 && width == p->next_line/2) {
/* Special (but often used) case: Moving whole lines can be
* done with memmove()
*/
mymemmove(p->screen_base + dy * p->next_line * p->fontheight,
p->screen_base + sy * p->next_line * p->fontheight,
p->next_line * height * p->fontheight);
} else {
int rows, cols;
u_char *src;
u_char *dst;
int bytes = p->next_line;
int linesize = bytes * p->fontheight;
u_int colsize = height * p->fontheight;
u_int upwards = (dy < sy) || (dy == sy && dx < sx);
if ((sx & 1) == (dx & 1)) {
/* odd->odd or even->even */
if (upwards) {
src = p->screen_base + sy * linesize + (sx>>1)*4 + (sx & 1);
dst = p->screen_base + dy * linesize + (dx>>1)*4 + (dx & 1);
if (sx & 1) {
memmove_2p_col(dst, src, colsize, bytes);
src += 3;
dst += 3;
--width;
}
if (width > 1) {
for(rows = colsize; rows > 0; --rows) {
mymemmove(dst, src, (width>>1)*4);
src += bytes;
dst += bytes;
}
}
if (width & 1) {
src -= colsize * bytes;
dst -= colsize * bytes;
memmove_2p_col(dst + (width>>1)*4, src + (width>>1)*4,
colsize, bytes);
}
}
else {
if (!((sx+width-1) & 1)) {
src = p->screen_base + sy * linesize + ((sx+width-1)>>1)*4;
dst = p->screen_base + dy * linesize + ((dx+width-1)>>1)*4;
memmove_2p_col(dst, src, colsize, bytes);
--width;
}
src = p->screen_base + sy * linesize + (sx>>1)*4 + (sx & 1);
dst = p->screen_base + dy * linesize + (dx>>1)*4 + (dx & 1);
if (width > 1) {
src += colsize * bytes + (sx & 1)*3;
dst += colsize * bytes + (sx & 1)*3;
for(rows = colsize; rows > 0; --rows) {
src -= bytes;
dst -= bytes;
mymemmove(dst, src, (width>>1)*4);
}
}
if (width & 1) {
memmove_2p_col(dst-3, src-3, colsize, bytes);
}
}
}
else {
/* odd->even or even->odd */
if (upwards) {
src = p->screen_base + sy * linesize + (sx>>1)*4 + (sx & 1);
dst = p->screen_base + dy * linesize + (dx>>1)*4 + (dx & 1);
for(cols = width; cols > 0; --cols) {
memmove_2p_col(dst, src, colsize, bytes);
INC_2P(src);
INC_2P(dst);
}
}
else {
sx += width-1;
dx += width-1;
src = p->screen_base + sy * linesize + (sx>>1)*4 + (sx & 1);
dst = p->screen_base + dy * linesize + (dx>>1)*4 + (dx & 1);
for(cols = width; cols > 0; --cols) {
memmove_2p_col(dst, src, colsize, bytes);
DEC_2P(src);
DEC_2P(dst);
}
}
}
}
}
static void clear_2_plane(struct vc_data *conp, struct display *p, int sy,
int sx, int height, int width)
{
ulong offset;
u_char *start;
int rows;
int bytes = p->next_line;
int lines = height * p->fontheight;
ulong size;
u_long cval;
u_short pcval;
cval = expand2l (COLOR_2P (attr_bgcol_ec(p,conp)));
if (sx == 0 && width == bytes/2) {
offset = sy * bytes * p->fontheight;
size = lines * bytes;
memset_even_2p(p->screen_base+offset, size, cval);
} else {
offset = (sy * bytes * p->fontheight) + (sx>>1)*4 + (sx & 1);
start = p->screen_base + offset;
pcval = expand2w(COLOR_2P(attr_bgcol_ec(p,conp)));
/* Clears are split if the region starts at an odd column or
* end at an even column. These extra columns are spread
* across the interleaved planes. All in between can be
* cleared by normal mymemclear_small(), because both bytes of
* the single plane words are affected.
*/
if (sx & 1) {
memclear_2p_col(start, lines, pcval, bytes);
start += 3;
width--;
}
if (width & 1) {
memclear_2p_col(start + (width>>1)*4, lines, pcval, bytes);
width--;
}
if (width) {
for(rows = lines; rows-- ; start += bytes)
memset_even_2p(start, width*2, cval);
}
}
}
static void putc_2_plane(struct vc_data *conp, struct display *p, int c, int y,
int x)
{
u_char *dest;
u_char *cdat;
int rows;
int bytes = p->next_line;
ulong eorx, fgx, bgx, fdx;
c &= 0xff;
dest = p->screen_base + y * p->fontheight * bytes + (x>>1)*4 + (x & 1);
cdat = p->fontdata + (c * p->fontheight);
fgx = expand2w(COLOR_2P(attr_fgcol(p,conp)));
bgx = expand2w(COLOR_2P(attr_bgcol(p,conp)));
eorx = fgx ^ bgx;
for(rows = p->fontheight ; rows-- ; dest += bytes) {
fdx = dup2w(*cdat++);
__asm__ __volatile__ ("movepw %1,%0@(0)" : /* no outputs */
: "a" (dest), "d" ((fdx & eorx) ^ bgx));
}
}
static void putcs_2_plane(struct vc_data *conp, struct display *p,
const char *s, int count, int y, int x)
{
u_char *dest, *dest0;
u_char *cdat, c;
int rows;
int bytes;
ulong eorx, fgx, bgx, fdx;
bytes = p->next_line;
dest0 = p->screen_base + y * p->fontheight * bytes + (x>>1)*4 + (x & 1);
fgx = expand2w(COLOR_2P(attr_fgcol(p,conp)));
bgx = expand2w(COLOR_2P(attr_bgcol(p,conp)));
eorx = fgx ^ bgx;
while (count--) {
c = *s++;
cdat = p->fontdata + (c * p->fontheight);
for(rows = p->fontheight, dest = dest0; rows-- ; dest += bytes) {
fdx = dup2w(*cdat++);
__asm__ __volatile__ ("movepw %1,%0@(0)" : /* no outputs */
: "a" (dest), "d" ((fdx & eorx) ^ bgx));
}
INC_2P(dest0);
}
}
static void rev_char_2_plane(struct display *p, int x, int y)
{
u_char *dest;
int j;
int bytes;
dest = p->screen_base + y * p->fontheight * p->next_line + (x>>1)*4 + (x & 1);
j = p->fontheight;
bytes = p->next_line;
while (j--)
{
/* This should really obey the individual character's
* background and foreground colors instead of simply
* inverting.
*/
dest[0] = ~dest[0];
dest[2] = ~dest[2];
dest += bytes;
}
}
#endif /* CONFIG_FBCON_2PLANE */
/* ====================================================================== */
#ifdef CONFIG_FBCON_4PLANE
/*
* 4 Planes (2-bytes interleave)
*/
/* Increment/decrement 4 plane addresses */
#define INC_4P(p) do { if (!((long)(++(p)) & 1)) (p) += 6; } while(0)
#define DEC_4P(p) do { if ((long)(--(p)) & 1) (p) -= 6; } while(0)
static void bmove_4_plane(struct display *p, int sy, int sx, int dy, int dx,
int height, int width)
{
/* bmove() has to distinguish two major cases: If both, source and
* destination, start at even addresses or both are at odd
* addresses, just the first odd and last even column (if present)
* require special treatment (memmove_col()). The rest between
* then can be copied by normal operations, because all adjacent
* bytes are affected and are to be stored in the same order.
* The pathological case is when the move should go from an odd
* address to an even or vice versa. Since the bytes in the plane
* words must be assembled in new order, it seems wisest to make
* all movements by memmove_col().
*/
if (sx == 0 && dx == 0 && width == p->next_line/4) {
/* Special (but often used) case: Moving whole lines can be
* done with memmove()
*/
mymemmove(p->screen_base + dy * p->next_line * p->fontheight,
p->screen_base + sy * p->next_line * p->fontheight,
p->next_line * height * p->fontheight);
} else {
int rows, cols;
u_char *src;
u_char *dst;
int bytes = p->next_line;
int linesize = bytes * p->fontheight;
u_int colsize = height * p->fontheight;
u_int upwards = (dy < sy) || (dy == sy && dx < sx);
if ((sx & 1) == (dx & 1)) {
/* odd->odd or even->even */
if (upwards) {
src = p->screen_base + sy * linesize + (sx>>1)*8 + (sx & 1);
dst = p->screen_base + dy * linesize + (dx>>1)*8 + (dx & 1);
if (sx & 1) {
memmove_4p_col(dst, src, colsize, bytes);
src += 7;
dst += 7;
--width;
}
if (width > 1) {
for(rows = colsize; rows > 0; --rows) {
mymemmove(dst, src, (width>>1)*8);
src += bytes;
dst += bytes;
}
}
if (width & 1) {
src -= colsize * bytes;
dst -= colsize * bytes;
memmove_4p_col(dst + (width>>1)*8, src + (width>>1)*8,
colsize, bytes);
}
}
else {
if (!((sx+width-1) & 1)) {
src = p->screen_base + sy * linesize + ((sx+width-1)>>1)*8;
dst = p->screen_base + dy * linesize + ((dx+width-1)>>1)*8;
memmove_4p_col(dst, src, colsize, bytes);
--width;
}
src = p->screen_base + sy * linesize + (sx>>1)*8 + (sx & 1);
dst = p->screen_base + dy * linesize + (dx>>1)*8 + (dx & 1);
if (width > 1) {
src += colsize * bytes + (sx & 1)*7;
dst += colsize * bytes + (sx & 1)*7;
for(rows = colsize; rows > 0; --rows) {
src -= bytes;
dst -= bytes;
mymemmove(dst, src, (width>>1)*8);
}
}
if (width & 1) {
memmove_4p_col(dst-7, src-7, colsize, bytes);
}
}
}
else {
/* odd->even or even->odd */
if (upwards) {
src = p->screen_base + sy * linesize + (sx>>1)*8 + (sx & 1);
dst = p->screen_base + dy * linesize + (dx>>1)*8 + (dx & 1);
for(cols = width; cols > 0; --cols) {
memmove_4p_col(dst, src, colsize, bytes);
INC_4P(src);
INC_4P(dst);
}
}
else {
sx += width-1;
dx += width-1;
src = p->screen_base + sy * linesize + (sx>>1)*8 + (sx & 1);
dst = p->screen_base + dy * linesize + (dx>>1)*8 + (dx & 1);
for(cols = width; cols > 0; --cols) {
memmove_4p_col(dst, src, colsize, bytes);
DEC_4P(src);
DEC_4P(dst);
}
}
}
}
}
static void clear_4_plane(struct vc_data *conp, struct display *p, int sy,
int sx, int height, int width)
{
ulong offset;
u_char *start;
int rows;
int bytes = p->next_line;
int lines = height * p->fontheight;
ulong size;
u_long cval1, cval2, pcval;
expand4dl(attr_bgcol_ec(p,conp), &cval1, &cval2);
if (sx == 0 && width == bytes/4) {
offset = sy * bytes * p->fontheight;
size = lines * bytes;
memset_even_4p(p->screen_base+offset, size, cval1, cval2);
} else {
offset = (sy * bytes * p->fontheight) + (sx>>1)*8 + (sx & 1);
start = p->screen_base + offset;
pcval = expand4l(attr_bgcol_ec(p,conp));
/* Clears are split if the region starts at an odd column or
* end at an even column. These extra columns are spread
* across the interleaved planes. All in between can be
* cleared by normal mymemclear_small(), because both bytes of
* the single plane words are affected.
*/
if (sx & 1) {
memclear_4p_col(start, lines, pcval, bytes);
start += 7;
width--;
}
if (width & 1) {
memclear_4p_col(start + (width>>1)*8, lines, pcval, bytes);
width--;
}
if (width) {
for(rows = lines; rows-- ; start += bytes)
memset_even_4p(start, width*4, cval1, cval2);
}
}
}
static void putc_4_plane(struct vc_data *conp, struct display *p, int c, int y,
int x)
{
u_char *dest;
u_char *cdat;
int rows;
int bytes = p->next_line;
ulong eorx, fgx, bgx, fdx;
c &= 0xff;
dest = p->screen_base + y * p->fontheight * bytes + (x>>1)*8 + (x & 1);
cdat = p->fontdata + (c * p->fontheight);
fgx = expand4l(attr_fgcol(p,conp));
bgx = expand4l(attr_bgcol(p,conp));
eorx = fgx ^ bgx;
for(rows = p->fontheight ; rows-- ; dest += bytes) {
fdx = dup4l(*cdat++);
__asm__ __volatile__ ("movepl %1,%0@(0)" : /* no outputs */
: "a" (dest), "d" ((fdx & eorx) ^ bgx));
}
}
static void putcs_4_plane(struct vc_data *conp, struct display *p,
const char *s, int count, int y, int x)
{
u_char *dest, *dest0;
u_char *cdat, c;
int rows;
int bytes;
ulong eorx, fgx, bgx, fdx;
bytes = p->next_line;
dest0 = p->screen_base + y * p->fontheight * bytes + (x>>1)*8 + (x & 1);
fgx = expand4l(attr_fgcol(p,conp));
bgx = expand4l(attr_bgcol(p,conp));
eorx = fgx ^ bgx;
while (count--) {
/* I think, unrolling the loops like in the 1 plane case isn't
* practicable here, because the body is much longer for 4
* planes (mostly the dup4l()). I guess, unrolling this would
* need more than 256 bytes and so exceed the instruction
* cache :-(
*/
c = *s++;
cdat = p->fontdata + (c * p->fontheight);
for(rows = p->fontheight, dest = dest0; rows-- ; dest += bytes) {
fdx = dup4l(*cdat++);
__asm__ __volatile__ ("movepl %1,%0@(0)" : /* no outputs */
: "a" (dest), "d" ((fdx & eorx) ^ bgx));
}
INC_4P(dest0);
}
}
static void rev_char_4_plane(struct display *p, int x, int y)
{
u_char *dest;
int j;
int bytes;
dest = p->screen_base + y * p->fontheight * p->next_line + (x>>1)*8 + (x & 1);
j = p->fontheight;
bytes = p->next_line;
while (j--)
{
/* This should really obey the individual character's
* background and foreground colors instead of simply
* inverting.
*/
dest[0] = ~dest[0];
dest[2] = ~dest[2];
dest[4] = ~dest[4];
dest[6] = ~dest[6];
dest += bytes;
}
}
#endif /* CONFIG_FBCON_4PLANE */
/* ====================================================================== */
#ifdef CONFIG_FBCON_8PLANE
/*
* 8 Planes (2-bytes interleave)
*/
/* In 8 plane mode, 256 colors would be possible, but only the first
* 16 are used by the console code (the upper 4 bits are
* background/unused). For that, the following functions mask off the
* higher 4 bits of each color.
*/
/* Increment/decrement 8 plane addresses */
#define INC_8P(p) do { if (!((long)(++(p)) & 1)) (p) += 14; } while(0)
#define DEC_8P(p) do { if ((long)(--(p)) & 1) (p) -= 14; } while(0)
static void bmove_8_plane(struct display *p, int sy, int sx, int dy, int dx,
int height, int width)
{
/* bmove() has to distinguish two major cases: If both, source and
* destination, start at even addresses or both are at odd
* addresses, just the first odd and last even column (if present)
* require special treatment (memmove_col()). The rest between
* then can be copied by normal operations, because all adjacent
* bytes are affected and are to be stored in the same order.
* The pathological case is when the move should go from an odd
* address to an even or vice versa. Since the bytes in the plane
* words must be assembled in new order, it seems wisest to make
* all movements by memmove_col().
*/
if (sx == 0 && dx == 0 && width == p->next_line/8) {
/* Special (but often used) case: Moving whole lines can be
* done with memmove()
*/
fast_memmove (p->screen_base + dy * p->next_line * p->fontheight,
p->screen_base + sy * p->next_line * p->fontheight,
p->next_line * height * p->fontheight);
} else {
int rows, cols;
u_char *src;
u_char *dst;
int bytes = p->next_line;
int linesize = bytes * p->fontheight;
u_int colsize = height * p->fontheight;
u_int upwards = (dy < sy) || (dy == sy && dx < sx);
if ((sx & 1) == (dx & 1)) {
/* odd->odd or even->even */
if (upwards) {
src = p->screen_base + sy * linesize + (sx>>1)*16 + (sx & 1);
dst = p->screen_base + dy * linesize + (dx>>1)*16 + (dx & 1);
if (sx & 1) {
memmove_8p_col(dst, src, colsize, bytes);
src += 15;
dst += 15;
--width;
}
if (width > 1) {
for(rows = colsize; rows > 0; --rows) {
fast_memmove (dst, src, (width >> 1) * 16);
src += bytes;
dst += bytes;
}
}
if (width & 1) {
src -= colsize * bytes;
dst -= colsize * bytes;
memmove_8p_col(dst + (width>>1)*16, src + (width>>1)*16,
colsize, bytes);
}
}
else {
if (!((sx+width-1) & 1)) {
src = p->screen_base + sy * linesize + ((sx+width-1)>>1)*16;
dst = p->screen_base + dy * linesize + ((dx+width-1)>>1)*16;
memmove_8p_col(dst, src, colsize, bytes);
--width;
}
src = p->screen_base + sy * linesize + (sx>>1)*16 + (sx & 1);
dst = p->screen_base + dy * linesize + (dx>>1)*16 + (dx & 1);
if (width > 1) {
src += colsize * bytes + (sx & 1)*15;
dst += colsize * bytes + (sx & 1)*15;
for(rows = colsize; rows > 0; --rows) {
src -= bytes;
dst -= bytes;
fast_memmove (dst, src, (width>>1)*16);
}
}
if (width & 1) {
memmove_8p_col(dst-15, src-15, colsize, bytes);
}
}
}
else {
/* odd->even or even->odd */
if (upwards) {
src = p->screen_base + sy * linesize + (sx>>1)*16 + (sx & 1);
dst = p->screen_base + dy * linesize + (dx>>1)*16 + (dx & 1);
for(cols = width; cols > 0; --cols) {
memmove_8p_col(dst, src, colsize, bytes);
INC_8P(src);
INC_8P(dst);
}
}
else {
sx += width-1;
dx += width-1;
src = p->screen_base + sy * linesize + (sx>>1)*16 + (sx & 1);
dst = p->screen_base + dy * linesize + (dx>>1)*16 + (dx & 1);
for(cols = width; cols > 0; --cols) {
memmove_8p_col(dst, src, colsize, bytes);
DEC_8P(src);
DEC_8P(dst);
}
}
}
}
}
static void clear_8_plane(struct vc_data *conp, struct display *p, int sy,
int sx, int height, int width)
{
ulong offset;
u_char *start;
int rows;
int bytes = p->next_line;
int lines = height * p->fontheight;
ulong size;
u_long cval1, cval2, cval3, cval4, pcval1, pcval2;
expand8ql(attr_bgcol_ec(p,conp), cval1, cval2, cval3, cval4);
if (sx == 0 && width == bytes/8) {
offset = sy * bytes * p->fontheight;
size = lines * bytes;
memset_even_8p(p->screen_base+offset, size, cval1, cval2, cval3, cval4);
} else {
offset = (sy * bytes * p->fontheight) + (sx>>1)*16 + (sx & 1);
start = p->screen_base + offset;
expand8dl(attr_bgcol_ec(p,conp), &pcval1, &pcval2);
/* Clears are split if the region starts at an odd column or
* end at an even column. These extra columns are spread
* across the interleaved planes. All in between can be
* cleared by normal mymemclear_small(), because both bytes of
* the single plane words are affected.
*/
if (sx & 1) {
memclear_8p_col(start, lines, pcval1, pcval2, bytes);
start += 7;
width--;
}
if (width & 1) {
memclear_8p_col(start + (width>>1)*16, lines, pcval1,
pcval2, bytes);
width--;
}
if (width) {
for(rows = lines; rows-- ; start += bytes)
memset_even_8p(start, width*8, cval1, cval2, cval3, cval4);
}
}
}
static void putc_8_plane(struct vc_data *conp, struct display *p, int c, int y,
int x)
{
u_char *dest;
u_char *cdat;
int rows;
int bytes = p->next_line;
ulong eorx1, eorx2, fgx1, fgx2, bgx1, bgx2, fdx;
c &= 0xff;
dest = p->screen_base + y * p->fontheight * bytes + (x>>1)*16 + (x & 1);
cdat = p->fontdata + (c * p->fontheight);
expand8dl(attr_fgcol(p,conp), &fgx1, &fgx2);
expand8dl(attr_bgcol(p,conp), &bgx1, &bgx2);
eorx1 = fgx1 ^ bgx1; eorx2 = fgx2 ^ bgx2;
for(rows = p->fontheight ; rows-- ; dest += bytes) {
fdx = dup4l(*cdat++);
__asm__ __volatile__
("movepl %1,%0@(0)\n\t"
"movepl %2,%0@(8)"
: /* no outputs */
: "a" (dest), "d" ((fdx & eorx1) ^ bgx1),
"d" ((fdx & eorx2) ^ bgx2)
);
}
}
static void putcs_8_plane(struct vc_data *conp, struct display *p,
const char *s, int count, int y, int x)
{
u_char *dest, *dest0;
u_char *cdat, c;
int rows;
int bytes;
ulong eorx1, eorx2, fgx1, fgx2, bgx1, bgx2, fdx;
bytes = p->next_line;
dest0 = p->screen_base + y * p->fontheight * bytes + (x>>1)*16 + (x & 1);
expand8dl(attr_fgcol(p,conp), &fgx1, &fgx2);
expand8dl(attr_bgcol(p,conp), &bgx1, &bgx2);
eorx1 = fgx1 ^ bgx1; eorx2 = fgx2 ^ bgx2;
while (count--) {
/* I think, unrolling the loops like in the 1 plane case isn't
* practicable here, because the body is much longer for 4
* planes (mostly the dup4l()). I guess, unrolling this would
* need more than 256 bytes and so exceed the instruction
* cache :-(
*/
c = *s++;
cdat = p->fontdata + (c * p->fontheight);
for(rows = p->fontheight, dest = dest0; rows-- ; dest += bytes) {
fdx = dup4l(*cdat++);
__asm__ __volatile__
("movepl %1,%0@(0)\n\t"
"movepl %2,%0@(8)"
: /* no outputs */
: "a" (dest), "d" ((fdx & eorx1) ^ bgx1),
"d" ((fdx & eorx2) ^ bgx2)
);
}
INC_8P(dest0);
}
}
static void rev_char_8_plane(struct display *p, int x, int y)
{
u_char *dest;
int j;
int bytes;
dest = p->screen_base + y * p->fontheight * p->next_line + (x>>1)*16 + (x & 1);
j = p->fontheight;
bytes = p->next_line;
while (j--)
{
/* This should really obey the individual character's
* background and foreground colors instead of simply
* inverting. For 8 plane mode, only the lower 4 bits of the
* color are inverted, because only that color registers have
* been set up.
*/
dest[0] = ~dest[0];
dest[2] = ~dest[2];
dest[4] = ~dest[4];
dest[6] = ~dest[6];
dest += bytes;
}
}
#endif /* CONFIG_FBCON_8PLANE */
/* ====================================================================== */
#ifdef CONFIG_FBCON_8PACKED
/*
* 8 bpp Packed Pixels
*/
static u_long nibbletab_8_packed[]={
0x00000000,0x000000ff,0x0000ff00,0x0000ffff,
0x00ff0000,0x00ff00ff,0x00ffff00,0x00ffffff,
0xff000000,0xff0000ff,0xff00ff00,0xff00ffff,
0xffff0000,0xffff00ff,0xffffff00,0xffffffff};
static void bmove_8_packed(struct display *p, int sy, int sx, int dy, int dx,
int height, int width)
{
int bytes = p->next_line, linesize = bytes * p->fontheight, rows;
u_char *src,*dst;
if (sx == 0 && dx == 0 && width * 8 == bytes) {
mymemmove(p->screen_base + dy * linesize,
p->screen_base + sy * linesize,
height * linesize);
}
else {
if (dy < sy || (dy == sy && dx < sx)) {
src = p->screen_base + sy * linesize + sx * 8;
dst = p->screen_base + dy * linesize + dx * 8;
for (rows = height * p->fontheight ; rows-- ;) {
mymemmove(dst, src, width * 8);
src += bytes;
dst += bytes;
}
}
else {
src = p->screen_base + (sy+height) * linesize + sx * 8
- bytes;
dst = p->screen_base + (dy+height) * linesize + dx * 8
- bytes;
for (rows = height * p->fontheight ; rows-- ;) {
mymemmove(dst, src, width * 8);
src -= bytes;
dst -= bytes;
}
}
}
}
static void clear_8_packed(struct vc_data *conp, struct display *p, int sy,
int sx, int height, int width)
{
u_char *dest0,*dest;
int bytes=p->next_line,lines=height * p->fontheight, rows, i;
u_long bgx;
dest = p->screen_base + sy * p->fontheight * bytes + sx * 8;
bgx=attr_bgcol_ec(p,conp);
bgx |= (bgx << 8);
bgx |= (bgx << 16);
if (sx == 0 && width * 8 == bytes) {
for (i = 0 ; i < lines * width ; i++) {
((u_long *)dest)[0]=bgx;
((u_long *)dest)[1]=bgx;
dest+=8;
}
} else {
dest0=dest;
for (rows = lines; rows-- ; dest0 += bytes) {
dest=dest0;
for (i = 0 ; i < width ; i++) {
((u_long *)dest)[0]=bgx;
((u_long *)dest)[1]=bgx;
dest+=8;
}
}
}
}
static void putc_8_packed(struct vc_data *conp, struct display *p, int c, int y,
int x)
{
u_char *dest,*cdat;
int bytes=p->next_line,rows;
ulong eorx,fgx,bgx;
c &= 0xff;
dest = p->screen_base + y * p->fontheight * bytes + x * 8;
cdat = p->fontdata + c * p->fontheight;
fgx=attr_fgcol(p,conp);
bgx=attr_bgcol(p,conp);
fgx |= (fgx << 8);
fgx |= (fgx << 16);
bgx |= (bgx << 8);
bgx |= (bgx << 16);
eorx = fgx ^ bgx;
for (rows = p->fontheight ; rows-- ; dest += bytes) {
((u_long *)dest)[0]=
(nibbletab_8_packed[*cdat >> 4] & eorx) ^ bgx;
((u_long *)dest)[1]=
(nibbletab_8_packed[*cdat++ & 0xf] & eorx) ^ bgx;
}
}
static void putcs_8_packed(struct vc_data *conp, struct display *p,
const char *s, int count, int y, int x)
{
u_char *cdat, c, *dest, *dest0;
int rows,bytes=p->next_line;
u_long eorx, fgx, bgx;
dest0 = p->screen_base + y * p->fontheight * bytes + x * 8;
fgx=attr_fgcol(p,conp);
bgx=attr_bgcol(p,conp);
fgx |= (fgx << 8);
fgx |= (fgx << 16);
bgx |= (bgx << 8);
bgx |= (bgx << 16);
eorx = fgx ^ bgx;
while (count--) {
c = *s++;
cdat = p->fontdata + c * p->fontheight;
for (rows = p->fontheight, dest = dest0; rows-- ; dest += bytes) {
((u_long *)dest)[0]=
(nibbletab_8_packed[*cdat >> 4] & eorx) ^ bgx;
((u_long *)dest)[1]=
(nibbletab_8_packed[*cdat++ & 0xf] & eorx) ^ bgx;
}
dest0+=8;
}
}
static void rev_char_8_packed(struct display *p, int x, int y)
{
u_char *dest;
int bytes=p->next_line, rows;
dest = p->screen_base + y * p->fontheight * bytes + x * 8;
for (rows = p->fontheight ; rows-- ; dest += bytes) {
((u_long *)dest)[0] ^= 0x0f0f0f0f;
((u_long *)dest)[1] ^= 0x0f0f0f0f;
}
}
#endif /* CONFIG_FBCON_8PACKED */
/* ====================================================================== */
#ifdef CONFIG_FBCON_16PACKED
/*
* 16 bpp Packed Pixels
*/
u_short packed16_cmap[16];
static u_long tab_16_packed[]={
0x00000000,0x0000ffff,0xffff0000,0xffffffff};
static void bmove_16_packed(struct display *p, int sy, int sx, int dy, int dx,
int height, int width)
{
int bytes = p->next_line, linesize = bytes * p->fontheight, rows;
u_char *src,*dst;
if (sx == 0 && dx == 0 && width * 16 == bytes) {
mymemmove(p->screen_base + dy * linesize,
p->screen_base + sy * linesize,
height * linesize);
}
else {
if (dy < sy || (dy == sy && dx < sx)) {
src = p->screen_base + sy * linesize + sx * 16;
dst = p->screen_base + dy * linesize + dx * 16;
for (rows = height * p->fontheight ; rows-- ;) {
mymemmove(dst, src, width * 16);
src += bytes;
dst += bytes;
}
}
else {
src = p->screen_base + (sy+height) * linesize + sx * 16
- bytes;
dst = p->screen_base + (dy+height) * linesize + dx * 16
- bytes;
for (rows = height * p->fontheight ; rows-- ;) {
mymemmove(dst, src, width * 16);
src -= bytes;
dst -= bytes;
}
}
}
}
static void clear_16_packed(struct vc_data *conp, struct display *p, int sy,
int sx, int height, int width)
{
u_char *dest0,*dest;
int bytes=p->next_line,lines=height * p->fontheight, rows, i;
u_long bgx;
dest = p->screen_base + sy * p->fontheight * bytes + sx * 16;
bgx = attr_bgcol_ec(p,conp);
bgx = packed16_cmap[bgx];
bgx |= (bgx << 16);
if (sx == 0 && width * 16 == bytes) {
for (i = 0 ; i < lines * width ; i++) {
((u_long *)dest)[0]=bgx;
((u_long *)dest)[1]=bgx;
((u_long *)dest)[2]=bgx;
((u_long *)dest)[3]=bgx;
dest+=16;
}
} else {
dest0=dest;
for (rows = lines; rows-- ; dest0 += bytes) {
dest=dest0;
for (i = 0 ; i < width ; i++) {
((u_long *)dest)[0]=bgx;
((u_long *)dest)[1]=bgx;
((u_long *)dest)[2]=bgx;
((u_long *)dest)[3]=bgx;
dest+=16;
}
}
}
}
static void putc_16_packed(struct vc_data *conp, struct display *p, int c,
int y, int x)
{
u_char *dest,*cdat;
int bytes=p->next_line,rows;
ulong eorx,fgx,bgx;
c &= 0xff;
dest = p->screen_base + y * p->fontheight * bytes + x * 16;
cdat = p->fontdata + c * p->fontheight;
fgx = attr_fgcol(p,conp);
fgx = packed16_cmap[fgx];
bgx = attr_bgcol(p,conp);
bgx = packed16_cmap[bgx];
fgx |= (fgx << 16);
bgx |= (bgx << 16);
eorx = fgx ^ bgx;
for (rows = p->fontheight ; rows-- ; dest += bytes) {
((u_long *)dest)[0]=
(tab_16_packed[*cdat >> 6] & eorx) ^ bgx;
((u_long *)dest)[1]=
(tab_16_packed[*cdat >> 4 & 0x3] & eorx) ^ bgx;
((u_long *)dest)[2]=
(tab_16_packed[*cdat >> 2 & 0x3] & eorx) ^ bgx;
((u_long *)dest)[3]=
(tab_16_packed[*cdat++ & 0x3] & eorx) ^ bgx;
}
}
/* TODO */
static void putcs_16_packed(struct vc_data *conp, struct display *p,
const char *s, int count, int y, int x)
{
u_char *cdat, c, *dest, *dest0;
int rows,bytes=p->next_line;
u_long eorx, fgx, bgx;
dest0 = p->screen_base + y * p->fontheight * bytes + x * 16;
fgx = attr_fgcol(p,conp);
fgx = packed16_cmap[fgx];
bgx = attr_bgcol(p,conp);
bgx = packed16_cmap[bgx];
fgx |= (fgx << 16);
bgx |= (bgx << 16);
eorx = fgx ^ bgx;
while (count--) {
c = *s++;
cdat = p->fontdata + c * p->fontheight;
for (rows = p->fontheight, dest = dest0; rows-- ; dest += bytes) {
((u_long *)dest)[0]=
(tab_16_packed[*cdat >> 6] & eorx) ^ bgx;
((u_long *)dest)[1]=
(tab_16_packed[*cdat >> 4 & 0x3] & eorx) ^ bgx;
((u_long *)dest)[2]=
(tab_16_packed[*cdat >> 2 & 0x3] & eorx) ^ bgx;
((u_long *)dest)[3]=
(tab_16_packed[*cdat++ & 0x3] & eorx) ^ bgx;
}
dest0+=16;
}
}
static void rev_char_16_packed(struct display *p, int x, int y)
{
u_char *dest;
int bytes=p->next_line, rows;
dest = p->screen_base + y * p->fontheight * bytes + x * 16;
for (rows = p->fontheight ; rows-- ; dest += bytes) {
((u_long *)dest)[0] ^= 0xffffffff;
((u_long *)dest)[1] ^= 0xffffffff;
((u_long *)dest)[2] ^= 0xffffffff;
((u_long *)dest)[3] ^= 0xffffffff;
}
}
#endif /* CONFIG_FBCON_16PACKED */
/* ====================================================================== */
#ifdef CONFIG_FBCON_CYBER
/*
* Cybervision (accelerated)
*/
static void bmove_cyber(struct display *p, int sy, int sx, int dy, int dx,
int height, int width)
{
sx *= 8; dx *= 8; width *= 8;
Cyber_BitBLT((u_short)sx, (u_short)(sy*p->fontheight), (u_short)dx,
(u_short)(dy*p->fontheight), (u_short)width,
(u_short)(height*p->fontheight), (u_short)S3_NEW);
}
static void clear_cyber(struct vc_data *conp, struct display *p, int sy, int sx,
int height, int width)
{
u_char bg;
sx *= 8; width *= 8;
bg = attr_bgcol_ec(p,conp);
Cyber_RectFill((u_short)sx, (u_short)(sy*p->fontheight), (u_short)width,
(u_short)(height*p->fontheight), (u_short)S3_NEW,
(u_short)bg);
}
static void putc_cyber(struct vc_data *conp, struct display *p, int c, int y,
int x)
{
u_char *dest, *cdat;
u_long tmp;
u_int rows, reverse, underline;
u_char d;
u_char fg, bg;
c &= 0xff;
dest = p->screen_base+y*p->fontheight*p->next_line+8*x;
cdat = p->fontdata+(c*p->fontheight);
fg = disp->fgcol;
bg = disp->bgcol;
reverse = conp->vc_reverse;
underline = conp->vc_underline;
Cyber_WaitBlit();
for (rows = p->fontheight; rows--; dest += p->next_line) {
d = *cdat++;
if (underline && !rows)
d = 0xff;
if (reverse)
d = ~d;
tmp = ((d & 0x80) ? fg : bg) << 24;
tmp |= ((d & 0x40) ? fg : bg) << 16;
tmp |= ((d & 0x20) ? fg : bg) << 8;
tmp |= ((d & 0x10) ? fg : bg);
*((u_long*) dest) = tmp;
tmp = ((d & 0x8) ? fg : bg) << 24;
tmp |= ((d & 0x4) ? fg : bg) << 16;
tmp |= ((d & 0x2) ? fg : bg) << 8;
tmp |= ((d & 0x1) ? fg : bg);
*((u_long*) dest + 1) = tmp;
}
}
static void putcs_cyber(struct vc_data *conp, struct display *p, const char *s,
int count, int y, int x)
{
u_char *dest, *dest0, *cdat;
u_long tmp;
u_int rows, reverse, underline;
u_char c, d;
u_char fg, bg;
dest0 = p->screen_base+y*p->fontheight*p->next_line+8*x;
fg = disp->fgcol;
bg = disp->bgcol;
reverse = conp->vc_reverse;
underline = conp->vc_underline;
Cyber_WaitBlit();
while (count--) {
c = *s++;
dest = dest0;
dest0 += 8;
cdat = p->fontdata+(c*p->fontheight);
for (rows = p->fontheight; rows--; dest += p->next_line) {
d = *cdat++;
if (underline && !rows)
d = 0xff;
if (reverse)
d = ~d;
tmp = ((d & 0x80) ? fg : bg) << 24;
tmp |= ((d & 0x40) ? fg : bg) << 16;
tmp |= ((d & 0x20) ? fg : bg) << 8;
tmp |= ((d & 0x10) ? fg : bg);
*((u_long*) dest) = tmp;
tmp = ((d & 0x8) ? fg : bg) << 24;
tmp |= ((d & 0x4) ? fg : bg) << 16;
tmp |= ((d & 0x2) ? fg : bg) << 8;
tmp |= ((d & 0x1) ? fg : bg);
*((u_long*) dest + 1) = tmp;
}
}
}
static void rev_char_cyber(struct display *p, int x, int y)
{
u_char *dest;
u_int rows;
u_char fg, bg;
fg = disp->fgcol;
bg = disp->bgcol;
dest = p->screen_base+y*p->fontheight*p->next_line+8*x;
Cyber_WaitBlit();
for (rows = p->fontheight; rows--; dest += p->next_line) {
*dest = (*dest == fg) ? bg : fg;
*(dest+1) = (*(dest + 1) == fg) ? bg : fg;
*(dest+2) = (*(dest + 2) == fg) ? bg : fg;
*(dest+3) = (*(dest + 3) == fg) ? bg : fg;
*(dest+4) = (*(dest + 4) == fg) ? bg : fg;
*(dest+5) = (*(dest + 5) == fg) ? bg : fg;
*(dest+6) = (*(dest + 6) == fg) ? bg : fg;
*(dest+7) = (*(dest + 7) == fg) ? bg : fg;
}
}
#endif /* CONFIG_FBCON_CYBER */
/* ====================================================================== */
/*
* The console `switch' structure for the frame buffer based console
*/
struct consw fb_con = {
fbcon_startup, fbcon_init, fbcon_deinit, fbcon_clear, fbcon_putc,
fbcon_putcs, fbcon_cursor, fbcon_scroll, fbcon_bmove, fbcon_switch,
fbcon_blank, fbcon_get_font, fbcon_set_font
};
|