1 /* $NetBSD: isapnp_machdep.c,v 1.2 2000/02/22 11:26:03 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 sc->sc_addr_ioh = sc->sc_iot->bus_base + ISAPNP_ADDR; 104 sc->sc_wrdata_ioh = sc->sc_iot->bus_base + ISAPNP_WRDATA; 105 return (0); 106 } 107 108 /* isapnp_unmap(): 109 * Unmap I/O regions used by PnP 110 */ 111 void 112 isapnp_unmap(sc) 113 struct isapnp_softc *sc; 114 { 115 /* Do nothing. */ 116 } 117 118 /* isapnp_map_readport(): 119 * Called to map the PnP `read port', which is mapped independently 120 * of the `write' and `addr' ports. 121 * 122 * NOTE: assumes the caller has filled in sc->sc_read_port! 123 */ 124 int 125 isapnp_map_readport(sc) 126 struct isapnp_softc *sc; 127 { 128 #ifdef _KERNEL 129 int error; 130 131 /* Check if some other device has already claimed this port. */ 132 if ((error = bus_space_map(sc->sc_iot, sc->sc_read_port, 1, 0, 133 &sc->sc_read_ioh)) != 0) 134 return error; 135 136 /* 137 * XXX: We unmap the port because it can and will be used by other 138 * devices such as a joystick. We need a better port accounting 139 * scheme with read and write ports. 140 */ 141 bus_space_unmap(sc->sc_iot, sc->sc_read_ioh, 1); 142 #endif 143 return 0; 144 } 145 146 /* isapnp_unmap_readport(): 147 * Pretend to unmap a previously mapped `read port'. 148 */ 149 void 150 isapnp_unmap_readport(sc) 151 struct isapnp_softc *sc; 152 { 153 /* Do nothing */ 154 } 155