Home | History | Annotate | Line # | Download | only in isa
isavar.h revision 1.27
      1 /*	$NetBSD: isavar.h,v 1.27 1997/07/15 08:40:02 leo Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1997 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9  * NASA Ames Research Center.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  * 3. All advertising materials mentioning features or use of this software
     20  *    must display the following acknowledgement:
     21  *	This product includes software developed by the NetBSD
     22  *	Foundation, Inc. and its contributors.
     23  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24  *    contributors may be used to endorse or promote products derived
     25  *    from this software without specific prior written permission.
     26  *
     27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37  * POSSIBILITY OF SUCH DAMAGE.
     38  */
     39 
     40 /*
     41  * Copyright (c) 1995 Chris G. Demetriou
     42  * Copyright (c) 1992 Berkeley Software Design, Inc.
     43  * 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 Berkeley Software
     56  *	Design, Inc.
     57  * 4. The name of Berkeley Software Design must not be used to endorse
     58  *    or promote products derived from this software without specific
     59  *    prior written permission.
     60  *
     61  * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN, INC. ``AS IS'' AND
     62  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     63  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     64  * ARE DISCLAIMED.  IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN, INC. BE LIABLE
     65  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     66  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     67  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     68  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     69  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     70  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     71  * SUCH DAMAGE.
     72  *
     73  *	BSDI Id: isavar.h,v 1.5 1992/12/01 18:06:00 karels Exp
     74  */
     75 
     76 #ifndef _DEV_ISA_ISAVAR_H_
     77 #define	_DEV_ISA_ISAVAR_H_
     78 
     79 /*
     80  * Definitions for ISA autoconfiguration.
     81  */
     82 
     83 #include <sys/queue.h>
     84 #include <machine/bus.h>
     85 
     86 /*
     87  * Structures and definitions needed by the machine-dependent header.
     88  */
     89 struct isabus_attach_args;
     90 
     91 #if (alpha + atari + i386 != 1)
     92 ERROR: COMPILING FOR UNSUPPORTED MACHINE, OR MORE THAN ONE.
     93 #endif
     94 #if alpha
     95 #include <alpha/isa/isa_machdep.h>
     96 #endif
     97 #if atari
     98 #include <atari/isa/isa_machdep.h>
     99 #endif
    100 #if i386
    101 #include <i386/isa/isa_machdep.h>
    102 #endif
    103 
    104 /*
    105  * ISA bus attach arguments
    106  */
    107 struct isabus_attach_args {
    108 	char	*iba_busname;		/* XXX should be common */
    109 	bus_space_tag_t iba_iot;	/* isa i/o space tag */
    110 	bus_space_tag_t iba_memt;	/* isa mem space tag */
    111 	bus_dma_tag_t iba_dmat;		/* isa DMA tag */
    112 	isa_chipset_tag_t iba_ic;
    113 };
    114 
    115 /*
    116  * ISA driver attach arguments
    117  */
    118 struct isa_attach_args {
    119 	bus_space_tag_t ia_iot;		/* isa i/o space tag */
    120 	bus_space_tag_t ia_memt;	/* isa mem space tag */
    121 	bus_dma_tag_t ia_dmat;		/* DMA tag */
    122 
    123 	isa_chipset_tag_t ia_ic;
    124 
    125 	int	ia_iobase;		/* base i/o address */
    126 	int	ia_iosize;		/* span of ports used */
    127 	int	ia_irq;			/* interrupt request */
    128 	int	ia_drq;			/* DMA request */
    129 	int	ia_maddr;		/* physical i/o mem addr */
    130 	u_int	ia_msize;		/* size of i/o memory */
    131 	void	*ia_aux;		/* driver specific */
    132 
    133 	bus_space_handle_t ia_delaybah; /* i/o handle for `delay port' */
    134 };
    135 
    136 #define	IOBASEUNK	-1		/* i/o address is unknown */
    137 #define	IRQUNK		-1		/* interrupt request line is unknown */
    138 #define	DRQUNK		-1		/* DMA request line is unknown */
    139 #define	MADDRUNK	-1		/* shared memory address is unknown */
    140 
    141 /*
    142  * Per-device ISA variables
    143  */
    144 struct isadev {
    145 	struct  device *id_dev;		/* back pointer to generic */
    146 	TAILQ_ENTRY(isadev)
    147 		id_bchain;		/* bus chain */
    148 };
    149 
    150 /*
    151  * ISA master bus
    152  */
    153 struct isa_softc {
    154 	struct	device sc_dev;		/* base device */
    155 	TAILQ_HEAD(, isadev)
    156 		sc_subdevs;		/* list of all children */
    157 
    158 	bus_space_tag_t sc_iot;		/* isa io space tag */
    159 	bus_space_tag_t sc_memt;	/* isa mem space tag */
    160 	bus_dma_tag_t sc_dmat;		/* isa DMA tag */
    161 
    162 	isa_chipset_tag_t sc_ic;
    163 
    164 	/*
    165 	 * Bitmap representing the DRQ channels available
    166 	 * for ISA.
    167 	 */
    168 	int	sc_drqmap;
    169 
    170 	bus_space_handle_t sc_dma1h;	/* i/o handle for DMA controller #1 */
    171 	bus_space_handle_t sc_dma2h;	/* i/o handle for DMA controller #2 */
    172 	bus_space_handle_t sc_dmapgh;	/* i/o handle for DMA page registers */
    173 
    174 	/*
    175 	 * DMA maps used for the 8 DMA channels.
    176 	 */
    177 	bus_dmamap_t	sc_dmamaps[8];
    178 	vm_size_t	sc_dmalength[8];
    179 
    180 	int	sc_dmareads;		/* state for isa_dmadone() */
    181 	int	sc_dmafinished;		/* DMA completion state */
    182 
    183 	/*
    184 	 * This i/o handle is used to map port 0x84, which is
    185 	 * read to provide a 1.25us delay.  This access handle
    186 	 * is mapped in isaattach(), and exported to drivers
    187 	 * via isa_attach_args.
    188 	 */
    189 	bus_space_handle_t   sc_delaybah;
    190 };
    191 
    192 #define	ISA_DRQ_ISFREE(isadev, drq) \
    193 	((((struct isa_softc *)(isadev))->sc_drqmap & (1 << (drq))) == 0)
    194 
    195 #define	ISA_DRQ_ALLOC(isadev, drq) \
    196 	((struct isa_softc *)(isadev))->sc_drqmap |= (1 << (drq))
    197 
    198 #define	ISA_DRQ_FREE(isadev, drq) \
    199 	((struct isa_softc *)(isadev))->sc_drqmap &= ~(1 << (drq))
    200 
    201 #define		cf_iobase		cf_loc[0]
    202 #define		cf_iosize		cf_loc[1]
    203 #define		cf_maddr		cf_loc[2]
    204 #define		cf_msize		cf_loc[3]
    205 #define		cf_irq			cf_loc[4]
    206 #define		cf_drq			cf_loc[5]
    207 
    208 /*
    209  * ISA interrupt handler manipulation.
    210  *
    211  * To establish an ISA interrupt handler, a driver calls isa_intr_establish()
    212  * with the interrupt number, type, level, function, and function argument of
    213  * the interrupt it wants to handle.  Isa_intr_establish() returns an opaque
    214  * handle to an event descriptor if it succeeds, and invokes panic() if it
    215  * fails.  (XXX It should return NULL, then drivers should handle that, but
    216  * what should they do?)  Interrupt handlers should return 0 for "interrupt
    217  * not for me", 1  for "I took care of it", or -1 for "I guess it was mine,
    218  * but I wasn't expecting it."
    219  *
    220  * To remove an interrupt handler, the driver calls isa_intr_disestablish()
    221  * with the handle returned by isa_intr_establish() for that handler.
    222  */
    223 
    224 /* ISA interrupt sharing types */
    225 char	*isa_intr_typename __P((int type));
    226 
    227 #ifdef NEWCONFIG
    228 /*
    229  * Establish a device as being on the ISA bus (XXX NOT IMPLEMENTED).
    230  */
    231 void isa_establish __P((struct isadev *, struct device *));
    232 #endif
    233 
    234 /*
    235  * Some ISA devices (e.g. on a VLB) can perform 32-bit DMA.  This
    236  * flag is passed to bus_dmamap_create() to indicate that fact.
    237  */
    238 #define	ISABUS_DMA_32BIT	BUS_DMA_BUS1
    239 
    240 #endif /* _DEV_ISA_ISAVAR_H_ */
    241