pci_machdep.h revision 1.15
1/* $NetBSD: pci_machdep.h,v 1.15 2010/02/16 00:47:46 dyoung Exp $ */
2
3/*
4 * Copyright (c) 2006 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 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 */
27
28/*
29 * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
30 * Copyright (c) 1994 Charles M. Hannum.  All rights reserved.
31 *
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
34 * are met:
35 * 1. Redistributions of source code must retain the above copyright
36 *    notice, this list of conditions and the following disclaimer.
37 * 2. Redistributions in binary form must reproduce the above copyright
38 *    notice, this list of conditions and the following disclaimer in the
39 *    documentation and/or other materials provided with the distribution.
40 * 3. All advertising materials mentioning features or use of this software
41 *    must display the following acknowledgement:
42 *      This product includes software developed by Charles M. Hannum.
43 * 4. The name of the author may not be used to endorse or promote products
44 *    derived from this software without specific prior written permission.
45 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
46 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
47 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
48 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
49 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
50 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
51 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
52 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
53 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
54 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55 */
56
57#ifndef _XEN_PCI_MACHDEP_H_
58#define _XEN_PCI_MACHDEP_H_
59
60#include "opt_xen.h"
61
62struct pci_attach_args;
63
64extern struct x86_bus_dma_tag pci_bus_dma_tag;
65#ifdef _LP64
66extern struct x86_bus_dma_tag pci_bus_dma64_tag;
67#endif
68
69/* Some values appropriate for x86, from x86/include/pci_machdep.h */
70#define __HAVE_PCIIDE_MACHDEP_COMPAT_INTR_ESTABLISH
71#define PCI_PREFER_IOSPACE
72
73union x86_pci_tag_u {
74	uint32_t mode1;
75	struct {
76		uint16_t port;
77		uint8_t enable;
78		uint8_t forward;
79	} mode2;
80};
81
82typedef union x86_pci_tag_u pcitag_t;
83
84#ifndef DOM0OPS
85int		xpci_enumerate_bus(struct pci_softc *, const int *,
86		   int (*)(struct pci_attach_args *), struct pci_attach_args *);
87#define PCI_MACHDEP_ENUMERATE_BUS xpci_enumerate_bus
88#endif
89typedef void *pci_chipset_tag_t;
90
91typedef struct xen_intr_handle pci_intr_handle_t;
92
93/* functions provided to MI PCI */
94struct pci_attach_args;
95
96void		pci_attach_hook(device_t, device_t,
97		    struct pcibus_attach_args *);
98int		pci_bus_maxdevs(pci_chipset_tag_t, int);
99pcitag_t	pci_make_tag(pci_chipset_tag_t, int, int, int);
100void		pci_decompose_tag(pci_chipset_tag_t, pcitag_t,
101		    int *, int *, int *);
102pcireg_t	pci_conf_read(pci_chipset_tag_t, pcitag_t, int);
103void		pci_conf_write(pci_chipset_tag_t, pcitag_t, int,
104		    pcireg_t);
105int		pci_intr_map(struct pci_attach_args *, pci_intr_handle_t *);
106const char	*pci_intr_string(pci_chipset_tag_t, pci_intr_handle_t);
107const struct evcnt *pci_intr_evcnt(pci_chipset_tag_t, pci_intr_handle_t);
108void		*pci_intr_establish(pci_chipset_tag_t, pci_intr_handle_t,
109		    int, int (*)(void *), void *);
110void		pci_intr_disestablish(pci_chipset_tag_t, void *);
111int		xen_pci_enumerate_bus(struct pci_softc *, const int *,
112		   int (*)(struct pci_attach_args *), struct pci_attach_args *);
113
114/* Extract Bus Number for a host bridge or -1 if unknown. */
115int             pchb_get_bus_number(pci_chipset_tag_t, pcitag_t);
116
117/*
118 * Section 6.2.4, `Miscellaneous Functions' of the PCI Specification,
119 * says that 255 means `unknown' or `no connection' to the interrupt
120 * controller on a PC.
121 */
122#define	X86_PCI_INTERRUPT_LINE_NO_CONNECTION	0xff
123
124void pci_mode_set(int);
125int pci_mode_detect(void);
126int pci_bus_flags(void);
127
128void pci_device_foreach(pci_chipset_tag_t, int,
129			void (*)(pci_chipset_tag_t, pcitag_t, void*),
130			void *);
131
132void pci_device_foreach_min(pci_chipset_tag_t, int, int,
133			    void (*)(pci_chipset_tag_t, pcitag_t, void*),
134			    void *);
135
136void pci_bridge_foreach(pci_chipset_tag_t, int, int,
137	void (*) (pci_chipset_tag_t, pcitag_t, void *), void *);
138
139#endif /* _XEN_PCI_MACHDEP_H_ */
140