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