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