Home | History | Annotate | Line # | Download | only in dev
obio.c revision 1.1
      1  1.1  deraadt /*	$NetBSD: obio.c,v 1.1 1994/08/24 09:16:46 deraadt Exp $	*/
      2  1.1  deraadt 
      3  1.1  deraadt /*
      4  1.1  deraadt  * Copyright (c) 1993, 1994 Theo de Raadt
      5  1.1  deraadt  * All rights reserved.
      6  1.1  deraadt  *
      7  1.1  deraadt  * Redistribution and use in source and binary forms, with or without
      8  1.1  deraadt  * modification, are permitted provided that the following conditions
      9  1.1  deraadt  * are met:
     10  1.1  deraadt  * 1. Redistributions of source code must retain the above copyright
     11  1.1  deraadt  *    notice, this list of conditions and the following disclaimer.
     12  1.1  deraadt  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  deraadt  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  deraadt  *    documentation and/or other materials provided with the distribution.
     15  1.1  deraadt  * 3. All advertising materials mentioning features or use of this software
     16  1.1  deraadt  *    must display the following acknowledgement:
     17  1.1  deraadt  *	This product includes software developed by Theo de Raadt.
     18  1.1  deraadt  * 4. The name of the author may not be used to endorse or promote products
     19  1.1  deraadt  *    derived from this software without specific prior written permission.
     20  1.1  deraadt  *
     21  1.1  deraadt  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  1.1  deraadt  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  1.1  deraadt  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  1.1  deraadt  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  1.1  deraadt  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  1.1  deraadt  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  1.1  deraadt  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  1.1  deraadt  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  1.1  deraadt  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  1.1  deraadt  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  1.1  deraadt  */
     32  1.1  deraadt 
     33  1.1  deraadt #include <sys/param.h>
     34  1.1  deraadt #include <sys/device.h>
     35  1.1  deraadt #include <sys/malloc.h>
     36  1.1  deraadt 
     37  1.1  deraadt #ifdef DEBUG
     38  1.1  deraadt #include <sys/proc.h>
     39  1.1  deraadt #include <sys/syslog.h>
     40  1.1  deraadt #endif
     41  1.1  deraadt 
     42  1.1  deraadt #include <vm/vm.h>
     43  1.1  deraadt 
     44  1.1  deraadt #include <machine/autoconf.h>
     45  1.1  deraadt #include <machine/pmap.h>
     46  1.1  deraadt 
     47  1.1  deraadt struct vme_attach_args {
     48  1.1  deraadt 	u_long	paddr;
     49  1.1  deraadt 	int	irq;
     50  1.1  deraadt };
     51  1.1  deraadt 
     52  1.1  deraadt struct obio_softc {
     53  1.1  deraadt 	struct	device sc_dev;		/* base device */
     54  1.1  deraadt 	int	nothing;
     55  1.1  deraadt };
     56  1.1  deraadt 
     57  1.1  deraadt /* autoconfiguration driver */
     58  1.1  deraadt static int	obiomatch(struct device *, struct cfdata *, void *);
     59  1.1  deraadt static void	obioattach(struct device *, struct device *, void *);
     60  1.1  deraadt struct cfdriver obiocd = { NULL, "cgsix", obiomatch, obioattach,
     61  1.1  deraadt 	DV_DULL, sizeof(struct obio_softc)
     62  1.1  deraadt };
     63  1.1  deraadt 
     64  1.1  deraadt int
     65  1.1  deraadt obiomatch(parent, cf, args)
     66  1.1  deraadt 	struct device *parent;
     67  1.1  deraadt 	struct cfdata *cf;
     68  1.1  deraadt 	void *args;
     69  1.1  deraadt {
     70  1.1  deraadt printf("obiomatch\n");
     71  1.1  deraadt 	if (cputyp != CPU_SUN4)
     72  1.1  deraadt 		return 0;
     73  1.1  deraadt 	return 1;
     74  1.1  deraadt }
     75  1.1  deraadt 
     76  1.1  deraadt int
     77  1.1  deraadt obio_print(args, obio)
     78  1.1  deraadt 	void *args;
     79  1.1  deraadt 	char *obio;
     80  1.1  deraadt {
     81  1.1  deraadt 	printf("obio_print ");
     82  1.1  deraadt 	return (UNCONF);
     83  1.1  deraadt }
     84  1.1  deraadt 
     85  1.1  deraadt void
     86  1.1  deraadt obioattach(parent, self, aux)
     87  1.1  deraadt 	struct device *parent, *self;
     88  1.1  deraadt 	void *aux;
     89  1.1  deraadt {
     90  1.1  deraadt 	extern struct cfdata cfdata[];
     91  1.1  deraadt 
     92  1.1  deraadt 	register struct obio_softc *sc = (struct obio_softc *)self;
     93  1.1  deraadt 	struct vme_attach_args va;
     94  1.1  deraadt 	register short *p;
     95  1.1  deraadt 	struct cfdata *cf;
     96  1.1  deraadt 
     97  1.1  deraadt 	if (sc->sc_dev.dv_unit > 0) {
     98  1.1  deraadt 		printf(" unsupported\n");
     99  1.1  deraadt 		return;
    100  1.1  deraadt 	}
    101  1.1  deraadt 
    102  1.1  deraadt 	for (cf = cfdata; cf->cf_driver; cf++) {
    103  1.1  deraadt 		if (cf->cf_fstate == FSTATE_FOUND)
    104  1.1  deraadt 			continue;
    105  1.1  deraadt 		for (p = cf->cf_parents; *p >= 0; p++)
    106  1.1  deraadt 			if (parent->dv_cfdata == &cfdata[*p]) {
    107  1.1  deraadt 				va.paddr = cf->cf_loc[0];
    108  1.1  deraadt 				va.irq = cf->cf_loc[1];
    109  1.1  deraadt 				if ((*cf->cf_driver->cd_match)(self, cf, &va))
    110  1.1  deraadt 					config_attach(self, cf, &va, NULL);
    111  1.1  deraadt 			}
    112  1.1  deraadt 	}
    113  1.1  deraadt }
    114