isapnp_machdep.c revision 1.5 1 1.5 thorpej /* $NetBSD: isapnp_machdep.c,v 1.5 1997/10/04 17:32:30 thorpej Exp $ */
2 1.5 thorpej
3 1.5 thorpej /*-
4 1.5 thorpej * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
5 1.5 thorpej * All rights reserved.
6 1.5 thorpej *
7 1.5 thorpej * This code is derived from software contributed to The NetBSD Foundation
8 1.5 thorpej * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 1.5 thorpej * NASA Ames Research Center.
10 1.5 thorpej *
11 1.5 thorpej * Redistribution and use in source and binary forms, with or without
12 1.5 thorpej * modification, are permitted provided that the following conditions
13 1.5 thorpej * are met:
14 1.5 thorpej * 1. Redistributions of source code must retain the above copyright
15 1.5 thorpej * notice, this list of conditions and the following disclaimer.
16 1.5 thorpej * 2. Redistributions in binary form must reproduce the above copyright
17 1.5 thorpej * notice, this list of conditions and the following disclaimer in the
18 1.5 thorpej * documentation and/or other materials provided with the distribution.
19 1.5 thorpej * 3. All advertising materials mentioning features or use of this software
20 1.5 thorpej * must display the following acknowledgement:
21 1.5 thorpej * This product includes software developed by the NetBSD
22 1.5 thorpej * Foundation, Inc. and its contributors.
23 1.5 thorpej * 4. Neither the name of The NetBSD Foundation nor the names of its
24 1.5 thorpej * contributors may be used to endorse or promote products derived
25 1.5 thorpej * from this software without specific prior written permission.
26 1.5 thorpej *
27 1.5 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 1.5 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 1.5 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 1.5 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 1.5 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 1.5 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 1.5 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 1.5 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 1.5 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 1.5 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 1.5 thorpej * POSSIBILITY OF SUCH DAMAGE.
38 1.5 thorpej */
39 1.1 christos
40 1.1 christos /*
41 1.1 christos * Copyright (c) 1996 Christos Zoulas. All rights reserved.
42 1.1 christos *
43 1.1 christos * Redistribution and use in source and binary forms, with or without
44 1.1 christos * modification, are permitted provided that the following conditions
45 1.1 christos * are met:
46 1.1 christos * 1. Redistributions of source code must retain the above copyright
47 1.1 christos * notice, this list of conditions and the following disclaimer.
48 1.1 christos * 2. Redistributions in binary form must reproduce the above copyright
49 1.1 christos * notice, this list of conditions and the following disclaimer in the
50 1.1 christos * documentation and/or other materials provided with the distribution.
51 1.1 christos * 3. All advertising materials mentioning features or use of this software
52 1.1 christos * must display the following acknowledgement:
53 1.5 thorpej * This product includes software developed by Christos Zoulas.
54 1.1 christos * 4. The name of the author may not be used to endorse or promote products
55 1.1 christos * derived from this software without specific prior written permission.
56 1.1 christos *
57 1.1 christos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
58 1.1 christos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
59 1.1 christos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
60 1.1 christos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
61 1.1 christos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62 1.1 christos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
63 1.1 christos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
64 1.1 christos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
65 1.1 christos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
66 1.1 christos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
67 1.1 christos */
68 1.1 christos
69 1.1 christos /*
70 1.1 christos * Machine-dependent portions of ISA PnP bus autoconfiguration.
71 1.1 christos *
72 1.1 christos * N.B. This file exists mostly to get around some lameness surrounding
73 1.1 christos * the PnP spec. ISA PnP registers live where some `normal' ISA
74 1.1 christos * devices do, but are e.g. write-only registers where the normal
75 1.1 christos * device has a read-only register. This breaks in the presence of
76 1.1 christos * i/o port accounting. This file takes care of mapping ISA PnP
77 1.1 christos * registers without actually allocating them in extent maps.
78 1.1 christos *
79 1.1 christos * Since this is a machine-dependent file, we make all sorts of
80 1.1 christos * assumptions about bus.h's guts. Beware!
81 1.1 christos */
82 1.1 christos
83 1.1 christos #include <sys/param.h>
84 1.1 christos #include <sys/systm.h>
85 1.1 christos #include <sys/device.h>
86 1.1 christos #include <sys/malloc.h>
87 1.1 christos
88 1.1 christos #include <machine/bus.h>
89 1.1 christos
90 1.1 christos #include <dev/isa/isavar.h>
91 1.1 christos
92 1.1 christos #include <dev/isapnp/isapnpreg.h>
93 1.1 christos #include <dev/isapnp/isapnpvar.h>
94 1.1 christos
95 1.1 christos /* isapnp_map():
96 1.1 christos * Map I/O regions used by PnP
97 1.1 christos */
98 1.1 christos int
99 1.1 christos isapnp_map(sc)
100 1.1 christos struct isapnp_softc *sc;
101 1.1 christos {
102 1.1 christos
103 1.4 mikel #ifdef DIAGNOSTIC
104 1.1 christos if (sc->sc_iot != I386_BUS_SPACE_IO)
105 1.1 christos panic("isapnp_map: bogus bus space tag");
106 1.4 mikel #endif
107 1.1 christos
108 1.1 christos sc->sc_addr_ioh = ISAPNP_ADDR;
109 1.1 christos sc->sc_wrdata_ioh = ISAPNP_WRDATA;
110 1.1 christos return (0);
111 1.1 christos }
112 1.1 christos
113 1.1 christos /* isapnp_unmap():
114 1.1 christos * Unmap I/O regions used by PnP
115 1.1 christos */
116 1.1 christos void
117 1.1 christos isapnp_unmap(sc)
118 1.1 christos struct isapnp_softc *sc;
119 1.1 christos {
120 1.1 christos
121 1.1 christos /* Do nothing. */
122 1.1 christos }
123 1.1 christos
124 1.1 christos /* isapnp_map_readport():
125 1.1 christos * Called to map the PnP `read port', which is mapped independently
126 1.1 christos * of the `write' and `addr' ports.
127 1.1 christos *
128 1.1 christos * NOTE: assumes the caller has filled in sc->sc_read_port!
129 1.1 christos */
130 1.1 christos int
131 1.1 christos isapnp_map_readport(sc)
132 1.1 christos struct isapnp_softc *sc;
133 1.1 christos {
134 1.4 mikel #ifdef _KERNEL
135 1.3 christos int error;
136 1.4 mikel #endif
137 1.3 christos
138 1.4 mikel #ifdef DIAGNOSTIC
139 1.1 christos if (sc->sc_iot != I386_BUS_SPACE_IO)
140 1.1 christos panic("isapnp_map_readport: bogus bus space tag");
141 1.4 mikel #endif
142 1.1 christos
143 1.4 mikel #ifdef _KERNEL
144 1.2 christos /* Check if some other device has already claimed this port. */
145 1.3 christos if ((error = bus_space_map(sc->sc_iot, sc->sc_read_port, 1, 0,
146 1.3 christos &sc->sc_read_ioh)) != 0)
147 1.3 christos return error;
148 1.3 christos
149 1.3 christos /*
150 1.3 christos * XXX: We unmap the port because it can and will be used by other
151 1.3 christos * devices such as a joystick. We need a better port accounting
152 1.3 christos * scheme with read and write ports.
153 1.3 christos */
154 1.3 christos bus_space_unmap(sc->sc_iot, sc->sc_read_ioh, 1);
155 1.4 mikel #endif
156 1.3 christos return 0;
157 1.1 christos }
158 1.1 christos
159 1.1 christos /* isapnp_unmap_readport():
160 1.3 christos * Pretend to unmap a previously mapped `read port'.
161 1.1 christos */
162 1.1 christos void
163 1.1 christos isapnp_unmap_readport(sc)
164 1.1 christos struct isapnp_softc *sc;
165 1.1 christos {
166 1.4 mikel
167 1.3 christos /* Do nothing */
168 1.1 christos }
169