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