Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/i386/i386 New files for the changed interrupt code....



details:   https://anonhg.NetBSD.org/src/rev/f2b3782b7b63
branches:  trunk
changeset: 539585:f2b3782b7b63
user:      fvdl <fvdl%NetBSD.org@localhost>
date:      Fri Nov 22 15:05:23 2002 +0000

description:
New files for the changed interrupt code. i8259.c deals with some of
the old ('legacy') i8259 code, intr.c now contains the bulk of
the interrupt establish/disestablish code.

diffstat:

 sys/arch/i386/i386/i8259.c |  247 ++++++++++++++++
 sys/arch/i386/i386/intr.c  |  691 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 938 insertions(+), 0 deletions(-)

diffs (truncated from 946 to 300 lines):

diff -r 032eab3af6f5 -r f2b3782b7b63 sys/arch/i386/i386/i8259.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/i386/i8259.c        Fri Nov 22 15:05:23 2002 +0000
@@ -0,0 +1,247 @@
+/*     $NetBSD: i8259.c,v 1.1 2002/11/22 15:05:23 fvdl Exp $   */
+
+/*
+ * Copyright 2002 (c) Wasabi Systems, Inc.
+ * All rights reserved.
+ *
+ * Written by Frank van der Linden for Wasabi Systems, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed for the NetBSD Project by
+ *      Wasabi Systems, Inc.
+ * 4. The name of Wasabi Systems, Inc. may not be used to endorse
+ *    or promote products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*-
+ * Copyright (c) 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)isa.c       7.2 (Berkeley) 5/13/91
+ */
+
+#include <sys/param.h> 
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/syslog.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+#include <sys/proc.h>
+
+#include <dev/isa/isareg.h>
+
+#include <machine/pio.h>
+#include <machine/cpufunc.h>  
+#include <machine/cpu.h>
+#include <machine/pic.h>
+#include <machine/i8259.h>
+
+
+#if NMCA > 0
+#include <machine/mca_machdep.h>                /* for MCA_system */
+#endif
+
+static void i8259_hwmask(struct pic *, int);
+static void i8259_hwunmask(struct pic *, int);
+static void i8259_setup(struct pic *, struct cpu_info *, int, int, int);
+static void i8259_reinit_irqs(void);
+
+unsigned i8259_imen;
+
+/*
+ * Perhaps this should be made into a real device.
+ */
+struct pic i8259_pic = {
+       {0, {NULL}, NULL, NULL, NULL, 0, "pic0", NULL, 0},
+       PIC_I8259,
+       __SIMPLELOCK_UNLOCKED,
+       i8259_hwmask,
+       i8259_hwunmask,
+       i8259_setup,
+       i8259_setup,
+       i8259_stubs,
+       i8259_stubs,
+};
+
+void
+i8259_default_setup(void)
+{
+#if NMCA > 0
+       /* level-triggered interrupts on MCA PS/2s */
+       if (MCA_system)
+               outb(IO_ICU1, 0x19);    /* reset; program device, four bytes */
+       else
+#endif
+               outb(IO_ICU1, 0x11);    /* reset; program device, four bytes */
+
+       outb(IO_ICU1+1, ICU_OFFSET);    /* starting at this vector index */
+       outb(IO_ICU1+1, 1 << IRQ_SLAVE); /* slave on line 2 */
+#ifdef AUTO_EOI_1
+       outb(IO_ICU1+1, 2 | 1);         /* auto EOI, 8086 mode */
+#else
+       outb(IO_ICU1+1, 1);             /* 8086 mode */
+#endif
+       outb(IO_ICU1+1, 0xff);          /* leave interrupts masked */
+       outb(IO_ICU1, 0x68);            /* special mask mode (if available) */
+       outb(IO_ICU1, 0x0a);            /* Read IRR by default. */
+#ifdef REORDER_IRQ
+       outb(IO_ICU1, 0xc0 | (3 - 1));  /* pri order 3-7, 0-2 (com2 first) */
+#endif
+
+#if NMCA > 0
+       /* level-triggered interrupts on MCA PS/2s */
+       if (MCA_system)
+               outb(IO_ICU2, 0x19);    /* reset; program device, four bytes */
+       else
+#endif 
+               outb(IO_ICU2, 0x11);    /* reset; program device, four bytes */
+
+       outb(IO_ICU2+1, ICU_OFFSET+8);  /* staring at this vector index */
+       outb(IO_ICU2+1, IRQ_SLAVE);
+#ifdef AUTO_EOI_2
+       outb(IO_ICU2+1, 2 | 1);         /* auto EOI, 8086 mode */
+#else
+       outb(IO_ICU2+1, 1);             /* 8086 mode */
+#endif
+       outb(IO_ICU2+1, 0xff);          /* leave interrupts masked */
+       outb(IO_ICU2, 0x68);            /* special mask mode (if available) */
+       outb(IO_ICU2, 0x0a);            /* Read IRR by default. */
+}
+
+static void
+i8259_hwmask(struct pic *pic, int pin)
+{
+       unsigned port;
+       u_int8_t byte;
+
+       i8259_imen |= (1 << pin);
+#ifdef PIC_MASKDELAY
+       delay(10);
+#endif
+       if (pin > 7) {
+               port = IO_ICU2 + 1;
+               byte = i8259_imen >> 8;
+       } else {
+               port = IO_ICU1 + 1;
+               byte = i8259_imen & 0xff;
+       }
+       outb(port, byte);
+}
+
+static void
+i8259_hwunmask(struct pic *pic, int pin)
+{
+       unsigned port;
+       u_int8_t byte;
+
+       disable_intr(); /* XXX */
+       i8259_imen &= ~(1 << pin);
+#ifdef PIC_MASKDELAY
+       delay(10);
+#endif
+       if (pin > 7) {
+               port = IO_ICU2 + 1;
+               byte = i8259_imen >> 8;
+       } else {
+               port = IO_ICU1 + 1;
+               byte = i8259_imen & 0xff;
+       }
+       outb(port, byte);
+       enable_intr();
+}
+
+static void
+i8259_reinit_irqs(void)
+{
+       int irqs, irq;
+       struct cpu_info *ci = &cpu_info_primary;
+
+       irqs = 0;
+       for (irq = 0; irq < NUM_LEGACY_IRQS; irq++)
+               if (ci->ci_isources[irq] != NULL)
+                       irqs |= 1 << irq;
+       if (irqs >= 0x100) /* any IRQs >= 8 in use */
+               irqs |= 1 << IRQ_SLAVE;
+       i8259_imen = ~irqs;
+
+       outb(IO_ICU1 + 1, i8259_imen);
+       outb(IO_ICU2 + 1, i8259_imen >> 8);
+}
+
+static void
+i8259_setup(struct pic *pic, struct cpu_info *ci, int pin, int idtvec, int type)
+{
+       if (CPU_IS_PRIMARY(ci))
+               i8259_reinit_irqs();
+}
+
+void
+i8259_reinit(void)
+{
+       i8259_default_setup();
+       i8259_reinit_irqs();
+}
+
+unsigned
+i8259_setmask(unsigned mask)
+{
+       unsigned old = i8259_imen;
+
+       i8259_imen = mask;
+       outb(IO_ICU1 + 1, i8259_imen);
+       outb(IO_ICU2 + 1, i8259_imen >> 8);
+       return old;
+}
diff -r 032eab3af6f5 -r f2b3782b7b63 sys/arch/i386/i386/intr.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/i386/intr.c Fri Nov 22 15:05:23 2002 +0000
@@ -0,0 +1,691 @@
+/*     $NetBSD: intr.c,v 1.1 2002/11/22 15:05:24 fvdl Exp $    */
+
+/*
+ * Copyright 2002 (c) Wasabi Systems, Inc.
+ * All rights reserved.
+ *
+ * Written by Frank van der Linden for Wasabi Systems, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed for the NetBSD Project by
+ *      Wasabi Systems, Inc.
+ * 4. The name of Wasabi Systems, Inc. may not be used to endorse
+ *    or promote products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "opt_multiprocessor.h"
+
+#include <sys/cdefs.h>
+#include <sys/param.h> 
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/syslog.h>
+#include <sys/device.h>



Home | Main Index | Thread Index | Old Index