isavar.h revision 1.24 1 /* $NetBSD: isavar.h,v 1.24 1996/10/21 22:41:11 thorpej Exp $ */
2
3 /*
4 * Copyright (c) 1995 Chris G. Demetriou
5 * Copyright (c) 1992 Berkeley Software Design, Inc.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Berkeley Software
19 * Design, Inc.
20 * 4. The name of Berkeley Software Design must not be used to endorse
21 * or promote products derived from this software without specific
22 * prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN, INC. ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN, INC. BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * BSDI Id: isavar.h,v 1.5 1992/12/01 18:06:00 karels Exp
37 */
38
39 #ifndef _DEV_ISA_ISAVAR_H_
40 #define _DEV_ISA_ISAVAR_H_
41
42 /*
43 * Definitions for ISA autoconfiguration.
44 */
45
46 #include <sys/queue.h>
47 #include <machine/bus.h>
48
49 /*
50 * Structures and definitions needed by the machine-dependent header.
51 */
52 struct isabus_attach_args;
53
54 #if (alpha + i386 != 1)
55 ERROR: COMPILING FOR UNSUPPORTED MACHINE, OR MORE THAN ONE.
56 #endif
57 #if alpha
58 #include <alpha/isa/isa_machdep.h>
59 #endif
60 #if i386
61 #include <i386/isa/isa_machdep.h>
62 #endif
63
64 /*
65 * ISA bus attach arguments
66 */
67 struct isabus_attach_args {
68 char *iba_busname; /* XXX should be common */
69 bus_space_tag_t iba_iot; /* isa i/o space tag */
70 bus_space_tag_t iba_memt; /* isa mem space tag */
71 isa_chipset_tag_t iba_ic;
72 };
73
74 /*
75 * ISA driver attach arguments
76 */
77 struct isa_attach_args {
78 bus_space_tag_t ia_iot; /* isa i/o space tag */
79 bus_space_tag_t ia_memt; /* isa mem space tag */
80
81 isa_chipset_tag_t ia_ic;
82
83 int ia_iobase; /* base i/o address */
84 int ia_iosize; /* span of ports used */
85 int ia_irq; /* interrupt request */
86 int ia_drq; /* DMA request */
87 int ia_maddr; /* physical i/o mem addr */
88 u_int ia_msize; /* size of i/o memory */
89 void *ia_aux; /* driver specific */
90
91 bus_space_handle_t ia_delaybah; /* i/o handle for `delay port' */
92 };
93
94 #define IOBASEUNK -1 /* i/o address is unknown */
95 #define IRQUNK -1 /* interrupt request line is unknown */
96 #define DRQUNK -1 /* DMA request line is unknown */
97 #define MADDRUNK -1 /* shared memory address is unknown */
98
99 /*
100 * Per-device ISA variables
101 */
102 struct isadev {
103 struct device *id_dev; /* back pointer to generic */
104 TAILQ_ENTRY(isadev)
105 id_bchain; /* bus chain */
106 };
107
108 /*
109 * ISA master bus
110 */
111 struct isa_softc {
112 struct device sc_dev; /* base device */
113 TAILQ_HEAD(, isadev)
114 sc_subdevs; /* list of all children */
115
116 bus_space_tag_t sc_iot; /* isa io space tag */
117 bus_space_tag_t sc_memt; /* isa mem space tag */
118
119 isa_chipset_tag_t sc_ic;
120
121 /*
122 * This i/o handle is used to map port 0x84, which is
123 * read to provide a 1.25us delay. This access handle
124 * is mapped in isaattach(), and exported to drivers
125 * via isa_attach_args.
126 */
127 bus_space_handle_t sc_delaybah;
128 };
129
130 #define cf_iobase cf_loc[0]
131 #define cf_iosize cf_loc[1]
132 #define cf_maddr cf_loc[2]
133 #define cf_msize cf_loc[3]
134 #define cf_irq cf_loc[4]
135 #define cf_drq cf_loc[5]
136
137 /*
138 * ISA interrupt handler manipulation.
139 *
140 * To establish an ISA interrupt handler, a driver calls isa_intr_establish()
141 * with the interrupt number, type, level, function, and function argument of
142 * the interrupt it wants to handle. Isa_intr_establish() returns an opaque
143 * handle to an event descriptor if it succeeds, and invokes panic() if it
144 * fails. (XXX It should return NULL, then drivers should handle that, but
145 * what should they do?) Interrupt handlers should return 0 for "interrupt
146 * not for me", 1 for "I took care of it", or -1 for "I guess it was mine,
147 * but I wasn't expecting it."
148 *
149 * To remove an interrupt handler, the driver calls isa_intr_disestablish()
150 * with the handle returned by isa_intr_establish() for that handler.
151 */
152
153 /* ISA interrupt sharing types */
154 void isascan __P((struct device *parent, void *match));
155 char *isa_intr_typename __P((int type));
156
157 #ifdef NEWCONFIG
158 /*
159 * Establish a device as being on the ISA bus (XXX NOT IMPLEMENTED).
160 */
161 void isa_establish __P((struct isadev *, struct device *));
162 #endif
163
164 #endif /* _DEV_ISA_ISAVAR_H_ */
165