Home | History | Annotate | Line # | Download | only in ibus
ibus.c revision 1.1
      1 /*	$NetBSD: ibus.c,v 1.1 1998/04/19 02:52:45 jonathan Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1998 Jonathan Stone.  All rights reserved.
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions
      8  * are met:
      9  * 1. Redistributions of source code must retain the above copyright
     10  *    notice, this list of conditions and the following disclaimer.
     11  * 2. Redistributions in binary form must reproduce the above copyright
     12  *    notice, this list of conditions and the following disclaimer in the
     13  *    documentation and/or other materials provided with the distribution.
     14  * 3. All advertising materials mentioning features or use of this software
     15  *    must display the following acknowledgement:
     16  *	This product includes software developed by Jonathan Stone for
     17  *      the NetBSD Project.
     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/cdefs.h>			/* RCS ID & Copyright macro defns */
     34 
     35 __KERNEL_RCSID(0, "$NetBSD: ibus.c,v 1.1 1998/04/19 02:52:45 jonathan Exp $");
     36 
     37 #include <sys/param.h>
     38 #include <sys/systm.h>
     39 #include <sys/device.h>
     40 
     41 #include <machine/autoconf.h>
     42 #include <pmax/ibus/ibusvar.h>
     43 #include <pmax/pmax/pmaxtype.h>
     44 
     45 static int  ibusmatch __P((struct device *, struct cfdata *, void *));
     46 static void ibusattach __P((struct device *, struct device *, void *));
     47 int  ibusprint __P((void *, const char *));
     48 
     49 struct ibus_softc {
     50 	struct device	ibd_dev;
     51 	int		ibd_ndevs;
     52 	struct ibus_attach_args *ibd_devs;
     53 	ibus_intr_establish_t (*ibd_establish);
     54 
     55 	ibus_intr_disestablish_t (*ibd_disestablish);
     56 };
     57 
     58 struct cfattach ibus_ca = {
     59         sizeof(struct ibus_softc), ibusmatch, ibusattach
     60 };
     61 
     62 extern struct cfdriver ibus_cd;
     63 
     64 
     65 static int
     66 ibusmatch(parent, cfdata, aux)
     67         struct device *parent;
     68         struct cfdata *cfdata;
     69         void *aux;
     70 {
     71 	struct ibus_dev_attach_args *ibd =  (struct ibus_dev_attach_args *)aux;
     72 
     73 	if (strcmp(ibd->ibd_busname, "ibus") != 0)  {
     74 		return 0;
     75 	}
     76 
     77 	if (systype != DS_PMAX && systype != DS_MIPSMATE && systype != DS_3MAX)
     78 		return (0);
     79 	return(1);
     80 }
     81 
     82 
     83 static void
     84 ibusattach(parent, self, aux)
     85         struct device *parent;
     86         struct device *self;
     87         void *aux;
     88 {
     89         struct ibus_softc *sc = (struct ibus_softc *)self;
     90 	struct ibus_dev_attach_args* ibd_args = aux;
     91         struct ibus_attach_args *child;
     92         int i;
     93 
     94         printf("\n");
     95 
     96 	sc->ibd_ndevs = ibd_args->ibd_ndevs;
     97 	sc->ibd_devs = ibd_args->ibd_devs;
     98         sc->ibd_establish = ibd_args->ibd_establish;
     99         sc->ibd_disestablish = ibd_args->ibd_disestablish;
    100 
    101 	for (i = 0; i <  sc->ibd_ndevs; i++) {
    102 		child = &sc->ibd_devs[i];
    103 		config_found(self, child, ibusprint);
    104 	}
    105 }
    106 
    107 int
    108 ibusprint(aux, pnp)
    109 	void *aux;
    110 	const char *pnp;
    111 {
    112 	if (pnp)
    113 		return (QUIET);
    114 	return (UNCONF);
    115 }
    116 
    117 
    118 void
    119 ibus_intr_establish(cookie, level, handler, arg)
    120 	void * cookie;
    121 	int level;
    122 	int (*handler) __P((intr_arg_t));
    123 	intr_arg_t arg;
    124 {
    125 	((struct ibus_softc*)ibus_cd.cd_devs[0])->
    126 	      ibd_establish(cookie, level, handler, arg);
    127 }
    128 
    129 
    130 void
    131 ibus_intr_disestablish(ia)
    132 	struct ibus_attach_args *ia;
    133 {
    134 	((struct ibus_softc*)ibus_cd.cd_devs[0])->ibd_disestablish(ia);
    135 }
    136