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