Home | History | Annotate | Line # | Download | only in tc
ioasic_subr.c revision 1.1
      1  1.1  jonathan /*
      2  1.1  jonathan  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
      3  1.1  jonathan  * All rights reserved.
      4  1.1  jonathan  *
      5  1.1  jonathan  * Author: Keith Bostic, Chris G. Demetriou
      6  1.1  jonathan  *
      7  1.1  jonathan  * Permission to use, copy, modify and distribute this software and
      8  1.1  jonathan  * its documentation is hereby granted, provided that both the copyright
      9  1.1  jonathan  * notice and this permission notice appear in all copies of the
     10  1.1  jonathan  * software, derivative works or modified versions, and any portions
     11  1.1  jonathan  * thereof, and that both notices appear in supporting documentation.
     12  1.1  jonathan  *
     13  1.1  jonathan  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     14  1.1  jonathan  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     15  1.1  jonathan  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     16  1.1  jonathan  *
     17  1.1  jonathan  * Carnegie Mellon requests users of this software to return to
     18  1.1  jonathan  *
     19  1.1  jonathan  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     20  1.1  jonathan  *  School of Computer Science
     21  1.1  jonathan  *  Carnegie Mellon University
     22  1.1  jonathan  *  Pittsburgh PA 15213-3890
     23  1.1  jonathan  *
     24  1.1  jonathan  * any improvements or extensions that they make and grant Carnegie the
     25  1.1  jonathan  * rights to redistribute these changes.
     26  1.1  jonathan  */
     27  1.1  jonathan 
     28  1.1  jonathan 
     29  1.1  jonathan #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
     30  1.1  jonathan 
     31  1.1  jonathan __KERNEL_RCSID(0, "$NetBSD: ioasic_subr.c,v 1.1 1999/03/15 01:25:26 jonathan Exp $");
     32  1.1  jonathan 
     33  1.1  jonathan #include <sys/param.h>
     34  1.1  jonathan #include <sys/systm.h>
     35  1.1  jonathan #include <sys/device.h>
     36  1.1  jonathan #include <dev/tc/tcvar.h>
     37  1.1  jonathan #include <dev/tc/ioasicvar.h>
     38  1.1  jonathan 
     39  1.1  jonathan int     ioasicprint(void *, const char *);
     40  1.1  jonathan 
     41  1.1  jonathan int
     42  1.1  jonathan ioasicprint(aux, pnp)
     43  1.1  jonathan 	void *aux;
     44  1.1  jonathan 	const char *pnp;
     45  1.1  jonathan {
     46  1.1  jonathan 	struct ioasicdev_attach_args *d = aux;
     47  1.1  jonathan 
     48  1.1  jonathan 	if (pnp)
     49  1.1  jonathan 		printf("%s at %s", d->iada_modname, pnp);
     50  1.1  jonathan 	printf(" offset 0x%lx", (long)d->iada_offset);
     51  1.1  jonathan 	return (UNCONF);
     52  1.1  jonathan }
     53  1.1  jonathan 
     54  1.1  jonathan int
     55  1.1  jonathan ioasic_submatch(match, d)
     56  1.1  jonathan 	struct cfdata *match;
     57  1.1  jonathan 	struct ioasicdev_attach_args *d;
     58  1.1  jonathan {
     59  1.1  jonathan 
     60  1.1  jonathan 	return ((match->ioasiccf_offset == d->iada_offset) ||
     61  1.1  jonathan 		(match->ioasiccf_offset == IOASIC_OFFSET_UNKNOWN));
     62  1.1  jonathan }
     63  1.1  jonathan 
     64  1.1  jonathan void
     65  1.1  jonathan ioasic_attach_devs(sc, ioasic_devs, ioasic_ndevs)
     66  1.1  jonathan 	struct ioasic_softc *sc;
     67  1.1  jonathan 	struct ioasic_dev *ioasic_devs;
     68  1.1  jonathan 	int ioasic_ndevs;
     69  1.1  jonathan {
     70  1.1  jonathan 	struct ioasicdev_attach_args idev;
     71  1.1  jonathan 	int i;
     72  1.1  jonathan 
     73  1.1  jonathan         /*
     74  1.1  jonathan 	 * Try to configure each device.
     75  1.1  jonathan 	 */
     76  1.1  jonathan         for (i = 0; i < ioasic_ndevs; i++) {
     77  1.1  jonathan 		strncpy(idev.iada_modname, ioasic_devs[i].iad_modname,
     78  1.1  jonathan 			TC_ROM_LLEN);
     79  1.1  jonathan 		idev.iada_modname[TC_ROM_LLEN] = '\0';
     80  1.1  jonathan 		idev.iada_offset = ioasic_devs[i].iad_offset;
     81  1.1  jonathan 		idev.iada_addr = sc->sc_base + ioasic_devs[i].iad_offset;
     82  1.1  jonathan 		idev.iada_cookie = ioasic_devs[i].iad_cookie;
     83  1.1  jonathan 
     84  1.1  jonathan                 /* Tell the autoconfig machinery we've found the hardware. */
     85  1.1  jonathan                 config_found(&sc->sc_dv, &idev, ioasicprint);
     86  1.1  jonathan         }
     87  1.1  jonathan }
     88