Home | History | Annotate | Line # | Download | only in vme
vme.c revision 1.1
      1 /*	$NetBSD: vme.c,v 1.1 1997/11/01 22:56:22 pk Exp $	*/
      2 /*-
      3  * Copyright (c) 1997 The NetBSD Foundation, Inc.
      4  * All rights reserved.
      5  *
      6  * This code is derived from software contributed to The NetBSD Foundation
      7  * by Paul Kranenburg.
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  * 3. All advertising materials mentioning features or use of this software
     18  *    must display the following acknowledgement:
     19  *        This product includes software developed by the NetBSD
     20  *        Foundation, Inc. and its contributors.
     21  * 4. Neither the name of The NetBSD Foundation nor the names of its
     22  *    contributors may be used to endorse or promote products derived
     23  *    from this software without specific prior written permission.
     24  *
     25  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     26  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     29  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35  * POSSIBILITY OF SUCH DAMAGE.
     36  */
     37 
     38 #include <sys/param.h>
     39 #include <sys/systm.h>
     40 #include <sys/device.h>
     41 #include <sys/malloc.h>
     42 
     43 #include <vm/vm.h>
     44 
     45 #include <dev/vme/vmevar.h>
     46 
     47 #include "locators.h"
     48 
     49 struct vmebus_softc {
     50 	struct device	 sc_dev;	/* base device */
     51 	struct vmebusreg *sc_reg; 	/* VME control registers */
     52 	struct vmebusvec *sc_vec;	/* VME interrupt vector */
     53 	struct rom_range *sc_range;	/* ROM range property */
     54 	int		 sc_nrange;
     55 };
     56 
     57 int		vmeprint __P((void *, const char *));
     58 
     59 int
     60 vmeprint(args, name)
     61 	void *args;
     62 	const char *name;
     63 {
     64 	struct vme_attach_args *va = args;
     65 
     66 	if (name)
     67 		printf("[%s at %s]", "???", name);
     68 
     69 	printf(" addr %lx", va->vma_reg[0]);
     70 	printf(" pri %x", va->vma_pri);
     71 	printf(" vec %x", va->vma_vec);
     72 	return (UNCONF);
     73 }
     74 
     75 
     76 int
     77 vmesearch(parent, cf, aux)
     78 	struct device *parent;
     79 	struct cfdata *cf;
     80 	void *aux;
     81 {
     82 	struct vme_busattach_args *vba = (struct vme_busattach_args *)aux;
     83 	struct vme_attach_args vma;
     84 	int i;
     85 
     86 	vma.vma_bustag = vba->vba_bustag;
     87 	vma.vma_dmatag = vba->vba_dmatag;
     88 	vma.vma_chipset_tag = vba->vba_chipset_tag;
     89 
     90 	vma.vma_nreg = 1;
     91 	for (i = 0; i < vma.vma_nreg; i++)
     92 		/* XXX - or whatever shape this config enhancement takes on */
     93 		vma.vma_reg[0] = cf->cf_loc[VMECF_ADDR + i];
     94 
     95 	vma.vma_vec = cf->cf_loc[VMECF_VEC];
     96 	vma.vma_pri = cf->cf_loc[VMECF_PRI];
     97 
     98 	if ((*cf->cf_attach->ca_match)(parent, cf, &vma) == 0)
     99 		return (0);
    100 
    101 	config_attach(parent, cf, &vma, vmeprint);
    102 	return (0);
    103 }
    104