From owner-svn-src-all@FreeBSD.ORG Fri Mar 9 19:42:49 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5A2B4106566C; Fri, 9 Mar 2012 19:42:49 +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 440748FC0A; Fri, 9 Mar 2012 19:42:49 +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 q29JgnW0022238; Fri, 9 Mar 2012 19:42:49 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q29Jgmj1022231; Fri, 9 Mar 2012 19:42:48 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201203091942.q29Jgmj1022231@svn.freebsd.org> From: John Baldwin Date: Fri, 9 Mar 2012 19:42:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r232744 - in head/sys: conf i386/i386 i386/include X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Mar 2012 19:42:49 -0000 Author: jhb Date: Fri Mar 9 19:42:48 2012 New Revision: 232744 URL: http://svn.freebsd.org/changeset/base/232744 Log: 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. While here, be more selective on amd64 about which kernel configurations need elcr.c. MFC after: 2 weeks Modified: head/sys/conf/files.amd64 head/sys/conf/files.i386 head/sys/i386/i386/exception.s head/sys/i386/i386/intr_machdep.c head/sys/i386/i386/machdep.c head/sys/i386/include/intr_machdep.h Modified: head/sys/conf/files.amd64 ============================================================================== --- head/sys/conf/files.amd64 Fri Mar 9 19:22:31 2012 (r232743) +++ head/sys/conf/files.amd64 Fri Mar 9 19:42:48 2012 (r232744) @@ -466,7 +466,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 Modified: head/sys/conf/files.i386 ============================================================================== --- head/sys/conf/files.i386 Fri Mar 9 19:22:31 2012 (r232743) +++ head/sys/conf/files.i386 Fri Mar 9 19:42:48 2012 (r232744) @@ -516,9 +516,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 Modified: head/sys/i386/i386/exception.s ============================================================================== --- head/sys/i386/i386/exception.s Fri Mar 9 19:22:31 2012 (r232743) +++ head/sys/i386/i386/exception.s Fri Mar 9 19:42:48 2012 (r232744) @@ -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: head/sys/i386/i386/intr_machdep.c ============================================================================== --- head/sys/i386/i386/intr_machdep.c Fri Mar 9 19:22:31 2012 (r232743) +++ head/sys/i386/i386/intr_machdep.c Fri Mar 9 19:42:48 2012 (r232744) @@ -37,6 +37,7 @@ * that source. */ +#include "opt_atpic.h" #include "opt_ddb.h" #include @@ -57,6 +58,14 @@ #include #endif +#ifndef DEV_ATPIC +#include +#include +#include +#include +#include +#endif + #define MAX_STRAY_LOG 5 typedef void (*mask_fn)(void *); @@ -270,6 +279,9 @@ intr_resume(void) { struct pic *pic; +#ifndef DEV_ATPIC + atpic_reset(); +#endif mtx_lock(&intr_table_lock); STAILQ_FOREACH(pic, &pics, pics) { if (pic->pic_resume != NULL) @@ -371,6 +383,28 @@ intr_init(void *dummy __unused) } SYSINIT(intr_init, SI_SUB_INTR, SI_ORDER_FIRST, intr_init, NULL); +#ifndef DEV_ATPIC +/* Initialize the two 8259A's to a known-good shutdown state. */ +void +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, 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, 0xff); + outb(IO_ICU2, OCW3_SEL | OCW3_RR); +} +#endif + /* Add a description to an active interrupt handler. */ int intr_describe(u_int vector, void *ih, const char *descr) Modified: head/sys/i386/i386/machdep.c ============================================================================== --- head/sys/i386/i386/machdep.c Fri Mar 9 19:22:31 2012 (r232743) +++ head/sys/i386/i386/machdep.c Fri Mar 9 19:42:48 2012 (r232744) @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include "opt_atalk.h" +#include "opt_atpic.h" #include "opt_compat.h" #include "opt_cpu.h" #include "opt_ddb.h" @@ -2712,8 +2713,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 @@ -2971,8 +2986,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: head/sys/i386/include/intr_machdep.h ============================================================================== --- head/sys/i386/include/intr_machdep.h Fri Mar 9 19:22:31 2012 (r232743) +++ head/sys/i386/include/intr_machdep.h Fri Mar 9 19:42:48 2012 (r232744) @@ -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);