Sophie

Sophie

distrib > Mandriva > 10.0-com > i586 > by-pkgid > 4f3a920ebaa906755b046a698d17e508 > files > 1

kernel-win4lin-2.4.25.5mdk-3-7mdk.src.rpm

--- linux-2.4.25-2mdk/arch/i386/boot/compressed/head.S.win4lin	2000-07-05 15:03:12.000000000 -0400
+++ linux-2.4.25-2mdk/arch/i386/boot/compressed/head.S	2004-06-21 07:48:00.168387978 -0400
@@ -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:
--- linux-2.4.25-2mdk/arch/i386/boot/compressed/misc.c.win4lin	2003-08-25 07:44:39.000000000 -0400
+++ linux-2.4.25-2mdk/arch/i386/boot/compressed/misc.c	2004-06-21 07:48:00.169388031 -0400
@@ -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)
 {
--- linux-2.4.25-2mdk/arch/i386/boot/setup.S.win4lin	2004-03-02 00:28:03.000000000 -0500
+++ linux-2.4.25-2mdk/arch/i386/boot/setup.S	2004-06-21 07:48:00.170388085 -0400
@@ -891,7 +891,7 @@
 	subw	$DELTA_INITSEG, %si
 	shll	$4, %esi			# Convert to 32-bit pointer
 # NOTE: For high loaded big kernels we need a
-#	jmpi    0x100000,__KERNEL_CS
+#	jmpi    0x100000,__BOOT_KERNEL_CS
 #
 #	but we yet haven't reloaded the CS register, so the default size 
 #	of the target offset still is 16 bit.
@@ -902,7 +902,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
@@ -1097,12 +1097,12 @@
 # Descriptor tables
 #
 # NOTE: if you think the GDT is large, you can make it smaller by just
-# defining the KERNEL_CS and KERNEL_DS entries and shifting the gdt
-# address down by GDT_ENTRY_KERNEL_CS*8. This puts bogus entries into
+# defining the BOOT_KERNEL_CS and BOOT_KERNEL_DS entries and shifting the gdt
+# address down by GDT_ENTRY_BOOT_KERNEL_CS*8. This puts bogus entries into
 # the GDT, but those wont be used so it's not a problem.
 #
 gdt:
-	.fill GDT_ENTRY_KERNEL_CS,8,0
+	.fill GDT_ENTRY_BOOT_KERNEL_CS,8,0
 
 	.word	0xFFFF				# 4Gb - (0x100000*0x1000 = 4Gb)
 	.word	0				# base address = 0
@@ -1119,7 +1119,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)
--- linux-2.4.25-2mdk/arch/i386/kernel/entry.S.win4lin	2004-03-02 00:28:04.000000000 -0500
+++ linux-2.4.25-2mdk/arch/i386/kernel/entry.S	2004-06-21 07:48:00.171388139 -0400
@@ -226,6 +226,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:
@@ -266,6 +271,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:
--- linux-2.4.25-2mdk/arch/i386/kernel/head.S.win4lin	2004-03-02 00:28:03.000000000 -0500
+++ linux-2.4.25-2mdk/arch/i386/kernel/head.S	2004-06-21 07:48:00.172388192 -0400
@@ -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
@@ -314,6 +314,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
@@ -362,7 +366,7 @@
 
 SYMBOL_NAME(cpu_gdt_descr):
 	.word GDT_ENTRIES*8-1
-	.long SYMBOL_NAME(cpu_gdt_table)
+	.long SYMBOL_NAME(gdt_table)
 
 	.fill NR_CPUS-1,6,0		# space for the other GDT descriptors
 
@@ -417,6 +421,63 @@
 .data
 
 ALIGN
+
+#ifdef CONFIG_MKI
+/*
+ * The Global Descriptor Table contains 512 quadwords, per-CPU.
+ */
+ENTRY(gdt_table)
+	.quad 0x0000000000000000	/* NULL descriptor */
+	.quad 0x0000000000000000	/* 0x0b reserved */
+	.quad 0x0000000000000000	/* 0x13 reserved */
+	.quad 0x0000000000000000	/* 0x1b reserved */
+	.quad 0x00cffa000000ffff	/* 0x23 user 4GB code at 0x00000000 */
+	.quad 0x00cff2000000ffff	/* 0x2b user 4GB data at 0x00000000 */
+	.quad 0x0000000000000000	/* 0x33 TLS entry 1 */
+	.quad 0x0000000000000000	/* 0x3b TLS entry 2 */
+	.quad 0x0000000000000000	/* 0x43 TLS entry 3 */
+	.quad 0x0000000000000000	/* 0x4b reserved */
+	.quad 0x0000000000000000	/* 0x53 reserved */
+	.quad 0x0000000000000000	/* 0x5b reserved */
+
+	/* __BOOT_KERNEL_CS and __BOOT_KERNEL_DS */
+	.quad 0x00cf9a000000ffff	/* 0x60 kernel 4GB code at 0x00000000 */
+	.quad 0x00cf92000000ffff	/* 0x68 kernel 4GB data at 0x00000000 */
+
+	.fill (GDT_ENTRY_KERNEL_BASE-GDT_ENTRY_BOOT_KERNEL_BASE-2),8,0 
+
+	.quad 0x00cf9a000000ffff	/* 0x500 kernel 4GB code at 0x00000000*/
+	.quad 0x00cf92000000ffff	/* 0x501 kernel 4GB data at 0x00000000*/
+	.quad 0x0000000000000000	/* 0x502 TSS descriptor */
+	.quad 0x0000000000000000	/* 0x503 LDT descriptor */
+
+	/* Segments used for calling PnP BIOS */
+	.quad 0x00c09a0000000000	/* 0x504 32-bit code */
+	.quad 0x00809a0000000000	/* 0x505 16-bit code */
+	.quad 0x0080920000000000	/* 0x506 16-bit data */
+	.quad 0x0080920000000000	/* 0x507 16-bit data */
+	.quad 0x0080920000000000	/* 0x508 16-bit data */
+	/*
+	 * The APM segments have byte granularity and their bases
+	 * and limits are set at run time.
+	 */
+	.quad 0x00409a0000000000	/* 0x509 APM CS    code */
+	.quad 0x00009a0000000000	/* 0x510 APM CS 16 code (16 bit) */
+	.quad 0x0040920000000000	/* 0x511 APM DS    data */
+
+/*
+ * Array of pointers to per-CPU GDTs
+ */
+ENTRY(cpu_gdt_table)
+	.long SYMBOL_NAME(gdt_table)	/* CPU0's GDT */
+#if CONFIG_SMP
+	.fill (NR_CPUS-1),4,0		/* pointer to other CPU's GDT */
+#endif
+	.long	0
+
+/* ------------------------------------------------------------------ */
+#else  /* !CONFIG_MKI */
+
 /*
  * The Global Descriptor Table contains 28 quadwords, per-CPU.
  */
@@ -450,4 +511,4 @@
 #if CONFIG_SMP
 	.fill (NR_CPUS-1)*GDT_ENTRIES,8,0 /* other CPU's GDT */
 #endif
-
+#endif /* !CONFIG_MKI */
--- linux-2.4.25-2mdk/arch/i386/kernel/process.c.win4lin	2004-03-02 00:28:04.000000000 -0500
+++ linux-2.4.25-2mdk/arch/i386/kernel/process.c	2004-06-21 07:48:00.172388192 -0400
@@ -55,6 +55,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");
@@ -721,6 +725,11 @@
 
 	unlazy_fpu(prev_p);
 
+#ifdef CONFIG_MKI
+	if (next_p->mki_task_info)
+		CALL_MKI_HOOK(MKI_HOOK_SWITCH_TO, next_p, NULL);
+#endif /* CONFIG_MKI */
+
 	/*
 	 * Reload esp0, LDT and the page table pointer:
 	 */
--- linux-2.4.25-2mdk/arch/i386/kernel/signal.c.win4lin	2004-03-02 00:28:03.000000000 -0500
+++ linux-2.4.25-2mdk/arch/i386/kernel/signal.c	2004-06-21 07:48:00.173388246 -0400
@@ -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 <linux/suspend.h>
 #include <asm/ucontext.h>
@@ -594,8 +595,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 (current->flags & PF_FREEZE) {
 		refrigerator(PF_FREEZE);
--- linux-2.4.25-2mdk/arch/i386/kernel/smpboot.c.win4lin	2004-03-02 00:28:04.000000000 -0500
+++ linux-2.4.25-2mdk/arch/i386/kernel/smpboot.c	2004-06-21 07:48:00.174388300 -0400
@@ -510,6 +510,11 @@
 	unsigned short ss;
 } stack_start;
 
+extern struct {
+	void * esp;
+	unsigned short ss;
+} boot_stack_start;
+
 static struct task_struct * __init fork_by_hand(void)
 {
 	struct pt_regs regs;
@@ -823,6 +828,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
--- linux-2.4.25-2mdk/arch/i386/kernel/trampoline.S.win4lin	2004-03-02 00:28:03.000000000 -0500
+++ linux-2.4.25-2mdk/arch/i386/kernel/trampoline.S	2004-06-21 07:48:00.175388354 -0400
@@ -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:
@@ -68,7 +69,11 @@
 
 gdt_48:
 	.word	0x0800			# gdt limit = 2048, 256 GDT entries
+#ifdef CONFIG_MKI
+	.long	gdt_table-__PAGE_OFFSET	# gdt base = gdt (first SMP CPU)
+#else
 	.long	cpu_gdt_table-__PAGE_OFFSET	# gdt base = gdt (first SMP CPU)
+#endif
 
 .globl SYMBOL_NAME(trampoline_end)
 SYMBOL_NAME_LABEL(trampoline_end)
--- linux-2.4.25-2mdk/arch/i386/kernel/setup.c.win4lin	2004-03-02 00:28:04.000000000 -0500
+++ linux-2.4.25-2mdk/arch/i386/kernel/setup.c	2004-06-21 07:48:00.177388461 -0400
@@ -3198,6 +3198,14 @@
 	 * and set up the GDT descriptor:
 	 */
 	if (cpu) {
+#ifdef CONFIG_MKI
+#if    GDT_SIZE != PAGE_SIZE
+#error CONFIG_MKI - unexpected GDT_SIZE
+#endif
+		cpu_gdt_table[cpu] =
+			(struct desc_struct *) __get_free_page(GFP_ATOMIC);
+#endif /* CONFIG_MKI */
+
 		memcpy(cpu_gdt_table[cpu], cpu_gdt_table[0], GDT_SIZE);
 		cpu_gdt_descr[cpu].size = GDT_SIZE-1;
 		cpu_gdt_descr[cpu].address = (unsigned long)cpu_gdt_table[cpu];
--- linux-2.4.25-2mdk/arch/i386/kernel/apm.c.win4lin	2004-06-21 07:48:27.033824440 -0400
+++ linux-2.4.25-2mdk/arch/i386/kernel/apm.c	2004-06-21 07:49:04.393800939 -0400
@@ -2020,7 +2020,11 @@
 	apm_bios_entry.offset = apm_info.bios.offset;
 	apm_bios_entry.segment = APM_CS;
 
+#ifdef CONFIG_MKI
+	for (i = 0; i < smp_num_cpus; i++) {
+#else
 	for (i = 0; i < NR_CPUS; i++) {
+#endif
 		set_base(cpu_gdt_table[i][APM_CS >> 3],
 			 __va((unsigned long)apm_info.bios.cseg << 4));
 		set_base(cpu_gdt_table[i][APM_CS_16 >> 3],
--- linux-2.4.25-2mdk/arch/i386/mm/fault.c.win4lin	2004-03-02 00:28:03.000000000 -0500
+++ linux-2.4.25-2mdk/arch/i386/mm/fault.c	2004-06-21 07:48:00.178388515 -0400
@@ -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>
@@ -270,7 +271,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;
 		/* Kernel addresses are always protection faults */
 		tsk->thread.error_code = error_code | (address >= TASK_SIZE);
--- linux-2.4.25-2mdk/arch/i386/config.in.win4lin	2004-03-02 00:28:09.000000000 -0500
+++ linux-2.4.25-2mdk/arch/i386/config.in	2004-06-21 07:48:00.179388568 -0400
@@ -510,6 +510,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 'Make the kernel for install system (only usefull for distro makers)' CONFIG_BOOT_KERNEL
 bool 'Kernel debugging' CONFIG_DEBUG_KERNEL
--- linux-2.4.25-2mdk/arch/i386/Makefile.win4lin	2004-03-02 00:28:04.000000000 -0500
+++ linux-2.4.25-2mdk/arch/i386/Makefile	2004-06-21 07:48:00.179388568 -0400
@@ -1,3 +1,28 @@
+# Added by mki-adapter patch:
+ifdef CONFIG_MKI
+SUBDIRS += arch/i386/mki-adapter
+MOD_SUB_DIRS += arch/i386/mki-adapter
+endif
+# Added by mki-adapter patch:
+ifdef CONFIG_MKI
+SUBDIRS += arch/i386/mki-adapter
+MOD_SUB_DIRS += arch/i386/mki-adapter
+endif
+# Added by mki-adapter patch:
+ifdef CONFIG_MKI
+SUBDIRS += arch/i386/mki-adapter
+MOD_SUB_DIRS += arch/i386/mki-adapter
+endif
+# Added by mki-adapter patch:
+ifdef CONFIG_MKI
+SUBDIRS += arch/i386/mki-adapter
+MOD_SUB_DIRS += arch/i386/mki-adapter
+endif
+# Added by mki-adapter patch:
+ifdef CONFIG_MKI
+SUBDIRS += arch/i386/mki-adapter
+MOD_SUB_DIRS += arch/i386/mki-adapter
+endif
 #
 # i386/Makefile
 #
@@ -116,6 +141,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
 
--- linux-2.4.25-2mdk/arch/i386/mki/Makefile.win4lin	2004-06-21 07:48:00.180388622 -0400
+++ linux-2.4.25-2mdk/arch/i386/mki/Makefile	2004-06-21 07:48:00.180388622 -0400
@@ -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
--- linux-2.4.25-2mdk/arch/i386/mki/mki.c.win4lin	2004-06-21 07:48:00.181388676 -0400
+++ linux-2.4.25-2mdk/arch/i386/mki/mki.c	2004-06-21 07:48:00.181388676 -0400
@@ -0,0 +1,102 @@
+/*
+ * 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>
+
+extern struct desc_struct idt_table[], gdt_table[];
+
+EXPORT_SYMBOL_NOVERS(init_tss);
+EXPORT_SYMBOL_NOVERS(idt_table);
+EXPORT_SYMBOL_NOVERS(idt_descr);
+EXPORT_SYMBOL_NOVERS(gdt_table);
+EXPORT_SYMBOL_NOVERS(cpu_gdt_descr);
+//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);
+#ifdef pte_offset_map     /* HIGHPTE patch present */
+EXPORT_SYMBOL_NOVERS(pte_alloc_map);
+#else
+EXPORT_SYMBOL_NOVERS(pte_alloc);
+#endif	
+#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);
--- linux-2.4.25-2mdk/include/asm-i386/desc.h.win4lin	2004-03-02 00:28:03.000000000 -0500
+++ linux-2.4.25-2mdk/include/asm-i386/desc.h	2004-06-21 07:48:00.181388676 -0400
@@ -8,7 +8,12 @@
 
 #include <asm/mmu.h>
 
+#ifdef CONFIG_MKI
+#define MM_CONTEXT_HAS_LDT_FIELD       1
+extern struct desc_struct *cpu_gdt_table[NR_CPUS];
+#else
 extern struct desc_struct cpu_gdt_table[NR_CPUS][GDT_ENTRIES];
+#endif
 
 struct Xgt_desc_struct {
 	unsigned short size;
--- linux-2.4.25-2mdk/include/asm-i386/mki.h.win4lin	2004-06-21 07:48:00.181388676 -0400
+++ linux-2.4.25-2mdk/include/asm-i386/mki.h	2004-06-21 07:48:00.181388676 -0400
@@ -0,0 +1,45 @@
+/* 
+ * 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
+
+/* This kernel has an LDT field in the context structure */
+#define MM_CONTEXT_HAS_LDT_FIELD	1  
+
+#endif /* INCLUDE_MKI_H */
+#endif /* CONFIG_MKI */
--- linux-2.4.25-2mdk/include/asm-i386/mkiversion.h.win4lin	2004-06-21 07:48:00.182388730 -0400
+++ linux-2.4.25-2mdk/include/asm-i386/mkiversion.h	2004-06-21 07:48:00.181388676 -0400
@@ -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 */
--- linux-2.4.25-2mdk/include/asm-i386/segment.h.win4lin	2004-03-02 00:28:03.000000000 -0500
+++ linux-2.4.25-2mdk/include/asm-i386/segment.h	2004-06-21 07:48:00.182388730 -0400
@@ -1,6 +1,77 @@
 #ifndef _ASM_SEGMENT_H
 #define _ASM_SEGMENT_H
 
+#include <linux/config.h>
+  
+#ifdef CONFIG_MKI
+/*
+ * The layout of the per-CPU GDT under Linux:
+ *
+ *   0 - null
+ *   1 - reserved
+ *   2 - reserved
+ *   3 - reserved
+ *
+ *   4 - default user CS		<==== new cacheline
+ *   5 - default user DS
+ *
+ *  ------- start of TLS (Thread-Local Storage) segments:
+ *
+ *   6 - TLS segment #1			[ glibc's TLS segment ]
+ *   7 - TLS segment #2			[ Wine's %fs Win32 segment ]
+ *   8 - TLS segment #3
+ *   9 - reserved
+ *  10 - reserved
+ *  11 - reserved
+ *  12 - boot time kernel code segment
+ *  13 - boot time kernel data segment
+ *  14 - 499 - fill
+ *
+ *  ------- start of kernel segments:
+ *
+ *  500 - kernel code segment		<==== new cacheline
+ *  501 - kernel data segment
+ *  502 - TSS
+ *  503 - LDT
+ *  504 - PNPBIOS support (16->32 gate)
+ *  505 - PNPBIOS support
+ *  506 - PNPBIOS support
+ *  507 - PNPBIOS support
+ *  508 - PNPBIOS support
+ *  509 - APM BIOS support
+ *  510 - APM BIOS support
+ *  511 - APM BIOS support 
+ */
+#define GDT_ENTRY_BOOT_KERNEL_BASE	12
+
+#define GDT_ENTRY_BOOT_KERNEL_CS	(GDT_ENTRY_BOOT_KERNEL_BASE + 0)
+#define __BOOT_KERNEL_CS (GDT_ENTRY_BOOT_KERNEL_CS * 8)
+
+#define GDT_ENTRY_BOOT_KERNEL_DS	(GDT_ENTRY_BOOT_KERNEL_BASE + 1)
+#define __BOOT_KERNEL_DS (GDT_ENTRY_BOOT_KERNEL_DS * 8)
+
+#define GDT_ENTRY_KERNEL_BASE	500
+
+#define GDT_ENTRY_KERNEL_CS		(GDT_ENTRY_KERNEL_BASE + 0)
+#define __KERNEL_CS (GDT_ENTRY_KERNEL_CS * 8)
+
+#define GDT_ENTRY_KERNEL_DS		(GDT_ENTRY_KERNEL_BASE + 1)
+#define __KERNEL_DS (GDT_ENTRY_KERNEL_DS * 8)
+
+#define GDT_ENTRY_TSS			(GDT_ENTRY_KERNEL_BASE + 2)
+#define GDT_ENTRY_LDT			(GDT_ENTRY_KERNEL_BASE + 3)
+
+#define GDT_ENTRY_PNPBIOS_BASE		(GDT_ENTRY_KERNEL_BASE + 4)
+#define GDT_ENTRY_APMBIOS_BASE		(GDT_ENTRY_KERNEL_BASE + 9)
+
+/*
+ * The GDT has 21 entries but we pad it to cacheline boundary:
+ */
+#define GDT_ENTRIES 512
+
+/* ------------------------------------------------------------------ */
+#else /* !CONFIG_MKI */
+
 /*
  * The layout of the per-CPU GDT under Linux:
  *
@@ -31,25 +102,15 @@
  *  17 - APM BIOS support
  *  18 - APM BIOS support 
  */
-#define GDT_ENTRY_TLS_ENTRIES	3
-#define GDT_ENTRY_TLS_MIN	6
-#define GDT_ENTRY_TLS_MAX 	(GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
-
-#define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES * 8)
-
-#define GDT_ENTRY_DEFAULT_USER_CS	4
-#define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS * 8 + 3)
-
-#define GDT_ENTRY_DEFAULT_USER_DS	5
-#define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS * 8 + 3)
-
 #define GDT_ENTRY_KERNEL_BASE	12
 
 #define GDT_ENTRY_KERNEL_CS		(GDT_ENTRY_KERNEL_BASE + 0)
 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS * 8)
+#define __BOOT_KERNEL_CS  __KERNEL_CS
 
 #define GDT_ENTRY_KERNEL_DS		(GDT_ENTRY_KERNEL_BASE + 1)
 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS * 8)
+#define __BOOT_KERNEL_DS  __KERNEL_DS
 
 #define GDT_ENTRY_TSS			(GDT_ENTRY_KERNEL_BASE + 2)
 #define GDT_ENTRY_LDT			(GDT_ENTRY_KERNEL_BASE + 3)
@@ -61,8 +122,23 @@
  */
 #define GDT_ENTRIES 24
 
+#endif /* !CONFIG_MKI */
+
 #define GDT_SIZE (GDT_ENTRIES * 8)
 
+ 
+#define GDT_ENTRY_TLS_ENTRIES	3
+#define GDT_ENTRY_TLS_MIN	6
+#define GDT_ENTRY_TLS_MAX 	(GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
+
+#define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES * 8)
+
+#define GDT_ENTRY_DEFAULT_USER_CS	4
+#define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS * 8 + 3)
+
+#define GDT_ENTRY_DEFAULT_USER_DS	5
+#define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS * 8 + 3)
+
 /*
  * The interrupt descriptor table has room for 256 idt's,
  * the global descriptor table is dependent on the number
--- linux-2.4.25-2mdk/include/linux/sched.h.win4lin	2004-03-02 01:39:10.000000000 -0500
+++ linux-2.4.25-2mdk/include/linux/sched.h	2004-06-21 07:48:00.183388783 -0400
@@ -534,6 +534,15 @@
 
 	unsigned long ptrace_message;
 	siginfo_t *last_siginfo; /* For ptrace use.  */
+
+#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
+
 };
 
 /*
@@ -721,6 +730,7 @@
     alloc_lock:		SPIN_LOCK_UNLOCKED,				\
     switch_lock:	SPIN_LOCK_UNLOCKED,				\
     journal_info:	NULL,						\
+    MKI_INIT_TASK							\
 }
 
 
--- linux-2.4.25-2mdk/kernel/exit.c.win4lin	2004-03-02 00:28:03.000000000 -0500
+++ linux-2.4.25-2mdk/kernel/exit.c	2004-06-21 07:48:00.184388837 -0400
@@ -24,6 +24,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;
@@ -670,6 +673,9 @@
 		ptrace_notify((PTRACE_EVENT_EXIT << 8) | SIGTRAP);
 
 	acct_process(code);
+#ifdef CONFIG_MKI
+	CALL_MKI_HOOK(MKI_HOOK_EXIT, NULL, NULL);
+#endif
 	__exit_mm(tsk);
 
 	sem_exit();
--- linux-2.4.25-2mdk/kernel/fork.c.win4lin	2004-03-02 00:28:09.000000000 -0500
+++ linux-2.4.25-2mdk/kernel/fork.c	2004-06-21 07:55:08.211708161 -0400
@@ -772,6 +772,11 @@
   	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
--- linux-2.4.25-2mdk/kernel/sched.c.win4lin	2004-03-02 00:28:04.000000000 -0500
+++ linux-2.4.25-2mdk/kernel/sched.c	2004-06-21 07:48:00.186388944 -0400
@@ -32,6 +32,10 @@
 #include <linux/delay.h>
 #include <linux/timer.h>
 #include <linux/suspend.h>
+#ifdef CONFIG_MKI
+#include <asm/mki.h>
+#endif
+
 
 #ifdef CONFIG_NUMA
 #define cpu_to_node_mask(cpu) node_to_cpumask(cpu_to_node(cpu))
@@ -864,6 +868,11 @@
 	struct mm_struct *mm = next->mm;
 	struct mm_struct *oldmm = prev->active_mm;
 
+#ifdef CONFIG_MKI
+	CALL_MKI_HOOK(MKI_HOOK_SWITCH_AWAY, prev, NULL);
+#endif
+
+
 	if (unlikely(!mm)) {
 		next->active_mm = oldmm;
 		atomic_inc(&oldmm->mm_count);
--- linux-2.4.25-2mdk/mm/vmscan.c.win4lin	2004-03-02 00:28:04.000000000 -0500
+++ linux-2.4.25-2mdk/mm/vmscan.c	2004-06-21 07:48:00.187388998 -0400
@@ -35,6 +35,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
@@ -352,9 +357,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();