1 /* $NetBSD: pci_machdep.h,v 1.5 2005/12/11 12:19:48 christos Exp $ */ 2 3 /* 4 * Copyright (c) 2005 Manuel Bouyer. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. All advertising materials mentioning features or use of this software 15 * must display the following acknowledgement: 16 * This product includes software developed by Manuel Bouyer. 17 * 4. The name of the author may not be used to endorse or promote products 18 * derived from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * 31 */ 32 33 #ifndef _XEN_PCI_MACHDEP_H_ 34 #define _XEN_PCI_MACHDEP_H_ 35 36 extern struct x86_bus_dma_tag pci_bus_dma_tag; 37 extern u_int32_t pci_bus_attached[]; 38 39 /* Some values appropriate for x86, from x86/include/pci_machdep.h */ 40 #define __HAVE_PCIIDE_MACHDEP_COMPAT_INTR_ESTABLISH 41 #define PCI_PREFER_IOSPACE 42 #define PCI_MACHDEP_ENUMERATE_BUS xen_pci_enumerate_bus 43 44 /* types provided to MI PCI */ 45 struct xen_pci_tag { 46 u_int8_t bus; 47 u_int8_t device; 48 u_int8_t function; 49 u_int8_t _pad; /* pad to 32bits */ 50 }; 51 52 struct xen_intr_handle { 53 int pirq; 54 int evtch; 55 }; 56 57 typedef struct xen_pci_tag pcitag_t; 58 typedef void *pci_chipset_tag_t; 59 typedef struct xen_intr_handle pci_intr_handle_t; 60 61 /* functions provided to MI PCI */ 62 struct pci_attach_args; 63 64 void pci_attach_hook(struct device *, struct device *, 65 struct pcibus_attach_args *); 66 int pci_bus_maxdevs(pci_chipset_tag_t, int); 67 pcitag_t pci_make_tag(pci_chipset_tag_t, int, int, int); 68 void pci_decompose_tag(pci_chipset_tag_t, pcitag_t, 69 int *, int *, int *); 70 pcireg_t pci_conf_read(pci_chipset_tag_t, pcitag_t, int); 71 void pci_conf_write(pci_chipset_tag_t, pcitag_t, int, 72 pcireg_t); 73 int pci_intr_map(struct pci_attach_args *, pci_intr_handle_t *); 74 const char *pci_intr_string(pci_chipset_tag_t, pci_intr_handle_t); 75 const struct evcnt *pci_intr_evcnt(pci_chipset_tag_t, pci_intr_handle_t); 76 void *pci_intr_establish(pci_chipset_tag_t, pci_intr_handle_t, 77 int, int (*)(void *), void *); 78 void pci_intr_disestablish(pci_chipset_tag_t, void *); 79 int xen_pci_enumerate_bus(struct pci_softc *, const int *, 80 int (*)(struct pci_attach_args *), struct pci_attach_args *); 81 82 /* 83 * Section 6.2.4, `Miscellaneous Functions' of the PCI Specification, 84 * says that 255 means `unknown' or `no connection' to the interrupt 85 * controller on a PC. 86 */ 87 #define X86_PCI_INTERRUPT_LINE_NO_CONNECTION 0xff 88 #endif /* _XEN_PCI_MACHDEP_H_ */ 89