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