diff -auP linux-2.4.23/arch/i386/boot/compressed/head.S linux-2.4.23-win4lin/arch/i386/boot/compressed/head.S
--- linux-2.4.23/arch/i386/boot/compressed/head.S	2000-07-05 12:03:12.000000000 -0700
+++ linux-2.4.23-win4lin/arch/i386/boot/compressed/head.S	2003-12-02 09:46:39.000000000 -0800
@@ -31,7 +31,7 @@
 startup_32:
 	cld
 	cli
-	movl $(__KERNEL_DS),%eax
+	movl $(__BOOT_KERNEL_DS),%eax
 	movl %eax,%ds
 	movl %eax,%es
 	movl %eax,%fs
@@ -74,7 +74,7 @@
 	popl %esi	# discard address
 	popl %esi	# real mode pointer
 	xorl %ebx,%ebx
-	ljmp $(__KERNEL_CS), $0x100000
+	ljmp $(__BOOT_KERNEL_CS), $0x100000
 
 /*
  * We come here, if we were loaded high.
@@ -101,7 +101,7 @@
 	popl %eax	# hcount
 	movl $0x100000,%edi
 	cli		# make sure we don't get interrupted
-	ljmp $(__KERNEL_CS), $0x1000 # and jump to the move routine
+	ljmp $(__BOOT_KERNEL_CS), $0x1000 # and jump to the move routine
 
 /*
  * Routine (template) for moving the decompressed kernel in place,
@@ -124,5 +124,5 @@
 	movsl
 	movl %ebx,%esi	# Restore setup pointer
 	xorl %ebx,%ebx
-	ljmp $(__KERNEL_CS), $0x100000
+	ljmp $(__BOOT_KERNEL_CS), $0x100000
 move_routine_end:
diff -auP linux-2.4.23/arch/i386/boot/compressed/misc.c linux-2.4.23-win4lin/arch/i386/boot/compressed/misc.c
--- linux-2.4.23/arch/i386/boot/compressed/misc.c	2003-08-25 04:44:39.000000000 -0700
+++ linux-2.4.23-win4lin/arch/i386/boot/compressed/misc.c	2003-12-02 09:46:39.000000000 -0800
@@ -297,7 +297,7 @@
 struct {
 	long * a;
 	short b;
-	} stack_start = { & user_stack [STACK_SIZE] , __KERNEL_DS };
+	} stack_start = { & user_stack [STACK_SIZE] , __BOOT_KERNEL_DS };
 
 static void setup_normal_output_buffer(void)
 {
diff -auP linux-2.4.23/arch/i386/boot/setup.S linux-2.4.23-win4lin/arch/i386/boot/setup.S
--- linux-2.4.23/arch/i386/boot/setup.S	2003-11-28 10:26:19.000000000 -0800
+++ linux-2.4.23-win4lin/arch/i386/boot/setup.S	2003-12-02 09:46:39.000000000 -0800
@@ -881,7 +881,7 @@
 	.byte 0x66, 0xea			# prefix + jmpi-opcode
 code32:	.long	0x1000				# will be set to 0x100000
 						# for big kernels
-	.word	__KERNEL_CS
+	.word	__BOOT_KERNEL_CS
 
 # Here's a bunch of information about your current kernel..
 kernel_version:	.ascii	UTS_RELEASE
@@ -1093,7 +1093,7 @@
 	.word	0				# idt limit = 0
 	.word	0, 0				# idt base = 0L
 gdt_48:
-	.word	0x8000				# gdt limit=2048,
+	.word	0x8000				# gdt limit=2048 + reserve,
 						#  256 GDT entries
 
 	.word	0, 0				# gdt base (filled in later)
diff -auP linux-2.4.23/arch/i386/config.in linux-2.4.23-win4lin/arch/i386/config.in
--- linux-2.4.23/arch/i386/config.in	2003-11-28 10:26:19.000000000 -0800
+++ linux-2.4.23-win4lin/arch/i386/config.in	2003-12-02 09:46:39.000000000 -0800
@@ -468,6 +468,13 @@
 source net/bluetooth/Config.in
 
 mainmenu_option next_comment
+comment 'Windows Applications support'
+if [ "$CONFIG_MODULES" = "y" ]; then
+bool 'Include NeTraverse Win4Lin Support' CONFIG_MKI
+fi
+endmenu
+
+mainmenu_option next_comment
 comment 'Kernel hacking'
 
 bool 'Kernel debugging' CONFIG_DEBUG_KERNEL
diff -auP linux-2.4.23/arch/i386/Makefile linux-2.4.23-win4lin/arch/i386/Makefile
--- linux-2.4.23/arch/i386/Makefile	2003-06-13 07:51:29.000000000 -0700
+++ linux-2.4.23-win4lin/arch/i386/Makefile	2003-12-02 09:46:39.000000000 -0800
@@ -106,6 +106,11 @@
 DRIVERS += arch/i386/math-emu/math.o
 endif
 
+ifdef CONFIG_MKI
+SUBDIRS += arch/i386/mki
+CORE_FILES += arch/i386/mki/mki.o
+endif
+
 arch/i386/kernel: dummy
 	$(MAKE) linuxsubdirs SUBDIRS=arch/i386/kernel
 
diff -auP linux-2.4.23/arch/i386/kernel/apm.c linux-2.4.23-win4lin/arch/i386/kernel/apm.c
diff -auP linux-2.4.23/arch/i386/kernel/entry.S linux-2.4.23-win4lin/arch/i386/kernel/entry.S
--- linux-2.4.23/arch/i386/kernel/entry.S	2003-06-13 07:51:29.000000000 -0700
+++ linux-2.4.23-win4lin/arch/i386/kernel/entry.S	2003-12-02 09:46:39.000000000 -0800
@@ -213,6 +213,11 @@
 	cli				# need_resched and signals atomic test
 	cmpl $0,need_resched(%ebx)
 	jne reschedule
+#ifdef CONFIG_MKI
+	pushl %esp
+	call SYMBOL_NAME(mki_ret_user)
+	addl $4,%esp
+#endif /* CONFIG_MKI */
 	cmpl $0,sigpending(%ebx)
 	jne signal_return
 restore_all:
@@ -253,6 +258,13 @@
 	jmp ret_from_sys_call
 
 	ALIGN
+#ifdef CONFIG_MKI
+ENTRY(mki_process_trapret)
+#ifdef CONFIG_PREEMPT
+	GET_CURRENT(%ebx)
+	jmp ret_from_exception
+#endif
+#endif /* CONFIG_MKI */
 ENTRY(ret_from_intr)
 	GET_CURRENT(%ebx)
 ret_from_exception:
diff -auP linux-2.4.23/arch/i386/kernel/head.S linux-2.4.23-win4lin/arch/i386/kernel/head.S
--- linux-2.4.23/arch/i386/kernel/head.S	2003-11-28 10:26:19.000000000 -0800
+++ linux-2.4.23-win4lin/arch/i386/kernel/head.S	2003-12-02 09:46:39.000000000 -0800
@@ -46,7 +46,7 @@
  * Set segments to known values
  */
 	cld
-	movl $(__KERNEL_DS),%eax
+	movl $(__BOOT_KERNEL_DS),%eax
 	movl %eax,%ds
 	movl %eax,%es
 	movl %eax,%fs
@@ -104,7 +104,7 @@
 	jmp *%eax		/* make sure eip is relocated */
 1:
 	/* Set up the stack pointer */
-	lss stack_start,%esp
+	lss boot_stack_start,%esp
 
 #ifdef CONFIG_SMP
 	orw  %bx,%bx
@@ -319,6 +319,10 @@
 	jne rp_sidt
 	ret
 
+ENTRY(boot_stack_start)
+	.long SYMBOL_NAME(init_task_union)+8192
+	.long __BOOT_KERNEL_DS
+
 ENTRY(stack_start)
 	.long SYMBOL_NAME(init_task_union)+8192
 	.long __KERNEL_DS
@@ -408,19 +412,6 @@
 
 .org 0x5000
 
-/*
- * Real beginning of normal "text" segment
- */
-ENTRY(stext)
-ENTRY(_stext)
-
-/*
- * This starts the data section. Note that the above is all
- * in the text section because it has alignment requirements
- * that we cannot fulfill any other way.
- */
-.data
-
 ALIGN
 /*
  * This contains typically 140 quadwords, depending on NR_CPUS.
@@ -445,4 +436,28 @@
 	.quad 0x00409a0000000000	/* 0x48 APM CS    code */
 	.quad 0x00009a0000000000	/* 0x50 APM CS 16 code (16 bit) */
 	.quad 0x0040920000000000	/* 0x58 APM DS    data */
+#ifdef CONFIG_MKI
+/* increase the ENTRIES_AFTER_KERNEL constant in segment.h if more */
+/* entries are added after 0x18 above */
+	.fill __GDT_SLOTS_RESERVED-(2+ENTRIES_AFTER_KERNEL_DS),8,0 
+					/* fill to page boundary + 2 slots */
+	.quad 0x00cf9a000000ffff	/* 0x1010 kernel 4GB code at 0x00000000 */
+	.quad 0x00cf92000000ffff	/* 0x1018 kernel 4GB data at 0x00000000 */
+	.fill ENTRIES_AFTER_KERNEL_DS,8,0 
+#endif
 	.fill NR_CPUS*4,8,0		/* space for TSS's and LDT's */
+
+	ALIGN
+/*
+ * Real beginning of normal "text" segment
+ */
+ENTRY(stext)
+ENTRY(_stext)
+
+/*
+ * This starts the data section. Note that the above is all
+ * in the text section because it has alignment requirements
+ * that we cannot fulfill any other way.
+ */
+.data
+
diff -auP linux-2.4.23/arch/i386/kernel/process.c linux-2.4.23-win4lin/arch/i386/kernel/process.c
--- linux-2.4.23/arch/i386/kernel/process.c	2003-11-28 10:26:19.000000000 -0800
+++ linux-2.4.23-win4lin/arch/i386/kernel/process.c	2003-12-02 09:50:13.000000000 -0800
@@ -50,6 +50,10 @@
 #endif
 #include <asm/apic.h>
 
+#ifdef CONFIG_MKI
+#include <asm/mki.h>
+#endif
+
 #include <linux/irq.h>
 
 asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
@@ -707,6 +711,11 @@
 	asm volatile("movl %%fs,%0":"=m" (*(int *)&prev->fs));
 	asm volatile("movl %%gs,%0":"=m" (*(int *)&prev->gs));
 
+#ifdef CONFIG_MKI
+	if (next_p->mki_task_info)
+		CALL_MKI_HOOK(MKI_HOOK_SWITCH_TO, next_p, NULL);
+#endif /* CONFIG_MKI */
+
 	/*
 	 * Restore %fs and %gs.
 	 */
diff -auP linux-2.4.23/arch/i386/kernel/setup.c linux-2.4.23-win4lin/arch/i386/kernel/setup.c
diff -auP linux-2.4.23/arch/i386/kernel/signal.c linux-2.4.23-win4lin/arch/i386/kernel/signal.c
--- linux-2.4.23/arch/i386/kernel/signal.c	2002-08-02 17:39:42.000000000 -0700
+++ linux-2.4.23-win4lin/arch/i386/kernel/signal.c	2003-12-02 09:46:39.000000000 -0800
@@ -19,6 +19,7 @@
 #include <linux/unistd.h>
 #include <linux/stddef.h>
 #include <linux/tty.h>
+#include <linux/config.h>
 #include <linux/personality.h>
 #include <asm/ucontext.h>
 #include <asm/uaccess.h>
@@ -592,8 +593,16 @@
 	 * kernel mode. Just return without doing anything
 	 * if so.
 	 */
+#ifdef CONFIG_MKI
+	/* When we are in vm86 mode don't do the quick return */
+	if (((regs->eflags & 0x20000) == 0) &&
+	    ((regs->xcs & 3) != 3)) {
+		return 1;
+	}
+#else
 	if ((regs->xcs & 3) != 3)
 		return 1;
+#endif
 
 	if (!oldset)
 		oldset = &current->blocked;
diff -auP linux-2.4.23/arch/i386/kernel/smpboot.c linux-2.4.23-win4lin/arch/i386/kernel/smpboot.c
--- linux-2.4.23/arch/i386/kernel/smpboot.c	2003-11-28 10:26:19.000000000 -0800
+++ linux-2.4.23-win4lin/arch/i386/kernel/smpboot.c	2003-12-02 09:46:39.000000000 -0800
@@ -499,6 +499,11 @@
 	unsigned short ss;
 } stack_start;
 
+extern struct {
+	void * esp;
+	unsigned short ss;
+} boot_stack_start;
+
 static int __init fork_by_hand(void)
 {
 	struct pt_regs regs;
@@ -820,6 +825,7 @@
 	/* So we see what's up   */
 	printk("Booting processor %d/%d eip %lx\n", cpu, apicid, start_eip);
 	stack_start.esp = (void *) (1024 + PAGE_SIZE + (char *)idle);
+	boot_stack_start.esp = (void *) (1024 + PAGE_SIZE + (char *)idle);
 
 	/*
 	 * This grunge runs the startup process for
diff -auP linux-2.4.23/arch/i386/kernel/trampoline.S linux-2.4.23-win4lin/arch/i386/kernel/trampoline.S
--- linux-2.4.23/arch/i386/kernel/trampoline.S	2002-11-28 15:53:09.000000000 -0800
+++ linux-2.4.23-win4lin/arch/i386/kernel/trampoline.S	2003-12-02 09:46:39.000000000 -0800
@@ -26,6 +26,7 @@
  *	entries except for the gdt one..
  */
 
+#include <linux/config.h>
 #include <linux/linkage.h>
 #include <asm/segment.h>
 #include <asm/page.h>
@@ -54,7 +55,7 @@
 	lmsw	%ax		# into protected mode
 	jmp	flush_instr
 flush_instr:
-	ljmpl	$__KERNEL_CS, $0x00100000
+	ljmpl	$__BOOT_KERNEL_CS, $0x00100000
 			# jump to startup_32 in arch/i386/kernel/head.S
 
 idt_48:
diff -auP linux-2.4.23/arch/i386/mki/Makefile linux-2.4.23-win4lin/arch/i386/mki/Makefile
--- linux-2.4.23/arch/i386/mki/Makefile	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.4.23-win4lin/arch/i386/mki/Makefile	2003-12-02 09:46:39.000000000 -0800
@@ -0,0 +1,27 @@
+#
+# Makefile for the Merge Kernel Interface (MKI).
+#
+# Copyright 1999-2001 by NeTraverse Inc.
+# This source code is provided "AS IS", free of charge
+# and without restrictions.
+# NeTraverse (and it's third party suppliers and licensors) make no warranty
+# to its use, performance, or suitability for any particular purpose.
+# In no event, shall NeTraverse (and it's third party suppliers and licensors)
+# be liable for any damages resulting in the use of this source code.
+# The entire risk arising out of the use of this source code remains
+# with you.
+#
+#**********************************************************************
+#  This software may be used and distributed according to the terms
+#  of the GNU General Public License, incorporated herein by reference.
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+# Note 2! The CFLAGS definitions are now in the main makefile...
+
+all: mki.o
+#OX_OBJS := mki.o
+export-objs := mki.o
+include $(TOPDIR)/Rules.make
diff -auP linux-2.4.23/arch/i386/mki/mki.c linux-2.4.23-win4lin/arch/i386/mki/mki.c
--- linux-2.4.23/arch/i386/mki/mki.c	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.4.23-win4lin/arch/i386/mki/mki.c	2003-12-02 09:46:39.000000000 -0800
@@ -0,0 +1,91 @@
+/*
+ * Copyright 1999-2001 by NeTraverse Inc.
+ * This source code is provided "AS IS", free of charge
+ * and without restrictions.
+ * NeTraverse (and it's third party suppliers and licensors) make no warranty
+ * to its use, performance, or suitability for any particular purpose.
+ * In no event, shall NeTraverse (and it's third party suppliers and licensors)
+ * be liable for any damages resulting in the use of this source code.
+ * The entire risk arising out of the use of this source code remains
+ * with you.
+ *
+ ***********************************************************************
+ *  This software may be used and distributed according to the terms
+ *  of the GNU General Public License, incorporated herein by reference.
+ */
+/*
+ * These hooks will get populated by the mki-adapter module
+ */
+
+#include <linux/config.h>
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/spinlock.h>
+
+#include <asm/system.h>
+#include <asm/mki.h>
+#include <asm/mkiversion.h>
+
+void mhi_void_hook(void *parm1, void *parm2)
+{
+	return;
+}
+
+void (*mhi_hooks[])(void *, void *) =
+{
+	&mhi_void_hook, /* MKI_HOOK_RET_USER */
+	&mhi_void_hook, /* MKI_HOOK_SWITCH_TO */
+	&mhi_void_hook, /* MKI_HOOK_SWITCH_AWAY */
+	&mhi_void_hook, /* MKI_HOOK_EXIT */
+	&mhi_void_hook, /* MKI_HOOK_SWAP */
+};
+
+void mki_ret_user(unsigned long *r0ptr)
+{
+	CALL_MKI_HOOK(MKI_HOOK_RET_USER, r0ptr, NULL);
+}
+
+EXPORT_SYMBOL_NOVERS(mhi_void_hook);
+EXPORT_SYMBOL_NOVERS(mhi_hooks);
+EXPORT_SYMBOL_NOVERS(mki_ret_user);
+extern void mki_process_trapret(void);
+EXPORT_SYMBOL_NOVERS(mki_process_trapret);
+//some data that we need for the other modules
+#include <linux/sched.h>
+#include <asm/processor.h>
+#include <asm/desc.h>
+EXPORT_SYMBOL_NOVERS(init_tss);
+EXPORT_SYMBOL_NOVERS(idt);
+EXPORT_SYMBOL_NOVERS(gdt_table);
+EXPORT_SYMBOL_NOVERS(runqueue_lock);
+//and some functions
+#include <linux/mm.h>
+EXPORT_SYMBOL_NOVERS(handle_mm_fault);
+EXPORT_SYMBOL_NOVERS(make_pages_present);
+#ifdef CONFIG_SMP
+EXPORT_SYMBOL_NOVERS(smp_send_reschedule);
+extern void flush_tlb_all(void);
+EXPORT_SYMBOL_NOVERS(flush_tlb_all);
+#endif
+
+/* pte and pmd allocation changed in 2.4.3 */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3)
+#include <asm/pgalloc.h>
+EXPORT_SYMBOL_NOVERS(__handle_bad_pmd);
+EXPORT_SYMBOL_NOVERS(get_pte_slow);
+#else
+EXPORT_SYMBOL_NOVERS(__pmd_alloc);
+EXPORT_SYMBOL_NOVERS(pte_alloc);
+#endif
+
+#include <asm/uaccess.h>
+EXPORT_SYMBOL_NOVERS(search_exception_table);
+extern int sys_mprotect(unsigned long, size_t, unsigned long);
+EXPORT_SYMBOL_NOVERS(sys_mprotect);
+extern int sys_ftruncate(int, unsigned long);
+EXPORT_SYMBOL_NOVERS(sys_ftruncate);
+extern int sys_munmap(unsigned long, size_t);
+EXPORT_SYMBOL_NOVERS(sys_munmap);
+void do_exit(long code);
+EXPORT_SYMBOL_NOVERS(do_exit);
diff -auP linux-2.4.23/arch/i386/mm/fault.c linux-2.4.23-win4lin/arch/i386/mm/fault.c
--- linux-2.4.23/arch/i386/mm/fault.c	2002-11-28 15:53:09.000000000 -0800
+++ linux-2.4.23-win4lin/arch/i386/mm/fault.c	2003-12-02 09:46:39.000000000 -0800
@@ -19,6 +19,7 @@
 #include <linux/init.h>
 #include <linux/tty.h>
 #include <linux/vt_kern.h>		/* For unblank_screen() */
+#include <linux/config.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
@@ -268,7 +269,11 @@
 	up_read(&mm->mmap_sem);
 
 	/* User mode accesses just cause a SIGSEGV */
+#ifdef CONFIG_MKI
+	if (user_mode(regs)) {
+#else
 	if (error_code & 4) {
+#endif
 		tsk->thread.cr2 = address;
 		tsk->thread.error_code = error_code;
 		tsk->thread.trap_no = 14;
diff -auP linux-2.4.23/drivers/ide/ide-io.c linux-2.4.23-win4lin/drivers/ide/ide-io.c
--- linux-2.4.23/drivers/ide/ide-io.c	2003-11-28 10:26:20.000000000 -0800
+++ linux-2.4.23-win4lin/drivers/ide/ide-io.c	2003-12-02 10:08:18.000000000 -0800
@@ -1312,6 +1312,10 @@
 	ide_do_request(hwgroup, IDE_NO_IRQ);
 	spin_unlock_irqrestore(&io_request_lock, flags);
 	if (action == ide_wait) {
+		/*
+		 * make sure IO is not suspended
+		 */
+		generic_unplug_device(&drive->queue);
 		/* wait for it to be serviced */
 		wait_for_completion(&wait);
 		/* return -EIO if errors */
diff -auP linux-2.4.23/drivers/ide/ide-cd.c linux-2.4.23-win4lin/drivers/ide/ide-cd.c
diff -auP linux-2.4.23/include/asm-i386/desc.h linux-2.4.23-win4lin/include/asm-i386/desc.h
--- linux-2.4.23/include/asm-i386/desc.h	2001-07-26 13:40:32.000000000 -0700
+++ linux-2.4.23-win4lin/include/asm-i386/desc.h	2003-12-02 09:46:39.000000000 -0800
@@ -2,6 +2,7 @@
 #define __ARCH_DESC_H
 
 #include <asm/ldt.h>
+#include <linux/config.h>
 
 /*
  * The layout of the GDT under Linux:
@@ -34,7 +35,7 @@
  *
  * Entry into gdt where to find first TSS.
  */
-#define __FIRST_TSS_ENTRY 12
+#define __FIRST_TSS_ENTRY (12+__GDT_SLOTS_RESERVED)
 #define __FIRST_LDT_ENTRY (__FIRST_TSS_ENTRY+1)
 
 #define __TSS(n) (((n)<<2) + __FIRST_TSS_ENTRY)
diff -auP linux-2.4.23/include/asm-i386/mki.h linux-2.4.23-win4lin/include/asm-i386/mki.h
--- linux-2.4.23/include/asm-i386/mki.h	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.4.23-win4lin/include/asm-i386/mki.h	2003-12-02 09:59:17.000000000 -0800
@@ -0,0 +1,42 @@
+/* 
+ * Copyright 1999-2001 by NeTraverse Inc.
+ * This source code is provided "AS IS", free of charge 
+ * and without restrictions.
+ * NeTraverse (and it's third party suppliers and licensors) make no warranty
+ * to its use, performance, or suitability for any particular purpose.
+ * In no event, shall NeTraverse (and it's third party suppliers and licensors)
+ * be liable for any damages resulting in the use of this source code.
+ * The entire risk arising out of the use of this source code remains
+ * with you.
+ * 
+ ***********************************************************************
+ *  This software may be used and distributed according to the terms
+ *  of the GNU General Public License, incorporated herein by reference.
+ */
+
+
+#ifdef CONFIG_MKI
+#ifndef INCLUDE_MKI_H
+#define INCLUDE_MKI_H
+
+extern void mhi_void_hook(void *, void *);
+extern void (*mhi_hooks[])(void *, void *);
+
+#define CALL_MKI_HOOK(hook, arg1, arg2)  mhi_hooks[hook](arg1, arg2)
+
+/* for mki-adapter module */
+#define MKI_HOOK_TABLE_EXISTS	1
+
+/* constants for hook table  */
+#define MKI_HOOK_RET_USER 		0
+#define MKI_HOOK_SWITCH_TO 		1
+#define MKI_HOOK_SWITCH_AWAY 		2
+#define MKI_HOOK_EXIT			3
+#define MKI_HOOK_SWAP			4
+
+/* Definitions for MKI_HOOK_SWAP */
+#define MKI_HARD_PRIORITY       1
+#define MKI_NORMAL_PRIORITY     6
+
+#endif /* INCLUDE_MKI_H */
+#endif /* CONFIG_MKI */
diff -auP linux-2.4.23/include/asm-i386/mkiversion.h linux-2.4.23-win4lin/include/asm-i386/mkiversion.h
--- linux-2.4.23/include/asm-i386/mkiversion.h	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.4.23-win4lin/include/asm-i386/mkiversion.h	2003-12-02 09:46:39.000000000 -0800
@@ -0,0 +1,25 @@
+/*
+ * Copyright 1999-2001 by NeTraverse Inc.
+ * This source code is provided "AS IS", free of charge
+ * and without restrictions.
+ * NeTraverse (and it's third party suppliers and licensors) make no warranty
+ * to its use, performance, or suitability for any particular purpose.
+ * In no event, shall NeTraverse (and it's third party suppliers and licensors)
+ * be liable for any damages resulting in the use of this source code.
+ * The entire risk arising out of the use of this source code remains
+ * with you.
+ *
+ ***********************************************************************
+ *  This software may be used and distributed according to the terms
+ *  of the GNU General Public License, incorporated herein by reference.
+ */
+
+#ifdef CONFIG_MKI
+#ifndef INCLUDE_MKI_VERSION_H
+#define INCLUDE_MKI_VERSION_H
+
+int mki_version_3_0_1 = 0;
+EXPORT_SYMBOL_NOVERS(mki_version_3_0_1);
+
+#endif /* INCLUDE_MKI_H */
+#endif /* CONFIG_MKI */
diff -auP linux-2.4.23/include/asm-i386/segment.h linux-2.4.23-win4lin/include/asm-i386/segment.h
--- linux-2.4.23/include/asm-i386/segment.h	1997-12-01 10:34:12.000000000 -0800
+++ linux-2.4.23-win4lin/include/asm-i386/segment.h	2003-12-02 09:46:39.000000000 -0800
@@ -1,8 +1,22 @@
 #ifndef _ASM_SEGMENT_H
 #define _ASM_SEGMENT_H
+#include <linux/config.h>
 
-#define __KERNEL_CS	0x10
-#define __KERNEL_DS	0x18
+#ifdef CONFIG_MKI
+/* this number increases if more entries than 
+ * this are added after 0x18 in head.S */
+#define ENTRIES_AFTER_KERNEL_DS 8
+#define ENTRIES_BEFORE_KERNEL_CS 2
+#define __GDT_SLOTS_RESERVED   512     /* Reserve a page full. */
+#else
+#define __GDT_SLOTS_RESERVED   0
+#endif
+
+#define __BOOT_KERNEL_CS	0x10
+#define __BOOT_KERNEL_DS	0x18
+
+#define __KERNEL_CS	(__GDT_SLOTS_RESERVED*8) + 0x10
+#define __KERNEL_DS	(__GDT_SLOTS_RESERVED*8) + 0x18
 
 #define __USER_CS	0x23
 #define __USER_DS	0x2B
diff -auP linux-2.4.23/include/linux/sched.h linux-2.4.23-win4lin/include/linux/sched.h
--- linux-2.4.23/include/linux/sched.h	2003-11-28 10:26:21.000000000 -0800
+++ linux-2.4.23-win4lin/include/linux/sched.h	2003-12-02 09:46:39.000000000 -0800
@@ -415,6 +415,14 @@
 
 /* journalling filesystem info */
 	void *journal_info;
+#ifdef CONFIG_MKI
+/* mki task info structure */
+	void *mki_task_info;
+#define MKI_INIT_TASK mki_task_info: NULL,
+#else
+#define MKI_INIT_TASK
+#endif
+
 };
 
 /*
@@ -508,6 +516,7 @@
     blocked:		{{0}},						\
     alloc_lock:		SPIN_LOCK_UNLOCKED,				\
     journal_info:	NULL,						\
+    MKI_INIT_TASK							\
 }
 
 
diff -auP linux-2.4.23/kernel/exit.c linux-2.4.23-win4lin/kernel/exit.c
--- linux-2.4.23/kernel/exit.c	2002-11-28 15:53:15.000000000 -0800
+++ linux-2.4.23-win4lin/kernel/exit.c	2003-12-02 09:46:39.000000000 -0800
@@ -20,6 +20,9 @@
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
 #include <asm/mmu_context.h>
+#ifdef CONFIG_MKI
+#include <asm/mki.h>
+#endif
 
 extern void sem_exit (void);
 extern struct task_struct *child_reaper;
@@ -439,6 +442,9 @@
 #ifdef CONFIG_BSD_PROCESS_ACCT
 	acct_process(code);
 #endif
+#ifdef CONFIG_MKI
+	CALL_MKI_HOOK(MKI_HOOK_EXIT, NULL, NULL);
+#endif
 	__exit_mm(tsk);
 
 	lock_kernel();
diff -auP linux-2.4.23/kernel/fork.c linux-2.4.23-win4lin/kernel/fork.c
--- linux-2.4.23/kernel/fork.c	2003-11-28 10:26:21.000000000 -0800
+++ linux-2.4.23-win4lin/kernel/fork.c	2003-12-02 09:46:39.000000000 -0800
@@ -675,6 +675,10 @@
 	atomic_inc(&p->user->__count);
 	atomic_inc(&p->user->processes);
 
+#ifdef CONFIG_MKI
+	p->mki_task_info = NULL;
+#endif
+
 	/*
 	 * Counter increases are protected by
 	 * the kernel lock so nr_threads can't
diff -auP linux-2.4.23/kernel/sched.c linux-2.4.23-win4lin/kernel/sched.c
--- linux-2.4.23/kernel/sched.c	2003-11-28 10:26:21.000000000 -0800
+++ linux-2.4.23-win4lin/kernel/sched.c	2003-12-02 09:46:39.000000000 -0800
@@ -32,6 +32,9 @@
 
 #include <asm/uaccess.h>
 #include <asm/mmu_context.h>
+#ifdef CONFIG_MKI
+#include <asm/mki.h>
+#endif
 
 extern void timer_bh(void);
 extern void tqueue_bh(void);
@@ -659,6 +662,9 @@
 #endif /* CONFIG_SMP */
 
 	kstat.context_swtch++;
+#ifdef CONFIG_MKI
+	CALL_MKI_HOOK(MKI_HOOK_SWITCH_AWAY, prev, NULL);
+#endif
 	/*
 	 * there are 3 processes which are affected by a context switch:
 	 *
diff -auP linux-2.4.23/mm/mmap.c linux-2.4.23-win4lin/mm/mmap.c
diff -auP linux-2.4.23/mm/vmscan.c linux-2.4.23-win4lin/mm/vmscan.c
--- linux-2.4.23/mm/vmscan.c	2003-11-28 10:26:21.000000000 -0800
+++ linux-2.4.23-win4lin/mm/vmscan.c	2003-12-02 09:58:12.000000000 -0800
@@ -34,6 +34,11 @@
  */
 int vm_passes = 60;
 
+#include <linux/config.h>
+#ifdef CONFIG_MKI
+#include <asm/mki.h>
+#endif
+
 /*
  * "vm_cache_scan_ratio" is how much of the inactive LRU queue we will scan
  * in one go. A value of 6 for vm_cache_scan_ratio implies that we'll
@@ -327,9 +332,20 @@
 {
 	int counter, nr_pages = SWAP_CLUSTER_MAX;
 	struct mm_struct *mm;
+#ifdef CONFIG_MKI
+	int loops = 0;
+#endif
 
 	counter = mmlist_nr << 1;
 	do {
+#ifdef CONFIG_MKI
+		void *mki_swap_pri = (void *) ((loops > 0)
+			? MKI_HARD_PRIORITY : MKI_NORMAL_PRIORITY);
+
+		CALL_MKI_HOOK(MKI_HOOK_SWAP, mki_swap_pri, (void *) NULL);
+		loops++;
+#endif /* CONFIG_MKI */
+
 		if (unlikely(current->need_resched)) {
 			__set_current_state(TASK_RUNNING);
 			schedule();
