Annotation of sys/arch/mvme68k/dev/vsdma.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: vsdma.c,v 1.12 2006/11/28 23:59:45 dlg Exp $ */
! 2: /*
! 3: * Copyright (c) 1999 Steve Murphree, Jr.
! 4: * All rights reserved.
! 5: *
! 6: * Redistribution and use in source and binary forms, with or without
! 7: * modification, are permitted provided that the following conditions
! 8: * are met:
! 9: * 1. Redistributions of source code must retain the above copyright
! 10: * notice, this list of conditions and the following disclaimer.
! 11: * 2. Redistributions in binary form must reproduce the above copyright
! 12: * notice, this list of conditions and the following disclaimer in the
! 13: * documentation and/or other materials provided with the distribution.
! 14: * 3. All advertising materials mentioning features or use of this software
! 15: * must display the following acknowledgement:
! 16: * This product includes software developed by the University of
! 17: * California, Berkeley and its contributors.
! 18: * 4. Neither the name of the University nor the names of its contributors
! 19: * may be used to endorse or promote products derived from this software
! 20: * without specific prior written permission.
! 21: *
! 22: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
! 23: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! 24: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! 25: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
! 26: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! 27: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
! 28: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 29: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
! 30: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
! 31: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! 32: * SUCH DAMAGE.
! 33: *
! 34: * @(#)vsdma.c
! 35: */
! 36:
! 37: /*
! 38: * MVME328 scsi adaptor driver
! 39: */
! 40:
! 41: #include <sys/param.h>
! 42: #include <sys/systm.h>
! 43: #include <sys/kernel.h>
! 44: #include <sys/device.h>
! 45:
! 46: #include <scsi/scsi_all.h>
! 47: #include <scsi/scsiconf.h>
! 48:
! 49: #include <machine/autoconf.h>
! 50:
! 51: #include <mvme68k/dev/vsreg.h>
! 52: #include <mvme68k/dev/vsvar.h>
! 53: #include <mvme68k/dev/vme.h>
! 54:
! 55: int vsmatch(struct device *, void *, void *);
! 56: void vsattach(struct device *, struct device *, void *);
! 57: int vsprint(void *auxp, char *);
! 58: void vs_initialize(struct vs_softc *);
! 59: int vs_intr(struct vs_softc *);
! 60: int vs_nintr(void *);
! 61: int vs_eintr(void *);
! 62:
! 63: struct scsi_adapter vs_scsiswitch = {
! 64: vs_scsicmd,
! 65: vs_minphys,
! 66: 0, /* no lun support */
! 67: 0, /* no lun support */
! 68: };
! 69:
! 70: struct scsi_device vs_scsidev = {
! 71: NULL, /* use default error handler */
! 72: NULL, /* do not have a start function */
! 73: NULL, /* have no async handler */
! 74: NULL, /* Use default done routine */
! 75: };
! 76:
! 77: struct cfattach vs_ca = {
! 78: sizeof(struct vs_softc), vsmatch, vsattach,
! 79: };
! 80:
! 81: struct cfdriver vs_cd = {
! 82: NULL, "vs", DV_DULL
! 83: };
! 84:
! 85: int
! 86: vsmatch(pdp, vcf, args)
! 87: struct device *pdp;
! 88: void *vcf, *args;
! 89: {
! 90: struct confargs *ca = args;
! 91: return(!badvaddr((vaddr_t)ca->ca_vaddr, 1));
! 92: }
! 93:
! 94: void
! 95: vsattach(parent, self, auxp)
! 96: struct device *parent, *self;
! 97: void *auxp;
! 98: {
! 99: struct vs_softc *sc = (struct vs_softc *)self;
! 100: struct confargs *ca = auxp;
! 101: struct scsibus_attach_args saa;
! 102: struct vsreg * rp;
! 103: int tmp;
! 104:
! 105: sc->sc_vsreg = rp = (void *)ca->ca_vaddr;
! 106:
! 107: sc->sc_ipl = ca->ca_ipl;
! 108: sc->sc_nvec = ca->ca_vec + 0;
! 109: sc->sc_evec = ca->ca_vec + 1;
! 110: sc->sc_link.adapter_softc = sc;
! 111: sc->sc_link.adapter_target = 7;
! 112: sc->sc_link.adapter = &vs_scsiswitch;
! 113: sc->sc_link.device = &vs_scsidev;
! 114: sc->sc_link.luns = 1;
! 115: sc->sc_link.openings = 1;
! 116:
! 117: sc->sc_ih_n.ih_fn = vs_nintr;
! 118: sc->sc_ih_n.ih_arg = sc;
! 119: sc->sc_ih_n.ih_ipl = ca->ca_ipl;
! 120:
! 121: sc->sc_ih_e.ih_fn = vs_eintr;
! 122: sc->sc_ih_e.ih_arg = sc;
! 123: sc->sc_ih_e.ih_ipl = ca->ca_ipl;
! 124:
! 125: vs_initialize(sc);
! 126:
! 127: snprintf(sc->sc_intrname_e, sizeof sc->sc_intrname_e,
! 128: "%s_err", self->dv_xname);
! 129:
! 130: vmeintr_establish(sc->sc_nvec, &sc->sc_ih_n, self->dv_xname);
! 131: vmeintr_establish(sc->sc_evec, &sc->sc_ih_e, sc->sc_intrname_e);
! 132:
! 133: /*
! 134: * attach all scsi units on us, watching for boot device
! 135: * (see device_register).
! 136: */
! 137: bzero(&saa, sizeof(saa));
! 138: saa.saa_sc_link = &sc->sc_link;
! 139: tmp = bootpart;
! 140: if (ca->ca_paddr != bootaddr)
! 141: bootpart = -1; /* invalid flag to device_register */
! 142: config_found(self, &saa, scsiprint);
! 143: bootpart = tmp; /* restore old value */
! 144: }
! 145:
! 146: /*
! 147: * print diag if pnp is NULL else just extra
! 148: */
! 149: int
! 150: vsprint(auxp, pnp)
! 151: void *auxp;
! 152: char *pnp;
! 153: {
! 154: if (pnp == NULL)
! 155: return (UNCONF);
! 156: return (QUIET);
! 157: }
! 158:
! 159: /* normal interrupt function */
! 160: int
! 161: vs_nintr(arg)
! 162: void *arg;
! 163: {
! 164: struct vs_softc *sc = (struct vs_softc *)arg;
! 165:
! 166: #ifdef SDEBUG
! 167: printf("Normal Interrupt!!!\n");
! 168: #endif
! 169: vs_intr(sc);
! 170: return (1);
! 171: }
! 172:
! 173: /* error interrupt function */
! 174: int
! 175: vs_eintr(arg)
! 176: void *arg;
! 177: {
! 178: struct vs_softc *sc = (struct vs_softc *)arg;
! 179:
! 180: #ifdef SDEBUG
! 181: printf("Error Interrupt!!!\n");
! 182: #endif
! 183: vs_intr(sc);
! 184: return (1);
! 185: }
! 186:
! 187:
CVSweb