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