Home | History | Annotate | Line # | Download | only in isa
isavar.h revision 1.38.4.2
      1  1.38.4.2   nathanw /*	$NetBSD: isavar.h,v 1.38.4.2 2002/02/28 04:13:44 nathanw Exp $	*/
      2      1.26   thorpej 
      3      1.26   thorpej /*-
      4  1.38.4.1   nathanw  * Copyright (c) 1997, 2001 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.38.4.1   nathanw  * by Jason R. Thorpe of Wasabi Systems, Inc.
      9      1.26   thorpej  *
     10      1.26   thorpej  * Redistribution and use in source and binary forms, with or without
     11      1.26   thorpej  * modification, are permitted provided that the following conditions
     12      1.26   thorpej  * are met:
     13      1.26   thorpej  * 1. Redistributions of source code must retain the above copyright
     14      1.26   thorpej  *    notice, this list of conditions and the following disclaimer.
     15      1.26   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     16      1.26   thorpej  *    notice, this list of conditions and the following disclaimer in the
     17      1.26   thorpej  *    documentation and/or other materials provided with the distribution.
     18      1.26   thorpej  * 3. All advertising materials mentioning features or use of this software
     19      1.26   thorpej  *    must display the following acknowledgement:
     20      1.26   thorpej  *	This product includes software developed by the NetBSD
     21      1.26   thorpej  *	Foundation, Inc. and its contributors.
     22      1.26   thorpej  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23      1.26   thorpej  *    contributors may be used to endorse or promote products derived
     24      1.26   thorpej  *    from this software without specific prior written permission.
     25      1.26   thorpej  *
     26      1.26   thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27      1.26   thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28      1.26   thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29      1.26   thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30      1.26   thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31      1.26   thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32      1.26   thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33      1.26   thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34      1.26   thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35      1.26   thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36      1.26   thorpej  * POSSIBILITY OF SUCH DAMAGE.
     37      1.26   thorpej  */
     38      1.11       cgd 
     39       1.8   mycroft /*
     40      1.15       cgd  * Copyright (c) 1995 Chris G. Demetriou
     41       1.8   mycroft  * Copyright (c) 1992 Berkeley Software Design, Inc.
     42       1.8   mycroft  * All rights reserved.
     43       1.7   mycroft  *
     44       1.8   mycroft  * Redistribution and use in source and binary forms, with or without
     45       1.8   mycroft  * modification, are permitted provided that the following conditions
     46       1.8   mycroft  * are met:
     47       1.8   mycroft  * 1. Redistributions of source code must retain the above copyright
     48       1.8   mycroft  *    notice, this list of conditions and the following disclaimer.
     49       1.8   mycroft  * 2. Redistributions in binary form must reproduce the above copyright
     50       1.8   mycroft  *    notice, this list of conditions and the following disclaimer in the
     51       1.8   mycroft  *    documentation and/or other materials provided with the distribution.
     52       1.8   mycroft  * 3. All advertising materials mentioning features or use of this software
     53       1.8   mycroft  *    must display the following acknowledgement:
     54       1.8   mycroft  *	This product includes software developed by Berkeley Software
     55       1.8   mycroft  *	Design, Inc.
     56       1.8   mycroft  * 4. The name of Berkeley Software Design must not be used to endorse
     57       1.8   mycroft  *    or promote products derived from this software without specific
     58       1.8   mycroft  *    prior written permission.
     59       1.8   mycroft  *
     60       1.8   mycroft  * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN, INC. ``AS IS'' AND
     61       1.8   mycroft  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     62       1.8   mycroft  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     63       1.8   mycroft  * ARE DISCLAIMED.  IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN, INC. BE LIABLE
     64       1.8   mycroft  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     65       1.8   mycroft  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     66       1.8   mycroft  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     67       1.8   mycroft  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     68       1.8   mycroft  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     69       1.8   mycroft  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     70       1.8   mycroft  * SUCH DAMAGE.
     71       1.8   mycroft  *
     72      1.11       cgd  *	BSDI Id: isavar.h,v 1.5 1992/12/01 18:06:00 karels Exp
     73       1.7   mycroft  */
     74       1.7   mycroft 
     75      1.19       cgd #ifndef _DEV_ISA_ISAVAR_H_
     76      1.19       cgd #define	_DEV_ISA_ISAVAR_H_
     77      1.19       cgd 
     78       1.7   mycroft /*
     79      1.15       cgd  * Definitions for ISA autoconfiguration.
     80      1.15       cgd  */
     81      1.15       cgd 
     82      1.15       cgd #include <sys/queue.h>
     83      1.19       cgd #include <machine/bus.h>
     84      1.18       cgd 
     85      1.21       cgd /*
     86      1.21       cgd  * Structures and definitions needed by the machine-dependent header.
     87      1.21       cgd  */
     88      1.21       cgd struct isabus_attach_args;
     89      1.21       cgd 
     90      1.37       cgd #include <machine/isa_machdep.h>
     91      1.21       cgd 
     92      1.18       cgd /*
     93      1.18       cgd  * ISA bus attach arguments
     94      1.18       cgd  */
     95      1.18       cgd struct isabus_attach_args {
     96      1.24   thorpej 	char	*iba_busname;		/* XXX should be common */
     97      1.24   thorpej 	bus_space_tag_t iba_iot;	/* isa i/o space tag */
     98      1.24   thorpej 	bus_space_tag_t iba_memt;	/* isa mem space tag */
     99      1.26   thorpej 	bus_dma_tag_t iba_dmat;		/* isa DMA tag */
    100      1.21       cgd 	isa_chipset_tag_t iba_ic;
    101      1.18       cgd };
    102      1.15       cgd 
    103      1.15       cgd /*
    104  1.38.4.1   nathanw  * ISA bus resources.
    105  1.38.4.1   nathanw  */
    106  1.38.4.1   nathanw 
    107  1.38.4.1   nathanw struct isa_io {
    108  1.38.4.1   nathanw 	int ir_addr;
    109  1.38.4.1   nathanw 	int ir_size;
    110  1.38.4.1   nathanw };
    111  1.38.4.1   nathanw 
    112  1.38.4.1   nathanw struct isa_iomem {
    113  1.38.4.1   nathanw 	int ir_addr;
    114  1.38.4.1   nathanw 	int ir_size;
    115  1.38.4.1   nathanw };
    116  1.38.4.1   nathanw 
    117  1.38.4.1   nathanw struct isa_irq {
    118  1.38.4.1   nathanw 	int ir_irq;
    119  1.38.4.1   nathanw };
    120  1.38.4.1   nathanw 
    121  1.38.4.1   nathanw struct isa_drq {
    122  1.38.4.1   nathanw 	int ir_drq;
    123  1.38.4.1   nathanw };
    124  1.38.4.1   nathanw 
    125  1.38.4.1   nathanw struct isa_pnpname {
    126  1.38.4.1   nathanw 	struct isa_pnpname *ipn_next;
    127  1.38.4.1   nathanw 	char *ipn_name;
    128  1.38.4.1   nathanw };
    129  1.38.4.1   nathanw 
    130  1.38.4.1   nathanw /*
    131  1.38.4.1   nathanw  * Machine-dependent code provides a list of these to describe
    132  1.38.4.1   nathanw  * devices on the ISA bus which should be attached via direct
    133  1.38.4.1   nathanw  * configuration.
    134  1.38.4.1   nathanw  *
    135  1.38.4.1   nathanw  * All of this information is dynamically allocated, so that
    136  1.38.4.1   nathanw  * the ISA bus driver may free all of this information if the
    137  1.38.4.1   nathanw  * bus does not support dynamic attach/detach of devices (e.g.
    138  1.38.4.1   nathanw  * on a docking station).
    139  1.38.4.1   nathanw  *
    140  1.38.4.1   nathanw  * Some info on the "ik_key" field: This is a unique number for
    141  1.38.4.1   nathanw  * each knowndev node.  If, when we need to re-enumerate the
    142  1.38.4.1   nathanw  * knowndevs, we discover that a node with key N is in the old
    143  1.38.4.1   nathanw  * list but not in the new, the device has disappeared.  Similarly,
    144  1.38.4.1   nathanw  * if a node with key M is in the new list but not in the old,
    145  1.38.4.1   nathanw  * the device is new.  Note that the knowndevs list must be
    146  1.38.4.1   nathanw  * sorted in ascending "key" order.
    147  1.38.4.1   nathanw  */
    148  1.38.4.1   nathanw struct isa_knowndev {
    149  1.38.4.1   nathanw 	TAILQ_ENTRY(isa_knowndev) ik_list;
    150  1.38.4.1   nathanw 	uintptr_t ik_key;
    151  1.38.4.1   nathanw 	struct device *ik_claimed;
    152  1.38.4.1   nathanw 
    153  1.38.4.1   nathanw 	/*
    154  1.38.4.1   nathanw 	 * The rest of these fields correspond to isa_attach_args
    155  1.38.4.1   nathanw 	 * fields.
    156  1.38.4.1   nathanw 	 */
    157  1.38.4.1   nathanw 	char *ik_pnpname;
    158  1.38.4.1   nathanw 	struct isa_pnpname *ik_pnpcompatnames;
    159  1.38.4.1   nathanw 
    160  1.38.4.1   nathanw 	struct isa_io *ik_io;
    161  1.38.4.1   nathanw 	int ik_nio;
    162  1.38.4.1   nathanw 
    163  1.38.4.1   nathanw 	struct isa_iomem *ik_iomem;
    164  1.38.4.1   nathanw 	int ik_niomem;
    165  1.38.4.1   nathanw 
    166  1.38.4.1   nathanw 	struct isa_irq *ik_irq;
    167  1.38.4.1   nathanw 	int ik_nirq;
    168  1.38.4.1   nathanw 
    169  1.38.4.1   nathanw 	struct isa_drq *ik_drq;
    170  1.38.4.1   nathanw 	int ik_ndrq;
    171  1.38.4.1   nathanw };
    172  1.38.4.1   nathanw 
    173  1.38.4.1   nathanw /*
    174       1.7   mycroft  * ISA driver attach arguments
    175       1.7   mycroft  */
    176       1.7   mycroft struct isa_attach_args {
    177      1.24   thorpej 	bus_space_tag_t ia_iot;		/* isa i/o space tag */
    178      1.24   thorpej 	bus_space_tag_t ia_memt;	/* isa mem space tag */
    179      1.26   thorpej 	bus_dma_tag_t ia_dmat;		/* DMA tag */
    180      1.24   thorpej 
    181      1.21       cgd 	isa_chipset_tag_t ia_ic;
    182      1.19       cgd 
    183  1.38.4.1   nathanw 	/*
    184  1.38.4.1   nathanw 	 * PNP (or other) names to with which we can match a device
    185  1.38.4.1   nathanw 	 * driver to a device that machine-dependent code tells us
    186  1.38.4.1   nathanw 	 * is there (i.e. support for direct-configuration of ISA
    187  1.38.4.1   nathanw 	 * devices).
    188  1.38.4.1   nathanw 	 */
    189  1.38.4.1   nathanw 	char *ia_pnpname;
    190  1.38.4.1   nathanw 	struct isa_pnpname *ia_pnpcompatnames;
    191  1.38.4.1   nathanw 
    192  1.38.4.1   nathanw 	struct isa_io *ia_io;		/* I/O resources */
    193  1.38.4.1   nathanw 	int ia_nio;
    194  1.38.4.1   nathanw 
    195  1.38.4.1   nathanw 	struct isa_iomem *ia_iomem;	/* memory resources */
    196  1.38.4.1   nathanw 	int ia_niomem;
    197  1.38.4.1   nathanw 
    198  1.38.4.1   nathanw 	struct isa_irq *ia_irq;		/* IRQ resources */
    199  1.38.4.1   nathanw 	int ia_nirq;
    200  1.38.4.1   nathanw 
    201  1.38.4.1   nathanw 	struct isa_drq *ia_drq;		/* DRQ resources */
    202  1.38.4.1   nathanw 	int ia_ndrq;
    203  1.38.4.1   nathanw 
    204       1.7   mycroft 	void	*ia_aux;		/* driver specific */
    205       1.7   mycroft };
    206       1.7   mycroft 
    207  1.38.4.1   nathanw /*
    208  1.38.4.1   nathanw  * Test to determine if a given call to an ISA device probe routine
    209  1.38.4.1   nathanw  * is actually an attempt to do direct configuration.
    210  1.38.4.1   nathanw  */
    211  1.38.4.1   nathanw #define	ISA_DIRECT_CONFIG(ia)						\
    212  1.38.4.1   nathanw 	((ia)->ia_pnpname != NULL || (ia)->ia_pnpcompatnames != NULL)
    213      1.28       jtk 
    214  1.38.4.1   nathanw #include "locators.h"
    215       1.7   mycroft 
    216       1.7   mycroft /*
    217      1.15       cgd  * ISA master bus
    218       1.7   mycroft  */
    219       1.7   mycroft struct isa_softc {
    220       1.7   mycroft 	struct	device sc_dev;		/* base device */
    221      1.19       cgd 
    222      1.24   thorpej 	bus_space_tag_t sc_iot;		/* isa io space tag */
    223      1.24   thorpej 	bus_space_tag_t sc_memt;	/* isa mem space tag */
    224      1.26   thorpej 	bus_dma_tag_t sc_dmat;		/* isa DMA tag */
    225      1.24   thorpej 
    226      1.21       cgd 	isa_chipset_tag_t sc_ic;
    227  1.38.4.1   nathanw 
    228  1.38.4.1   nathanw 	TAILQ_HEAD(, isa_knowndev) sc_knowndevs;
    229  1.38.4.1   nathanw 	int sc_dynamicdevs;
    230       1.7   mycroft };
    231      1.26   thorpej 
    232      1.28       jtk #define		cf_iobase		cf_loc[ISACF_PORT]
    233      1.28       jtk #define		cf_iosize		cf_loc[ISACF_SIZE]
    234      1.28       jtk #define		cf_maddr		cf_loc[ISACF_IOMEM]
    235      1.28       jtk #define		cf_msize		cf_loc[ISACF_IOSIZ]
    236      1.28       jtk #define		cf_irq			cf_loc[ISACF_IRQ]
    237      1.28       jtk #define		cf_drq			cf_loc[ISACF_DRQ]
    238      1.29  augustss #define		cf_drq2			cf_loc[ISACF_DRQ2]
    239       1.7   mycroft 
    240       1.7   mycroft /*
    241      1.15       cgd  * ISA interrupt handler manipulation.
    242      1.15       cgd  *
    243      1.15       cgd  * To establish an ISA interrupt handler, a driver calls isa_intr_establish()
    244      1.15       cgd  * with the interrupt number, type, level, function, and function argument of
    245      1.15       cgd  * the interrupt it wants to handle.  Isa_intr_establish() returns an opaque
    246      1.35       leo  * handle to an event descriptor if it succeeds, and returns NULL on failure.
    247      1.35       leo  * (XXX: some drivers can't handle this, since the former behaviour was to
    248      1.35       leo  * invoke panic() on failure). When the system does not accept any of the
    249      1.35       leo  * interrupt types supported by the driver, the driver should fail the attach.
    250      1.35       leo  * Interrupt handlers should return 0 for "interrupt not for me", 1  for
    251      1.35       leo  * "I took care of it", or -1 for "I guess it was mine, but I wasn't
    252      1.35       leo  * expecting it."
    253      1.15       cgd  *
    254      1.15       cgd  * To remove an interrupt handler, the driver calls isa_intr_disestablish()
    255      1.15       cgd  * with the handle returned by isa_intr_establish() for that handler.
    256      1.38       cgd  *
    257      1.38       cgd  * The event counter (struct evcnt) associated with an interrupt line
    258      1.38       cgd  * (to be used as 'parent' for an ISA device's interrupt handler's evcnt)
    259      1.38       cgd  * can be obtained with isa_intr_evcnt().
    260      1.15       cgd  */
    261      1.15       cgd 
    262      1.15       cgd /* ISA interrupt sharing types */
    263      1.17   mycroft char	*isa_intr_typename __P((int type));
    264      1.26   thorpej 
    265      1.26   thorpej /*
    266      1.26   thorpej  * Some ISA devices (e.g. on a VLB) can perform 32-bit DMA.  This
    267      1.26   thorpej  * flag is passed to bus_dmamap_create() to indicate that fact.
    268      1.26   thorpej  */
    269      1.26   thorpej #define	ISABUS_DMA_32BIT	BUS_DMA_BUS1
    270      1.19       cgd 
    271      1.19       cgd #endif /* _DEV_ISA_ISAVAR_H_ */
    272