Home | History | Annotate | Line # | Download | only in isa
isavar.h revision 1.11
      1 /*	$NetBSD: isavar.h,v 1.11 1994/10/27 04:17:50 cgd Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1992 Berkeley Software Design, Inc.
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *	This product includes software developed by Berkeley Software
     18  *	Design, Inc.
     19  * 4. The name of Berkeley Software Design must not be used to endorse
     20  *    or promote products derived from this software without specific
     21  *    prior written permission.
     22  *
     23  * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN, INC. ``AS IS'' AND
     24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  * ARE DISCLAIMED.  IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN, INC. BE LIABLE
     27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  * SUCH DAMAGE.
     34  *
     35  *	BSDI Id: isavar.h,v 1.5 1992/12/01 18:06:00 karels Exp
     36  */
     37 
     38 /*
     39  * ISA driver attach arguments
     40  */
     41 struct isa_attach_args {
     42 	u_short	ia_iobase;		/* base i/o address */
     43 	u_short	ia_iosize;		/* span of ports used */
     44 	u_short	ia_irq;			/* interrupt request */
     45 	u_short	ia_drq;			/* DMA request */
     46 	caddr_t ia_maddr;		/* physical i/o mem addr */
     47 	u_int	ia_msize;		/* size of i/o memory */
     48 	void	*ia_aux;		/* driver specific */
     49 };
     50 
     51 #define	IOBASEUNK	0xffff		/* i/o address is unknown */
     52 #define	IRQUNK		0xffff		/* interrupt request line is unknown */
     53 #define	DRQUNK		0xffff		/* DMA request line is unknown */
     54 #define	MADDRUNK	(caddr_t)-1	/* shared memory address is unknown */
     55 
     56 /*
     57  * per-device ISA variables
     58  */
     59 struct isadev {
     60 	struct  device *id_dev;		/* back pointer to generic */
     61 	struct	isadev *id_bchain;	/* forward link in bus chain */
     62 };
     63 
     64 /*
     65  * ISA masterbus
     66  */
     67 struct isa_softc {
     68 	struct	device sc_dev;		/* base device */
     69 	struct	isadev *sc_isadev;	/* list of all children */
     70 };
     71 
     72 #define		cf_iobase		cf_loc[0]
     73 #define		cf_iosize		cf_loc[1]
     74 #define		cf_maddr		cf_loc[2]
     75 #define		cf_msize		cf_loc[3]
     76 #define		cf_irq			cf_loc[4]
     77 #define		cf_drq			cf_loc[5]
     78 
     79 /*
     80  * Interrupt handler chains.  Interrupt handlers should return 0 for
     81  * `not I', 1 (`I took care of it'), or -1 (`I guess it was mine, but
     82  * I wasn't expecting it').  intr_establish() inserts a handler into
     83  * the list.  The handler is called with its (single) argument.
     84  */
     85 struct intrhand {
     86 	int	(*ih_fun)();
     87 	void	*ih_arg;
     88 	u_long	ih_count;
     89 	struct	intrhand *ih_next;
     90 	int	ih_level;
     91 };
     92 
     93 void intr_establish __P((int intr, struct intrhand *));
     94 void intr_disestablish __P((int intr, struct intrhand *));
     95 void isa_establish __P((struct isadev *, struct device *));
     96 
     97 /*
     98  * software conventions
     99  */
    100 typedef enum { BUS_ISA, BUS_EISA, BUS_MCA } isa_type;
    101 
    102 extern int atdevbase;		/* kernel virtual address of "hole" */
    103 extern isa_type isa_bustype;	/* type of bus */
    104 
    105 /*
    106  * Given a kernel virtual address for some location
    107  * in the "hole" I/O space, return a physical address.
    108  */
    109 #define	ISA_PHYSADDR(v)	((caddr_t) ((u_long)(v) - atdevbase + IOM_BEGIN))
    110 /*
    111  * Given a physical address in the "hole",
    112  * return a kernel virtual address.
    113  */
    114 #define	ISA_HOLE_VADDR(p)  ((caddr_t) ((u_long)(p) - IOM_BEGIN + atdevbase))
    115