From owner-svn-src-stable@FreeBSD.ORG Wed Apr 11 20:04:32 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5105F106564A; Wed, 11 Apr 2012 20:04:32 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3815E8FC15; Wed, 11 Apr 2012 20:04:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3BK4W7Y093278; Wed, 11 Apr 2012 20:04:32 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3BK4VR2093267; Wed, 11 Apr 2012 20:04:31 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201204112004.q3BK4VR2093267@svn.freebsd.org> From: John Baldwin Date: Wed, 11 Apr 2012 20:04:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234144 - in stable/9/sys: amd64/amd64 conf i386/conf i386/i386 i386/include kern pc98/pc98 x86/isa x86/x86 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Apr 2012 20:04:32 -0000 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 +#endif -#ifdef DEV_APIC +#if defined(DEV_APIC) && defined(DEV_ATPIC) .data .p2align 4 .text SUPERALIGN_TEXT +#endif +#ifdef DEV_APIC #include #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 __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 #endif +#ifdef DEV_APIC +#include +#endif + #ifdef DEV_ISA #include #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 __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 #endif +#ifdef DEV_APIC +#include +#endif + #ifdef DEV_ISA #include #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 #include #include +#ifdef PC98 +#include +#else #include #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); }