diff -urN kernel-source-2.4.20/Documentation/Configure.help kernel-source-2.4.20-hal/Documentation/Configure.help
--- kernel-source-2.4.20/Documentation/Configure.help Sat Dec 14 19:50:40 2002
+++ kernel-source-2.4.20-hal/Documentation/Configure.help Fri Feb 14 16:10:03 2003
@@ -14905,6 +14905,19 @@
UMLs on a single host). You may choose more than one without
conflict. If you don't need UML networking, say N.
+Virtual Machines
+CONFIG_X86_HAL
+ 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:
+ .
+
Microtek USB scanner support
CONFIG_USB_MICROTEK
Say Y here if you want support for the Microtek X6USB and
diff -urN kernel-source-2.4.20/arch/i386/Makefile kernel-source-2.4.20-hal/arch/i386/Makefile
--- kernel-source-2.4.20/arch/i386/Makefile Thu Nov 28 18:53:09 2002
+++ kernel-source-2.4.20-hal/arch/i386/Makefile Thu Feb 13 14:41:33 2003
@@ -86,6 +86,18 @@
CFLAGS += -march=i486 -malign-functions=0 -malign-jumps=0 -malign-loops=0
endif
+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 $(TOPDIR)/include/asm/eflags_if.h
+AFLAGS += -include $(TOPDIR)/include/asm/eflags_if.h
+endif
+
HEAD := arch/i386/kernel/head.o arch/i386/kernel/init_task.o
SUBDIRS += arch/i386/kernel arch/i386/mm arch/i386/lib
diff -urN kernel-source-2.4.20/arch/i386/boot/Makefile kernel-source-2.4.20-hal/arch/i386/boot/Makefile
--- kernel-source-2.4.20/arch/i386/boot/Makefile Sat Aug 11 18:29:20 2001
+++ kernel-source-2.4.20-hal/arch/i386/boot/Makefile Thu Feb 13 12:40:26 2003
@@ -8,6 +8,10 @@
# Copyright (C) 1994 by Linus Torvalds
#
+ifdef CONFIG_X86_HAL
+AFLAGS += -DNO_X86_HAL_INCLUDES
+endif
+
BOOT_INCL = $(TOPDIR)/include/linux/config.h \
$(TOPDIR)/include/linux/autoconf.h \
$(TOPDIR)/include/asm/boot.h
diff -urN kernel-source-2.4.20/arch/i386/config.in kernel-source-2.4.20-hal/arch/i386/config.in
--- kernel-source-2.4.20/arch/i386/config.in Fri Nov 29 23:49:25 2002
+++ kernel-source-2.4.20-hal/arch/i386/config.in Thu Feb 13 13:52:38 2003
@@ -456,4 +456,20 @@
endmenu
+mainmenu_option next_comment
+comment 'Virtual Machines'
+
+if [ "$CONFIG_HIGHMEM" = "n" -a \
+ "$CONFIG_SMP" = "n" -a \
+ "$CONFIG_M386" = "n" -a \
+ "$CONFIG_MATH_EMULATION" = "y" -a \
+ "$CONFIG_X86_UP_APIC" = "n" ]; then
+ bool 'Compile for plex86 VM (experimental)' CONFIG_X86_HAL
+ if [ "$CONFIG_X86_HAL" = "y" ]; then
+ define_bool CONFIG_DUMMY_KEYB y
+ fi
+fi
+
+endmenu
+
source lib/Config.in
diff -urN kernel-source-2.4.20/arch/i386/kernel/dmi_scan.c kernel-source-2.4.20-hal/arch/i386/kernel/dmi_scan.c
--- kernel-source-2.4.20/arch/i386/kernel/dmi_scan.c Thu Nov 28 18:53:09 2002
+++ kernel-source-2.4.20-hal/arch/i386/kernel/dmi_scan.c Thu Feb 13 13:37:10 2003
@@ -478,7 +478,7 @@
#ifdef CONFIG_VT
if (pm_kbd_request_override == NULL)
{
- pm_kbd_request_override = pckbd_pm_resume;
+ pm_kbd_request_override = kbd_pm_resume;
printk(KERN_INFO "%s machine detected. Mousepad Resume Bug workaround enabled.\n", d->ident);
}
#endif
diff -urN kernel-source-2.4.20/drivers/char/dummy_keyb.c kernel-source-2.4.20-hal/drivers/char/dummy_keyb.c
--- kernel-source-2.4.20/drivers/char/dummy_keyb.c Fri Aug 2 20:39:43 2002
+++ kernel-source-2.4.20-hal/drivers/char/dummy_keyb.c Thu Feb 13 13:32:11 2003
@@ -23,9 +23,17 @@
* CONFIG_VT.
*
*/
+#include
#include
#include
#include
+#include
+
+#ifdef CONFIG_X86_HAL
+void panic_blink(void)
+{
+}
+#endif
void kbd_leds(unsigned char leds)
{
@@ -57,4 +65,9 @@
void __init kbd_init_hw(void)
{
printk("Dummy keyboard driver installed.\n");
+}
+
+int kbd_pm_resume(struct pm_dev *dev, pm_request_t rqst, void *data)
+{
+ return 0;
}
diff -urN kernel-source-2.4.20/include/asm-i386/eflags_if.h kernel-source-2.4.20-hal/include/asm-i386/eflags_if.h
--- kernel-source-2.4.20/include/asm-i386/eflags_if.h Wed Dec 31 19:00:00 1969
+++ kernel-source-2.4.20-hal/include/asm-i386/eflags_if.h Sun Feb 9 12:32:19 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 kernel-source-2.4.20/include/asm-i386/keyboard.h kernel-source-2.4.20-hal/include/asm-i386/keyboard.h
--- kernel-source-2.4.20/include/asm-i386/keyboard.h Thu Nov 22 14:47:23 2001
+++ kernel-source-2.4.20-hal/include/asm-i386/keyboard.h Fri Feb 14 16:21:28 2003
@@ -22,6 +22,26 @@
#define KEYBOARD_IRQ 1
#define DISABLE_KBD_DURING_INTERRUPTS 0
+#ifdef CONFIG_DUMMY_KEYB
+
+extern int kbd_setkeycode(unsigned int scancode, unsigned int keycode);
+extern int kbd_getkeycode(unsigned int scancode);
+extern int kbd_translate(unsigned char scancode, unsigned char *keycode,
+ char raw_mode);
+extern char kbd_unexpected_up(unsigned char keycode);
+extern void kbd_leds(unsigned char leds);
+extern void kbd_init_hw(void);
+extern int kbd_pm_resume(struct pm_dev *, pm_request_t, void *);
+
+#else
+#define kbd_setkeycode pckbd_setkeycode
+#define kbd_getkeycode pckbd_getkeycode
+#define kbd_translate pckbd_translate
+#define kbd_unexpected_up pckbd_unexpected_up
+#define kbd_leds pckbd_leds
+#define kbd_init_hw pckbd_init_hw
+#define kbd_pm_resume pckbd_pm_resume
+
extern int pckbd_setkeycode(unsigned int scancode, unsigned int keycode);
extern int pckbd_getkeycode(unsigned int scancode);
extern int pckbd_translate(unsigned char scancode, unsigned char *keycode,
@@ -29,16 +49,13 @@
extern char pckbd_unexpected_up(unsigned char keycode);
extern void pckbd_leds(unsigned char leds);
extern void pckbd_init_hw(void);
-extern int pckbd_pm_resume(struct pm_dev *, pm_request_t, void *);
+extern int pckbd_pm_resume(struct pm_dev *, pm_request_t, void *);
+#endif
+
extern pm_callback pm_kbd_request_override;
extern unsigned char pckbd_sysrq_xlate[128];
-#define kbd_setkeycode pckbd_setkeycode
-#define kbd_getkeycode pckbd_getkeycode
-#define kbd_translate pckbd_translate
-#define kbd_unexpected_up pckbd_unexpected_up
-#define kbd_leds pckbd_leds
-#define kbd_init_hw pckbd_init_hw
+
#define kbd_sysrq_xlate pckbd_sysrq_xlate
#define SYSRQ_KEY 0x54
diff -urN kernel-source-2.4.20/init/main.c kernel-source-2.4.20-hal/init/main.c
--- kernel-source-2.4.20/init/main.c Mon Aug 5 07:23:29 2002
+++ kernel-source-2.4.20-hal/init/main.c Fri Feb 14 15:44:17 2003
@@ -157,11 +157,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... ");
@@ -192,10 +209,12 @@
loops_per_jiffy &= ~loopbit;
}
+print_bogomips:
+
/* Round the value and print it */
printk("%lu.%02lu BogoMIPS\n",
- loops_per_jiffy/(500000/HZ),
- (loops_per_jiffy/(5000/HZ)) % 100);
+ loops_per_jiffy/LPJ_BOGOMIPS_RATIO,
+ (loops_per_jiffy/(LPJ_BOGOMIPS_RATIO/100)) % 100);
}
static int __init debug_kernel(char *str)