Home | History | Annotate | Line # | Download | only in pci
pcivar.h revision 1.30
      1 /*	$NetBSD: pcivar.h,v 1.30 1998/05/15 12:35:06 tsubai Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
      5  * Copyright (c) 1994 Charles Hannum.  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 Charles Hannum.
     18  * 4. The name of the author may not be used to endorse or promote products
     19  *    derived from this software without specific prior written permission.
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  */
     32 
     33 #ifndef _DEV_PCI_PCIVAR_H_
     34 #define	_DEV_PCI_PCIVAR_H_
     35 
     36 /*
     37  * Definitions for PCI autoconfiguration.
     38  *
     39  * This file describes types and functions which are used for PCI
     40  * configuration.  Some of this information is machine-specific, and is
     41  * provided by pci_machdep.h.
     42  */
     43 
     44 #include <machine/bus.h>
     45 #include <dev/pci/pcireg.h>
     46 
     47 /*
     48  * Structures and definitions needed by the machine-dependent header.
     49  */
     50 typedef u_int32_t pcireg_t;		/* configuration space register XXX */
     51 struct pcibus_attach_args;
     52 
     53 /*
     54  * Machine-dependent definitions.
     55  */
     56 #if (alpha + atari + bebox + i386 + macppc != 1)
     57 ERROR: COMPILING FOR UNSUPPORTED MACHINE, OR MORE THAN ONE.
     58 #endif
     59 #if alpha
     60 #include <alpha/pci/pci_machdep.h>
     61 #endif
     62 #if atari
     63 #include <atari/pci/pci_machdep.h>
     64 #endif
     65 #if bebox
     66 #include <bebox/pci/pci_machdep.h>
     67 #endif
     68 #if i386
     69 #include <i386/pci/pci_machdep.h>
     70 #endif
     71 #if macppc
     72 #include <macppc/pci/pci_machdep.h>
     73 #endif
     74 
     75 /*
     76  * PCI bus attach arguments.
     77  */
     78 struct pcibus_attach_args {
     79 	char		*pba_busname;	/* XXX should be common */
     80 	bus_space_tag_t pba_iot;	/* pci i/o space tag */
     81 	bus_space_tag_t pba_memt;	/* pci mem space tag */
     82 	bus_dma_tag_t pba_dmat;		/* DMA tag */
     83 	pci_chipset_tag_t pba_pc;
     84 	int		pba_flags;	/* flags; see below */
     85 
     86 	int		pba_bus;	/* PCI bus number */
     87 
     88 	/*
     89 	 * Interrupt swizzling information.  These fields
     90 	 * are only used by secondary busses.
     91 	 */
     92 	u_int		pba_intrswiz;	/* how to swizzle pins */
     93 	pcitag_t	pba_intrtag;	/* intr. appears to come from here */
     94 };
     95 
     96 /*
     97  * PCI device attach arguments.
     98  */
     99 struct pci_attach_args {
    100 	bus_space_tag_t pa_iot;		/* pci i/o space tag */
    101 	bus_space_tag_t pa_memt;	/* pci mem space tag */
    102 	bus_dma_tag_t pa_dmat;		/* DMA tag */
    103 	pci_chipset_tag_t pa_pc;
    104 	int		pa_flags;	/* flags; see below */
    105 
    106 	u_int		pa_device;
    107 	u_int		pa_function;
    108 	pcitag_t	pa_tag;
    109 	pcireg_t	pa_id, pa_class;
    110 
    111 	/*
    112 	 * Interrupt information.
    113 	 *
    114 	 * "Intrline" is used on systems whose firmware puts
    115 	 * the right routing data into the line register in
    116 	 * configuration space.  The rest are used on systems
    117 	 * that do not.
    118 	 */
    119 	u_int		pa_intrswiz;	/* how to swizzle pins if ppb */
    120 	pcitag_t	pa_intrtag;	/* intr. appears to come from here */
    121 	pci_intr_pin_t	pa_intrpin;	/* intr. appears on this pin */
    122 	pci_intr_line_t	pa_intrline;	/* intr. routing information */
    123 };
    124 
    125 /*
    126  * Flags given in the bus and device attachment args.
    127  */
    128 #define	PCI_FLAGS_IO_ENABLED	0x01		/* I/O space is enabled */
    129 #define	PCI_FLAGS_MEM_ENABLED	0x02		/* memory space is enabled */
    130 
    131 #include "locators.h"
    132 
    133 /*
    134  * Locators devices that attach to 'pcibus', as specified to config.
    135  */
    136 #define	pcibuscf_bus		cf_loc[PCIBUSCF_BUS]
    137 #define	PCIBUS_UNK_BUS		PCIBUSCF_BUS_DEFAULT	/* wildcarded 'bus' */
    138 
    139 /*
    140  * Locators for PCI devices, as specified to config.
    141  */
    142 #define	pcicf_dev		cf_loc[PCICF_DEV]
    143 #define	PCI_UNK_DEV		PCICF_DEV_DEFAULT	/* wildcarded 'dev' */
    144 
    145 #define	pcicf_function		cf_loc[PCICF_FUNCTION]
    146 #define	PCI_UNK_FUNCTION	PCICF_FUNCTION_DEFAULT /* wildcarded 'function' */
    147 
    148 /*
    149  * Configuration space access and utility functions.  (Note that most,
    150  * e.g. make_tag, conf_read, conf_write are declared by pci_machdep.h.)
    151  */
    152 int	pci_mapreg_info __P((pci_chipset_tag_t, pcitag_t, int, pcireg_t,
    153 	    bus_addr_t *, bus_size_t *, int *));
    154 int	pci_mapreg_map __P((struct pci_attach_args *, int, pcireg_t, int,
    155 	    bus_space_tag_t *, bus_space_handle_t *, bus_addr_t *,
    156 	    bus_size_t *));
    157 
    158 /*
    159  * Helper functions for autoconfiguration.
    160  */
    161 void	pci_devinfo __P((pcireg_t, pcireg_t, int, char *));
    162 void	pci_conf_print __P((pci_chipset_tag_t, pcitag_t));
    163 void	set_pci_isa_bridge_callback __P((void (*)(void *), void *));
    164 
    165 #endif /* _DEV_PCI_PCIVAR_H_ */
    166