1 /* $NetBSD: isavar.h,v 1.54 2025/10/17 16:56:00 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/queue.h> 76 #include <sys/bus.h> 77 78 /* 79 * Structures and definitions needed by the machine-dependent header. 80 */ 81 struct isabus_attach_args; 82 83 #include <machine/isa_machdep.h> 84 85 /* 86 * ISA bus attach arguments 87 */ 88 struct isabus_attach_args { 89 const char *_iba_busname; /* XXX placeholder */ 90 bus_space_tag_t iba_iot; /* isa i/o space tag */ 91 bus_space_tag_t iba_memt; /* isa mem space tag */ 92 bus_dma_tag_t iba_dmat; /* isa DMA tag */ 93 isa_chipset_tag_t iba_ic; 94 }; 95 96 /* 97 * ISA bus resources. 98 */ 99 100 struct isa_io { 101 int ir_addr; 102 int ir_size; 103 }; 104 105 struct isa_iomem { 106 int ir_addr; 107 int ir_size; 108 }; 109 110 struct isa_irq { 111 int ir_irq; 112 }; 113 114 struct isa_drq { 115 int ir_drq; 116 }; 117 118 struct isa_pnpname { 119 struct isa_pnpname *ipn_next; 120 char *ipn_name; 121 }; 122 123 /* 124 * ISA driver attach arguments 125 */ 126 struct isa_attach_args { 127 bus_space_tag_t ia_iot; /* isa i/o space tag */ 128 bus_space_tag_t ia_memt; /* isa mem space tag */ 129 bus_dma_tag_t ia_dmat; /* DMA tag */ 130 131 isa_chipset_tag_t ia_ic; 132 133 /* 134 * PNP (or other) names to with which we can match a device 135 * driver to a device that machine-dependent code tells us 136 * is there (i.e. support for direct-configuration of ISA 137 * devices). 138 */ 139 char *ia_pnpname; 140 struct isa_pnpname *ia_pnpcompatnames; 141 142 struct isa_io *ia_io; /* I/O resources */ 143 int ia_nio; 144 145 struct isa_iomem *ia_iomem; /* memory resources */ 146 int ia_niomem; 147 148 struct isa_irq *ia_irq; /* IRQ resources */ 149 int ia_nirq; 150 151 struct isa_drq *ia_drq; /* DRQ resources */ 152 int ia_ndrq; 153 154 void *ia_aux; /* driver specific */ 155 }; 156 157 /* 158 * Test to determine if a given call to an ISA device probe routine 159 * is actually an attempt to do direct configuration. 160 */ 161 #define ISA_DIRECT_CONFIG(ia) \ 162 ((ia)->ia_pnpname != NULL || (ia)->ia_pnpcompatnames != NULL) 163 164 /* 165 * ISA master bus 166 */ 167 struct isa_softc { 168 device_t sc_dev; /* base device */ 169 170 bus_space_tag_t sc_iot; /* isa io space tag */ 171 bus_space_tag_t sc_memt; /* isa mem space tag */ 172 bus_dma_tag_t sc_dmat; /* isa DMA tag */ 173 174 isa_chipset_tag_t sc_ic; 175 }; 176 177 /* 178 * These must be in sync with the ISACF_XXX_DEFAULT definitions 179 * in "locators.h" (generated from files.isa). 180 * (not including "locators.h" here to avoid dependency) 181 */ 182 #define ISA_UNKNOWN_PORT (-1) 183 #define ISA_UNKNOWN_IOMEM (-1) 184 #define ISA_UNKNOWN_IOSIZ (0) 185 #define ISA_UNKNOWN_IRQ (-1) 186 #define ISA_UNKNOWN_DRQ (-1) 187 #define ISA_UNKNOWN_DRQ2 (-1) 188 189 int isabusprint(void *, const char *); 190 191 /* 192 * ISA interrupt handler manipulation. 193 * 194 * To establish an ISA interrupt handler, a driver calls isa_intr_establish() 195 * with the interrupt number, type, level, function, and function argument of 196 * the interrupt it wants to handle. Isa_intr_establish() returns an opaque 197 * handle to an event descriptor if it succeeds, and returns NULL on failure. 198 * (XXX: some drivers can't handle this, since the former behaviour was to 199 * invoke panic() on failure). When the system does not accept any of the 200 * interrupt types supported by the driver, the driver should fail the attach. 201 * Interrupt handlers should return 0 for "interrupt not for me", 1 for 202 * "I took care of it", or -1 for "I guess it was mine, but I wasn't 203 * expecting it." 204 * 205 * To remove an interrupt handler, the driver calls isa_intr_disestablish() 206 * with the handle returned by isa_intr_establish() for that handler. 207 * 208 * The event counter (struct evcnt) associated with an interrupt line 209 * (to be used as 'parent' for an ISA device's interrupt handler's evcnt) 210 * can be obtained with isa_intr_evcnt(). 211 */ 212 213 /* ISA interrupt sharing types */ 214 const char *isa_intr_typename(int); 215 216 /* 217 * Some ISA devices (e.g. on a VLB) can perform 32-bit DMA. This 218 * flag is passed to bus_dmamap_create() to indicate that fact. 219 */ 220 #define ISABUS_DMA_32BIT BUS_DMA_BUS1 221 222 /* 223 * This flag indicates that the DMA channel should not yet be reserved, 224 * even if BUS_DMA_ALLOCNOW is specified. 225 */ 226 #define ISABUS_DMA_DEFERCHAN BUS_DMA_BUS2 227 228 void isa_set_slotcount(int); 229 int isa_get_slotcount(void); 230 231 #endif /* _DEV_ISA_ISAVAR_H_ */ 232