Home | History | Annotate | Line # | Download | only in isa
      1 /*	$NetBSD: isavar.h,v 1.57 2025/10/20 15:35:47 thorpej Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1997, 2001 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 Wasabi Systems, Inc.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 /*
     33  * Copyright (c) 1995 Chris G. Demetriou
     34  * Copyright (c) 1992 Berkeley Software Design, Inc.
     35  * All rights reserved.
     36  *
     37  * Redistribution and use in source and binary forms, with or without
     38  * modification, are permitted provided that the following conditions
     39  * are met:
     40  * 1. Redistributions of source code must retain the above copyright
     41  *    notice, this list of conditions and the following disclaimer.
     42  * 2. Redistributions in binary form must reproduce the above copyright
     43  *    notice, this list of conditions and the following disclaimer in the
     44  *    documentation and/or other materials provided with the distribution.
     45  * 3. All advertising materials mentioning features or use of this software
     46  *    must display the following acknowledgement:
     47  *	This product includes software developed by Berkeley Software
     48  *	Design, Inc.
     49  * 4. The name of Berkeley Software Design must not be used to endorse
     50  *    or promote products derived from this software without specific
     51  *    prior written permission.
     52  *
     53  * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN, INC. ``AS IS'' AND
     54  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     55  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     56  * ARE DISCLAIMED.  IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN, INC. BE LIABLE
     57  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     58  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     59  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     60  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     61  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     62  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     63  * SUCH DAMAGE.
     64  *
     65  *	BSDI Id: isavar.h,v 1.5 1992/12/01 18:06:00 karels Exp
     66  */
     67 
     68 #ifndef _DEV_ISA_ISAVAR_H_
     69 #define	_DEV_ISA_ISAVAR_H_
     70 
     71 /*
     72  * Definitions for ISA autoconfiguration.
     73  */
     74 
     75 #include <sys/param.h>
     76 #include <sys/device.h>
     77 #include <sys/errno.h>
     78 #include <sys/queue.h>
     79 #include <sys/bus.h>
     80 
     81 /*
     82  * Structures and definitions needed by the machine-dependent header.
     83  */
     84 struct isabus_attach_args;
     85 
     86 #include <machine/isa_machdep.h>
     87 
     88 /*
     89  * ISA bus attach arguments
     90  */
     91 struct isabus_attach_args {
     92 	const char *_iba_busname;	/* XXX placeholder */
     93 	bus_space_tag_t iba_iot;	/* isa i/o space tag */
     94 	bus_space_tag_t iba_memt;	/* isa mem space tag */
     95 	bus_dma_tag_t iba_dmat;		/* isa DMA tag */
     96 	isa_chipset_tag_t iba_ic;
     97 };
     98 
     99 int	isabusprint(void *, const char *);
    100 
    101 static inline device_t
    102 isabus_attach(device_t dev, struct isabus_attach_args *iba)
    103 {
    104 	return config_found(dev, iba, isabusprint,
    105 	    CFARGS(.iattr = "isabus",
    106 		   .devhandle = device_handle(dev)));
    107 }
    108 
    109 /*
    110  * ISA bus resources.
    111  */
    112 
    113 struct isa_io {
    114 	int ir_addr;
    115 	int ir_size;
    116 };
    117 
    118 struct isa_iomem {
    119 	int ir_addr;
    120 	int ir_size;
    121 };
    122 
    123 struct isa_irq {
    124 	int ir_irq;
    125 };
    126 
    127 struct isa_drq {
    128 	int ir_drq;
    129 };
    130 
    131 struct isa_pnpname {
    132 	struct isa_pnpname *ipn_next;
    133 	char *ipn_name;
    134 };
    135 
    136 /*
    137  * ISA driver attach arguments
    138  */
    139 struct isa_attach_args {
    140 	bus_space_tag_t ia_iot;		/* isa i/o space tag */
    141 	bus_space_tag_t ia_memt;	/* isa mem space tag */
    142 	bus_dma_tag_t ia_dmat;		/* DMA tag */
    143 
    144 	isa_chipset_tag_t ia_ic;
    145 
    146 	/*
    147 	 * PNP (or other) names to with which we can match a device
    148 	 * driver to a device that machine-dependent code tells us
    149 	 * is there (i.e. support for direct-configuration of ISA
    150 	 * devices).
    151 	 */
    152 	char *ia_pnpname;
    153 	struct isa_pnpname *ia_pnpcompatnames;
    154 
    155 	struct isa_io *ia_io;		/* I/O resources */
    156 	int ia_nio;
    157 
    158 	struct isa_iomem *ia_iomem;	/* memory resources */
    159 	int ia_niomem;
    160 
    161 	struct isa_irq *ia_irq;		/* IRQ resources */
    162 	int ia_nirq;
    163 
    164 	struct isa_drq *ia_drq;		/* DRQ resources */
    165 	int ia_ndrq;
    166 
    167 	void	*ia_aux;		/* driver specific */
    168 };
    169 
    170 /*
    171  * Test to determine if a given call to an ISA device probe routine
    172  * is actually an attempt to do direct configuration.
    173  */
    174 #define	ISA_DIRECT_CONFIG(ia)						\
    175 	((ia)->ia_pnpname != NULL || (ia)->ia_pnpcompatnames != NULL)
    176 
    177 /*
    178  * ISA master bus
    179  */
    180 struct isa_softc {
    181 	device_t sc_dev;		/* base device */
    182 
    183 	bus_space_tag_t sc_iot;		/* isa io space tag */
    184 	bus_space_tag_t sc_memt;	/* isa mem space tag */
    185 	bus_dma_tag_t sc_dmat;		/* isa DMA tag */
    186 
    187 	isa_chipset_tag_t sc_ic;
    188 };
    189 
    190 /*
    191  * These must be in sync with the ISACF_XXX_DEFAULT definitions
    192  * in "locators.h" (generated from files.isa).
    193  * (not including "locators.h" here to avoid dependency)
    194  */
    195 #define ISA_UNKNOWN_PORT	(-1)
    196 #define ISA_UNKNOWN_IOMEM	(-1)
    197 #define ISA_UNKNOWN_IOSIZ	(0)
    198 #define ISA_UNKNOWN_IRQ		(-1)
    199 #define ISA_UNKNOWN_DRQ		(-1)
    200 #define ISA_UNKNOWN_DRQ2	(-1)
    201 
    202 /*
    203  * ISA interrupt handler manipulation.
    204  *
    205  * To establish an ISA interrupt handler, a driver calls isa_intr_establish()
    206  * with the interrupt number, type, level, function, and function argument of
    207  * the interrupt it wants to handle.  Isa_intr_establish() returns an opaque
    208  * handle to an event descriptor if it succeeds, and returns NULL on failure.
    209  * (XXX: some drivers can't handle this, since the former behaviour was to
    210  * invoke panic() on failure). When the system does not accept any of the
    211  * interrupt types supported by the driver, the driver should fail the attach.
    212  * Interrupt handlers should return 0 for "interrupt not for me", 1  for
    213  * "I took care of it", or -1 for "I guess it was mine, but I wasn't
    214  * expecting it."
    215  *
    216  * To remove an interrupt handler, the driver calls isa_intr_disestablish()
    217  * with the handle returned by isa_intr_establish() for that handler.
    218  *
    219  * The event counter (struct evcnt) associated with an interrupt line
    220  * (to be used as 'parent' for an ISA device's interrupt handler's evcnt)
    221  * can be obtained with isa_intr_evcnt().
    222  */
    223 
    224 /* ISA interrupt sharing types */
    225 const char	*isa_intr_typename(int);
    226 
    227 /*
    228  * Some ISA devices (e.g. on a VLB) can perform 32-bit DMA.  This
    229  * flag is passed to bus_dmamap_create() to indicate that fact.
    230  */
    231 #define	ISABUS_DMA_32BIT	BUS_DMA_BUS1
    232 
    233 /*
    234  * This flag indicates that the DMA channel should not yet be reserved,
    235  * even if BUS_DMA_ALLOCNOW is specified.
    236  */
    237 #define ISABUS_DMA_DEFERCHAN	BUS_DMA_BUS2
    238 
    239 void	isa_set_slotcount(int);
    240 int	isa_get_slotcount(void);
    241 
    242 #endif /* _DEV_ISA_ISAVAR_H_ */
    243