1 /* $NetBSD: vme.c,v 1.2 1997/10/09 07:41:04 jtc Exp $ */ 2 3 /*- 4 * Copyright (c) 1997 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by the NetBSD 18 * Foundation, Inc. and its contributors. 19 * 4. Neither the name of The NetBSD Foundation nor the names of its 20 * contributors may be used to endorse or promote products derived 21 * from this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 24 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 27 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 * POSSIBILITY OF SUCH DAMAGE. 34 */ 35 36 #include <sys/param.h> 37 #include <sys/systm.h> 38 #include <sys/kernel.h> 39 #include <sys/conf.h> 40 #include <sys/malloc.h> 41 #include <sys/device.h> 42 43 #include <machine/intr.h> 44 45 #include <atari/vme/vmevar.h> 46 47 int vmematch __P((struct device *, struct cfdata *, void *)); 48 void vmeattach __P((struct device *, struct device *, void *)); 49 int vmeprint __P((void *, const char *)); 50 51 struct cfattach vme_ca = { 52 sizeof(struct vme_softc), vmematch, vmeattach 53 }; 54 55 struct cfdriver vme_cd = { 56 NULL, "vme", DV_DULL 57 }; 58 59 int vmesearch __P((struct device *, struct cfdata *, void *)); 60 61 int 62 vmematch(parent, cf, aux) 63 struct device *parent; 64 struct cfdata *cf; 65 void *aux; 66 { 67 struct vmebus_attach_args *vba = aux; 68 69 if (strcmp(vba->vba_busname, cf->cf_driver->cd_name)) 70 return (0); 71 72 return (1); 73 } 74 75 void 76 vmeattach(parent, self, aux) 77 struct device *parent, *self; 78 void *aux; 79 { 80 struct vme_softc *sc = (struct vme_softc *)self; 81 struct vmebus_attach_args *vba = aux; 82 83 printf("\n"); 84 85 sc->sc_iot = vba->vba_iot; 86 sc->sc_memt = vba->vba_memt; 87 sc->sc_vc = vba->vba_vc; 88 89 config_search(vmesearch, self, NULL); 90 } 91 92 int 93 vmeprint(aux, vme) 94 void *aux; 95 const char *vme; 96 { 97 struct vme_attach_args *va = aux; 98 99 if (va->va_iosize) 100 printf(" port 0x%x", va->va_iobase); 101 if (va->va_iosize > 1) 102 printf("-0x%x", va->va_iobase + va->va_iosize - 1); 103 if (va->va_msize) 104 printf(" iomem 0x%x", va->va_maddr); 105 if (va->va_msize > 1) 106 printf("-0x%x", va->va_maddr + va->va_msize - 1); 107 if (va->va_irq != IRQUNK) 108 printf(" irq %d", va->va_irq); 109 return (UNCONF); 110 } 111 112 int 113 vmesearch(parent, cf, aux) 114 struct device *parent; 115 struct cfdata *cf; 116 void *aux; 117 { 118 struct vme_softc *sc = (struct vme_softc *)parent; 119 struct vme_attach_args va; 120 121 va.va_iot = sc->sc_iot; 122 va.va_memt = sc->sc_memt; 123 va.va_vc = sc->sc_vc; 124 va.va_iobase = cf->cf_iobase; 125 va.va_iosize = cf->cf_iosize; 126 va.va_maddr = cf->cf_maddr; 127 va.va_msize = cf->cf_msize; 128 va.va_irq = cf->cf_irq; 129 130 if ((*cf->cf_attach->ca_match)(parent, cf, &va) > 0) 131 config_attach(parent, cf, &va, vmeprint); 132 return (0); 133 } 134