Annotation of sys/dev/pci/pcivar.h, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: pcivar.h,v 1.54 2007/08/01 21:43:03 deraadt Exp $ */
! 2: /* $NetBSD: pcivar.h,v 1.23 1997/06/06 23:48:05 thorpej Exp $ */
! 3:
! 4: /*
! 5: * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
! 6: * Copyright (c) 1994 Charles Hannum. All rights reserved.
! 7: *
! 8: * Redistribution and use in source and binary forms, with or without
! 9: * modification, are permitted provided that the following conditions
! 10: * are met:
! 11: * 1. Redistributions of source code must retain the above copyright
! 12: * notice, this list of conditions and the following disclaimer.
! 13: * 2. Redistributions in binary form must reproduce the above copyright
! 14: * notice, this list of conditions and the following disclaimer in the
! 15: * documentation and/or other materials provided with the distribution.
! 16: * 3. All advertising materials mentioning features or use of this software
! 17: * must display the following acknowledgement:
! 18: * This product includes software developed by Charles Hannum.
! 19: * 4. The name of the author may not be used to endorse or promote products
! 20: * derived from this software without specific prior written permission.
! 21: *
! 22: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
! 23: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
! 24: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
! 25: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
! 26: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
! 27: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
! 28: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
! 29: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! 30: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
! 31: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! 32: */
! 33:
! 34: #ifndef _DEV_PCI_PCIVAR_H_
! 35: #define _DEV_PCI_PCIVAR_H_
! 36:
! 37: /*
! 38: * Definitions for PCI autoconfiguration.
! 39: *
! 40: * This file describes types and functions which are used for PCI
! 41: * configuration. Some of this information is machine-specific, and is
! 42: * provided by pci_machdep.h.
! 43: */
! 44:
! 45: #include <sys/device.h>
! 46: #include <machine/bus.h>
! 47: #include <dev/pci/pcireg.h>
! 48:
! 49: /*
! 50: * Structures and definitions needed by the machine-dependent header.
! 51: */
! 52: typedef u_int32_t pcireg_t; /* configuration space register XXX */
! 53:
! 54: /*
! 55: * Power Management (PCI 2.2)
! 56: */
! 57: #define PCI_PWR_D0 0
! 58: #define PCI_PWR_D1 1
! 59: #define PCI_PWR_D2 2
! 60: #define PCI_PWR_D3 3
! 61:
! 62: #ifdef _KERNEL
! 63:
! 64: struct pcibus_attach_args;
! 65: struct pci_softc;
! 66:
! 67: /*
! 68: * Machine-dependent definitions.
! 69: */
! 70: #if defined(__alpha__)
! 71: #include <alpha/pci/pci_machdep.h>
! 72: #elif defined(__i386__)
! 73: #include <i386/pci/pci_machdep.h>
! 74: #elif defined(__powerpc__)
! 75: #include <powerpc/pci/pci_machdep.h>
! 76: #elif defined(__sgi__)
! 77: #include <sgi/pci/pci_machdep.h>
! 78: #else
! 79: #include <machine/pci_machdep.h>
! 80: #endif
! 81:
! 82: /*
! 83: * PCI bus attach arguments.
! 84: */
! 85: struct pcibus_attach_args {
! 86: char *pba_busname; /* XXX should be common */
! 87: bus_space_tag_t pba_iot; /* pci i/o space tag */
! 88: bus_space_tag_t pba_memt; /* pci mem space tag */
! 89: bus_dma_tag_t pba_dmat; /* DMA tag */
! 90: pci_chipset_tag_t pba_pc;
! 91:
! 92: int pba_domain; /* PCI domain */
! 93: int pba_bus; /* PCI bus number */
! 94:
! 95: /*
! 96: * Pointer to the pcitag of our parent bridge. If there is no
! 97: * parent bridge, then we assume we are a root bus.
! 98: */
! 99: pcitag_t *pba_bridgetag;
! 100: pci_intr_handle_t *pba_bridgeih;
! 101:
! 102: /*
! 103: * Interrupt swizzling information. These fields
! 104: * are only used by secondary busses.
! 105: */
! 106: u_int pba_intrswiz; /* how to swizzle pins */
! 107: pcitag_t pba_intrtag; /* intr. appears to come from here */
! 108: };
! 109:
! 110: /*
! 111: * PCI device attach arguments.
! 112: */
! 113: struct pci_attach_args {
! 114: bus_space_tag_t pa_iot; /* pci i/o space tag */
! 115: bus_space_tag_t pa_memt; /* pci mem space tag */
! 116: bus_dma_tag_t pa_dmat; /* DMA tag */
! 117: pci_chipset_tag_t pa_pc;
! 118: int pa_flags; /* flags; see below */
! 119:
! 120: u_int pa_domain;
! 121: u_int pa_bus;
! 122: u_int pa_device;
! 123: u_int pa_function;
! 124: pcitag_t pa_tag;
! 125: pcireg_t pa_id, pa_class;
! 126:
! 127: pcitag_t *pa_bridgetag;
! 128: pci_intr_handle_t *pa_bridgeih;
! 129:
! 130: /*
! 131: * Interrupt information.
! 132: *
! 133: * "Intrline" is used on systems whose firmware puts
! 134: * the right routing data into the line register in
! 135: * configuration space. The rest are used on systems
! 136: * that do not.
! 137: */
! 138: u_int pa_intrswiz; /* how to swizzle pins if ppb */
! 139: pcitag_t pa_intrtag; /* intr. appears to come from here */
! 140: pci_intr_pin_t pa_intrpin; /* intr. appears on this pin */
! 141: pci_intr_line_t pa_intrline; /* intr. routing information */
! 142: pci_intr_pin_t pa_rawintrpin; /* unswizzled pin */
! 143: };
! 144:
! 145: /*
! 146: * Flags given in the bus and device attachment args.
! 147: *
! 148: * OpenBSD doesn't actually use them yet -- csapuntz@cvs.openbsd.org
! 149: */
! 150: #define PCI_FLAGS_IO_ENABLED 0x01 /* I/O space is enabled */
! 151: #define PCI_FLAGS_MEM_ENABLED 0x02 /* memory space is enabled */
! 152: #define PCI_FLAGS_MRL_OKAY 0x04 /* Memory Read Line okay */
! 153: #define PCI_FLAGS_MRM_OKAY 0x08 /* Memory Read Multiple okay */
! 154: #define PCI_FLAGS_MWI_OKAY 0x10 /* Memory Write and Invalidate
! 155: okay */
! 156:
! 157: /*
! 158: *
! 159: */
! 160: struct pci_quirkdata {
! 161: pci_vendor_id_t vendor; /* Vendor ID */
! 162: pci_product_id_t product; /* Product ID */
! 163: int quirks; /* quirks; see below */
! 164: };
! 165: #define PCI_QUIRK_MULTIFUNCTION 1
! 166: #define PCI_QUIRK_MONOFUNCTION 2
! 167:
! 168: struct pci_softc {
! 169: struct device sc_dev;
! 170: bus_space_tag_t sc_iot, sc_memt;
! 171: bus_dma_tag_t sc_dmat;
! 172: pci_chipset_tag_t sc_pc;
! 173: void *sc_powerhook;
! 174: LIST_HEAD(, pci_dev) sc_devs;
! 175: int sc_domain, sc_bus, sc_maxndevs;
! 176: pcitag_t *sc_bridgetag;
! 177: pci_intr_handle_t *sc_bridgeih;
! 178: u_int sc_intrswiz;
! 179: pcitag_t sc_intrtag;
! 180: };
! 181:
! 182: extern int pci_ndomains;
! 183:
! 184: /*
! 185: * Locators devices that attach to 'pcibus', as specified to config.
! 186: */
! 187: #define pcibuscf_bus cf_loc[0]
! 188: #define PCIBUS_UNK_BUS -1 /* wildcarded 'bus' */
! 189:
! 190: /*
! 191: * Locators for PCI devices, as specified to config.
! 192: */
! 193: #define pcicf_dev cf_loc[0]
! 194: #define PCI_UNK_DEV -1 /* wildcarded 'dev' */
! 195:
! 196: #define pcicf_function cf_loc[1]
! 197: #define PCI_UNK_FUNCTION -1 /* wildcarded 'function' */
! 198:
! 199: /*
! 200: * Configuration space access and utility functions. (Note that most,
! 201: * e.g. make_tag, conf_read, conf_write are declared by pci_machdep.h.)
! 202: */
! 203: int pci_mapreg_probe(pci_chipset_tag_t, pcitag_t, int, pcireg_t *);
! 204: pcireg_t pci_mapreg_type(pci_chipset_tag_t, pcitag_t, int);
! 205: int pci_mapreg_info(pci_chipset_tag_t, pcitag_t, int, pcireg_t,
! 206: bus_addr_t *, bus_size_t *, int *);
! 207: int pci_mapreg_map(struct pci_attach_args *, int, pcireg_t, int,
! 208: bus_space_tag_t *, bus_space_handle_t *, bus_addr_t *,
! 209: bus_size_t *, bus_size_t);
! 210:
! 211:
! 212: int pci_io_find(pci_chipset_tag_t, pcitag_t, int, bus_addr_t *,
! 213: bus_size_t *);
! 214: int pci_mem_find(pci_chipset_tag_t, pcitag_t, int, bus_addr_t *,
! 215: bus_size_t *, int *);
! 216:
! 217: int pci_get_capability(pci_chipset_tag_t, pcitag_t, int,
! 218: int *, pcireg_t *);
! 219:
! 220: struct pci_matchid {
! 221: pci_vendor_id_t pm_vid;
! 222: pci_product_id_t pm_pid;
! 223: };
! 224:
! 225: int pci_matchbyid(struct pci_attach_args *, const struct pci_matchid *, int);
! 226:
! 227: /*
! 228: * Helper functions for autoconfiguration.
! 229: */
! 230: const char *pci_findvendor(pcireg_t);
! 231: const char *pci_findproduct(pcireg_t);
! 232: int pci_find_device(struct pci_attach_args *pa,
! 233: int (*match)(struct pci_attach_args *));
! 234: int pci_probe_device(struct pci_softc *, pcitag_t tag,
! 235: int (*)(struct pci_attach_args *), struct pci_attach_args *);
! 236: void pci_devinfo(pcireg_t, pcireg_t, int, char *, size_t);
! 237: const struct pci_quirkdata *
! 238: pci_lookup_quirkdata(pci_vendor_id_t, pci_product_id_t);
! 239: void pciagp_set_pchb(struct pci_attach_args *);
! 240:
! 241: #endif /* _KERNEL */
! 242: #endif /* _DEV_PCI_PCIVAR_H_ */
CVSweb