isapnp_machdep.c revision 1.6.26.1 1 1.6.26.1 nathanw /* $NetBSD: isapnp_machdep.c,v 1.6.26.1 2002/01/08 00:25:35 nathanw 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.6 christos * NASA Ames Research Center and by Christos Zoulas.
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.1 christos */
39 1.1 christos
40 1.1 christos /*
41 1.1 christos * Machine-dependent portions of ISA PnP bus autoconfiguration.
42 1.1 christos *
43 1.1 christos * N.B. This file exists mostly to get around some lameness surrounding
44 1.1 christos * the PnP spec. ISA PnP registers live where some `normal' ISA
45 1.1 christos * devices do, but are e.g. write-only registers where the normal
46 1.1 christos * device has a read-only register. This breaks in the presence of
47 1.1 christos * i/o port accounting. This file takes care of mapping ISA PnP
48 1.1 christos * registers without actually allocating them in extent maps.
49 1.1 christos *
50 1.1 christos * Since this is a machine-dependent file, we make all sorts of
51 1.1 christos * assumptions about bus.h's guts. Beware!
52 1.1 christos */
53 1.6.26.1 nathanw
54 1.6.26.1 nathanw #include <sys/cdefs.h>
55 1.6.26.1 nathanw __KERNEL_RCSID(0, "$NetBSD: isapnp_machdep.c,v 1.6.26.1 2002/01/08 00:25:35 nathanw Exp $");
56 1.1 christos
57 1.1 christos #include <sys/param.h>
58 1.1 christos #include <sys/systm.h>
59 1.1 christos #include <sys/device.h>
60 1.1 christos #include <sys/malloc.h>
61 1.1 christos
62 1.1 christos #include <machine/bus.h>
63 1.1 christos
64 1.1 christos #include <dev/isa/isavar.h>
65 1.1 christos
66 1.1 christos #include <dev/isapnp/isapnpreg.h>
67 1.1 christos #include <dev/isapnp/isapnpvar.h>
68 1.1 christos
69 1.1 christos /* isapnp_map():
70 1.1 christos * Map I/O regions used by PnP
71 1.1 christos */
72 1.1 christos int
73 1.1 christos isapnp_map(sc)
74 1.1 christos struct isapnp_softc *sc;
75 1.1 christos {
76 1.1 christos
77 1.4 mikel #ifdef DIAGNOSTIC
78 1.1 christos if (sc->sc_iot != I386_BUS_SPACE_IO)
79 1.1 christos panic("isapnp_map: bogus bus space tag");
80 1.4 mikel #endif
81 1.1 christos
82 1.1 christos sc->sc_addr_ioh = ISAPNP_ADDR;
83 1.1 christos sc->sc_wrdata_ioh = ISAPNP_WRDATA;
84 1.1 christos return (0);
85 1.1 christos }
86 1.1 christos
87 1.1 christos /* isapnp_unmap():
88 1.1 christos * Unmap I/O regions used by PnP
89 1.1 christos */
90 1.1 christos void
91 1.1 christos isapnp_unmap(sc)
92 1.1 christos struct isapnp_softc *sc;
93 1.1 christos {
94 1.1 christos
95 1.1 christos /* Do nothing. */
96 1.1 christos }
97 1.1 christos
98 1.1 christos /* isapnp_map_readport():
99 1.1 christos * Called to map the PnP `read port', which is mapped independently
100 1.1 christos * of the `write' and `addr' ports.
101 1.1 christos *
102 1.1 christos * NOTE: assumes the caller has filled in sc->sc_read_port!
103 1.1 christos */
104 1.1 christos int
105 1.1 christos isapnp_map_readport(sc)
106 1.1 christos struct isapnp_softc *sc;
107 1.1 christos {
108 1.4 mikel #ifdef _KERNEL
109 1.3 christos int error;
110 1.4 mikel #endif
111 1.3 christos
112 1.4 mikel #ifdef DIAGNOSTIC
113 1.1 christos if (sc->sc_iot != I386_BUS_SPACE_IO)
114 1.1 christos panic("isapnp_map_readport: bogus bus space tag");
115 1.4 mikel #endif
116 1.1 christos
117 1.4 mikel #ifdef _KERNEL
118 1.2 christos /* Check if some other device has already claimed this port. */
119 1.3 christos if ((error = bus_space_map(sc->sc_iot, sc->sc_read_port, 1, 0,
120 1.3 christos &sc->sc_read_ioh)) != 0)
121 1.3 christos return error;
122 1.3 christos
123 1.3 christos /*
124 1.3 christos * XXX: We unmap the port because it can and will be used by other
125 1.3 christos * devices such as a joystick. We need a better port accounting
126 1.3 christos * scheme with read and write ports.
127 1.3 christos */
128 1.3 christos bus_space_unmap(sc->sc_iot, sc->sc_read_ioh, 1);
129 1.4 mikel #endif
130 1.3 christos return 0;
131 1.1 christos }
132 1.1 christos
133 1.1 christos /* isapnp_unmap_readport():
134 1.3 christos * Pretend to unmap a previously mapped `read port'.
135 1.1 christos */
136 1.1 christos void
137 1.1 christos isapnp_unmap_readport(sc)
138 1.1 christos struct isapnp_softc *sc;
139 1.1 christos {
140 1.4 mikel
141 1.3 christos /* Do nothing */
142 1.1 christos }
143