isavar.h revision 1.22 1 1.22 thorpej /* $NetBSD: isavar.h,v 1.22 1996/05/05 01:14:14 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.19 cgd char *iba_busname; /* XXX should be common */
69 1.19 cgd bus_chipset_tag_t iba_bc; /* XXX should be common */
70 1.21 cgd isa_chipset_tag_t iba_ic;
71 1.18 cgd };
72 1.15 cgd
73 1.15 cgd /*
74 1.7 mycroft * ISA driver attach arguments
75 1.7 mycroft */
76 1.7 mycroft struct isa_attach_args {
77 1.21 cgd bus_chipset_tag_t ia_bc;
78 1.21 cgd isa_chipset_tag_t ia_ic;
79 1.19 cgd
80 1.12 mycroft int ia_iobase; /* base i/o address */
81 1.12 mycroft int ia_iosize; /* span of ports used */
82 1.12 mycroft int ia_irq; /* interrupt request */
83 1.12 mycroft int ia_drq; /* DMA request */
84 1.13 mycroft int ia_maddr; /* physical i/o mem addr */
85 1.7 mycroft u_int ia_msize; /* size of i/o memory */
86 1.7 mycroft void *ia_aux; /* driver specific */
87 1.22 thorpej
88 1.22 thorpej bus_io_handle_t ia_delayioh; /* i/o handle for `delay port' */
89 1.7 mycroft };
90 1.7 mycroft
91 1.12 mycroft #define IOBASEUNK -1 /* i/o address is unknown */
92 1.12 mycroft #define IRQUNK -1 /* interrupt request line is unknown */
93 1.12 mycroft #define DRQUNK -1 /* DMA request line is unknown */
94 1.13 mycroft #define MADDRUNK -1 /* shared memory address is unknown */
95 1.7 mycroft
96 1.7 mycroft /*
97 1.15 cgd * Per-device ISA variables
98 1.7 mycroft */
99 1.7 mycroft struct isadev {
100 1.7 mycroft struct device *id_dev; /* back pointer to generic */
101 1.15 cgd TAILQ_ENTRY(isadev)
102 1.15 cgd id_bchain; /* bus chain */
103 1.7 mycroft };
104 1.7 mycroft
105 1.7 mycroft /*
106 1.15 cgd * ISA master bus
107 1.7 mycroft */
108 1.7 mycroft struct isa_softc {
109 1.7 mycroft struct device sc_dev; /* base device */
110 1.15 cgd TAILQ_HEAD(, isadev)
111 1.15 cgd sc_subdevs; /* list of all children */
112 1.19 cgd
113 1.21 cgd bus_chipset_tag_t sc_bc;
114 1.21 cgd isa_chipset_tag_t sc_ic;
115 1.22 thorpej
116 1.22 thorpej /*
117 1.22 thorpej * This i/o handle is used to map port 0x84, which is
118 1.22 thorpej * read to provide a 2.5us delay. This i/o handle
119 1.22 thorpej * is mapped in isaattach(), and exported to drivers
120 1.22 thorpej * via isa_attach_args.
121 1.22 thorpej */
122 1.22 thorpej bus_io_handle_t sc_delayioh;
123 1.7 mycroft };
124 1.7 mycroft
125 1.7 mycroft #define cf_iobase cf_loc[0]
126 1.7 mycroft #define cf_iosize cf_loc[1]
127 1.7 mycroft #define cf_maddr cf_loc[2]
128 1.7 mycroft #define cf_msize cf_loc[3]
129 1.7 mycroft #define cf_irq cf_loc[4]
130 1.7 mycroft #define cf_drq cf_loc[5]
131 1.7 mycroft
132 1.7 mycroft /*
133 1.15 cgd * ISA interrupt handler manipulation.
134 1.15 cgd *
135 1.15 cgd * To establish an ISA interrupt handler, a driver calls isa_intr_establish()
136 1.15 cgd * with the interrupt number, type, level, function, and function argument of
137 1.15 cgd * the interrupt it wants to handle. Isa_intr_establish() returns an opaque
138 1.15 cgd * handle to an event descriptor if it succeeds, and invokes panic() if it
139 1.15 cgd * fails. (XXX It should return NULL, then drivers should handle that, but
140 1.15 cgd * what should they do?) Interrupt handlers should return 0 for "interrupt
141 1.15 cgd * not for me", 1 for "I took care of it", or -1 for "I guess it was mine,
142 1.15 cgd * but I wasn't expecting it."
143 1.15 cgd *
144 1.15 cgd * To remove an interrupt handler, the driver calls isa_intr_disestablish()
145 1.15 cgd * with the handle returned by isa_intr_establish() for that handler.
146 1.15 cgd */
147 1.15 cgd
148 1.15 cgd /* ISA interrupt sharing types */
149 1.16 cgd void isascan __P((struct device *parent, void *match));
150 1.17 mycroft char *isa_intr_typename __P((int type));
151 1.7 mycroft
152 1.15 cgd #ifdef NEWCONFIG
153 1.15 cgd /*
154 1.15 cgd * Establish a device as being on the ISA bus (XXX NOT IMPLEMENTED).
155 1.15 cgd */
156 1.7 mycroft void isa_establish __P((struct isadev *, struct device *));
157 1.15 cgd #endif
158 1.19 cgd
159 1.19 cgd #endif /* _DEV_ISA_ISAVAR_H_ */
160