Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Apr 2012 20:04:31 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r234144 - in stable/9/sys: amd64/amd64 conf i386/conf i386/i386 i386/include kern pc98/pc98 x86/isa x86/x86
Message-ID:  <201204112004.q3BK4VR2093267@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Wed Apr 11 20:04:31 2012
New Revision: 234144
URL: http://svn.freebsd.org/changeset/base/234144

Log:
  MFC 232744,232747,233031:
  - Allow a native i386 kernel to be built with 'nodevice atpic'.  Just as on
    amd64, if 'device isa' is present quiesce the 8259A's during boot and
    resume from suspend.
  - Move i386's intr_machdep.c to the x86 tree and share it with amd64.
  - Merge r232744 changes to pc98.
    (Allow a kernel to be built with 'nodevice atpic'.)
  - Move ICU related defines from x86/isa/atpic.c to x86/isa/icu.h and
    use them in x86/x86/intr_machdep.c.
  
  Note, I normally would have merged 232747 separately, but 233031 assumed
  232747 was already merged and 232744 needs to be merged with 233031.

Added:
  stable/9/sys/x86/x86/intr_machdep.c
     - copied, changed from r232747, head/sys/x86/x86/intr_machdep.c
Deleted:
  stable/9/sys/amd64/amd64/intr_machdep.c
  stable/9/sys/i386/i386/intr_machdep.c
Modified:
  stable/9/sys/conf/files.amd64
  stable/9/sys/conf/files.i386
  stable/9/sys/conf/files.pc98
  stable/9/sys/i386/i386/exception.s
  stable/9/sys/i386/i386/machdep.c
  stable/9/sys/i386/include/intr_machdep.h
  stable/9/sys/pc98/pc98/machdep.c
  stable/9/sys/x86/isa/atpic.c
  stable/9/sys/x86/isa/icu.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/amd64/include/xen/   (props changed)
  stable/9/sys/boot/   (props changed)
  stable/9/sys/boot/i386/efi/   (props changed)
  stable/9/sys/boot/ia64/efi/   (props changed)
  stable/9/sys/boot/ia64/ski/   (props changed)
  stable/9/sys/boot/powerpc/boot1.chrp/   (props changed)
  stable/9/sys/boot/powerpc/ofw/   (props changed)
  stable/9/sys/cddl/contrib/opensolaris/   (props changed)
  stable/9/sys/conf/   (props changed)
  stable/9/sys/contrib/dev/acpica/   (props changed)
  stable/9/sys/contrib/octeon-sdk/   (props changed)
  stable/9/sys/contrib/pf/   (props changed)
  stable/9/sys/contrib/x86emu/   (props changed)
  stable/9/sys/fs/   (props changed)
  stable/9/sys/fs/ntfs/   (props changed)
  stable/9/sys/i386/conf/XENHVM   (props changed)
  stable/9/sys/kern/subr_witness.c   (props changed)

Modified: stable/9/sys/conf/files.amd64
==============================================================================
--- stable/9/sys/conf/files.amd64	Wed Apr 11 19:58:29 2012	(r234143)
+++ stable/9/sys/conf/files.amd64	Wed Apr 11 20:04:31 2012	(r234144)
@@ -112,7 +112,6 @@ amd64/amd64/gdb_machdep.c	optional	gdb
 amd64/amd64/identcpu.c		standard
 amd64/amd64/in_cksum.c		optional	inet | inet6
 amd64/amd64/initcpu.c		standard
-amd64/amd64/intr_machdep.c	standard
 amd64/amd64/io.c		optional	io
 amd64/amd64/legacy.c		standard
 amd64/amd64/locore.S		standard	no-obj
@@ -465,7 +464,7 @@ x86/cpufreq/p4tcc.c		optional	cpufreq
 x86/isa/atpic.c			optional	atpic isa
 x86/isa/atrtc.c			standard
 x86/isa/clock.c			standard
-x86/isa/elcr.c			standard
+x86/isa/elcr.c			optional	atpic isa | mptable
 x86/isa/isa.c			standard
 x86/isa/isa_dma.c		standard
 x86/isa/nmi.c			standard
@@ -474,6 +473,7 @@ x86/pci/pci_bus.c		optional	pci
 x86/pci/qpi.c			optional	pci
 x86/x86/busdma_machdep.c	standard
 x86/x86/dump_machdep.c		standard
+x86/x86/intr_machdep.c		standard
 x86/x86/io_apic.c		standard
 x86/x86/local_apic.c		standard
 x86/x86/mca.c			standard

Modified: stable/9/sys/conf/files.i386
==============================================================================
--- stable/9/sys/conf/files.i386	Wed Apr 11 19:58:29 2012	(r234143)
+++ stable/9/sys/conf/files.i386	Wed Apr 11 20:04:31 2012	(r234144)
@@ -404,7 +404,6 @@ i386/i386/i686_mem.c		optional mem
 i386/i386/identcpu.c		standard
 i386/i386/in_cksum.c		optional inet | inet6
 i386/i386/initcpu.c		standard
-i386/i386/intr_machdep.c	standard
 i386/i386/io.c			optional io
 i386/i386/k6_mem.c		optional mem
 i386/i386/legacy.c		optional native
@@ -515,9 +514,9 @@ x86/cpufreq/p4tcc.c		optional cpufreq
 x86/cpufreq/powernow.c		optional cpufreq
 x86/cpufreq/smist.c		optional cpufreq
 x86/isa/atpic.c			optional atpic	
-x86/isa/atrtc.c			optional atpic
+x86/isa/atrtc.c			optional native
 x86/isa/clock.c			optional native
-x86/isa/elcr.c			standard
+x86/isa/elcr.c			optional atpic | apic native
 x86/isa/isa.c			optional isa
 x86/isa/isa_dma.c		optional isa
 x86/isa/nmi.c			standard
@@ -526,6 +525,7 @@ x86/pci/pci_bus.c		optional pci
 x86/pci/qpi.c			optional pci
 x86/x86/busdma_machdep.c	standard
 x86/x86/dump_machdep.c		standard
+x86/x86/intr_machdep.c		standard
 x86/x86/io_apic.c		optional apic
 x86/x86/local_apic.c		optional apic
 x86/x86/mca.c			standard

Modified: stable/9/sys/conf/files.pc98
==============================================================================
--- stable/9/sys/conf/files.pc98	Wed Apr 11 19:58:29 2012	(r234143)
+++ stable/9/sys/conf/files.pc98	Wed Apr 11 20:04:31 2012	(r234144)
@@ -144,7 +144,6 @@ i386/i386/i686_mem.c		optional mem
 i386/i386/identcpu.c		standard
 i386/i386/in_cksum.c		optional inet | inet6
 i386/i386/initcpu.c		standard
-i386/i386/intr_machdep.c	standard
 i386/i386/io.c			optional io
 i386/i386/k6_mem.c		optional mem
 i386/i386/legacy.c		standard
@@ -227,7 +226,7 @@ pc98/cbus/gdc.c			optional gdc
 pc98/cbus/nmi.c			standard
 pc98/cbus/olpt.c		optional olpt
 pc98/cbus/pckbd.c		optional pckbd
-pc98/cbus/pcrtc.c		optional atpic
+pc98/cbus/pcrtc.c		standard
 pc98/cbus/pmc.c			optional pmc
 pc98/cbus/scgdcrndr.c		optional sc gdc
 pc98/cbus/scterm-sck.c		optional sc
@@ -251,6 +250,7 @@ x86/isa/isa.c			optional isa
 x86/pci/pci_bus.c		optional pci
 x86/x86/busdma_machdep.c	standard
 x86/x86/dump_machdep.c		standard
+x86/x86/intr_machdep.c		standard
 x86/x86/io_apic.c		optional apic
 x86/x86/local_apic.c		optional apic
 x86/x86/mca.c			standard

Modified: stable/9/sys/i386/i386/exception.s
==============================================================================
--- stable/9/sys/i386/i386/exception.s	Wed Apr 11 19:58:29 2012	(r234143)
+++ stable/9/sys/i386/i386/exception.s	Wed Apr 11 20:04:31 2012	(r234144)
@@ -35,6 +35,7 @@
  */
 
 #include "opt_apic.h"
+#include "opt_atpic.h"
 #include "opt_hwpmc_hooks.h"
 #include "opt_kdtrace.h"
 #include "opt_npx.h"
@@ -299,14 +300,18 @@ ENTRY(fork_trampoline)
 	SUPERALIGN_TEXT
 MCOUNT_LABEL(bintr)
 
+#ifdef DEV_ATPIC
 #include <i386/i386/atpic_vector.s>
+#endif
 
-#ifdef DEV_APIC
+#if defined(DEV_APIC) && defined(DEV_ATPIC)
 	.data
 	.p2align 4
 	.text
 	SUPERALIGN_TEXT
+#endif
 
+#ifdef DEV_APIC
 #include <i386/i386/apic_vector.s>
 #endif
 

Modified: stable/9/sys/i386/i386/machdep.c
==============================================================================
--- stable/9/sys/i386/i386/machdep.c	Wed Apr 11 19:58:29 2012	(r234143)
+++ stable/9/sys/i386/i386/machdep.c	Wed Apr 11 20:04:31 2012	(r234144)
@@ -40,7 +40,9 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include "opt_apic.h"
 #include "opt_atalk.h"
+#include "opt_atpic.h"
 #include "opt_compat.h"
 #include "opt_cpu.h"
 #include "opt_ddb.h"
@@ -135,6 +137,10 @@ __FBSDID("$FreeBSD$");
 #include <machine/smp.h>
 #endif
 
+#ifdef DEV_APIC
+#include <machine/apicvar.h>
+#endif
+
 #ifdef DEV_ISA
 #include <x86/isa/icu.h>
 #endif
@@ -2683,8 +2689,22 @@ init386(first)
 		printf("WARNING: loader(8) metadata is missing!\n");
 
 #ifdef DEV_ISA
+#ifdef DEV_ATPIC
 	elcr_probe();
 	atpic_startup();
+#else
+	/* Reset and mask the atpics and leave them shut down. */
+	atpic_reset();
+
+	/*
+	 * Point the ICU spurious interrupt vectors at the APIC spurious
+	 * interrupt handler.
+	 */
+	setidt(IDT_IO_INTS + 7, IDTVEC(spuriousint), SDT_SYS386IGT, SEL_KPL,
+	    GSEL(GCODE_SEL, SEL_KPL));
+	setidt(IDT_IO_INTS + 15, IDTVEC(spuriousint), SDT_SYS386IGT, SEL_KPL,
+	    GSEL(GCODE_SEL, SEL_KPL));
+#endif
 #endif
 
 #ifdef DDB
@@ -2942,8 +2962,22 @@ init386(first)
 		printf("WARNING: loader(8) metadata is missing!\n");
 
 #ifdef DEV_ISA
+#ifdef DEV_ATPIC
 	elcr_probe();
 	atpic_startup();
+#else
+	/* Reset and mask the atpics and leave them shut down. */
+	atpic_reset();
+
+	/*
+	 * Point the ICU spurious interrupt vectors at the APIC spurious
+	 * interrupt handler.
+	 */
+	setidt(IDT_IO_INTS + 7, IDTVEC(spuriousint), SDT_SYS386IGT, SEL_KPL,
+	    GSEL(GCODE_SEL, SEL_KPL));
+	setidt(IDT_IO_INTS + 15, IDTVEC(spuriousint), SDT_SYS386IGT, SEL_KPL,
+	    GSEL(GCODE_SEL, SEL_KPL));
+#endif
 #endif
 
 #ifdef DDB

Modified: stable/9/sys/i386/include/intr_machdep.h
==============================================================================
--- stable/9/sys/i386/include/intr_machdep.h	Wed Apr 11 19:58:29 2012	(r234143)
+++ stable/9/sys/i386/include/intr_machdep.h	Wed Apr 11 20:04:31 2012	(r234144)
@@ -123,6 +123,9 @@ struct trapframe;
 extern struct mtx icu_lock;
 extern int elcr_found;
 
+#ifndef DEV_ATPIC
+void	atpic_reset(void);
+#endif
 /* XXX: The elcr_* prototypes probably belong somewhere else. */
 int	elcr_probe(void);
 enum intr_trigger elcr_read_trigger(u_int irq);

Modified: stable/9/sys/pc98/pc98/machdep.c
==============================================================================
--- stable/9/sys/pc98/pc98/machdep.c	Wed Apr 11 19:58:29 2012	(r234143)
+++ stable/9/sys/pc98/pc98/machdep.c	Wed Apr 11 20:04:31 2012	(r234144)
@@ -40,7 +40,9 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include "opt_apic.h"
 #include "opt_atalk.h"
+#include "opt_atpic.h"
 #include "opt_compat.h"
 #include "opt_cpu.h"
 #include "opt_ddb.h"
@@ -132,6 +134,10 @@ __FBSDID("$FreeBSD$");
 #include <machine/smp.h>
 #endif
 
+#ifdef DEV_APIC
+#include <machine/apicvar.h>
+#endif
+
 #ifdef DEV_ISA
 #include <x86/isa/icu.h>
 #endif
@@ -2269,7 +2275,21 @@ init386(first)
 		printf("WARNING: loader(8) metadata is missing!\n");
 
 #ifdef DEV_ISA
+#ifdef DEV_ATPIC
 	atpic_startup();
+#else
+	/* Reset and mask the atpics and leave them shut down. */
+	atpic_reset();
+
+	/*
+	 * Point the ICU spurious interrupt vectors at the APIC spurious
+	 * interrupt handler.
+	 */
+	setidt(IDT_IO_INTS + 7, IDTVEC(spuriousint), SDT_SYS386IGT, SEL_KPL,
+	    GSEL(GCODE_SEL, SEL_KPL));
+	setidt(IDT_IO_INTS + 15, IDTVEC(spuriousint), SDT_SYS386IGT, SEL_KPL,
+	    GSEL(GCODE_SEL, SEL_KPL));
+#endif
 #endif
 
 #ifdef DDB

Modified: stable/9/sys/x86/isa/atpic.c
==============================================================================
--- stable/9/sys/x86/isa/atpic.c	Wed Apr 11 19:58:29 2012	(r234143)
+++ stable/9/sys/x86/isa/atpic.c	Wed Apr 11 20:04:31 2012	(r234144)
@@ -72,48 +72,6 @@ __FBSDID("$FreeBSD$");
 #define	MASTER	0
 #define	SLAVE	1
 
-/*
- * PC-98 machines wire the slave 8259A to pin 7 on the master PIC, and
- * PC-AT machines wire the slave PIC to pin 2 on the master PIC.
- */
-#ifdef PC98
-#define	ICU_SLAVEID	7
-#else
-#define	ICU_SLAVEID	2
-#endif
-
-/*
- * Determine the base master and slave modes not including auto EOI support.
- * All machines that FreeBSD supports use 8086 mode.
- */
-#ifdef PC98
-/*
- * PC-98 machines do not support auto EOI on the second PIC.  Also, it
- * seems that PC-98 machine PICs use buffered mode, and the master PIC
- * uses special fully nested mode.
- */
-#define	BASE_MASTER_MODE	(ICW4_SFNM | ICW4_BUF | ICW4_MS | ICW4_8086)
-#define	BASE_SLAVE_MODE		(ICW4_BUF | ICW4_8086)
-#else
-#define	BASE_MASTER_MODE	ICW4_8086
-#define	BASE_SLAVE_MODE		ICW4_8086
-#endif
-
-/* Enable automatic EOI if requested. */
-#ifdef AUTO_EOI_1
-#define	MASTER_MODE		(BASE_MASTER_MODE | ICW4_AEOI)
-#else
-#define	MASTER_MODE		BASE_MASTER_MODE
-#endif
-#ifdef AUTO_EOI_2
-#define	SLAVE_MODE		(BASE_SLAVE_MODE | ICW4_AEOI)
-#else
-#define	SLAVE_MODE		BASE_SLAVE_MODE
-#endif
-
-#define	IRQ_MASK(irq)		(1 << (irq))
-#define	IMEN_MASK(ai)		(IRQ_MASK((ai)->at_irq))
-
 #define	NUM_ISA_IRQS		16
 
 static void	atpic_init(void *dummy);

Modified: stable/9/sys/x86/isa/icu.h
==============================================================================
--- stable/9/sys/x86/isa/icu.h	Wed Apr 11 19:58:29 2012	(r234143)
+++ stable/9/sys/x86/isa/icu.h	Wed Apr 11 20:04:31 2012	(r234144)
@@ -47,6 +47,48 @@
 #define	ICU_IMR_OFFSET	1
 #endif
 
+/*
+ * PC-98 machines wire the slave 8259A to pin 7 on the master PIC, and
+ * PC-AT machines wire the slave PIC to pin 2 on the master PIC.
+ */
+#ifdef PC98
+#define	ICU_SLAVEID	7
+#else
+#define	ICU_SLAVEID	2
+#endif
+
+/*
+ * Determine the base master and slave modes not including auto EOI support.
+ * All machines that FreeBSD supports use 8086 mode.
+ */
+#ifdef PC98
+/*
+ * PC-98 machines do not support auto EOI on the second PIC.  Also, it
+ * seems that PC-98 machine PICs use buffered mode, and the master PIC
+ * uses special fully nested mode.
+ */
+#define	BASE_MASTER_MODE	(ICW4_SFNM | ICW4_BUF | ICW4_MS | ICW4_8086)
+#define	BASE_SLAVE_MODE		(ICW4_BUF | ICW4_8086)
+#else
+#define	BASE_MASTER_MODE	ICW4_8086
+#define	BASE_SLAVE_MODE		ICW4_8086
+#endif
+
+/* Enable automatic EOI if requested. */
+#ifdef AUTO_EOI_1
+#define	MASTER_MODE		(BASE_MASTER_MODE | ICW4_AEOI)
+#else
+#define	MASTER_MODE		BASE_MASTER_MODE
+#endif
+#ifdef AUTO_EOI_2
+#define	SLAVE_MODE		(BASE_SLAVE_MODE | ICW4_AEOI)
+#else
+#define	SLAVE_MODE		BASE_SLAVE_MODE
+#endif
+
+#define	IRQ_MASK(irq)		(1 << (irq))
+#define	IMEN_MASK(ai)		(IRQ_MASK((ai)->at_irq))
+
 void	atpic_handle_intr(u_int vector, struct trapframe *frame);
 void	atpic_startup(void);
 

Copied and modified: stable/9/sys/x86/x86/intr_machdep.c (from r232747, head/sys/x86/x86/intr_machdep.c)
==============================================================================
--- head/sys/x86/x86/intr_machdep.c	Fri Mar  9 20:43:29 2012	(r232747, copy source)
+++ stable/9/sys/x86/x86/intr_machdep.c	Wed Apr 11 20:04:31 2012	(r234144)
@@ -63,8 +63,12 @@
 #include <machine/frame.h>
 #include <dev/ic/i8259.h>
 #include <x86/isa/icu.h>
+#ifdef PC98
+#include <pc98/cbus/cbus.h>
+#else
 #include <x86/isa/isa.h>
 #endif
+#endif
 
 #define	MAX_STRAY_LOG	5
 
@@ -391,15 +395,15 @@ atpic_reset(void)
 
 	outb(IO_ICU1, ICW1_RESET | ICW1_IC4);
 	outb(IO_ICU1 + ICU_IMR_OFFSET, IDT_IO_INTS);
-	outb(IO_ICU1 + ICU_IMR_OFFSET, 1 << 2);
-	outb(IO_ICU1 + ICU_IMR_OFFSET, ICW4_8086);
+	outb(IO_ICU1 + ICU_IMR_OFFSET, IRQ_MASK(ICU_SLAVEID));
+	outb(IO_ICU1 + ICU_IMR_OFFSET, MASTER_MODE);
 	outb(IO_ICU1 + ICU_IMR_OFFSET, 0xff);
 	outb(IO_ICU1, OCW3_SEL | OCW3_RR);
 
 	outb(IO_ICU2, ICW1_RESET | ICW1_IC4);
 	outb(IO_ICU2 + ICU_IMR_OFFSET, IDT_IO_INTS + 8);
-	outb(IO_ICU2 + ICU_IMR_OFFSET, 2);
-	outb(IO_ICU2 + ICU_IMR_OFFSET, ICW4_8086);
+	outb(IO_ICU2 + ICU_IMR_OFFSET, ICU_SLAVEID);
+	outb(IO_ICU2 + ICU_IMR_OFFSET, SLAVE_MODE);
 	outb(IO_ICU2 + ICU_IMR_OFFSET, 0xff);
 	outb(IO_ICU2, OCW3_SEL | OCW3_RR);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204112004.q3BK4VR2093267>