Home | History | Annotate | Line # | Download | only in isa
isavar.h revision 1.28.2.1
      1  1.28.2.1  thorpej /*	$NetBSD: isavar.h,v 1.28.2.1 1997/08/27 23:31:47 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.27      leo #if (alpha + atari + 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.27      leo #endif
     97      1.27      leo #if atari
     98      1.27      leo #include <atari/isa/isa_machdep.h>
     99      1.21      cgd #endif
    100      1.21      cgd #if i386
    101      1.21      cgd #include <i386/isa/isa_machdep.h>
    102      1.21      cgd #endif
    103      1.21      cgd 
    104      1.18      cgd /*
    105      1.18      cgd  * ISA bus attach arguments
    106      1.18      cgd  */
    107      1.18      cgd struct isabus_attach_args {
    108      1.24  thorpej 	char	*iba_busname;		/* XXX should be common */
    109      1.24  thorpej 	bus_space_tag_t iba_iot;	/* isa i/o space tag */
    110      1.24  thorpej 	bus_space_tag_t iba_memt;	/* isa mem space tag */
    111      1.26  thorpej 	bus_dma_tag_t iba_dmat;		/* isa DMA tag */
    112      1.21      cgd 	isa_chipset_tag_t iba_ic;
    113      1.18      cgd };
    114      1.15      cgd 
    115      1.15      cgd /*
    116       1.7  mycroft  * ISA driver attach arguments
    117       1.7  mycroft  */
    118       1.7  mycroft struct isa_attach_args {
    119      1.24  thorpej 	bus_space_tag_t ia_iot;		/* isa i/o space tag */
    120      1.24  thorpej 	bus_space_tag_t ia_memt;	/* isa mem space tag */
    121      1.26  thorpej 	bus_dma_tag_t ia_dmat;		/* DMA tag */
    122      1.24  thorpej 
    123      1.21      cgd 	isa_chipset_tag_t ia_ic;
    124      1.19      cgd 
    125      1.12  mycroft 	int	ia_iobase;		/* base i/o address */
    126      1.12  mycroft 	int	ia_iosize;		/* span of ports used */
    127      1.12  mycroft 	int	ia_irq;			/* interrupt request */
    128      1.12  mycroft 	int	ia_drq;			/* DMA request */
    129  1.28.2.1  thorpej 	int	ia_drq2;		/* second DMA request */
    130      1.13  mycroft 	int	ia_maddr;		/* physical i/o mem addr */
    131       1.7  mycroft 	u_int	ia_msize;		/* size of i/o memory */
    132       1.7  mycroft 	void	*ia_aux;		/* driver specific */
    133      1.22  thorpej 
    134      1.24  thorpej 	bus_space_handle_t ia_delaybah; /* i/o handle for `delay port' */
    135       1.7  mycroft };
    136       1.7  mycroft 
    137      1.28      jtk #include "locators.h"
    138      1.28      jtk 
    139      1.28      jtk #define	IOBASEUNK	ISACF_PORT_DEFAULT	/* i/o address is unknown */
    140      1.28      jtk #define	IRQUNK		ISACF_IRQ_DEFAULT	/* interrupt request line is unknown */
    141      1.28      jtk #define	DRQUNK		ISACF_DRQ_DEFAULT	/* DMA request line is unknown */
    142      1.28      jtk #define	MADDRUNK	ISACF_IOMEM_DEFAULT	/* shared memory address is unknown */
    143       1.7  mycroft 
    144       1.7  mycroft /*
    145      1.15      cgd  * Per-device ISA variables
    146       1.7  mycroft  */
    147       1.7  mycroft struct isadev {
    148       1.7  mycroft 	struct  device *id_dev;		/* back pointer to generic */
    149      1.15      cgd 	TAILQ_ENTRY(isadev)
    150      1.15      cgd 		id_bchain;		/* bus chain */
    151       1.7  mycroft };
    152       1.7  mycroft 
    153       1.7  mycroft /*
    154      1.15      cgd  * ISA master bus
    155       1.7  mycroft  */
    156       1.7  mycroft struct isa_softc {
    157       1.7  mycroft 	struct	device sc_dev;		/* base device */
    158      1.15      cgd 	TAILQ_HEAD(, isadev)
    159      1.15      cgd 		sc_subdevs;		/* list of all children */
    160      1.19      cgd 
    161      1.24  thorpej 	bus_space_tag_t sc_iot;		/* isa io space tag */
    162      1.24  thorpej 	bus_space_tag_t sc_memt;	/* isa mem space tag */
    163      1.26  thorpej 	bus_dma_tag_t sc_dmat;		/* isa DMA tag */
    164      1.24  thorpej 
    165      1.21      cgd 	isa_chipset_tag_t sc_ic;
    166      1.22  thorpej 
    167      1.22  thorpej 	/*
    168      1.26  thorpej 	 * Bitmap representing the DRQ channels available
    169      1.26  thorpej 	 * for ISA.
    170      1.26  thorpej 	 */
    171      1.26  thorpej 	int	sc_drqmap;
    172      1.26  thorpej 
    173      1.26  thorpej 	bus_space_handle_t sc_dma1h;	/* i/o handle for DMA controller #1 */
    174      1.26  thorpej 	bus_space_handle_t sc_dma2h;	/* i/o handle for DMA controller #2 */
    175      1.26  thorpej 	bus_space_handle_t sc_dmapgh;	/* i/o handle for DMA page registers */
    176      1.26  thorpej 
    177      1.26  thorpej 	/*
    178      1.26  thorpej 	 * DMA maps used for the 8 DMA channels.
    179      1.26  thorpej 	 */
    180      1.26  thorpej 	bus_dmamap_t	sc_dmamaps[8];
    181      1.26  thorpej 	vm_size_t	sc_dmalength[8];
    182      1.26  thorpej 
    183      1.26  thorpej 	int	sc_dmareads;		/* state for isa_dmadone() */
    184      1.26  thorpej 	int	sc_dmafinished;		/* DMA completion state */
    185      1.26  thorpej 
    186      1.26  thorpej 	/*
    187      1.22  thorpej 	 * This i/o handle is used to map port 0x84, which is
    188      1.24  thorpej 	 * read to provide a 1.25us delay.  This access handle
    189      1.22  thorpej 	 * is mapped in isaattach(), and exported to drivers
    190      1.22  thorpej 	 * via isa_attach_args.
    191      1.22  thorpej 	 */
    192      1.24  thorpej 	bus_space_handle_t   sc_delaybah;
    193       1.7  mycroft };
    194       1.7  mycroft 
    195      1.26  thorpej #define	ISA_DRQ_ISFREE(isadev, drq) \
    196      1.26  thorpej 	((((struct isa_softc *)(isadev))->sc_drqmap & (1 << (drq))) == 0)
    197      1.26  thorpej 
    198      1.26  thorpej #define	ISA_DRQ_ALLOC(isadev, drq) \
    199      1.26  thorpej 	((struct isa_softc *)(isadev))->sc_drqmap |= (1 << (drq))
    200      1.26  thorpej 
    201      1.26  thorpej #define	ISA_DRQ_FREE(isadev, drq) \
    202      1.26  thorpej 	((struct isa_softc *)(isadev))->sc_drqmap &= ~(1 << (drq))
    203      1.26  thorpej 
    204      1.28      jtk #define		cf_iobase		cf_loc[ISACF_PORT]
    205      1.28      jtk #define		cf_iosize		cf_loc[ISACF_SIZE]
    206      1.28      jtk #define		cf_maddr		cf_loc[ISACF_IOMEM]
    207      1.28      jtk #define		cf_msize		cf_loc[ISACF_IOSIZ]
    208      1.28      jtk #define		cf_irq			cf_loc[ISACF_IRQ]
    209      1.28      jtk #define		cf_drq			cf_loc[ISACF_DRQ]
    210  1.28.2.1  thorpej #define		cf_drq2			cf_loc[ISACF_DRQ2]
    211       1.7  mycroft 
    212       1.7  mycroft /*
    213      1.15      cgd  * ISA interrupt handler manipulation.
    214      1.15      cgd  *
    215      1.15      cgd  * To establish an ISA interrupt handler, a driver calls isa_intr_establish()
    216      1.15      cgd  * with the interrupt number, type, level, function, and function argument of
    217      1.15      cgd  * the interrupt it wants to handle.  Isa_intr_establish() returns an opaque
    218      1.15      cgd  * handle to an event descriptor if it succeeds, and invokes panic() if it
    219      1.15      cgd  * fails.  (XXX It should return NULL, then drivers should handle that, but
    220      1.15      cgd  * what should they do?)  Interrupt handlers should return 0 for "interrupt
    221      1.15      cgd  * not for me", 1  for "I took care of it", or -1 for "I guess it was mine,
    222      1.15      cgd  * but I wasn't expecting it."
    223      1.15      cgd  *
    224      1.15      cgd  * To remove an interrupt handler, the driver calls isa_intr_disestablish()
    225      1.15      cgd  * with the handle returned by isa_intr_establish() for that handler.
    226      1.15      cgd  */
    227      1.15      cgd 
    228      1.15      cgd /* ISA interrupt sharing types */
    229      1.17  mycroft char	*isa_intr_typename __P((int type));
    230       1.7  mycroft 
    231      1.15      cgd #ifdef NEWCONFIG
    232      1.15      cgd /*
    233      1.15      cgd  * Establish a device as being on the ISA bus (XXX NOT IMPLEMENTED).
    234      1.15      cgd  */
    235       1.7  mycroft void isa_establish __P((struct isadev *, struct device *));
    236      1.15      cgd #endif
    237      1.26  thorpej 
    238      1.26  thorpej /*
    239      1.26  thorpej  * Some ISA devices (e.g. on a VLB) can perform 32-bit DMA.  This
    240      1.26  thorpej  * flag is passed to bus_dmamap_create() to indicate that fact.
    241      1.26  thorpej  */
    242      1.26  thorpej #define	ISABUS_DMA_32BIT	BUS_DMA_BUS1
    243      1.19      cgd 
    244      1.19      cgd #endif /* _DEV_ISA_ISAVAR_H_ */
    245