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