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