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