isapnpvar.h revision 1.24 1 1.24 perry /* $NetBSD: isapnpvar.h,v 1.24 2006/02/16 20:17:19 perry Exp $ */
2 1.1 christos
3 1.16 christos /*-
4 1.16 christos * Copyright (c) 1996 The NetBSD Foundation, Inc.
5 1.16 christos * All rights reserved.
6 1.16 christos *
7 1.16 christos * This code is derived from software contributed to The NetBSD Foundation
8 1.16 christos * by Christos Zoulas.
9 1.1 christos *
10 1.1 christos * Redistribution and use in source and binary forms, with or without
11 1.1 christos * modification, are permitted provided that the following conditions
12 1.1 christos * are met:
13 1.1 christos * 1. Redistributions of source code must retain the above copyright
14 1.1 christos * notice, this list of conditions and the following disclaimer.
15 1.1 christos * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 christos * notice, this list of conditions and the following disclaimer in the
17 1.1 christos * documentation and/or other materials provided with the distribution.
18 1.1 christos * 3. All advertising materials mentioning features or use of this software
19 1.1 christos * must display the following acknowledgement:
20 1.16 christos * This product includes software developed by the NetBSD
21 1.16 christos * Foundation, Inc. and its contributors.
22 1.16 christos * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.16 christos * contributors may be used to endorse or promote products derived
24 1.16 christos * from this software without specific prior written permission.
25 1.1 christos *
26 1.16 christos * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.16 christos * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.16 christos * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.16 christos * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.16 christos * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.16 christos * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.16 christos * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.16 christos * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.16 christos * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.16 christos * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.16 christos * POSSIBILITY OF SUCH DAMAGE.
37 1.1 christos */
38 1.1 christos
39 1.1 christos #ifndef _DEV_ISAPNP_ISAPNPVAR_H_
40 1.1 christos #define _DEV_ISAPNP_ISAPNPVAR_H_
41 1.1 christos
42 1.1 christos /*
43 1.1 christos * ISA Plug and Play register definitions;
44 1.1 christos * From Plug and Play ISA Specification V1.0a, May 5 1994
45 1.1 christos */
46 1.1 christos
47 1.1 christos /*
48 1.1 christos * Structures and definitions needed by the machine-dependent header.
49 1.1 christos */
50 1.1 christos struct isapnp_softc;
51 1.1 christos
52 1.18 cgd #include <machine/isapnp_machdep.h>
53 1.1 christos
54 1.1 christos #ifndef _KERNEL
55 1.1 christos
56 1.5 mikel # include <stdlib.h>
57 1.1 christos # include <string.h>
58 1.1 christos # include <unistd.h>
59 1.1 christos
60 1.1 christos # define ISAPNP_WRITE_ADDR(sc, v) outb(ISAPNP_ADDR, v)
61 1.1 christos # define ISAPNP_WRITE_DATA(sc, v) outb(ISAPNP_WRDATA, v)
62 1.1 christos # define ISAPNP_READ_DATA(sc) inb(sc->sc_read_port)
63 1.1 christos
64 1.1 christos # define DELAY(us) usleep(us)
65 1.1 christos # define ISAPNP_MALLOC(a) malloc(a)
66 1.1 christos # define ISAPNP_FREE(a) free(a)
67 1.1 christos
68 1.1 christos # define panic printf
69 1.1 christos
70 1.1 christos #else
71 1.1 christos
72 1.1 christos # define ISAPNP_WRITE_ADDR(sc, v) \
73 1.1 christos bus_space_write_1(sc->sc_iot, sc->sc_addr_ioh, 0, v)
74 1.5 mikel # define ISAPNP_WRITE_DATA(sc, v) \
75 1.1 christos bus_space_write_1(sc->sc_iot, sc->sc_wrdata_ioh, 0, v)
76 1.5 mikel # define ISAPNP_READ_DATA(sc) \
77 1.1 christos bus_space_read_1(sc->sc_iot, sc->sc_read_ioh, 0)
78 1.1 christos
79 1.5 mikel # define ISAPNP_MALLOC(a) malloc(a, M_DEVBUF, M_WAITOK)
80 1.5 mikel # define ISAPNP_FREE(a) free(a, M_DEVBUF)
81 1.1 christos
82 1.1 christos #endif
83 1.1 christos
84 1.1 christos #ifdef DEBUG_ISAPNP
85 1.1 christos # define DPRINTF(a) printf a
86 1.1 christos #else
87 1.1 christos # define DPRINTF(a)
88 1.1 christos #endif
89 1.1 christos
90 1.1 christos struct isapnp_softc {
91 1.1 christos struct device sc_dev;
92 1.1 christos int sc_read_port;
93 1.1 christos bus_space_tag_t sc_iot;
94 1.1 christos bus_space_tag_t sc_memt;
95 1.8 thorpej isa_chipset_tag_t sc_ic;
96 1.11 thorpej bus_dma_tag_t sc_dmat;
97 1.1 christos bus_space_handle_t sc_addr_ioh;
98 1.1 christos bus_space_handle_t sc_wrdata_ioh;
99 1.1 christos bus_space_handle_t sc_read_ioh;
100 1.1 christos bus_space_handle_t sc_memh;
101 1.1 christos u_int8_t sc_ncards;
102 1.1 christos u_int8_t sc_id[ISAPNP_MAX_CARDS][ISAPNP_SERIAL_SIZE];
103 1.1 christos };
104 1.1 christos
105 1.1 christos struct isapnp_region {
106 1.1 christos bus_space_handle_t h;
107 1.1 christos u_int32_t base;
108 1.1 christos
109 1.1 christos u_int32_t minbase;
110 1.1 christos u_int32_t maxbase;
111 1.1 christos u_int32_t length;
112 1.1 christos u_int32_t align;
113 1.1 christos u_int8_t flags;
114 1.1 christos };
115 1.1 christos
116 1.1 christos struct isapnp_pin {
117 1.7 christos u_int8_t num;
118 1.7 christos u_int8_t flags:4;
119 1.7 christos u_int8_t type:4;
120 1.1 christos u_int16_t bits;
121 1.1 christos };
122 1.1 christos
123 1.1 christos struct isapnp_attach_args {
124 1.1 christos bus_space_tag_t ipa_iot; /* isa i/o space tag */
125 1.1 christos bus_space_tag_t ipa_memt; /* isa mem space tag */
126 1.3 thorpej bus_dma_tag_t ipa_dmat; /* isa dma tag */
127 1.1 christos
128 1.1 christos isa_chipset_tag_t ipa_ic;
129 1.1 christos
130 1.2 christos struct isapnp_attach_args *ipa_sibling;
131 1.2 christos struct isapnp_attach_args *ipa_child;
132 1.1 christos
133 1.1 christos char ipa_devident[ISAPNP_MAX_IDENT];
134 1.1 christos char ipa_devlogic[ISAPNP_MAX_DEVCLASS];
135 1.4 mikel char ipa_devcompat[ISAPNP_MAX_DEVCLASS];
136 1.1 christos char ipa_devclass[ISAPNP_MAX_DEVCLASS];
137 1.1 christos
138 1.1 christos u_char ipa_pref;
139 1.1 christos u_char ipa_devnum;
140 1.1 christos
141 1.1 christos u_char ipa_nio;
142 1.1 christos u_char ipa_nirq;
143 1.1 christos u_char ipa_ndrq;
144 1.1 christos u_char ipa_nmem;
145 1.1 christos u_char ipa_nmem32;
146 1.1 christos
147 1.1 christos struct isapnp_region ipa_io[ISAPNP_NUM_IO];
148 1.1 christos struct isapnp_region ipa_mem[ISAPNP_NUM_MEM];
149 1.1 christos struct isapnp_region ipa_mem32[ISAPNP_NUM_MEM32];
150 1.1 christos struct isapnp_pin ipa_irq[ISAPNP_NUM_IRQ];
151 1.1 christos struct isapnp_pin ipa_drq[ISAPNP_NUM_DRQ];
152 1.1 christos };
153 1.1 christos
154 1.24 perry static __inline void isapnp_write_reg(struct isapnp_softc *, int, u_char);
155 1.24 perry static __inline u_char isapnp_read_reg(struct isapnp_softc *, int);
156 1.1 christos
157 1.24 perry static __inline void
158 1.1 christos isapnp_write_reg(sc, r, v)
159 1.1 christos struct isapnp_softc *sc;
160 1.1 christos int r;
161 1.1 christos u_char v;
162 1.1 christos {
163 1.1 christos ISAPNP_WRITE_ADDR(sc, r);
164 1.1 christos ISAPNP_WRITE_DATA(sc, v);
165 1.1 christos }
166 1.1 christos
167 1.24 perry static __inline u_char
168 1.1 christos isapnp_read_reg(sc, r)
169 1.1 christos struct isapnp_softc *sc;
170 1.1 christos {
171 1.1 christos ISAPNP_WRITE_ADDR(sc, r);
172 1.1 christos return ISAPNP_READ_DATA(sc);
173 1.1 christos }
174 1.1 christos
175 1.1 christos struct isapnp_attach_args *
176 1.21 perry isapnp_get_resource(struct isapnp_softc *, int);
177 1.21 perry char *isapnp_id_to_vendor(char *, const u_char *);
178 1.1 christos
179 1.21 perry int isapnp_config(bus_space_tag_t, bus_space_tag_t,
180 1.21 perry struct isapnp_attach_args *);
181 1.21 perry void isapnp_unconfig(bus_space_tag_t, bus_space_tag_t,
182 1.21 perry struct isapnp_attach_args *);
183 1.9 christos #ifdef _KERNEL
184 1.9 christos struct isapnp_devinfo;
185 1.21 perry int isapnp_devmatch(const struct isapnp_attach_args *,
186 1.21 perry const struct isapnp_devinfo *, int *);
187 1.21 perry void isapnp_isa_attach_hook(struct isa_softc *);
188 1.9 christos #endif
189 1.1 christos
190 1.1 christos #ifdef DEBUG_ISAPNP
191 1.21 perry void isapnp_print_mem(const char *, const struct isapnp_region *);
192 1.21 perry void isapnp_print_io(const char *, const struct isapnp_region *);
193 1.21 perry void isapnp_print_irq(const char *, const struct isapnp_pin *);
194 1.21 perry void isapnp_print_drq(const char *, const struct isapnp_pin *);
195 1.21 perry void isapnp_print_dep_start(const char *, const u_char);
196 1.21 perry void isapnp_print_attach(const struct isapnp_attach_args *);
197 1.21 perry void isapnp_get_config(struct isapnp_softc *, struct isapnp_attach_args *);
198 1.21 perry void isapnp_print_config(const struct isapnp_attach_args *);
199 1.1 christos #endif
200 1.1 christos
201 1.1 christos #endif /* ! _DEV_ISAPNP_ISAPNPVAR_H_ */
202