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