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
|
Index: linux22/Makefile
diff -u linux22/Makefile:1.1.1.3 linux22/Makefile:1.14
--- linux22/Makefile:1.1.1.3 Wed Oct 20 23:13:41 1999
+++ linux22/Makefile Thu Nov 25 15:31:25 1999
@@ -1,7 +1,7 @@
VERSION = 2
PATCHLEVEL = 2
SUBLEVEL = 13
-EXTRAVERSION =
+EXTRAVERSION =-rtl2.0
ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
@@ -95,6 +95,10 @@
ifdef CONFIG_SMP
CFLAGS += -D__SMP__
AFLAGS += -D__SMP__
+endif
+ifdef CONFIG_RTL
+CFLAGS += -D__RTL__
+AFLAGS += -D__RTL__
endif
#
Index: linux22/arch/i386/config.in
diff -u linux22/arch/i386/config.in:1.1.1.1 linux22/arch/i386/config.in:1.2
--- linux22/arch/i386/config.in:1.1.1.1 Thu Aug 12 22:06:27 1999
+++ linux22/arch/i386/config.in Thu Aug 12 22:12:36 1999
@@ -40,6 +40,7 @@
bool 'Math emulation' CONFIG_MATH_EMULATION
bool 'MTRR (Memory Type Range Register) support' CONFIG_MTRR
bool 'Symmetric multi-processing support' CONFIG_SMP
+bool 'Hard realtime support' CONFIG_RTL
endmenu
mainmenu_option next_comment
Index: linux22/arch/i386/defconfig
diff -u linux22/arch/i386/defconfig:1.1.1.2 linux22/arch/i386/defconfig:1.2
--- linux22/arch/i386/defconfig:1.1.1.2 Wed Sep 1 20:10:18 1999
+++ linux22/arch/i386/defconfig Thu Sep 2 08:24:14 1999
@@ -26,6 +26,7 @@
# CONFIG_MATH_EMULATION is not set
# CONFIG_MTRR is not set
CONFIG_SMP=y
+CONFIG_RTL=y
#
# Loadable module support
Index: linux22/arch/i386/kernel/entry.S
diff -u linux22/arch/i386/kernel/entry.S:1.1.1.1 linux22/arch/i386/kernel/entry.S:1.2
--- linux22/arch/i386/kernel/entry.S:1.1.1.1 Thu Aug 12 22:06:29 1999
+++ linux22/arch/i386/kernel/entry.S Thu Aug 12 22:12:36 1999
@@ -190,6 +190,9 @@
jne reschedule
cmpl $0,sigpending(%ebx)
jne signal_return
+#ifdef __RTL__
+ call __sti #VY just checking
+#endif
restore_all:
RESTORE_ALL
Index: linux22/arch/i386/kernel/io_apic.c
diff -u linux22/arch/i386/kernel/io_apic.c:1.1.1.2 linux22/arch/i386/kernel/io_apic.c:1.4
--- linux22/arch/i386/kernel/io_apic.c:1.1.1.2 Wed Oct 20 23:16:03 1999
+++ linux22/arch/i386/kernel/io_apic.c Tue Oct 26 01:29:28 1999
@@ -1019,7 +1019,11 @@
if (irq < 16) {
disable_8259A_irq(irq);
if (i8259A_irq_pending(irq))
+#ifndef __RTL__
irq_desc[irq].status |= IRQ_PENDING;
+#else
+ rtl_global_pend_irq(irq);
+#endif
}
enable_edge_ioapic_irq(irq);
}
@@ -1048,7 +1052,9 @@
* Edge triggered IRQs can be acknowledged immediately
* and do not need to be masked.
*/
+#ifndef __RTL__
ack_APIC_irq();
+#endif
status = desc->status & ~(IRQ_REPLAY | IRQ_WAITING);
status |= IRQ_PENDING;
@@ -1085,9 +1091,28 @@
spin_unlock(&irq_controller_lock);
}
desc->status &= ~IRQ_INPROGRESS;
+#ifdef __RTL__
+ if (!(desc->status & IRQ_DISABLED))/* need this cause RTL has soft_disabled*/
+ rtl_emulate_enable_irq(irq);
+#endif
spin_unlock(&irq_controller_lock);
}
+#ifdef __RTL__
+/* RTL
+ moved this out of the do_level_ioapic code
+ called by rtl_intercept
+ */
+static void mask_and_ack_edge_ioapic(unsigned int irq){
+ ack_APIC_irq();
+}
+static void mask_and_ack_level_ioapic(unsigned int irq)
+{
+ mask_IO_APIC_irq(irq);
+ ack_APIC_irq();
+}
+#endif /* __RTL__ */
+
static void do_level_ioapic_IRQ(unsigned int irq, struct pt_regs * regs)
{
irq_desc_t *desc = irq_desc + irq;
@@ -1103,7 +1128,9 @@
* disable has to happen before the ACK, to avoid IRQ storms.
* So this all has to be within the spinlock.
*/
+#ifndef __RTL__
mask_IO_APIC_irq(irq);
+#endif
status = desc->status & ~(IRQ_REPLAY | IRQ_WAITING);
/*
@@ -1117,7 +1144,9 @@
}
desc->status = status;
+#ifndef __RTL__
ack_APIC_irq();
+#endif
spin_unlock(&irq_controller_lock);
/* Exit early if we had no action or it was disabled */
@@ -1129,7 +1158,11 @@
spin_lock(&irq_controller_lock);
desc->status &= ~IRQ_INPROGRESS;
if (!(desc->status & IRQ_DISABLED))
+#ifndef __RTL__
unmask_IO_APIC_irq(irq);
+#else
+ rtl_emulate_enable_irq(irq);/* RTL: can't touch hdwr*/
+#endif
spin_unlock(&irq_controller_lock);
}
@@ -1149,6 +1182,9 @@
do_edge_ioapic_IRQ,
enable_edge_ioapic_irq,
disable_edge_ioapic_irq
+#ifdef __RTL__
+ ,mask_and_ack_edge_ioapic
+#endif
};
static struct hw_interrupt_type ioapic_level_irq_type = {
@@ -1158,6 +1194,9 @@
do_level_ioapic_IRQ,
enable_level_ioapic_irq,
disable_level_ioapic_irq
+#ifdef __RTL__
+ ,mask_and_ack_level_ioapic
+#endif
};
static inline void init_IO_APIC_traps(void)
Index: linux22/arch/i386/kernel/irq.c
diff -u linux22/arch/i386/kernel/irq.c:1.1.1.2 linux22/arch/i386/kernel/irq.c:1.28
--- linux22/arch/i386/kernel/irq.c:1.1.1.2 Wed Oct 20 23:16:03 1999
+++ linux22/arch/i386/kernel/irq.c Thu Nov 25 01:03:25 1999
@@ -39,9 +39,134 @@
#include <asm/pgtable.h>
#include <asm/delay.h>
#include <asm/desc.h>
+#include <asm/rtl_sync.h>
+
#include "irq.h"
+#include <linux/cons.h>
+
+/* tracer */
+#ifdef CONFIG_RTL_TRACER
+void rtl_trace_default(int event_id, long event_data, long eip) { }
+void (*rtl_trace)(int event_id, long event_data, long eip) = rtl_trace_default;
+#endif
+
+/* Real Time Linux support */
+unsigned int rtl_intercept(struct pt_regs r);
+void rtl_emulate_enable_irq(unsigned int irq);
+void rtl_emulate_disable_irq(unsigned int irq);
+void rtl_emulate_shutdown_irq(unsigned int irq);
+void rtl_emulate_startup_irq(unsigned int irq);
+void rtl_make_sure_real_sti(const char *);
+
+#define RTL_L_IDLE_BIT 1
+#define RTL_L_IENABLE_BIT 4
+#define RTL_L_SINCE_STI_BIT 8
+#define RTL_L_IDLE_POS 0
+#define RTL_L_IENABLE_POS 2
+#define RTL_L_SINCE_STI_POS 3
+#define is_soft_sti() (RTL_LOCAL.flags & RTL_L_IENABLE_BIT)
+#define is_idle_realtime_system() (RTL_LOCAL.flags & RTL_L_IDLE_BIT)
+#define set_idle_realtime_system() set_bit(RTL_L_IDLE_POS,&RTL_LOCAL.flags)
+#define clear_idle_realtime_system() clear_bit(RTL_L_IDLE_POS,&RTL_LOCAL.flags)
+#define soft_cli() clear_bit(RTL_L_IENABLE_POS,&RTL_LOCAL.flags)
+#define soft_sti() set_bit(RTL_L_IENABLE_POS,&RTL_LOCAL.flags)
+
+/* assuming 255 global irqs and 31 max local smp vectors */
+#define IRQ_ARRAY_SIZE 4
+#define IRQ_ZINIT {0}
+#define IRQ_NZINIT {0xffffffff,0xffffffff,0xffffffff,0xffffffff}
+/* fix if IRQ_ARRAY_SIZE !=4 */
+#define irq_to_index(x) ((x>>5)&3)
+#define irq_to_pos(x) ((x)& 0x1fUL)
+#define irq_to_bit(x) (1UL<< ((x) & 0x1f))
+#define pos_and_index_to_irq(p,i) ( (p) + (i*32))
+#ifdef __SMP__
+struct rtl_local {
+ __u32 flags;
+ __u32 pending;
+}rtl_local[NR_CPUS] = { {RTL_L_IDLE_BIT ,0},{RTL_L_IDLE_BIT,0}};
+#define RTL_LOCAL rtl_local[cpu_id]
+#define active_local_irqs() (RTL_LOCAL.pending)
+#define active_irqs() (active_local_irqs() || active_global_irqs())
+#define DeclareAndInit(cpu_id) unsigned int cpu_id = smp_processor_id()
+#define HardDeclareAndInit(cpu_id) unsigned int cpu_id = hard_smp_processor_id()
+void rtl_local_pend_vec(int vector,int cpu_id) {
+ int i = VECTOR_TO_LOCAL_PND(vector);
+ set_bit(i,&(RTL_LOCAL.pending));
+ set_bit(RTL_L_SINCE_STI_POS, &RTL_LOCAL.flags);
+}
+#else
+#define DeclareAndInit(cpu_id)
+#define HardDeclareAndInit(cpu_id)
+struct rtl_local {
+ __u32 flags;
+} rtl_local = {RTL_L_IENABLE_BIT | RTL_L_IDLE_BIT};
+#define RTL_LOCAL rtl_local
+#endif
+
+
+struct rtl_global{
+ spinlock_t hard_irq_controller_lock;
+ unsigned int rtl_off;
+ unsigned int pending[IRQ_ARRAY_SIZE];
+ unsigned int soft_enabled[IRQ_ARRAY_SIZE];
+ unsigned int rt_system_is_idle;
+ unsigned int rtirq[IRQ_ARRAY_SIZE];
+ unsigned int pended_since_sti;
+};
+struct rtl_global rtl_global ={ SPIN_LOCK_UNLOCKED,1,IRQ_ZINIT,IRQ_NZINIT,1,IRQ_ZINIT,0} ;
+
+/* macros for touching the global structure */
+#define test_g(ix,y) test_bit(irq_to_pos(ix),&y[irq_to_index(ix)])
+#define global_is_pending_irq(ix) test_g(ix,rtl_global.pending)
+#define global_is_enabled_irq(ix) test_g(ix,rtl_global.soft_enabled)
+#define there_is_a_rt_handler(ix) test_g(ix,rtl_global.rtirq)
+#define global_pend_irq(ix)\
+ set_bit(irq_to_pos(ix),&rtl_global.pending[irq_to_index(ix)])
+#define global_unpend_irq(ix) \
+ {clear_bit(irq_to_pos(ix),&rtl_global.pending[irq_to_index(ix)]);}
+#define atomic_global_soft_disable(x) \
+ clear_bit(irq_to_pos(x),&rtl_global.soft_enabled[irq_to_index(x)]);
+#define global_soft_enable(x) \
+ set_bit(irq_to_pos(x),&rtl_global.soft_enabled[irq_to_index(x)]);
+
+
+/* this are exported so that they can be called by rt drivers */
+void rtl_global_pend_irq(int ix) { global_pend_irq(ix);}
+void rtl_hard_enable_irq(unsigned int ix) {
+ int flags;
+ rtl_hard_savef_and_cli(flags);
+ rtl_spin_lock(&rtl_global.hard_irq_controller_lock);
+ irq_desc[ix].handler->enable(ix);
+ rtl_spin_unlock(&rtl_global.hard_irq_controller_lock);
+ rtl_hard_restore_flags(flags);
+}
+void rtl_hard_disable_irq(unsigned int ix) {
+ int flags;
+ rtl_hard_savef_and_cli(flags);
+ rtl_spin_lock(&rtl_global.hard_irq_controller_lock);
+ irq_desc[ix].handler->disable(ix);
+ rtl_spin_unlock(&rtl_global.hard_irq_controller_lock);
+ rtl_hard_restore_flags(flags);
+}
+
+unsigned int rtl_rt_system_is_idle(){
+ HardDeclareAndInit(cpu_id);
+ return is_idle_realtime_system();
+}
+/* needs to be called with irqs disabled */
+void rtl_make_rt_system_active(){
+ HardDeclareAndInit(cpu_id);
+ clear_idle_realtime_system();
+}
+/* needs to be called with irqs disabled */
+void rtl_make_rt_system_idle(){
+ HardDeclareAndInit(cpu_id);
+ set_idle_realtime_system();
+}
+
unsigned int local_bh_count[NR_CPUS];
unsigned int local_irq_count[NR_CPUS];
@@ -111,7 +236,36 @@
shutdown_none,
do_none,
enable_none,
- disable_none
+ disable_none,0
+};
+
+/*
+ * Dummy controller type for RTL soft interrupts
+ */
+static void rtl_do_none(unsigned int irq, struct pt_regs * regs)
+{
+ struct irqaction * action;
+ irq_desc_t *desc = irq_desc + irq;
+
+ action = desc->action;
+ if (!action)
+ return;
+ handle_IRQ_event(irq, regs, action);
+}
+static void rtl_enable_none(unsigned int irq) { }
+static void rtl_disable_none(unsigned int irq) { }
+
+/* startup is the same as "enable", shutdown is same as "disable" */
+#define rtl_startup_none rtl_enable_none
+#define rtl_shutdown_none rtl_disable_none
+
+struct hw_interrupt_type rtl_soft_irq_type = {
+ "rtl-soft",
+ rtl_startup_none,
+ rtl_shutdown_none,
+ rtl_do_none,
+ rtl_enable_none,
+ rtl_disable_none,0
};
/*
@@ -126,14 +280,15 @@
/* startup is the same as "enable", shutdown is same as "disable" */
#define startup_8259A_irq enable_8259A_irq
#define shutdown_8259A_irq disable_8259A_irq
-
+static inline void mask_and_ack_8259A(unsigned int irq);
static struct hw_interrupt_type i8259A_irq_type = {
"XT-PIC",
startup_8259A_irq,
shutdown_8259A_irq,
do_8259A_IRQ,
enable_8259A_irq,
- disable_8259A_irq
+ disable_8259A_irq,
+ mask_and_ack_8259A
};
/*
@@ -215,7 +370,8 @@
* first, _then_ send the EOI, and the order of EOI
* to the two 8259s is important!
*/
-static inline void mask_and_ack_8259A(unsigned int irq)
+/* RTL can't inline this yet, since we put the pointer in the desc */
+static void mask_and_ack_8259A(unsigned int irq)
{
cached_irq_mask |= 1 << irq;
if (irq & 8) {
@@ -238,7 +394,6 @@
spin_lock(&irq_controller_lock);
{
unsigned int status;
- mask_and_ack_8259A(irq);
status = desc->status & ~(IRQ_REPLAY | IRQ_WAITING);
action = NULL;
if (!(status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
@@ -252,15 +407,16 @@
/* Exit early if we had no action or it was disabled */
if (!action)
return;
-
handle_IRQ_event(irq, regs, action);
+ __cli(); /* RTL just to make sure */
spin_lock(&irq_controller_lock);
{
unsigned int status = desc->status & ~IRQ_INPROGRESS;
desc->status = status;
- if (!(status & IRQ_DISABLED))
- enable_8259A_irq(irq);
+ if (!(status & IRQ_DISABLED)){
+ rtl_emulate_enable_irq(irq);/* RTL: can't touch hdwr*/
+ }
}
spin_unlock(&irq_controller_lock);
}
@@ -319,11 +475,13 @@
* is no hardware IRQ pin equivalent for them, they are triggered
* through the ICC by us (IPIs)
*/
-BUILD_SMP_INTERRUPT(reschedule_interrupt)
-BUILD_SMP_INTERRUPT(invalidate_interrupt)
-BUILD_SMP_INTERRUPT(stop_cpu_interrupt)
-BUILD_SMP_INTERRUPT(call_function_interrupt)
-BUILD_SMP_INTERRUPT(spurious_interrupt)
+BUILD_COMMON_SMP_IRQ() /* RTL needs to have a common path */
+BUILD_SMP_INTERRUPT(RESCHEDULE_VECTOR,reschedule_interrupt)
+BUILD_SMP_INTERRUPT(INVALIDATE_TLB_VECTOR,invalidate_interrupt)
+BUILD_SMP_INTERRUPT(STOP_CPU_VECTOR,stop_cpu_interrupt)
+BUILD_SMP_INTERRUPT(SPURIOUS_APIC_VECTOR,spurious_interrupt)
+BUILD_SMP_INTERRUPT(CALL_FUNCTION_VECTOR,call_function_interrupt)
+
/*
* every pentium local APIC has two 'local interrupts', with a
@@ -332,7 +490,8 @@
* overflow. Linux uses the local APIC timer interrupt to get
* a much simpler SMP time architecture:
*/
-BUILD_SMP_TIMER_INTERRUPT(apic_timer_interrupt)
+BUILD_SMP_TIMER_INTERRUPT(LOCAL_TIMER_VECTOR,apic_timer_interrupt)
+BUILD_SMP_TIMER_INTERRUPT(RTL_RESCHEDULE_VECTOR,rtl_resched_interrupt)
#endif
@@ -349,10 +508,10 @@
IRQLIST_16(0x0),
#ifdef CONFIG_X86_IO_APIC
- IRQLIST_16(0x1), IRQLIST_16(0x2), IRQLIST_16(0x3),
- IRQLIST_16(0x4), IRQLIST_16(0x5), IRQLIST_16(0x6), IRQLIST_16(0x7),
+ IRQLIST_16(0x1)/*, IRQLIST_16(0x2), IRQLIST_16(0x3),
+ IRQLIST_16(0x4) , IRQLIST_16(0x5), IRQLIST_16(0x6), IRQLIST_16(0x7),
IRQLIST_16(0x8), IRQLIST_16(0x9), IRQLIST_16(0xa), IRQLIST_16(0xb),
- IRQLIST_16(0xc), IRQLIST_16(0xd)
+ IRQLIST_16(0xc), IRQLIST_16(0xd) */
#endif
};
@@ -758,7 +917,7 @@
spin_lock_irqsave(&irq_controller_lock, flags);
if (!irq_desc[irq].depth++) {
irq_desc[irq].status |= IRQ_DISABLED;
- irq_desc[irq].handler->disable(irq);
+ rtl_emulate_disable_irq(irq); /* RTL: hands off hdwr*/
}
spin_unlock_irqrestore(&irq_controller_lock, flags);
}
@@ -781,12 +940,13 @@
void enable_irq(unsigned int irq)
{
unsigned long flags;
+ DeclareAndInit(cpu_id);
spin_lock_irqsave(&irq_controller_lock, flags);
switch (irq_desc[irq].depth) {
case 1:
irq_desc[irq].status &= ~IRQ_DISABLED;
- irq_desc[irq].handler->enable(irq);
+ rtl_emulate_enable_irq(irq); /*RTL: hands off hrdwr */
/* fall throught */
default:
irq_desc[irq].depth--;
@@ -796,6 +956,7 @@
__builtin_return_address(0));
}
spin_unlock_irqrestore(&irq_controller_lock, flags);
+ if(is_soft_sti())__sti();
}
/*
@@ -803,23 +964,15 @@
* SMP cross-CPU interrupts have their own specific
* handlers).
*/
-asmlinkage void do_IRQ(struct pt_regs regs)
+/* For RTL call with pointer to regs and with irq number already
+ calculated by rtl_intercept or by fake_irq
+ */
+void do_IRQ(unsigned int irq, struct pt_regs *regs)
{
- /*
- * We ack quickly, we don't want the irq controller
- * thinking we're snobs just because some other CPU has
- * disabled global interrupts (we have already done the
- * INT_ACK cycles, it's too late to try to pretend to the
- * controller that we aren't taking the interrupt).
- *
- * 0 return value means that this irq is already being
- * handled by some other CPU. (or is disabled)
- */
- int irq = regs.orig_eax & 0xff; /* subtle, see irq.h */
int cpu = smp_processor_id();
kstat.irqs[cpu][irq]++;
- irq_desc[irq].handler->handle(irq, ®s);
+ irq_desc[irq].handler->handle(irq, regs);
/*
* This should be conditional: we should really get
@@ -881,12 +1034,32 @@
if (!shared) {
irq_desc[irq].depth = 0;
irq_desc[irq].status &= ~IRQ_DISABLED;
- irq_desc[irq].handler->startup(irq);
+ rtl_emulate_startup_irq(irq); /* RTL: hands off hardware*/
}
spin_unlock_irqrestore(&irq_controller_lock,flags);
return 0;
}
+/* VY: needs some synchronization here. Doesn't request_irq also
+ have a problem? */
+int rtl_get_soft_irq (void (*handler) (int, void *, struct pt_regs *),
+ const char *devname)
+{
+ int i;
+ for (i = NR_IRQS - 1; i > 15; i--) {
+ if (!irq_desc[i].action) {
+ irq_desc[i].handler = &rtl_soft_irq_type;
+ if (request_irq (i, handler, 0, devname, 0)) {
+ return -EBUSY;
+ } else {
+ global_soft_enable(i);
+ return i;
+ }
+ }
+ }
+ return -1;
+}
+
int request_irq(unsigned int irq,
void (*handler)(int, void *, struct pt_regs *),
unsigned long irqflags,
@@ -949,7 +1122,7 @@
kfree(action);
if (!irq_desc[irq].action) {
irq_desc[irq].status |= IRQ_DISABLED;
- irq_desc[irq].handler->shutdown(irq);
+ rtl_emulate_shutdown_irq(irq);/*RTL hands off hardware*/
}
goto out;
}
@@ -978,7 +1151,7 @@
for (i = NR_IRQS-1; i > 0; i--) {
if (!irq_desc[i].action) {
irq_desc[i].status |= IRQ_AUTODETECT | IRQ_WAITING;
- irq_desc[i].handler->startup(i);
+ rtl_emulate_startup_irq(i); /* RTL hands off hardware*/
}
}
spin_unlock_irq(&irq_controller_lock);
@@ -1002,7 +1175,8 @@
/* It triggered already - consider it spurious. */
if (!(status & IRQ_WAITING)) {
irq_desc[i].status = status & ~IRQ_AUTODETECT;
- irq_desc[i].handler->shutdown(i);
+ rtl_emulate_shutdown_irq(i);
+/* conpr("SSh"); conprn(i); */
}
}
spin_unlock_irq(&irq_controller_lock);
@@ -1032,7 +1206,7 @@
nr_irqs++;
}
irq_desc[i].status = status & ~IRQ_AUTODETECT;
- irq_desc[i].handler->shutdown(i);
+ rtl_emulate_shutdown_irq(i);
}
spin_unlock_irq(&irq_controller_lock);
@@ -1064,6 +1238,16 @@
}
}
+#ifdef __SMP__
+/* RTL needs this */
+void smp_reschedule_interrupt(void);
+void smp_invalidate_interrupt(void);
+void smp_stop_cpu_interrupt(void);
+void smp_apic_timer_interrupt(struct pt_regs *);
+void smp_spurious_interrupt(void);
+void smp_call_function_interrupt(void);
+#endif /* SMP */
+
__initfunc(void init_IRQ(void))
{
int i;
@@ -1112,6 +1296,9 @@
/* IPI vector for APIC spurious interrupts */
set_intr_gate(SPURIOUS_APIC_VECTOR, spurious_interrupt);
+#ifdef __RTL__
+ set_intr_gate(RTL_RESCHEDULE_VECTOR, rtl_resched_interrupt);
+#endif
#endif
request_region(0x20,0x20,"pic1");
request_region(0xa0,0x20,"pic2");
@@ -1138,5 +1325,525 @@
if (IO_APIC_VECTOR(i) > 0)
set_intr_gate(IO_APIC_VECTOR(i), interrupt[i]);
}
+#endif
+
+
+
+/* these should only be called from Linux kernel so they need
+ to hard cli/sti -- I'm saving out of sloppiness, they should never
+ be called with hard cli.
+ */
+void rtl_emulate_shutdown_irq(unsigned int irq){ rtl_emulate_disable_irq(irq);}
+
+void rtl_emulate_disable_irq(unsigned int irq){
+ if(rtl_global.rtl_off){
+ irq_desc[irq].handler->disable(irq);
+ return;
+ }
+
+ /* don't actually disable here. We are optimistic and
+ only mask/disable in intercept */
+ atomic_global_soft_disable(irq);
+}
+void rtl_emulate_startup_irq(unsigned int irq){
+ int flags;
+ if(rtl_global.rtl_off){
+ irq_desc[irq].handler->startup(irq);
+ global_soft_enable(irq);
+ return;
+ }
+ rtl_hard_savef_and_cli(flags);
+ rtl_spin_lock(&rtl_global.hard_irq_controller_lock);
+ global_soft_enable(irq);
+ irq_desc[irq].handler->startup(irq); /* start it whether pending or
+ not */
+ rtl_spin_unlock(&rtl_global.hard_irq_controller_lock);
+ rtl_hard_restore_flags(flags);
+}
+void rtl_emulate_enable_irq(unsigned int irq){
+ int flags;
+ if(rtl_global.rtl_off){
+ irq_desc[irq].handler->enable(irq);
+ global_soft_enable(irq);
+ return;
+ }
+ rtl_hard_savef_and_cli(flags);
+ rtl_spin_lock(&rtl_global.hard_irq_controller_lock);
+ global_soft_enable(irq);
+ if(!global_is_pending_irq(irq)){
+ irq_desc[irq].handler->enable(irq);
+ }
+ rtl_spin_unlock(&rtl_global.hard_irq_controller_lock);
+ rtl_hard_restore_flags(flags);
+}
+
+void rtl_test_cli(unsigned int *);
+#define IENABLE 0x200 /* need to have the actual bit set since global_cli and
+ global_save_flags etc look at it */
+void __cli(void) {
+ DeclareAndInit(cpu_id);
+ if(rtl_global.rtl_off)rtl_hard_cli();
+ soft_cli();
+}
+void __restore_flags(unsigned int x) {
+ DeclareAndInit(cpu_id);
+ if(rtl_global.rtl_off){
+ if(x& IENABLE) {
+ soft_sti();
+ rtl_hard_sti();
+ }
+ else {
+ soft_cli();
+ rtl_hard_cli();
+ }
+ return;
+ }
+ if(x)__sti();
+ else __cli();
+}
+unsigned int __return_flags(void) {
+ DeclareAndInit(cpu_id);
+ if(rtl_global.rtl_off) {
+ unsigned int y;
+ rtl_hard_save_flags(y);
+ if(y & 0x200) soft_sti();
+ else soft_cli();
+ }
+ return ((RTL_LOCAL.flags & RTL_L_IENABLE_BIT)? IENABLE:0);
+}
+/* DIAGNOSTICS */
+
+/* Diagnostics */
+void rtl_test_cli(unsigned int *x)
+{
+ unsigned long g,j;
+ HardDeclareAndInit(cpu_id);
+ rtl_hard_save_flags(g);
+ g = (g&0x200? 1: 0);
+ j = (RTL_LOCAL.flags & RTL_L_IENABLE_BIT ? 1: 0);
+ if( g != j)
+ {
+ printk("RTL g: x %p x-1:%x x-2:%x\n",x,*( (int *)x -1),*((int *)x -2));
+ }
+ return;
+}
+
+void do_rtl_debug(void){
+ unsigned long g;
+ HardDeclareAndInit(cpu_id);
+ rtl_hard_save_flags(g);
+ rtl_hard_cli();
+ conpr("\nflags="); conprn(g);
+#ifdef __SMP__
+ conpr("\nProcessor="); conprn(cpu_id);
+ conpr("\nGlobal hard_irq_controller_lock=");
+ conprn(rtl_global.hard_irq_controller_lock.lock);
+#endif // __SMP__
+conpr("\npending 0;"); conprn(rtl_global.pending[0]);
+conpr("\nrtl_off;"); conprn(rtl_global.rtl_off);
+conpr("\nsoft_enabled 0 ;"); conprn(rtl_global.soft_enabled[0]);
+conpr("\nrtirq 0;"); conprn(rtl_global.rtirq[0]);
+conpr("\nlocal flags;"); conprn(RTL_LOCAL.flags);
+conpr("\ncached irq flags="); conprn(cached_irq_mask);
+conpr("----------------\n");
+ //outb_p(0x34,0x43); /* binary, mode 2, LSB/MSB, ch 0 */
+// outb_p(LATCH & 0xff , 0x40); /* LSB */
+// outb(LATCH >> 8 , 0x40); /* MSB */
+rtl_hard_restore_flags(g);
+
+}
+
+void rtl_panic(const char *x)
+{
+ conpr("\nPANIC "); conpr(x);
+ do_rtl_debug();
+ while(1);
+}
+void rtl_test_timer(unsigned char *s)
+{
+ unsigned long g;
+ if(rtl_global.rtl_off)return;
+ rtl_hard_save_flags(g);
+ conpr(s);
+ g = (g&0x200? 1: 0);
+ if(!g)
+ {
+ conpr("real cli in "); conpr(s); conpr("\n");
+ }
+ if(!(rtl_global.soft_enabled[0] & 1)){
+ conpr("no timer enable:"); conpr(s); conpr("\n");
+ conpr("pending=:"); conprn(rtl_global.pending[0]); conpr("\n");
+ }
+
+}
+void rtl_make_sure_real_sti(const char *s){
+ unsigned long g;
+ if(rtl_global.rtl_off)return;
+ rtl_hard_save_flags(g);
+ g = (g&0x200? 1: 0);
+ if(!g)
+ {
+ conpr("real cli in "); conpr(s); conpr("\n");
+ }
+ return;
+}
+
+int rtltc(void)
+{
+ unsigned long g;
+ rtl_hard_save_flags(g);
+ return (g&0x200? 1: 0);
+}
+
+
+/* INTERCEPTS */
+/* this intercepts SMP irqs */
+#ifdef __SMP__
+
+static inline void do_local_irq(int , struct pt_regs *);
+
+static unsigned int default_local_timer_handler(struct pt_regs *r)
+{
+ HardDeclareAndInit(cpu_id);
+ rtl_local_pend_vec(LOCAL_TIMER_VECTOR,cpu_id);
+ return 0;
+}
+
+static unsigned int default_local_resched_handler(struct pt_regs *r)
+{
+ return 0;
+}
+
+struct rtl_local_handlers local_timer_handler[NR_CPUS] = {{default_local_timer_handler}, {default_local_timer_handler}};
+struct rtl_local_handlers local_resched_handler[NR_CPUS] = {{default_local_resched_handler}, {default_local_resched_handler}};
+
+unsigned int rtl_smp_intercept(struct pt_regs regs){
+ unsigned int vector = regs.orig_eax & 0xff;
+ HardDeclareAndInit(cpu_id);
+ ack_APIC_irq();
+
+ rtl_trace(RTL_TRACE_SMP_INTERCEPT, vector, regs.eip);
+
+ if(rtl_global.rtl_off){
+ rtl_spin_unlock(&rtl_global.hard_irq_controller_lock);
+ soft_cli();
+ do_local_irq(vector,®s);
+ soft_sti();
+ return 0;
+ }
+
+ switch (vector) {
+ case RTL_RESCHEDULE_VECTOR:
+ local_resched_handler[cpu_id].handler(®s);
+ rtl_trace(RTL_TRACE_SMP_INTERCEPT_EXIT, vector, regs.eip);
+ return 1;
+ case LOCAL_TIMER_VECTOR:
+ local_timer_handler[cpu_id].handler(®s);
+ break;
+ case INVALIDATE_TLB_VECTOR:
+ case STOP_CPU_VECTOR:
+ case CALL_FUNCTION_VECTOR:
+ case RESCHEDULE_VECTOR:
+ rtl_local_pend_vec(vector,cpu_id);
+ break;
+ default:
+ conpr("RTL unexpected local vector: ");
+ conprn(vector);
+ return 1;
+ }
+
+
+ if((regs.eflags & 0x200) && is_idle_realtime_system() && is_soft_sti())
+ {
+ soft_cli();
+ rtl_hard_sti(); /* yikes */
+ __sti(); /* handle any pending interrupts */
+ rtl_trace(RTL_TRACE_SMP_INTERCEPT_EXIT, vector, regs.eip);
+ return 0;
+ }
+ else return 1;
+}
+static inline void do_local_irq(int vector, struct pt_regs *regs){
+ switch(vector){
+ /* IPI for rescheduling */
+ case RESCHEDULE_VECTOR:
+ smp_reschedule_interrupt();
+ break;
+ /* IPI for invalidation */
+ case INVALIDATE_TLB_VECTOR:
+ smp_invalidate_interrupt();
+ break;
+ /* IPI for CPU halt */
+ case STOP_CPU_VECTOR:
+ smp_stop_cpu_interrupt();
+ break;
+ /* self generated IPI for local APIC timer */
+ case LOCAL_TIMER_VECTOR:
+ smp_apic_timer_interrupt(regs);
+ break;
+ /* IPI for function call control */
+ case CALL_FUNCTION_VECTOR:
+ smp_call_function_interrupt();
+ break;
+ /* IPI vector for APIC spurious interrupts */
+ case SPURIOUS_APIC_VECTOR:
+ smp_spurious_interrupt();
+ break;
+ default:
+ printk("RTL: bad smp vector %x\n",vector);
+ break;
+ }
+}
+
+#endif
+
+unsigned int rtl_intercept(struct pt_regs regs)
+{
+ unsigned int irq = regs.orig_eax & 0xff;
+ HardDeclareAndInit(cpu_id);
+
+ rtl_trace(RTL_TRACE_INTERCEPT, irq, regs.eip);
+ /*
+ * We ack quickly, we don't want the irq controller
+ * thinking we're snobs just because some other CPU has
+ * disabled global interrupts (we have already done the
+ * INT_ACK cycles, it's too late to try to pretend to the
+ * controller that we aren't taking the interrupt).
+ *
+ * 0 return value means that this irq is already being
+ * handled by some other CPU. (or is disabled)
+ */
+ rtl_spin_lock(&rtl_global.hard_irq_controller_lock);
+ irq_desc[irq].handler->mask_and_ack(irq);
+ if(rtl_global.rtl_off){
+ rtl_spin_unlock(&rtl_global.hard_irq_controller_lock);
+ soft_cli();
+ do_IRQ(irq,®s);
+ soft_sti();
+ return 0;
+ }
+ /* if there is a real time handler, call it and see if it is
+ willing to share the interrupt */
+ if(there_is_a_rt_handler(irq) && rtl_global_handlers[irq].handler)
+ {
+ rtl_spin_unlock(&rtl_global.hard_irq_controller_lock);
+ rtl_global_handlers[irq].handler(irq,®s);
+ rtl_hard_cli(); /* driver may have hard sti'd */
+ rtl_spin_lock(&rtl_global.hard_irq_controller_lock);
+ if(!global_is_pending_irq(irq)){/* does linux need it? */
+ rtl_spin_unlock(&rtl_global.hard_irq_controller_lock);
+ rtl_trace2(RTL_TRACE_INTERCEPT_EXIT, irq);
+ return 1;
+ }
+ }
+ else {
+ global_pend_irq(irq); /*note structure is locked */
+ }
+ if( is_soft_sti() && is_idle_realtime_system()
+ && global_is_enabled_irq(irq))
+ {
+ global_unpend_irq(irq); /* because we call do_IRQ */
+ soft_cli(); /*soft disable interrupts */
+ rtl_spin_unlock(&rtl_global.hard_irq_controller_lock);
+ rtl_hard_sti(); /* yikes */
+ do_IRQ(irq,®s);
+ __sti(); /* take care of any left over irqs */
+
+ rtl_trace2(RTL_TRACE_INTERCEPT_EXIT, irq);
+ return 0;
+ }
+ rtl_global.pended_since_sti = 1;
+ rtl_spin_unlock(&rtl_global.hard_irq_controller_lock);
+ rtl_trace2(RTL_TRACE_INTERCEPT_EXIT, irq);
+ return 1;
+
+}
+
+
+
+/* pt_regs
+long ebx= 0, long ecx=0, long edx=0, long esi=0, long edi=0,
+long ebp=0, long eax=0, int xds= __KERNEL_DS, int xes=0, long orig_eax=0,
+long eip= (long)__sti, int xcs= __KERNEL_CS, long eflags= IENABLE,
+long esp=0, int xss=0
+*/
+#define FAKE_REGS { 0, 0, 0, 0, 0, 0, 0, __KERNEL_DS, 0, 0, (long)__sti, __KERNEL_CS, IENABLE, 0, 0 }
+
+#define MAX_FAKE_DEPTH 200
+struct pt_regs fake_regs[NR_CPUS][MAX_FAKE_DEPTH];
+struct pt_regs *fake_top[NR_CPUS];
+struct pt_regs *next_fake_top(void){
+ int i;
+ struct pt_regs *r = 0;
+#ifdef __SMP__
+ DeclareAndInit(cpu_id);
+#else
+ unsigned int cpu_id = 0;
+#endif
+ for(i=0; i < MAX_FAKE_DEPTH;i++){
+ if(fake_regs[cpu_id][i].orig_eax)continue;
+ else{
+ r = &fake_regs[cpu_id][i];
+ r->orig_eax = -1;
+ break;}
+ }
+ if(!r)printk("RTL is astonished to announce out of fake regs\n");
+ return r;
+
+}
+
+void pop_fake(struct pt_regs *r){ r->orig_eax = 0; }
+
+
+
+#ifdef __SMP__
+static inline int fake_local_irq(unsigned int);
+static inline int fake_local_irq(unsigned int cpu_id){
+ struct pt_regs *r;
+ unsigned int pos;
+ rtl_hard_cli();
+ if( !(r= next_fake_top())) {
+ rtl_hard_sti();
+ return 0;
+ }
+ if(RTL_LOCAL.pending){
+ pos = ffz(~RTL_LOCAL.pending);
+ clear_bit(pos,&RTL_LOCAL.pending);
+ r->orig_eax = -1;
+ rtl_hard_sti(); /* yikes */
+ do_local_irq(LOCAL_PND_TO_VECTOR(pos),r);
+ pop_fake(r);
+ return 1;
+ }
+ rtl_hard_sti(); /* yikes */
+ pop_fake(r);
+ return 0; /* didn't find anything to emulate */
+}
+#else
+#define fake_local_irq(x) 0
+#endif
+
+static inline int fake_global_irq(void);
+static inline int fake_global_irq(){
+ int i,pos,active;
+ struct pt_regs *r;
+ rtl_hard_cli();
+ if(!(r= next_fake_top())){
+ rtl_hard_sti();
+ return 0;
+ }
+ rtl_spin_lock(&rtl_global.hard_irq_controller_lock);
+ for(i=0; i < IRQ_ARRAY_SIZE;i++){
+ if((active= (rtl_global.pending[i]&rtl_global.soft_enabled[i])))
+ {
+ pos = ffz(~active);
+ clear_bit(pos,&rtl_global.pending[i]);
+ rtl_spin_unlock(&rtl_global.hard_irq_controller_lock);
+ rtl_hard_sti(); /* yikes */
+ r->orig_eax = pos_and_index_to_irq(pos,i);
+ do_IRQ(pos_and_index_to_irq(pos,i),r);
+ pop_fake(r);
+ return 1;
+ }
+ }
+ rtl_spin_unlock(&rtl_global.hard_irq_controller_lock);
+ rtl_hard_sti(); /* yikes */
+ pop_fake(r);
+ return 0; /* didn't find anything to emulate */
+}
+
+void __sti(){
+ unsigned int faked_an_interrupt = 0;
+ DeclareAndInit(cpu_id);
+
+ soft_sti();
+ rtl_hard_sti();
+ if(rtl_global.rtl_off) return;
+ do{
+ soft_cli();
+ faked_an_interrupt = fake_global_irq()| fake_local_irq(cpu_id);
+ soft_sti();
+ } while((faked_an_interrupt > 0)
+ || (test_and_clear_bit(0,&rtl_global.pended_since_sti))
+ || test_and_clear_bit(RTL_L_SINCE_STI_POS, &RTL_LOCAL.flags));
+ /* the point of this loop is to make sure that IRQs are not
+ stranded pending.
+ fake_irq may return 0, indicating no irqs pending (nothing to
+ fake) and then a new irq may pend. If so, pended_since_sti will
+ be true. If an irq occurs after the test for pended_since, it
+ will simply roll into a second invocation of __sti since we
+ only do the test with IENABLE and in_sti=0;
+ Might need a MB, but it should be doable more simply.
+ */
+
+}
+
+void rtl_init(void)
+{
+ DeclareAndInit(cpu_id);
+#ifdef CONFIG_RTL
+ printk("RTL start");
+ soft_cli();
+ if(test_and_clear_bit(0,&rtl_global.rtl_off)) {
+ // rtl time stuff is now in a module
+ }
+ printk("ed\n");
+#endif
+ rtl_hard_sti();
+ return;
+}
+
+int rtl_request_global_irq(unsigned int irq,
+ unsigned int (*handler)(unsigned int, struct pt_regs *))
+{
+ if (!test_and_set_bit(irq,&rtl_global.rtirq)) {
+ rtl_global_handlers[irq].handler =handler;
+/* rtl_hard_enable_irq (irq); */
+ return 0;
+ }
+ return -EBUSY;
+}
+
+int rtl_free_global_irq(unsigned int irq )
+{
+ if (!test_bit(irq,&rtl_global.rtirq)) {
+ return -EINVAL;
+ } else {
+ rtl_global_handlers[irq].handler = 0;
+ clear_bit(irq,&rtl_global.rtirq);
+ return 0;
+ }
+}
+
+
+
+#ifdef __SMP__
+/* spinlock_t rtl_lock; */
+int rtl_request_local_irq(int i, unsigned int (*handler)(struct pt_regs *r), unsigned int cpu) {
+ if (i == LOCAL_TIMER_VECTOR) {
+ local_timer_handler[cpu].handler = handler;
+ return 0;
+ }
+ if (i == RTL_RESCHEDULE_VECTOR) {
+ local_resched_handler[cpu].handler = handler;
+ return 0;
+ }
+ printk("rtl_request_local_irq not implemented yet\n");
+ return -EINVAL;
+}
+
+int rtl_free_local_irq(int i, unsigned int cpu){
+ if (i == LOCAL_TIMER_VECTOR) {
+ local_timer_handler[cpu].handler = default_local_timer_handler;
+ return 0;
+ }
+ if (i == RTL_RESCHEDULE_VECTOR) {
+ local_resched_handler[cpu].handler = default_local_resched_handler;
+ return 0;
+ }
+ printk("rtl_free_local_irq not implemented yet\n");
+ return -EINVAL;
+}
+
#endif
Index: linux22/arch/i386/kernel/irq.h
diff -u linux22/arch/i386/kernel/irq.h:1.1.1.1 linux22/arch/i386/kernel/irq.h:1.2
--- linux22/arch/i386/kernel/irq.h:1.1.1.1 Thu Aug 12 22:06:29 1999
+++ linux22/arch/i386/kernel/irq.h Thu Aug 12 22:12:36 1999
@@ -2,7 +2,19 @@
#define __irq_h
#include <asm/irq.h>
+#include <linux/rtl.h>
+extern void rtl_emulate_enable_irq(unsigned int irq);
+
+/* RTL real time interrupt handlers */
+struct rtl_global_handlers{
+ unsigned int (*handler)(unsigned int irq, struct pt_regs *r);
+}rtl_global_handlers[64];
+
+struct rtl_local_handlers{
+ unsigned int (*handler)(struct pt_regs *r);
+};
+
/*
* Interrupt controller descriptor. This is all we need
* to describe about the low-level hardware.
@@ -14,6 +26,7 @@
void (*handle)(unsigned int irq, struct pt_regs * regs);
void (*enable)(unsigned int irq);
void (*disable)(unsigned int irq);
+ void (*mask_and_ack)(unsigned int irq);
};
extern struct hw_interrupt_type no_irq_type;
@@ -67,13 +80,27 @@
#define STOP_CPU_VECTOR 0x40
#define LOCAL_TIMER_VECTOR 0x41
#define CALL_FUNCTION_VECTOR 0x50
+#define RTL_RESCHEDULE_VECTOR 0x51
+
+#define VECTOR_TO_LOCAL_PND(x) (((x)>>3)|((x)&1)) /* ok, it's stupid */
+#define LOCAL_PND_TO_VECTOR(x) ((((x)&0xe)<<3)|((x)&1)) /* ok, it's stupid */
+ /* but 0x30 -> 6
+ 0x31 -> 7
+ 0x40 -> 8
+ 0x41 -> 9
+ 0x50 -> A
+ etc
+ only a problem if use more than one bit
+ in the low order 4 bits or more than
+ 31 vectors total!
+ */
+ /*
+ * First APIC vector available to drivers: (vectors 0x61-0xfe)
+ */
+#define IRQ0_TRAP_VECTOR 0x61
+
/*
- * First APIC vector available to drivers: (vectors 0x51-0xfe)
- */
-#define IRQ0_TRAP_VECTOR 0x51
-
-/*
* This IRQ should never happen, but we print a message nevertheless.
*/
#define SPURIOUS_APIC_VECTOR 0xff
@@ -185,38 +212,59 @@
* SMP has a few special interrupts for IPI messages
*/
-#define BUILD_SMP_INTERRUPT(x) \
-asmlinkage void x(void); \
+#define BUILD_COMMON_SMP_IRQ() \
__asm__( \
-"\n"__ALIGN_STR"\n" \
-SYMBOL_NAME_STR(x) ":\n\t" \
- "pushl $-1\n\t" \
+ "\n" __ALIGN_STR"\n" \
+ "common_smp_interrupt:\n\t" \
SAVE_ALL \
- "call "SYMBOL_NAME_STR(smp_##x)"\n\t" \
- "jmp ret_from_intr\n");
+ "call "SYMBOL_NAME_STR(rtl_smp_intercept)"\n\t"\
+ "testl %eax,%eax;\n\t"\
+ "jz ret_from_intr;\n\t" \
+ "popl %ebx; \n\t" \
+ "popl %ecx; \n\t" \
+ "popl %edx; \n\t" \
+ "popl %esi; \n\t" \
+ "popl %edi; \n\t" \
+ "popl %ebp; \n\t" \
+ "popl %eax; \n\t" \
+ "popl %ds; \n\t" \
+ "popl %es; \n\t" \
+ "addl $4,%esp; \n\t" \
+ "iret; \n\t" );
-#define BUILD_SMP_TIMER_INTERRUPT(x) \
-asmlinkage void x(struct pt_regs * regs); \
+#define BUILD_SMP_INTERRUPT(vctr,f) \
+asmlinkage void f(void); \
__asm__( \
"\n"__ALIGN_STR"\n" \
-SYMBOL_NAME_STR(x) ":\n\t" \
- "pushl $-1\n\t" \
- SAVE_ALL \
- "movl %esp,%eax\n\t" \
- "pushl %eax\n\t" \
- "call "SYMBOL_NAME_STR(smp_##x)"\n\t" \
- "addl $4,%esp\n\t" \
- "jmp ret_from_intr\n");
+SYMBOL_NAME_STR(f) ":\n\t" \
+ "pushl $"SYMBOL_NAME_STR(vctr)"\n\t" \
+ "jmp common_smp_interrupt");
+/* RTL the difference is taken care of in the intercept routine */
+#define BUILD_SMP_TIMER_INTERRUPT(x,y) BUILD_SMP_INTERRUPT(x,y)
#endif /* __SMP__ */
+/* The restore state part of this better change if
+ SAVE_ALL changes or things will not look good VY*/
#define BUILD_COMMON_IRQ() \
__asm__( \
"\n" __ALIGN_STR"\n" \
"common_interrupt:\n\t" \
SAVE_ALL \
- "call "SYMBOL_NAME_STR(do_IRQ)"\n\t" \
- "jmp ret_from_intr\n");
+ "call "SYMBOL_NAME_STR(rtl_intercept)"\n\t"\
+ "testl %eax,%eax;\n\t"\
+ "jz ret_from_intr;\n\t" \
+ "popl %ebx; \n\t" \
+ "popl %ecx; \n\t" \
+ "popl %edx; \n\t" \
+ "popl %esi; \n\t" \
+ "popl %edi; \n\t" \
+ "popl %ebp; \n\t" \
+ "popl %eax; \n\t" \
+ "popl %ds; \n\t" \
+ "popl %es; \n\t" \
+ "addl $4,%esp; \n\t" \
+ "iret; \n\t" );
/*
* subtle. orig_eax is used by the signal code to distinct between
Index: linux22/arch/i386/kernel/smp.c
diff -u linux22/arch/i386/kernel/smp.c:1.1.1.2 linux22/arch/i386/kernel/smp.c:1.6
--- linux22/arch/i386/kernel/smp.c:1.1.1.2 Wed Oct 20 23:16:03 1999
+++ linux22/arch/i386/kernel/smp.c Tue Oct 26 01:29:28 1999
@@ -1581,6 +1581,14 @@
#endif
}
+
+#ifdef __RTL__
+void rtl_reschedule(unsigned int cpu){
+ send_IPI_single(cpu,RTL_RESCHEDULE_VECTOR);
+}
+#endif
+
+
/*
* This is fraught with deadlocks. Probably the situation is not that
* bad as in the early days of SMP, so we might ease some of the
@@ -1625,7 +1633,7 @@
* Spin waiting for completion
*/
- stuck = 50000000;
+ stuck = 250000000;
while (smp_invalidate_needed) {
/*
* Take care of "crossing" invalidates
@@ -1840,7 +1848,10 @@
* want to be able to accept NMI tlb invalidates
* during this time.
*/
+#ifndef __RTL__
ack_APIC_irq();
+ /* RTL -- no ack here, ack in intercept */
+#endif
smp_local_timer_interrupt(regs);
}
@@ -1851,7 +1862,10 @@
*/
asmlinkage void smp_reschedule_interrupt(void)
{
+#ifndef __RTL__
ack_APIC_irq();
+ /* RTL -- no ack here, ack in intercept */
+#endif
}
/*
@@ -1861,9 +1875,9 @@
{
if (test_and_clear_bit(smp_processor_id(), &smp_invalidate_needed))
local_flush_tlb();
-
+#ifndef __RTL__
ack_APIC_irq();
-
+#endif
}
static void stop_this_cpu (void)
@@ -1892,7 +1906,9 @@
void *info = smp_call_function_data->info;
int wait = smp_call_function_data->wait;
+#ifndef __RTL__
ack_APIC_irq ();
+#endif
/* Notify initiating CPU that I've grabbed the data and am about to
execute the function */
atomic_dec (&smp_call_function_data->unstarted_count);
@@ -2125,8 +2141,8 @@
/*
* We ACK the APIC, just in case there is something pending.
*/
+ ack_APIC_irq(); /* RTL ok to ack in an initialization routine*/
- ack_APIC_irq ();
__restore_flags(flags);
}
Index: linux22/arch/i386/kernel/time.c
diff -u linux22/arch/i386/kernel/time.c:1.1.1.1 linux22/arch/i386/kernel/time.c:1.3
--- linux22/arch/i386/kernel/time.c:1.1.1.1 Thu Aug 12 22:06:29 1999
+++ linux22/arch/i386/kernel/time.c Mon Oct 25 03:07:40 1999
@@ -223,7 +223,7 @@
return count;
}
-static unsigned long (*do_gettimeoffset)(void) = do_slow_gettimeoffset;
+unsigned long (*do_gettimeoffset)(void) = do_slow_gettimeoffset;
#else
Index: linux22/fs/proc/array.c
diff -u linux22/fs/proc/array.c:1.1.1.3 linux22/fs/proc/array.c:1.4
--- linux22/fs/proc/array.c:1.1.1.3 Wed Oct 20 23:13:43 1999
+++ linux22/fs/proc/array.c Wed Oct 20 23:24:41 1999
@@ -75,6 +75,9 @@
int get_malloc(char * buffer);
#endif
+#ifdef CONFIG_RTL
+extern int get_rtl_status(char *buf);
+#endif
static int open_kcore(struct inode * inode, struct file * filp)
{
@@ -1383,6 +1386,10 @@
#ifdef CONFIG_RTC
case PROC_RTC:
return get_rtc_status(page);
+#endif
+#ifdef CONFIG_RTL
+ case PROC_RTLINUX:
+ return get_rtl_status(page);
#endif
#ifdef CONFIG_SGI_DS1286
case PROC_RTC:
Index: linux22/fs/proc/root.c
diff -u linux22/fs/proc/root.c:1.1.1.2 linux22/fs/proc/root.c:1.3
--- linux22/fs/proc/root.c:1.1.1.2 Wed Oct 20 23:13:43 1999
+++ linux22/fs/proc/root.c Wed Oct 20 23:24:41 1999
@@ -633,6 +633,13 @@
0, &proc_array_inode_operations
};
#endif
+#ifdef CONFIG_RTL
+static struct proc_dir_entry proc_root_rtlinux = {
+ PROC_RTLINUX, 7, "rtlinux",
+ S_IFREG | S_IRUGO, 1, 0, 0,
+ 0, &proc_array_inode_operations
+ };
+#endif
#ifdef CONFIG_SGI_DS1286
static struct proc_dir_entry proc_root_ds1286 = {
PROC_RTC, 3, "rtc",
@@ -686,6 +693,9 @@
proc_register(&proc_root, &proc_root_version);
proc_register(&proc_root, &proc_root_cpuinfo);
proc_register(&proc_root, &proc_root_self);
+#ifdef CONFIG_RTL
+ proc_register(&proc_root, &proc_root_rtlinux);
+#endif
proc_net = create_proc_entry("net", S_IFDIR, 0);
proc_scsi = create_proc_entry("scsi", S_IFDIR, 0);
#ifdef CONFIG_SYSCTL
Index: linux22/include/asm-i386/irq.h
diff -u linux22/include/asm-i386/irq.h:1.1.1.1 linux22/include/asm-i386/irq.h:1.2
--- linux22/include/asm-i386/irq.h:1.1.1.1 Thu Aug 12 22:05:36 1999
+++ linux22/include/asm-i386/irq.h Thu Aug 12 22:12:37 1999
@@ -21,7 +21,13 @@
* Since vectors 0x00-0x1f are used/reserved for the CPU,
* the usable vector space is 0x20-0xff (224 vectors)
*/
+
+#ifndef __RTL__
#define NR_IRQS 224
+#else
+/* RTL quick hack */
+#define NR_IRQS 64
+#endif
static __inline__ int irq_cannonicalize(int irq)
{
Index: linux22/include/asm-i386/rtl_sync.h
diff -u /dev/null linux22/include/asm-i386/rtl_sync.h:1.5
--- /dev/null Thu Nov 25 15:32:16 1999
+++ linux22/include/asm-i386/rtl_sync.h Thu Oct 21 00:35:56 1999
@@ -0,0 +1,69 @@
+#ifndef __RTL_LINUX_SYNC_H__
+#define __RTL_LINUX_SYNC_H__
+
+#include <linux/rtl_trace.h>
+#include <asm/spinlock.h>
+
+/* DO NOT USE THESE OUTSIDE OF THE RTLINUX CODE!!! */
+/* (c) Victor Yodaiken 1999. */
+
+#ifndef CONFIG_RTL_TRACER
+
+#define rtl_allow_interrupts() __asm__ __volatile__ ("sti": : :"memory")
+#define rtl_stop_interrupts() __asm__ __volatile__ ("cli": : :"memory")
+#define rtl_save_interrupts(x) \
+__asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */ :"memory")
+#define rtl_restore_interrupts(x) \
+__asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory")
+#define rtl_no_interrupts(x) \
+__asm__ __volatile__("pushfl ; cli; popl %0": "=g" (x): /* no input */ :"memory")
+/* I wonder if the code above is slower because the cli gives the pushed
+ value a chance to disappear from some forwarding register? VY */
+
+
+#else
+
+#define rtl_allow_interrupts() do { rtl_trace2a(RTL_TRACE_ALLOW_INTERRUPTS, 0); __asm__ __volatile__ ("sti": : :"memory"); } while (0)
+#define rtl_stop_interrupts() do { __asm__ __volatile__ ("cli": : :"memory"); rtl_trace2(RTL_TRACE_STOP_INTERRUPTS, 0); } while (0)
+#define rtl_save_interrupts(x) \
+do { __asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */ :"memory"); rtl_trace2(RTL_TRACE_SAVE_INTERRUPTS, x); } while (0)
+#define rtl_restore_interrupts(x) \
+do { __asm__ __volatile__ ("cli": : :"memory"); rtl_trace2a(RTL_TRACE_RESTORE_INTERRUPTS, x); __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory"); } while (0)
+#define rtl_no_interrupts(x) \
+do { __asm__ __volatile__("pushfl ; cli; popl %0": "=g" (x): /* no input */ :"memory"); rtl_trace2(RTL_TRACE_NO_INTERRUPTS, x); } while (0)
+
+#endif
+
+#define rtl_hard_savef_and_cli(x) rtl_no_interrupts(x)
+#define rtl_hard_restore_flags(x) rtl_restore_interrupts(x)
+#define rtl_hard_sti() rtl_allow_interrupts()
+#define rtl_hard_cli() rtl_stop_interrupts()
+#define rtl_hard_save_flags(x) rtl_save_interrupts(x)
+
+#ifdef __SMP__
+/*
+#define rtl_spin_lock(x) { static int z;\
+ for(z=0;z<100000000;z++)\
+ if(!test_and_set_bit(0,x.lock))break;\
+ rtl_trace2(RTL_TRACE_SPIN_LOCK, (long ) x); \
+ if(! rtl_global.rtl_off){ \
+ if(z==100000000) { \
+ conpr("\nRTLBADSpin=");\
+ conprn((unsigned int)&z);\
+ panic("badspin"); }}}
+
+
+#define rtl_spin_unlock(x) do { rtl_trace2a(RTL_TRACE_SPIN_UNLOCK, (long) x); clear_bit(0,x.lock); } while (0)
+*/
+
+#define rtl_spin_lock(x) do { spin_lock(x); rtl_trace2(RTL_TRACE_SPIN_LOCK, (long)x); } while (0)
+#define rtl_spin_unlock(x) do { rtl_trace2a(RTL_TRACE_SPIN_UNLOCK, (long) x); spin_unlock(x); } while (0)
+
+#else
+
+#define rtl_spin_lock(x)
+#define rtl_spin_unlock(x)
+
+#endif
+
+#endif
Index: linux22/include/asm-i386/system.h
diff -u linux22/include/asm-i386/system.h:1.1.1.1 linux22/include/asm-i386/system.h:1.2
--- linux22/include/asm-i386/system.h:1.1.1.1 Thu Aug 12 22:05:36 1999
+++ linux22/include/asm-i386/system.h Thu Aug 12 22:12:37 1999
@@ -174,6 +174,8 @@
#define wmb() __asm__ __volatile__ ("": : :"memory")
/* interrupt control.. */
+/* RTL: these are all defined in irq.c for now */
+#if 0 /* ! __RTL__ */
#define __sti() __asm__ __volatile__ ("sti": : :"memory")
#define __cli() __asm__ __volatile__ ("cli": : :"memory")
#define __save_flags(x) \
@@ -181,6 +183,13 @@
#define __restore_flags(x) \
__asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory")
+#else
+extern void __sti(void);
+extern void __cli(void);
+extern void __restore_flags(unsigned int);
+extern unsigned int __return_flags(void);
+#define __save_flags(x) {x = __return_flags();}
+#endif
#ifdef __SMP__
Index: linux22/include/linux/cons.h
diff -u /dev/null linux22/include/linux/cons.h:1.5
--- /dev/null Thu Nov 25 15:32:20 1999
+++ linux22/include/linux/cons.h Mon Oct 25 08:38:22 1999
@@ -0,0 +1,94 @@
+#ifndef __RTL_CONS_H__
+#define __RTL_CONS_H__
+/*
+ * debugging routines for RT-Linux
+ *
+ * Copyright (C) Michael Barabanov 1997
+ * Copyright (C) VJY Associates 1999
+ * Released under the terms of the GPL
+ *
+ */
+
+#include <asm/system.h>
+
+extern void conpr(const char * b);
+
+extern int rtl_printf(const char * fmt, ...);
+
+static inline void conprn(const unsigned int hexnum)
+{
+ int i;
+ unsigned int d;
+ unsigned int n = hexnum;
+ char s[10];
+ s[9] = 0;
+ s[8] = ' ';
+ for (i=7; i>=0; i--) {
+ d = n % 16;
+ if (d < 10) {
+ d += '0';
+ } else {
+ d += 'a' - 10;
+ }
+ s[i] = d;
+ n = n / 16;
+ }
+ conpr(s);
+}
+
+static inline void conprd(const unsigned int num)
+{
+ int i;
+ unsigned int d;
+ unsigned int n = num;
+ char s[12];
+ s[11] = 0;
+ s[10] = ' ';
+ for (i=9; i>=0; i--) {
+ d = n % 10;
+ if (d < 10) {
+ d += '0';
+ } else {
+ d += 'a' - 10;
+ }
+ s[i] = d;
+ n = n / 10;
+ }
+ conpr(s);
+}
+
+#define rt_check_cli() { long flags; r_save_flags(flags); \
+ if (flags & 0x200) { \
+ conpr("interrupts are enabled!\n"); \
+ } \
+}
+
+#define CONPRX(a,b) {conpr(a); conprn((int)(b)); conpr("\n");}
+#define conprll(ll) { conprn((int)((ll) >> 32)); conprn((int) (ll)); }
+#define conprtime(ts) { conprd((ts).tv_sec); conprd((ts).tv_nsec); }
+
+#define PRINTAX \
+ "pushl %%eax\n\t" \
+ "pushl %%ebp\n\t" \
+ "pushl %%edi\n\t" \
+ "pushl %%esi\n\t" \
+ "pushl %%edx\n\t" \
+ "pushl %%ecx\n\t" \
+ "pushl %%ebx\n\t" \
+ "pushl %%eax\n\t" \
+ "call "SYMBOL_NAME_STR(conprn)"\n\t" \
+ "add $4, %%esp\n\t" \
+ "popl %%ebx\n\t \
+ popl %%ecx\n\t \
+ popl %%edx\n\t \
+ popl %%esi\n\t \
+ popl %%edi\n\t \
+ popl %%ebp\n\t \
+ popl %%eax\n\t"
+
+extern inline void conf(void) {
+ int i;
+ for ( i=0; i< 10000000; i++);
+}
+
+#endif
Index: linux22/include/linux/major.h
diff -u linux22/include/linux/major.h:1.1.1.2 linux22/include/linux/major.h:1.3
--- linux22/include/linux/major.h:1.1.1.2 Wed Sep 1 20:08:29 1999
+++ linux22/include/linux/major.h Wed Sep 1 20:18:51 1999
@@ -83,6 +83,7 @@
#define IDE4_MAJOR 56
#define IDE5_MAJOR 57
+#define RTF_MAJOR 150 /* real time fifos RTL */
#define SCSI_DISK1_MAJOR 65
#define SCSI_DISK2_MAJOR 66
#define SCSI_DISK3_MAJOR 67
Index: linux22/include/linux/proc_fs.h
diff -u linux22/include/linux/proc_fs.h:1.1.1.3 linux22/include/linux/proc_fs.h:1.4
--- linux22/include/linux/proc_fs.h:1.1.1.3 Wed Oct 20 23:13:57 1999
+++ linux22/include/linux/proc_fs.h Wed Oct 20 23:24:41 1999
@@ -53,6 +53,9 @@
PROC_SOUND,
PROC_MTRR, /* whether enabled or not */
PROC_FS
+#ifdef CONFIG_RTL
+ ,PROC_RTLINUX
+#endif
};
enum pid_directory_inos {
Index: linux22/include/linux/rtl.h
diff -u /dev/null linux22/include/linux/rtl.h:1.5
--- /dev/null Thu Nov 25 15:32:22 1999
+++ linux22/include/linux/rtl.h Sun Sep 19 15:24:51 1999
@@ -0,0 +1,35 @@
+/* Copyright Victor Yodaiken 1999.
+ Released under the terms of the GNU Library GPL
+ */
+
+#ifndef __rtl_h
+#define __rtl_h
+
+extern void rtl_make_rt_system_active(void);
+extern unsigned int rtl_rt_system_is_idle(void);
+extern void rtl_make_rt_system_idle(void);
+extern unsigned int rtl_hard_smp_processor_id(void);
+extern void rtl_reschedule(unsigned int);
+
+extern int rtl_get_soft_irq( void (*handler)(int, void *, struct pt_regs *),
+ const char * devname);
+
+extern int rtl_request_global_irq(unsigned int irq,
+ unsigned int (*handler)(unsigned int, struct pt_regs *));
+extern int rtl_free_global_irq(unsigned int irq);
+extern void rtl_global_pend_irq(int ix);
+
+/* if you don't say local, you mean global */
+#define rtl_request_irq(x, y) rtl_request_global_irq(x, y)
+#define rtl_free_irq(x) rtl_free_global_irq(x)
+
+#ifdef __SMP__
+int rtl_request_local_irq(int i, unsigned int (*handler)(struct pt_regs *r),
+ unsigned int cpu);
+int rtl_free_local_irq(int i, unsigned int cpu);
+
+extern void rtl_local_pend_vec(int intvec,int cpu_id);
+
+#endif
+
+#endif
Index: linux22/include/linux/rtl_trace.h
diff -u /dev/null linux22/include/linux/rtl_trace.h:1.5
--- /dev/null Thu Nov 25 15:32:22 1999
+++ linux22/include/linux/rtl_trace.h Sun Sep 19 18:54:15 1999
@@ -0,0 +1,43 @@
+#ifndef __RTL_TRACE_H__
+#define __RTL_TRACE_H__
+
+/* #undef to leave no trace */
+/* #define CONFIG_RTL_TRACER */
+
+/* event ids */
+enum { RTL_TRACE_STOP_INTERRUPTS = 1, RTL_TRACE_ALLOW_INTERRUPTS = 2,
+ RTL_TRACE_SAVE_INTERRUPTS = 4, RTL_TRACE_RESTORE_INTERRUPTS = 8,
+ RTL_TRACE_NO_INTERRUPTS = 16,
+ RTL_TRACE_SMP_INTERCEPT = 32, RTL_TRACE_SMP_INTERCEPT_EXIT = 64,
+ RTL_TRACE_USER = 128, RTL_TRACE_SPIN_LOCK = 256, RTL_TRACE_SPIN_UNLOCK = 512, RTL_TRACE_INTERCEPT = 1024, RTL_TRACE_INTERCEPT_EXIT = 2048,
+ RTL_TRACE_USER2 = 4096};
+
+#define RTL_TRACE_ALL 0xffffffff
+
+
+#ifdef CONFIG_RTL_TRACER
+extern void (*rtl_trace)(int event_id, long event_data, long eip);
+
+#define rtl_trace2(event_id, event_data) \
+do { \
+ long eip; \
+ __asm__("1: mov $1b, %%eax" : "=a" (eip) : ); \
+ rtl_trace(event_id, event_data, eip); \
+} while (0)
+
+#define rtl_trace2a(event_id, event_data) \
+do { \
+ long eip; \
+ __asm__("mov $1f, %%eax" : "=a" (eip) : ); \
+ rtl_trace(event_id, event_data, eip); \
+ __asm__("1:" : : ); \
+} while (0)
+
+#else
+
+#define rtl_trace(event_id, event_data, eip)
+#define rtl_trace2(event_id, event_data)
+#define rtl_trace2a(event_id, event_data)
+#endif
+
+#endif
Index: linux22/init/main.c
diff -u linux22/init/main.c:1.1.1.2 linux22/init/main.c:1.3
--- linux22/init/main.c:1.1.1.2 Wed Oct 20 23:13:52 1999
+++ linux22/init/main.c Wed Oct 20 23:24:41 1999
@@ -1143,6 +1143,9 @@
#endif
extern void initialize_secondary(void);
+#ifdef CONFIG_RTL
+extern void rtl_init(void);
+#endif
/*
* Activate the first processor.
@@ -1229,6 +1232,10 @@
* make syscalls (and thus be locked).
*/
smp_init();
+#ifdef CONFIG_RTL
+ rtl_init();
+ sti();
+#endif
kernel_thread(init, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
current->need_resched = 1;
cpu_idle(NULL);
Index: linux22/kernel/Makefile
diff -u linux22/kernel/Makefile:1.1.1.1 linux22/kernel/Makefile:1.2
--- linux22/kernel/Makefile:1.1.1.1 Thu Aug 12 22:05:32 1999
+++ linux22/kernel/Makefile Thu Aug 12 22:12:37 1999
@@ -15,6 +15,10 @@
module.o exit.o itimer.o info.o time.o softirq.o resource.o \
sysctl.o acct.o capability.o
+ifdef CONFIG_RTL
+O_OBJS += rtl.o
+endif
+
OX_OBJS += signal.o
ifeq ($(CONFIG_KMOD),y)
Index: linux22/kernel/ksyms.c
diff -u linux22/kernel/ksyms.c:1.1.1.2 linux22/kernel/ksyms.c:1.7
--- linux22/kernel/ksyms.c:1.1.1.2 Wed Oct 20 23:13:53 1999
+++ linux22/kernel/ksyms.c Tue Oct 26 01:29:35 1999
@@ -406,5 +406,53 @@
/* library functions */
EXPORT_SYMBOL(strnicmp);
+#ifdef __RTL__
+/* functions needed for RTL */
+#include <linux/rtl_trace.h>
+
+#ifdef CONFIG_RTL_TRACER
+EXPORT_SYMBOL(rtl_trace);
+#endif
+
+#include <asm/system.h>
+#include <linux/rtl.h>
+EXPORT_SYMBOL(__cli);
+EXPORT_SYMBOL(__sti);
+EXPORT_SYMBOL(__return_flags);
+EXPORT_SYMBOL(__restore_flags);
+
+#ifdef __SMP__
+EXPORT_SYMBOL(smp_found_config);
+#endif
+
+extern int rtl_printf(const char * fmt, ...);
+extern void conpr(const char * b);
+extern void rtl_hard_enable_irq(int );
+extern void rtl_hard_disable_irq(int );
+EXPORT_SYMBOL(rtl_printf);
+EXPORT_SYMBOL(conpr);
+EXPORT_SYMBOL(rtl_request_global_irq);
+EXPORT_SYMBOL(rtl_free_global_irq);
+EXPORT_SYMBOL(rtl_global_pend_irq);
+EXPORT_SYMBOL(rtl_get_soft_irq);
+EXPORT_SYMBOL(rtl_hard_enable_irq);
+EXPORT_SYMBOL(rtl_hard_disable_irq);
+#ifdef __SMP__
+EXPORT_SYMBOL(rtl_request_local_irq);
+EXPORT_SYMBOL(rtl_free_local_irq);
+EXPORT_SYMBOL(rtl_local_pend_vec);
+#endif
+
+#include <linux/vt_kern.h>
+EXPORT_SYMBOL(kd_mksound);
+
+EXPORT_SYMBOL(rtl_rt_system_is_idle);
+EXPORT_SYMBOL(rtl_make_rt_system_active);
+EXPORT_SYMBOL(rtl_make_rt_system_idle);
+#ifdef __SMP__
+EXPORT_SYMBOL(rtl_reschedule);
+#endif
+#endif /* __RTL__ */
+
/* init task, for moving kthread roots - ought to export a function ?? */
EXPORT_SYMBOL(init_task_union);
Index: linux22/kernel/rtl.c
diff -u /dev/null linux22/kernel/rtl.c:1.2
--- /dev/null Thu Nov 25 15:32:24 1999
+++ linux22/kernel/rtl.c Thu Oct 21 23:03:58 1999
@@ -0,0 +1,77 @@
+
+/* REAL TIME LINUX
+ Right now this is just for the proc entry
+
+ (c) Victor Yodaiken August 1998, GPL
+ */
+#include <linux/kernel.h>
+/* #include <linux/rtl_version.h> */
+#include <linux/version.h>
+
+#include <linux/mm.h>
+#include <linux/tty_driver.h>
+#include <linux/smp_lock.h>
+#include <linux/console.h>
+#include <linux/init.h>
+
+#include <asm/uaccess.h>
+#include <linux/cons.h>
+#include <linux/console.h>
+#include <asm/spinlock.h>
+#include <asm/rtl_sync.h>
+#include <stdarg.h>
+
+
+int get_rtl_status(char *buf)
+{
+ return(sprintf(buf, "RT-Linux version %s\n", UTS_RELEASE));
+}
+
+
+extern struct console *console_drivers;
+
+void conpr(const char *s)
+{
+ long flags;
+ static spinlock_t rtl_conpr_lock = SPIN_LOCK_UNLOCKED;
+ struct console *c;
+ int len = strlen(s);
+
+ rtl_hard_savef_and_cli(flags);
+ spin_lock(&rtl_conpr_lock);
+
+ c = console_drivers;
+ while(c) {
+ if ((c->flags & CON_ENABLED) && c->write)
+ c->write(c, s, len);
+ c = c->next;
+ }
+ spin_unlock(&rtl_conpr_lock);
+ rtl_hard_restore_flags(flags);
+}
+
+
+int rtl_printf(const char * fmt, ...)
+{
+ static char buf[2048];
+ int flags;
+ int i;
+ va_list args;
+ static spinlock_t rtl_cprintf_lock = SPIN_LOCK_UNLOCKED;
+
+ rtl_hard_savef_and_cli(flags);
+ spin_lock(&rtl_cprintf_lock);
+
+ va_start(args, fmt);
+ i=vsprintf(buf,fmt,args);
+ va_end(args);
+ conpr(buf);
+
+ rtl_hard_cli();
+ spin_unlock(&rtl_cprintf_lock);
+ rtl_hard_restore_flags(flags);
+
+ return i;
+}
+
+
|