diff options
| author | drochner <drochner@NetBSD.org> | 1999-06-30 15:06:05 +0000 |
|---|---|---|
| committer | drochner <drochner@NetBSD.org> | 1999-06-30 15:06:05 +0000 |
| commit | 44418fdf70bb5522a229c589a405cb5ccc49dc6d (patch) | |
| tree | 8d42f50631a600c1b37fa9949a36501cc0d82864 /sys/dev | |
| parent | 09a05c8950aa2d047aff23747982d8ab4fa254e4 (diff) | |
new, more mi, VME framework
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/vme/files.vme | 20 | ||||
| -rw-r--r-- | sys/dev/vme/vme.c | 358 | ||||
| -rw-r--r-- | sys/dev/vme/vmereg.h | 38 | ||||
| -rw-r--r-- | sys/dev/vme/vmevar.h | 262 |
4 files changed, 534 insertions, 144 deletions
diff --git a/sys/dev/vme/files.vme b/sys/dev/vme/files.vme index e2f0cb29fe9..8ca4130c9ba 100644 --- a/sys/dev/vme/files.vme +++ b/sys/dev/vme/files.vme @@ -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 @@ device xdc {drive = -1} 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 --git a/sys/dev/vme/vme.c b/sys/dev/vme/vme.c index 011bc140982..76340567fd8 100644 --- a/sys/dev/vme/vme.c +++ b/sys/dev/vme/vme.c @@ -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 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 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. */ #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 -int -vmeprint(args, name) - void *args; - const char *name; +#define VME_SLAVE_DUMMYDRV "vme_slv" + +#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; - if (name) - printf("[%s at %s]", "???", name); + /* XXX can't use constants in locators.h this way */ - printf(" addr %lx", va->vma_reg[0]); - printf(" pri %x", va->vma_pri); - printf(" vec %x", va->vma_vec); + 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]; +} + +static int +vmeprint(v, dummy) + struct vme_attach_args *v; + char *dummy; +{ + int i; + + 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; { - struct vme_busattach_args *vba = (struct vme_busattach_args *)aux; - struct vme_attach_args vma; - int i; + return (1); +} + +void +vmeattach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct vmebus_softc *sc = (struct vmebus_softc *)self; - vma.vma_bustag = vba->vba_bustag; - vma.vma_dmatag = vba->vba_dmatag; - vma.vma_chipset_tag = vba->vba_chipset_tag; + struct vmebus_attach_args *aa = + (struct vmebus_attach_args*)aux; - vma.vma_nreg = 1; - for (i = 0; i < vma.vma_nreg; i++) - /* XXX - or whatever shape this config enhancement takes on */ - vma.vma_reg[0] = cf->cf_loc[VMECF_ADDR + i]; + sc->sc_vct = aa->va_vct; + sc->sc_bdt = aa->va_bdt; - vma.vma_vec = cf->cf_loc[VMECF_VEC]; - vma.vma_pri = cf->cf_loc[VMECF_PRI]; + /* the "bus" are we ourselves */ + sc->sc_vct->bus = sc; - if ((*cf->cf_attach->ca_match)(parent, cf, &vma) == 0) - return (0); + sc->slaveconfig = aa->va_slaveconfig; + + printf("\n"); + + /* + * 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"); + return; + } + + sc->vme16ext = extent_create("vme16", 0, 0x0000ffff, + M_DEVBUF, 0, 0, 0); + if (!sc->vme16ext) { + printf("error creating A16 map\n"); + return; + } + + if (sc->slaveconfig) { + /* first get info about the bus master's slave side, + if present */ + config_search((cfmatch_t)vmesubmatch1, self, 0); + } + config_search((cfmatch_t)vmesubmatch, self, 0); + +#ifdef VMEDEBUG + if (sc->vme32ext) + extent_print(sc->vme32ext); + if (sc->vme24ext) + extent_print(sc->vme24ext); + if (sc->vme16ext) + extent_print(sc->vme16ext); +#endif +} + +#ifdef notyet +int +vmedetach(dev) + struct device *dev; +{ + struct vmebus_softc *sc = (struct vmebus_softc*)dev; + + if (sc->slaveconfig) { + /* allow bus master to free its bus ressources */ + (*sc->slaveconfig)(dev->dv_parent, 0); + } + + /* extent maps should be empty now */ + + if (sc->vme32ext) { +#ifdef VMEDEBUG + extent_print(sc->vme32ext); +#endif + extent_destroy(sc->vme32ext); + } + if (sc->vme24ext) { +#ifdef VMEDEBUG + extent_print(sc->vme24ext); +#endif + extent_destroy(sc->vme24ext); + } + if (sc->vme16ext) { +#ifdef VMEDEBUG + extent_print(sc->vme16ext); +#endif + extent_destroy(sc->vme16ext); + } - config_attach(parent, cf, &vma, vmeprint); return (0); } +#endif + +static struct extent * +vme_select_map(sc, ams) + struct vmebus_softc *sc; + vme_am_t ams; +{ + if ((ams & VME_AM_ADRSIZEMASK) == VME_AM_A32) + return (sc->vme32ext); + else if ((ams & VME_AM_ADRSIZEMASK) == VME_AM_A24) + return (sc->vme24ext); + else if ((ams & VME_AM_ADRSIZEMASK) == VME_AM_A16) + return (sc->vme16ext); + else + return (0); +} + +int +_vme_space_alloc(sc, addr, len, ams) + struct vmebus_softc *sc; + vme_addr_t addr; + vme_size_t len; + vme_am_t ams; +{ + struct extent *ex; + + ex = vme_select_map(sc, ams); + if (!ex) + return (EINVAL); + + return (extent_alloc_region(ex, addr, len, EX_NOWAIT)); +} + +void +_vme_space_free(sc, addr, len, ams) + struct vmebus_softc *sc; + vme_addr_t addr; + vme_size_t len; + vme_am_t ams; +{ + struct extent *ex; + + ex = vme_select_map(sc, ams); + if (!ex) { + panic("vme_space_free: invalid am %x", ams); + return; + } + + extent_free(ex, addr, len, EX_NOWAIT); +} + +int +_vme_space_get(sc, len, ams, align, addr) + struct vmebus_softc *sc; + vme_size_t len; + vme_am_t ams; + u_long align; + vme_addr_t *addr; +{ + struct extent *ex; + + ex = vme_select_map(sc, ams); + if (!ex) + return (EINVAL); + + return (extent_alloc(ex, len, align, EX_NOBOUNDARY, EX_NOWAIT, + (u_long *)addr)); +} diff --git a/sys/dev/vme/vmereg.h b/sys/dev/vme/vmereg.h new file mode 100644 index 00000000000..8208f5b74a4 --- /dev/null +++ b/sys/dev/vme/vmereg.h @@ -0,0 +1,38 @@ +/* $NetBSD: vmereg.h,v 1.1 1999/06/30 15:06:05 drochner Exp $ */ + +/* constants for address modifiers */ + +#define VME_AM_ADRSIZEMASK 0x30 +#define VME_AM_A32 0 +#define VME_AM_A16 0x20 +#define VME_AM_A24 0x30 +#define VME_AM_USERDEF 0x10 /* user/vendor definable */ + +#define VME_AM_MBO 8 /* must be set for standard AMs */ + +#define VME_AM_PRIVMASK 4 +#define VME_AM_SUPER 4 +#define VME_AM_USER 0 + +#define VME_AM_MODEMASK 3 +#define VME_AM_DATA 1 +#define VME_AM_PRG 2 /* only with A32, A24 */ +#define VME_AM_BLT32 3 /* only with A32, A24 */ +#define VME_AM_BLT64 0 /* new, only with A32, A24 */ + +#if 0 +/* some AMs not yet supported by the framework */ + +/* ??? */ +VME_AM_A24_xxx 0x32 +VME_AM_A32_xxx 0x05 + +/* VME64 extension */ +VME_AM_A40 0x34,0x35,0x37 +VME_AM_A64 0x00,0x01,0x03,0x04 +VME_AM_CR_CSR 0x2f /* GEO */ + +/* 2eVME extension */ +VME_AM_2E_6U 0x20 +VME_AM_2E_3U 0x21 +#endif diff --git a/sys/dev/vme/vmevar.h b/sys/dev/vme/vmevar.h index 0aaf95ba558..80e76710109 100644 --- a/sys/dev/vme/vmevar.h +++ b/sys/dev/vme/vmevar.h @@ -1,10 +1,8 @@ -/* $NetBSD: vmevar.h,v 1.5 1998/04/07 20:31:26 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: vmevar.h,v 1.6 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,104 +12,200 @@ * 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 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 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. */ -#include <machine/bus.h> +#ifndef _vmevar_h_ +#define _vmevar_h_ + +typedef u_int32_t vme_addr_t, vme_size_t; +typedef int vme_am_t; + +typedef enum { + VME_D8 = 1, + VME_D16 = 2, + VME_D32 = 4 +} vme_datasize_t; + +typedef int vme_swap_t; /* hardware swap capabilities, + placeholder - contents to be specified */ + +#ifdef _KERNEL + +/* generic placeholder for any ressources needed for a mapping, + overloaded by bus interface driver */ +typedef void *vme_mapresc_t; + +/* describes interrupt mapping, overloaded by bus interface driver */ +typedef void *vme_intr_handle_t; + +/* + * tag structure passed to VME bus devices, + * contains the bus dependant functions, accessed via macros below + */ +typedef struct vme_chipset_tag { + void *cookie; + + int (*vct_map) __P((void *, vme_addr_t, vme_size_t, + vme_am_t, vme_datasize_t, vme_swap_t, + bus_space_tag_t *, bus_space_handle_t *, + vme_mapresc_t *)); + void (*vct_unmap) __P((void *, vme_mapresc_t)); + + int (*vct_probe) __P((void *, vme_addr_t, vme_size_t, + vme_am_t, vme_datasize_t, + int (*)(void *, bus_space_tag_t, bus_space_handle_t), + void *)); + + int (*vct_int_map) __P((void *, int, int, vme_intr_handle_t *)); + void *(*vct_int_establish) __P((void *, vme_intr_handle_t, int, + int (*)(void *), void *)); + void (*vct_int_disestablish) __P((void *, void *)); + + int (*vct_dmamap_create) __P((void *, vme_size_t, + vme_am_t, vme_datasize_t, vme_swap_t, + int, vme_size_t, vme_addr_t, + int, bus_dmamap_t *)); + void (*vct_dmamap_destroy) __P((void *, bus_dmamap_t)); + + /* + * This sucks: we have to give all the VME specific arguments + * twice - for dmamem_alloc and for dmamem_create. Perhaps + * give a "dmamap" argument here, meaning: "allocate memory which + * can be accessed through this DMA map". + */ + int (*vct_dmamem_alloc) __P((void *, vme_size_t, + vme_am_t, vme_datasize_t, vme_swap_t, + bus_dma_segment_t *, int, int *, int)); + void (*vct_dmamem_free) __P((void *, bus_dma_segment_t *, int)); + + struct vmebus_softc *bus; +} *vme_chipset_tag_t; /* - * VME address modifiers + * map / unmap: map VME address ranges into kernel address space + * XXX should have mapping to CPU only to allow user mmap() without + * wasting kvm */ -#define VMEMOD_A32 0x00 /* 32-bit address */ -#define VMEMOD_A16 0x20 /* 16-bit address */ -#define VMEMOD_A24 0x30 /* 24-bit address */ +#define vme_space_map(vc, vmeaddr, len, am, datasize, swap, tag, handle, resc) \ + (*((vc)->vct_map))((vc)->cookie, (vmeaddr), (len), (am), (datasize), \ + (swap), (tag), (handle), (resc)) +#define vme_space_unmap(vc, resc) \ + (*((vc)->vct_unmap))((vc)->cookie, (resc)) -#define VMEMOD_BLT64 0x08 /* 64-bit block transfer */ -#define VMEMOD_D 0x09 /* data access */ -#define VMEMOD_I 0x0a /* instruction access */ -#define VMEMOD_B 0x0b /* block access */ +/* + * probe: check readability or call callback + */ +#define vme_probe(vc, vmeaddr, len, am, datasize, callback, cbarg) \ + (*((vc)->vct_probe))((vc)->cookie, (vmeaddr), (len), (am), (datasize), \ + (callback), (cbarg)) + +/* + * install / deinstall VME interrupt handler + */ +#define vme_intr_map(vc, level, vector, handlep) \ + (*((vc)->vct_int_map))((vc)->cookie, (level), (vector), (handlep)) +#define vme_intr_establish(vc, handle, prio, func, arg) \ + (*((vc)->vct_int_establish))((vc)->cookie, \ + (handle), (prio), (func), (arg)) +#define vme_intr_disestablish(vc, cookie) \ + (*((vc)->vct_int_unmap))((vc)->cookie, (cookie)) -#define VMEMOD_S 0x04 /* Supervisor access */ +/* + * create DMA map (which is later used by bus independant + * DMA functions) + */ +#define vme_dmamap_create(vc, size, am, datasize, swap, nsegs, segsz, bound, \ + flags, map) \ + (*((vc)->vct_dmamap_create))((vc)->cookie, (size), (am), (datasize), (swap), \ + (nsegs), (segsz), (bound), (flags), (map)) +#define vme_dmamap_destroy(vc, map) \ + (*((vc)->vct_dmamap_destroy))((vc)->cookie, (map)) -#define VMEMOD_D32 0x40 /* 32-bit access */ +/* + * allocate memory directly accessible from VME + */ +#define vme_dmamem_alloc(vc, size, am, datasize, swap, \ + segs, nsegs, rsegs, flags) \ + (*((vc)->vct_dmamem_alloc))((vc)->cookie, (size), (am), (datasize), (swap), \ + (segs), (nsegs), (rsegs), (flags)) +#define vme_dmamem_free(vc, segs, nsegs) \ + (*((vc)->vct_dmamem_free))((vc)->cookie, (segs), (nsegs)) +/* + * autoconfiguration data structures + */ -typedef u_int32_t vme_addr_t; -typedef u_int32_t vme_size_t; -typedef int vme_mod_t; +struct vme_attach_args; +typedef void (*vme_slaveconf_callback) __P((struct device *, + struct vme_attach_args *)); -typedef void *vme_intr_handle_t; +struct vmebus_attach_args { + vme_chipset_tag_t va_vct; + bus_dma_tag_t va_bdt; -struct vme_chipset_tag { - void *cookie; - int (*vct_probe) __P((void *, bus_space_tag_t, vme_addr_t, - size_t, vme_size_t, vme_mod_t, - int (*) __P((void *, void *)), void *)); + vme_slaveconf_callback va_slaveconfig; +}; - int (*vct_map) __P((void *, vme_addr_t, vme_size_t, vme_mod_t, - bus_space_tag_t, bus_space_handle_t *)); - void (*vct_unmap) __P((void *)); - int (*vct_mmap_cookie) __P((void *, vme_addr_t, vme_mod_t, - bus_space_tag_t, bus_space_handle_t *)); +struct vmebus_softc { + struct device sc_dev; - int (*vct_intr_map) __P((void *, int, int, vme_intr_handle_t *)); + vme_chipset_tag_t sc_vct; + bus_dma_tag_t sc_bdt; - void *(*vct_intr_establish) __P((void *, vme_intr_handle_t, - int (*) __P((void *)), void *)); - void (*vct_intr_disestablish) __P((void *, void *)); - void (*vct_bus_establish) __P((void *, struct device *)); + vme_slaveconf_callback slaveconfig; + struct extent *vme32ext, *vme24ext, *vme16ext; }; -typedef struct vme_chipset_tag *vme_chipset_tag_t; - -#define vme_bus_probe(ct, bt, addr, offset, size, mod, callback, arg) \ - (*ct->vct_probe)(ct->cookie, bt, addr, offset, size, mod, callback, arg) -#define vme_bus_map(ct, addr, size, mod, bt, bhp) \ - (*ct->vct_map)(ct->cookie, addr, size, mod, bt, bhp) -#define vme_bus_mmap_cookie(ct, addr, mod, bt, hp) \ - (*ct->vct_mmap_cookie)(ct->cookie, addr, mod, bt, hp) -#define vme_intr_map(ct, vec, pri, hp) \ - (*ct->vct_intr_map)(ct->cookie, vec, pri, hp) -#define vme_intr_establish(ct, h, f, a) \ - (*ct->vct_intr_establish)(ct->cookie, h, f, a) -#define vme_bus_establish(ct, d) \ - (*ct->vct_bus_establish)(ct->cookie, d) - -struct vme_busattach_args { - bus_space_tag_t vba_bustag; - bus_dma_tag_t vba_dmatag; - vme_chipset_tag_t vba_chipset_tag; + +#define VME_MAXCFRANGES 3 + +struct vme_range { + vme_addr_t offset; + vme_size_t size; + vme_am_t am; }; struct vme_attach_args { - bus_space_tag_t vma_bustag; - bus_dma_tag_t vma_dmatag; - vme_chipset_tag_t vma_chipset_tag; - -#define VMA_MAX_PADDR 1 - int vma_nreg; /* # of address locators */ - u_long vma_reg[VMA_MAX_PADDR]; + vme_chipset_tag_t va_vct; + bus_dma_tag_t va_bdt; - int vma_vec; /* VMEbus interrupt vector */ - int vma_pri; /* VMEbus interrupt priority */ + int ivector, ilevel; + int numcfranges; + struct vme_range r[VME_MAXCFRANGES]; }; -int vmesearch __P((struct device *, struct cfdata *, void *)); +/* + * address space accounting + */ +int _vme_space_alloc __P((struct vmebus_softc *, vme_addr_t, + vme_size_t, vme_am_t)); +void _vme_space_free __P((struct vmebus_softc *, vme_addr_t, + vme_size_t, vme_am_t)); +int _vme_space_get __P((struct vmebus_softc *, vme_size_t, vme_am_t, + u_long, vme_addr_t*)); + +#define vme_space_alloc(tag, addr, size, ams) \ + _vme_space_alloc(tag->bus, addr, size, ams) + +#define vme_space_free(tag, addr, size, ams) \ + _vme_space_free(tag->bus, addr, size, ams) + +#define vme_space_get(tag, size, ams, align, addr) \ + _vme_space_get(tag->bus, size, ams, align, addr) + +#endif /* KERNEL */ +#endif /* _vmevar_h_ */ |
