diff -Naur linux-2.6.24.7/arch/x86/Kconfig linux-2.6.24.7_NO_APIC/arch/x86/Kconfig
--- linux-2.6.24.7/arch/x86/Kconfig	2008-05-07 00:22:34.000000000 +0100
+++ linux-2.6.24.7_NO_APIC/arch/x86/Kconfig	2008-11-15 18:54:52.000000000 +0000
@@ -163,6 +163,10 @@
 	depends on X86_SMP || (X86_VOYAGER && SMP)
 	default y
 
+config RTLINUX
+	bool
+	default y
+
 config KTIME_SCALAR
 	def_bool X86_32
 source "init/Kconfig"
diff -Naur linux-2.6.24.7/arch/x86/kernel/entry_32.S linux-2.6.24.7_NO_APIC/arch/x86/kernel/entry_32.S
--- linux-2.6.24.7/arch/x86/kernel/entry_32.S	2008-05-07 00:22:34.000000000 +0100
+++ linux-2.6.24.7_NO_APIC/arch/x86/kernel/entry_32.S	2009-01-17 19:30:18.000000000 +0000
@@ -51,6 +51,7 @@
 #include <asm/desc.h>
 #include <asm/percpu.h>
 #include <asm/dwarf2.h>
+#include <asm/rtlinux.h>
 #include "irq_vectors.h"
 
 /*
@@ -66,6 +67,13 @@
  * enough to patch inline, increasing performance.
  */
 
+#define RTLINUX_IRET   \
+       movl  rtl_emulate_iret,%eax; \
+       testl %eax, %eax; \
+       je  1f; \
+       call  *%eax;    \
+       1:
+
 #define nr_syscalls ((syscall_table_size)/4)
 
 CF_MASK		= 0x00000001
@@ -241,6 +249,7 @@
 	RING0_PTREGS_FRAME
 ret_from_exception:
 	preempt_stop(CLBR_ANY)
+ENTRY(ret_from_intr)
 ret_from_intr:
 	GET_THREAD_INFO(%ebp)
 check_userspace:
@@ -252,9 +261,9 @@
 
 ENTRY(resume_userspace)
 	LOCKDEP_SYS_EXIT
- 	DISABLE_INTERRUPTS(CLBR_ANY)	# make sure we don't miss an interrupt
-					# setting need_resched or sigpending
-					# between sampling and the iret
+
+        call *(irq_control+8) # cli from irq_control structure
+
 	movl TI_flags(%ebp), %ecx
 	andl $_TIF_WORK_MASK, %ecx	# is there any work to be done on
 					# int/exception return?
@@ -294,7 +303,7 @@
 	 * No need to follow this irqs on/off section: the syscall
 	 * disabled irqs and here we enable it straight after entry:
 	 */
-	ENABLE_INTERRUPTS(CLBR_NONE)
+        call *(irq_control+12) # cli from irq_control structure
 	pushl $(__USER_DS)
 	CFI_ADJUST_CFA_OFFSET 4
 	/*CFI_REL_OFFSET ss, 0*/
@@ -332,15 +341,18 @@
 	SAVE_ALL
 	GET_THREAD_INFO(%ebp)
 
+        call *(irq_control+12) # cli from irq_control structure
+
 	/* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */
 	testw $(_TIF_SYSCALL_EMU|_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
 	jnz syscall_trace_entry
 	cmpl $(nr_syscalls), %eax
 	jae syscall_badsys
 	call *sys_call_table(,%eax,4)
+
 	movl %eax,PT_EAX(%esp)
 	LOCKDEP_SYS_EXIT
-	DISABLE_INTERRUPTS(CLBR_ANY)
+        call *(irq_control+8) # cli from irq_control structure
 	TRACE_IRQS_OFF
 	movl TI_flags(%ebp), %ecx
 	testw $_TIF_ALLWORK_MASK, %cx
@@ -351,7 +363,8 @@
 	xorl %ebp,%ebp
 	TRACE_IRQS_ON
 1:	mov  PT_FS(%esp), %fs
-	ENABLE_INTERRUPTS_SYSEXIT
+        call *(irq_control+12) # cli from irq_control structure
+	sysexit
 	CFI_ENDPROC
 .pushsection .fixup,"ax"
 2:	movl $0,PT_FS(%esp)
@@ -380,9 +393,7 @@
 	movl %eax,PT_EAX(%esp)		# store the return value
 syscall_exit:
 	LOCKDEP_SYS_EXIT
-	DISABLE_INTERRUPTS(CLBR_ANY)	# make sure we don't miss an interrupt
-					# setting need_resched or sigpending
-					# between sampling and the iret
+        call *(irq_control+8) # cli from irq_control structure
 	TRACE_IRQS_OFF
 	testl $TF_MASK,PT_EFLAGS(%esp)	# If tracing set singlestep flag on exit
 	jz no_singlestep
@@ -406,6 +417,7 @@
 restore_nocheck:
 	TRACE_IRQS_IRET
 restore_nocheck_notrace:
+	RTLINUX_IRET
 	RESTORE_REGS
 	addl $4, %esp			# skip orig_eax/error_code
 	CFI_ADJUST_CFA_OFFSET -4
@@ -454,7 +466,7 @@
 	CFI_ADJUST_CFA_OFFSET 4
 	pushl %eax
 	CFI_ADJUST_CFA_OFFSET 4
-	DISABLE_INTERRUPTS(CLBR_EAX)
+        call *(irq_control+8) # cli from irq_control structure
 	TRACE_IRQS_OFF
 	lss (%esp), %esp
 	CFI_ADJUST_CFA_OFFSET -8
@@ -471,9 +483,7 @@
 work_resched:
 	call schedule
 	LOCKDEP_SYS_EXIT
-	DISABLE_INTERRUPTS(CLBR_ANY)	# make sure we don't miss an interrupt
-					# setting need_resched or sigpending
-					# between sampling and the iret
+        call *(irq_control+8) # cli from irq_control structure
 	TRACE_IRQS_OFF
 	movl TI_flags(%ebp), %ecx
 	andl $_TIF_WORK_MASK, %ecx	# is there any work to be done other
@@ -531,8 +541,7 @@
 	testb $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP), %cl
 	jz work_pending
 	TRACE_IRQS_ON
-	ENABLE_INTERRUPTS(CLBR_ANY)	# could let do_syscall_trace() call
-					# schedule() instead
+        call *(irq_control+12) # cli from irq_control structure
 	movl %esp, %eax
 	movl $1, %edx
 	call do_syscall_trace
@@ -618,8 +627,13 @@
 	SAVE_ALL
 	TRACE_IRQS_OFF
 	movl %esp,%eax
-	call do_IRQ
-	jmp ret_from_intr
+	pushl $ret_from_intr
+.section rtlinux_patch, "a"
+.align 4
+.long 1f, do_IRQ
+.previous
+1:
+	jmp do_IRQ
 ENDPROC(common_interrupt)
 	CFI_ENDPROC
 
@@ -630,11 +644,17 @@
 	CFI_ADJUST_CFA_OFFSET 4;	\
 	SAVE_ALL;			\
 	TRACE_IRQS_OFF			\
-	movl %esp,%eax;			\
+	movl %esp,%eax;\
+.section rtlinux_patch, "a";	\
+.align 4; \
+.long 1f, smp_##name; \
+.previous; \
+1:; \
 	call smp_##name;		\
 	jmp ret_from_intr;		\
 	CFI_ENDPROC;			\
-ENDPROC(name)
+END(name)
+
 
 /* The include is where all of the SMP etc. interrupts come from */
 #include "entry_arch.h"
@@ -980,6 +1000,14 @@
 	CFI_ENDPROC
 END(alignment_check)
 
+#define RTL_PUSH_VECTOR(vector,routine) \
+1:     cmpl $routine, %edi; \
+       jne 1f; \
+       pushl $vector; \
+       jmp 7f;
+
+
+
 ENTRY(divide_error)
 	RING0_INT_FRAME
 	pushl $0			# no error code
diff -Naur linux-2.6.24.7/arch/x86/kernel/i386_ksyms_32.c linux-2.6.24.7_NO_APIC/arch/x86/kernel/i386_ksyms_32.c
--- linux-2.6.24.7/arch/x86/kernel/i386_ksyms_32.c	2008-05-07 00:22:34.000000000 +0100
+++ linux-2.6.24.7_NO_APIC/arch/x86/kernel/i386_ksyms_32.c	2009-01-17 19:31:06.000000000 +0000
@@ -31,3 +31,44 @@
 
 EXPORT_SYMBOL(csum_partial);
 EXPORT_SYMBOL(empty_zero_page);
+
+#ifdef CONFIG_RTLINUX
+#include <asm/mpspec.h>
+#ifdef CONFIG_X86_IO_APIC
+EXPORT_SYMBOL(smp_found_config);
+#endif
+
+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);
+EXPORT_SYMBOL(xtime_lock);
+extern unsigned char *rtl_cached21;
+extern void (*rtl_syscall_intercept)(struct pt_regs regs);
+EXPORT_SYMBOL(rtl_syscall_intercept);
+#ifdef CONFIG_SMP_RTLINUX
+extern int rtl_reserved_cpumask;
+EXPORT_SYMBOL(rtl_reserved_cpumask);
+extern unsigned long irq_affinity [NR_IRQS];
+EXPORT_SYMBOL(irq_affinity);
+EXPORT_SYMBOL(physical_apicid_2_cpu);
+extern unsigned long flush_cpumask;
+EXPORT_SYMBOL(flush_cpumask);
+EXPORT_SYMBOL(cpu_tlbstate);
+#endif /* CONFIG_SMP */
+/* ULLI Watch out! */
+
+extern struct console *console_drivers;
+
+EXPORT_SYMBOL(console_drivers);
+extern void do_softirq(void);
+EXPORT_SYMBOL(do_softirq); 
+#endif /* CONFIG_RTLINUX */
+
+extern void early_printk(const char *fmt, ...) __attribute__((format(printf,1,2)));
+EXPORT_SYMBOL(early_printk);
+
+
+
+
diff -Naur linux-2.6.24.7/arch/x86/kernel/i8259_32.c linux-2.6.24.7_NO_APIC/arch/x86/kernel/i8259_32.c
--- linux-2.6.24.7/arch/x86/kernel/i8259_32.c	2008-05-07 00:22:34.000000000 +0100
+++ linux-2.6.24.7_NO_APIC/arch/x86/kernel/i8259_32.c	2009-01-17 19:32:19.000000000 +0000
@@ -64,6 +64,15 @@
  */
 unsigned long io_apic_irqs;
 
+#ifdef RTLINUX
+#undef spin_lock_irqsave
+#define spin_lock_irqsave(lock, flags)         do { rtl_hard_local_irq_save_kernel(flags);       spin_lock(lock); } while (0)
+
+#undef spin_unlock_irqrestore
+#define spin_unlock_irqrestore(lock, flags)    do { spin_unlock(lock);  rtl_hard_local_irq_restore_kernel(flags); } while (0)
+#endif
+
+
 void disable_8259A_irq(unsigned int irq)
 {
 	unsigned int mask = 1 << irq;
diff -Naur linux-2.6.24.7/arch/x86/kernel/io_apic_32.c linux-2.6.24.7_NO_APIC/arch/x86/kernel/io_apic_32.c
--- linux-2.6.24.7/arch/x86/kernel/io_apic_32.c	2008-05-07 00:22:34.000000000 +0100
+++ linux-2.6.24.7_NO_APIC/arch/x86/kernel/io_apic_32.c	2008-11-15 18:54:52.000000000 +0000
@@ -137,6 +137,14 @@
 	struct IO_APIC_route_entry entry;
 };
 
+#ifdef CONFIG_RTLINUX
+#undef spin_lock_irqsave
+#define spin_lock_irqsave(lock, flags)         do { rtl_hard_local_irq_save_kernel(flags);       spin_lock(lock); } while (0)
+
+#undef spin_unlock_irqrestore
+#define spin_unlock_irqrestore(lock, flags)    do { spin_unlock(lock);  rtl_hard_local_irq_restore_kernel(flags); } while (0)
+#endif
+
 static struct IO_APIC_route_entry ioapic_read_entry(int apic, int pin)
 {
 	union entry_union eu;
diff -Naur linux-2.6.24.7/arch/x86/kernel/irq_32.c linux-2.6.24.7_NO_APIC/arch/x86/kernel/irq_32.c
--- linux-2.6.24.7/arch/x86/kernel/irq_32.c	2008-05-07 00:22:34.000000000 +0100
+++ linux-2.6.24.7_NO_APIC/arch/x86/kernel/irq_32.c	2009-01-17 19:52:03.000000000 +0000
@@ -66,7 +66,7 @@
  * SMP cross-CPU interrupts have their own specific
  * handlers).
  */
-fastcall unsigned int do_IRQ(struct pt_regs *regs)
+__attribute__ ((regparm(3))) unsigned int do_IRQ(struct pt_regs *regs)
 {	
 	struct pt_regs *old_regs;
 	/* high bit used in ret_from_ code */
diff -Naur linux-2.6.24.7/arch/x86/kernel/Makefile_32 linux-2.6.24.7_NO_APIC/arch/x86/kernel/Makefile_32
--- linux-2.6.24.7/arch/x86/kernel/Makefile_32	2008-05-07 00:22:34.000000000 +0100
+++ linux-2.6.24.7_NO_APIC/arch/x86/kernel/Makefile_32	2008-11-15 18:54:52.000000000 +0000
@@ -50,6 +50,8 @@
 
 obj-$(CONFIG_SCx200)		+= scx200_32.o
 
+obj-$(CONFIG_RTLINUX)		+= rtlinux.o
+
 # vsyscall_32.o contains the vsyscall DSO images as __initdata.
 # We must build both images before we can assemble it.
 # Note: kbuild does not track this dependency due to usage of .incbin
diff -Naur linux-2.6.24.7/arch/x86/kernel/rtlinux.c linux-2.6.24.7_NO_APIC/arch/x86/kernel/rtlinux.c
--- linux-2.6.24.7/arch/x86/kernel/rtlinux.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.24.7_NO_APIC/arch/x86/kernel/rtlinux.c	2008-12-07 10:10:39.000000000 +0000
@@ -0,0 +1,80 @@
+#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>
+#include <asm/rtlinux.h>
+
+#include <linux/irq.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;
+void *rtl_syscall_intercept = 0;
+
+extern void *__start_rtlinux_patch,*__stop_rtlinux_patch;
+extern fastcall unsigned int 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_error_interrupt);
+RTLINUX_EXPORT(smp_apic_timer_interrupt);
+#endif
+
+#ifdef CONFIG_SMP_RTLINUX
+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 -Naur linux-2.6.24.7/arch/x86/kernel/setup_32.c linux-2.6.24.7_NO_APIC/arch/x86/kernel/setup_32.c
--- linux-2.6.24.7/arch/x86/kernel/setup_32.c	2008-05-07 00:22:34.000000000 +0100
+++ linux-2.6.24.7_NO_APIC/arch/x86/kernel/setup_32.c	2009-01-17 19:33:52.000000000 +0000
@@ -82,6 +82,9 @@
 struct cpuinfo_x86 boot_cpu_data __read_mostly = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
 EXPORT_SYMBOL(boot_cpu_data);
 
+int rtl_var_debug = 0;
+EXPORT_SYMBOL(rtl_var_debug);
+
 unsigned long mmu_cr4_features;
 
 /* for MCA, but anyone else can use it if they want */
diff -Naur linux-2.6.24.7/arch/x86/kernel/sysenter_32.c linux-2.6.24.7_NO_APIC/arch/x86/kernel/sysenter_32.c
--- linux-2.6.24.7/arch/x86/kernel/sysenter_32.c	2008-05-07 00:22:34.000000000 +0100
+++ linux-2.6.24.7_NO_APIC/arch/x86/kernel/sysenter_32.c	2008-11-19 20:25:47.000000000 +0000
@@ -245,6 +245,11 @@
 
 	printk("Compat vDSO mapped to %08lx.\n", __fix_to_virt(FIX_VDSO));
 
+	/* RTLINUX: Always using int80 system calls by now */
+	vsyscall = &vsyscall_int80_start;
+       	vsyscall_len = &vsyscall_int80_end - &vsyscall_int80_start;
+
+#if 0
 	if (!boot_cpu_has(X86_FEATURE_SEP)) {
 		vsyscall = &vsyscall_int80_start;
 		vsyscall_len = &vsyscall_int80_end - &vsyscall_int80_start;
@@ -252,6 +257,7 @@
 		vsyscall = &vsyscall_sysenter_start;
 		vsyscall_len = &vsyscall_sysenter_end - &vsyscall_sysenter_start;
 	}
+#endif
 
 	memcpy(syscall_page, vsyscall, vsyscall_len);
 	relocate_vdso(syscall_page);
diff -Naur linux-2.6.24.7/arch/x86/kernel/time_32.c linux-2.6.24.7_NO_APIC/arch/x86/kernel/time_32.c
--- linux-2.6.24.7/arch/x86/kernel/time_32.c	2008-05-07 00:22:34.000000000 +0100
+++ linux-2.6.24.7_NO_APIC/arch/x86/kernel/time_32.c	2008-11-15 21:42:09.000000000 +0000
@@ -166,11 +166,18 @@
 		 * This will also deassert NMI lines for the watchdog if run
 		 * on an 82489DX-based system.
 		 */
+#ifdef CONFIG_RTLINUX
+	    	unsigned long flags;
+	    	rtl_hard_local_irq_save_kernel(flags);
+#endif
 		spin_lock(&i8259A_lock);
 		outb(0x0c, PIC_MASTER_OCW3);
 		/* Ack the IRQ; AEOI will end it automatically. */
 		inb(PIC_MASTER_POLL);
 		spin_unlock(&i8259A_lock);
+#ifdef CONFIG_RTLINUX
+	       	rtl_hard_local_irq_restore_kernel(flags);
+#endif
 	}
 #endif
 
diff -Naur linux-2.6.24.7/arch/x86/mm/fault_32.c linux-2.6.24.7_NO_APIC/arch/x86/mm/fault_32.c
--- linux-2.6.24.7/arch/x86/mm/fault_32.c	2008-05-07 00:22:34.000000000 +0100
+++ linux-2.6.24.7_NO_APIC/arch/x86/mm/fault_32.c	2008-11-15 18:54:52.000000000 +0000
@@ -346,7 +346,8 @@
 	/* It's safe to allow irq's after cr2 has been saved and the vmalloc
 	   fault has been handled. */
 	if (regs->eflags & (X86_EFLAGS_IF|VM_MASK))
-		local_irq_enable();
+               __asm__ __volatile__("sti":::"memory");
+		//local_irq_enable();
 
 	mm = tsk->mm;
 
diff -Naur linux-2.6.24.7/include/asm-generic/bug.h linux-2.6.24.7_NO_APIC/include/asm-generic/bug.h
--- linux-2.6.24.7/include/asm-generic/bug.h	2008-05-07 00:22:34.000000000 +0100
+++ linux-2.6.24.7_NO_APIC/include/asm-generic/bug.h	2008-11-29 11:37:43.000000000 +0000
@@ -23,15 +23,24 @@
 #ifndef HAVE_ARCH_BUG
 #define BUG() do { \
 	printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \
-	panic("BUG!"); \
 } while (0)
 #endif
 
+/*#ifndef HAVE_ARCH_BUG
+#define BUG() do { \
+	printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \
+	panic("BUG!"); \
+} while (0)
+#endif*/
+
 #ifndef HAVE_ARCH_BUG_ON
-#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0)
+//#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0)
+#define BUG_ON(condition) 		0
 #endif
 
 #ifndef HAVE_ARCH_WARN_ON
+#define WARN_ON(condition) 		0
+#if 0
 #define WARN_ON(condition) ({						\
 	int __ret_warn_on = !!(condition);				\
 	if (unlikely(__ret_warn_on)) {					\
@@ -42,6 +51,7 @@
 	unlikely(__ret_warn_on);					\
 })
 #endif
+#endif
 
 #else /* !CONFIG_BUG */
 #ifndef HAVE_ARCH_BUG
@@ -49,17 +59,23 @@
 #endif
 
 #ifndef HAVE_ARCH_BUG_ON
-#define BUG_ON(condition) do { if (condition) ; } while(0)
+//#define BUG_ON(condition) do { if (condition) ; } while(0)
+#define BUG_ON(condition) 		0
 #endif
 
 #ifndef HAVE_ARCH_WARN_ON
+#define WARN_ON(condition) 		0
+#if 0
 #define WARN_ON(condition) ({						\
 	int __ret_warn_on = !!(condition);				\
 	unlikely(__ret_warn_on);					\
 })
 #endif
 #endif
+#endif
 
+#define WARN_ON_ONCE(condition)		0
+#if 0
 #define WARN_ON_ONCE(condition)	({				\
 	static int __warned;					\
 	int __ret_warn_once = !!(condition);			\
@@ -69,6 +85,7 @@
 			__warned = 1;				\
 	unlikely(__ret_warn_once);				\
 })
+#endif
 
 #ifdef CONFIG_SMP
 # define WARN_ON_SMP(x)			WARN_ON(x)
diff -Naur linux-2.6.24.7/include/asm-x86/rtlinux_cli.h linux-2.6.24.7_NO_APIC/include/asm-x86/rtlinux_cli.h
--- linux-2.6.24.7/include/asm-x86/rtlinux_cli.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.24.7_NO_APIC/include/asm-x86/rtlinux_cli.h	2008-11-15 18:54:52.000000000 +0000
@@ -0,0 +1,43 @@
+#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
+#undef __restore_flags
+#undef local_irq_save
+#undef local_irq_restore
+#undef local_irq_disable
+#undef local_irq_enable
+#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()
+#define local_irq_save(x)	irq_control.do_local_irq_save((&x))
+#define local_irq_restore(x)	irq_control.do_local_irq_restore(x)
+#define local_irq_disable()	irq_control.do_cli()
+#define local_irq_enable()	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 -Naur linux-2.6.24.7/include/asm-x86/rtlinux.h linux-2.6.24.7_NO_APIC/include/asm-x86/rtlinux.h
--- linux-2.6.24.7/include/asm-x86/rtlinux.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.24.7_NO_APIC/include/asm-x86/rtlinux.h	2008-11-15 18:54:52.000000000 +0000
@@ -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 -Naur linux-2.6.24.7/include/asm-x86/system_32.h linux-2.6.24.7_NO_APIC/include/asm-x86/system_32.h
--- linux-2.6.24.7/include/asm-x86/system_32.h	2008-05-07 00:22:34.000000000 +0100
+++ linux-2.6.24.7_NO_APIC/include/asm-x86/system_32.h	2008-11-15 18:54:52.000000000 +0000
@@ -300,6 +300,7 @@
 #endif
 
 #include <linux/irqflags.h>
+#include <asm/rtlinux_cli.h>
 
 /*
  * disable hlt during certain critical i/o operations
diff -Naur linux-2.6.24.7/kernel/posix-cpu-timers.c linux-2.6.24.7_NO_APIC/kernel/posix-cpu-timers.c
--- linux-2.6.24.7/kernel/posix-cpu-timers.c	2008-05-07 00:22:34.000000000 +0100
+++ linux-2.6.24.7_NO_APIC/kernel/posix-cpu-timers.c	2008-11-15 18:54:52.000000000 +0000
@@ -578,7 +578,7 @@
 		p->cpu_timers : p->signal->cpu_timers);
 	head += CPUCLOCK_WHICH(timer->it_clock);
 
-	BUG_ON(!irqs_disabled());
+	//BUG_ON(!irqs_disabled());
 	spin_lock(&p->sighand->siglock);
 
 	listpos = head;
@@ -735,7 +735,7 @@
 	/*
 	 * Disarm any old timer after extracting its expiry time.
 	 */
-	BUG_ON(!irqs_disabled());
+	//BUG_ON(!irqs_disabled());
 
 	ret = 0;
 	spin_lock(&p->sighand->siglock);
@@ -1292,7 +1292,7 @@
 	LIST_HEAD(firing);
 	struct k_itimer *timer, *next;
 
-	BUG_ON(!irqs_disabled());
+	//BUG_ON(!irqs_disabled());
 
 #define UNEXPIRED(clock) \
 		(cputime_eq(tsk->it_##clock##_expires, cputime_zero) || \
diff -Naur linux-2.6.24.7/kernel/softirq.c linux-2.6.24.7_NO_APIC/kernel/softirq.c
--- linux-2.6.24.7/kernel/softirq.c	2008-05-07 00:22:34.000000000 +0100
+++ linux-2.6.24.7_NO_APIC/kernel/softirq.c	2008-11-15 18:54:52.000000000 +0000
@@ -120,7 +120,7 @@
 void _local_bh_enable(void)
 {
 	WARN_ON_ONCE(in_irq());
-	WARN_ON_ONCE(!irqs_disabled());
+	//WARN_ON_ONCE(!irqs_disabled());
 
 	if (softirq_count() == SOFTIRQ_OFFSET)
 		trace_softirqs_on((unsigned long)__builtin_return_address(0));
@@ -136,7 +136,7 @@
 
 	WARN_ON_ONCE(in_irq());
 #endif
-	WARN_ON_ONCE(irqs_disabled());
+	//WARN_ON_ONCE(irqs_disabled());
 
 #ifdef CONFIG_TRACE_IRQFLAGS
 	local_irq_save(flags);
