11a4290e7SDoug Rabson /*- 21a4290e7SDoug Rabson * Copyright (c) 1998 Doug Rabson 31a4290e7SDoug Rabson * All rights reserved. 41a4290e7SDoug Rabson * 51a4290e7SDoug Rabson * Redistribution and use in source and binary forms, with or without 61a4290e7SDoug Rabson * modification, are permitted provided that the following conditions 71a4290e7SDoug Rabson * are met: 81a4290e7SDoug Rabson * 1. Redistributions of source code must retain the above copyright 91a4290e7SDoug Rabson * notice, this list of conditions and the following disclaimer. 101a4290e7SDoug Rabson * 2. Redistributions in binary form must reproduce the above copyright 111a4290e7SDoug Rabson * notice, this list of conditions and the following disclaimer in the 121a4290e7SDoug Rabson * documentation and/or other materials provided with the distribution. 131a4290e7SDoug Rabson * 141a4290e7SDoug Rabson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 151a4290e7SDoug Rabson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 161a4290e7SDoug Rabson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 171a4290e7SDoug Rabson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 181a4290e7SDoug Rabson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 191a4290e7SDoug Rabson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 201a4290e7SDoug Rabson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 211a4290e7SDoug Rabson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 221a4290e7SDoug Rabson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 231a4290e7SDoug Rabson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 241a4290e7SDoug Rabson * SUCH DAMAGE. 251a4290e7SDoug Rabson * 26c3aac50fSPeter Wemm * $FreeBSD$ 271a4290e7SDoug Rabson */ 281a4290e7SDoug Rabson 29cfa84f46SDoug Rabson #ifndef _ISA_ISAVAR_H_ 30cfa84f46SDoug Rabson #define _ISA_ISAVAR_H_ 31cfa84f46SDoug Rabson 324249382dSDoug Rabson struct isa_config; 334249382dSDoug Rabson struct isa_pnp_id; 344249382dSDoug Rabson typedef void isa_config_cb(void *arg, struct isa_config *config, int enable); 354249382dSDoug Rabson 36a3be63b3SDoug Rabson #include "isa_if.h" 374249382dSDoug Rabson #include <isa/pnpvar.h> 38cfa84f46SDoug Rabson 39cfa84f46SDoug Rabson #ifdef KERNEL 40a3be63b3SDoug Rabson 41bea6af4dSDoug Rabson /* 42bea6af4dSDoug Rabson * ISA devices are partially ordered to ensure that devices which are 43bea6af4dSDoug Rabson * sensitive to other driver probe routines are probed first. Plug and 44bea6af4dSDoug Rabson * Play devices are added after devices with speculative probes so that 45bea6af4dSDoug Rabson * the legacy hardware can claim resources allowing the Plug and Play 46bea6af4dSDoug Rabson * hardware to choose different resources. 47bea6af4dSDoug Rabson */ 48bea6af4dSDoug Rabson #define ISA_ORDER_SENSITIVE 0 /* legacy sensitive hardware */ 49bea6af4dSDoug Rabson #define ISA_ORDER_SPECULATIVE 1 /* legacy non-sensitive hardware */ 50bea6af4dSDoug Rabson #define ISA_ORDER_PNP 2 /* plug-and-play hardware */ 51bea6af4dSDoug Rabson 52523df07bSPeter Wemm #define ISA_NPORT 8 53523df07bSPeter Wemm #define ISA_NMEM 4 54523df07bSPeter Wemm #define ISA_NIRQ 2 55523df07bSPeter Wemm #define ISA_NDRQ 2 5608b6a4cbSDoug Rabson 574249382dSDoug Rabson /* 584249382dSDoug Rabson * Plug and play cards can support a range of resource 594249382dSDoug Rabson * configurations. This structure is used by the isapnp parser to 604249382dSDoug Rabson * inform the isa bus about the resource possibilities of the 614249382dSDoug Rabson * device. Each different alternative should be supplied by calling 624249382dSDoug Rabson * ISA_ADD_CONFIG(). 634249382dSDoug Rabson */ 644249382dSDoug Rabson struct isa_range { 654249382dSDoug Rabson u_int32_t ir_start; 664249382dSDoug Rabson u_int32_t ir_end; 674249382dSDoug Rabson u_int32_t ir_size; 684249382dSDoug Rabson u_int32_t ir_align; 694249382dSDoug Rabson }; 704249382dSDoug Rabson 714249382dSDoug Rabson struct isa_config { 724249382dSDoug Rabson struct isa_range ic_mem[ISA_NMEM]; 734249382dSDoug Rabson struct isa_range ic_port[ISA_NPORT]; 744249382dSDoug Rabson u_int32_t ic_irqmask[ISA_NIRQ]; 754249382dSDoug Rabson u_int32_t ic_drqmask[ISA_NDRQ]; 764249382dSDoug Rabson int ic_nmem; 774249382dSDoug Rabson int ic_nport; 784249382dSDoug Rabson int ic_nirq; 794249382dSDoug Rabson int ic_ndrq; 804249382dSDoug Rabson }; 814249382dSDoug Rabson 824249382dSDoug Rabson /* 834249382dSDoug Rabson * Used to build lists of IDs and description strings for PnP drivers. 844249382dSDoug Rabson */ 854249382dSDoug Rabson struct isa_pnp_id { 864249382dSDoug Rabson u_int32_t ip_id; 874249382dSDoug Rabson const char *ip_desc; 884249382dSDoug Rabson }; 894249382dSDoug Rabson 901a4290e7SDoug Rabson enum isa_device_ivars { 911a4290e7SDoug Rabson ISA_IVAR_PORT, 9208b6a4cbSDoug Rabson ISA_IVAR_PORT_0 = ISA_IVAR_PORT, 9308b6a4cbSDoug Rabson ISA_IVAR_PORT_1, 941a4290e7SDoug Rabson ISA_IVAR_PORTSIZE, 9508b6a4cbSDoug Rabson ISA_IVAR_PORTSIZE_0 = ISA_IVAR_PORTSIZE, 9608b6a4cbSDoug Rabson ISA_IVAR_PORTSIZE_1, 9708b6a4cbSDoug Rabson ISA_IVAR_MADDR, 9808b6a4cbSDoug Rabson ISA_IVAR_MADDR_0 = ISA_IVAR_MADDR, 9908b6a4cbSDoug Rabson ISA_IVAR_MADDR_1, 10008b6a4cbSDoug Rabson ISA_IVAR_MSIZE, 10108b6a4cbSDoug Rabson ISA_IVAR_MSIZE_0 = ISA_IVAR_MSIZE, 10208b6a4cbSDoug Rabson ISA_IVAR_MSIZE_1, 1031a4290e7SDoug Rabson ISA_IVAR_FLAGS, 10408b6a4cbSDoug Rabson ISA_IVAR_IRQ, 10508b6a4cbSDoug Rabson ISA_IVAR_IRQ_0 = ISA_IVAR_IRQ, 10608b6a4cbSDoug Rabson ISA_IVAR_IRQ_1, 10708b6a4cbSDoug Rabson ISA_IVAR_DRQ, 10808b6a4cbSDoug Rabson ISA_IVAR_DRQ_0 = ISA_IVAR_DRQ, 109cfa84f46SDoug Rabson ISA_IVAR_DRQ_1, 110cfa84f46SDoug Rabson ISA_IVAR_VENDORID, 111cfa84f46SDoug Rabson ISA_IVAR_SERIAL, 112cfa84f46SDoug Rabson ISA_IVAR_LOGICALID, 113cfa84f46SDoug Rabson ISA_IVAR_COMPATID 1141a4290e7SDoug Rabson }; 1151a4290e7SDoug Rabson 1161a4290e7SDoug Rabson /* 1171a4290e7SDoug Rabson * Simplified accessors for isa devices 1181a4290e7SDoug Rabson */ 1191a4290e7SDoug Rabson #define ISA_ACCESSOR(A, B, T) \ 1201a4290e7SDoug Rabson \ 1211a4290e7SDoug Rabson static __inline T isa_get_ ## A(device_t dev) \ 1221a4290e7SDoug Rabson { \ 1236182fdbdSPeter Wemm uintptr_t v; \ 1241a4290e7SDoug Rabson BUS_READ_IVAR(device_get_parent(dev), dev, ISA_IVAR_ ## B, &v); \ 1251a4290e7SDoug Rabson return (T) v; \ 1261a4290e7SDoug Rabson } \ 1271a4290e7SDoug Rabson \ 1281a4290e7SDoug Rabson static __inline void isa_set_ ## A(device_t dev, T t) \ 1291a4290e7SDoug Rabson { \ 1301a4290e7SDoug Rabson u_long v = (u_long) t; \ 1311a4290e7SDoug Rabson BUS_WRITE_IVAR(device_get_parent(dev), dev, ISA_IVAR_ ## B, v); \ 1321a4290e7SDoug Rabson } 1331a4290e7SDoug Rabson 1341a4290e7SDoug Rabson ISA_ACCESSOR(port, PORT, int) 1351a4290e7SDoug Rabson ISA_ACCESSOR(portsize, PORTSIZE, int) 1361a4290e7SDoug Rabson ISA_ACCESSOR(irq, IRQ, int) 1376182fdbdSPeter Wemm ISA_ACCESSOR(drq, DRQ, int) 1386182fdbdSPeter Wemm ISA_ACCESSOR(maddr, MADDR, int) 1396182fdbdSPeter Wemm ISA_ACCESSOR(msize, MSIZE, int) 1406c2e3ddeSDoug Rabson ISA_ACCESSOR(flags, FLAGS, int) 141cfa84f46SDoug Rabson ISA_ACCESSOR(vendorid, VENDORID, int) 142cfa84f46SDoug Rabson ISA_ACCESSOR(serial, SERIAL, int) 143cfa84f46SDoug Rabson ISA_ACCESSOR(logicalid, LOGICALID, int) 144cfa84f46SDoug Rabson ISA_ACCESSOR(compatid, COMPATID, int) 145cfa84f46SDoug Rabson 1464249382dSDoug Rabson extern intrmask_t isa_irq_pending(void); 1474249382dSDoug Rabson extern intrmask_t isa_irq_mask(void); 1484249382dSDoug Rabson #ifdef __i386__ 1494249382dSDoug Rabson extern void isa_wrap_old_drivers(void); 1504249382dSDoug Rabson #endif 1514249382dSDoug Rabson extern void isa_probe_children(device_t dev); 1524249382dSDoug Rabson 1534249382dSDoug Rabson extern void isa_dmacascade __P((int chan)); 1544249382dSDoug Rabson extern void isa_dmadone __P((int flags, caddr_t addr, int nbytes, int chan)); 1554249382dSDoug Rabson extern void isa_dmainit __P((int chan, u_int bouncebufsize)); 1564249382dSDoug Rabson extern void isa_dmastart __P((int flags, caddr_t addr, u_int nbytes, int chan)); 1574249382dSDoug Rabson extern int isa_dma_acquire __P((int chan)); 1584249382dSDoug Rabson extern void isa_dma_release __P((int chan)); 1594249382dSDoug Rabson extern int isa_dmastatus __P((int chan)); 1604249382dSDoug Rabson extern int isa_dmastop __P((int chan)); 161cfa84f46SDoug Rabson 162cfa84f46SDoug Rabson #endif /* KERNEL */ 163cfa84f46SDoug Rabson 164cfa84f46SDoug Rabson #endif /* !_ISA_ISAVAR_H_ */ 165