Annotation of src/sys/arch/i386/eisa/eisa_machdep.c, Revision 1.10.22.5
1.10.22.4 sommerfe 1: /* $NetBSD$ */
1.6 thorpej 2:
3: /*-
1.7 thorpej 4: * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
1.6 thorpej 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: */
1.1 cgd 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:
1.10.22.3 sommerfe 74: #include "ioapic.h"
75:
1.1 cgd 76: #include <sys/types.h>
77: #include <sys/param.h>
78: #include <sys/time.h>
79: #include <sys/systm.h>
80: #include <sys/errno.h>
81: #include <sys/device.h>
1.5 thorpej 82: #include <sys/extent.h>
1.1 cgd 83:
1.6 thorpej 84: #define _I386_BUS_DMA_PRIVATE
85: #include <machine/bus.h>
86:
1.1 cgd 87: #include <i386/isa/icu.h>
1.5 thorpej 88: #include <dev/isa/isareg.h>
1.1 cgd 89: #include <dev/isa/isavar.h>
90: #include <dev/eisa/eisavar.h>
91:
1.10.22.3 sommerfe 92: #if NIOAPIC > 0
93: #include <machine/i82093var.h>
94: #include <machine/mpbiosvar.h>
95: #endif
96:
1.6 thorpej 97: /*
98: * EISA doesn't have any special needs; just use the generic versions
99: * of these funcions.
100: */
101: struct i386_bus_dma_tag eisa_bus_dma_tag = {
1.10 thorpej 102: 0, /* _bounce_thresh */
1.6 thorpej 103: _bus_dmamap_create,
104: _bus_dmamap_destroy,
105: _bus_dmamap_load,
106: _bus_dmamap_load_mbuf,
107: _bus_dmamap_load_uio,
108: _bus_dmamap_load_raw,
109: _bus_dmamap_unload,
110: NULL, /* _dmamap_sync */
111: _bus_dmamem_alloc,
112: _bus_dmamem_free,
113: _bus_dmamem_map,
114: _bus_dmamem_unmap,
115: _bus_dmamem_mmap,
116: };
117:
1.1 cgd 118: void
119: eisa_attach_hook(parent, self, eba)
120: struct device *parent, *self;
121: struct eisabus_attach_args *eba;
122: {
1.7 thorpej 123: extern int eisa_has_been_seen;
1.1 cgd 124:
1.7 thorpej 125: /*
1.8 thorpej 126: * Notify others that might need to know that the EISA bus
1.7 thorpej 127: * has now been attached.
128: */
129: if (eisa_has_been_seen)
130: panic("eisaattach: EISA bus already seen!");
131: eisa_has_been_seen = 1;
1.1 cgd 132: }
133:
134: int
135: eisa_maxslots(ec)
136: eisa_chipset_tag_t ec;
137: {
138:
139: /*
140: * Always try 16 slots.
141: */
142: return (16);
143: }
144:
145: int
146: eisa_intr_map(ec, irq, ihp)
147: eisa_chipset_tag_t ec;
148: u_int irq;
149: eisa_intr_handle_t *ihp;
150: {
1.10.22.1 sommerfe 151: #if NIOAPIC > 0
152: struct mp_intr_map *mip;
153: #endif
1.1 cgd 154:
155: if (irq >= ICU_LEN) {
1.4 christos 156: printf("eisa_intr_map: bad IRQ %d\n", irq);
1.1 cgd 157: *ihp = -1;
158: return 1;
159: }
160: if (irq == 2) {
1.4 christos 161: printf("eisa_intr_map: changed IRQ 2 to IRQ 9\n");
1.1 cgd 162: irq = 9;
163: }
164:
1.10.22.1 sommerfe 165: #if NIOAPIC > 0
166: if (mp_busses != NULL) {
1.10.22.3 sommerfe 167: int bus = mp_eisa_bus;
168:
169: if (bus != -1) {
170: for (mip = mp_busses[bus].mb_intrs; mip != NULL;
171: mip=mip->next) {
172: if (mip->bus_pin == irq) {
173: *ihp = mip->ioapic_ih | irq;
174: return 0;
175: }
176: }
177: }
178:
179: bus = mp_isa_bus;
1.10.22.1 sommerfe 180:
1.10.22.3 sommerfe 181: if (bus != -1) {
182: for (mip = mp_busses[bus].mb_intrs; mip != NULL;
183: mip=mip->next) {
184: if (mip->bus_pin == irq) {
185: *ihp = mip->ioapic_ih | irq;
186: return 0;
187: }
1.10.22.1 sommerfe 188: }
189: }
1.10.22.3 sommerfe 190:
191: printf("eisa_intr_map: no MP mapping found\n");
1.10.22.1 sommerfe 192: }
193: #endif
194:
195:
1.1 cgd 196: *ihp = irq;
197: return 0;
198: }
199:
200: const char *
201: eisa_intr_string(ec, ih)
202: eisa_chipset_tag_t ec;
203: eisa_intr_handle_t ih;
204: {
205: static char irqstr[8]; /* 4 + 2 + NULL + sanity */
206:
1.10.22.1 sommerfe 207: if (ih == 0 || (ih & 0xff) >= ICU_LEN || ih == 2)
1.1 cgd 208: panic("eisa_intr_string: bogus handle 0x%x\n", ih);
209:
1.10.22.1 sommerfe 210: #if NIOAPIC > 0
211: if (ih & APIC_INT_VIA_APIC)
212: sprintf(irqstr, "apic %d int %d (irq %d)",
213: APIC_IRQ_APIC(ih),
214: APIC_IRQ_PIN(ih),
215: ih&0xff);
216: else
217: sprintf(irqstr, "irq %d", ih&0xff);
218: #else
1.4 christos 219: sprintf(irqstr, "irq %d", ih);
1.10.22.1 sommerfe 220: #endif
1.1 cgd 221: return (irqstr);
222:
1.10.22.2 sommerfe 223: }
224:
225: const struct evcnt *
226: eisa_intr_evcnt(eisa_chipset_tag_t ec, eisa_intr_handle_t ih)
227: {
228:
229: /* XXX for now, no evcnt parent reported */
230: return NULL;
1.1 cgd 231: }
232:
233: void *
234: eisa_intr_establish(ec, ih, type, level, func, arg)
235: eisa_chipset_tag_t ec;
236: eisa_intr_handle_t ih;
237: int type, level, (*func) __P((void *));
238: void *arg;
239: {
1.10.22.1 sommerfe 240: if (ih != -1) {
241: #if NIOAPIC > 0
242: if (ih & APIC_INT_VIA_APIC) {
243: return apic_intr_establish(ih, type, level,
244: func, arg);
245: }
246: #endif
247: }
1.1 cgd 248:
249: if (ih == 0 || ih >= ICU_LEN || ih == 2)
250: panic("eisa_intr_establish: bogus handle 0x%x\n", ih);
251:
1.2 cgd 252: return isa_intr_establish(NULL, ih, type, level, func, arg);
1.1 cgd 253: }
254:
255: void
256: eisa_intr_disestablish(ec, cookie)
257: eisa_chipset_tag_t ec;
258: void *cookie;
259: {
260:
1.10.22.5! sommerfe 261: isa_intr_disestablish(NULL, cookie);
1.5 thorpej 262: }
263:
264: int
265: eisa_mem_alloc(t, size, align, boundary, cacheable, addrp, bahp)
266: bus_space_tag_t t;
267: bus_size_t size, align;
268: bus_addr_t boundary;
269: int cacheable;
270: bus_addr_t *addrp;
271: bus_space_handle_t *bahp;
272: {
273: extern struct extent *iomem_ex;
274:
275: /*
276: * Allocate physical address space after the ISA hole.
277: */
278: return bus_space_alloc(t, IOM_END, iomem_ex->ex_end, size, align,
279: boundary, cacheable, addrp, bahp);
280: }
281:
282: void
283: eisa_mem_free(t, bah, size)
284: bus_space_tag_t t;
285: bus_space_handle_t bah;
286: bus_size_t size;
287: {
288:
289: bus_space_free(t, bah, size);
1.10.22.4 sommerfe 290: }
291:
292: int
293: eisa_conf_read_mem(ec, slot, func, entry, ecm)
294: eisa_chipset_tag_t ec;
295: int slot, func, entry;
296: struct eisa_cfg_mem *ecm;
297: {
298:
299: /* XXX XXX XXX */
300: return (ENOENT);
301: }
302:
303: int
304: eisa_conf_read_irq(ec, slot, func, entry, eci)
305: eisa_chipset_tag_t ec;
306: int slot, func, entry;
307: struct eisa_cfg_irq *eci;
308: {
309:
310: /* XXX XXX XXX */
311: return (ENOENT);
312: }
313:
314: int
315: eisa_conf_read_dma(ec, slot, func, entry, ecd)
316: eisa_chipset_tag_t ec;
317: int slot, func, entry;
318: struct eisa_cfg_dma *ecd;
319: {
320:
321: /* XXX XXX XXX */
322: return (ENOENT);
323: }
324:
325: int
326: eisa_conf_read_io(ec, slot, func, entry, ecio)
327: eisa_chipset_tag_t ec;
328: int slot, func, entry;
329: struct eisa_cfg_io *ecio;
330: {
331:
332: /* XXX XXX XXX */
333: return (ENOENT);
1.1 cgd 334: }
CVSweb <webmaster@jp.NetBSD.org>