Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/vme new, more mi, VME framework



details:   https://anonhg.NetBSD.org/src/rev/b78b90dc49bb
branches:  trunk
changeset: 474170:b78b90dc49bb
user:      drochner <drochner%NetBSD.org@localhost>
date:      Wed Jun 30 15:06:05 1999 +0000

description:
new, more mi, VME framework

diffstat:

 sys/dev/vme/files.vme |   20 ++-
 sys/dev/vme/vme.c     |  358 ++++++++++++++++++++++++++++++++++++++++++-------
 sys/dev/vme/vmereg.h  |   38 +++++
 sys/dev/vme/vmevar.h  |  264 +++++++++++++++++++++++++-----------
 4 files changed, 535 insertions(+), 145 deletions(-)

diffs (truncated from 779 to 300 lines):

diff -r 7347a1ab23c5 -r b78b90dc49bb sys/dev/vme/files.vme
--- a/sys/dev/vme/files.vme     Wed Jun 30 13:53:49 1999 +0000
+++ b/sys/dev/vme/files.vme     Wed Jun 30 15:06:05 1999 +0000
@@ -1,9 +1,17 @@
-#      $NetBSD: files.vme,v 1.4 1998/02/16 22:12:50 thorpej Exp $
+#      $NetBSD: files.vme,v 1.5 1999/06/30 15:06:05 drochner Exp $
 #
 # Config file and device description for machine-independent VME code.
 # Included by ports that need it.
 
-device vme {addr = -1, pri = -1, vec = -1}
+# keep the "3" consistent with VME_MAXCFRANGES in vmevar.h
+#  and VME_NUMCFRANGES in vme.c!
+#  (the latter will hopefully go away)
+device vme {[addr[3] = {-1,-1,-1}], [len[3] = {-1,-1,-1}],
+       [am[3] = {-1,-1,-1}], [irq = -1], [vect = -1]}
+
+attach vme at vmebus
+device vme_slv
+attach vme_slv at vme
 file   dev/vme/vme.c                   vme
 
 
@@ -15,10 +23,14 @@
 attach xdc at vme
 device xd: disk
 attach xd at xdc
-file   dev/vme/xd.c            xd needs-flag
+file   dev/vme/xd.c            xd | xdc needs-flag
 
 device xyc {drive = -1}
 attach xyc at vme
 device xy: disk
 attach xy at xyc
-file   dev/vme/xy.c            xy needs-flag
+file   dev/vme/xy.c            xy | xyc needs-flag
+
+device vmegeneric
+attach vmegeneric at vme
+file  dev/vme/vmegeneric.c     vmegeneric needs-flag
diff -r 7347a1ab23c5 -r b78b90dc49bb sys/dev/vme/vme.c
--- a/sys/dev/vme/vme.c Wed Jun 30 13:53:49 1999 +0000
+++ b/sys/dev/vme/vme.c Wed Jun 30 15:06:05 1999 +0000
@@ -1,10 +1,8 @@
-/*     $NetBSD: vme.c,v 1.2 1998/02/04 00:38:34 pk Exp $       */
-/*-
- * Copyright (c) 1997 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Paul Kranenburg.
+/* $NetBSD: vme.c,v 1.3 1999/06/30 15:06:05 drochner Exp $ */
+
+/*
+ * Copyright (c) 1999
+ *     Matthias Drochner.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -14,82 +12,330 @@
  * 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.
+ * 3. 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 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.
+ * 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.
+ *
  */
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/device.h>
 #include <sys/malloc.h>
+#include <sys/extent.h>
+#include <machine/bus.h>
 
-#include <vm/vm.h>
-
+#include <dev/vme/vmereg.h>
 #include <dev/vme/vmevar.h>
 
-#include "locators.h"
+static void vme_extractlocators __P((int*, struct vme_attach_args*));
+static int vmeprint __P((struct vme_attach_args*, char*));
+static int vmesubmatch1 __P((struct device*, struct cfdata*, void*));
+static int vmesubmatch __P((struct device*, struct cfdata*, void*));
+int vmematch __P((struct device *, struct cfdata *, void *));
+void vmeattach __P((struct device*, struct device*,void*));
+static struct extent *vme_select_map __P((struct vmebus_softc*, vme_am_t));
 
-int            vmeprint __P((void *, const char *));
+#ifdef notyet
+int vmedetach __P((struct device*));
+#endif
+
+#define VME_SLAVE_DUMMYDRV "vme_slv"
 
-int
-vmeprint(args, name)
-       void *args;
-       const char *name;
+#define VME_NUMCFRANGES 3 /* cf. "files.vme" */
+
+struct cfattach vme_ca = {
+       sizeof(struct vmebus_softc), vmematch, vmeattach,
+};
+
+struct cfattach vme_slv_ca = {
+       0       /* never used */
+};
+
+static void
+vme_extractlocators(loc, aa)
+       int *loc;
+       struct vme_attach_args *aa;
 {
-       struct vme_attach_args *va = args;
+       int i = 0;
+
+       /* XXX can't use constants in locators.h this way */
+
+       while (i < VME_NUMCFRANGES && i < VME_MAXCFRANGES &&
+              loc[i] != -1) {
+               aa->r[i].offset = (vme_addr_t)loc[i];
+               aa->r[i].size = (vme_size_t)loc[3 + i];
+               aa->r[i].am = (vme_am_t)loc[6 + i];
+               i++;
+       }
+       aa->numcfranges = i;
+       aa->ilevel = loc[9];
+       aa->ivector = loc[10];
+}
 
-       if (name)
-               printf("[%s at %s]", "???", name);
+static int
+vmeprint(v, dummy)
+       struct vme_attach_args *v;
+       char *dummy;
+{
+       int i;
 
-       printf(" addr %lx", va->vma_reg[0]);
-       printf(" pri %x", va->vma_pri);
-       printf(" vec %x", va->vma_vec);
+       for (i = 0; i < v->numcfranges; i++) {
+               printf(" addr %x", v->r[i].offset);
+               if (v->r[i].size != -1)
+                       printf("-%x", v->r[i].offset + v->r[i].size - 1);
+               if (v->r[i].am != -1)
+                       printf(" am %02x", v->r[i].am);
+       }
+       if (v->ilevel != -1) {
+               printf(" irq %d", v->ilevel);
+               if (v->ivector != -1)
+                       printf(" vector %x", v->ivector);
+       }
        return (UNCONF);
 }
 
+/*
+ * This looks for a (dummy) vme device "VME_SLAVE_DUMMYDRV".
+ * A callback provided by the bus's parent is called for every such
+ * entry in the config database.
+ * This is a special hack allowing to communicate the address settings
+ * of the VME master's slave side to its driver via the normal
+ * configuration mechanism.
+ * Needed in following cases:
+ *  -DMA windows are hardware settable but not readable by software
+ *   (driver gets offsets for DMA address calculations this way)
+ *  -DMA windows are software settable, but not persistent
+ *   (hardware is set up from config file entry)
+ *  -other adapter VME slave ranges which should be kept track of
+ *   for address space accounting
+ * In any case, the adapter driver must get the data before VME
+ * devices are attached.
+ */
+static int
+vmesubmatch1(bus, dev, aux)
+       struct device *bus;
+       struct cfdata *dev;
+       void *aux;
+{
+       struct vmebus_softc *sc = (struct vmebus_softc*)bus;
+       struct vme_attach_args v;
+
+       if (strcmp(dev->cf_driver->cd_name, VME_SLAVE_DUMMYDRV))
+               return (0);
+
+       vme_extractlocators(dev->cf_loc, &v);
+
+       v.va_vct = sc->sc_vct; /* for space allocation */
+
+       (*sc->slaveconfig)(bus->dv_parent, &v);
+       return (0);
+}
+
+static int
+vmesubmatch(bus, dev, aux)
+       struct device *bus;
+       struct cfdata *dev;
+       void *aux;
+{
+       struct vmebus_softc *sc = (struct vmebus_softc*)bus;
+       struct vme_attach_args v;
+
+       if (!strcmp(dev->cf_driver->cd_name, VME_SLAVE_DUMMYDRV))
+               return (0);
+
+       vme_extractlocators(dev->cf_loc, &v);
+
+       v.va_vct = sc->sc_vct;
+       v.va_bdt = sc->sc_bdt;
+
+       if (dev->cf_attach->ca_match(bus, dev, &v)) {
+               config_attach(bus, dev, &v, (cfprint_t)vmeprint);
+               return (1);
+       }
+       return (0);
+}
 
 int
-vmesearch(parent, cf, aux)
+vmematch(parent, match, aux)
        struct device *parent;
-       struct cfdata *cf;
+       struct cfdata *match;
+       void *aux;
+{
+       return (1);
+}
+
+void
+vmeattach(parent, self, aux)
+       struct device *parent, *self;
        void *aux;
 {
-       struct vme_busattach_args *vba = (struct vme_busattach_args *)aux;
-       struct vme_attach_args vma;
-       int i;
+       struct vmebus_softc *sc = (struct vmebus_softc *)self;
+
+       struct vmebus_attach_args *aa =
+           (struct vmebus_attach_args*)aux;
+
+       sc->sc_vct = aa->va_vct;
+       sc->sc_bdt = aa->va_bdt;
+
+       /* the "bus" are we ourselves */
+       sc->sc_vct->bus = sc;
+
+       sc->slaveconfig = aa->va_slaveconfig;
+
+       printf("\n");
 
-       vma.vma_bustag = vba->vba_bustag;
-       vma.vma_dmatag = vba->vba_dmatag;
-       vma.vma_chipset_tag = vba->vba_chipset_tag;
+       /*
+        * set up address space accounting - assume incomplete decoding
+        */
+       sc->vme32ext = extent_create("vme32", 0, 0xffffffff,
+                                    M_DEVBUF, 0, 0, 0);
+       if (!sc->vme32ext) {
+               printf("error creating A32 map\n");
+               return;
+       }
+
+       sc->vme24ext = extent_create("vme24", 0, 0x00ffffff,
+                                    M_DEVBUF, 0, 0, 0);
+       if (!sc->vme24ext) {
+               printf("error creating A24 map\n");



Home | Main Index | Thread Index | Old Index