isa_machdep.h revision 1.15 1 /* $NetBSD: isa_machdep.h,v 1.15 2000/06/01 00:04:51 cgd Exp $ */
2
3 /*-
4 * Copyright (c) 1996, 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) 1990 The Regents of the University of California.
42 * All rights reserved.
43 *
44 * This code is derived from software contributed to Berkeley by
45 * William Jolitz.
46 *
47 * Redistribution and use in source and binary forms, with or without
48 * modification, are permitted provided that the following conditions
49 * are met:
50 * 1. Redistributions of source code must retain the above copyright
51 * notice, this list of conditions and the following disclaimer.
52 * 2. Redistributions in binary form must reproduce the above copyright
53 * notice, this list of conditions and the following disclaimer in the
54 * documentation and/or other materials provided with the distribution.
55 * 3. All advertising materials mentioning features or use of this software
56 * must display the following acknowledgement:
57 * This product includes software developed by the University of
58 * California, Berkeley and its contributors.
59 * 4. Neither the name of the University nor the names of its contributors
60 * may be used to endorse or promote products derived from this software
61 * without specific prior written permission.
62 *
63 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
64 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
65 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
66 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
67 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
68 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
69 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
70 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
71 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
72 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
73 * SUCH DAMAGE.
74 *
75 * @(#)isa.h 5.7 (Berkeley) 5/9/91
76 */
77
78 /*
79 * Various pieces of the i386 port want to include this file without
80 * or in spite of using isavar.h, and should be fixed.
81 */
82
83 #ifndef _I386_ISA_MACHDEP_H_ /* XXX */
84 #define _I386_ISA_MACHDEP_H_ /* XXX */
85
86 #include <machine/bus.h>
87 #include <dev/isa/isadmavar.h>
88
89 /*
90 * XXX THIS FILE IS A MESS. copyright: berkeley's probably.
91 * contents from isavar.h and isareg.h, mostly the latter.
92 * perhaps charles's?
93 *
94 * copyright from berkeley's isa.h which is now dev/isa/isareg.h.
95 */
96
97 /*
98 * Types provided to machine-independent ISA code.
99 */
100 struct i386_isa_chipset {
101 struct isa_dma_state ic_dmastate;
102 };
103
104 typedef struct i386_isa_chipset *isa_chipset_tag_t;
105
106 struct device; /* XXX */
107 struct isabus_attach_args; /* XXX */
108
109 /*
110 * Functions provided to machine-independent ISA code.
111 */
112 void isa_attach_hook(struct device *, struct device *,
113 struct isabus_attach_args *);
114 int isa_intr_alloc(isa_chipset_tag_t, int, int, int *);
115 void *isa_intr_establish(isa_chipset_tag_t ic, int irq, int type,
116 int level, int (*ih_fun)(void *), void *ih_arg);
117 void isa_intr_disestablish(isa_chipset_tag_t ic, void *handler);
118 int isa_mem_alloc(bus_space_tag_t, bus_size_t, bus_size_t,
119 bus_addr_t, int, bus_addr_t *, bus_space_handle_t *);
120 void isa_mem_free(bus_space_tag_t, bus_space_handle_t, bus_size_t);
121
122 #define isa_dmainit(ic, bst, dmat, d) \
123 _isa_dmainit(&(ic)->ic_dmastate, (bst), (dmat), (d))
124 #define isa_dmacascade(ic, c) \
125 _isa_dmacascade(&(ic)->ic_dmastate, (c))
126 #define isa_dmamaxsize(ic, c) \
127 _isa_dmamaxsize(&(ic)->ic_dmastate, (c))
128 #define isa_dmamap_create(ic, c, s, f) \
129 _isa_dmamap_create(&(ic)->ic_dmastate, (c), (s), (f))
130 #define isa_dmamap_destroy(ic, c) \
131 _isa_dmamap_destroy(&(ic)->ic_dmastate, (c))
132 #define isa_dmastart(ic, c, a, n, p, f, bf) \
133 _isa_dmastart(&(ic)->ic_dmastate, (c), (a), (n), (p), (f), (bf))
134 #define isa_dmaabort(ic, c) \
135 _isa_dmaabort(&(ic)->ic_dmastate, (c))
136 #define isa_dmacount(ic, c) \
137 _isa_dmacount(&(ic)->ic_dmastate, (c))
138 #define isa_dmafinished(ic, c) \
139 _isa_dmafinished(&(ic)->ic_dmastate, (c))
140 #define isa_dmadone(ic, c) \
141 _isa_dmadone(&(ic)->ic_dmastate, (c))
142 #define isa_dmafreeze(ic) \
143 _isa_dmafreeze(&(ic)->ic_dmastate)
144 #define isa_dmathaw(ic) \
145 _isa_dmathaw(&(ic)->ic_dmastate)
146 #define isa_dmamem_alloc(ic, c, s, ap, f) \
147 _isa_dmamem_alloc(&(ic)->ic_dmastate, (c), (s), (ap), (f))
148 #define isa_dmamem_free(ic, c, a, s) \
149 _isa_dmamem_free(&(ic)->ic_dmastate, (c), (a), (s))
150 #define isa_dmamem_map(ic, c, a, s, kp, f) \
151 _isa_dmamem_map(&(ic)->ic_dmastate, (c), (a), (s), (kp), (f))
152 #define isa_dmamem_unmap(ic, c, k, s) \
153 _isa_dmamem_unmap(&(ic)->ic_dmastate, (c), (k), (s))
154 #define isa_dmamem_mmap(ic, c, a, s, o, p, f) \
155 _isa_dmamem_mmap(&(ic)->ic_dmastate, (c), (a), (s), (o), (p), (f))
156 #define isa_drq_isfree(ic, c) \
157 _isa_drq_isfree(&(ic)->ic_dmastate, (c))
158 #define isa_malloc(ic, c, s, p, f) \
159 _isa_malloc(&(ic)->ic_dmastate, (c), (s), (p), (f))
160 #define isa_free(a, p) \
161 _isa_free((a), (p))
162 #define isa_mappage(m, o, p) \
163 _isa_mappage((m), (o), (p))
164
165 /*
166 * ALL OF THE FOLLOWING ARE MACHINE-DEPENDENT, AND SHOULD NOT BE USED
167 * BY PORTABLE CODE.
168 */
169
170 extern struct i386_bus_dma_tag isa_bus_dma_tag;
171
172 /*
173 * Cookie used by ISA dma. A pointer to one of these it stashed in
174 * the DMA map.
175 */
176 struct i386_isa_dma_cookie {
177 int id_flags; /* flags; see below */
178
179 /*
180 * Information about the original buffer used during
181 * DMA map syncs. Note that origibuflen is only used
182 * for ID_BUFTYPE_LINEAR.
183 */
184 void *id_origbuf; /* pointer to orig buffer if
185 bouncing */
186 bus_size_t id_origbuflen; /* ...and size */
187 int id_buftype; /* type of buffer */
188
189 void *id_bouncebuf; /* pointer to the bounce buffer */
190 bus_size_t id_bouncebuflen; /* ...and size */
191 int id_nbouncesegs; /* number of valid bounce segs */
192 bus_dma_segment_t id_bouncesegs[0]; /* array of bounce buffer
193 physical memory segments */
194 };
195
196 /* id_flags */
197 #define ID_MIGHT_NEED_BOUNCE 0x01 /* map could need bounce buffers */
198 #define ID_HAS_BOUNCE 0x02 /* map currently has bounce buffers */
199 #define ID_IS_BOUNCING 0x04 /* map is bouncing current xfer */
200
201 /* id_buftype */
202 #define ID_BUFTYPE_INVALID 0
203 #define ID_BUFTYPE_LINEAR 1
204 #define ID_BUFTYPE_MBUF 2
205 #define ID_BUFTYPE_UIO 3
206 #define ID_BUFTYPE_RAW 4
207
208 /*
209 * XXX Various seemingly PC-specific constants, some of which may be
210 * unnecessary anyway.
211 */
212
213 /*
214 * RAM Physical Address Space (ignoring the above mentioned "hole")
215 */
216 #define RAM_BEGIN 0x0000000 /* Start of RAM Memory */
217 #define RAM_END 0x1000000 /* End of RAM Memory */
218 #define RAM_SIZE (RAM_END - RAM_BEGIN)
219
220 /*
221 * Oddball Physical Memory Addresses
222 */
223 #define COMPAQ_RAMRELOC 0x80c00000 /* Compaq RAM relocation/diag */
224 #define COMPAQ_RAMSETUP 0x80c00002 /* Compaq RAM setup */
225 #define WEITEK_FPU 0xC0000000 /* WTL 2167 */
226 #define CYRIX_EMC 0xC0000000 /* Cyrix EMC */
227
228 /*
229 * stuff that used to be in pccons.c
230 */
231 #define MONO_BASE 0x3B4
232 #define MONO_BUF 0xB0000
233 #define CGA_BASE 0x3D4
234 #define CGA_BUF 0xB8000
235 #define IOPHYSMEM 0xA0000
236
237
238 /*
239 * Interrupt handler chains. isa_intr_establish() inserts a handler into
240 * the list. The handler is called with its (single) argument.
241 */
242
243 struct intrhand {
244 int (*ih_fun)(void *);
245 void *ih_arg;
246 u_long ih_count;
247 struct intrhand *ih_next;
248 int ih_level;
249 int ih_irq;
250 };
251
252
253 /*
254 * ISA DMA bounce buffers.
255 * XXX should be made partially machine- and bus-mapping-independent.
256 *
257 * DMA_BOUNCE is the number of pages of low-addressed physical memory
258 * to acquire for ISA bounce buffers.
259 *
260 * isaphysmem is the location of those bounce buffers. (They are currently
261 * assumed to be contiguous.
262 */
263
264 #ifndef DMA_BOUNCE
265 #define DMA_BOUNCE 8 /* one buffer per channel */
266 #endif
267
268 extern vaddr_t isaphysmem;
269
270
271 /*
272 * Variables and macros to deal with the ISA I/O hole.
273 * XXX These should be converted to machine- and bus-mapping-independent
274 * function definitions, invoked through the softc.
275 */
276
277 extern u_long atdevbase; /* kernel virtual address of "hole" */
278
279 /*
280 * Given a kernel virtual address for some location
281 * in the "hole" I/O space, return a physical address.
282 */
283 #define ISA_PHYSADDR(v) ((void *) ((u_long)(v) - atdevbase + IOM_BEGIN))
284
285 /*
286 * Given a physical address in the "hole",
287 * return a kernel virtual address.
288 */
289 #define ISA_HOLE_VADDR(p) ((void *) ((u_long)(p) - IOM_BEGIN + atdevbase))
290
291
292 /*
293 * Miscellanous functions.
294 */
295 void sysbeep(int, int); /* beep with the system speaker */
296
297 #endif /* _I386_ISA_MACHDEP_H_ XXX */
298