xref: /minix3/sys/arch/x86/include/isa_machdep.h (revision 1cd76c751364e6270e8d5a0daebc6d3d169baf4d)
1*1cd76c75SBen Gras /*	$NetBSD: isa_machdep.h,v 1.11 2011/07/01 18:22:39 dyoung Exp $	*/
2*1cd76c75SBen Gras 
3*1cd76c75SBen Gras /*-
4*1cd76c75SBen Gras  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
5*1cd76c75SBen Gras  * All rights reserved.
6*1cd76c75SBen Gras  *
7*1cd76c75SBen Gras  * This code is derived from software contributed to The NetBSD Foundation
8*1cd76c75SBen Gras  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9*1cd76c75SBen Gras  * NASA Ames Research Center.
10*1cd76c75SBen Gras  *
11*1cd76c75SBen Gras  * Redistribution and use in source and binary forms, with or without
12*1cd76c75SBen Gras  * modification, are permitted provided that the following conditions
13*1cd76c75SBen Gras  * are met:
14*1cd76c75SBen Gras  * 1. Redistributions of source code must retain the above copyright
15*1cd76c75SBen Gras  *    notice, this list of conditions and the following disclaimer.
16*1cd76c75SBen Gras  * 2. Redistributions in binary form must reproduce the above copyright
17*1cd76c75SBen Gras  *    notice, this list of conditions and the following disclaimer in the
18*1cd76c75SBen Gras  *    documentation and/or other materials provided with the distribution.
19*1cd76c75SBen Gras  *
20*1cd76c75SBen Gras  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21*1cd76c75SBen Gras  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22*1cd76c75SBen Gras  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23*1cd76c75SBen Gras  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24*1cd76c75SBen Gras  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25*1cd76c75SBen Gras  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26*1cd76c75SBen Gras  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27*1cd76c75SBen Gras  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28*1cd76c75SBen Gras  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29*1cd76c75SBen Gras  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30*1cd76c75SBen Gras  * POSSIBILITY OF SUCH DAMAGE.
31*1cd76c75SBen Gras  */
32*1cd76c75SBen Gras 
33*1cd76c75SBen Gras /*-
34*1cd76c75SBen Gras  * Copyright (c) 1990 The Regents of the University of California.
35*1cd76c75SBen Gras  * All rights reserved.
36*1cd76c75SBen Gras  *
37*1cd76c75SBen Gras  * This code is derived from software contributed to Berkeley by
38*1cd76c75SBen Gras  * William Jolitz.
39*1cd76c75SBen Gras  *
40*1cd76c75SBen Gras  * Redistribution and use in source and binary forms, with or without
41*1cd76c75SBen Gras  * modification, are permitted provided that the following conditions
42*1cd76c75SBen Gras  * are met:
43*1cd76c75SBen Gras  * 1. Redistributions of source code must retain the above copyright
44*1cd76c75SBen Gras  *    notice, this list of conditions and the following disclaimer.
45*1cd76c75SBen Gras  * 2. Redistributions in binary form must reproduce the above copyright
46*1cd76c75SBen Gras  *    notice, this list of conditions and the following disclaimer in the
47*1cd76c75SBen Gras  *    documentation and/or other materials provided with the distribution.
48*1cd76c75SBen Gras  * 3. Neither the name of the University nor the names of its contributors
49*1cd76c75SBen Gras  *    may be used to endorse or promote products derived from this software
50*1cd76c75SBen Gras  *    without specific prior written permission.
51*1cd76c75SBen Gras  *
52*1cd76c75SBen Gras  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
53*1cd76c75SBen Gras  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54*1cd76c75SBen Gras  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
55*1cd76c75SBen Gras  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
56*1cd76c75SBen Gras  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
57*1cd76c75SBen Gras  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
58*1cd76c75SBen Gras  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
59*1cd76c75SBen Gras  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
60*1cd76c75SBen Gras  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
61*1cd76c75SBen Gras  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
62*1cd76c75SBen Gras  * SUCH DAMAGE.
63*1cd76c75SBen Gras  *
64*1cd76c75SBen Gras  *	@(#)isa.h	5.7 (Berkeley) 5/9/91
65*1cd76c75SBen Gras  */
66*1cd76c75SBen Gras 
67*1cd76c75SBen Gras /*
68*1cd76c75SBen Gras  * Various pieces of the i386 port want to include this file without
69*1cd76c75SBen Gras  * or in spite of using isavar.h, and should be fixed.
70*1cd76c75SBen Gras  */
71*1cd76c75SBen Gras 
72*1cd76c75SBen Gras #ifndef _X86_ISA_MACHDEP_H_			/* XXX */
73*1cd76c75SBen Gras #define _X86_ISA_MACHDEP_H_			/* XXX */
74*1cd76c75SBen Gras 
75*1cd76c75SBen Gras #include <sys/bus.h>
76*1cd76c75SBen Gras #include <sys/device.h>
77*1cd76c75SBen Gras #include <dev/isa/isadmavar.h>
78*1cd76c75SBen Gras 
79*1cd76c75SBen Gras /*
80*1cd76c75SBen Gras  * XXX THIS FILE IS A MESS.  copyright: berkeley's probably.
81*1cd76c75SBen Gras  * contents from isavar.h and isareg.h, mostly the latter.
82*1cd76c75SBen Gras  * perhaps charles's?
83*1cd76c75SBen Gras  *
84*1cd76c75SBen Gras  * copyright from berkeley's isa.h which is now dev/isa/isareg.h.
85*1cd76c75SBen Gras  */
86*1cd76c75SBen Gras 
87*1cd76c75SBen Gras /*
88*1cd76c75SBen Gras  * Types provided to machine-independent ISA code.
89*1cd76c75SBen Gras  */
90*1cd76c75SBen Gras struct x86_isa_chipset {
91*1cd76c75SBen Gras 	struct isa_dma_state ic_dmastate;
92*1cd76c75SBen Gras };
93*1cd76c75SBen Gras 
94*1cd76c75SBen Gras typedef struct x86_isa_chipset *isa_chipset_tag_t;
95*1cd76c75SBen Gras 
96*1cd76c75SBen Gras struct isabus_attach_args;	/* XXX */
97*1cd76c75SBen Gras 
98*1cd76c75SBen Gras /*
99*1cd76c75SBen Gras  * Functions provided to machine-independent ISA code.
100*1cd76c75SBen Gras  */
101*1cd76c75SBen Gras void	isa_attach_hook(device_t, device_t,
102*1cd76c75SBen Gras 	    struct isabus_attach_args *);
103*1cd76c75SBen Gras void	isa_detach_hook(isa_chipset_tag_t, device_t);
104*1cd76c75SBen Gras int	isa_intr_alloc(isa_chipset_tag_t, int, int, int *);
105*1cd76c75SBen Gras const struct evcnt *isa_intr_evcnt(isa_chipset_tag_t ic, int irq);
106*1cd76c75SBen Gras void	*isa_intr_establish(isa_chipset_tag_t ic, int irq, int type,
107*1cd76c75SBen Gras 	    int level, int (*ih_fun)(void *), void *ih_arg);
108*1cd76c75SBen Gras void	isa_intr_disestablish(isa_chipset_tag_t ic, void *handler);
109*1cd76c75SBen Gras int	isa_mem_alloc(bus_space_tag_t, bus_size_t, bus_size_t,
110*1cd76c75SBen Gras 	    bus_addr_t, int, bus_addr_t *, bus_space_handle_t *);
111*1cd76c75SBen Gras void	isa_mem_free(bus_space_tag_t, bus_space_handle_t, bus_size_t);
112*1cd76c75SBen Gras 
113*1cd76c75SBen Gras #define	isa_dmadestroy(ic)						\
114*1cd76c75SBen Gras 	_isa_dmadestroy(&(ic)->ic_dmastate)
115*1cd76c75SBen Gras #define	isa_dmainit(ic, bst, dmat, d)					\
116*1cd76c75SBen Gras 	_isa_dmainit(&(ic)->ic_dmastate, (bst), (dmat), (d))
117*1cd76c75SBen Gras #define	isa_dmacascade(ic, c)						\
118*1cd76c75SBen Gras 	_isa_dmacascade(&(ic)->ic_dmastate, (c))
119*1cd76c75SBen Gras #define	isa_dmamaxsize(ic, c)						\
120*1cd76c75SBen Gras 	_isa_dmamaxsize(&(ic)->ic_dmastate, (c))
121*1cd76c75SBen Gras #define	isa_dmamap_create(ic, c, s, f)					\
122*1cd76c75SBen Gras 	_isa_dmamap_create(&(ic)->ic_dmastate, (c), (s), (f))
123*1cd76c75SBen Gras #define	isa_dmamap_destroy(ic, c)					\
124*1cd76c75SBen Gras 	_isa_dmamap_destroy(&(ic)->ic_dmastate, (c))
125*1cd76c75SBen Gras #define	isa_dmastart(ic, c, a, n, p, f, bf)				\
126*1cd76c75SBen Gras 	_isa_dmastart(&(ic)->ic_dmastate, (c), (a), (n), (p), (f), (bf))
127*1cd76c75SBen Gras #define	isa_dmaabort(ic, c)						\
128*1cd76c75SBen Gras 	_isa_dmaabort(&(ic)->ic_dmastate, (c))
129*1cd76c75SBen Gras #define	isa_dmacount(ic, c)						\
130*1cd76c75SBen Gras 	_isa_dmacount(&(ic)->ic_dmastate, (c))
131*1cd76c75SBen Gras #define	isa_dmafinished(ic, c)						\
132*1cd76c75SBen Gras 	_isa_dmafinished(&(ic)->ic_dmastate, (c))
133*1cd76c75SBen Gras #define	isa_dmadone(ic, c)						\
134*1cd76c75SBen Gras 	_isa_dmadone(&(ic)->ic_dmastate, (c))
135*1cd76c75SBen Gras #define	isa_dmafreeze(ic)						\
136*1cd76c75SBen Gras 	_isa_dmafreeze(&(ic)->ic_dmastate)
137*1cd76c75SBen Gras #define	isa_dmathaw(ic)							\
138*1cd76c75SBen Gras 	_isa_dmathaw(&(ic)->ic_dmastate)
139*1cd76c75SBen Gras #define	isa_dmamem_alloc(ic, c, s, ap, f)				\
140*1cd76c75SBen Gras 	_isa_dmamem_alloc(&(ic)->ic_dmastate, (c), (s), (ap), (f))
141*1cd76c75SBen Gras #define	isa_dmamem_free(ic, c, a, s)					\
142*1cd76c75SBen Gras 	_isa_dmamem_free(&(ic)->ic_dmastate, (c), (a), (s))
143*1cd76c75SBen Gras #define	isa_dmamem_map(ic, c, a, s, kp, f)				\
144*1cd76c75SBen Gras 	_isa_dmamem_map(&(ic)->ic_dmastate, (c), (a), (s), (kp), (f))
145*1cd76c75SBen Gras #define	isa_dmamem_unmap(ic, c, k, s)					\
146*1cd76c75SBen Gras 	_isa_dmamem_unmap(&(ic)->ic_dmastate, (c), (k), (s))
147*1cd76c75SBen Gras #define	isa_dmamem_mmap(ic, c, a, s, o, p, f)				\
148*1cd76c75SBen Gras 	_isa_dmamem_mmap(&(ic)->ic_dmastate, (c), (a), (s), (o), (p), (f))
149*1cd76c75SBen Gras #define isa_drq_alloc(ic, c)						\
150*1cd76c75SBen Gras 	_isa_drq_alloc(&(ic)->ic_dmastate, c)
151*1cd76c75SBen Gras #define isa_drq_free(ic, c)						\
152*1cd76c75SBen Gras 	_isa_drq_free(&(ic)->ic_dmastate, c)
153*1cd76c75SBen Gras #define	isa_drq_isfree(ic, c)						\
154*1cd76c75SBen Gras 	_isa_drq_isfree(&(ic)->ic_dmastate, (c))
155*1cd76c75SBen Gras #define	isa_malloc(ic, c, s, p, f)					\
156*1cd76c75SBen Gras 	_isa_malloc(&(ic)->ic_dmastate, (c), (s), (p), (f))
157*1cd76c75SBen Gras #define	isa_free(a, p)							\
158*1cd76c75SBen Gras 	_isa_free((a), (p))
159*1cd76c75SBen Gras #define	isa_mappage(m, o, p)						\
160*1cd76c75SBen Gras 	_isa_mappage((m), (o), (p))
161*1cd76c75SBen Gras 
162*1cd76c75SBen Gras /*
163*1cd76c75SBen Gras  * for ACPI code
164*1cd76c75SBen Gras  */
165*1cd76c75SBen Gras 
166*1cd76c75SBen Gras void	isa_reinit_irq(void);
167*1cd76c75SBen Gras 
168*1cd76c75SBen Gras /*
169*1cd76c75SBen Gras  * ALL OF THE FOLLOWING ARE MACHINE-DEPENDENT, AND SHOULD NOT BE USED
170*1cd76c75SBen Gras  * BY PORTABLE CODE.
171*1cd76c75SBen Gras  */
172*1cd76c75SBen Gras 
173*1cd76c75SBen Gras extern struct x86_bus_dma_tag isa_bus_dma_tag;
174*1cd76c75SBen Gras 
175*1cd76c75SBen Gras /*
176*1cd76c75SBen Gras  * XXX Various seemingly PC-specific constants, some of which may be
177*1cd76c75SBen Gras  * unnecessary anyway.
178*1cd76c75SBen Gras  */
179*1cd76c75SBen Gras 
180*1cd76c75SBen Gras /*
181*1cd76c75SBen Gras  * RAM Physical Address Space (ignoring the above mentioned "hole")
182*1cd76c75SBen Gras  */
183*1cd76c75SBen Gras #define	RAM_BEGIN	0x0000000	/* Start of RAM Memory */
184*1cd76c75SBen Gras #define	RAM_END		0x1000000	/* End of RAM Memory */
185*1cd76c75SBen Gras #define	RAM_SIZE	(RAM_END - RAM_BEGIN)
186*1cd76c75SBen Gras 
187*1cd76c75SBen Gras /*
188*1cd76c75SBen Gras  * Oddball Physical Memory Addresses
189*1cd76c75SBen Gras  */
190*1cd76c75SBen Gras #define	COMPAQ_RAMRELOC	0x80c00000	/* Compaq RAM relocation/diag */
191*1cd76c75SBen Gras #define	COMPAQ_RAMSETUP	0x80c00002	/* Compaq RAM setup */
192*1cd76c75SBen Gras #define	WEITEK_FPU	0xC0000000	/* WTL 2167 */
193*1cd76c75SBen Gras #define	CYRIX_EMC	0xC0000000	/* Cyrix EMC */
194*1cd76c75SBen Gras 
195*1cd76c75SBen Gras /*
196*1cd76c75SBen Gras  * stuff that used to be in pccons.c
197*1cd76c75SBen Gras  */
198*1cd76c75SBen Gras #define	MONO_BASE	0x3B4
199*1cd76c75SBen Gras #define	MONO_BUF	0xB0000
200*1cd76c75SBen Gras #define	CGA_BASE	0x3D4
201*1cd76c75SBen Gras #define	CGA_BUF		0xB8000
202*1cd76c75SBen Gras 
203*1cd76c75SBen Gras /*
204*1cd76c75SBen Gras  * Variables and macros to deal with the ISA I/O hole.
205*1cd76c75SBen Gras  * XXX These should be converted to machine- and bus-mapping-independent
206*1cd76c75SBen Gras  * function definitions, invoked through the softc.
207*1cd76c75SBen Gras  */
208*1cd76c75SBen Gras 
209*1cd76c75SBen Gras extern vaddr_t atdevbase;         /* kernel virtual address of "hole" */
210*1cd76c75SBen Gras 
211*1cd76c75SBen Gras /*
212*1cd76c75SBen Gras  * Given a kernel virtual address for some location
213*1cd76c75SBen Gras  * in the "hole" I/O space, return a physical address.
214*1cd76c75SBen Gras  */
215*1cd76c75SBen Gras #define ISA_PHYSADDR(v) ((bus_addr_t)(v) - atdevbase + IOM_BEGIN)
216*1cd76c75SBen Gras 
217*1cd76c75SBen Gras /*
218*1cd76c75SBen Gras  * Given a physical address in the "hole",
219*1cd76c75SBen Gras  * return a kernel virtual address.
220*1cd76c75SBen Gras  */
221*1cd76c75SBen Gras #define ISA_HOLE_VADDR(p)  ((void *) ((vaddr_t)(p) - IOM_BEGIN + atdevbase))
222*1cd76c75SBen Gras 
223*1cd76c75SBen Gras 
224*1cd76c75SBen Gras /*
225*1cd76c75SBen Gras  * Miscellanous functions.
226*1cd76c75SBen Gras  */
227*1cd76c75SBen Gras void sysbeep(int, int);		/* beep with the system speaker */
228*1cd76c75SBen Gras 
229*1cd76c75SBen Gras #endif /* _X86_ISA_MACHDEP_H_ XXX */
230