
From: Eric W. Biederman <ebiederm@xmission.com>

Restore the local apic to virtual wire mode on reboot.

Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/arch/i386/kernel/apic.c    |   30 ++++++++++++++++++++++++++++++
 25-akpm/include/asm-i386/apicdef.h |    1 +
 2 files changed, 31 insertions(+)

diff -puN arch/i386/kernel/apic.c~kexec-apic-virtwire-on-shutdowni386patch arch/i386/kernel/apic.c
--- 25/arch/i386/kernel/apic.c~kexec-apic-virtwire-on-shutdowni386patch	2004-10-16 01:30:50.055890992 -0700
+++ 25-akpm/arch/i386/kernel/apic.c	2004-10-16 01:30:50.060890232 -0700
@@ -220,6 +220,36 @@ void disconnect_bsp_APIC(void)
 		outb(0x70, 0x22);
 		outb(0x00, 0x23);
 	}
+	else {
+		/* Go back to Virtual Wire compatibility mode */
+		unsigned long value;
+
+		/* For the spurious interrupt use vector F, and enable it */
+		value = apic_read(APIC_SPIV);
+		value &= ~APIC_VECTOR_MASK;
+		value |= APIC_SPIV_APIC_ENABLED;
+		value |= 0xf;
+		apic_write_around(APIC_SPIV, value);
+
+		/* For LVT0 make it edge triggered, active high, external and enabled */
+		value = apic_read(APIC_LVT0);
+		value &= ~(APIC_MODE_MASK | APIC_SEND_PENDING |
+			APIC_INPUT_POLARITY | APIC_LVT_REMOTE_IRR |
+			APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED );
+		value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING;
+		value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_EXINT);
+		apic_write_around(APIC_LVT0, value);
+
+		/* For LVT1 make it edge triggered, active high, nmi and enabled */
+		value = apic_read(APIC_LVT1);
+		value &= ~(
+			APIC_MODE_MASK | APIC_SEND_PENDING |
+			APIC_INPUT_POLARITY | APIC_LVT_REMOTE_IRR |
+			APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED);
+		value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING;
+		value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_NMI);
+		apic_write_around(APIC_LVT1, value);
+	}
 }
 
 void disable_local_APIC(void)
diff -puN include/asm-i386/apicdef.h~kexec-apic-virtwire-on-shutdowni386patch include/asm-i386/apicdef.h
--- 25/include/asm-i386/apicdef.h~kexec-apic-virtwire-on-shutdowni386patch	2004-10-16 01:30:50.057890688 -0700
+++ 25-akpm/include/asm-i386/apicdef.h	2004-10-16 01:30:50.061890080 -0700
@@ -86,6 +86,7 @@
 #define			APIC_LVT_REMOTE_IRR		(1<<14)
 #define			APIC_INPUT_POLARITY		(1<<13)
 #define			APIC_SEND_PENDING		(1<<12)
+#define			APIC_MODE_MASK			0x700
 #define			GET_APIC_DELIVERY_MODE(x)	(((x)>>8)&0x7)
 #define			SET_APIC_DELIVERY_MODE(x,y)	(((x)&~0x700)|((y)<<8))
 #define				APIC_MODE_FIXED		0x0
_
