isa.c revision 1.62 1 /* $NetBSD: isa.c,v 1.62 1994/11/04 02:55:32 mycroft Exp $ */
2
3 /*-
4 * Copyright (c) 1993, 1994 Charles Hannum. 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 Charles Hannum.
17 * 4. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include <sys/param.h>
33 #include <sys/systm.h>
34 #include <sys/kernel.h>
35 #include <sys/conf.h>
36 #include <sys/malloc.h>
37 #include <sys/device.h>
38
39 #include <i386/isa/isareg.h>
40 #include <i386/isa/isavar.h>
41
42 /* sorry, has to be here, no place else really suitable */
43 #include <machine/pc/display.h>
44 u_short *Crtat = (u_short *)MONO_BUF;
45
46 int isamatch __P((struct device *, void *, void *));
47 void isaattach __P((struct device *, struct device *, void *));
48
49 struct cfdriver isacd = {
50 NULL, "isa", isamatch, isaattach, DV_DULL, sizeof(struct device), 1
51 };
52
53 int
54 isamatch(parent, match, aux)
55 struct device *parent;
56 void *match, *aux;
57 {
58
59 return (1);
60 }
61
62 int
63 isaprint(aux, isa)
64 void *aux;
65 char *isa;
66 {
67 struct isa_attach_args *ia = aux;
68
69 if (ia->ia_iosize)
70 printf(" port 0x%x", ia->ia_iobase);
71 if (ia->ia_iosize > 1)
72 printf("-0x%x", ia->ia_iobase + ia->ia_iosize - 1);
73 if (ia->ia_msize)
74 printf(" iomem 0x%x", ia->ia_maddr - atdevbase + 0xa0000);
75 if (ia->ia_msize > 1)
76 printf("-0x%x",
77 ia->ia_maddr - atdevbase + 0xa0000 + ia->ia_msize - 1);
78 if (ia->ia_irq)
79 printf(" irq %d", ffs(ia->ia_irq) - 1);
80 if (ia->ia_drq != (u_short)-1)
81 printf(" drq %d", ia->ia_drq);
82 /* XXXX print flags */
83 return (QUIET);
84 }
85
86 int
87 isasubmatch(parent, match, aux)
88 struct device *parent;
89 void *match, *aux;
90 {
91 struct device *self = match;
92 struct cfdata *cf = self->dv_cfdata;
93 struct isa_attach_args ia;
94
95 ia.ia_iobase = cf->cf_loc[0];
96 ia.ia_iosize = 0x666;
97 ia.ia_maddr = cf->cf_loc[2] - 0xa0000 + atdevbase;
98 ia.ia_msize = cf->cf_loc[3];
99 ia.ia_irq = (cf->cf_loc[4] == -1) ? IRQUNK : (1 << cf->cf_loc[4]);
100 ia.ia_drq = cf->cf_loc[5];
101
102 if ((*cf->cf_driver->cd_match)(parent, match, &ia) <= 0) {
103 /*
104 * If we don't do this, isaattach() will repeatedly try to
105 * probe devices that weren't found. But we need to be careful
106 * to do it only for the ISA bus, or we would cause things like
107 * `com0 at ast? slave ?' to not probe on the second ast.
108 */
109 if (parent->dv_cfdata->cf_driver == &isacd)
110 cf->cf_fstate = FSTATE_FOUND;
111 return (0);
112 }
113
114 config_attach(parent, match, &ia, isaprint);
115 return (1);
116 }
117
118 void
119 isaattach(parent, self, aux)
120 struct device *parent, *self;
121 void *aux;
122 {
123
124 printf("\n");
125
126 while (config_search(isasubmatch, self, NULL) != NULL);
127 }
128