1 /* $NetBSD: vme.c,v 1.13 2008/04/28 20:23:15 martin 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 * 16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #include <sys/cdefs.h> 30 __KERNEL_RCSID(0, "$NetBSD: vme.c,v 1.13 2008/04/28 20:23:15 martin Exp $"); 31 32 #include <sys/param.h> 33 #include <sys/systm.h> 34 #include <sys/kernel.h> 35 #include <sys/conf.h> 36 #include <sys/malloc.h> 37 #include <sys/device.h> 38 39 #include <machine/intr.h> 40 41 #include <atari/vme/vmevar.h> 42 43 int vmematch __P((struct device *, struct cfdata *, void *)); 44 void vmeattach __P((struct device *, struct device *, void *)); 45 int vmeprint __P((void *, const char *)); 46 47 CFATTACH_DECL(vme, sizeof(struct vme_softc), 48 vmematch, vmeattach, NULL, NULL); 49 50 int vmesearch __P((struct device *, struct cfdata *, 51 const int *, void *)); 52 53 int 54 vmematch(parent, cf, aux) 55 struct device *parent; 56 struct cfdata *cf; 57 void *aux; 58 { 59 struct vmebus_attach_args *vba = aux; 60 61 if (strcmp(vba->vba_busname, cf->cf_name)) 62 return (0); 63 64 return (1); 65 } 66 67 void 68 vmeattach(parent, self, aux) 69 struct device *parent, *self; 70 void *aux; 71 { 72 struct vme_softc *sc = (struct vme_softc *)self; 73 struct vmebus_attach_args *vba = aux; 74 75 printf("\n"); 76 77 sc->sc_iot = vba->vba_iot; 78 sc->sc_memt = vba->vba_memt; 79 sc->sc_vc = vba->vba_vc; 80 81 config_search_ia(vmesearch, self, "vme", NULL); 82 } 83 84 int 85 vmeprint(aux, vme) 86 void *aux; 87 const char *vme; 88 { 89 struct vme_attach_args *va = aux; 90 91 if (va->va_iosize) 92 aprint_normal(" port 0x%x", va->va_iobase); 93 if (va->va_iosize > 1) 94 aprint_normal("-0x%x", va->va_iobase + va->va_iosize - 1); 95 if (va->va_msize) 96 aprint_normal(" iomem 0x%x", va->va_maddr); 97 if (va->va_msize > 1) 98 aprint_normal("-0x%x", va->va_maddr + va->va_msize - 1); 99 if (va->va_irq != IRQUNK) 100 aprint_normal(" irq %d", va->va_irq); 101 return (UNCONF); 102 } 103 104 int 105 vmesearch(parent, cf, ldesc, aux) 106 struct device *parent; 107 struct cfdata *cf; 108 const int *ldesc; 109 void *aux; 110 { 111 struct vme_softc *sc = (struct vme_softc *)parent; 112 struct vme_attach_args va; 113 114 va.va_iot = sc->sc_iot; 115 va.va_memt = sc->sc_memt; 116 va.va_vc = sc->sc_vc; 117 va.va_iobase = cf->cf_iobase; 118 va.va_iosize = cf->cf_iosize; 119 va.va_maddr = cf->cf_maddr; 120 va.va_msize = cf->cf_msize; 121 va.va_irq = cf->cf_irq; 122 123 if (config_match(parent, cf, &va) > 0) 124 config_attach(parent, cf, &va, vmeprint); 125 return (0); 126 } 127