pci_machdep.h revision 1.11
11.11Sbouyer/* $NetBSD: pci_machdep.h,v 1.11 2009/02/13 21:03:59 bouyer Exp $ */ 21.2Sbouyer 31.2Sbouyer/* 41.6Sbouyer * Copyright (c) 2006 Manuel Bouyer. 51.2Sbouyer * 61.2Sbouyer * Redistribution and use in source and binary forms, with or without 71.2Sbouyer * modification, are permitted provided that the following conditions 81.2Sbouyer * are met: 91.2Sbouyer * 1. Redistributions of source code must retain the above copyright 101.2Sbouyer * notice, this list of conditions and the following disclaimer. 111.2Sbouyer * 2. Redistributions in binary form must reproduce the above copyright 121.2Sbouyer * notice, this list of conditions and the following disclaimer in the 131.2Sbouyer * documentation and/or other materials provided with the distribution. 141.2Sbouyer * 3. All advertising materials mentioning features or use of this software 151.2Sbouyer * must display the following acknowledgement: 161.2Sbouyer * This product includes software developed by Manuel Bouyer. 171.2Sbouyer * 4. The name of the author may not be used to endorse or promote products 181.2Sbouyer * derived from this software without specific prior written permission. 191.2Sbouyer * 201.2Sbouyer * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 211.2Sbouyer * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 221.2Sbouyer * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 231.2Sbouyer * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 241.2Sbouyer * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 251.2Sbouyer * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 261.2Sbouyer * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 271.2Sbouyer * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 281.2Sbouyer * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 291.2Sbouyer * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 301.2Sbouyer * 311.2Sbouyer */ 321.2Sbouyer 331.6Sbouyer/* 341.6Sbouyer * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. 351.6Sbouyer * Copyright (c) 1994 Charles M. Hannum. All rights reserved. 361.6Sbouyer * 371.6Sbouyer * Redistribution and use in source and binary forms, with or without 381.6Sbouyer * modification, are permitted provided that the following conditions 391.6Sbouyer * are met: 401.6Sbouyer * 1. Redistributions of source code must retain the above copyright 411.6Sbouyer * notice, this list of conditions and the following disclaimer. 421.6Sbouyer * 2. Redistributions in binary form must reproduce the above copyright 431.6Sbouyer * notice, this list of conditions and the following disclaimer in the 441.6Sbouyer * documentation and/or other materials provided with the distribution. 451.6Sbouyer * 3. All advertising materials mentioning features or use of this software 461.6Sbouyer * must display the following acknowledgement: 471.6Sbouyer * This product includes software developed by Charles M. Hannum. 481.6Sbouyer * 4. The name of the author may not be used to endorse or promote products 491.6Sbouyer * derived from this software without specific prior written permission. 501.6Sbouyer * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 511.6Sbouyer * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 521.6Sbouyer * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 531.6Sbouyer * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 541.6Sbouyer * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 551.6Sbouyer * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 561.6Sbouyer * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 571.6Sbouyer * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 581.6Sbouyer * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 591.6Sbouyer * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 601.6Sbouyer */ 611.6Sbouyer 621.2Sbouyer#ifndef _XEN_PCI_MACHDEP_H_ 631.2Sbouyer#define _XEN_PCI_MACHDEP_H_ 641.2Sbouyer 651.6Sbouyer#include "opt_xen.h" 661.6Sbouyer 671.11Sbouyerstruct pci_attach_args; 681.11Sbouyer 691.2Sbouyerextern struct x86_bus_dma_tag pci_bus_dma_tag; 701.6Sbouyer#ifdef _LP64 711.6Sbouyerextern struct x86_bus_dma_tag pci_bus_dma64_tag; 721.6Sbouyer#endif 731.2Sbouyer 741.2Sbouyer/* Some values appropriate for x86, from x86/include/pci_machdep.h */ 751.2Sbouyer#define __HAVE_PCIIDE_MACHDEP_COMPAT_INTR_ESTABLISH 761.2Sbouyer#define PCI_PREFER_IOSPACE 771.6Sbouyer 781.6Sbouyer#ifdef XEN3 791.6Sbouyerunion x86_pci_tag_u { 801.8Scegger uint32_t mode1; 811.6Sbouyer struct { 821.8Scegger uint16_t port; 831.8Scegger uint8_t enable; 841.8Scegger uint8_t forward; 851.6Sbouyer } mode2; 861.6Sbouyer}; 871.6Sbouyer 881.6Sbouyertypedef union x86_pci_tag_u pcitag_t; 891.6Sbouyer 901.11Sbouyer#ifndef DOM0OPS 911.11Sbouyerint xpci_enumerate_bus(struct pci_softc *, const int *, 921.11Sbouyer int (*)(struct pci_attach_args *), struct pci_attach_args *); 931.11Sbouyer#define PCI_MACHDEP_ENUMERATE_BUS xpci_enumerate_bus 941.11Sbouyer#endif 951.11Sbouyer 961.6Sbouyer#else /* XEN3 */ 971.6Sbouyer 981.8Sceggerextern uint32_t pci_bus_attached[]; 991.6Sbouyer 1001.4Sbouyer#define PCI_MACHDEP_ENUMERATE_BUS xen_pci_enumerate_bus 1011.2Sbouyer 1021.2Sbouyer/* types provided to MI PCI */ 1031.2Sbouyerstruct xen_pci_tag { 1041.8Scegger uint8_t bus; 1051.8Scegger uint8_t device; 1061.8Scegger uint8_t function; 1071.8Scegger uint8_t _pad; /* pad to 32bits */ 1081.2Sbouyer}; 1091.2Sbouyer 1101.6Sbouyertypedef struct xen_pci_tag pcitag_t; 1111.6Sbouyer#endif /* !XEN3 */ 1121.6Sbouyer 1131.6Sbouyertypedef void *pci_chipset_tag_t; 1141.6Sbouyer 1151.2Sbouyertypedef struct xen_intr_handle pci_intr_handle_t; 1161.2Sbouyer 1171.2Sbouyer/* functions provided to MI PCI */ 1181.2Sbouyerstruct pci_attach_args; 1191.2Sbouyer 1201.9Sceggervoid pci_attach_hook(device_t, device_t, 1211.2Sbouyer struct pcibus_attach_args *); 1221.2Sbouyerint pci_bus_maxdevs(pci_chipset_tag_t, int); 1231.2Sbouyerpcitag_t pci_make_tag(pci_chipset_tag_t, int, int, int); 1241.2Sbouyervoid pci_decompose_tag(pci_chipset_tag_t, pcitag_t, 1251.2Sbouyer int *, int *, int *); 1261.2Sbouyerpcireg_t pci_conf_read(pci_chipset_tag_t, pcitag_t, int); 1271.2Sbouyervoid pci_conf_write(pci_chipset_tag_t, pcitag_t, int, 1281.2Sbouyer pcireg_t); 1291.2Sbouyerint pci_intr_map(struct pci_attach_args *, pci_intr_handle_t *); 1301.2Sbouyerconst char *pci_intr_string(pci_chipset_tag_t, pci_intr_handle_t); 1311.2Sbouyerconst struct evcnt *pci_intr_evcnt(pci_chipset_tag_t, pci_intr_handle_t); 1321.2Sbouyervoid *pci_intr_establish(pci_chipset_tag_t, pci_intr_handle_t, 1331.2Sbouyer int, int (*)(void *), void *); 1341.2Sbouyervoid pci_intr_disestablish(pci_chipset_tag_t, void *); 1351.4Sbouyerint xen_pci_enumerate_bus(struct pci_softc *, const int *, 1361.4Sbouyer int (*)(struct pci_attach_args *), struct pci_attach_args *); 1371.2Sbouyer 1381.10Scegger/* Extract Bus Number for a host bridge or -1 if unknown. */ 1391.10Sceggerint pchb_get_bus_number(pci_chipset_tag_t, pcitag_t); 1401.10Scegger 1411.2Sbouyer/* 1421.2Sbouyer * Section 6.2.4, `Miscellaneous Functions' of the PCI Specification, 1431.2Sbouyer * says that 255 means `unknown' or `no connection' to the interrupt 1441.2Sbouyer * controller on a PC. 1451.2Sbouyer */ 1461.2Sbouyer#define X86_PCI_INTERRUPT_LINE_NO_CONNECTION 0xff 1471.6Sbouyer 1481.6Sbouyerextern int pci_mode; 1491.6Sbouyerint pci_mode_detect(void); 1501.6Sbouyerint pci_bus_flags(void); 1511.6Sbouyer 1521.6Sbouyervoid pci_device_foreach(pci_chipset_tag_t, int, 1531.6Sbouyer void (*)(pci_chipset_tag_t, pcitag_t, void*), 1541.6Sbouyer void *); 1551.6Sbouyer 1561.6Sbouyervoid pci_device_foreach_min(pci_chipset_tag_t, int, int, 1571.6Sbouyer void (*)(pci_chipset_tag_t, pcitag_t, void*), 1581.6Sbouyer void *); 1591.6Sbouyer 1601.6Sbouyervoid pci_bridge_foreach(pci_chipset_tag_t, int, int, 1611.6Sbouyer void (*) (pci_chipset_tag_t, pcitag_t, void *), void *); 1621.6Sbouyer 1631.2Sbouyer#endif /* _XEN_PCI_MACHDEP_H_ */ 164