pci_machdep.h revision 1.3
1/* $NetBSD: pci_machdep.h,v 1.3 2005/04/16 22:49:38 bouyer 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
36extern struct x86_bus_dma_tag pci_bus_dma_tag;
37extern 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
43/* types provided to MI PCI */
44struct xen_pci_tag {
45	u_int8_t bus;
46	u_int8_t device;
47	u_int8_t function;
48	u_int8_t _pad; /* pad to 32bits */
49};
50
51struct xen_intr_handle {
52	int pirq;
53	int evtch;
54};
55
56typedef struct xen_pci_tag pcitag_t;
57typedef void *pci_chipset_tag_t;
58typedef struct xen_intr_handle pci_intr_handle_t;
59
60/* functions provided to MI PCI */
61struct pci_attach_args;
62
63void		pci_attach_hook(struct device *, struct device *,
64		    struct pcibus_attach_args *);
65int		pci_bus_maxdevs(pci_chipset_tag_t, int);
66pcitag_t	pci_make_tag(pci_chipset_tag_t, int, int, int);
67void		pci_decompose_tag(pci_chipset_tag_t, pcitag_t,
68		    int *, int *, int *);
69pcireg_t	pci_conf_read(pci_chipset_tag_t, pcitag_t, int);
70void		pci_conf_write(pci_chipset_tag_t, pcitag_t, int,
71		    pcireg_t);
72int		pci_intr_map(struct pci_attach_args *, pci_intr_handle_t *);
73const char	*pci_intr_string(pci_chipset_tag_t, pci_intr_handle_t);
74const struct evcnt *pci_intr_evcnt(pci_chipset_tag_t, pci_intr_handle_t);
75void		*pci_intr_establish(pci_chipset_tag_t, pci_intr_handle_t,
76		    int, int (*)(void *), void *);
77void		pci_intr_disestablish(pci_chipset_tag_t, void *);
78
79/*
80 * Section 6.2.4, `Miscellaneous Functions' of the PCI Specification,
81 * says that 255 means `unknown' or `no connection' to the interrupt
82 * controller on a PC.
83 */
84#define	X86_PCI_INTERRUPT_LINE_NO_CONNECTION	0xff
85#endif /* _XEN_PCI_MACHDEP_H_ */
86