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