Source-Changes-HG archive

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

[src/sommerfeld_i386mp_1]: src/sys/arch/i386/isa Overhaul of the ISA autoconf...



details:   https://anonhg.NetBSD.org/src/rev/ef12912782f9
branches:  sommerfeld_i386mp_1
changeset: 482478:ef12912782f9
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Mon Jan 07 21:47:02 2002 +0000

description:
Overhaul of the ISA autoconfiguration code to support direct
configuration of devices logically attached to the ISA bus:

* Change the isa_attach_args to have arrays of io, mem, irq, drq
  resources.
* Add a "pnpnames" and a linked list of "pnpcompatnames" to the
  isa_attach_args.  If either of these members are non-NULL,
  direct configuration of the bus is being performed.  Add an
  ISA_DIRECT_CONFIG() macro to test for this.
* Drivers are not allowed to modify the isa_attach_args unless
  direct configuration is not being performed and the probe fucntion
  is returning success.
* Adapt device drivers -- currently, all driver probe routines return
  "no match" if ISA_DIRECT_CONFIG() evaluates to true.

diffstat:

 sys/arch/i386/isa/ahc_isa.c |  568 ++++++++++++++++++++++++++++++++++++++++++++
 sys/arch/i386/isa/joy_isa.c |  119 +++++++++
 sys/arch/i386/isa/olms.c    |  404 +++++++++++++++++++++++++++++++
 sys/arch/i386/isa/omms.c    |  399 ++++++++++++++++++++++++++++++
 4 files changed, 1490 insertions(+), 0 deletions(-)

diffs (truncated from 1506 to 300 lines):

diff -r b068a31989dd -r ef12912782f9 sys/arch/i386/isa/ahc_isa.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/isa/ahc_isa.c       Mon Jan 07 21:47:02 2002 +0000
@@ -0,0 +1,568 @@
+/*     $NetBSD: ahc_isa.c,v 1.16.2.2 2002/01/07 21:47:02 thorpej Exp $ */
+
+/*
+ * Product specific probe and attach routines for:
+ *     AHA-284X VL-bus SCSI controllers
+ *
+ * Copyright (c) 1994, 1995, 1996, 1997, 1998 Justin T. Gibbs.
+ * All rights reserved.
+ *
+ * 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 immediately at the beginning of the file, without modification,
+ *    this list of conditions, and the following disclaimer.
+ * 2. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ * $FreeBSD: src/sys/dev/aic7xxx/ahc_eisa.c,v 1.15 2000/01/29 14:22:19 peter Exp $
+ */
+
+/*-
+ * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * 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) 1995, 1996 Christopher G. Demetriou
+ * All rights reserved.
+ *
+ * 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 Christopher G. Demetriou
+ *      for the NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+
+/*
+ * This front-end driver is really sort of a hack.  The AHA-284X likes
+ * to masquerade as an EISA device.  However, on VLbus machines with
+ * no EISA signature in the BIOS, the EISA bus will never be scanned.
+ * This is intended to catch the 284X controllers on those systems
+ * by looking in "EISA i/o space" for 284X controllers.
+ *
+ * This relies heavily on i/o port accounting.  We also just use the
+ * EISA macros for everything ... it's a real waste to redefine them.
+ *
+ * Note: there isn't any #ifdef for FreeBSD in this file, since the
+ * FreeBSD EISA driver handles all cases of the 284X.
+ *
+ *     -- Jason R. Thorpe <thorpej%NetBSD.ORG@localhost>
+ *        July 12, 1996
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: ahc_isa.c,v 1.16.2.2 2002/01/07 21:47:02 thorpej Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+#include <sys/queue.h>
+#include <sys/malloc.h>
+#include <sys/reboot.h>
+
+#include <machine/bus.h>
+#include <machine/intr.h>
+
+#include <dev/scsipi/scsi_all.h>
+#include <dev/scsipi/scsipi_all.h>
+#include <dev/scsipi/scsiconf.h>
+
+#include <dev/isa/isavar.h>
+
+#include <dev/eisa/eisareg.h>
+#include <dev/eisa/eisavar.h>
+#include <dev/eisa/eisadevs.h>
+
+#include <dev/microcode/aic7xxx/aic7xxx_reg.h>
+#include <dev/ic/aic7xxxvar.h>
+#include <dev/ic/aic77xxreg.h>
+#include <dev/ic/aic77xxvar.h>
+#include <dev/ic/smc93cx6var.h>
+
+/* IO port address setting range as EISA slot number */
+#define AHC_ISA_MIN_SLOT       0x1     /* from iobase = 0x1c00 */
+#define AHC_ISA_MAX_SLOT       0xe     /* to   iobase = 0xec00 */
+
+#define AHC_ISA_SLOT_OFFSET    AHC_EISA_SLOT_OFFSET
+#define AHC_ISA_IOSIZE         AHC_EISA_IOSIZE
+
+/*
+ * I/O port offsets
+ */
+#define        AHC_ISA_VID             (EISA_SLOTOFF_VID - AHC_ISA_SLOT_OFFSET)
+#define        AHC_ISA_PID             (EISA_SLOTOFF_PID - AHC_ISA_SLOT_OFFSET)
+#define        AHC_ISA_PRIMING         AHC_ISA_VID     /* enable vendor/product ID */
+
+/*
+ * AHC_ISA_PRIMING register values (write)
+ */
+#define        AHC_ISA_PRIMING_VID(index)      (AHC_ISA_VID + (index))
+#define        AHC_ISA_PRIMING_PID(index)      (AHC_ISA_PID + (index))
+
+int    ahc_isa_idstring __P((bus_space_tag_t, bus_space_handle_t, char *));
+int    ahc_isa_match __P((struct isa_attach_args *, bus_addr_t));
+
+int    ahc_isa_probe __P((struct device *, struct cfdata *, void *));
+void   ahc_isa_attach __P((struct device *, struct device *, void *));
+void   aha2840_load_seeprom __P((struct ahc_softc *ahc));
+
+struct cfattach ahc_isa_ca = {
+       sizeof(struct ahc_softc), ahc_isa_probe, ahc_isa_attach
+};
+
+/*
+ * This keeps track of which slots are to be checked next if the
+ * iobase locator is a wildcard.  A simple static variable isn't enough,
+ * since it's conceivable that a system might have more than one ISA
+ * bus.
+ *
+ * The "bus" member is the unit number of the parent ISA bus, e.g. "0"
+ * for "isa0".
+ */
+struct ahc_isa_slot {
+       LIST_ENTRY(ahc_isa_slot)        link;
+       int                             bus;
+       int                             slot;
+};
+static LIST_HEAD(, ahc_isa_slot) ahc_isa_all_slots;
+static int ahc_isa_slot_initialized;
+
+int
+ahc_isa_idstring(iot, ioh, idstring)
+       bus_space_tag_t iot;
+       bus_space_handle_t ioh;
+       char *idstring;
+{
+       u_int8_t vid[EISA_NVIDREGS], pid[EISA_NPIDREGS];
+       int i;
+
+       /* Get the vendor ID bytes */
+       for (i = 0; i < EISA_NVIDREGS; i++) {
+               bus_space_write_1(iot, ioh, AHC_ISA_PRIMING,
+                   AHC_ISA_PRIMING_VID(i));
+               vid[i] = bus_space_read_1(iot, ioh, AHC_ISA_VID + i);
+       }
+
+       /* Check for device existence */
+       if (EISA_VENDID_NODEV(vid)) {
+#if 0
+               printf("ahc_isa_idstring: no device at 0x%lx\n",
+                   ioh); /* XXX knows about ioh guts */
+               printf("\t(0x%x, 0x%x)\n", vid[0], vid[1]);
+#endif
+               return (0);
+       }
+
+       /* And check that the firmware didn't biff something badly */
+       if (EISA_VENDID_IDDELAY(vid)) {
+               printf("ahc_isa_idstring: BIOS biffed it at 0x%lx\n",
+                   ioh);       /* XXX knows about ioh guts */
+               return (0);
+       }
+
+       /* Get the product ID bytes */
+       for (i = 0; i < EISA_NPIDREGS; i++) {
+               bus_space_write_1(iot, ioh, AHC_ISA_PRIMING,
+                   AHC_ISA_PRIMING_PID(i));
+               pid[i] = bus_space_read_1(iot, ioh, AHC_ISA_PID + i);
+       }
+
+       /* Create the ID string from the vendor and product IDs */
+       idstring[0] = EISA_VENDID_0(vid);
+       idstring[1] = EISA_VENDID_1(vid);
+       idstring[2] = EISA_VENDID_2(vid);
+       idstring[3] = EISA_PRODID_0(pid);
+       idstring[4] = EISA_PRODID_1(pid);
+       idstring[5] = EISA_PRODID_2(pid);
+       idstring[6] = EISA_PRODID_3(pid);
+       idstring[7] = '\0';             /* sanity */
+
+       return (1);
+}
+
+int
+ahc_isa_match(ia, iobase)
+       struct isa_attach_args *ia;
+       bus_addr_t iobase;
+{
+       bus_space_tag_t iot = ia->ia_iot;
+       bus_space_handle_t ioh;
+       int irq;
+       char idstring[EISA_IDSTRINGLEN];
+
+       /*
+        * Get a mapping for the while slot-specific address
+        * space.  If we can't, assume nothing's there, but
+        * warn about it.
+        */
+       if (bus_space_map(iot, iobase, AHC_ISA_IOSIZE, 0, &ioh)) {
+#if 0
+               /*
+                * Don't print anything out here, since this could
+                * be common on machines configured to look for
+                * ahc_eisa and ahc_isa.
+                */
+               printf("ahc_isa_match: can't map I/O space for 0x%x\n",
+                   iobase);
+#endif
+               return (0);
+       }
+
+       if (!ahc_isa_idstring(iot, ioh, idstring))
+               irq = -1;       /* cannot get the ID string */
+       else if (strcmp(idstring, "ADP7756") &&
+           strcmp(idstring, "ADP7757"))
+               irq = -1;       /* unknown ID strings */
+       else
+               irq = ahc_aic77xx_irq(iot, ioh);
+
+       bus_space_unmap(iot, ioh, AHC_ISA_IOSIZE);
+
+       if (irq < 0)
+               return (0);
+
+       if (ia->ia_irq[0].ir_irq != ISACF_IRQ_DEFAULT &&
+           ia->ia_irq[0].ir_irq != irq) {
+               printf("ahc_isa_match: irq mismatch (kernel %d, card %d)\n",
+                   ia->ia_irq[0].ir_irq, irq);
+               return (0);
+       }



Home | Main Index | Thread Index | Old Index