Home | History | Annotate | Line # | Download | only in ibus
ibus.c revision 1.1
      1  1.1  jonathan /*	$NetBSD: ibus.c,v 1.1 1998/04/19 02:52:45 jonathan Exp $	*/
      2  1.1  jonathan 
      3  1.1  jonathan /*
      4  1.1  jonathan  * Copyright (c) 1998 Jonathan Stone.  All rights reserved.
      5  1.1  jonathan  *
      6  1.1  jonathan  * Redistribution and use in source and binary forms, with or without
      7  1.1  jonathan  * modification, are permitted provided that the following conditions
      8  1.1  jonathan  * are met:
      9  1.1  jonathan  * 1. Redistributions of source code must retain the above copyright
     10  1.1  jonathan  *    notice, this list of conditions and the following disclaimer.
     11  1.1  jonathan  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.1  jonathan  *    notice, this list of conditions and the following disclaimer in the
     13  1.1  jonathan  *    documentation and/or other materials provided with the distribution.
     14  1.1  jonathan  * 3. All advertising materials mentioning features or use of this software
     15  1.1  jonathan  *    must display the following acknowledgement:
     16  1.1  jonathan  *	This product includes software developed by Jonathan Stone for
     17  1.1  jonathan  *      the NetBSD Project.
     18  1.1  jonathan  * 4. The name of the author may not be used to endorse or promote products
     19  1.1  jonathan  *    derived from this software without specific prior written permission.
     20  1.1  jonathan  *
     21  1.1  jonathan  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  1.1  jonathan  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  1.1  jonathan  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  1.1  jonathan  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  1.1  jonathan  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  1.1  jonathan  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  1.1  jonathan  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  1.1  jonathan  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  1.1  jonathan  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  1.1  jonathan  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  1.1  jonathan  */
     32  1.1  jonathan 
     33  1.1  jonathan #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
     34  1.1  jonathan 
     35  1.1  jonathan __KERNEL_RCSID(0, "$NetBSD: ibus.c,v 1.1 1998/04/19 02:52:45 jonathan Exp $");
     36  1.1  jonathan 
     37  1.1  jonathan #include <sys/param.h>
     38  1.1  jonathan #include <sys/systm.h>
     39  1.1  jonathan #include <sys/device.h>
     40  1.1  jonathan 
     41  1.1  jonathan #include <machine/autoconf.h>
     42  1.1  jonathan #include <pmax/ibus/ibusvar.h>
     43  1.1  jonathan #include <pmax/pmax/pmaxtype.h>
     44  1.1  jonathan 
     45  1.1  jonathan static int  ibusmatch __P((struct device *, struct cfdata *, void *));
     46  1.1  jonathan static void ibusattach __P((struct device *, struct device *, void *));
     47  1.1  jonathan int  ibusprint __P((void *, const char *));
     48  1.1  jonathan 
     49  1.1  jonathan struct ibus_softc {
     50  1.1  jonathan 	struct device	ibd_dev;
     51  1.1  jonathan 	int		ibd_ndevs;
     52  1.1  jonathan 	struct ibus_attach_args *ibd_devs;
     53  1.1  jonathan 	ibus_intr_establish_t (*ibd_establish);
     54  1.1  jonathan 
     55  1.1  jonathan 	ibus_intr_disestablish_t (*ibd_disestablish);
     56  1.1  jonathan };
     57  1.1  jonathan 
     58  1.1  jonathan struct cfattach ibus_ca = {
     59  1.1  jonathan         sizeof(struct ibus_softc), ibusmatch, ibusattach
     60  1.1  jonathan };
     61  1.1  jonathan 
     62  1.1  jonathan extern struct cfdriver ibus_cd;
     63  1.1  jonathan 
     64  1.1  jonathan 
     65  1.1  jonathan static int
     66  1.1  jonathan ibusmatch(parent, cfdata, aux)
     67  1.1  jonathan         struct device *parent;
     68  1.1  jonathan         struct cfdata *cfdata;
     69  1.1  jonathan         void *aux;
     70  1.1  jonathan {
     71  1.1  jonathan 	struct ibus_dev_attach_args *ibd =  (struct ibus_dev_attach_args *)aux;
     72  1.1  jonathan 
     73  1.1  jonathan 	if (strcmp(ibd->ibd_busname, "ibus") != 0)  {
     74  1.1  jonathan 		return 0;
     75  1.1  jonathan 	}
     76  1.1  jonathan 
     77  1.1  jonathan 	if (systype != DS_PMAX && systype != DS_MIPSMATE && systype != DS_3MAX)
     78  1.1  jonathan 		return (0);
     79  1.1  jonathan 	return(1);
     80  1.1  jonathan }
     81  1.1  jonathan 
     82  1.1  jonathan 
     83  1.1  jonathan static void
     84  1.1  jonathan ibusattach(parent, self, aux)
     85  1.1  jonathan         struct device *parent;
     86  1.1  jonathan         struct device *self;
     87  1.1  jonathan         void *aux;
     88  1.1  jonathan {
     89  1.1  jonathan         struct ibus_softc *sc = (struct ibus_softc *)self;
     90  1.1  jonathan 	struct ibus_dev_attach_args* ibd_args = aux;
     91  1.1  jonathan         struct ibus_attach_args *child;
     92  1.1  jonathan         int i;
     93  1.1  jonathan 
     94  1.1  jonathan         printf("\n");
     95  1.1  jonathan 
     96  1.1  jonathan 	sc->ibd_ndevs = ibd_args->ibd_ndevs;
     97  1.1  jonathan 	sc->ibd_devs = ibd_args->ibd_devs;
     98  1.1  jonathan         sc->ibd_establish = ibd_args->ibd_establish;
     99  1.1  jonathan         sc->ibd_disestablish = ibd_args->ibd_disestablish;
    100  1.1  jonathan 
    101  1.1  jonathan 	for (i = 0; i <  sc->ibd_ndevs; i++) {
    102  1.1  jonathan 		child = &sc->ibd_devs[i];
    103  1.1  jonathan 		config_found(self, child, ibusprint);
    104  1.1  jonathan 	}
    105  1.1  jonathan }
    106  1.1  jonathan 
    107  1.1  jonathan int
    108  1.1  jonathan ibusprint(aux, pnp)
    109  1.1  jonathan 	void *aux;
    110  1.1  jonathan 	const char *pnp;
    111  1.1  jonathan {
    112  1.1  jonathan 	if (pnp)
    113  1.1  jonathan 		return (QUIET);
    114  1.1  jonathan 	return (UNCONF);
    115  1.1  jonathan }
    116  1.1  jonathan 
    117  1.1  jonathan 
    118  1.1  jonathan void
    119  1.1  jonathan ibus_intr_establish(cookie, level, handler, arg)
    120  1.1  jonathan 	void * cookie;
    121  1.1  jonathan 	int level;
    122  1.1  jonathan 	int (*handler) __P((intr_arg_t));
    123  1.1  jonathan 	intr_arg_t arg;
    124  1.1  jonathan {
    125  1.1  jonathan 	((struct ibus_softc*)ibus_cd.cd_devs[0])->
    126  1.1  jonathan 	      ibd_establish(cookie, level, handler, arg);
    127  1.1  jonathan }
    128  1.1  jonathan 
    129  1.1  jonathan 
    130  1.1  jonathan void
    131  1.1  jonathan ibus_intr_disestablish(ia)
    132  1.1  jonathan 	struct ibus_attach_args *ia;
    133  1.1  jonathan {
    134  1.1  jonathan 	((struct ibus_softc*)ibus_cd.cd_devs[0])->ibd_disestablish(ia);
    135  1.1  jonathan }
    136