Sophie

Sophie

distrib > Mandriva > 10.1 > i586 > by-pkgid > bc8d0b4fc4e4a3147f9120628df711d2 > files > 1

kernel-win4lin-2.4.22.24mdk-3-6mdk.src.rpm

diff -auP linux-2.4.22-6mdk/arch/i386/boot/compressed/head.S linux-2.4.22-6mdk-win4lin/arch/i386/boot/compressed/head.S
--- linux-2.4.22-6mdk/arch/i386/boot/compressed/head.S	2000-07-05 12:03:12.000000000 -0700
+++ linux-2.4.22-6mdk-win4lin/arch/i386/boot/compressed/head.S	2003-09-09 14:40:51.000000000 -0700
@@ -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.22-6mdk/arch/i386/boot/compressed/misc.c linux-2.4.22-6mdk-win4lin/arch/i386/boot/compressed/misc.c
--- linux-2.4.22-6mdk/arch/i386/boot/compressed/misc.c	2003-08-25 04:44:39.000000000 -0700
+++ linux-2.4.22-6mdk-win4lin/arch/i386/boot/compressed/misc.c	2003-09-09 14:40:51.000000000 -0700
@@ -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.22-6mdk/arch/i386/boot/setup.S linux-2.4.22-6mdk-win4lin/arch/i386/boot/setup.S
--- linux-2.4.22-6mdk/arch/i386/boot/setup.S	2003-09-07 12:09:25.000000000 -0700
+++ linux-2.4.22-6mdk-win4lin/arch/i386/boot/setup.S	2003-09-09 14:40:51.000000000 -0700
@@ -812,7 +812,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
@@ -1024,7 +1024,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.22-6mdk/arch/i386/config.in linux-2.4.22-6mdk-win4lin/arch/i386/config.in
--- linux-2.4.22-6mdk/arch/i386/config.in	2003-09-07 12:10:15.000000000 -0700
+++ linux-2.4.22-6mdk-win4lin/arch/i386/config.in	2003-09-09 14:40:51.000000000 -0700
@@ -494,6 +494,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
diff -auP linux-2.4.22-6mdk/arch/i386/Makefile linux-2.4.22-6mdk-win4lin/arch/i386/Makefile
--- linux-2.4.22-6mdk/arch/i386/Makefile	2003-09-07 12:09:31.000000000 -0700
+++ linux-2.4.22-6mdk-win4lin/arch/i386/Makefile	2003-09-09 14:40:51.000000000 -0700
@@ -119,6 +119,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.22-6mdk/arch/i386/vmlinux.lds.S linux-2.4.22-6mdk-win4lin/arch/i386/vmlinux.lds.S
--- linux-2.4.22-6mdk/arch/i386/vmlinux.lds.S	2003-09-07 12:10:14.000000000 -0700
+++ linux-2.4.22-6mdk-win4lin/arch/i386/vmlinux.lds.S	2003-09-11 15:31:44.000000000 -0700
@@ -16,7 +16,7 @@
 	LONG(startup_32 - __PAGE_OFFSET)
 #endif
 
-	SHORT(__KERNEL_CS)
+	SHORT(__BOOT_KERNEL_CS)
 	}
 
   .data : {			/* Data */
diff -auP linux-2.4.22-6mdk/arch/i386/kernel/apm.c linux-2.4.22-6mdk-win4lin/arch/i386/kernel/apm.c
diff -auP linux-2.4.22-6mdk/arch/i386/kernel/entry.S linux-2.4.22-6mdk-win4lin/arch/i386/kernel/entry.S
--- linux-2.4.22-6mdk/arch/i386/kernel/entry.S	2003-09-07 12:10:14.000000000 -0700
+++ linux-2.4.22-6mdk-win4lin/arch/i386/kernel/entry.S	2003-09-09 14:40:51.000000000 -0700
@@ -237,6 +237,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:
@@ -277,6 +282,9 @@
 	jmp ret_from_sys_call
 
 	ALIGN
+#ifdef CONFIG_MKI
+ENTRY(mki_process_trapret)
+#endif /* CONFIG_MKI */
 ENTRY(ret_from_intr)
 	GET_CURRENT(%ebx)
 ret_from_exception:
diff -auP linux-2.4.22-6mdk/arch/i386/kernel/head.S linux-2.4.22-6mdk-win4lin/arch/i386/kernel/head.S
--- linux-2.4.22-6mdk/arch/i386/kernel/head.S	2003-09-07 12:10:14.000000000 -0700
+++ linux-2.4.22-6mdk-win4lin/arch/i386/kernel/head.S	2003-09-09 18:06:32.000000000 -0700
@@ -47,7 +47,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
@@ -115,7 +115,7 @@
 #endif
 
 	/* Set up the stack pointer */
-	lss stack_start,%esp
+	lss boot_stack_start,%esp
 
 #ifdef CONFIG_SMP
 	orw  %bx,%bx
@@ -352,6 +352,10 @@
 .data
 ready:	.byte 0
 
+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
@@ -437,21 +441,6 @@
 ENTRY(empty_zero_page)
 	.fill 1024,4,0
 
-.text
-
-/*
- * 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.
- */
-.section .rodata,"a"
-
 ALIGN
 /*
  * This contains typically 140 quadwords, depending on NR_CPUS.
@@ -483,8 +472,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_DS constant in segment.h if more */
+/* entries are added after 0x18 above */
+	.fill __GDT_SLOTS_RESERVED-(4+ENTRIES_AFTER_KERNEL_DS),8,0 
+					/* fill to page boundary */
+	.quad 0x0000000000000000	/* 0x1000 - shadow NULL descriptor */
+
+#ifdef CONFIG_GRKERNSEC_PAX_KERNEXEC
+	.quad 0x00cf9b000000ffff        /* 0x1008 krnl 4GB code at 0x00000000 */
+	.quad 0xc0cf9b400000ffff        /* 0x1010 krnl 4GB code at 0xc0400000 */
+#else
+	.quad 0x0000000000000000        /* 0x1008 not used */
+	.quad 0x00cf9b000000ffff        /* 0x1010 krnl 4GB code at 0x00000000 */
+#endif
+	.quad 0x00cf93000000ffff	/* 0x1018 krnl 4GB data at 0x00000000 */
+	.fill ENTRIES_AFTER_KERNEL_DS,8,0 
+#endif /* CONFIG_MKI */
+
 	.fill NR_CPUS*4,8,0             /* space for TSS's and LDT's */
 
+
 #ifdef CONFIG_GRKERNSEC_PAX_SEGMEXEC
 ENTRY(gdt_table2)
 	.quad 0x0000000000000000        /* NULL descriptor */
@@ -511,5 +520,39 @@
 	.quad 0x00409b0000000000	/* 0x48 APM CS    code */
 	.quad 0x00009b0000000000	/* 0x50 APM CS 16 code (16 bit) */
 	.quad 0x0040930000000000	/* 0x58 APM DS    data */
+
+#ifdef CONFIG_MKI
+/* Increase the ENTRIES_AFTER_KERNEL_DS constant in segment.h if more */
+/* entries are added after 0x18 above */
+	.fill __GDT_SLOTS_RESERVED-(4+ENTRIES_AFTER_KERNEL_DS),8,0 
+					/* fill to page boundary */
+	.quad 0x0000000000000000	/* 0x1000 - shadow NULL descriptor */
+
+#ifdef CONFIG_GRKERNSEC_PAX_KERNEXEC
+	.quad 0x00cf9b000000ffff        /* 0x1008 krnl 4GB code at 0x00000000 */
+	.quad 0xc0cf9b400000ffff        /* 0x1010 krnl 4GB code at 0xc0400000 */
+#else
+	.quad 0x0000000000000000        /* 0x1008 not used */
+	.quad 0x00cf9b000000ffff        /* 0x1010 krnl 4GB code at 0x00000000 */
+#endif
+	.quad 0x00cf93000000ffff	/* 0x1018 krnl 4GB data at 0x00000000 */
+	.fill ENTRIES_AFTER_KERNEL_DS,8,0 
+#endif /* CONFIG_MKI */
+
 	.fill NR_CPUS*4,8,0		/* space for TSS's and LDT's */
 #endif
+
+.text
+
+/*
+ * 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.
+ */
+.section .rodata,"a"
diff -auP linux-2.4.22-6mdk/arch/i386/kernel/process.c linux-2.4.22-6mdk-win4lin/arch/i386/kernel/process.c
--- linux-2.4.22-6mdk/arch/i386/kernel/process.c	2003-09-07 12:10:14.000000000 -0700
+++ linux-2.4.22-6mdk-win4lin/arch/i386/kernel/process.c	2003-09-09 16:24:17.000000000 -0700
@@ -47,6 +47,9 @@
 #include <asm/irq.h>
 #include <asm/desc.h>
 #include <asm/mmu_context.h>
+#ifdef CONFIG_MKI
+#include <asm/mki.h>
+#endif
 #ifdef CONFIG_MATH_EMULATION
 #include <asm/math_emu.h>
 #endif
@@ -735,6 +738,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.22-6mdk/arch/i386/kernel/setup.c linux-2.4.22-6mdk-win4lin/arch/i386/kernel/setup.c
diff -auP linux-2.4.22-6mdk/arch/i386/kernel/signal.c linux-2.4.22-6mdk-win4lin/arch/i386/kernel/signal.c
--- linux-2.4.22-6mdk/arch/i386/kernel/signal.c	2003-09-07 12:09:23.000000000 -0700
+++ linux-2.4.22-6mdk-win4lin/arch/i386/kernel/signal.c	2003-09-09 14:40:51.000000000 -0700
@@ -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>
@@ -593,8 +594,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(0);
diff -auP linux-2.4.22-6mdk/arch/i386/kernel/smpboot.c linux-2.4.22-6mdk-win4lin/arch/i386/kernel/smpboot.c
--- linux-2.4.22-6mdk/arch/i386/kernel/smpboot.c	2003-09-07 12:09:31.000000000 -0700
+++ linux-2.4.22-6mdk-win4lin/arch/i386/kernel/smpboot.c	2003-09-09 14:40:51.000000000 -0700
@@ -507,6 +507,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;
@@ -828,6 +833,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.22-6mdk/arch/i386/kernel/trampoline.S linux-2.4.22-6mdk-win4lin/arch/i386/kernel/trampoline.S
--- linux-2.4.22-6mdk/arch/i386/kernel/trampoline.S	2003-09-07 12:10:14.000000000 -0700
+++ linux-2.4.22-6mdk-win4lin/arch/i386/kernel/trampoline.S	2003-09-09 16:26:05.000000000 -0700
@@ -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, $SYMBOL_NAME(startup_32)-__PAGE_OFFSET
+	ljmpl	$__BOOT_KERNEL_CS, $SYMBOL_NAME(startup_32)-__PAGE_OFFSET
 			# jump to startup_32 in arch/i386/kernel/head.S
 
 idt_48:
diff -auP linux-2.4.22-6mdk/arch/i386/mki/Makefile linux-2.4.22-6mdk-win4lin/arch/i386/mki/Makefile
--- linux-2.4.22-6mdk/arch/i386/mki/Makefile	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.4.22-6mdk-win4lin/arch/i386/mki/Makefile	2003-09-09 14:40:51.000000000 -0700
@@ -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.22-6mdk/arch/i386/mki/mki.c linux-2.4.22-6mdk-win4lin/arch/i386/mki/mki.c
--- linux-2.4.22-6mdk/arch/i386/mki/mki.c	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.4.22-6mdk-win4lin/arch/i386/mki/mki.c	2003-09-09 17:37:09.000000000 -0700
@@ -0,0 +1,97 @@
+/*
+ * 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);
+
+#ifdef CONFIG_SMP
+EXPORT_SYMBOL_NOVERS(mki_kick_if_running);
+#endif CONFIG_SMP
diff -auP linux-2.4.22-6mdk/arch/i386/mm/fault.c linux-2.4.22-6mdk-win4lin/arch/i386/mm/fault.c
--- linux-2.4.22-6mdk/arch/i386/mm/fault.c	2003-09-07 12:10:14.000000000 -0700
+++ linux-2.4.22-6mdk-win4lin/arch/i386/mm/fault.c	2003-09-09 14:40:51.000000000 -0700
@@ -284,7 +284,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
 #ifdef CONFIG_GRKERNSEC_PAX_SEGMEXEC
 		if (current->flags & PF_PAX_SEGMEXEC) {
 
diff -auP linux-2.4.22-6mdk/drivers/ide/ide-io.c linux-2.4.22-6mdk-win4lin/drivers/ide/ide-io.c
diff -auP linux-2.4.22-6mdk/include/asm-i386/desc.h linux-2.4.22-6mdk-win4lin/include/asm-i386/desc.h
--- linux-2.4.22-6mdk/include/asm-i386/desc.h	2003-09-07 15:11:21.000000000 -0700
+++ linux-2.4.22-6mdk-win4lin/include/asm-i386/desc.h	2003-09-09 14:40:51.000000000 -0700
@@ -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.22-6mdk/include/asm-i386/mki.h linux-2.4.22-6mdk-win4lin/include/asm-i386/mki.h
--- linux-2.4.22-6mdk/include/asm-i386/mki.h	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.4.22-6mdk-win4lin/include/asm-i386/mki.h	2003-09-09 16:52:36.000000000 -0700
@@ -0,0 +1,47 @@
+/* 
+ * 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
+
+#ifdef CONFIG_SMP
+/*
+ * For mki-adapter: this version of the MKI has a mki_kick_if_running()
+ * function.
+ */
+#define MKI_HAS_MKI_KICK_IF_RUNNING	1
+extern void mki_kick_if_running(struct task_struct *);
+#endif /* CONFIG_SMP */
+
+/* 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
+
+#endif /* INCLUDE_MKI_H */
+#endif /* CONFIG_MKI */
diff -auP linux-2.4.22-6mdk/include/asm-i386/mkiversion.h linux-2.4.22-6mdk-win4lin/include/asm-i386/mkiversion.h
--- linux-2.4.22-6mdk/include/asm-i386/mkiversion.h	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.4.22-6mdk-win4lin/include/asm-i386/mkiversion.h	2003-09-09 14:40:51.000000000 -0700
@@ -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.22-6mdk/include/asm-i386/segment.h linux-2.4.22-6mdk-win4lin/include/asm-i386/segment.h
--- linux-2.4.22-6mdk/include/asm-i386/segment.h	1997-12-01 10:34:12.000000000 -0800
+++ linux-2.4.22-6mdk-win4lin/include/asm-i386/segment.h	2003-09-09 14:40:51.000000000 -0700
@@ -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.22-6mdk/include/linux/sched.h linux-2.4.22-6mdk-win4lin/include/linux/sched.h
--- linux-2.4.22-6mdk/include/linux/sched.h	2003-09-07 15:11:21.000000000 -0700
+++ linux-2.4.22-6mdk-win4lin/include/linux/sched.h	2003-09-09 16:34:38.000000000 -0700
@@ -461,6 +461,15 @@
 	u8 used_connect:1;	
 	u8 is_writable:1;
 #endif
+
+#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
+
 };
 
 /*
@@ -567,6 +576,7 @@
     blocked:		{{0}},						\
     alloc_lock:		SPIN_LOCK_UNLOCKED,				\
     journal_info:	NULL,						\
+    MKI_INIT_TASK							\
 }
 
 
diff -auP linux-2.4.22-6mdk/kernel/exit.c linux-2.4.22-6mdk-win4lin/kernel/exit.c
--- linux-2.4.22-6mdk/kernel/exit.c	2003-09-07 12:10:11.000000000 -0700
+++ linux-2.4.22-6mdk-win4lin/kernel/exit.c	2003-09-09 16:36:01.000000000 -0700
@@ -21,6 +21,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;
@@ -441,6 +444,10 @@
 	acct_process(code);
 #endif
 
+#ifdef CONFIG_MKI
+	CALL_MKI_HOOK(MKI_HOOK_EXIT, NULL, NULL);
+#endif
+
 #ifdef CONFIG_GRKERNSEC
 	gr_acl_handle_psacct(tsk, code);
 	gr_acl_handle_exit();
diff -auP linux-2.4.22-6mdk/kernel/fork.c linux-2.4.22-6mdk-win4lin/kernel/fork.c
--- linux-2.4.22-6mdk/kernel/fork.c	2003-09-07 12:10:11.000000000 -0700
+++ linux-2.4.22-6mdk-win4lin/kernel/fork.c	2003-09-09 16:37:19.000000000 -0700
@@ -673,6 +673,10 @@
 
 	*p = *current;
 
+#ifdef CONFIG_MKI
+	p->mki_task_info = NULL;
+#endif
+
 	retval = -EAGAIN;
 	/*
 	 * Check if we are over our maximum process limit, but be sure to
diff -auP linux-2.4.22-6mdk/kernel/sched.c linux-2.4.22-6mdk-win4lin/kernel/sched.c
--- linux-2.4.22-6mdk/kernel/sched.c	2003-09-07 12:10:11.000000000 -0700
+++ linux-2.4.22-6mdk-win4lin/kernel/sched.c	2003-09-09 17:13:28.000000000 -0700
@@ -35,6 +35,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);
@@ -382,6 +385,23 @@
 	wake_up_process(p);
 }
 
+
+#if defined(CONFIG_MKI) && defined(CONFIG_SMP)
+/*
+ * If there is a possibility that task p is running in user mode
+ * (per force on a different CPU), then kick that CPU into the 
+ * kernel so that we can deliver MKI events (kind of like signals).
+ */
+void mki_kick_if_running(struct task_struct *p)
+{
+	spin_lock(&runqueue_lock);
+	if (task_has_cpu(p) && p->processor != smp_processor_id())
+		smp_send_reschedule(p->processor);
+	spin_unlock(&runqueue_lock);
+}
+#endif /* CONFIG_MKI && CONFIG_SMP */
+
+
 /**
  * schedule_timeout - sleep until timeout
  * @timeout: timeout value in jiffies
@@ -671,6 +691,9 @@
 	}
 #endif
 	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.22-6mdk/mm/mmap.c linux-2.4.22-6mdk-win4lin/mm/mmap.c
diff -auP linux-2.4.22-6mdk/mm/vmscan.c linux-2.4.22-6mdk-win4lin/mm/vmscan.c
--- linux-2.4.22-6mdk/mm/vmscan.c	2003-09-07 12:09:30.000000000 -0700
+++ linux-2.4.22-6mdk-win4lin/mm/vmscan.c	2003-09-09 14:40:51.000000000 -0700
@@ -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,6 +357,9 @@
 
 	counter = mmlist_nr << 1;
 	do {
+#ifdef CONFIG_MKI
+		CALL_MKI_HOOK(MKI_HOOK_SWAP, (void *)counter, (void *)0);
+#endif
 		if (unlikely(current->need_resched)) {
 			__set_current_state(TASK_RUNNING);
 			schedule();