isavar.h revision 1.19 1 1.19 cgd /* $NetBSD: isavar.h,v 1.19 1996/03/08 20:25:25 cgd 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.18 cgd /*
50 1.18 cgd * ISA bus attach arguments
51 1.18 cgd */
52 1.18 cgd struct isabus_attach_args {
53 1.19 cgd char *iba_busname; /* XXX should be common */
54 1.19 cgd bus_chipset_tag_t iba_bc; /* XXX should be common */
55 1.18 cgd };
56 1.15 cgd
57 1.15 cgd /*
58 1.7 mycroft * ISA driver attach arguments
59 1.7 mycroft */
60 1.7 mycroft struct isa_attach_args {
61 1.19 cgd bus_chipset_tag_t ia_bc; /* bus chipset tag */
62 1.19 cgd
63 1.12 mycroft int ia_iobase; /* base i/o address */
64 1.12 mycroft int ia_iosize; /* span of ports used */
65 1.12 mycroft int ia_irq; /* interrupt request */
66 1.12 mycroft int ia_drq; /* DMA request */
67 1.13 mycroft int ia_maddr; /* physical i/o mem addr */
68 1.7 mycroft u_int ia_msize; /* size of i/o memory */
69 1.7 mycroft void *ia_aux; /* driver specific */
70 1.7 mycroft };
71 1.7 mycroft
72 1.12 mycroft #define IOBASEUNK -1 /* i/o address is unknown */
73 1.12 mycroft #define IRQUNK -1 /* interrupt request line is unknown */
74 1.12 mycroft #define DRQUNK -1 /* DMA request line is unknown */
75 1.13 mycroft #define MADDRUNK -1 /* shared memory address is unknown */
76 1.7 mycroft
77 1.7 mycroft /*
78 1.15 cgd * Per-device ISA variables
79 1.7 mycroft */
80 1.7 mycroft struct isadev {
81 1.7 mycroft struct device *id_dev; /* back pointer to generic */
82 1.15 cgd TAILQ_ENTRY(isadev)
83 1.15 cgd id_bchain; /* bus chain */
84 1.7 mycroft };
85 1.7 mycroft
86 1.7 mycroft /*
87 1.15 cgd * ISA master bus
88 1.7 mycroft */
89 1.7 mycroft struct isa_softc {
90 1.7 mycroft struct device sc_dev; /* base device */
91 1.15 cgd TAILQ_HEAD(, isadev)
92 1.15 cgd sc_subdevs; /* list of all children */
93 1.19 cgd
94 1.19 cgd bus_chipset_tag_t sc_bc; /* bus chipset tag */
95 1.7 mycroft };
96 1.7 mycroft
97 1.7 mycroft #define cf_iobase cf_loc[0]
98 1.7 mycroft #define cf_iosize cf_loc[1]
99 1.7 mycroft #define cf_maddr cf_loc[2]
100 1.7 mycroft #define cf_msize cf_loc[3]
101 1.7 mycroft #define cf_irq cf_loc[4]
102 1.7 mycroft #define cf_drq cf_loc[5]
103 1.7 mycroft
104 1.7 mycroft /*
105 1.15 cgd * ISA interrupt handler manipulation.
106 1.15 cgd *
107 1.15 cgd * To establish an ISA interrupt handler, a driver calls isa_intr_establish()
108 1.15 cgd * with the interrupt number, type, level, function, and function argument of
109 1.15 cgd * the interrupt it wants to handle. Isa_intr_establish() returns an opaque
110 1.15 cgd * handle to an event descriptor if it succeeds, and invokes panic() if it
111 1.15 cgd * fails. (XXX It should return NULL, then drivers should handle that, but
112 1.15 cgd * what should they do?) Interrupt handlers should return 0 for "interrupt
113 1.15 cgd * not for me", 1 for "I took care of it", or -1 for "I guess it was mine,
114 1.15 cgd * but I wasn't expecting it."
115 1.15 cgd *
116 1.15 cgd * To remove an interrupt handler, the driver calls isa_intr_disestablish()
117 1.15 cgd * with the handle returned by isa_intr_establish() for that handler.
118 1.15 cgd */
119 1.15 cgd
120 1.15 cgd /* ISA interrupt sharing types */
121 1.16 cgd void isascan __P((struct device *parent, void *match));
122 1.17 mycroft void *isa_intr_establish __P((int intr, int type, int level,
123 1.17 mycroft int (*ih_fun)(void *), void *ih_arg));
124 1.16 cgd void isa_intr_disestablish __P((void *handler));
125 1.17 mycroft char *isa_intr_typename __P((int type));
126 1.7 mycroft
127 1.15 cgd #ifdef NEWCONFIG
128 1.15 cgd /*
129 1.15 cgd * Establish a device as being on the ISA bus (XXX NOT IMPLEMENTED).
130 1.15 cgd */
131 1.7 mycroft void isa_establish __P((struct isadev *, struct device *));
132 1.15 cgd #endif
133 1.7 mycroft
134 1.7 mycroft /*
135 1.7 mycroft * software conventions
136 1.7 mycroft */
137 1.15 cgd typedef enum { BUS_ISA, BUS_EISA } isa_type;
138 1.7 mycroft
139 1.15 cgd extern isa_type isa_bustype; /* type of bus; XXX should be in softc */
140 1.19 cgd
141 1.19 cgd #endif /* _DEV_ISA_ISAVAR_H_ */
142