1 /* $NetBSD: isapnpvar.h,v 1.27 2008/04/28 20:23:53 martin Exp $ */
4 * Copyright (c) 1996 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #ifndef _DEV_ISAPNP_ISAPNPVAR_H_
33 #define _DEV_ISAPNP_ISAPNPVAR_H_
36 * ISA Plug and Play register definitions;
37 * From Plug and Play ISA Specification V1.0a, May 5 1994
41 * Structures and definitions needed by the machine-dependent header.
45 #include <machine/isapnp_machdep.h>
53 # define ISAPNP_WRITE_ADDR(sc, v) outb(ISAPNP_ADDR, v)
54 # define ISAPNP_WRITE_DATA(sc, v) outb(ISAPNP_WRDATA, v)
55 # define ISAPNP_READ_DATA(sc) inb(sc->sc_read_port)
57 # define DELAY(us) usleep(us)
58 # define ISAPNP_MALLOC(a) malloc(a)
59 # define ISAPNP_FREE(a) free(a)
65 # define ISAPNP_WRITE_ADDR(sc, v) \
66 bus_space_write_1(sc->sc_iot, sc->sc_addr_ioh, 0, v)
67 # define ISAPNP_WRITE_DATA(sc, v) \
68 bus_space_write_1(sc->sc_iot, sc->sc_wrdata_ioh, 0, v)
69 # define ISAPNP_READ_DATA(sc) \
70 bus_space_read_1(sc->sc_iot, sc->sc_read_ioh, 0)
72 # define ISAPNP_MALLOC(a) malloc(a, M_DEVBUF, M_WAITOK)
73 # define ISAPNP_FREE(a) free(a, M_DEVBUF)
78 # define DPRINTF(a) printf a
86 bus_space_tag_t sc_iot
;
87 bus_space_tag_t sc_memt
;
88 isa_chipset_tag_t sc_ic
;
89 bus_dma_tag_t sc_dmat
;
90 bus_space_handle_t sc_addr_ioh
;
91 bus_space_handle_t sc_wrdata_ioh
;
92 bus_space_handle_t sc_read_ioh
;
93 bus_space_handle_t sc_memh
;
95 u_int8_t sc_id
[ISAPNP_MAX_CARDS
][ISAPNP_SERIAL_SIZE
];
98 struct isapnp_region
{
116 struct isapnp_attach_args
{
117 bus_space_tag_t ipa_iot
; /* isa i/o space tag */
118 bus_space_tag_t ipa_memt
; /* isa mem space tag */
119 bus_dma_tag_t ipa_dmat
; /* isa dma tag */
121 isa_chipset_tag_t ipa_ic
;
123 struct isapnp_attach_args
*ipa_sibling
;
124 struct isapnp_attach_args
*ipa_child
;
126 char ipa_devident
[ISAPNP_MAX_IDENT
];
127 char ipa_devlogic
[ISAPNP_MAX_DEVCLASS
];
128 char ipa_devcompat
[ISAPNP_MAX_DEVCLASS
];
129 char ipa_devclass
[ISAPNP_MAX_DEVCLASS
];
140 struct isapnp_region ipa_io
[ISAPNP_NUM_IO
];
141 struct isapnp_region ipa_mem
[ISAPNP_NUM_MEM
];
142 struct isapnp_region ipa_mem32
[ISAPNP_NUM_MEM32
];
143 struct isapnp_pin ipa_irq
[ISAPNP_NUM_IRQ
];
144 struct isapnp_pin ipa_drq
[ISAPNP_NUM_DRQ
];
147 static __inline
void isapnp_write_reg(struct isapnp_softc
*, int, u_char
);
148 static __inline u_char
isapnp_read_reg(struct isapnp_softc
*, int);
151 isapnp_write_reg(struct isapnp_softc
*sc
, int r
, u_char v
)
153 ISAPNP_WRITE_ADDR(sc
, r
);
154 ISAPNP_WRITE_DATA(sc
, v
);
157 static __inline u_char
158 isapnp_read_reg(struct isapnp_softc
*sc
, int r
)
160 ISAPNP_WRITE_ADDR(sc
, r
);
161 return ISAPNP_READ_DATA(sc
);
164 struct isapnp_attach_args
*
165 isapnp_get_resource(struct isapnp_softc
*, int);
166 char *isapnp_id_to_vendor(char *, const u_char
*);
168 int isapnp_config(bus_space_tag_t
, bus_space_tag_t
,
169 struct isapnp_attach_args
*);
170 void isapnp_unconfig(bus_space_tag_t
, bus_space_tag_t
,
171 struct isapnp_attach_args
*);
173 struct isapnp_devinfo
;
174 int isapnp_devmatch(const struct isapnp_attach_args
*,
175 const struct isapnp_devinfo
*, int *);
176 void isapnp_isa_attach_hook(struct isa_softc
*);
180 void isapnp_print_mem(const char *, const struct isapnp_region
*);
181 void isapnp_print_io(const char *, const struct isapnp_region
*);
182 void isapnp_print_irq(const char *, const struct isapnp_pin
*);
183 void isapnp_print_drq(const char *, const struct isapnp_pin
*);
184 void isapnp_print_dep_start(const char *, const u_char
);
185 void isapnp_print_attach(const struct isapnp_attach_args
*);
186 void isapnp_get_config(struct isapnp_softc
*, struct isapnp_attach_args
*);
187 void isapnp_print_config(const struct isapnp_attach_args
*);
190 #endif /* ! _DEV_ISAPNP_ISAPNPVAR_H_ */