File: kernel_patch-2.2.19

package info (click to toggle)
rtlinux 3.1pre3-3
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 4,896 kB
  • ctags: 4,228
  • sloc: ansic: 26,204; sh: 2,069; makefile: 1,414; perl: 855; tcl: 489; asm: 380; cpp: 42
file content (1191 lines) | stat: -rw-r--r-- 34,682 bytes parent folder | download | duplicates (2)
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
diff -Nru a/Makefile b/Makefile
--- a/Makefile	Sat May 26 15:03:18 2001
+++ b/Makefile	Sat May 26 15:03:18 2001
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 2
 SUBLEVEL = 19
-EXTRAVERSION = 
+EXTRAVERSION = -rtl
 
 ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
 
@@ -436,7 +436,7 @@
 
 dep-files: scripts/mkdep archdep include/linux/version.h new-genksyms
 	scripts/mkdep init/*.c > .depend
-	scripts/mkdep `find $(FINDHPATH) -follow -name \*.h ! -name modversions.h -print` > .hdepend
+	scripts/mkdep `find $(FINDHPATH) -name SCCS -prune -or -follow -name \*.h ! -name modversions.h -print` > .hdepend
 #	set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i fastdep ;done
 # let this be made through the fastdep rule in Rules.make
 	$(MAKE) $(patsubst %,_sfdep_%,$(SUBDIRS)) _FASTDEP_ALL_SUB_DIRS="$(SUBDIRS)"
diff -Nru a/arch/i386/config.in b/arch/i386/config.in
--- a/arch/i386/config.in	Sat May 26 15:03:18 2001
+++ b/arch/i386/config.in	Sat May 26 15:03:18 2001
@@ -2,7 +2,12 @@
 # For a description of the syntax of this configuration file,
 # see Documentation/kbuild/config-language.txt.
 #
-mainmenu_name "Linux Kernel Configuration"
+mainmenu_name "RTLinux Kernel Configuration"
+define_bool CONFIG_RTLINUX  y
+
+if [ "$CONFIG_RTLINUX" = "y" ]; then
+  define_bool CONFIG_RTL y
+fi
 
 mainmenu_option next_comment
 comment 'Code maturity level options'
diff -Nru a/arch/i386/kernel/Makefile b/arch/i386/kernel/Makefile
--- a/arch/i386/kernel/Makefile	Sat May 26 15:03:18 2001
+++ b/arch/i386/kernel/Makefile	Sat May 26 15:03:18 2001
@@ -13,7 +13,7 @@
 all: kernel.o head.o init_task.o
 
 O_TARGET := kernel.o
-O_OBJS   := process.o signal.o entry.o traps.o irq.o vm86.o \
+O_OBJS   := process.o signal.o entry.o traps.o irq.o vm86.o rtlinux.o \
             ptrace.o ioport.o ldt.o setup.o time.o sys_i386.o \
 	    bluesmoke.o
 OX_OBJS  := i386_ksyms.o dmi_scan.o
diff -Nru a/arch/i386/kernel/entry.S b/arch/i386/kernel/entry.S
--- a/arch/i386/kernel/entry.S	Sat May 26 15:03:18 2001
+++ b/arch/i386/kernel/entry.S	Sat May 26 15:03:18 2001
@@ -166,7 +166,22 @@
  * but we want the default path for a system call return to
  * go as quickly as possible which is why some of this is
  * less clear than it otherwise should be.
+ *
+ * (c) Victor Yodaiken 1999
+ * RTLINUX_IRET emulates the turn on interrupts effect of
+ * iret since, under RTLinux we may have pended interrupts
+ * that will not be automatically enabled on an iret.
  */
+#ifdef CONFIG_RTLINUX
+#define RTLINUX_IRET 	\
+	movl  rtl_emulate_iret,%eax; \
+	testl %eax, %eax; \
+        je  1f;	\
+        call  *%eax;	\
+        1:
+#else
+#define RTLINUX_IRET 
+#endif
 
 ENTRY(system_call)
 	pushl %eax			# save orig_eax
@@ -191,11 +206,13 @@
 	cmpl $0,sigpending(%ebx)
 	jne signal_return
 restore_all:
+        RTLINUX_IRET
 	RESTORE_ALL
 
 	ALIGN
 signal_return:
 	sti				# we can get here from an interrupt handler
+	RTLINUX_IRET
 	testl $(VM_MASK),EFLAGS(%esp)
 	movl %esp,%eax
 	jne v86_signal_return
@@ -250,6 +267,12 @@
 	call SYMBOL_NAME(schedule)    # test
 	jmp ret_from_sys_call
 
+#define RTL_PUSH_VECTOR(vector,routine) \
+1:	cmpl $routine, %edi; \
+	jne 1f; \
+	pushl $vector; \
+	jmp 7f;
+
 ENTRY(divide_error)
 	pushl $0		# no error code
 	pushl $ SYMBOL_NAME(do_divide_error)
@@ -277,6 +300,35 @@
 	movl $(__KERNEL_DS),%edx
 	movl %dx,%ds
 	movl %dx,%es
+#ifdef CONFIG_RTLINUX
+	movl  rtl_exception_intercept,%eax
+	testl %eax, %eax
+        je  8f
+	RTL_PUSH_VECTOR(0,do_divide_error)
+	RTL_PUSH_VECTOR(1,do_debug)
+	RTL_PUSH_VECTOR(3,do_int3)
+	RTL_PUSH_VECTOR(4,do_overflow)
+	RTL_PUSH_VECTOR(5,do_bounds)
+	RTL_PUSH_VECTOR(6,do_invalid_op)
+	RTL_PUSH_VECTOR(8,do_double_fault)
+	RTL_PUSH_VECTOR(9,do_coprocessor_segment_overrun)
+	RTL_PUSH_VECTOR(10,do_invalid_TSS)
+	RTL_PUSH_VECTOR(11,do_segment_not_present)
+	RTL_PUSH_VECTOR(12,do_stack_segment)
+	RTL_PUSH_VECTOR(13,do_general_protection)
+	RTL_PUSH_VECTOR(14,do_page_fault)
+	RTL_PUSH_VECTOR(15,do_spurious_interrupt_bug)
+	RTL_PUSH_VECTOR(16,do_coprocessor_error)
+	RTL_PUSH_VECTOR(17,do_alignment_check)
+1:	push $-1
+7: 	call  *%eax
+	popl %ebx
+	testl %eax, %eax
+	je 8f
+	addl $8,%esp
+	RESTORE_ALL
+8:
+#endif
 	GET_CURRENT(%ebx)
 	call *%edi
 	addl $8,%esp
@@ -290,6 +342,21 @@
 ENTRY(device_not_available)
 	pushl $-1		# mark this as an int
 	SAVE_ALL
+#ifdef CONFIG_RTLINUX
+	movl  rtl_exception_intercept,%eax
+	testl %eax, %eax
+        je  8f
+	movl %esp,%edx
+	pushl $0		# no error code
+	pushl %edx
+	pushl $7		# vector
+	call  *%eax
+	addl $12,%esp
+	testl %eax, %eax
+	je 8f
+	RESTORE_ALL
+8:
+#endif
 	GET_CURRENT(%ebx)
 	pushl $ret_from_exception
 	movl %cr0,%eax
diff -Nru a/arch/i386/kernel/i386_ksyms.c b/arch/i386/kernel/i386_ksyms.c
--- a/arch/i386/kernel/i386_ksyms.c	Sat May 26 15:03:18 2001
+++ b/arch/i386/kernel/i386_ksyms.c	Sat May 26 15:03:18 2001
@@ -121,3 +121,35 @@
 EXPORT_SYMBOL(screen_info);
 #endif
 
+#ifdef CONFIG_RTLINUX
+#include <linux/vt_kern.h>
+EXPORT_SYMBOL(kd_mksound);
+extern void *__start_rtlinux_funcs,*__stop_rtlinux_funcs;
+EXPORT_SYMBOL(__start_rtlinux_funcs);
+EXPORT_SYMBOL(__stop_rtlinux_funcs);
+EXPORT_SYMBOL(irq_control);
+extern unsigned long (*do_gettimeoffset)(void);
+extern unsigned int use_tsc;
+EXPORT_SYMBOL(do_gettimeoffset);
+EXPORT_SYMBOL(use_tsc);
+EXPORT_SYMBOL(tick);
+extern volatile unsigned long lost_ticks;
+extern rwlock_t xtime_lock;
+EXPORT_SYMBOL(lost_ticks);
+EXPORT_SYMBOL(xtime_lock);
+extern unsigned char *rtl_cached21;
+EXPORT_SYMBOL(rtl_cached21);
+#ifdef CONFIG_SMP
+extern unsigned long irq_affinity [NR_IRQS];
+EXPORT_SYMBOL(irq_affinity);
+#include <asm/smp.h>
+EXPORT_SYMBOL(smp_found_config);
+#endif
+#endif
+
+#ifdef CONFIG_RTLINUX
+extern struct console *console_drivers;
+EXPORT_SYMBOL(console_drivers);
+extern spinlock_t console_lock;
+EXPORT_SYMBOL(console_lock);
+#endif
diff -Nru a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
--- a/arch/i386/kernel/io_apic.c	Sat May 26 15:03:18 2001
+++ b/arch/i386/kernel/io_apic.c	Sat May 26 15:03:18 2001
@@ -196,12 +196,14 @@
 	FINAL;								\
 }
 
+extern unsigned long irq_affinity [NR_IRQS];
+
 /*
  * We disable IO-APIC IRQs by setting their 'destination CPU mask' to
  * zero. Trick by Ramesh Nalluri.
  */
 DO_ACTION( disable, 1, &= 0x00ffffff, io_apic_sync(entry->apic))/* destination = 0x00 */
-DO_ACTION( enable,  1, |= 0xff000000, )				/* destination = 0xff */
+DO_ACTION( enable,  1, |= (irq_affinity[irq] << 24), )				/* destination = 0xff */
 DO_ACTION( mask,    0, |= 0x00010000, io_apic_sync(entry->apic))/* mask = 1 */
 DO_ACTION( unmask,  0, &= 0xfffeffff, )				/* mask = 0 */
 
@@ -1035,7 +1037,7 @@
  * an edge even if it isn't on the 8259A...
  */
 
-static void startup_edge_ioapic_irq(unsigned int irq)
+static unsigned int startup_edge_ioapic_irq(unsigned int irq)
 {
 	if (irq < 16) {
 		disable_8259A_irq(irq);
@@ -1043,6 +1045,7 @@
 			irq_desc[irq].status |= IRQ_PENDING;
 	}
 	enable_edge_ioapic_irq(irq);
+	return 0;
 }
 
 #define shutdown_edge_ioapic_irq	disable_edge_ioapic_irq
@@ -1052,11 +1055,60 @@
  * and shutting down and starting up the interrupt
  * is the same as enabling and disabling them.
  */
-#define startup_level_ioapic_irq	unmask_IO_APIC_irq
+#define startup_level_ioapic_irq	(unsigned int (*)(unsigned int)) unmask_IO_APIC_irq
 #define shutdown_level_ioapic_irq	mask_IO_APIC_irq
 #define enable_level_ioapic_irq		unmask_IO_APIC_irq
 #define disable_level_ioapic_irq	mask_IO_APIC_irq
 
+static void end_edge_ioapic_irq (unsigned int i)
+{
+	unmask_IO_APIC_irq(i);
+}
+
+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();
+}
+
+#define __DO_ACTION(R, ACTION, FINAL)					\
+									\
+{									\
+	int pin;							\
+	struct irq_pin_list *entry = irq_2_pin + irq;			\
+									\
+	for (;;) {							\
+		unsigned int reg;					\
+		pin = entry->pin;					\
+		if (pin == -1)						\
+			break;						\
+		reg = io_apic_read(entry->apic, 0x10 + R + pin*2);	\
+		reg ACTION;						\
+		io_apic_modify(entry->apic, reg);			\
+		if (!entry->next)					\
+			break;						\
+		entry = irq_2_pin + entry->next;			\
+	}								\
+	FINAL;								\
+}
+
+static void set_ioapic_affinity (unsigned int irq, unsigned long mask)
+{
+	unsigned long flags;
+	/*
+	 * Only the first 8 bits are valid.
+	 */
+	irq_affinity[irq] = mask;
+	mask = mask << 24;
+
+/* 	spin_lock_irqsave(&ioapic_lock, flags); */
+	__DO_ACTION(1, = mask, )
+/* 	spin_unlock_irqrestore(&ioapic_lock, flags); */
+}
+
 static void do_edge_ioapic_IRQ(unsigned int irq, struct pt_regs * regs)
 {
 	irq_desc_t *desc = irq_desc + irq;
@@ -1069,7 +1121,7 @@
 	 * Edge triggered IRQs can be acknowledged immediately
 	 * and do not need to be masked.
 	 */
-	ack_APIC_irq();
+	desc->handler->ack(irq);
 	status = desc->status & ~(IRQ_REPLAY | IRQ_WAITING);
 	status |= IRQ_PENDING;
 
@@ -1106,6 +1158,8 @@
 		spin_unlock(&irq_controller_lock);
 	}
 	desc->status &= ~IRQ_INPROGRESS;
+	if (!(desc->status & IRQ_DISABLED))
+		desc->handler->end(irq);
 	spin_unlock(&irq_controller_lock);
 }
 
@@ -1124,7 +1178,7 @@
 	 * disable has to happen before the ACK, to avoid IRQ storms.
 	 * So this all has to be within the spinlock.
 	 */
-	mask_IO_APIC_irq(irq);
+	desc->handler->ack(irq);
 	status = desc->status & ~(IRQ_REPLAY | IRQ_WAITING);
 
 	/*
@@ -1138,7 +1192,7 @@
 	}
 	desc->status = status;
 
-	ack_APIC_irq();
+/* 	ack_APIC_irq(); */
 	spin_unlock(&irq_controller_lock);
 
 	/* Exit early if we had no action or it was disabled */
@@ -1150,7 +1204,7 @@
 	spin_lock(&irq_controller_lock);
 	desc->status &= ~IRQ_INPROGRESS;
 	if (!(desc->status & IRQ_DISABLED))
-		unmask_IO_APIC_irq(irq);
+		desc->handler->end(irq);
 	spin_unlock(&irq_controller_lock);
 }
 
@@ -1167,18 +1221,24 @@
 	"IO-APIC-edge",
 	startup_edge_ioapic_irq,
 	shutdown_edge_ioapic_irq,
-	do_edge_ioapic_IRQ,
 	enable_edge_ioapic_irq,
-	disable_edge_ioapic_irq
+	disable_edge_ioapic_irq,
+	mask_and_ack_edge_ioapic,
+	end_edge_ioapic_irq,
+	set_ioapic_affinity,
+	do_edge_ioapic_IRQ,
 };
 
 static struct hw_interrupt_type ioapic_level_irq_type = {
 	"IO-APIC-level",
 	startup_level_ioapic_irq,
 	shutdown_level_ioapic_irq,
-	do_level_ioapic_IRQ,
 	enable_level_ioapic_irq,
-	disable_level_ioapic_irq
+	disable_level_ioapic_irq,
+	mask_and_ack_level_ioapic,
+	end_edge_ioapic_irq,
+	set_ioapic_affinity,
+	do_level_ioapic_IRQ
 };
 
 static inline void init_IO_APIC_traps(void)
diff -Nru a/arch/i386/kernel/irq.c b/arch/i386/kernel/irq.c
--- a/arch/i386/kernel/irq.c	Sat May 26 15:03:18 2001
+++ b/arch/i386/kernel/irq.c	Sat May 26 15:03:18 2001
@@ -32,6 +32,7 @@
 #include <linux/init.h>
 
 #include <asm/system.h>
+#include <asm/hw_irq.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/bitops.h>
@@ -73,45 +74,60 @@
 /*
  * Dummy controller type for unused interrupts
  */
+
+/* For RTLinux, moved illegal vector warnings into handler->ack -- MB */
 static void do_none(unsigned int irq, struct pt_regs * regs)
 {
-	/*
-	 * we are careful. While for ISA irqs it's common to happen
-	 * outside of any driver (think autodetection), this is not
-	 * at all nice for PCI interrupts. So we are stricter and
-	 * print a warning when such spurious interrupts happen.
-	 * Spurious interrupts can confuse other drivers if the PCI
-	 * IRQ line is shared.
-	 *
-	 * Such spurious interrupts are either driver bugs, or
-	 * sometimes hw (chipset) bugs.
-	 */
-	printk("unexpected IRQ vector %d on CPU#%d!\n",irq, smp_processor_id());
+	struct irqaction * action;
+	irq_desc_t *desc = irq_desc + irq;
+	desc->handler->ack(irq);
+	action = desc->action;
+	if (!action)
+		return;
+	handle_IRQ_event(irq, regs, action);
+}
 
-#ifdef __SMP__
+static void enable_none(unsigned int irq) { }
+static void disable_none(unsigned int irq) { }
+static void ack_none(unsigned int irq)
+{
+/*
+ * 'what should we do if we get a hw irq event on an illegal vector'.
+ * each architecture has to answer this themselves, it doesnt deserve
+ * a generic callback i think.
+ */
+#if CONFIG_X86
+	printk("unexpected IRQ trap at vector %02x\n", irq);
+#ifdef CONFIG_SMP
 	/*
-	 * [currently unexpected vectors happen only on SMP and APIC.
-	 *  if we want to have non-APIC and non-8259A controllers
-	 *  in the future with unexpected vectors, this ack should
-	 *  probably be made controller-specific.]
+	 * Currently unexpected vectors happen only on SMP and APIC.
+	 * We _must_ ack these because every local APIC has only N
+	 * irq slots per priority level, and a 'hanging, unacked' IRQ
+	 * holds up an irq slot - in excessive cases (when multiple
+	 * unexpected vectors occur) that might lock up the APIC
+	 * completely.
 	 */
 	ack_APIC_irq();
 #endif
+#endif
 }
-static void enable_none(unsigned int irq) { }
-static void disable_none(unsigned int irq) { }
+
 
 /* startup is the same as "enable", shutdown is same as "disable" */
-#define startup_none	enable_none
+#define startup_none (unsigned int (*)(unsigned int)) enable_none
 #define shutdown_none	disable_none
+#define end_none	enable_none
 
 struct hw_interrupt_type no_irq_type = {
 	"none",
 	startup_none,
 	shutdown_none,
-	do_none,
 	enable_none,
-	disable_none
+	disable_none,
+	ack_none,
+	end_none,
+	0,
+	do_none,
 };
 
 /*
@@ -120,20 +136,30 @@
  */
 
 static void do_8259A_IRQ(unsigned int irq, struct pt_regs * regs);
+static void mask_and_ack_8259A(unsigned int irq);
 static void enable_8259A_irq(unsigned int irq);
 void disable_8259A_irq(unsigned int irq);
 
 /* startup is the same as "enable", shutdown is same as "disable" */
-#define startup_8259A_irq	enable_8259A_irq
+#define startup_8259A_irq	(unsigned int (*)(unsigned int)) enable_8259A_irq
 #define shutdown_8259A_irq	disable_8259A_irq
 
+static void end_8259A_irq (unsigned int irq)
+{
+	if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
+		enable_8259A_irq(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,
+	end_8259A_irq,
+	0,
+	do_8259A_IRQ
 };
 
 /*
@@ -154,6 +180,7 @@
 #define __byte(x,y) 	(((unsigned char *)&(y))[x])
 #define cached_21	(__byte(0,cached_irq_mask))
 #define cached_A1	(__byte(1,cached_irq_mask))
+unsigned char *rtl_cached21 = &cached_21;
 
 /*
  * Not all IRQs can be routed through the IO-APIC, eg. on certain (older)
@@ -215,7 +242,7 @@
  * 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)
+static void mask_and_ack_8259A(unsigned int irq)
 {
 	cached_irq_mask |= 1 << irq;
 	if (irq & 8) {
@@ -238,7 +265,7 @@
 	spin_lock(&irq_controller_lock);
 	{
 		unsigned int status;
-		mask_and_ack_8259A(irq);
+		desc->handler->ack(irq);
 		status = desc->status & ~(IRQ_REPLAY | IRQ_WAITING);
 		action = NULL;
 		if (!(status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
@@ -260,7 +287,7 @@
 		unsigned int status = desc->status & ~IRQ_INPROGRESS;
 		desc->status = status;
 		if (!(status & IRQ_DISABLED))
-			enable_8259A_irq(irq);
+			desc->handler->enable(irq);
 	}
 	spin_unlock(&irq_controller_lock);
 }
@@ -319,11 +346,11 @@
  * 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_SMP_INTERRUPT(reschedule_interrupt, RESCHEDULE_VECTOR)
+BUILD_SMP_INTERRUPT(invalidate_interrupt, INVALIDATE_TLB_VECTOR)
+BUILD_SMP_INTERRUPT(stop_cpu_interrupt, STOP_CPU_VECTOR)
+BUILD_SMP_INTERRUPT(call_function_interrupt, CALL_FUNCTION_VECTOR)
+BUILD_SMP_INTERRUPT(spurious_interrupt, SPURIOUS_APIC_VECTOR)
 
 /*
  * every pentium local APIC has two 'local interrupts', with a
@@ -332,7 +359,7 @@
  * 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(apic_timer_interrupt, LOCAL_TIMER_VECTOR)
 
 #endif
 
@@ -643,7 +670,7 @@
  */
 void __global_cli(void)
 {
-	unsigned int flags;
+	unsigned long flags;
 
 	__save_flags(flags);
 	if (flags & (1 << EFLAGS_IF_SHIFT)) {
@@ -960,6 +987,8 @@
 out:
 	spin_unlock_irqrestore(&irq_controller_lock,flags);
 }
+
+unsigned long irq_affinity [NR_IRQS] = { [0 ... NR_IRQS-1] = ~0UL };
 
 /*
  * IRQ autodetection code..
diff -Nru a/arch/i386/kernel/irq.h b/arch/i386/kernel/irq.h
--- a/arch/i386/kernel/irq.h	Sat May 26 15:03:18 2001
+++ b/arch/i386/kernel/irq.h	Sat May 26 15:03:18 2001
@@ -2,11 +2,12 @@
 #define __irq_h
 
 #include <asm/irq.h>
+#include <asm/rtlinux.h>
+#include <asm/hw_irq.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
 
 /*
- * Interrupt controller descriptor. This is all we need
- * to describe about the low-level hardware.
- */
 struct hw_interrupt_type {
 	const char * typename;
 	void (*startup)(unsigned int irq);
@@ -15,70 +16,10 @@
 	void (*enable)(unsigned int irq);
 	void (*disable)(unsigned int irq);
 };
+*/
 
 extern struct hw_interrupt_type no_irq_type;
 
-/*
- * IRQ line status.
- */
-#define IRQ_INPROGRESS	1	/* IRQ handler active - do not enter! */
-#define IRQ_DISABLED	2	/* IRQ disabled - do not enter! */
-#define IRQ_PENDING	4	/* IRQ pending - replay on enable */
-#define IRQ_REPLAY	8	/* IRQ has been replayed but not acked yet */
-#define IRQ_AUTODETECT	16	/* IRQ is being autodetected */
-#define IRQ_WAITING	32	/* IRQ not yet seen - for autodetection */
-
-/*
- * This is the "IRQ descriptor", which contains various information
- * about the irq, including what kind of hardware handling it has,
- * whether it is disabled etc etc.
- *
- * Pad this out to 32 bytes for cache and indexing reasons.
- */
-typedef struct {
-	unsigned int status;			/* IRQ status - IRQ_INPROGRESS, IRQ_DISABLED */
-	struct hw_interrupt_type *handler;	/* handle/enable/disable functions */
-	struct irqaction *action;		/* IRQ action list */
-	unsigned int depth;			/* Disable depth for nested irq disables */
-	unsigned int unused[4];
-} irq_desc_t;
-
-/*
- * IDT vectors usable for external interrupt sources start
- * at 0x20:
- */
-#define FIRST_EXTERNAL_VECTOR	0x20
-
-#define SYSCALL_VECTOR		0x80
-
-/*
- * Vectors 0x20-0x2f are used for ISA interrupts.
- */
-
-/*
- * Special IRQ vectors used by the SMP architecture:
- *
- * (some of the following vectors are 'rare', they might be merged
- *  into a single vector to save vector space. TLB, reschedule and
- *  local APIC vectors are performance-critical.)
- */
-#define RESCHEDULE_VECTOR	0x30
-#define INVALIDATE_TLB_VECTOR	0x31
-#define STOP_CPU_VECTOR		0x40
-#define LOCAL_TIMER_VECTOR	0x41
-#define CALL_FUNCTION_VECTOR	0x50
-
-/*
- * 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
-
-extern irq_desc_t irq_desc[NR_IRQS];
 extern int irq_vector[NR_IRQS];
 #define IO_APIC_VECTOR(irq)	irq_vector[irq]
 
@@ -190,25 +131,30 @@
  *	SMP has a few special interrupts for IPI messages
  */
 
-#define BUILD_SMP_INTERRUPT(x) \
+#define BUILD_SMP_INTERRUPT(x,v) XBUILD_SMP_INTERRUPT(x,v)
+#define XBUILD_SMP_INTERRUPT(x,v)\
 asmlinkage void x(void); \
 __asm__( \
 "\n"__ALIGN_STR"\n" \
 SYMBOL_NAME_STR(x) ":\n\t" \
-	"pushl $-1\n\t" \
+	"pushl $"#v"\n\t" \
 	SAVE_ALL \
-	"call "SYMBOL_NAME_STR(smp_##x)"\n\t" \
+	"pushl $ret_from_intr\n\t" \
+	RTLINUX_LABEL(smp_##x)\
+	"jmp "SYMBOL_NAME_STR(smp_##x)"\n\t" \
 	"jmp ret_from_intr\n");
 
-#define BUILD_SMP_TIMER_INTERRUPT(x) \
+#define BUILD_SMP_TIMER_INTERRUPT(x,v) XBUILD_SMP_TIMER_INTERRUPT(x,v)
+#define XBUILD_SMP_TIMER_INTERRUPT(x,v) \
 asmlinkage void x(struct pt_regs * regs); \
 __asm__( \
 "\n"__ALIGN_STR"\n" \
 SYMBOL_NAME_STR(x) ":\n\t" \
-	"pushl $-1\n\t" \
+	"pushl $"#v"\n\t" \
 	SAVE_ALL \
 	"movl %esp,%eax\n\t" \
 	"pushl %eax\n\t" \
+	RTLINUX_LABEL(smp_##x)\
 	"call "SYMBOL_NAME_STR(smp_##x)"\n\t" \
 	"addl $4,%esp\n\t" \
 	"jmp ret_from_intr\n");
@@ -220,8 +166,9 @@
 	"\n" __ALIGN_STR"\n" \
 	"common_interrupt:\n\t" \
 	SAVE_ALL \
-	"call "SYMBOL_NAME_STR(do_IRQ)"\n\t" \
-	"jmp ret_from_intr\n");
+ 	"pushl $ret_from_intr\n\t" \
+	RTLINUX_LABEL(do_IRQ)"\n\t" \
+ 	"jmp "SYMBOL_NAME_STR(do_IRQ));
 
 /*
  * subtle. orig_eax is used by the signal code to distinct between
diff -Nru a/arch/i386/kernel/rtlinux.c b/arch/i386/kernel/rtlinux.c
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/arch/i386/kernel/rtlinux.c	Sat May 26 15:03:18 2001
@@ -0,0 +1,77 @@
+#include <linux/config.h>
+#include <linux/ptrace.h>
+#include <linux/errno.h>
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/ioport.h>
+#include <linux/interrupt.h>
+#include <linux/timex.h>
+#include <linux/malloc.h>
+#include <linux/random.h>
+#include <linux/smp_lock.h>
+#include <linux/init.h>
+#include <linux/kernel_stat.h>
+
+#include <asm/system.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/bitops.h>
+#include <asm/pgtable.h>
+#include <asm/delay.h>
+#include <asm/desc.h>
+
+static void rtl_hard_save_flags_f(unsigned long  *z){
+	unsigned long y;
+	rtl_hard_save_flags_kernel(y);
+	*z=y;
+}
+static void rtl_hard_restore_flags_f(unsigned long  x) { rtl_hard_restore_flags_kernel(x); }
+static void rtl_hard_cli_f(void) { rtl_hard_cli_kernel(); }
+static void rtl_hard_sti_f(void) { rtl_hard_sti_kernel(); }
+static void rtl_hard_local_irq_save_f(unsigned long  *x)
+{ unsigned long y;rtl_hard_local_irq_save_kernel(y);*x=y; }
+static void rtl_hard_local_irq_restore_f(unsigned long  x){
+	rtl_hard_local_irq_restore_kernel(x);
+}
+struct irq_control_s irq_control = {
+ 	rtl_hard_save_flags_f,
+ 	rtl_hard_restore_flags_f,
+ 	rtl_hard_cli_f,
+ 	rtl_hard_sti_f,
+ 	rtl_hard_local_irq_save_f,
+ 	rtl_hard_local_irq_restore_f
+ };
+void *rtl_emulate_iret = 0;
+void *rtl_exception_intercept = 0;
+
+extern void *__start_rtlinux_patch,*__stop_rtlinux_patch;
+extern asmlinkage void do_IRQ(struct pt_regs );
+extern void ret_from_intr(void);
+RTLINUX_EXPORT(__start_rtlinux_patch);
+RTLINUX_EXPORT(__stop_rtlinux_patch);
+RTLINUX_EXPORT(rtl_emulate_iret);
+RTLINUX_EXPORT(irq_desc);
+RTLINUX_EXPORT(do_IRQ);
+RTLINUX_EXPORT(ret_from_intr);
+RTLINUX_EXPORT(rtl_exception_intercept);
+
+#ifdef CONFIG_X86_LOCAL_APIC
+extern asmlinkage void smp_spurious_interrupt(void);
+extern asmlinkage void smp_error_interrupt(void);
+extern void smp_apic_timer_interrupt(struct pt_regs *);
+
+RTLINUX_EXPORT(smp_spurious_interrupt);
+RTLINUX_EXPORT(smp_stop_cpu_interrupt);
+RTLINUX_EXPORT(smp_apic_timer_interrupt);
+#endif
+
+#ifdef CONFIG_SMP
+extern void rtl_reschedule(int cpu);
+extern asmlinkage void smp_reschedule_interrupt(void);
+extern asmlinkage void smp_invalidate_interrupt(void);
+extern asmlinkage void smp_call_function_interrupt(void);
+RTLINUX_EXPORT(smp_reschedule_interrupt);
+RTLINUX_EXPORT(smp_invalidate_interrupt);
+RTLINUX_EXPORT(smp_call_function_interrupt);
+RTLINUX_EXPORT(rtl_reschedule);
+#endif
diff -Nru a/arch/i386/kernel/smp.c b/arch/i386/kernel/smp.c
--- a/arch/i386/kernel/smp.c	Sat May 26 15:03:18 2001
+++ b/arch/i386/kernel/smp.c	Sat May 26 15:03:18 2001
@@ -171,17 +171,6 @@
 		max_cpus = 0;
 }
 
-void ack_APIC_irq(void)
-{
-	/* Clear the IPI */
-
-	/* Dummy read */
-	apic_read(APIC_SPIV);
-
-	/* Docs say use 0 for future compatibility */
-	apic_write(APIC_EOI, 0);
-}
-
 /*
  * Intel MP BIOS table parsing routines:
  */
@@ -756,6 +745,7 @@
 	 */
  	value = apic_read(APIC_LDR);
 	value &= ~APIC_LDR_MASK;
+	value |= (1<<(smp_processor_id()+24));
  	apic_write(APIC_LDR,value);
 
  	value = apic_read(APIC_DFR);
@@ -1755,8 +1745,7 @@
 #if FORCE_APIC_SERIALIZATION
 	unsigned long flags;
 
-	__save_flags(flags);
-	__cli();
+	rtl_hard_local_irq_save_kernel(flags);
 #endif
 
 	/*
@@ -1770,7 +1759,7 @@
 	 */
 	apic_write(APIC_ICR, cfg);
 #if FORCE_APIC_SERIALIZATION
-	__restore_flags(flags);
+	rtl_hard_local_irq_restore_kernel(flags);
 #endif
 }
 
@@ -1904,6 +1893,12 @@
 	send_IPI_single(cpu, RESCHEDULE_VECTOR);
 }
 
+#define RTL_RESCHEDULE_VECTOR 0xEE
+void rtl_reschedule(int cpu)
+{
+	send_IPI_single(cpu, RTL_RESCHEDULE_VECTOR);
+}
+
 /*
  * this function sends a 'stop' IPI to all other CPUs in the system.
  * it goes straight through.
@@ -2128,6 +2123,7 @@
 asmlinkage void smp_stop_cpu_interrupt(void)
 {
 	stop_this_cpu();
+	ack_APIC_irq();
 }
 
 asmlinkage void smp_call_function_interrupt(void)
diff -Nru a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c
--- a/arch/i386/kernel/time.c	Sat May 26 15:03:18 2001
+++ b/arch/i386/kernel/time.c	Sat May 26 15:03:18 2001
@@ -113,7 +113,7 @@
 
 #define TICK_SIZE tick
 
-#ifndef CONFIG_X86_TSC
+/* #ifndef CONFIG_X86_TSC */
 
 spinlock_t i8253_lock = SPIN_LOCK_UNLOCKED;
 
@@ -239,13 +239,13 @@
 	return count;
 }
 
-static unsigned long (*do_gettimeoffset)(void) = do_slow_gettimeoffset;
+unsigned long (*do_gettimeoffset)(void) = do_slow_gettimeoffset;
 
-#else
+/* #else */
 
-#define do_gettimeoffset()	do_fast_gettimeoffset()
+/* #define do_gettimeoffset()	do_fast_gettimeoffset() */
 
-#endif
+/* #endif */
 
 /*
  * This version of gettimeofday has microsecond resolution
@@ -428,7 +428,7 @@
 #endif
 }
 
-static int use_tsc = 0;
+int use_tsc = 0;
 
 /*
  * This is the same as the above, except we _also_ save the current
diff -Nru a/include/asm-i386/apic.h b/include/asm-i386/apic.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/include/asm-i386/apic.h	Sat May 26 15:03:18 2001
@@ -0,0 +1,10 @@
+#ifndef __ASM_APIC_H
+#define __ASM_APIC_H
+
+#include <linux/config.h>
+#ifdef CONFIG_X86_LOCAL_API
+#include <asm/fixmap.h>
+#include <asm/i82489.h>
+#include <asm/hw_irq.h>
+#endif
+#endif
diff -Nru a/include/asm-i386/hw_irq.h b/include/asm-i386/hw_irq.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/include/asm-i386/hw_irq.h	Sat May 26 15:03:18 2001
@@ -0,0 +1,48 @@
+#ifndef _ASM_HW_IRQ_H
+#define _ASM_HW_IRQ_H
+
+
+#include <linux/config.h>
+
+/*
+ * IRQ line status.
+ */
+#define IRQ_INPROGRESS	1	/* IRQ handler active - do not enter! */
+#define IRQ_DISABLED	2	/* IRQ disabled - do not enter! */
+#define IRQ_PENDING	4	/* IRQ pending - replay on enable */
+#define IRQ_REPLAY	8	/* IRQ has been replayed but not acked yet */
+#define IRQ_AUTODETECT	16	/* IRQ is being autodetected */
+#define IRQ_WAITING	32	/* IRQ not yet seen - for autodetection */
+
+/*
+ * IDT vectors usable for external interrupt sources start
+ * at 0x20:
+ */
+#define FIRST_EXTERNAL_VECTOR	0x20
+
+#define SYSCALL_VECTOR		0x80
+
+/*
+ * Vectors 0x20-0x2f are used for ISA interrupts.
+ */
+
+#define SPURIOUS_APIC_VECTOR	0xff
+#define STOP_CPU_VECTOR		0xfe
+/* ERROR_APIC_VECTOR never used in 2.2 */
+#define ERROR_APIC_VECTOR	0xfe
+#define INVALIDATE_TLB_VECTOR	0xfd
+#define RESCHEDULE_VECTOR	0xfc
+#define CALL_FUNCTION_VECTOR	0xfb
+#define LOCAL_TIMER_VECTOR	0xef
+
+/*
+ * First APIC vector available to drivers: (vectors 0x51-0xfe)
+ */
+#define IRQ0_TRAP_VECTOR	0x31
+
+/*
+ * This IRQ should never happen, but we print a message nevertheless.
+ */
+#define SPURIOUS_APIC_VECTOR	0xff
+
+#endif /* _ASM_HW_IRQ_H */
diff -Nru a/include/asm-i386/i82489.h b/include/asm-i386/i82489.h
--- a/include/asm-i386/i82489.h	Sat May 26 15:03:18 2001
+++ b/include/asm-i386/i82489.h	Sat May 26 15:03:18 2001
@@ -100,4 +100,26 @@
 	return *((volatile unsigned long *)(APIC_BASE+reg));
 }
 
+
+struct __xchg_dummy23 { unsigned long a[100]; };
+#define __xg23(x) ((struct __xchg_dummy23 *)(x))
+
+extern __inline void apic_write0(unsigned long reg)
+{
+	__asm__ __volatile__("xor %%eax, %%eax\n\t"
+			     "xchgl %%eax, %0\n\t"
+				:
+				:"m" (*__xg23(APIC_BASE + reg))
+				:"memory", "ax");
+}
+
+#include <asm/system.h>
+extern inline void ack_APIC_irq(void)
+{
+	/* Clear the IPI */
+
+ 	label_ack_APIC(); /* used to generate RTLinux patch point */
+	apic_write0(APIC_EOI);
+}
+
 #endif
diff -Nru a/include/asm-i386/mmu_context.h b/include/asm-i386/mmu_context.h
--- a/include/asm-i386/mmu_context.h	Sat May 26 15:03:18 2001
+++ b/include/asm-i386/mmu_context.h	Sat May 26 15:03:18 2001
@@ -10,4 +10,20 @@
 #define destroy_context(mm)	do { } while(0)
 #define activate_context(tsk)	do { } while(0)
 
+/* backport of 2.4 stuff for PSC */
+#define active_mm mm
+static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk, unsigned cpu)
+{
+	if (prev != next) {
+		/*
+		 * Re-load LDT if necessary
+		 */
+		if (prev->segments != next->segments)
+			asm volatile("lldt %0": :"g" (*(unsigned short *)&tsk->tss.ldt));
+
+		/* Re-load page tables */
+		asm volatile("movl %0,%%cr3": :"r" (__pa(next->pgd)));
+	}
+}
+
 #endif
diff -Nru a/include/asm-i386/rtlinux.h b/include/asm-i386/rtlinux.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/include/asm-i386/rtlinux.h	Sat May 26 15:03:18 2001
@@ -0,0 +1,14 @@
+
+/* RTLinux support for patching the running kernel.
+	* (c) Victor Yodaiken 1999
+*/
+
+#define label_ack_APIC() xlabel_code(0x12344321)
+#define xlabel_code(x) asm __volatile__(".section rtlinux_patch,\"a\"\n .align 4\n"\
+                             ".long 1f,"#x"\n" ".previous\n 1:\n" );
+#define RTLINUX_LABEL(x)\
+  ".section rtlinux_patch,\"a\"\n .align 4\n .long 1f,"#x"\n .previous\n 1:\n"
+
+#define RTLINUX_EXPORT(x)\
+  asm (".section rtlinux_funcs,\"a\"\n .align 4\n"\
+                             ".long "#x"\n .previous\n" );
diff -Nru a/include/asm-i386/rtlinux_cli.h b/include/asm-i386/rtlinux_cli.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/include/asm-i386/rtlinux_cli.h	Sat May 26 15:03:18 2001
@@ -0,0 +1,35 @@
+#ifndef RTLINUX_CLI_H
+#define RTLINUX_CLI_H
+
+/* interrupt control.. */
+#define rtl_hard_save_flags_kernel(x)		__asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */ :"memory")
+#define rtl_hard_restore_flags_kernel(x) 	__asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory")
+#define rtl_hard_cli_kernel() 		__asm__ __volatile__("cli": : :"memory")
+#define rtl_hard_sti_kernel()			__asm__ __volatile__("sti": : :"memory")
+
+/* For spinlocks etc */
+#define rtl_hard_local_irq_save_kernel(x)	__asm__ __volatile__("pushfl ; popl %0 ; cli":"=g" (x): /* no input */ :"memory")
+#define rtl_hard_local_irq_restore_kernel(x)	__asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory")
+#define rtl_hard_local_irq_disable_kernel()	__asm__ __volatile__("cli": : :"memory")
+#define rtl_hard_local_irq_enable_kernel()	__asm__ __volatile__("sti": : :"memory")
+struct irq_control_s {
+	void (*do_save_flags)(unsigned long *);
+	void (*do_restore_flags)(unsigned long);
+	void (*do_cli)(void);
+	void (*do_sti)(void);
+	void (*do_local_irq_save)(unsigned long *);
+	void (*do_local_irq_restore)(unsigned long);
+};
+extern struct irq_control_s irq_control;
+#undef __cli()
+#undef __sti()
+#undef __save_flags(x)
+#undef __restore_flags(x)
+#define __save_flags(x)	irq_control.do_save_flags(&x)
+#define __restore_flags(x) irq_control.do_restore_flags(x)	
+#define __cli()		irq_control.do_cli()	
+#define __sti()		irq_control.do_sti()
+
+#undef safe_halt()
+#define safe_halt()	do { __asm__ __volatile__("cli; nop; sti; hlt": : :"memory"); irq_control.do_sti();  } while (0)
+#endif /* RTLINUX_CLI_H */
diff -Nru a/include/asm-i386/smp.h b/include/asm-i386/smp.h
--- a/include/asm-i386/smp.h	Sat May 26 15:03:18 2001
+++ b/include/asm-i386/smp.h	Sat May 26 15:03:18 2001
@@ -209,6 +209,8 @@
 	return GET_APIC_ID(*(unsigned long *)(APIC_BASE+APIC_ID));
 }
 
+#define hw_smp_processor_id() (hard_smp_processor_id())
+
 #endif /* !ASSEMBLY */
 
 #define NO_PROC_ID		0xFF		/* No processor magic marker */
diff -Nru a/include/asm-i386/spinlock.h b/include/asm-i386/spinlock.h
--- a/include/asm-i386/spinlock.h	Sat May 26 15:03:18 2001
+++ b/include/asm-i386/spinlock.h	Sat May 26 15:03:18 2001
@@ -1,6 +1,11 @@
 #ifndef __ASM_SPINLOCK_H
 #define __ASM_SPINLOCK_H
 
+#define BUG() do { \
+	printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
+	__asm__ __volatile__(".byte 0x0f,0x0b"); \
+} while (0)
+
 #ifndef __SMP__
 
 #define DEBUG_SPINLOCKS	0	/* 0 == no debugging, 1 == maintain lock state, 2 == full debug */
diff -Nru a/include/asm-i386/system.h b/include/asm-i386/system.h
--- a/include/asm-i386/system.h	Sat May 26 15:03:18 2001
+++ b/include/asm-i386/system.h	Sat May 26 15:03:18 2001
@@ -3,6 +3,7 @@
 
 #include <linux/kernel.h>
 #include <asm/segment.h>
+#include <asm/rtlinux.h>
 
 #ifdef __KERNEL__
 
@@ -180,6 +181,7 @@
 __asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */ :"memory")
 #define __restore_flags(x) \
 __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory")
+#include <asm/rtlinux_cli.h>
 
 
 #ifdef __SMP__
diff -Nru a/include/linux/irq.h b/include/linux/irq.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/include/linux/irq.h	Sat May 26 15:03:18 2001
@@ -0,0 +1,46 @@
+#ifndef _LINUX_IRQ_H__
+#define _LINUX_IRQ_H__
+
+#include <linux/spinlock.h>
+
+#include <asm/irq.h>
+#include <asm/ptrace.h>
+
+/*
+ * Interrupt controller descriptor. This is all we need
+ * to describe about the low-level hardware. 
+ */
+struct hw_interrupt_type {
+	const char * typename;
+	unsigned int (*startup)(unsigned int irq);
+	void (*shutdown)(unsigned int irq);
+	void (*enable)(unsigned int irq);
+	void (*disable)(unsigned int irq);
+	void (*ack)(unsigned int irq);
+	void (*end)(unsigned int irq);
+	void (*set_affinity)(unsigned int irq, unsigned long mask);
+	void (*handle)(unsigned int irq, struct pt_regs * regs);
+};
+
+typedef struct hw_interrupt_type  hw_irq_controller;
+
+/*
+ * This is the "IRQ descriptor", which contains various information
+ * about the irq, including what kind of hardware handling it has,
+ * whether it is disabled etc etc.
+ *
+ * Pad this out to 32 bytes for cache and indexing reasons.
+ */
+typedef struct {
+	unsigned int status;		/* IRQ status */
+	hw_irq_controller *handler;
+	struct irqaction *action;	/* IRQ action list */
+	unsigned int depth;		/* nested irq disables */
+	spinlock_t lock;
+} irq_desc_t;
+
+extern irq_desc_t irq_desc [NR_IRQS];
+
+
+#endif /* __asm_h */
+
diff -Nru a/include/linux/major.h b/include/linux/major.h
--- a/include/linux/major.h	Sat May 26 15:03:18 2001
+++ b/include/linux/major.h	Sat May 26 15:03:18 2001
@@ -122,6 +122,7 @@
 
 #define LVM_CHAR_MAJOR	109	/* Logical Volume Manager */
 
+#define RTF_MAJOR       150
 #define MDISK_MAJOR     95	/* Official assignations from Peter */
 
 #define AURORA_MAJOR 79