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