1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 #ifndef _DEV_PCI_PCIVAR_H_
35 #define _DEV_PCI_PCIVAR_H_
36
37
38
39
40
41
42
43
44
45 #include <sys/device.h>
46 #include <machine/bus.h>
47 #include <dev/pci/pcireg.h>
48
49
50
51
52 typedef u_int32_t pcireg_t;
53
54
55
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
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
84
85 struct pcibus_attach_args {
86 char *pba_busname;
87 bus_space_tag_t pba_iot;
88 bus_space_tag_t pba_memt;
89 bus_dma_tag_t pba_dmat;
90 pci_chipset_tag_t pba_pc;
91
92 int pba_domain;
93 int pba_bus;
94
95
96
97
98
99 pcitag_t *pba_bridgetag;
100 pci_intr_handle_t *pba_bridgeih;
101
102
103
104
105
106 u_int pba_intrswiz;
107 pcitag_t pba_intrtag;
108 };
109
110
111
112
113 struct pci_attach_args {
114 bus_space_tag_t pa_iot;
115 bus_space_tag_t pa_memt;
116 bus_dma_tag_t pa_dmat;
117 pci_chipset_tag_t pa_pc;
118 int pa_flags;
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
132
133
134
135
136
137
138 u_int pa_intrswiz;
139 pcitag_t pa_intrtag;
140 pci_intr_pin_t pa_intrpin;
141 pci_intr_line_t pa_intrline;
142 pci_intr_pin_t pa_rawintrpin;
143 };
144
145
146
147
148
149
150 #define PCI_FLAGS_IO_ENABLED 0x01
151 #define PCI_FLAGS_MEM_ENABLED 0x02
152 #define PCI_FLAGS_MRL_OKAY 0x04
153 #define PCI_FLAGS_MRM_OKAY 0x08
154 #define PCI_FLAGS_MWI_OKAY 0x10
155
156
157
158
159
160 struct pci_quirkdata {
161 pci_vendor_id_t vendor;
162 pci_product_id_t product;
163 int quirks;
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
186
187 #define pcibuscf_bus cf_loc[0]
188 #define PCIBUS_UNK_BUS -1
189
190
191
192
193 #define pcicf_dev cf_loc[0]
194 #define PCI_UNK_DEV -1
195
196 #define pcicf_function cf_loc[1]
197 #define PCI_UNK_FUNCTION -1
198
199
200
201
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
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
242 #endif