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