eisa_machdep.c revision 1.12.2.2 1 /* $NetBSD: eisa_machdep.c,v 1.12.2.2 2002/01/08 00:25:16 nathanw Exp $ */
2
3 /*-
4 * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the NetBSD
22 * Foundation, Inc. and its contributors.
23 * 4. Neither the name of The NetBSD Foundation nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40 /*
41 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
42 *
43 * Redistribution and use in source and binary forms, with or without
44 * modification, are permitted provided that the following conditions
45 * are met:
46 * 1. Redistributions of source code must retain the above copyright
47 * notice, this list of conditions and the following disclaimer.
48 * 2. Redistributions in binary form must reproduce the above copyright
49 * notice, this list of conditions and the following disclaimer in the
50 * documentation and/or other materials provided with the distribution.
51 * 3. All advertising materials mentioning features or use of this software
52 * must display the following acknowledgement:
53 * This product includes software developed by Christopher G. Demetriou
54 * for the NetBSD Project.
55 * 4. The name of the author may not be used to endorse or promote products
56 * derived from this software without specific prior written permission
57 *
58 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
59 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
60 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
61 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
62 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
64 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
65 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
66 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
67 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
68 */
69
70 /*
71 * Machine-specific functions for EISA autoconfiguration.
72 */
73
74 #include <sys/cdefs.h>
75 __KERNEL_RCSID(0, "$NetBSD: eisa_machdep.c,v 1.12.2.2 2002/01/08 00:25:16 nathanw Exp $");
76
77 #include <sys/types.h>
78 #include <sys/param.h>
79 #include <sys/time.h>
80 #include <sys/systm.h>
81 #include <sys/errno.h>
82 #include <sys/device.h>
83 #include <sys/extent.h>
84
85 #define _I386_BUS_DMA_PRIVATE
86 #include <machine/bus.h>
87
88 #include <i386/isa/icu.h>
89 #include <dev/isa/isareg.h>
90 #include <dev/isa/isavar.h>
91 #include <dev/eisa/eisavar.h>
92
93 /*
94 * EISA doesn't have any special needs; just use the generic versions
95 * of these funcions.
96 */
97 struct i386_bus_dma_tag eisa_bus_dma_tag = {
98 0, /* _bounce_thresh */
99 _bus_dmamap_create,
100 _bus_dmamap_destroy,
101 _bus_dmamap_load,
102 _bus_dmamap_load_mbuf,
103 _bus_dmamap_load_uio,
104 _bus_dmamap_load_raw,
105 _bus_dmamap_unload,
106 NULL, /* _dmamap_sync */
107 _bus_dmamem_alloc,
108 _bus_dmamem_free,
109 _bus_dmamem_map,
110 _bus_dmamem_unmap,
111 _bus_dmamem_mmap,
112 };
113
114 void
115 eisa_attach_hook(parent, self, eba)
116 struct device *parent, *self;
117 struct eisabus_attach_args *eba;
118 {
119 extern int eisa_has_been_seen;
120
121 /*
122 * Notify others that might need to know that the EISA bus
123 * has now been attached.
124 */
125 if (eisa_has_been_seen)
126 panic("eisaattach: EISA bus already seen!");
127 eisa_has_been_seen = 1;
128 }
129
130 int
131 eisa_maxslots(ec)
132 eisa_chipset_tag_t ec;
133 {
134
135 /*
136 * Always try 16 slots.
137 */
138 return (16);
139 }
140
141 int
142 eisa_intr_map(ec, irq, ihp)
143 eisa_chipset_tag_t ec;
144 u_int irq;
145 eisa_intr_handle_t *ihp;
146 {
147
148 if (irq >= ICU_LEN) {
149 printf("eisa_intr_map: bad IRQ %d\n", irq);
150 *ihp = -1;
151 return 1;
152 }
153 if (irq == 2) {
154 printf("eisa_intr_map: changed IRQ 2 to IRQ 9\n");
155 irq = 9;
156 }
157
158 *ihp = irq;
159 return 0;
160 }
161
162 const char *
163 eisa_intr_string(ec, ih)
164 eisa_chipset_tag_t ec;
165 eisa_intr_handle_t ih;
166 {
167 static char irqstr[8]; /* 4 + 2 + NULL + sanity */
168
169 if (ih == 0 || ih >= ICU_LEN || ih == 2)
170 panic("eisa_intr_string: bogus handle 0x%x\n", ih);
171
172 sprintf(irqstr, "irq %d", ih);
173 return (irqstr);
174
175 }
176
177 const struct evcnt *
178 eisa_intr_evcnt(eisa_chipset_tag_t ec, eisa_intr_handle_t ih)
179 {
180
181 /* XXX for now, no evcnt parent reported */
182 return NULL;
183 }
184
185 void *
186 eisa_intr_establish(ec, ih, type, level, func, arg)
187 eisa_chipset_tag_t ec;
188 eisa_intr_handle_t ih;
189 int type, level, (*func) __P((void *));
190 void *arg;
191 {
192
193 if (ih == 0 || ih >= ICU_LEN || ih == 2)
194 panic("eisa_intr_establish: bogus handle 0x%x\n", ih);
195
196 return isa_intr_establish(NULL, ih, type, level, func, arg);
197 }
198
199 void
200 eisa_intr_disestablish(ec, cookie)
201 eisa_chipset_tag_t ec;
202 void *cookie;
203 {
204
205 isa_intr_disestablish(NULL, cookie);
206 }
207
208 int
209 eisa_mem_alloc(t, size, align, boundary, cacheable, addrp, bahp)
210 bus_space_tag_t t;
211 bus_size_t size, align;
212 bus_addr_t boundary;
213 int cacheable;
214 bus_addr_t *addrp;
215 bus_space_handle_t *bahp;
216 {
217 extern struct extent *iomem_ex;
218
219 /*
220 * Allocate physical address space after the ISA hole.
221 */
222 return bus_space_alloc(t, IOM_END, iomem_ex->ex_end, size, align,
223 boundary, cacheable, addrp, bahp);
224 }
225
226 void
227 eisa_mem_free(t, bah, size)
228 bus_space_tag_t t;
229 bus_space_handle_t bah;
230 bus_size_t size;
231 {
232
233 bus_space_free(t, bah, size);
234 }
235
236 int
237 eisa_conf_read_mem(ec, slot, func, entry, ecm)
238 eisa_chipset_tag_t ec;
239 int slot, func, entry;
240 struct eisa_cfg_mem *ecm;
241 {
242
243 /* XXX XXX XXX */
244 return (ENOENT);
245 }
246
247 int
248 eisa_conf_read_irq(ec, slot, func, entry, eci)
249 eisa_chipset_tag_t ec;
250 int slot, func, entry;
251 struct eisa_cfg_irq *eci;
252 {
253
254 /* XXX XXX XXX */
255 return (ENOENT);
256 }
257
258 int
259 eisa_conf_read_dma(ec, slot, func, entry, ecd)
260 eisa_chipset_tag_t ec;
261 int slot, func, entry;
262 struct eisa_cfg_dma *ecd;
263 {
264
265 /* XXX XXX XXX */
266 return (ENOENT);
267 }
268
269 int
270 eisa_conf_read_io(ec, slot, func, entry, ecio)
271 eisa_chipset_tag_t ec;
272 int slot, func, entry;
273 struct eisa_cfg_io *ecio;
274 {
275
276 /* XXX XXX XXX */
277 return (ENOENT);
278 }
279