Source-Changes-HG archive

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

[src/kqueue]: src/sys/arch sync with -current:



details:   https://anonhg.NetBSD.org/src/rev/21f38ddef232
branches:  kqueue
changeset: 512561:21f38ddef232
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Fri Oct 18 10:54:57 2002 +0000

description:
sync with -current:
Merge isa_machdep.c from netwinder and cats into footbridge/isa

diffstat:

 sys/arch/arm/footbridge/isa/isa_machdep.c        |  606 +++++++++++++++++++++++
 sys/arch/cats/cats/cats_machdep.c                |    4 +-
 sys/arch/cats/conf/files.cats                    |    4 +-
 sys/arch/cats/include/isa_machdep.h              |   12 +-
 sys/arch/cats/isa/isa_machdep.c                  |  600 ----------------------
 sys/arch/netwinder/conf/files.netwinder          |    4 +-
 sys/arch/netwinder/include/isa_machdep.h         |   12 +-
 sys/arch/netwinder/isa/isa_machdep.c             |  597 ----------------------
 sys/arch/netwinder/netwinder/netwinder_machdep.c |   12 +-
 9 files changed, 637 insertions(+), 1214 deletions(-)

diffs (truncated from 1961 to 300 lines):

diff -r e00dd2375c8d -r 21f38ddef232 sys/arch/arm/footbridge/isa/isa_machdep.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/footbridge/isa/isa_machdep.c Fri Oct 18 10:54:57 2002 +0000
@@ -0,0 +1,606 @@
+/*     $NetBSD: isa_machdep.c,v 1.1.4.2 2002/10/18 10:55:06 jdolecek Exp $     */
+
+/*-
+ * Copyright (c) 1996-1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Mark Brinicombe, Charles M. Hannum and by Jason R. Thorpe of the
+ * Numerical Aerospace Simulation Facility, NASA Ames Research Center.
+ *
+ * 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 NetBSD
+ *     Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+/*-
+ * 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 "opt_irqstats.h"
+
+#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>
+
+#define _ARM32_BUS_DMA_PRIVATE
+#include <machine/bus.h>
+
+#include <machine/intr.h>
+#include <machine/pio.h>
+#include <machine/bootconfig.h>
+#include <machine/isa_machdep.h>
+
+#include <dev/isa/isareg.h>
+#include <dev/isa/isavar.h>
+#include <dev/isa/isadmareg.h>
+#include <dev/isa/isadmavar.h>
+#include <arm/footbridge/isa/icu.h>
+#include <arm/footbridge/dc21285reg.h>
+#include <arm/footbridge/dc21285mem.h>
+
+#include <uvm/uvm_extern.h>
+
+#include "isadma.h"
+
+/* prototypes */
+static void isa_icu_init __P((void));
+
+struct arm32_isa_chipset isa_chipset_tag;
+
+void isa_strayintr __P((int));
+void intr_calculatemasks __P((void));
+int fakeintr __P((void *));
+
+int isa_irqdispatch __P((void *arg));
+
+u_int imask[IPL_LEVELS];
+unsigned imen;
+
+#ifdef IRQSTATS
+u_int isa_intr_count[ICU_LEN];
+#endif /* IRQSTATS */
+
+#define AUTO_EOI_1
+#define AUTO_EOI_2
+
+/*
+ * Fill in default interrupt table (in case of spuruious interrupt
+ * during configuration of kernel, setup interrupt control unit
+ */
+static void
+isa_icu_init(void)
+{
+       /* initialize 8259's */
+       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
+
+       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. */
+}
+
+/*
+ * Caught a stray interrupt, notify
+ */
+void
+isa_strayintr(irq)
+       int irq;
+{
+       static u_long strays;
+
+        /*
+         * Stray interrupts on irq 7 occur when an interrupt line is raised
+         * and then lowered before the CPU acknowledges it.  This generally
+         * means either the device is screwed or something is cli'ing too
+         * long and it's timing out.
+         */
+       if (++strays <= 5)
+               log(LOG_ERR, "stray interrupt %d%s\n", irq,
+                   strays >= 5 ? "; stopped logging" : "");
+}
+
+int intrtype[ICU_LEN], intrmask[ICU_LEN], intrlevel[ICU_LEN];
+struct irqhandler *intrhand[ICU_LEN];
+
+/*
+ * Recalculate the interrupt masks from scratch.
+ * We could code special registry and deregistry versions of this function that
+ * would be faster, but the code would be nastier, and we don't expect this to
+ * happen very much anyway.
+ */
+void
+intr_calculatemasks()
+{
+       int irq, level;
+       struct irqhandler *q;
+
+       /* First, figure out which levels each IRQ uses. */
+       for (irq = 0; irq < ICU_LEN; irq++) {
+               int levels = 0;
+               for (q = intrhand[irq]; q; q = q->ih_next)
+                       levels |= 1 << q->ih_level;
+               intrlevel[irq] = levels;
+       }
+
+       /* Then figure out which IRQs use each level. */
+       for (level = 0; level < IPL_LEVELS; level++) {
+               int irqs = 0;
+               for (irq = 0; irq < ICU_LEN; irq++)
+                       if (intrlevel[irq] & (1 << level))
+                               irqs |= 1 << irq;
+               imask[level] = irqs;
+       }
+
+       /*
+        * IPL_NONE is used for hardware interrupts that are never blocked,
+        * and do not block anything else.
+        */
+       imask[IPL_NONE] = 0;
+
+       /*
+        * Enforce a hierarchy that gives slow devices a better chance at not
+        * dropping data.
+        */
+       imask[IPL_BIO] |= imask[IPL_NONE];
+       imask[IPL_NET] |= imask[IPL_BIO];
+       imask[IPL_TTY] |= imask[IPL_NET];
+       /*
+        * There are tty, network and disk drivers that use free() at interrupt
+        * time, so imp > (tty | net | bio).
+        */
+       imask[IPL_IMP] |= imask[IPL_TTY];
+       imask[IPL_AUDIO] |= imask[IPL_IMP];
+
+       /*
+        * Since run queues may be manipulated by both the statclock and tty,
+        * network, and disk drivers, clock > imp.
+        */
+       imask[IPL_CLOCK] |= imask[IPL_AUDIO];
+       imask[IPL_CLOCK] |= imask[IPL_IMP];
+
+       /*
+        * IPL_HIGH must block everything that can manipulate a run queue.
+        */
+       imask[IPL_HIGH] |= imask[IPL_CLOCK];
+
+       /*
+        * We need serial drivers to run at the absolute highest priority to
+        * avoid overruns, so serial > high.
+        */
+       imask[IPL_SERIAL] |= imask[IPL_HIGH];
+
+       /* And eventually calculate the complete masks. */
+       for (irq = 0; irq < ICU_LEN; irq++) {
+               int irqs = 1 << irq;
+               for (q = intrhand[irq]; q; q = q->ih_next)
+                       irqs |= imask[q->ih_level];
+               intrmask[irq] = irqs;
+       }
+
+       /* Lastly, determine which IRQs are actually in use. */
+       {
+               int irqs = 0;
+               for (irq = 0; irq < ICU_LEN; irq++)
+                       if (intrhand[irq])
+                               irqs |= 1 << irq;
+               if (irqs >= 0x100) /* any IRQs >= 8 in use */
+                       irqs |= 1 << IRQ_SLAVE;
+               imen = ~irqs;
+               SET_ICUS();
+       }
+#if 0
+       printf("type\tmask\tlevel\thand\n");
+       for (irq = 0; irq < ICU_LEN; irq++) {
+               printf("%x\t%04x\t%x\t%p\n", intrtype[irq], intrmask[irq],
+               intrlevel[irq], intrhand[irq]);
+       }
+       for (level = 0; level < IPL_LEVELS; ++level)
+               printf("%d: %08x\n", level, imask[level]);
+#endif
+}
+
+int
+fakeintr(arg)
+       void *arg;
+{
+
+       return 0;
+}
+
+#define        LEGAL_IRQ(x)    ((x) >= 0 && (x) < ICU_LEN && (x) != 2)
+
+int
+isa_intr_alloc(ic, mask, type, irq)



Home | Main Index | Thread Index | Old Index