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 Tue Jan 21 17:23:41 2003 @@ -1661,3 +1661,18 @@ bool depends on SMP default y + +menu "Hardware Abstraction Layer" + +config X86_HAL + bool "Compile for HAL (experimental)" + depends on !HIGHMEM && !SMP && !M486 && !M386 && !X86_UP_APIC && !X86_UP_IOAPIC + help + Say Y here _only_ if you are compiling Linux to run inside an + experimental Hardware Abstraction Layer. Say N here unless + you absolutely know what this is for. This will break Linux + running on a real machine for sure. This option has the + following configuration constraints: Pentium or higher, + uniprocessor mode, no apic support. + +endmenu diff -urN linux-2.5.59/arch/i386/kernel/acpi_wakeup.S linux-2.5.59-hal/arch/i386/kernel/acpi_wakeup.S --- linux-2.5.59/arch/i386/kernel/acpi_wakeup.S Tue Jan 14 00:58:23 2003 +++ linux-2.5.59-hal/arch/i386/kernel/acpi_wakeup.S Tue Jan 21 18:35:48 2003 @@ -2,6 +2,7 @@ #include #include #include +#include # # wakeup_code runs in real mode, and at unknown address (determined at run-time). @@ -35,7 +36,7 @@ movw $0x0e00 + 'S', %fs:(0x12) pushl $0 # Kill any dangerous flags - popfl + POPFL movl real_magic - wakeup_code, %eax cmpl $0x12345678, %eax @@ -283,7 +284,7 @@ movl %ebp, saved_context_ebp movl %esi, saved_context_esi movl %edi, saved_context_edi - pushfl ; popl saved_context_eflags + PUSHFL ; popl saved_context_eflags movl $.L1432,saved_eip movl %esp,saved_esp @@ -309,7 +310,7 @@ movl saved_context_esi, %esi movl saved_context_edi, %edi call restore_processor_state - pushl saved_context_eflags ; popfl + pushl saved_context_eflags ; POPFL ret ALIGN diff -urN linux-2.5.59/arch/i386/kernel/cpu/common.c linux-2.5.59-hal/arch/i386/kernel/cpu/common.c --- linux-2.5.59/arch/i386/kernel/cpu/common.c Tue Jan 14 00:58:04 2003 +++ linux-2.5.59-hal/arch/i386/kernel/cpu/common.c Wed Jan 22 02:01:26 2003 @@ -7,6 +7,7 @@ #include #include #include +#include #include "cpu.h" @@ -170,16 +171,16 @@ { u32 f1, f2; - asm("pushfl\n\t" - "pushfl\n\t" + asm( PUSHFL + PUSHFL "popl %0\n\t" "movl %0,%1\n\t" "xorl %2,%0\n\t" "pushl %0\n\t" - "popfl\n\t" - "pushfl\n\t" + POPFL + PUSHFL "popl %0\n\t" - "popfl\n\t" + POPFL : "=&r" (f1), "=&r" (f2) : "ir" (flag)); @@ -473,7 +474,7 @@ /* * Delete NT */ - __asm__("pushfl ; andl $0xffffbfff,(%esp) ; popfl"); + __asm__(PUSHFL " ; andl $0xffffbfff,(%%esp) ; " POPFL : ); /* * Set up and load the per-CPU TSS and LDT diff -urN linux-2.5.59/arch/i386/kernel/entry.S linux-2.5.59-hal/arch/i386/kernel/entry.S --- linux-2.5.59/arch/i386/kernel/entry.S Wed Jan 22 12:25:59 2003 +++ linux-2.5.59-hal/arch/i386/kernel/entry.S Tue Jan 21 18:36:16 2003 @@ -48,6 +48,7 @@ #include #include #include +#include #include "irq_vectors.h" EBX = 0x00 @@ -141,7 +142,7 @@ ENTRY(lcall7) - pushfl # We get a different stack layout with call + PUSHFL # We get a different stack layout with call # gates, which has to be cleaned up later.. pushl %eax SAVE_ALL @@ -163,7 +164,7 @@ jmp resume_userspace ENTRY(lcall27) - pushfl # We get a different stack layout with call + PUSHFL # We get a different stack layout with call # gates, which has to be cleaned up later.. pushl %eax SAVE_ALL @@ -233,7 +234,7 @@ sti pushl $(__USER_DS) pushl %ebp - pushfl + PUSHFL pushl $(__USER_CS) pushl $SYSENTER_RETURN diff -urN linux-2.5.59/arch/i386/kernel/head.S linux-2.5.59-hal/arch/i386/kernel/head.S --- linux-2.5.59/arch/i386/kernel/head.S Tue Jan 14 00:58:06 2003 +++ linux-2.5.59-hal/arch/i386/kernel/head.S Tue Jan 21 18:35:07 2003 @@ -16,6 +16,7 @@ #include #include #include +#include #define OLD_CL_MAGIC_ADDR 0x90020 #define OLD_CL_MAGIC 0xA33F @@ -111,7 +112,7 @@ orw %bx,%bx jz 1f /* Initial CPU cleans BSS */ pushl $0 - popfl + POPFL jmp checkCPUtype 1: #endif CONFIG_SMP @@ -138,7 +139,7 @@ * XXX - best to initialize before switching to protected mode. */ pushl $0 - popfl + POPFL /* * Copy bootup parameters out of the way. First 2kB of * _empty_zero_page is for boot parameters, second 2kB @@ -180,17 +181,17 @@ */ movb $3,X86 # at least 386 - pushfl # push EFLAGS + PUSHFL # push EFLAGS popl %eax # get EFLAGS movl %eax,%ecx # save original EFLAGS xorl $0x240000,%eax # flip AC and ID bits in EFLAGS pushl %eax # copy to EFLAGS - popfl # set EFLAGS - pushfl # get new EFLAGS + POPFL # set EFLAGS + PUSHFL # get new EFLAGS popl %eax # put it in eax xorl %ecx,%eax # change in flags pushl %ecx # restore original EFLAGS - popfl + POPFL testl $0x40000,%eax # check if AC bit changed je is386 diff -urN linux-2.5.59/arch/i386/kernel/suspend_asm.S linux-2.5.59-hal/arch/i386/kernel/suspend_asm.S --- linux-2.5.59/arch/i386/kernel/suspend_asm.S Tue Jan 14 00:58:33 2003 +++ linux-2.5.59-hal/arch/i386/kernel/suspend_asm.S Tue Jan 21 18:36:31 2003 @@ -5,6 +5,7 @@ #include #include #include +#include ENTRY(do_magic) pushl %ebx @@ -21,7 +22,7 @@ movl %ebp, saved_context_ebp movl %esi, saved_context_esi movl %edi, saved_context_edi - pushfl ; popl saved_context_eflags + PUSHFL ; popl saved_context_eflags call do_magic_suspend_2 jmp .L1449 @@ -77,7 +78,7 @@ movl saved_context_esi, %esi movl saved_context_edi, %edi call restore_processor_state - pushl saved_context_eflags ; popfl + pushl saved_context_eflags ; POPFL call do_magic_resume_2 .L1449: popl %ebx @@ -89,4 +90,4 @@ loop2: .quad 0 .previous - \ No newline at end of file + diff -urN linux-2.5.59/drivers/hotplug/cpqphp_nvram.c linux-2.5.59-hal/drivers/hotplug/cpqphp_nvram.c --- linux-2.5.59/drivers/hotplug/cpqphp_nvram.c Tue Jan 14 00:59:15 2003 +++ linux-2.5.59-hal/drivers/hotplug/cpqphp_nvram.c Tue Jan 21 18:25:57 2003 @@ -37,6 +37,7 @@ #include #include #include +#include #include "cpqphp.h" #include "cpqphp_nvram.h" @@ -179,7 +180,7 @@ __asm__ ( "xorl %%ebx,%%ebx\n" \ "xorl %%edx,%%edx\n" \ - "pushf\n" \ + PUSHFL \ "push %%cs\n" \ "cli\n" \ "call *%6\n" diff -urN linux-2.5.59/drivers/pnp/pnpbios/core.c linux-2.5.59-hal/drivers/pnp/pnpbios/core.c --- linux-2.5.59/drivers/pnp/pnpbios/core.c Tue Jan 14 00:58:04 2003 +++ linux-2.5.59-hal/drivers/pnp/pnpbios/core.c Tue Jan 21 18:31:26 2003 @@ -54,6 +54,7 @@ #include #include #include +#include /* @@ -185,11 +186,11 @@ "pushl %%es\n\t" "pushl %%fs\n\t" "pushl %%gs\n\t" - "pushfl\n\t" + PUSHFL "movl %%esp, pnp_bios_fault_esp\n\t" "movl $1f, pnp_bios_fault_eip\n\t" "lcall %5,%6\n\t" - "1:popfl\n\t" + "1:" POPFL "popl %%gs\n\t" "popl %%fs\n\t" "popl %%es\n\t" diff -urN linux-2.5.59/include/asm-i386/if.h linux-2.5.59-hal/include/asm-i386/if.h --- linux-2.5.59/include/asm-i386/if.h Wed Dec 31 19:00:00 1969 +++ linux-2.5.59-hal/include/asm-i386/if.h Wed Jan 22 11:26:59 2003 @@ -0,0 +1,139 @@ +/* + * 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_ + + +#ifndef CONFIG_X86_HAL + +/* For a standard compile, just use the native instructions. */ + +#ifdef __ASSEMBLY__ /* For *.S assembly. */ +#define STI sti +#define CLI cli +#define PUSHFL pushfl +#define POPFL popfl +#else /* For *.C assembly. */ +#define STI "sti \n\t" +#define CLI "cli \n\t" +#define PUSHFL "pushfl \n\t" +#define POPFL "popfl \n\t" +#endif + + +#else /* CONFIG_X86_HAL */ + +/* 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. + */ + +/* cli/sti both work in PVI */ +#ifdef __ASSEMBLY__ /* For *.S assembly. */ +#define STI sti +#define CLI cli +#else /* For *.C assembly. */ +#define STI "sti \n\t" +#define CLI "cli \n\t" +#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. + */ + +#ifdef __ASSEMBLY__ /* For *.S assembly. */ +#define PUSHFL \ + pushfl ; \ + pushfl ; \ + testl $(1<<19), 4(%esp) ; \ + jz 69001f ; \ + orl $(1<<9), 4(%esp) ; \ + jmp 69002f ; \ + 69001: ; \ + andl $~(1<<9), 4(%esp) ; \ + 69002: ; \ + popfl +#else /* For *.C assembly. */ +#define PUSHFL \ + "pushfl \n\t" /* Final eflags stack image. */ \ + "pushfl \n\t" /* For restoring arithmetic flags. */ \ + "testl $(1<<19), 4(%%esp) \n\t" /* Was VIF bit set? */ \ + "jz 69001f \n\t" \ + "orl $(1<<9), 4(%%esp) \n\t" /* Yes: set stack image of IF. */ \ + "jmp 69002f \n\t" \ + "69001: \n\t" /* Use the zip of Lyon France :^) */ \ + "andl $~(1<<9), 4(%%esp) \n\t" /* No: clear stack image of IF. */ \ + "69002: \n\t" \ + "popfl \n\t" /* Restore arithmetic flags. */ +#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). + */ + +#ifdef __ASSEMBLY__ /* For *.S assembly. */ +#define POPFL \ + testl $(1<<9), 0(%esp) ; \ + jz 69003f ; \ + popfl ; \ + sti ; \ + jmp 69004f ; \ + 69003: ; \ + popfl ; \ + cli ; \ + 69004: +#else /* For *.C assembly. */ +#define POPFL \ + "testl $(1<<9), 0(%%esp) \n\t" /* Is IF set on stack image? */ \ + "jz 69003f \n\t" \ + "popfl \n\t" /* Yes: restore from stack and */ \ + "sti \n\t" /* force VIF=1. */ \ + "jmp 69004f \n\t" \ + "69003: \n\t" \ + "popfl \n\t" /* No: restore from stack and */ \ + "cli \n\t" /* force VIF=0. */ \ + "69004: \n\t" +#endif + + +#endif /* CONFIG_X86_HAL */ + + +#endif /* _LINUX_ASM_IF_H_ */ diff -urN linux-2.5.59/include/asm-i386/system.h linux-2.5.59-hal/include/asm-i386/system.h --- linux-2.5.59/include/asm-i386/system.h Tue Jan 14 00:58:03 2003 +++ linux-2.5.59-hal/include/asm-i386/system.h Tue Jan 21 18:34:08 2003 @@ -5,6 +5,7 @@ #include #include #include /* for LOCK_PREFIX */ +#include #ifdef __KERNEL__ @@ -12,7 +13,7 @@ extern void FASTCALL(__switch_to(struct task_struct *prev, struct task_struct *next)); #define switch_to(prev,next,last) do { \ - asm volatile("pushfl\n\t" \ + asm volatile(PUSHFL \ "pushl %%esi\n\t" \ "pushl %%edi\n\t" \ "pushl %%ebp\n\t" \ @@ -25,7 +26,7 @@ "popl %%ebp\n\t" \ "popl %%edi\n\t" \ "popl %%esi\n\t" \ - "popfl\n\t" \ + POPFL \ :"=m" (prev->thread.esp),"=m" (prev->thread.eip) \ :"m" (next->thread.esp),"m" (next->thread.eip), \ "a" (prev), "d" (next)); \ @@ -380,8 +381,8 @@ #define set_wmb(var, value) do { var = value; wmb(); } while (0) /* interrupt control.. */ -#define local_save_flags(x) __asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */) -#define local_irq_restore(x) __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory", "cc") +#define local_save_flags(x) __asm__ __volatile__(PUSHFL " ; popl %0":"=g" (x): /* no input */) +#define local_irq_restore(x) __asm__ __volatile__("pushl %0 ; " POPFL : /* no output */ :"g" (x):"memory", "cc") #define local_irq_disable() __asm__ __volatile__("cli": : :"memory") #define local_irq_enable() __asm__ __volatile__("sti": : :"memory") /* used in the idle loop; sti takes one instruction cycle to complete */ @@ -395,7 +396,7 @@ }) /* For spinlocks etc */ -#define local_irq_save(x) __asm__ __volatile__("pushfl ; popl %0 ; cli":"=g" (x): /* no input */ :"memory") +#define local_irq_save(x) __asm__ __volatile__(PUSHFL " ; popl %0 ; cli":"=g" (x): /* no input */ :"memory") /* * disable hlt during certain critical i/o operations