diff -r -N -u -X exclude linux/Makefile rtlinux-2.0.33/Makefile
--- linux/Makefile	Wed Nov 26 16:31:03 1997
+++ rtlinux-2.0.33/Makefile	Mon Feb 16 15:14:19 1998
@@ -16,6 +16,10 @@
 # SMP profiling options
 # SMP_PROF = 1
 
+# For the RT-kernel uncomment the following line
+ RT = 1
+# RT_DEBUG = 1
+
 .EXPORT_ALL_VARIABLES:
 
 CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
@@ -103,6 +107,14 @@
 endif
 endif
 
+ifdef RT
+CFLAGS += -D__RT__
+endif
+
+ifdef RT_DEBUG
+CFLAGS += -D__RT_DEBUG__
+endif
+
 #
 # if you want the ram-disk device, define this to be the
 # size in blocks.
@@ -313,7 +325,7 @@
 	rm -f core `find . -type f -name 'core' -print`
 	rm -f vmlinux System.map
 	rm -f .tmp* drivers/sound/configure
-	rm -fr modules/*
+	rm -fr modules/[^C]* modules/C modules/C[^V]* modules/CV modules/CV[^S]*
 	rm -f submenu*
 
 mrproper: clean
diff -r -N -u -X exclude linux/arch/i386/kernel/Makefile rtlinux-2.0.33/arch/i386/kernel/Makefile
--- linux/arch/i386/kernel/Makefile	Tue Sep 16 15:33:59 1997
+++ rtlinux-2.0.33/arch/i386/kernel/Makefile	Mon Feb 16 15:14:19 1998
@@ -13,10 +13,15 @@
 ifdef SMP
 .S.o:
 	$(CC) -D__ASSEMBLY__ $(AFLAGS) -traditional -c $< -o $*.o
+else 
+ifdef RT
+.S.o:
+	$(CC) -D__RT__ -D__ASSEMBLY__ -traditional -c $< -o $*.o
 else
 .S.o:
 	$(CC) -D__ASSEMBLY__ -traditional -c $< -o $*.o
 endif
+endif
 
 all: kernel.o head.o
 
@@ -36,6 +41,10 @@
 head.o: head.S $(TOPDIR)/include/linux/tasks.h
 	$(CC) -D__ASSEMBLY__ -traditional -c $*.S -o $*.o
 
+endif
+
+ifdef RT
+O_OBJS += rt_time.o
 endif
 
 hexify:
diff -r -N -u -X exclude linux/arch/i386/kernel/entry.S rtlinux-2.0.33/arch/i386/kernel/entry.S
--- linux/arch/i386/kernel/entry.S	Tue Sep 16 15:42:45 1997
+++ rtlinux-2.0.33/arch/i386/kernel/entry.S	Mon Feb 16 15:14:19 1998
@@ -237,6 +237,7 @@
 
 #else
 
+#ifndef __RT__
 #define RESTORE_ALL \
 	cmpw $(KERNEL_CS),CS(%esp); \
 	je 1f;   \
@@ -256,7 +257,32 @@
 	pop %fs; \
 	pop %gs; \
 	addl $4,%esp; \
-	iret
+	iret \
+
+#else /* __RT__ */
+#define RESTORE_ALL \
+	cmpw $(KERNEL_CS),CS(%esp); \
+	je 1f;   \
+	movl SYMBOL_NAME(current_set),%eax; \
+	movl dbgreg7(%eax),%ebx; \
+	movl %ebx,%db7;	\
+1:	\
+	popl %ebx; \
+	popl %ecx; \
+	popl %edx; \
+	popl %esi; \
+	popl %edi; \
+	popl %ebp; \
+	popl %eax; \
+	pop %ds; \
+	pop %es; \
+	pop %fs; \
+	pop %gs; \
+	addl $4,%esp; \
+    jmp _s_iret \
+
+#endif /* __RT__ */
+
 #endif
 
 ENTRY(lcall7)
@@ -353,7 +379,11 @@
 	jne 1f
 	cmpw $(KERNEL_CS),CS(%esp)	# was old code segment supervisor ?
 	je 2f
+#ifndef __RT__
 1:	sti
+#else
+1:	call SYMBOL_NAME(s_sti)
+#endif
 	orl $(IF_MASK),%eax		# these just try to make sure
 	andl $~NT_MASK,%eax		# the program doesn't do anything
 	movl %eax,EFLAGS(%esp)		# stupid
@@ -699,4 +729,13 @@
 	.long SYMBOL_NAME(sys_mremap)
 	.long 0,0
 	.long SYMBOL_NAME(sys_vm86)
+#ifdef __RT__
+	.space (199 - 166)*4
+	.long SYMBOL_NAME(sys_rt_fifo_create)		/* 200 */
+	.long SYMBOL_NAME(sys_rt_fifo_destroy)
+	.long SYMBOL_NAME(sys_rt_fifo_put)
+	.long SYMBOL_NAME(sys_rt_fifo_get)
+	.space (NR_syscalls - 205)*4
+#else
 	.space (NR_syscalls-166)*4
+#endif
diff -r -N -u -X exclude linux/arch/i386/kernel/irq.c rtlinux-2.0.33/arch/i386/kernel/irq.c
--- linux/arch/i386/kernel/irq.c	Mon Mar 17 15:58:59 1997
+++ rtlinux-2.0.33/arch/i386/kernel/irq.c	Mon Feb 16 15:14:19 1998
@@ -37,14 +37,39 @@
 static unsigned char cache_21 = 0xff;
 static unsigned char cache_A1 = 0xff;
 
+#ifdef __RT__
+unsigned long SFIF=0;
+unsigned long SFREQ=0;
+unsigned long SFMASK=0xffffffff;
+/* A SET bit in a SFMASK  ENABLES the corresponding interrupt  */
+
+void s_cli(void)
+{
+	__asm__(S_CLI "ret");
+}
+
+void s_sti(void)
+{
+	__asm__(S_STI "ret");
+}
+
+__asm__( ".align 4; .globl _s_iret; _s_iret: " S_IRET);
+
+#endif /* __RT__ */
+
 #ifdef __SMP_PROF__
 static unsigned int int_count[NR_CPUS][NR_IRQS] = {{0},};
 #endif
 
 static inline void mask_irq(unsigned int irq_nr)
 {
-	unsigned char mask;
 
+#ifdef __RT__
+	r_cli();
+	SFMASK &= ~(1 << irq_nr);
+	r_sti();
+#else
+	unsigned char mask;
 	mask = 1 << (irq_nr & 7);
 	if (irq_nr < 8) {
 		cache_21 |= mask;
@@ -53,12 +78,19 @@
 		cache_A1 |= mask;
 		outb(cache_A1,0xA1);
 	}
+#endif
 }
 
 static inline void unmask_irq(unsigned int irq_nr)
 {
 	unsigned char mask;
 
+#ifdef __RT__
+	r_cli();
+	SFMASK |= (1 << irq_nr);
+	mask = 1 << (irq_nr & 7);
+	if ((irq_nr < 8 && (cache_21 & mask)) || (cache_A1 & mask)) {
+#endif
 	mask = ~(1 << (irq_nr & 7));
 	if (irq_nr < 8) {
 		cache_21 &= mask;
@@ -67,16 +99,25 @@
 		cache_A1 &= mask;
 		outb(cache_A1,0xA1);
 	}
+
+#ifdef __RT__
+	}
+	r_sti();
+#endif
 }
 
 void disable_irq(unsigned int irq_nr)
 {
+#ifdef __RT__
+	mask_irq(irq_nr);
+#else
 	unsigned long flags;
 
 	save_flags(flags);
 	cli();
 	mask_irq(irq_nr);
 	restore_flags(flags);
+#endif
 }
 
 void enable_irq(unsigned int irq_nr)
@@ -111,6 +152,7 @@
  * other interrupts would have to avoid using the jiffies variable for delay
  * and interval timing operations to avoid hanging the system.
  */
+
 BUILD_TIMER_IRQ(FIRST,0,0x01)
 BUILD_IRQ(FIRST,1,0x02)
 BUILD_IRQ(FIRST,2,0x04)
@@ -171,6 +213,110 @@
 	bad_IRQ14_interrupt, bad_IRQ15_interrupt
 };
 
+
+#ifdef __RT__
+static void (*linux_interrupt[16])(void) = {
+	linux_IRQ0_interrupt, linux_IRQ1_interrupt,
+	linux_IRQ2_interrupt, linux_IRQ3_interrupt,
+	linux_IRQ4_interrupt, linux_IRQ5_interrupt,
+	linux_IRQ6_interrupt, linux_IRQ7_interrupt,
+	linux_IRQ8_interrupt, linux_IRQ9_interrupt,
+	linux_IRQ10_interrupt, linux_IRQ11_interrupt,
+	linux_IRQ12_interrupt, linux_IRQ13_interrupt,
+	linux_IRQ14_interrupt, linux_IRQ15_interrupt
+};
+
+static void (*rt_interrupt[16])(void) = {
+	rt_IRQ0_interrupt, rt_IRQ1_interrupt,
+	rt_IRQ2_interrupt, rt_IRQ3_interrupt,
+	rt_IRQ4_interrupt, rt_IRQ5_interrupt,
+	rt_IRQ6_interrupt, rt_IRQ7_interrupt,
+	rt_IRQ8_interrupt, rt_IRQ9_interrupt,
+	rt_IRQ10_interrupt, rt_IRQ11_interrupt,
+	rt_IRQ12_interrupt, rt_IRQ13_interrupt,
+	rt_IRQ14_interrupt, rt_IRQ15_interrupt
+};
+
+/* RT interrupts */
+void (*RTaction[16])(void);
+asmlinkage void RTno_action(void) 
+{ 
+}
+
+/* software IDT */
+void (*SFIDT[16])(void);
+
+static int rt_irq_status[16];
+
+#undef set_intr_gate
+
+#define hard_set_intr_gate(n,addr) \
+	_set_gate(&idt[n],14,0,addr)
+
+void set_handler(int irq) 
+{
+	if (rt_irq_status[irq]) {
+		hard_set_intr_gate(0x20+irq, rt_interrupt[irq]);
+	} else {
+		hard_set_intr_gate(0x20+irq, linux_interrupt[irq]);
+	}
+}
+
+void set_intr_gate(int gate, void *ptr) 
+{
+	int flags;
+	int irq;
+	
+	irq = gate - 0x20;
+	r_save_flags(flags);
+	r_cli();
+	SFIDT [irq] = ptr;
+	set_handler(irq);
+	r_restore_flags(irq);
+}
+
+
+int request_RTirq(unsigned int irq, void (*handler)(void) )
+{
+	unsigned long flags;
+
+	if (irq > 15)
+		return -EINVAL;
+
+	if (rt_irq_status[irq])
+		return -EBUSY;
+
+	if (!handler)
+		return -EINVAL;
+
+	rt_irq_status[irq] = 1;
+	r_save_flags(flags);
+	r_cli();
+	RTaction[irq] = handler;
+	set_handler(irq);
+	unmask_irq(irq);
+	r_restore_flags(flags);
+	return 0;
+}
+
+
+void free_RTirq(unsigned int irq)
+{
+	unsigned long flags;
+	if (irq > 15) {
+		printk("Trying to free IRQ%d\n",irq);
+		return;
+	}
+	rt_irq_status[irq] = 0;
+	r_save_flags(flags);
+	r_cli();
+	set_handler(irq);
+	mask_irq(irq);
+	r_restore_flags(flags);
+}
+
+#endif /* __RT__ */
+
 /*
  * Initial irq handlers.
  */
@@ -542,10 +688,21 @@
 		return;
 	smptrap=1;
 
+#ifndef __RT__
 	/* set the clock to 100 Hz */
 	outb_p(0x34,0x43);		/* binary, mode 2, LSB/MSB, ch 0 */
 	outb_p(LATCH & 0xff , 0x40);	/* LSB */
 	outb(LATCH >> 8 , 0x40);	/* MSB */
+
+#else /* __RT__ */
+	SFIF=0;
+	SFREQ=0;
+	SFMASK=0xffffffff;
+	for (i = 0; i < 16; i++) {
+		rt_irq_status[i] = 0;    
+	}
+#endif /* __RT__ */
+
 	for (i = 0; i < 16 ; i++)
 		set_intr_gate(0x20+i,bad_interrupt[i]);
 	/* This bit is a hack because we don't send timer messages to all processors yet */
diff -r -N -u -X exclude linux/arch/i386/kernel/rt_time.c rtlinux-2.0.33/arch/i386/kernel/rt_time.c
--- linux/arch/i386/kernel/rt_time.c	Wed Dec 31 17:00:00 1969
+++ rtlinux-2.0.33/arch/i386/kernel/rt_time.c	Mon Feb 16 15:14:19 1998
@@ -0,0 +1,232 @@
+/*
+ *  arch/i386/kernel/rt_time.c
+ *
+ *  Copyright (C) 1996 by Michael Barabanov
+ *
+ */
+
+
+#include <asm/io.h>
+#include <linux/errno.h>
+#include <asm/system.h>
+#include <asm/rt_time.h>
+#include <asm/rt_irq.h>
+#include <linux/sched.h>
+#include <linux/timex.h>
+
+#ifdef __RT_DEBUG__
+#include <linux/cons.h>
+#endif
+
+
+extern unsigned long SFREQ;
+
+RTIME rt_linux_clock;    /* time to generate the next linux interrupt  */
+static RTIME rt_callback_time;  /* time to invoke the supplied procedure      */
+
+static RTIME rt_intr_time;
+
+static void (*rt_timer_handler)(void);
+
+
+#define READ_CNT0(var) \
+{ var = inb(0x40); var |= (inb(0x40) << 8); }
+
+#define READ_CNT2(var) \
+{ var = inb(0x42); var |= (inb(0x42) << 8); }
+
+
+#define LATCH_CNT0() \
+outb(0xd2, 0x43);
+
+#define LATCH_CNT0_AND_2() \
+outb(0xda, 0x43);
+
+#define LATCH_CNT2() \
+outb(0xd8, 0x43);
+
+
+static RTIME rt_base_time;      /* the time when Counter 0 was == base_c0 */
+static int base_c0;
+
+int rt_latch2;			/* the current latch value for counter 2 */
+                                
+
+RTIME rt_get_time(void)
+{
+	register int c0;
+	int flags;
+	RTIME result;
+
+	r_save_flags(flags);
+	r_cli();
+	LATCH_CNT0();
+	READ_CNT0(c0);
+	result = rt_base_time + ((base_c0 - c0) & 0xffff);
+	r_restore_flags(flags);
+	return result;
+}
+
+
+#ifdef __RT_DEBUG__
+int maxdiff, mindiff;
+#endif
+
+/* The main procedure; resets the 8254 timer to generate an interrupt.  The
+ * tricky part is to keep the global time while reprogramming it.  We latch
+ * counters 0 and 2 atomically before and after reprogramming to figure it out.
+ */
+
+static void rt_reset_timer(void)
+{
+	register int c2;
+	register int c2new;
+	register int temp;
+	int incr;
+	int flags;
+	
+
+#ifdef __RT_DEBUG__
+	int diff;
+#endif
+
+	r_save_flags(flags);
+	r_cli();
+
+	if (rt_linux_clock < rt_callback_time) {
+		temp = rt_linux_clock - rt_base_time;
+	}
+	else {
+		temp = rt_callback_time - rt_base_time;
+	}
+
+	/* between the two latches we want to have as less stuff as possible */
+	LATCH_CNT0_AND_2();
+	READ_CNT0(c2new);
+	READ_CNT2(c2);
+
+	incr = ((base_c0 - c2new) & 0xffff);  /* current time = rt_base_time + incr */
+
+	temp -= incr;
+	if (temp < 10) {
+		temp = 10; 
+	}
+
+	outb(temp & 0xff, 0x40);
+	outb_p(temp >> 8, 0x40);
+    
+	LATCH_CNT0_AND_2();
+	READ_CNT0(base_c0);
+	READ_CNT2(c2new);
+
+	rt_base_time += (incr + ((c2new < c2) ? (c2 - c2new) / 2 : (c2 - c2new + rt_latch2) / 2));
+
+	rt_intr_time = rt_base_time + temp;
+	
+
+#ifdef __RT_DEBUG__
+	diff = (c2new < c2) ? (c2 - c2new) / 2 : (c2 - c2new + rt_latch2) / 2;
+	if (diff > maxdiff) {
+		maxdiff = diff;
+		conpr("new record: "); conprn(mindiff); conprn(maxdiff); conpr("\n");
+	}
+	if (diff < mindiff) {
+		mindiff = diff;
+		conpr("new record: "); conprn(mindiff); conprn(maxdiff); conpr("\n");
+	}
+	r_restore_flags(flags);
+#endif
+}
+
+
+void rt_timer_irq(void)
+{
+	if (rt_intr_time + 10 >= rt_callback_time) {
+		(*rt_timer_handler)();
+
+	} else {
+		SFREQ |= 1;
+		rt_linux_clock += LATCH;
+		rt_reset_timer();
+	}
+
+}
+
+
+void rt_set_timer(RTIME when) 
+{
+	rt_callback_time = when;
+	rt_reset_timer();
+}
+
+
+void rt_no_timer(void) 
+{
+	rt_callback_time = RT_TIME_END;
+	rt_reset_timer();
+}
+
+
+int rt_request_timer(void (*fn)(void)) 
+{
+	if (!fn) {
+		return -EINVAL;
+	}
+	if (rt_timer_handler) {
+		return -EBUSY;
+	}
+
+	rt_timer_handler = fn;
+	return 0;
+}
+
+
+void rt_free_timer(void)
+{
+	rt_timer_handler = 0;
+	rt_no_timer();
+}
+
+
+
+void rt_time_init(void)
+{
+	int flags;
+
+	r_save_flags(flags);
+	r_cli();
+
+	rt_timer_handler = 0;
+
+	rt_linux_clock = LATCH;
+	rt_callback_time = RT_TIME_END;
+
+	outb_p(0x30, 0x43);       /* 8254, channel 0, mode 0, lsb+msb */
+
+	request_RTirq(0, rt_timer_irq);
+
+	outb_p(0xff, 0x40);       /* start counting */
+	outb_p(0xff, 0x40);
+
+	rt_base_time = 0;
+	LATCH_CNT0();
+	READ_CNT0(base_c0);
+
+	rt_reset_timer();
+
+#ifdef __RT_DEBUG__
+	mindiff = 10000;
+	maxdiff = -10000;
+#endif /* __RT_DEBUG__ */
+
+	/* program channel 2 of the 8253 chip for periodic interrrupt */
+	rt_latch2 = 50000;
+	outb_p(0xb6, 0x43);	/* binary, mode 3, LSB/MSB, ch 2 */
+	outb_p(rt_latch2 & 0xff, 0x42);
+	outb((rt_latch2 >> 8) & 0xff, 0x42);
+
+	outb((inb_p(0x61) & 0xfd) | 1, 0x61); /* shut up the speaker and enable counting */
+
+	r_restore_flags(flags);
+}
+
diff -r -N -u -X exclude linux/arch/i386/kernel/time.c rtlinux-2.0.33/arch/i386/kernel/time.c
--- linux/arch/i386/kernel/time.c	Fri Nov  7 11:06:21 1997
+++ rtlinux-2.0.33/arch/i386/kernel/time.c	Mon Feb 16 15:14:19 1998
@@ -33,6 +33,7 @@
 #include <linux/mc146818rtc.h>
 #include <linux/timex.h>
 #include <linux/config.h>
+#include <linux/rt_time.h>
 
 extern int setup_x86_irq(int, struct irqaction *);
 
@@ -174,62 +175,16 @@
 static unsigned long do_slow_gettimeoffset(void)
 {
 	int count;
-	static int count_p = 0;
 	unsigned long offset = 0;
-	static unsigned long jiffies_p = 0;
+	RTIME now;
 
-	/*
-	 * cache volatile jiffies temporarily; we have IRQs turned off. 
-	 */
-	unsigned long jiffies_t;
-
-	/* timer count may underflow right here */
-	outb_p(0x00, 0x43);	/* latch the count ASAP */
-	count = inb_p(0x40);	/* read the latched count */
-	count |= inb(0x40) << 8;
-
- 	jiffies_t = jiffies;
-
-	/*
-	 * avoiding timer inconsistencies (they are rare, but they happen)...
-	 * there are three kinds of problems that must be avoided here:
-	 *  1. the timer counter underflows
-	 *  2. hardware problem with the timer, not giving us continuous time,
-	 *     the counter does small "jumps" upwards on some Pentium systems,
-	 *     thus causes time warps
-	 *  3. we are after the timer interrupt, but the bottom half handler
-	 *     hasn't executed yet.
-	 */
-	if( count > count_p ) {
-		if( jiffies_t == jiffies_p ) {
-			if( count > LATCH-LATCH/100 )
-				offset = TICK_SIZE;
-			else
-				/*
-				 * argh, the timer is bugging we cant do nothing 
-				 * but to give the previous clock value.
-				 */
-				count = count_p;
-		} else {
-			if( test_bit(TIMER_BH, &bh_active) ) {
-				/*
-				 * we have detected a counter underflow.
-			 	 */
-				offset = TICK_SIZE;
-				count_p = count;		
-			} else {
-				count_p = count;
-				jiffies_p = jiffies_t;
-			}
-		}
-	} else {
-		count_p = count;
-		jiffies_p = jiffies_t;
- 	}
+	now = rt_get_time();
 
+	if( test_bit(TIMER_BH, &bh_active) ) {
+		offset = TICK_SIZE;
+	}
 
-	count = ((LATCH-1) - count) * TICK_SIZE;
-	count = (count + LATCH/2) / LATCH;
+	count = (((long)(now - rt_linux_clock)) * TICK_SIZE) / LATCH;
 
 	return offset + count;
 }
diff -r -N -u -X exclude linux/drivers/block/hd.c rtlinux-2.0.33/drivers/block/hd.c
--- linux/drivers/block/hd.c	Thu Feb 29 22:50:39 1996
+++ rtlinux-2.0.33/drivers/block/hd.c	Mon Feb 16 15:14:19 1998
@@ -93,8 +93,13 @@
 #if (HD_DELAY > 0)
 unsigned long last_req;
 
+#ifdef __RT__
+#include <asm/rt_time.h>
+#endif
+
 unsigned long read_timer(void)
 {
+#ifndef __RT__
 	unsigned long t, flags;
 	int i;
 
@@ -106,6 +111,9 @@
 	i |= inb(0x40) << 8;
 	restore_flags(flags);
 	return(t - i);
+#else
+	return (long) rt_get_time();
+#endif
 }
 #endif
 
diff -r -N -u -X exclude linux/drivers/block/ide.c rtlinux-2.0.33/drivers/block/ide.c
--- linux/drivers/block/ide.c	Mon Aug  4 12:45:55 1997
+++ rtlinux-2.0.33/drivers/block/ide.c	Mon Feb 16 15:14:19 1998
@@ -333,8 +333,14 @@
  * For really screwy hardware (hey, at least it *can* be used with Linux)
  * we can enforce a minimum delay time between successive operations.
  */
+
+#ifdef __RT__
+#include <asm/rt_time.h>
+#endif
+
 static unsigned long read_timer(void)
 {
+#ifndef __RT__
 	unsigned long t, flags;
 	int i;
 
@@ -346,6 +352,9 @@
 	i |= inb(0x40) << 8;
 	restore_flags(flags);
 	return (t - i);
+#else
+	return (long) rt_get_time();
+#endif
 }
 
 static void set_recovery_timer (ide_hwif_t *hwif)
diff -r -N -u -X exclude linux/drivers/char/ftape/calibr.c rtlinux-2.0.33/drivers/char/ftape/calibr.c
--- linux/drivers/char/ftape/calibr.c	Thu Mar 14 02:51:41 1996
+++ rtlinux-2.0.33/drivers/char/ftape/calibr.c	Mon Feb 16 15:14:20 1998
@@ -32,8 +32,13 @@
 
 #undef DEBUG
 
+#ifdef __RT__
+#include <asm/rt_time.h>
+#endif
+
 unsigned timestamp(void)
 {
+#ifndef __RT__
 	unsigned count;
 	unsigned long flags;
 
@@ -44,6 +49,9 @@
 	count |= inb(0x40) << 8;
 	restore_flags(flags);
 	return (LATCH - count);	/* normal: downcounter */
+#else
+	return (long) rt_get_time();
+#endif
 }
 
 int timediff(int t0, int t1)
diff -r -N -u -X exclude linux/drivers/char/vt.c rtlinux-2.0.33/drivers/char/vt.c
--- linux/drivers/char/vt.c	Sun May 12 22:36:19 1996
+++ rtlinux-2.0.33/drivers/char/vt.c	Mon Feb 16 15:14:20 1998
@@ -147,11 +147,21 @@
  * We also return immediately, which is what was implied within the X
  * comments - KDMKTONE doesn't put the process to sleep.
  */
+
+#ifdef __RT__
+#include <asm/rt_time.h>
+#endif
+
 static void
 kd_nosound(unsigned long ignored)
 {
+#ifndef __RT__
 	/* disable counter 2 */
 	outb(inb_p(0x61)&0xFC, 0x61);
+#else
+	/* disable speaker */
+	outb(inb_p(0x61) & 0xfd, 0x61);
+#endif
 	return;
 }
 
@@ -163,19 +173,38 @@
 
 	unsigned int count = 0;
 
+#ifdef __RT__
+	if (hz > 4000) {
+		hz = 4000;
+	}
+#endif
+
 	if (hz > 20 && hz < 32767)
 		count = 1193180 / hz;
 	
 	cli();
 	del_timer(&sound_timer);
 	if (count) {
+
+#ifdef __RT__
+		/* enable speaker */
+		outb_p(inb_p(0x61)|2, 0x61);
+		count &= 0xfffffffe;  /* we do need an even count */
+
+		r_cli();
+		rt_latch2 = count;
+#else
 		/* enable counter 2 */
 		outb_p(inb_p(0x61)|3, 0x61);
+#endif
 		/* set command for counter 2, 2 byte write */
 		outb_p(0xB6, 0x43);
 		/* select desired HZ */
 		outb_p(count & 0xff, 0x42);
 		outb((count >> 8) & 0xff, 0x42);
+#ifdef __RT__
+		r_sti();
+#endif
 
 		if (ticks) {
 			sound_timer.expires = jiffies+ticks;
diff -r -N -u -X exclude linux/drivers/sound/local.h rtlinux-2.0.33/drivers/sound/local.h
--- linux/drivers/sound/local.h	Wed Dec 31 17:00:00 1969
+++ rtlinux-2.0.33/drivers/sound/local.h	Mon Feb 16 15:17:01 1998
@@ -0,0 +1,45 @@
+/* Computer generated file. Please don't edit! */
+
+#define KERNEL_COMPATIBLE_CONFIG
+
+#define SELECTED_SOUND_OPTIONS	0x00000000
+
+#if \
+  defined(CONFIG_PSS) || defined(CONFIG_SSCAPE) || \
+  defined(CONFIG_CS4232) || defined(CONFIG_MAUI)
+#	define CONFIG_MPU_EMU
+#endif
+
+#if \
+  defined(CONFIG_PSS) || defined(CONFIG_GUS16) || \
+  defined(CONFIG_GUSMAX) || defined(CONFIG_MSS) || \
+  defined(CONFIG_SSCAPE) || defined(CONFIG_TRIX) || \
+  defined(CONFIG_MAD16) || defined(CONFIG_CS4232)
+#	define CONFIG_AD1848
+#endif
+
+#if \
+  defined(CONFIG_SB) || defined(CONFIG_TRIX) || \
+  defined(CONFIG_MAD16)
+#	define CONFIG_SBDSP
+#endif
+
+#if \
+  defined(CONFIG_SB) || defined(CONFIG_TRIX) || \
+  defined(CONFIG_MAD16)
+#	define CONFIG_UART401
+#endif
+
+#if \
+  defined(CONFIG_PAS) || defined(CONFIG_SB) || \
+  defined(CONFIG_ADLIB) || defined(CONFIG_GUS) || \
+  defined(CONFIG_MPU401) || defined(CONFIG_PSS) || \
+  defined(CONFIG_SSCAPE) || defined(CONFIG_TRIX) || \
+  defined(CONFIG_MAD16) || defined(CONFIG_CS4232) || \
+  defined(CONFIG_MAUI)
+#	define CONFIG_SEQUENCER
+#endif
+
+#define SOUND_CONFIG_DATE "Mon Feb 16 15:17:01 MST 1998"
+#define SOUND_CONFIG_BY "root"
+#define SOUND_UNAME_A "Linux horek.cs.nmt.edu 2.0.29 #2 Thu Sep 18 19:15:33 MDT 1997 i586 unknown"
diff -r -N -u -X exclude linux/fs/Makefile rtlinux-2.0.33/fs/Makefile
--- linux/fs/Makefile	Fri Sep  5 21:43:59 1997
+++ rtlinux-2.0.33/fs/Makefile	Mon Feb 16 15:14:20 1998
@@ -19,6 +19,14 @@
 ALL_SUB_DIRS = minix ext ext2 fat msdos vfat proc isofs nfs xiafs umsdos \
 		hpfs sysv smbfs ncpfs ufs affs autofs
 
+ifdef RT
+O_OBJS += rt_fifo.o
+endif
+
+ifdef RT
+M_OBJS += rt_fifo_new.o
+endif
+
 ifeq ($(CONFIG_QUOTA),y)
 O_OBJS += dquot.o
 else
diff -r -N -u -X exclude linux/fs/rt_fifo.c rtlinux-2.0.33/fs/rt_fifo.c
--- linux/fs/rt_fifo.c	Wed Dec 31 17:00:00 1969
+++ rtlinux-2.0.33/fs/rt_fifo.c	Mon Feb 16 15:14:20 1998
@@ -0,0 +1,218 @@
+#include <linux/rt_fifo.h>
+
+#include <asm/segment.h>
+#include <linux/malloc.h>
+#include <asm/errno.h>
+
+#include <linux/cons.h>
+
+struct RTfifo {
+	char *buf;
+	char *eob;
+	int size;
+	char *head;
+	char *tail;
+};
+
+/* amount of data in a fifo */
+static inline int bytes(struct RTfifo * fifo) 
+{
+	return  fifo->head  >= fifo->tail ?  
+		fifo->head - fifo->tail :
+		fifo->size - (fifo->tail - fifo->head); 
+}
+
+
+
+int RTfifo_create(struct RTfifo *fifo, char * buf, int sz) 
+{
+
+	fifo->buf = buf;
+	fifo->size = sz;
+	fifo->eob = buf + sz;
+	fifo->head = buf;
+	fifo->tail = buf;
+	
+	return 0; 
+}
+
+
+inline int RTfifo_put(struct RTfifo *fifo, char * buf, int count) 
+{
+	int till_end;
+
+	till_end = fifo->eob - fifo-> head;
+	if (till_end > count) {
+		memcpy_fromfs(fifo-> head, buf, count);
+		fifo->head += count;
+	}
+	else {
+		memcpy_fromfs(fifo-> head, buf, till_end);
+		memcpy_fromfs(fifo-> buf, buf + till_end, count - till_end);
+		fifo-> head = fifo-> buf + count - till_end;
+	}
+
+	return count;
+}
+
+
+
+inline int RTfifo_get(struct RTfifo *fifo, char * buf, int count) 
+{
+	int till_end;
+
+	till_end = fifo->eob - fifo-> tail;
+	if (till_end > count) {
+		memcpy_tofs(buf, fifo-> tail, count);
+		fifo->tail += count;
+	}
+	else {
+		memcpy_tofs(buf, fifo-> tail, till_end);
+		memcpy_tofs(buf + till_end, fifo-> buf, count - till_end);
+		fifo-> tail = fifo-> buf + count - till_end;
+	}
+
+	return count;
+}
+
+
+
+struct RTfifo fifoes[RT_MAX_FIFO];
+static char status[RT_MAX_FIFO];
+
+static inline struct RTfifo * get_addr(unsigned int fifo) 
+{
+	if (fifo < RT_MAX_FIFO && status[fifo] )
+		return &fifoes[fifo];
+	return 0;
+}
+
+
+int rt_fifo_put(unsigned int f, char * buf, int count) 
+{
+	struct RTfifo *fifo= get_addr(f);
+	unsigned long old_fs = get_fs();
+	int result;
+	long flags;
+
+	if (!fifo) return -EINVAL;
+
+	r_save_flags(flags);
+	r_cli();
+	if (fifo->size - bytes(fifo) - 1 < count) {
+		r_restore_flags(flags);
+		return -1;
+	}
+	set_fs(get_ds());
+	result = RTfifo_put(fifo, buf, count);
+	set_fs(old_fs);
+
+	r_restore_flags(flags);
+	return  result;
+}
+
+
+int rt_fifo_get(unsigned int f, char * buf, int count) 
+{
+	struct RTfifo *fifo= get_addr(f);
+	unsigned long old_fs = get_fs();
+	int result;
+	long flags;
+
+	if (!fifo) return -EINVAL;
+
+	r_save_flags(flags);
+	r_cli();
+	if (bytes(fifo) < count) {
+		r_restore_flags(flags);
+		return -1;
+	}
+	set_fs(get_ds());
+	result = RTfifo_get(fifo, buf, count);
+	set_fs(old_fs);
+
+	r_restore_flags(flags);
+	return  result;
+}
+
+
+
+asmlinkage int sys_rt_fifo_create(unsigned int f, int size) 
+{
+	char * buf;
+	if (f >= RT_MAX_FIFO) {
+		return -EINVAL;
+	}
+	
+	buf= kmalloc(size, GFP_KERNEL);
+	if (!buf) {
+		return -ENOMEM;
+	}
+
+	RTfifo_create(&fifoes[f], buf, size);
+
+	status[f] =1;
+	return 0;
+}
+
+
+asmlinkage int sys_rt_fifo_destroy(unsigned int f) 
+{
+	struct RTfifo *fifo= get_addr(f);
+	if (!fifo) return -EINVAL;
+
+	status[f]=0;
+	
+	kfree(fifo-> buf);
+	return 0;
+}
+
+
+asmlinkage int sys_rt_fifo_put(unsigned int f, char * buf, int count) 
+{
+	long flags;
+	int ret;
+	struct RTfifo *fifo= get_addr(f);
+	if (!fifo) return -EINVAL;
+
+	r_save_flags(flags);
+
+	if (fifo->size - bytes(fifo) - 1 < count) {
+		r_restore_flags(flags);
+		return -1;
+	}
+	ret = RTfifo_put(fifo, buf, count);
+
+	r_restore_flags(flags);
+	return ret;
+}
+
+
+
+asmlinkage int sys_rt_fifo_get(unsigned int f, char * buf, int count) 
+{
+	long flags;
+	int ret;
+	struct RTfifo *fifo= get_addr(f);
+	if (!fifo) return -EINVAL;
+
+	r_save_flags(flags);
+
+	if (bytes(fifo) < count) {
+		r_restore_flags(flags);
+		return -1;
+	}
+
+	ret = RTfifo_get(fifo, buf, count);
+	r_restore_flags(flags);
+	return ret;
+}
+
+
+void rt_fifo_init(void) 
+{
+	int i;
+	for (i=0; i< RT_MAX_FIFO; i++) {
+		status[i]=0;
+	}
+}
diff -r -N -u -X exclude linux/fs/rt_fifo_new.c rtlinux-2.0.33/fs/rt_fifo_new.c
--- linux/fs/rt_fifo_new.c	Wed Dec 31 17:00:00 1969
+++ rtlinux-2.0.33/fs/rt_fifo_new.c	Mon Feb 16 15:14:20 1998
@@ -0,0 +1,455 @@
+/*
+ * RT-FIFO devices
+ *
+ * 1997, Michael Barabanov
+ *
+ * A lot of this code is stolen from fs/pipe.c
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/major.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/malloc.h>
+#include <linux/rtf.h>
+
+#include <asm/system.h>
+
+#define RTF_NO 64
+
+struct rt_fifo_struct {
+	int open;
+	int user_open;
+	int sleeps;
+	char *base;
+	int bufsize;
+	int start;
+	int len;
+	int (*user_handler) (unsigned int fifo);
+	struct wait_queue *wait;
+	struct tq_struct wake_up_task;
+};
+
+static struct rt_fifo_struct fifoes[RTF_NO];
+
+#define RTF_ADDR(minor)		(&fifoes[minor])
+
+#define RTF_OPEN(minor)		(RTF_ADDR(minor)->open)
+#define RTF_USER_OPEN(minor)	(RTF_ADDR(minor)->user_open)
+#define RTF_BASE(minor)		(RTF_ADDR(minor)->base)
+#define RTF_BUF(minor)		(RTF_ADDR(minor)->bufsize)
+#define RTF_START(minor)	(RTF_ADDR(minor)->start)
+#define RTF_HANDLER(minor)	(RTF_ADDR(minor)->user_handler)
+#define RTF_LEN(minor)		(RTF_ADDR(minor)->len)
+#define RTF_FREE(minor)		(RTF_BUF(minor) - RTF_LEN(minor))
+#define RTF_WAIT(minor)		(RTF_ADDR(minor)->wait)
+#define RTF_SLEEPS(minor)	(RTF_ADDR(minor)->sleeps)
+#define RTF_WAKE_UP_TASK(minor)	(RTF_ADDR(minor)->wake_up_task)
+
+#define RTF_WRAP(minor,pos)	((pos) < RTF_BUF(minor)? (pos) : (pos) - RTF_BUF(minor))
+#define RTF_END(minor)		RTF_WRAP(minor, RTF_START(minor)+RTF_LEN(minor))
+#define RTF_EMPTY(minor)	(RTF_LEN(minor)==0)
+#define RTF_FULL(minor)		(RTF_FREE(minor)==0)
+#define RTF_MAX_RCHUNK(minor)	(RTF_BUF(minor) - RTF_START(minor))
+#define RTF_MAX_WCHUNK(minor)	(RTF_BUF(minor) - RTF_END(minor))
+
+
+static void rtf_wake_up(void *p)
+{
+	struct rt_fifo_struct *fifo_ptr = (struct rt_fifo_struct *) p;
+	wake_up_interruptible(&(fifo_ptr->wait));
+}
+
+
+/* These are for use in real-time processes */
+
+int rtf_resize(unsigned int minor, int size)
+{
+	void *mem;
+	void *old;
+	long flags;
+
+	if (minor >= RTF_NO) {
+		return -ENODEV;
+	}
+	mem = kmalloc(size, GFP_KERNEL);
+	if (!mem) {
+		return -ENOMEM;
+	}
+	old = RTF_BASE(minor);
+
+	r_save_flags(flags);
+	r_cli();
+
+	RTF_BASE(minor) = mem;
+	RTF_BUF(minor) = size;
+	RTF_START(minor) = 0;
+	RTF_LEN(minor) = 0;
+
+	r_restore_flags(flags);
+
+	if (RTF_OPEN(minor)) {
+		kfree(old);
+	}
+	return size;
+}
+
+
+int rtf_create(unsigned int minor, int size)
+{
+	int result;
+
+	if (minor >= RTF_NO) {
+		return -ENODEV;
+	}
+	if (RTF_OPEN(minor)) {
+		return -EBUSY;
+	}
+	if ((result = rtf_resize(minor, size)) < 0) {
+		return result;
+	}
+	RTF_OPEN(minor) = 1;
+	RTF_SLEEPS(minor) = 0;
+	RTF_USER_OPEN(minor) = 0;
+	RTF_HANDLER(minor) = 0;
+
+	RTF_WAKE_UP_TASK(minor).next = 0;
+	RTF_WAKE_UP_TASK(minor).sync = 0;
+	RTF_WAKE_UP_TASK(minor).data = RTF_ADDR(minor);
+	RTF_WAKE_UP_TASK(minor).routine = &rtf_wake_up;
+
+	RTF_WAIT(minor) = 0;
+
+	return 0;
+}
+
+
+int rtf_destroy(unsigned int minor)
+{
+	if (minor >= RTF_NO) {
+		return -ENODEV;
+	}
+	if (RTF_USER_OPEN(minor)) {
+		return -EINVAL;
+	}
+	if (!RTF_OPEN(minor)) {
+		return -EINVAL;
+	}
+	RTF_OPEN(minor) = 0;
+	kfree(RTF_BASE(minor));
+	return 0;
+}
+
+
+int rtf_create_handler(unsigned int minor, int (*handler) (unsigned int fifo))
+{
+	if (minor >= RTF_NO || !RTF_OPEN(minor) || !handler) {
+		return -EINVAL;
+	}
+	RTF_HANDLER(minor) = handler;
+	return 0;
+}
+
+
+int rtf_put(unsigned int minor, void *buf, int count)
+{
+	long flags;
+	int chars = 0, free = 0, written = 0;
+	char *pipebuf;
+
+	if (minor >= RTF_NO) {
+		return -ENODEV;
+	}
+	if (!RTF_OPEN(minor))
+		return -EINVAL;
+
+	r_save_flags(flags);
+	r_cli();
+	if (RTF_FREE(minor) < count) {
+		r_restore_flags(flags);
+		return -ENOSPC;
+	}
+	while (count > 0 && (free = RTF_FREE(minor))) {
+		chars = RTF_MAX_WCHUNK(minor);
+		if (chars > count)
+			chars = count;
+		if (chars > free)
+			chars = free;
+		pipebuf = RTF_BASE(minor) + RTF_END(minor);
+		written += chars;
+		RTF_LEN(minor) += chars;
+		count -= chars;
+		memcpy(pipebuf, buf, chars);
+		buf += chars;
+	}
+	r_restore_flags(flags);
+	if (clear_bit(1, &RTF_SLEEPS(minor))) {
+		queue_task_rt(&RTF_WAKE_UP_TASK(minor), &tq_rt);
+	}
+	return count;
+}
+
+
+int rtf_get(unsigned int minor, void *buf, int count)
+{
+	long flags;
+	int chars = 0, size = 0, read = 0;
+	char *pipebuf;
+
+	if (minor >= RTF_NO) {
+		return -ENODEV;
+	}
+	if (!RTF_OPEN(minor))
+		return -EINVAL;
+
+	r_save_flags(flags);
+	r_cli();
+	while (count > 0 && (size = RTF_LEN(minor))) {
+		chars = RTF_MAX_RCHUNK(minor);
+		if (chars > count)
+			chars = count;
+		if (chars > size)
+			chars = size;
+
+		read += chars;
+		pipebuf = RTF_BASE(minor) + RTF_START(minor);
+		RTF_START(minor) += chars;
+		RTF_START(minor) = RTF_WRAP(minor, RTF_START(minor));
+		RTF_LEN(minor) -= chars;
+		count -= chars;
+		memcpy(buf, pipebuf, chars);
+		buf += chars;
+	}
+	r_restore_flags(flags);
+	if (clear_bit(1, &RTF_SLEEPS(minor))) {
+		queue_task_rt(&RTF_WAKE_UP_TASK(minor), &tq_rt);
+	}
+	return read;
+}
+
+
+/* 
+ * these are file_operations functions
+ */
+
+static int rtf_open(struct inode *inode, struct file *filp)
+{
+	unsigned int minor = MINOR(inode->i_rdev);
+
+	if (minor >= RTF_NO)
+		return -ENODEV;
+
+	if (!RTF_OPEN(minor)) {
+		return -EINVAL;
+	}
+	if (RTF_USER_OPEN(minor)) {
+		return -EBUSY;
+	}
+	RTF_USER_OPEN(minor) = 1;
+
+	MOD_INC_USE_COUNT;
+	return 0;
+}
+
+
+static void rtf_release(struct inode *inode, struct file *file)
+{
+	unsigned int minor = MINOR(inode->i_rdev);
+
+	if (!RTF_USER_OPEN(minor)) {
+		printk("rtf: release on a not opened descriptor\n");
+		return;
+	}
+	RTF_SLEEPS(minor) = 0;
+	RTF_USER_OPEN(minor) = 0;
+	MOD_DEC_USE_COUNT;
+}
+
+
+static int rtf_lseek(struct inode *inode, struct file *file, off_t offset, int origin)
+{
+	return -ESPIPE;
+}
+
+
+static int rtf_read(struct inode *inode, struct file *filp, char *buf, int count)
+{
+	unsigned int minor = MINOR(inode->i_rdev);
+	long flags;
+	int result;
+
+	int chars = 0, size = 0, read = 0;
+	char *pipebuf;
+
+	if (filp->f_flags & O_NONBLOCK) {
+		/*      if (RTF_LOCK(minor))
+		   return -EAGAIN;
+		 */
+		if (RTF_EMPTY(minor))
+			return 0;
+	} else
+		while (RTF_EMPTY(minor) /* || RTF_LOCK(minor) */ ) {
+			if (current->signal & ~current->blocked)
+				return -ERESTARTSYS;
+			set_bit(1, &RTF_SLEEPS(minor));
+			interruptible_sleep_on(&RTF_WAIT(minor));
+		}
+/*      RTF_LOCK(minor)++; */
+	while (count > 0 && (size = RTF_LEN(minor))) {
+		chars = RTF_MAX_RCHUNK(minor);
+		if (chars > count)
+			chars = count;
+		if (chars > size)
+			chars = size;
+
+		read += chars;
+		pipebuf = RTF_BASE(minor) + RTF_START(minor);
+		count -= chars;
+		memcpy_tofs(buf, pipebuf, chars);
+		r_save_flags(flags);
+		r_cli();
+		RTF_START(minor) += chars;
+		RTF_START(minor) = RTF_WRAP(minor, RTF_START(minor));
+		RTF_LEN(minor) -= chars;
+		r_restore_flags(flags);
+		buf += chars;
+	}
+/*      RTF_LOCK(minor)--; */
+	if (read) {
+		inode->i_atime = CURRENT_TIME;
+		if (RTF_HANDLER(minor)) {
+			if ((result = (*RTF_HANDLER(minor)) (minor)) < 0) {
+				return result;
+			}
+		}
+		return read;
+	}
+	return 0;
+}
+
+
+static int rtf_write(struct inode *inode, struct file *filp, const char *buf, int count)
+{
+	unsigned int minor = MINOR(inode->i_rdev);
+	long flags;
+	int chars = 0, free = 0, written = 0;
+	char *pipebuf;
+	int result;
+
+	if (count <= RTF_BUF(minor))
+		free = count;
+	else
+		free = 1;
+
+	while (count > 0) {
+		while ((RTF_FREE(minor) < free) /* || RTF_LOCK(minor) */ ) {
+			if (current->signal & ~current->blocked)
+				return written ? : -ERESTARTSYS;
+			if (filp->f_flags & O_NONBLOCK)
+				return written ? : -EAGAIN;
+			set_bit(1, &RTF_SLEEPS(minor));
+			interruptible_sleep_on(&RTF_WAIT(minor));
+		}
+		/*      RTF_LOCK(minor)++; */
+		while (count > 0 && (free = RTF_FREE(minor))) {
+			chars = RTF_MAX_WCHUNK(minor);
+			if (chars > count)
+				chars = count;
+			if (chars > free)
+				chars = free;
+			r_save_flags(flags);
+			r_cli();
+			pipebuf = RTF_BASE(minor) + RTF_END(minor);
+			r_restore_flags(flags);
+			count -= chars;
+			written += chars;
+
+			memcpy_fromfs(pipebuf, buf, chars);
+
+			r_save_flags(flags);
+			r_cli();
+			RTF_LEN(minor) += chars;
+			r_restore_flags(flags);
+			buf += chars;
+		}
+		/*      RTF_LOCK(minor)--; */
+		free = 1;
+	}
+	inode->i_ctime = inode->i_mtime = CURRENT_TIME;
+	if (RTF_HANDLER(minor)) {
+		if ((result = (*RTF_HANDLER(minor)) (minor)) < 0) {
+			return result;
+		}
+	}
+	return written;
+}
+
+static int rtf_select(struct inode *inode, struct file *filp, int sel_type, select_table * wait)
+{
+	unsigned int minor = MINOR(inode->i_rdev);
+	switch (sel_type) {
+		case SEL_IN:
+			if (!RTF_EMPTY(minor))
+				return 1;
+			set_bit(1,&RTF_SLEEPS(minor));
+			select_wait(&RTF_WAIT(minor), wait);
+			return 0;
+		case SEL_OUT:
+			if (RTF_EMPTY(minor))
+				return 1;
+			set_bit(1, &RTF_SLEEPS(minor));
+			select_wait(&RTF_WAIT(minor), wait);
+			return 0;
+	}
+	return 0;
+}
+
+
+static struct file_operations rtf_fops =
+{
+	rtf_lseek,
+	rtf_read,
+	rtf_write,
+	NULL,
+	rtf_select,
+	NULL,
+	NULL,
+	rtf_open,
+	rtf_release
+};
+
+
+
+int rtf_init(void)
+{
+	int i;
+
+	if (register_chrdev(RTF_MAJOR, "rtf", &rtf_fops)) {
+		printk("RT-FIFO: unable to get major %d\n", RTF_MAJOR);
+		return -EIO;
+	}
+	for (i = 0; i < RTF_NO; i++) {
+		RTF_OPEN(i) = 0;
+	}
+
+	return 0;
+}
+
+
+#ifdef MODULE
+
+
+int init_module(void)
+{
+	return rtf_init();
+}
+
+
+void cleanup_module(void)
+{
+	unregister_chrdev(RTF_MAJOR, "rtf");
+}
+
+
+#endif				/* MODULE */
diff -r -N -u -X exclude linux/include/asm-i386/arithm.h rtlinux-2.0.33/include/asm-i386/arithm.h
--- linux/include/asm-i386/arithm.h	Wed Dec 31 17:00:00 1969
+++ rtlinux-2.0.33/include/asm-i386/arithm.h	Mon Feb 16 15:14:20 1998
@@ -0,0 +1,48 @@
+#ifndef __RT_ARITHM__
+#define __RT_ARITHM__
+
+/* asm/arithm.h
+*
+*  1995 Michael Barabanov
+*/
+
+
+#ifndef div_t
+typedef struct {
+	int quot;	/* Quotient.  */
+	int rem;	/* Remainder.  */
+} div_t;
+#endif
+
+
+
+/*  a * mult / div  */
+
+static inline div_t imuldivmod(int a, int mult, int div)
+{
+	register div_t res;
+	__asm__("imull %1 ; idivl %3"
+	:	"=a"(res.quot),
+		"=d"(res.rem)
+	:	"1"(mult),
+		"r"(div),
+		"0"(a)
+      	:	"dx");
+	return res;
+}
+
+/* a * mult / div */
+
+static inline int imuldiv(int a, int mult, int div)
+{
+	__asm__("imull %1 ; idivl %2"
+		:"=a" (a)
+		:"d" (mult),
+		 "r" (div),
+		 "0" (a)
+		:"dx");
+	return a;
+}
+
+
+#endif /* defined(__RT_ARITHM__) */
diff -r -N -u -X exclude linux/include/asm-i386/irq.h rtlinux-2.0.33/include/asm-i386/irq.h
--- linux/include/asm-i386/irq.h	Mon Aug 11 14:42:11 1997
+++ rtlinux-2.0.33/include/asm-i386/irq.h	Mon Feb 16 15:14:20 1998
@@ -7,6 +7,7 @@
  *	(C) 1992, 1993 Linus Torvalds
  *
  *	IRQ/IPI changes taken from work by Thomas Radke <tomsoft@informatik.tu-chemnitz.de>
+ *
  */
 
 #include <linux/linkage.h>
@@ -21,6 +22,55 @@
 
 #define __STR(x) #x
 #define STR(x) __STR(x)
+
+#ifdef __RT__
+
+#define SAVE_LEAST \
+	"push %ds\n\t \
+	push %es\n\t \
+	pushl %eax\n\t \
+	pushl %edx\n\t \
+	pushl %ecx\n\t \
+	movl $"  STR(KERNEL_DS) ",%edx\n\t \
+	mov %dx,%es\n\t \
+	mov %dx,%ds\n\t"
+
+#define RESTORE_LEAST \
+	"popl %ecx\n\t \
+	popl %edx\n\t \
+	popl %eax\n\t \
+	pop %es\n\t \
+	pop %ds\n\t"
+
+#define S_CLI \
+	"movl $0,"SYMBOL_NAME_STR(SFIF)"\n\t"
+
+#define S_IRET \
+	SAVE_LEAST \
+	"cli\n\t \
+	movl "SYMBOL_NAME_STR(SFREQ)",%edx\n\t \
+	andl "SYMBOL_NAME_STR(SFMASK)",%edx\n\t \
+	bsrl %edx,%eax\n\t \
+	jz 991f\n\t" \
+	S_CLI \
+	"sti\n\t \
+	jmp  "SYMBOL_NAME_STR(SFIDT)"(,%eax,4)\n\t \
+991:	movl $1,"SYMBOL_NAME_STR(SFIF)"\n\t \
+	sti\n\t" \
+	RESTORE_LEAST \
+	"iret\n\t"
+
+#define S_INT \
+	RESTORE_LEAST
+
+#define S_STI \
+	"sti\n\t\
+	pushfl\n\t \
+	pushl $" STR(KERNEL_CS) "\n\t \
+	pushl $992f\n\t" \
+	S_IRET \
+"992:\n\t"
+#endif /* __RT__ */
  
 #define SAVE_ALL \
 	"cld\n\t" \
@@ -68,6 +118,7 @@
 	"mov %dx,%ds\n\t" \
 	"mov %dx,%es\n\t"
 
+#ifndef __RT__
 #define RESTORE_MOST \
 	"popl %ecx\n\t" \
 	"popl %edx\n\t" \
@@ -75,6 +126,15 @@
 	"pop %ds\n\t" \
 	"pop %es\n\t" \
 	"iret"
+#else
+#define RESTORE_MOST \
+	"popl %ecx\n\t" \
+	"popl %edx\n\t" \
+	"popl %eax\n\t" \
+	"pop %ds\n\t" \
+	"pop %es\n\t" \
+	 S_IRET
+#endif
 
 /*
  * The "inb" instructions are not needed, but seem to change the timings
@@ -129,6 +189,9 @@
 #define FAST_IRQ_NAME(nr) IRQ_NAME2(fast_IRQ##nr)
 #define BAD_IRQ_NAME(nr) IRQ_NAME2(bad_IRQ##nr)
 
+#define LINUX_IRQ_NAME(nr) IRQ_NAME2(linux_IRQ##nr)
+#define RT_IRQ_NAME(nr) IRQ_NAME2(rt_IRQ##nr)
+
 #ifdef	__SMP__
 
 #ifndef __SMP_PROF__
@@ -358,6 +421,8 @@
 	"jmp ret_from_sys_call\n");
 #else
 	
+#ifndef __RT__
+
 #define BUILD_IRQ(chip,nr,mask) \
 asmlinkage void IRQ_NAME(nr); \
 asmlinkage void FAST_IRQ_NAME(nr); \
@@ -419,6 +484,150 @@
 	UNBLK_##chip(mask) \
 	"decl "SYMBOL_NAME_STR(intr_count)"\n\t" \
 	"jmp ret_from_sys_call\n");
+
+#else /* __RT__ */
+#define EOI_FIRST \
+	"movb $0x20,%al\n\t \
+	outb %al,$0x20\n\t" \
+
+#define EOI_SECOND \
+	"movb $0x20,%al\n\t \
+	outb %al,$0x20\n\t \
+	outb %al,$0xA0\n\t" \
+
+#define MASK(i) "(1 <<" #i ")"
+
+
+/* A SET bit in a SFMASK  ENABLES the corresponding interrupt (NOT as in 8259A) */
+#define DISABLE_IRQ(i) "andl $~" MASK(i) ","SYMBOL_NAME_STR(SFMASK)"\n\t"
+#define ENABLE_IRQ(i) "orl $" MASK(i) ","SYMBOL_NAME_STR(SFMASK)"\n\t"
+
+#define BUILD_IRQ(chip,nr,mask) \
+asmlinkage void LINUX_IRQ_NAME(nr); \
+asmlinkage void RT_IRQ_NAME(nr); \
+asmlinkage void IRQ_NAME(nr); \
+asmlinkage void FAST_IRQ_NAME(nr); \
+asmlinkage void BAD_IRQ_NAME(nr); \
+__asm__( \
+"\n"__ALIGN_STR"\n" \
+SYMBOL_NAME_STR(rt_IRQ) #nr "_interrupt:\n\t" \
+	SAVE_LEAST \
+	EOI_##chip \
+	"call *("SYMBOL_NAME_STR(RTaction)" + (" #nr " * 4))\n\t" \
+	RESTORE_LEAST \
+	"iret\n\t" \
+"\n"__ALIGN_STR"\n" \
+SYMBOL_NAME_STR(linux_IRQ) #nr "_interrupt:\n\t" \
+	SAVE_LEAST \
+	ACK_##chip(mask,(nr&7)) \
+	"orl $" MASK(nr) ","SYMBOL_NAME_STR(SFREQ)"\n\t" \
+	"cmpl $1,"SYMBOL_NAME_STR(SFIF)"\n\t" \
+	"je 1f\n\t" \
+	RESTORE_LEAST \
+	"iret\n\t" \
+"1:     sti\n\t" \
+	RESTORE_LEAST \
+	S_IRET \
+"\n"__ALIGN_STR"\n" \
+SYMBOL_NAME_STR(IRQ) #nr "_interrupt:\n\t" \
+	S_INT \
+	"pushl $-"#nr"-2\n\t" \
+	SAVE_ALL \
+	DISABLE_IRQ(nr) \
+	"andl $~ " MASK(nr) ","SYMBOL_NAME_STR(SFREQ)"\n\t" \
+	"incl "SYMBOL_NAME_STR(intr_count)"\n\t"\
+	S_STI \
+	"movl %esp,%ebx\n\t" \
+	"pushl %ebx\n\t" \
+	"pushl $" #nr "\n\t" \
+	"call "SYMBOL_NAME_STR(do_IRQ)"\n\t" \
+	"addl $8,%esp\n\t" \
+	S_CLI \
+	"cli\n\t" \
+	UNBLK_##chip(mask) \
+	ENABLE_IRQ(nr) \
+	"sti\n\t" \
+	"decl "SYMBOL_NAME_STR(intr_count)"\n\t" \
+	"jmp ret_from_sys_call\n" \
+"\n"__ALIGN_STR"\n" \
+SYMBOL_NAME_STR(fast_IRQ) #nr "_interrupt:\n\t" \
+	S_INT \
+	SAVE_MOST \
+	DISABLE_IRQ(nr) \
+	"andl $~ " MASK(nr) ","SYMBOL_NAME_STR(SFREQ)"\n\t" \
+	"incl "SYMBOL_NAME_STR(intr_count)"\n\t" \
+	"pushl $" #nr "\n\t" \
+	"call "SYMBOL_NAME_STR(do_fast_IRQ)"\n\t" \
+	"addl $4,%esp\n\t" \
+	S_CLI \
+	"cli\n\t" \
+	UNBLK_##chip(mask) \
+	ENABLE_IRQ(nr) \
+	"sti\n\t" \
+	"decl "SYMBOL_NAME_STR(intr_count)"\n\t" \
+	RESTORE_MOST \
+"\n"__ALIGN_STR"\n" \
+SYMBOL_NAME_STR(bad_IRQ) #nr "_interrupt:\n\t" \
+	S_INT \
+	SAVE_MOST \
+	DISABLE_IRQ(nr) \
+	"andl $~ " MASK(nr) ","SYMBOL_NAME_STR(SFREQ)"\n\t" \
+	RESTORE_MOST);
+
+
+#define BUILD_TIMER_IRQ(chip,nr,mask) \
+asmlinkage void RT_IRQ_NAME(nr); \
+asmlinkage void LINUX_IRQ_NAME(nr); \
+asmlinkage void IRQ_NAME(nr); \
+asmlinkage void FAST_IRQ_NAME(nr); \
+asmlinkage void BAD_IRQ_NAME(nr); \
+__asm__( \
+"\n"__ALIGN_STR"\n" \
+SYMBOL_NAME_STR(rt_IRQ) #nr "_interrupt:\n\t" \
+	SAVE_LEAST \
+	EOI_##chip \
+	"call *("SYMBOL_NAME_STR(RTaction)" + (" #nr " * 4))\n\t" \
+	"cmpl $1,"SYMBOL_NAME_STR(SFIF)"\n\t" \
+	"je 1f\n\t" \
+	RESTORE_LEAST \
+	"iret\n\t" \
+"1:	sti\n\t" \
+	RESTORE_LEAST \
+	S_IRET \
+"\n"__ALIGN_STR"\n" \
+SYMBOL_NAME_STR(linux_IRQ) #nr "_interrupt:\n\t" \
+	SAVE_LEAST \
+	ACK_##chip(mask,(nr&7)) \
+	"orl $" MASK(nr) ","SYMBOL_NAME_STR(SFREQ)"\n\t" \
+	"cmpl $1,"SYMBOL_NAME_STR(SFIF)"\n\t" \
+	"je 1f\n\t" \
+	RESTORE_LEAST \
+	"iret\n\t" \
+"1:     sti\n\t" \
+	RESTORE_LEAST \
+	S_IRET \
+"\n"__ALIGN_STR"\n" \
+SYMBOL_NAME_STR(fast_IRQ) #nr "_interrupt:\n\t" \
+SYMBOL_NAME_STR(bad_IRQ) #nr "_interrupt:\n\t" \
+SYMBOL_NAME_STR(IRQ) #nr "_interrupt:\n\t" \
+	S_INT \
+	"pushl $-"#nr"-2\n\t" \
+	SAVE_ALL \
+	DISABLE_IRQ(nr) \
+	"andl $~ " MASK(nr) ","SYMBOL_NAME_STR(SFREQ)"\n\t" \
+	"incl "SYMBOL_NAME_STR(intr_count)"\n\t"\
+	"movl %esp,%ebx\n\t" \
+	"pushl %ebx\n\t" \
+	"pushl $" #nr "\n\t" \
+	"call "SYMBOL_NAME_STR(do_IRQ)"\n\t" \
+	"addl $8,%esp\n\t" \
+	"cli\n\t" \
+	UNBLK_##chip(mask) \
+	ENABLE_IRQ(nr) \
+	"sti\n\t" \
+	"decl "SYMBOL_NAME_STR(intr_count)"\n\t" \
+	"jmp ret_from_sys_call\n");
+#endif /* __RT__ */
 
 #endif
 #endif
diff -r -N -u -X exclude linux/include/asm-i386/rt_irq.h rtlinux-2.0.33/include/asm-i386/rt_irq.h
--- linux/include/asm-i386/rt_irq.h	Wed Dec 31 17:00:00 1969
+++ rtlinux-2.0.33/include/asm-i386/rt_irq.h	Mon Feb 16 15:14:20 1998
@@ -0,0 +1,13 @@
+#ifndef __RTIRQ__
+#define __RTIRQ__
+
+extern int request_RTirq(unsigned int irq, void (*handler)(void) );
+extern void free_RTirq(unsigned int irq);
+
+extern unsigned long SFIF;
+extern unsigned long SFREQ;
+extern void s_cli(void);
+extern void s_sti(void);
+
+
+#endif
diff -r -N -u -X exclude linux/include/asm-i386/rt_time.h rtlinux-2.0.33/include/asm-i386/rt_time.h
--- linux/include/asm-i386/rt_time.h	Wed Dec 31 17:00:00 1969
+++ rtlinux-2.0.33/include/asm-i386/rt_time.h	Mon Feb 16 15:14:20 1998
@@ -0,0 +1,41 @@
+#ifndef __RT_TIME_H__
+#define __RT_TIME_H__
+
+/*
+ *  linux/include/asm/rt_time.h
+ *
+ *  1996, 1997  Michael Barabanov
+ *
+ *  low-level time-related routines
+ */
+
+#include <asm/arithm.h>
+
+#ifdef __KERNEL__
+#include <linux/time.h>
+extern int rt_latch2;
+#endif
+
+
+#define RT_TICKS_PER_SEC 1193180LL
+#define RT_TIME_END 0x7fffFfffFfffFfffLL
+
+
+typedef long long RTIME;
+
+extern RTIME rt_get_time(void);
+extern RTIME rt_linux_clock;
+
+extern int rt_request_timer(void (*fn)(void));
+extern void rt_free_timer(void);
+extern void rt_set_timer(RTIME when);
+extern void rt_no_timer(void);
+
+static inline RTIME rt_ts_to_rtime(struct timespec *res)
+{
+	return res->tv_sec * RT_TICKS_PER_SEC + imuldiv(res->tv_nsec, RT_TICKS_PER_SEC, 1000000000);
+}
+
+extern RTIME rt_get_prof_time(void);
+
+#endif
diff -r -N -u -X exclude linux/include/asm-i386/system.h rtlinux-2.0.33/include/asm-i386/system.h
--- linux/include/asm-i386/system.h	Mon Dec 15 19:37:28 1997
+++ rtlinux-2.0.33/include/asm-i386/system.h	Mon Feb 16 15:14:20 1998
@@ -221,6 +221,33 @@
 }
 
 #define mb()  __asm__ __volatile__ (""   : : :"memory")
+
+
+#ifdef __RT__
+
+#define r_sti() __asm__ __volatile__ ("sti": : :"memory")
+#define r_cli() __asm__ __volatile__ ("cli": : :"memory")
+
+#define r_save_flags(x) \
+__asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */ :"memory")
+
+#define r_restore_flags(x) \
+__asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory")
+
+extern void s_cli(void);
+extern void s_sti(void);
+
+#define cli() s_cli()
+#define sti() s_sti()
+
+extern unsigned long SFIF;
+
+#define save_flags(x) x=SFIF
+#define restore_flags(x) if (x) sti(); else cli()
+
+
+#else
+
 #define sti() __asm__ __volatile__ ("sti": : :"memory")
 #define cli() __asm__ __volatile__ ("cli": : :"memory")
 
@@ -231,6 +258,9 @@
 __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory")
 
 #define iret() __asm__ __volatile__ ("iret": : :"memory")
+
+#endif /* #ifdef __RT__ */
+
 
 #define _set_gate(gate_addr,type,dpl,addr) \
 __asm__ __volatile__ ("movw %%dx,%%ax\n\t" \
diff -r -N -u -X exclude linux/include/linux/autoconf.h rtlinux-2.0.33/include/linux/autoconf.h
--- linux/include/linux/autoconf.h	Wed Dec 31 17:00:00 1969
+++ rtlinux-2.0.33/include/linux/autoconf.h	Mon Feb 16 15:16:57 1998
@@ -0,0 +1,239 @@
+/*
+ * Automatically generated by make menuconfig: don't edit
+ */
+
+/*
+ * Code maturity level options
+ */
+#define CONFIG_EXPERIMENTAL 1
+
+/*
+ * Loadable module support
+ */
+#define CONFIG_MODULES 1
+#undef  CONFIG_MODVERSIONS
+#undef  CONFIG_KERNELD
+
+/*
+ * General setup
+ */
+#undef  CONFIG_MATH_EMULATION
+#define CONFIG_NET 1
+#undef  CONFIG_MAX_16M
+#define CONFIG_PCI 1
+#undef  CONFIG_PCI_OPTIMIZE
+#define CONFIG_SYSVIPC 1
+#define CONFIG_BINFMT_AOUT 1
+#define CONFIG_BINFMT_ELF 1
+#undef  CONFIG_BINFMT_JAVA
+#define CONFIG_KERNEL_ELF 1
+#define CONFIG_M586 1
+
+/*
+ * Floppy, IDE, and other block devices
+ */
+#undef  CONFIG_BLK_DEV_FD
+#define CONFIG_BLK_DEV_FD_MODULE 1
+#define CONFIG_BLK_DEV_IDE 1
+#undef  CONFIG_BLK_DEV_HD_IDE
+#define CONFIG_BLK_DEV_IDECD 1
+#undef  CONFIG_BLK_DEV_IDETAPE
+#undef  CONFIG_BLK_DEV_IDEFLOPPY
+#undef  CONFIG_BLK_DEV_IDESCSI
+#undef  CONFIG_BLK_DEV_IDE_PCMCIA
+#define CONFIG_BLK_DEV_CMD640 1
+#undef  CONFIG_BLK_DEV_CMD640_ENHANCED
+#define CONFIG_BLK_DEV_RZ1000 1
+#define CONFIG_BLK_DEV_TRITON 1
+#undef  CONFIG_IDE_CHIPSETS
+#undef  CONFIG_BLK_DEV_LOOP
+#undef  CONFIG_BLK_DEV_MD
+#undef  CONFIG_BLK_DEV_RAM
+#undef  CONFIG_BLK_DEV_XD
+#undef  CONFIG_BLK_DEV_HD
+
+/*
+ * Networking options
+ */
+#undef  CONFIG_FIREWALL
+#undef  CONFIG_NET_ALIAS
+#define CONFIG_INET 1
+#undef  CONFIG_IP_FORWARD
+#define CONFIG_IP_MULTICAST 1
+#undef  CONFIG_SYN_COOKIES
+#undef  CONFIG_RST_COOKIES
+#undef  CONFIG_IP_ACCT
+#undef  CONFIG_IP_ROUTER
+#undef  CONFIG_NET_IPIP
+#undef  CONFIG_IP_MROUTE
+#undef  CONFIG_INET_PCTCP
+#undef  CONFIG_INET_RARP
+#undef  CONFIG_NO_PATH_MTU_DISCOVERY
+#define CONFIG_IP_NOSR 1
+#define CONFIG_SKB_LARGE 1
+#undef  CONFIG_IPX
+#undef  CONFIG_ATALK
+#undef  CONFIG_AX25
+#undef  CONFIG_BRIDGE
+#undef  CONFIG_NETLINK
+
+/*
+ * SCSI support
+ */
+#define CONFIG_SCSI 1
+#define CONFIG_BLK_DEV_SD 1
+#undef  CONFIG_CHR_DEV_ST
+#undef  CONFIG_BLK_DEV_SR
+#undef  CONFIG_CHR_DEV_SG
+#define CONFIG_SCSI_MULTI_LUN 1
+#define CONFIG_SCSI_CONSTANTS 1
+
+/*
+ * SCSI low-level drivers
+ */
+#undef  CONFIG_SCSI_7000FASST
+#undef  CONFIG_SCSI_AHA152X
+#undef  CONFIG_SCSI_AHA1542
+#undef  CONFIG_SCSI_AHA1740
+#undef  CONFIG_SCSI_AIC7XXX
+#undef  CONFIG_SCSI_ADVANSYS
+#undef  CONFIG_SCSI_IN2000
+#undef  CONFIG_SCSI_AM53C974
+#undef  CONFIG_SCSI_BUSLOGIC
+#undef  CONFIG_SCSI_DTC3280
+#define CONFIG_SCSI_EATA_DMA 1
+#undef  CONFIG_SCSI_EATA_PIO
+#undef  CONFIG_SCSI_EATA
+#undef  CONFIG_SCSI_FUTURE_DOMAIN
+#undef  CONFIG_SCSI_GENERIC_NCR5380
+#undef  CONFIG_SCSI_NCR53C406A
+#undef  CONFIG_SCSI_NCR53C7xx
+#undef  CONFIG_SCSI_NCR53C8XX
+#undef  CONFIG_SCSI_PPA
+#undef  CONFIG_SCSI_PAS16
+#undef  CONFIG_SCSI_QLOGIC_FAS
+#undef  CONFIG_SCSI_QLOGIC_ISP
+#undef  CONFIG_SCSI_SEAGATE
+#undef  CONFIG_SCSI_DC390T
+#undef  CONFIG_SCSI_T128
+#undef  CONFIG_SCSI_U14_34F
+#undef  CONFIG_SCSI_ULTRASTOR
+#undef  CONFIG_SCSI_GDTH
+
+/*
+ * Network device support
+ */
+#define CONFIG_NETDEVICES 1
+#undef  CONFIG_DUMMY
+#define CONFIG_DUMMY_MODULE 1
+#undef  CONFIG_EQUALIZER
+#undef  CONFIG_DLCI
+#undef  CONFIG_PLIP
+#undef  CONFIG_PPP
+#undef  CONFIG_SLIP
+#undef  CONFIG_NET_RADIO
+#define CONFIG_NET_ETHERNET 1
+#undef  CONFIG_NET_VENDOR_3COM
+#define CONFIG_LANCE 1
+#undef  CONFIG_LANCE32
+#undef  CONFIG_NET_VENDOR_SMC
+#define CONFIG_NET_ISA 1
+#undef  CONFIG_AT1700
+#define CONFIG_AT1700_MODULE 1
+#undef  CONFIG_E2100
+#undef  CONFIG_DEPCA
+#undef  CONFIG_EWRK3
+#undef  CONFIG_EEXPRESS
+#undef  CONFIG_EEXPRESS_PRO
+#undef  CONFIG_FMV18X
+#undef  CONFIG_HPLAN_PLUS
+#undef  CONFIG_HPLAN
+#undef  CONFIG_HP100
+#undef  CONFIG_ETH16I
+#undef  CONFIG_NE2000
+#undef  CONFIG_NI52
+#undef  CONFIG_NI65
+#undef  CONFIG_SEEQ8005
+#undef  CONFIG_SK_G16
+#undef  CONFIG_NET_EISA
+#undef  CONFIG_NET_POCKET
+#undef  CONFIG_TR
+#undef  CONFIG_FDDI
+#undef  CONFIG_ARCNET
+
+/*
+ * ISDN subsystem
+ */
+#undef  CONFIG_ISDN
+
+/*
+ * CD-ROM drivers (not for SCSI or IDE/ATAPI drives)
+ */
+#define CONFIG_CD_NO_IDESCSI 1
+#undef  CONFIG_AZTCD
+#undef  CONFIG_GSCD
+#undef  CONFIG_SBPCD
+#undef  CONFIG_MCD
+#undef  CONFIG_MCDX
+#undef  CONFIG_OPTCD
+#undef  CONFIG_CM206
+#undef  CONFIG_SJCD
+#undef  CONFIG_CDI_INIT
+#undef  CONFIG_CDU31A
+#undef  CONFIG_CDU535
+
+/*
+ * Filesystems
+ */
+#undef  CONFIG_QUOTA
+#undef  CONFIG_MINIX_FS
+#undef  CONFIG_EXT_FS
+#define CONFIG_EXT2_FS 1
+#undef  CONFIG_XIA_FS
+#define CONFIG_FAT_FS 1
+#define CONFIG_MSDOS_FS 1
+#undef  CONFIG_VFAT_FS
+#undef  CONFIG_UMSDOS_FS
+#define CONFIG_PROC_FS 1
+#define CONFIG_NFS_FS 1
+#undef  CONFIG_ROOT_NFS
+#undef  CONFIG_SMB_FS
+#undef  CONFIG_ISO9660_FS
+#undef  CONFIG_HPFS_FS
+#undef  CONFIG_SYSV_FS
+#undef  CONFIG_AUTOFS_FS
+#undef  CONFIG_AFFS_FS
+#undef  CONFIG_UFS_FS
+
+/*
+ * Character devices
+ */
+#define CONFIG_SERIAL 1
+#undef  CONFIG_DIGI
+#undef  CONFIG_CYCLADES
+#undef  CONFIG_STALDRV
+#undef  CONFIG_RISCOM8
+#undef  CONFIG_PRINTER
+#undef  CONFIG_SPECIALIX
+#define CONFIG_MOUSE 1
+#undef  CONFIG_ATIXL_BUSMOUSE
+#undef  CONFIG_BUSMOUSE
+#undef  CONFIG_MS_BUSMOUSE
+#define CONFIG_PSMOUSE 1
+#define CONFIG_82C710_MOUSE 1
+#undef  CONFIG_UMISC
+#undef  CONFIG_QIC02_TAPE
+#undef  CONFIG_FTAPE
+#undef  CONFIG_APM
+#undef  CONFIG_WATCHDOG
+#undef  CONFIG_RTC
+
+/*
+ * Sound
+ */
+#undef  CONFIG_SOUND
+
+/*
+ * Kernel hacking
+ */
+#undef  CONFIG_PROFILE
diff -r -N -u -X exclude linux/include/linux/cons.h rtlinux-2.0.33/include/linux/cons.h
--- linux/include/linux/cons.h	Wed Dec 31 17:00:00 1969
+++ rtlinux-2.0.33/include/linux/cons.h	Mon Feb 16 15:14:20 1998
@@ -0,0 +1,60 @@
+/*
+ * debugging routines for RT-Linux
+ */
+
+#include <asm/system.h>
+
+extern void console_print(const char * b);
+extern int sprintf(char * buf, const char * fmt, ...);
+
+
+#define conpr(s) \
+{ \
+    console_print(s); \
+}
+
+
+static inline void conprn(unsigned int n)
+{
+	int i;
+	int d;
+    	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);
+}
+
+#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++); 
+}
+
diff -r -N -u -X exclude linux/include/linux/major.h rtlinux-2.0.33/include/linux/major.h
--- linux/include/linux/major.h	Tue Aug 12 14:57:23 1997
+++ rtlinux-2.0.33/include/linux/major.h	Mon Feb 16 15:14:20 1998
@@ -72,6 +72,10 @@
 #define SPECIALIX_NORMAL_MAJOR 75
 #define SPECIALIX_CALLOUT_MAJOR 76
 
+#ifdef __RT__
+#define RTF_MAJOR       63   /* RT-FIFOs */
+#endif
+
 /*
  * Tests for SCSI devices.
  */
diff -r -N -u -X exclude linux/include/linux/rt_fifo.h rtlinux-2.0.33/include/linux/rt_fifo.h
--- linux/include/linux/rt_fifo.h	Wed Dec 31 17:00:00 1969
+++ rtlinux-2.0.33/include/linux/rt_fifo.h	Mon Feb 16 15:14:20 1998
@@ -0,0 +1,12 @@
+#ifndef __RTFIFO
+#define __RTFIFO
+
+#define RT_MAX_FIFO 20
+
+
+extern int rt_fifo_put(unsigned int f, char * buf, int count);
+
+extern int rt_fifo_get(unsigned int f, char * buf, int count);
+
+
+#endif
diff -r -N -u -X exclude linux/include/linux/rt_sched.h rtlinux-2.0.33/include/linux/rt_sched.h
--- linux/include/linux/rt_sched.h	Wed Dec 31 17:00:00 1969
+++ rtlinux-2.0.33/include/linux/rt_sched.h	Mon Feb 16 15:14:20 1998
@@ -0,0 +1,43 @@
+#ifndef __RT__SCHED__
+#define __RT__SCHED__
+
+#include <asm/rt_time.h>
+#define RT_TASK_MAGIC 0x754d2774
+
+#define RT_LOWEST_PRIORITY 1000000
+
+enum {RT_TASK_READY, RT_TASK_DELAYED, RT_TASK_DORMANT};
+
+struct rt_task_struct {
+	int *stack; 	/* hardcoded */
+	int uses_fp;	/* this one is too   */
+	int magic;
+	int state;
+	int *stack_bottom;
+	int priority;
+	RTIME period;
+	RTIME resume_time;
+	struct rt_task_struct *next;
+};
+
+typedef struct rt_task_struct RT_TASK;
+
+extern RT_TASK *rt_current;
+
+extern int rt_task_init(RT_TASK *task, void (*fn)(int data), int data, int stack_size,  int priority);
+
+extern int rt_task_delete(RT_TASK *task);
+extern int rt_task_wait(void);
+
+extern int rt_task_suspend(RT_TASK *task);
+extern int rt_task_wakeup(RT_TASK *task);
+
+extern int rt_task_make_periodic(RT_TASK *task, RTIME start_time, RTIME period);
+
+extern inline void rt_use_fp(int flag)
+{
+	rt_current->uses_fp = flag;
+}
+
+
+#endif
diff -r -N -u -X exclude linux/include/linux/rt_time.h rtlinux-2.0.33/include/linux/rt_time.h
--- linux/include/linux/rt_time.h	Wed Dec 31 17:00:00 1969
+++ rtlinux-2.0.33/include/linux/rt_time.h	Mon Feb 16 15:14:20 1998
@@ -0,0 +1,6 @@
+#ifndef __RT_LINUX_TIME_H__
+#define __RT_LINUX_TIME_H__
+
+#include <asm/rt_time.h>
+
+#endif
diff -r -N -u -X exclude linux/include/linux/rtf.h rtlinux-2.0.33/include/linux/rtf.h
--- linux/include/linux/rtf.h	Wed Dec 31 17:00:00 1969
+++ rtlinux-2.0.33/include/linux/rtf.h	Mon Feb 16 15:14:20 1998
@@ -0,0 +1,81 @@
+#ifndef __RTF__
+#define __RTF__
+
+#ifdef __KERNEL__
+
+
+extern int rtf_init(void);
+
+
+
+/* attach a handler to an RT-FIFO
+ *
+ * Allow function \arg{handler} to be called when a user process reads or
+ * writes to the FIFO. When the function is called, it is passed the fifo
+ * number as the argument.
+ */
+
+extern int rtf_create_handler(unsigned int fifo,	/* RT-FIFO */
+		int (*handler)(unsigned int fifo)	/* function to be called */);
+
+
+
+/* create an RT-FIFO
+ * 
+ * An RT-FIFO \arg{fifo} is created with initial size of \arg{size}.
+ * 
+ * Return value: On success,  \arg{size} is returned. On error, -1 is returned.
+ */
+
+extern int rtf_create(unsigned int fifo, int size);
+
+
+
+/* destroy an RT-FIFO
+ * 
+ * Return value: On success, 0 is returned
+ */
+
+extern int rtf_destroy(unsigned int fifo);
+
+
+
+/* resize an RT-FIFO
+ * 
+ * Return value: \arg{size} is returned on success. On error, a negative value
+ * is returned
+ * 
+ * Bugs: This operation destroys the contents of the FIFO
+ */
+
+extern int rtf_resize(unsigned int minor, int size);
+
+
+
+/*
+ * write to an RT-FIFO
+ *
+ * Try to write \arg{count} bytes to an FIFO.  Return -1 if there's not enough space
+ * in the FIFO; otherwise return \arg{count}
+ */
+
+extern int rtf_put(unsigned int fifo,	/* RT-FIFO */
+		void * buf,		/* buffer address */
+	       	int count		/* number of bytes to write */);
+
+
+
+/*
+ * read from an RT-FIFO
+ *
+ * Try to read \arg{count} bytes from a FIFO.
+ * Return -1 if there's not enough data in the FIFO; 
+ * otherwise return \arg{count}
+ */
+extern int rtf_get(unsigned int fifo,	/* RT-FIFO */
+		void * buf, 		/* buffer address */
+		int count		/* number of bytes to read */);
+
+#endif
+
+#endif
diff -r -N -u -X exclude linux/include/linux/tqueue.h rtlinux-2.0.33/include/linux/tqueue.h
--- linux/include/linux/tqueue.h	Fri Mar 28 17:08:16 1997
+++ rtlinux-2.0.33/include/linux/tqueue.h	Mon Feb 16 15:14:20 1998
@@ -52,6 +52,10 @@
 
 extern task_queue tq_timer, tq_immediate, tq_scheduler, tq_disk;
 
+#ifdef __RT__
+extern task_queue tq_rt;
+#endif
+
 /*
  * To implement your own list of active bottom halfs, use the following
  * two definitions:
@@ -118,6 +122,28 @@
 		restore_flags(flags);
 	}
 }
+
+#ifdef __RT__
+/*
+ * queue_task_rt: as queue_task, but can be called from RT-processes (and from
+ * anywhere else). Note: you shouldn't mix calls to queue_task and
+ * queue_task_rt on the same queue.
+ *
+ * tq_rt task queue is typically used with this function
+ */
+extern __inline__ void queue_task_rt(struct tq_struct *bh_pointer,
+			   task_queue *bh_list)
+{
+	if (!set_bit(0,&bh_pointer->sync)) {
+		unsigned long flags;
+		r_save_flags(flags);
+		r_cli();
+		bh_pointer->next = *bh_list;
+		*bh_list = bh_pointer;
+		r_restore_flags(flags);
+	}
+}
+#endif
 
 /*
  * Call all "bottom halfs" on a given list.
diff -r -N -u -X exclude linux/include/linux/version.h rtlinux-2.0.33/include/linux/version.h
--- linux/include/linux/version.h	Wed Dec 31 17:00:00 1969
+++ rtlinux-2.0.33/include/linux/version.h	Mon Feb 16 15:15:02 1998
@@ -0,0 +1,2 @@
+#define UTS_RELEASE "2.0.33"
+#define LINUX_VERSION_CODE 131105
diff -r -N -u -X exclude linux/init/main.c rtlinux-2.0.33/init/main.c
--- linux/init/main.c	Thu Aug 14 11:30:08 1997
+++ rtlinux-2.0.33/init/main.c	Mon Feb 16 15:14:20 1998
@@ -10,6 +10,7 @@
 
 #define __KERNEL_SYSCALLS__
 #include <stdarg.h>
+#include <linux/cons.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
@@ -194,6 +195,11 @@
 
 extern void time_init(void);
 
+#ifdef __RT__
+extern void rt_fifo_init(void);
+extern void rt_time_init(void);
+#endif
+
 static unsigned long memory_start = 0;
 static unsigned long memory_end = 0;
 
@@ -527,6 +533,8 @@
 			break;
 		}
 
+    /* conpr("  1st half calibr  "); */
+
 /* Do a binary approximation to get loops_per_second set to equal one clock
    (up to lps_precision bits) */
 	loops_per_sec >>= 1;
@@ -541,6 +549,7 @@
 			loops_per_sec &= ~loopbit;
 	}
 
+    /* conpr("   calibrated!    "); */
 /* finally, adjust loops per second in terms of seconds instead of clocks */	
 	loops_per_sec *= HZ;
 /* Round the value and print it */	
@@ -840,8 +849,13 @@
 	memory_start = pci_init(memory_start,memory_end);
 #endif
 	memory_start = kmalloc_init(memory_start,memory_end);
+#ifdef __RT__
+	rt_time_init();
+	rt_fifo_init();
+#endif
 	sti();
 	calibrate_delay();
+    /* conpr(" exit calibr  "); */
 	memory_start = inode_init(memory_start,memory_end);
 	memory_start = file_table_init(memory_start,memory_end);
 	memory_start = name_cache_init(memory_start,memory_end);
diff -r -N -u -X exclude linux/kernel/Makefile rtlinux-2.0.33/kernel/Makefile
--- linux/kernel/Makefile	Wed Jan 10 00:27:39 1996
+++ rtlinux-2.0.33/kernel/Makefile	Mon Feb 16 15:14:20 1998
@@ -15,6 +15,10 @@
 	module.o exit.o signal.o itimer.o info.o time.o softirq.o \
 	resource.o sysctl.o
 
+ifdef RT
+M_OBJS = rt_prio_sched.o
+endif
+
 ifeq ($(CONFIG_MODULES),y)
 OX_OBJS = ksyms.o
 endif
diff -r -N -u -X exclude linux/kernel/ksyms.c rtlinux-2.0.33/kernel/ksyms.c
--- linux/kernel/ksyms.c	Mon Nov 10 11:50:56 1997
+++ rtlinux-2.0.33/kernel/ksyms.c	Mon Feb 16 15:14:20 1998
@@ -65,6 +65,12 @@
 #include <linux/smp.h>
 #endif
 
+#ifdef __RT__
+#include <asm/rt_time.h>
+#include <asm/rt_irq.h>
+#include <linux/rt_fifo.h>
+#endif
+
 extern char *get_options(char *str, int *ints);
 extern void set_device_ro(kdev_t dev,int flag);
 extern struct file_operations * get_blkfops(unsigned int);
@@ -103,6 +109,27 @@
 #ifndef wp_works_ok__is_a_macro
 	X(wp_works_ok),
 #endif
+
+
+#ifdef __RT__
+	X(rt_get_time),
+	X(rt_request_timer),
+	X(rt_free_timer),
+	X(rt_set_timer),
+	X(rt_no_timer),
+
+	X(SFIF),
+	X(s_cli),
+	X(s_sti),
+	X(request_RTirq),
+	X(free_RTirq),
+
+	X(rt_fifo_get),
+	X(rt_fifo_put),
+
+	X(tq_rt),
+#endif /* __RT__ */
+
 
 #ifdef CONFIG_PCI
 	/* PCI BIOS support */
diff -r -N -u -X exclude linux/kernel/rt_prio_sched.c rtlinux-2.0.33/kernel/rt_prio_sched.c
--- linux/kernel/rt_prio_sched.c	Wed Dec 31 17:00:00 1969
+++ rtlinux-2.0.33/kernel/rt_prio_sched.c	Mon Feb 16 15:14:20 1998
@@ -0,0 +1,285 @@
+/* a primitive real-time scheduler */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/version.h>
+#include <linux/errno.h>
+#include <linux/malloc.h>
+
+#include <asm/system.h>
+#include <asm/rt_time.h>
+#include <asm/rt_irq.h>
+
+#include <linux/kernel.h>
+#include <linux/cons.h>
+
+#include <linux/rt_sched.h>
+
+#include <asm/segment.h>
+
+#define __STR(x) #x
+#define STR(x) __STR(x)
+
+#define rt_switch_to(tsk) \
+	__asm__ __volatile__( \
+	"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" \
+	"movl "SYMBOL_NAME_STR(rt_current)", %%edx\n\t" \
+	"cmpl $0, 4(%%edx)\n\t" \
+	"jz 25f\n\t" \
+	"sub $108,%%esp\n\t" \
+	"fsave (%%esp)\n\t" \
+"25:	pushl $1f\n\t" \
+	"movl %%esp, (%%edx)\n\t" \
+	"movl (%%ecx), %%esp\n\t" \
+	"movl %%ecx, "SYMBOL_NAME_STR(rt_current)"\n\t" \
+	"ret\n\t" \
+"1:	cmpl $0, 4(%%ecx)\n\t" \
+	"jz 26f\n\t" \
+	"frstor (%%esp)\n\t" \
+	"add $108,%%esp \n\t" \
+"26:	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" \
+	: /* no output */ \
+	: "c" (tsk) \
+	:"cx");
+
+
+
+/* RT_TASK *run_queue; */
+RT_TASK *rt_tasks;
+
+RT_TASK *rt_current;
+
+RT_TASK rt_linux_task;
+static int linux_irq_state;
+
+
+int rt_startup(void (*fn)(int), int data)
+{
+	r_sti();
+	(*fn)(data);
+	rt_task_delete(rt_current);
+	
+	/* should never reach this line */
+	return 0;
+}
+	
+
+int rt_task_init(RT_TASK *task, void (*fn)(int), int data, int stack_size, 
+			int priority) 
+{
+	int *st;
+	long flags;
+
+	if (task->magic == RT_TASK_MAGIC) {
+		return -EINVAL;
+	}
+
+	st = (int *) kmalloc(stack_size, GFP_KERNEL);	
+	if (!st) {
+		return -ENOMEM;
+	}
+
+	task->priority = priority; 
+	task->magic = RT_TASK_MAGIC; 
+	task->state = RT_TASK_DORMANT; 
+	task->stack_bottom = st;
+	task->stack = st + stack_size / sizeof(int);
+	task->uses_fp = 0;
+
+	*--(task->stack) = data;
+	*--(task->stack) = (int) fn;
+	*--(task->stack) = 0;	/* dummy return address from rt_startup --- Thanks, Victor! */
+	*--(task->stack) = (int) rt_startup;
+
+	r_save_flags(flags);
+	r_cli();
+	task->next = rt_tasks;
+	rt_tasks = task;
+	r_restore_flags(flags);
+	return 0;
+}
+
+
+void rt_schedule(void)
+{
+	RTIME now;
+	RTIME preemption_time;
+	RT_TASK *task;
+	RT_TASK *new_task;
+	RT_TASK *preemptor;
+	int prio;
+	int flags;
+
+	r_save_flags(flags);
+	r_cli();
+	now = rt_get_time();
+	for (task = rt_tasks; task; task = task->next) {
+		if (task->state == RT_TASK_DELAYED && 
+					task->resume_time < now + 10) {
+			task->state = RT_TASK_READY;
+
+		}
+	}
+	new_task = &rt_linux_task;
+	prio = rt_linux_task.priority;
+	for (task = rt_tasks; task; task = task->next) {
+		if (task->state == RT_TASK_READY && task->priority < prio) {
+			new_task = task;
+			prio = task->priority;
+		}
+	}
+ 	preemptor = 0;
+	preemption_time = RT_TIME_END;
+	for (task = rt_tasks; task; task = task->next) {
+		if (task->state == RT_TASK_DELAYED && task->priority < prio &&
+				task->resume_time < preemption_time) {
+			preemption_time = task->resume_time;
+			preemptor = task;
+		}
+	}
+	
+	if (preemptor) {
+		rt_set_timer(preemption_time);
+	} else {
+		rt_no_timer();
+	}
+
+	if (new_task == rt_current) {
+		r_restore_flags(flags);
+		return;
+	}
+
+	if (new_task == &rt_linux_task) {
+		SFIF = linux_irq_state;
+	} else if (rt_current == &rt_linux_task) {
+		linux_irq_state = SFIF;
+		SFIF = 0;
+	}
+
+
+	new_task->state = RT_TASK_READY;
+	rt_switch_to(new_task);
+	r_restore_flags(flags);
+}
+
+int rt_task_delete(RT_TASK *task)
+{
+	RT_TASK *t;
+	int found = 0;
+	long flags;
+
+	r_save_flags(flags);
+	r_cli();
+
+	if (task->magic != RT_TASK_MAGIC) {
+		r_restore_flags(flags);
+		return -EINVAL;
+	}
+
+	if (task != rt_tasks) {
+		for (t = rt_tasks; t; t = t->next) {
+			if (t->next == task) {
+				t->next = task->next;
+				found = 1;
+				break;
+			}
+		}
+		if (!found) {
+			r_restore_flags(flags);
+			return -EINVAL;
+		}
+	} else {
+		rt_tasks = task->next;
+	}
+	task->magic = 0;
+	r_restore_flags(flags);
+
+	kfree(task->stack_bottom);
+
+	rt_schedule();
+	return 0;
+}
+
+
+int rt_task_suspend(RT_TASK *task)
+{
+	task->state = RT_TASK_DORMANT;
+	rt_schedule();
+	return 0;
+}
+
+
+int rt_task_wakeup(RT_TASK *task)
+{
+	task->state = RT_TASK_READY;
+	rt_schedule();
+	return 0;
+}
+
+
+int rt_task_wait(void)
+{
+	long flags;
+	r_save_flags(flags);
+	r_cli();
+	rt_current->state = RT_TASK_DELAYED;
+	rt_current->resume_time += rt_current->period;
+	rt_schedule();
+	r_restore_flags(flags);
+	return 0;
+}
+
+
+int rt_task_make_periodic(RT_TASK *task, RTIME start_time, RTIME period)
+{
+	long flags;
+	if (task->magic != RT_TASK_MAGIC) {
+		return -EINVAL;
+	}
+	r_save_flags(flags);
+	r_cli();
+	task->resume_time = start_time;
+	task->period = period;
+	task->state = RT_TASK_DELAYED;
+	r_restore_flags(flags);
+	rt_schedule();
+	return 0;
+}
+
+
+int init_module(void)
+{
+	rt_tasks = &rt_linux_task;
+	rt_current = &rt_linux_task;
+	rt_linux_task.priority = RT_LOWEST_PRIORITY;
+	rt_linux_task.next = 0;
+	rt_linux_task.state = RT_TASK_READY;
+	rt_request_timer(&rt_schedule);
+	return 0;
+}
+
+
+void cleanup_module(void)
+{
+	RT_TASK *t;
+	RT_TASK *next_t;
+	rt_free_timer();
+	for (t = rt_tasks; t; t = next_t) {
+		next_t = t->next;
+		if (t != &rt_linux_task) {
+			rt_task_delete(t);
+		}
+	}
+}
diff -r -N -u -X exclude linux/kernel/sched.c rtlinux-2.0.33/kernel/sched.c
--- linux/kernel/sched.c	Fri Nov  7 11:06:21 1997
+++ rtlinux-2.0.33/kernel/sched.c	Mon Feb 16 15:14:21 1998
@@ -56,6 +56,16 @@
 DECLARE_TASK_QUEUE(tq_immediate);
 DECLARE_TASK_QUEUE(tq_scheduler);
 
+
+/*
+ * Runs together with tq_scheduler
+ */ 
+
+#ifdef __RT__
+DECLARE_TASK_QUEUE(tq_rt);
+#endif
+
+
 /*
  * phase-lock loop variables
  */
@@ -402,6 +412,10 @@
 	}
 
 	run_task_queue(&tq_scheduler);
+
+#ifdef __RT__
+	run_task_queue(&tq_rt);
+#endif
 
 	need_resched = 0;
 	prev = current;
