diff -urN linux-2.5.59/arch/i386/Kconfig linux-2.5.59-hal/arch/i386/Kconfig
--- linux-2.5.59/arch/i386/Kconfig Wed Jan 22 12:25:59 2003
+++ linux-2.5.59-hal/arch/i386/Kconfig Fri Feb 14 21:04:18 2003
@@ -1661,3 +1661,22 @@
bool
depends on SMP
default y
+
+menu "Virtual Machines"
+
+config X86_HAL
+ bool "Compile for plex86 VM (experimental)"
+ depends on MATH_EMULATION && !HIGHMEM && !SMP && !M386 && !X86_UP_APIC && !X86_UP_IOAPIC
+ help
+ Say N here unless you absolutely know you are compiling Linux for
+ use within a Plex86 virtual machine. Otherwise, the resulting
+ kernel will not execute properly on a real machine. If you are
+ compiling to run in a plex86 VM say Y here, in which case you should
+ compile out most all hardware drivers as they are not useful in a VM
+ and having drivers probe for various hardware will likely cause the VM
+ to quit when it sees access to an unhandled device. Please see the
+ following site for more information on compiling for use in a
+ plex86 VM, sample config files, and configuration constraints:
+ .
+
+endmenu
diff -urN linux-2.5.59/arch/i386/Makefile linux-2.5.59-hal/arch/i386/Makefile
--- linux-2.5.59/arch/i386/Makefile Wed Jan 22 12:25:59 2003
+++ linux-2.5.59-hal/arch/i386/Makefile Thu Jan 23 21:46:44 2003
@@ -90,6 +90,19 @@
CFLAGS += $(mflags-y)
AFLAGS += $(mflags-y)
+ifdef CONFIG_X86_HAL
+# On x86, if compiling for the Hardware Abstraction Layer
+# (running Linux as a guest OS in a Virtual Machine),
+# we need to insert some asm macros which redefine
+# the behaviour of instructions which modify the
+# interrupt flag. You are probably not configuring for
+# this mode. For more info, read 'Documentation/x86-hal.txt'.
+# This needs to be the first include any module sees.
+CFLAGS += -include include/asm/eflags_if.h
+AFLAGS += -include include/asm/eflags_if.h
+AFLAGS_vmlinux.lds.o += -DNO_X86_HAL_INCLUDES
+endif
+
boot := arch/i386/boot
.PHONY: zImage bzImage compressed zlilo bzlilo zdisk bzdisk install \
diff -urN linux-2.5.59/arch/i386/boot/Makefile linux-2.5.59-hal/arch/i386/boot/Makefile
--- linux-2.5.59/arch/i386/boot/Makefile Tue Jan 14 00:58:35 2003
+++ linux-2.5.59-hal/arch/i386/boot/Makefile Wed Jan 22 22:52:40 2003
@@ -32,6 +32,10 @@
host-progs := tools/build
+ifdef CONFIG_X86_HAL
+AFLAGS += -DNO_X86_HAL_INCLUDES
+endif
+
# ---------------------------------------------------------------------------
$(obj)/zImage: IMAGE_OFFSET := 0x1000
diff -urN linux-2.5.59/include/asm-i386/eflags_if.h linux-2.5.59-hal/include/asm-i386/eflags_if.h
--- linux-2.5.59/include/asm-i386/eflags_if.h Wed Dec 31 19:00:00 1969
+++ linux-2.5.59-hal/include/asm-i386/eflags_if.h Thu Jan 30 21:04:59 2003
@@ -0,0 +1,162 @@
+#ifndef NO_X86_HAL_INCLUDES
+/*
+ * Routines to manipulate the interrupt flag (EFLAGS.IF). Abstracting
+ * them, makes it easier to compile for a hardware abstraction layer (HAL).
+ *
+ * (c) 2003 Kevin P. Lawton
+ */
+
+#ifndef _LINUX_ASM_IF_H_
+#define _LINUX_ASM_IF_H_
+
+
+/* NOTE: This file is directly included via the "-include include/asm/if.h"
+ * option conditionally added to the compiler flags by the top Makefile when
+ * CONFIG_X86_HAL is defined. None of the header files have been included
+ * at this point.
+ */
+
+/* For a HAL (Hardware Abstraction Layer) compile, the kernel is executed
+ * at PL=3 using PVI (Protected mode Virtual Interrupts), which are the
+ * analog to VME for v86 code. For some reason, The Creators stopped short of
+ * implementing proper IF handling for PUSHF/POPF for PVI, but STI/CLI are
+ * fine. So we have to complete the PVI semantics using the following
+ * sequences.
+ */
+
+/* Shield your eyes. These macros make it possible to use the same
+ * code for asm or C inline asm, with all the quoting, comma, and
+ * newline issues. Q1 is for lines with no commas, and Q2 is for lines
+ * with one comma.
+ */
+#ifdef __ASSEMBLY__
+#define Q1(s0) s0
+#define Q2(s0, s1) s0, s1
+#else
+#define Q1(s0) #s0 "\n\t"
+#define Q2(s0, s1) #s0 "," #s1 "\n\t"
+#endif
+
+
+#ifndef __ASSEMBLY__
+__asm__ (
+#endif
+
+ Q1(.macro cli)
+ Q1(.byte 0xfa) /* cli (native instruction works fine in PVI) */
+ Q1(.endm)
+
+ Q1(.macro sti)
+ Q1(.byte 0xfb) /* sti (native instruction works fine in PVI) */
+ Q1(.endm)
+
+ Q1(.macro iret)
+ Q1(.byte 0xf0) /* LOCK: prefix will cause a fault. */
+ Q1(.byte 0xcf) /* iret */
+ Q1(.endm)
+
+#ifndef __ASSEMBLY__
+ );
+#endif
+
+
+
+/* PUSHFL:
+ * When execution is monitored using PVI (Protected mode Virtual Interrupts),
+ * we have to complete the PVI semantics of the PUSHFL instruction, as
+ * per behaviour of VME.
+ *
+ * b19 b9
+ * CPU image of eflags: VIF IF
+ * |
+ * +------------+
+ * |
+ * v
+ * Stack image of eflags: VIF IF
+ *
+ * Notes: VIF on the stack image could be cleared, if it matters.
+ */
+
+#ifndef __ASSEMBLY__
+__asm__ (
+#endif
+
+ Q1( .macro pushfl)
+ Q1( .byte 0x9c) /* (pushfl) Final eflags stack image. */
+ Q1( .byte 0x9c) /* (pushfl) For restoring arith flags. */
+ Q2( testl $(1<<19), 4(%esp)) /* Was VIF bit set? */
+ Q1( jz 69001f)
+ Q2( orl $(1<<9), 4(%esp)) /* Yes: set stack image of IF. */
+ Q1( jmp 69002f)
+ Q1(69001:) /* Use the zip of Lyon France :^} */
+ Q2( andl $~(1<<9), 4(%esp)) /* No: clear stack image of IF. */
+ Q1(69002:)
+ Q1( .byte 0x9d) /* (popfl) Restore arithmetic flags. */
+ Q1( .endm)
+
+ /* The user may use pushf with an implicit size. Just expand that
+ * to the previous macro.
+ */
+ Q1(.macro pushf)
+ Q1(pushfl)
+ Q1(.endm)
+
+#ifndef __ASSEMBLY__
+ );
+#endif
+
+
+
+/* POPFL:
+ * When execution is monitored using PVI (Protected mode Virtual Interrupts),
+ * we have to complete the PVI semantics of the POPFL instruction, as
+ * per behaviour of VME.
+ *
+ * b19 b9
+ * Stack image of eflags: VIF IF
+ * |
+ * +------------+
+ * |
+ * v
+ * CPU image of eflags: VIF IF
+ *
+ * Notes: IF of the eflags register retains its previous value, which
+ * should be 1 (when monitored down to PL3, the processor ignores this
+ * bit in a POPF).
+ */
+
+#ifndef __ASSEMBLY__
+__asm__ (
+#endif
+
+ Q1( .macro popfl)
+ Q2( testl $(1<<9), 0(%esp)) /* Is IF set on stack image? */
+ Q1( jz 69003f)
+ Q1( .byte 0x9d) /* (popfl) Yes: restore from stack and */
+ Q1( sti) /* force VIF=1. */
+ Q1( jmp 69004f)
+ Q1(69003:)
+ Q1( .byte 0x9d) /* (popfl) No: restore from stack and */
+ Q1( cli) /* force VIF=0. */
+ Q1(69004:)
+ Q1( .endm)
+
+ /* The user may use popf with an implicit size. Just expand that
+ * to the previous macro.
+ */
+ Q1(.macro popf)
+ Q1(popfl)
+ Q1(.endm)
+
+#ifndef __ASSEMBLY__
+ );
+#endif
+
+/* Get rid of quoting macros - good housekeeping. */
+#undef Q1
+#undef Q2
+
+
+#endif /* _LINUX_ASM_IF_H_ */
+
+#endif /* NO_X86_HAL_INCLUDES */
diff -urN linux-2.5.59/init/main.c linux-2.5.59-hal/init/main.c
--- linux-2.5.59/init/main.c Wed Jan 22 12:26:02 2003
+++ linux-2.5.59-hal/init/main.c Fri Feb 14 20:31:01 2003
@@ -159,11 +159,28 @@
better than 1% */
#define LPS_PREC 8
+#define LPJ_BOGOMIPS_RATIO (500000/HZ)
+static unsigned long bogomips = 0;
+
+static int __init bogomips_setup(char *str)
+{
+ bogomips = simple_strtoul(str, 0, 0);
+ loops_per_jiffy = bogomips * LPJ_BOGOMIPS_RATIO;
+ return 1;
+}
+
+__setup("bogomips=", bogomips_setup);
+
void __init calibrate_delay(void)
{
unsigned long ticks, loopbit;
int lps_precision = LPS_PREC;
+ /* If the kernel was passed a bogomips= option, calibration is calculated
+ * from that - nothing left to do.
+ */
+ if ( bogomips ) goto print_bogomips;
+
loops_per_jiffy = (1<<12);
printk("Calibrating delay loop... ");
@@ -193,6 +210,8 @@
if (jiffies != ticks) /* longer than 1 tick */
loops_per_jiffy &= ~loopbit;
}
+
+print_bogomips:
/* Round the value and print it */
printk("%lu.%02lu BogoMIPS\n",