pci.h revision 1.3.4.2 1 1.3.4.2 rmind /* $NetBSD: pci.h,v 1.3.4.2 2014/05/18 17:46:01 rmind Exp $ */
2 1.3.4.2 rmind
3 1.3.4.2 rmind /*-
4 1.3.4.2 rmind * Copyright (c) 2013 The NetBSD Foundation, Inc.
5 1.3.4.2 rmind * All rights reserved.
6 1.3.4.2 rmind *
7 1.3.4.2 rmind * This code is derived from software contributed to The NetBSD Foundation
8 1.3.4.2 rmind * by Taylor R. Campbell.
9 1.3.4.2 rmind *
10 1.3.4.2 rmind * Redistribution and use in source and binary forms, with or without
11 1.3.4.2 rmind * modification, are permitted provided that the following conditions
12 1.3.4.2 rmind * are met:
13 1.3.4.2 rmind * 1. Redistributions of source code must retain the above copyright
14 1.3.4.2 rmind * notice, this list of conditions and the following disclaimer.
15 1.3.4.2 rmind * 2. Redistributions in binary form must reproduce the above copyright
16 1.3.4.2 rmind * notice, this list of conditions and the following disclaimer in the
17 1.3.4.2 rmind * documentation and/or other materials provided with the distribution.
18 1.3.4.2 rmind *
19 1.3.4.2 rmind * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.3.4.2 rmind * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.3.4.2 rmind * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.3.4.2 rmind * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.3.4.2 rmind * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.3.4.2 rmind * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.3.4.2 rmind * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.3.4.2 rmind * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.3.4.2 rmind * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.3.4.2 rmind * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.3.4.2 rmind * POSSIBILITY OF SUCH DAMAGE.
30 1.3.4.2 rmind */
31 1.3.4.2 rmind
32 1.3.4.2 rmind #ifndef _LINUX_PCI_H_
33 1.3.4.2 rmind #define _LINUX_PCI_H_
34 1.3.4.2 rmind
35 1.3.4.2 rmind #include <sys/types.h>
36 1.3.4.2 rmind #include <sys/bus.h>
37 1.3.4.2 rmind #include <sys/cdefs.h>
38 1.3.4.2 rmind #include <sys/kmem.h>
39 1.3.4.2 rmind #include <sys/systm.h>
40 1.3.4.2 rmind
41 1.3.4.2 rmind #include <dev/pci/pcidevs.h>
42 1.3.4.2 rmind #include <dev/pci/pcireg.h>
43 1.3.4.2 rmind #include <dev/pci/pcivar.h>
44 1.3.4.2 rmind
45 1.3.4.2 rmind #include <linux/ioport.h>
46 1.3.4.2 rmind
47 1.3.4.2 rmind struct pci_bus;
48 1.3.4.2 rmind
49 1.3.4.2 rmind struct pci_device_id {
50 1.3.4.2 rmind uint32_t vendor;
51 1.3.4.2 rmind uint32_t device;
52 1.3.4.2 rmind uint32_t subvendor;
53 1.3.4.2 rmind uint32_t subdevice;
54 1.3.4.2 rmind uint32_t class;
55 1.3.4.2 rmind uint32_t class_mask;
56 1.3.4.2 rmind unsigned long driver_data;
57 1.3.4.2 rmind };
58 1.3.4.2 rmind
59 1.3.4.2 rmind #define PCI_ANY_ID ((pcireg_t)-1)
60 1.3.4.2 rmind
61 1.3.4.2 rmind #define PCI_BASE_CLASS_DISPLAY PCI_CLASS_DISPLAY
62 1.3.4.2 rmind
63 1.3.4.2 rmind #define PCI_CLASS_BRIDGE_ISA \
64 1.3.4.2 rmind ((PCI_CLASS_BRIDGE << 8) | PCI_SUBCLASS_BRIDGE_ISA)
65 1.3.4.2 rmind CTASSERT(PCI_CLASS_BRIDGE_ISA == 0x0601);
66 1.3.4.2 rmind
67 1.3.4.2 rmind #define PCI_VENDOR_ID_INTEL PCI_VENDOR_INTEL
68 1.3.4.2 rmind
69 1.3.4.2 rmind #define PCI_DEVFN(DEV, FN) \
70 1.3.4.2 rmind (__SHIFTIN((DEV), __BITS(3, 7)) | __SHIFTIN((FN), __BITS(0, 2)))
71 1.3.4.2 rmind #define PCI_SLOT(DEVFN) __SHIFTOUT((DEVFN), __BITS(3, 7))
72 1.3.4.2 rmind #define PCI_FUNC(DEVFN) __SHIFTOUT((DEVFN), __BITS(0, 2))
73 1.3.4.2 rmind
74 1.3.4.2 rmind #define PCI_CAP_ID_AGP PCI_CAP_AGP
75 1.3.4.2 rmind
76 1.3.4.2 rmind struct pci_dev {
77 1.3.4.2 rmind struct pci_attach_args pd_pa;
78 1.3.4.2 rmind int pd_kludges; /* Gotta lose 'em... */
79 1.3.4.2 rmind #define NBPCI_KLUDGE_GET_MUMBLE 0x01
80 1.3.4.2 rmind #define NBPCI_KLUDGE_MAP_ROM 0x02
81 1.3.4.2 rmind bus_space_tag_t pd_rom_bst;
82 1.3.4.2 rmind bus_space_handle_t pd_rom_bsh;
83 1.3.4.2 rmind bus_size_t pd_rom_size;
84 1.3.4.2 rmind void *pd_rom_vaddr;
85 1.3.4.2 rmind device_t pd_dev;
86 1.3.4.2 rmind struct device dev; /* XXX Don't believe me! */
87 1.3.4.2 rmind struct pci_bus *bus;
88 1.3.4.2 rmind uint32_t devfn;
89 1.3.4.2 rmind uint16_t vendor;
90 1.3.4.2 rmind uint16_t device;
91 1.3.4.2 rmind uint16_t subsystem_vendor;
92 1.3.4.2 rmind uint16_t subsystem_device;
93 1.3.4.2 rmind uint8_t revision;
94 1.3.4.2 rmind uint32_t class;
95 1.3.4.2 rmind bool msi_enabled;
96 1.3.4.2 rmind };
97 1.3.4.2 rmind
98 1.3.4.2 rmind static inline device_t
99 1.3.4.2 rmind pci_dev_dev(struct pci_dev *pdev)
100 1.3.4.2 rmind {
101 1.3.4.2 rmind return pdev->pd_dev;
102 1.3.4.2 rmind }
103 1.3.4.2 rmind
104 1.3.4.2 rmind static inline void
105 1.3.4.2 rmind linux_pci_dev_init(struct pci_dev *pdev, device_t dev,
106 1.3.4.2 rmind const struct pci_attach_args *pa, int kludges)
107 1.3.4.2 rmind {
108 1.3.4.2 rmind const uint32_t subsystem_id = pci_conf_read(pa->pa_pc, pa->pa_tag,
109 1.3.4.2 rmind PCI_SUBSYS_ID_REG);
110 1.3.4.2 rmind
111 1.3.4.2 rmind pdev->pd_pa = *pa;
112 1.3.4.2 rmind pdev->pd_kludges = kludges;
113 1.3.4.2 rmind pdev->pd_rom_vaddr = NULL;
114 1.3.4.2 rmind pdev->pd_dev = dev;
115 1.3.4.2 rmind pdev->bus = NULL; /* XXX struct pci_dev::bus */
116 1.3.4.2 rmind pdev->devfn = PCI_DEVFN(pa->pa_device, pa->pa_function);
117 1.3.4.2 rmind pdev->vendor = PCI_VENDOR(pa->pa_id);
118 1.3.4.2 rmind pdev->device = PCI_PRODUCT(pa->pa_id);
119 1.3.4.2 rmind pdev->subsystem_vendor = PCI_SUBSYS_VENDOR(subsystem_id);
120 1.3.4.2 rmind pdev->subsystem_device = PCI_SUBSYS_ID(subsystem_id);
121 1.3.4.2 rmind pdev->revision = PCI_REVISION(pa->pa_class);
122 1.3.4.2 rmind pdev->class = __SHIFTOUT(pa->pa_class, 0xffffff00UL); /* ? */
123 1.3.4.2 rmind pdev->msi_enabled = false;
124 1.3.4.2 rmind }
125 1.3.4.2 rmind
126 1.3.4.2 rmind static inline int
127 1.3.4.2 rmind pci_find_capability(struct pci_dev *pdev, int cap)
128 1.3.4.2 rmind {
129 1.3.4.2 rmind return pci_get_capability(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, cap,
130 1.3.4.2 rmind NULL, NULL);
131 1.3.4.2 rmind }
132 1.3.4.2 rmind
133 1.3.4.2 rmind static inline void
134 1.3.4.2 rmind pci_read_config_dword(struct pci_dev *pdev, int reg, uint32_t *valuep)
135 1.3.4.2 rmind {
136 1.3.4.2 rmind KASSERT(!ISSET(reg, 3));
137 1.3.4.2 rmind *valuep = pci_conf_read(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, reg);
138 1.3.4.2 rmind }
139 1.3.4.2 rmind
140 1.3.4.2 rmind static inline void
141 1.3.4.2 rmind pci_read_config_word(struct pci_dev *pdev, int reg, uint16_t *valuep)
142 1.3.4.2 rmind {
143 1.3.4.2 rmind KASSERT(!ISSET(reg, 1));
144 1.3.4.2 rmind *valuep = pci_conf_read(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag,
145 1.3.4.2 rmind (reg &~ 3)) >> (8 * (reg & 3));
146 1.3.4.2 rmind }
147 1.3.4.2 rmind
148 1.3.4.2 rmind static inline void
149 1.3.4.2 rmind pci_read_config_byte(struct pci_dev *pdev, int reg, uint8_t *valuep)
150 1.3.4.2 rmind {
151 1.3.4.2 rmind *valuep = pci_conf_read(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag,
152 1.3.4.2 rmind (reg &~ 1)) >> (8 * (reg & 1));
153 1.3.4.2 rmind }
154 1.3.4.2 rmind
155 1.3.4.2 rmind static inline void
156 1.3.4.2 rmind pci_write_config_dword(struct pci_dev *pdev, int reg, uint32_t value)
157 1.3.4.2 rmind {
158 1.3.4.2 rmind KASSERT(!ISSET(reg, 3));
159 1.3.4.2 rmind pci_conf_write(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, reg, value);
160 1.3.4.2 rmind }
161 1.3.4.2 rmind
162 1.3.4.2 rmind static inline void
163 1.3.4.2 rmind pci_rmw_config(struct pci_dev *pdev, int reg, unsigned int bytes,
164 1.3.4.2 rmind uint32_t value)
165 1.3.4.2 rmind {
166 1.3.4.2 rmind const uint32_t mask = ~((~0UL) << (8 * bytes));
167 1.3.4.2 rmind const int reg32 = (reg &~ 3);
168 1.3.4.2 rmind const unsigned int shift = (8 * (reg & 3));
169 1.3.4.2 rmind uint32_t value32;
170 1.3.4.2 rmind
171 1.3.4.2 rmind KASSERT(bytes <= 4);
172 1.3.4.2 rmind KASSERT(!ISSET(value, ~mask));
173 1.3.4.2 rmind pci_read_config_dword(pdev, reg32, &value32);
174 1.3.4.2 rmind value32 &=~ (mask << shift);
175 1.3.4.2 rmind value32 |= (value << shift);
176 1.3.4.2 rmind pci_write_config_dword(pdev, reg32, value32);
177 1.3.4.2 rmind }
178 1.3.4.2 rmind
179 1.3.4.2 rmind static inline void
180 1.3.4.2 rmind pci_write_config_word(struct pci_dev *pdev, int reg, uint16_t value)
181 1.3.4.2 rmind {
182 1.3.4.2 rmind KASSERT(!ISSET(reg, 1));
183 1.3.4.2 rmind pci_rmw_config(pdev, reg, 2, value);
184 1.3.4.2 rmind }
185 1.3.4.2 rmind
186 1.3.4.2 rmind static inline void
187 1.3.4.2 rmind pci_write_config_byte(struct pci_dev *pdev, int reg, uint8_t value)
188 1.3.4.2 rmind {
189 1.3.4.2 rmind pci_rmw_config(pdev, reg, 1, value);
190 1.3.4.2 rmind }
191 1.3.4.2 rmind
192 1.3.4.2 rmind /*
193 1.3.4.2 rmind * XXX pci msi
194 1.3.4.2 rmind */
195 1.3.4.2 rmind static inline void
196 1.3.4.2 rmind pci_enable_msi(struct pci_dev *pdev)
197 1.3.4.2 rmind {
198 1.3.4.2 rmind KASSERT(!pdev->msi_enabled);
199 1.3.4.2 rmind pdev->msi_enabled = true;
200 1.3.4.2 rmind }
201 1.3.4.2 rmind
202 1.3.4.2 rmind static inline void
203 1.3.4.2 rmind pci_disable_msi(struct pci_dev *pdev)
204 1.3.4.2 rmind {
205 1.3.4.2 rmind KASSERT(pdev->msi_enabled);
206 1.3.4.2 rmind pdev->msi_enabled = false;
207 1.3.4.2 rmind }
208 1.3.4.2 rmind
209 1.3.4.2 rmind static inline void
210 1.3.4.2 rmind pci_set_master(struct pci_dev *pdev)
211 1.3.4.2 rmind {
212 1.3.4.2 rmind pcireg_t csr;
213 1.3.4.2 rmind
214 1.3.4.2 rmind csr = pci_conf_read(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag,
215 1.3.4.2 rmind PCI_COMMAND_STATUS_REG);
216 1.3.4.2 rmind csr |= PCI_COMMAND_MASTER_ENABLE;
217 1.3.4.2 rmind pci_conf_write(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag,
218 1.3.4.2 rmind PCI_COMMAND_STATUS_REG, csr);
219 1.3.4.2 rmind }
220 1.3.4.2 rmind
221 1.3.4.2 rmind #define PCIBIOS_MIN_MEM 0 /* XXX bogus x86 kludge bollocks */
222 1.3.4.2 rmind
223 1.3.4.2 rmind static inline bus_addr_t
224 1.3.4.2 rmind pcibios_align_resource(void *p, const struct resource *resource,
225 1.3.4.2 rmind bus_addr_t addr, bus_size_t size)
226 1.3.4.2 rmind {
227 1.3.4.2 rmind panic("pcibios_align_resource has accessed unaligned neurons!");
228 1.3.4.2 rmind }
229 1.3.4.2 rmind
230 1.3.4.2 rmind static inline int
231 1.3.4.2 rmind pci_bus_alloc_resource(struct pci_bus *bus, struct resource *resource,
232 1.3.4.2 rmind bus_size_t size, bus_size_t align, bus_addr_t start, int type __unused,
233 1.3.4.2 rmind bus_addr_t (*align_fn)(void *, const struct resource *, bus_addr_t,
234 1.3.4.2 rmind bus_size_t) __unused,
235 1.3.4.2 rmind struct pci_dev *pdev)
236 1.3.4.2 rmind {
237 1.3.4.2 rmind const struct pci_attach_args *const pa = &pdev->pd_pa;
238 1.3.4.2 rmind bus_space_tag_t bst;
239 1.3.4.2 rmind int error;
240 1.3.4.2 rmind
241 1.3.4.2 rmind switch (resource->flags) {
242 1.3.4.2 rmind case IORESOURCE_MEM:
243 1.3.4.2 rmind bst = pa->pa_memt;
244 1.3.4.2 rmind break;
245 1.3.4.2 rmind
246 1.3.4.2 rmind case IORESOURCE_IO:
247 1.3.4.2 rmind bst = pa->pa_iot;
248 1.3.4.2 rmind break;
249 1.3.4.2 rmind
250 1.3.4.2 rmind default:
251 1.3.4.2 rmind panic("I don't know what kind of resource you want!");
252 1.3.4.2 rmind }
253 1.3.4.2 rmind
254 1.3.4.2 rmind resource->r_bst = bst;
255 1.3.4.2 rmind error = bus_space_alloc(bst, start, __type_max(bus_addr_t),
256 1.3.4.2 rmind size, align, 0, 0, &resource->start, &resource->r_bsh);
257 1.3.4.2 rmind if (error)
258 1.3.4.2 rmind return error;
259 1.3.4.2 rmind
260 1.3.4.2 rmind resource->size = size;
261 1.3.4.2 rmind return 0;
262 1.3.4.2 rmind }
263 1.3.4.2 rmind
264 1.3.4.2 rmind /*
265 1.3.4.2 rmind * XXX Mega-kludgerific! pci_get_bus_and_slot and pci_get_class are
266 1.3.4.2 rmind * defined only for their single purposes in i915drm, in
267 1.3.4.2 rmind * i915_get_bridge_dev and intel_detect_pch. We can't define them more
268 1.3.4.2 rmind * generally without adapting pci_find_device (and pci_enumerate_bus
269 1.3.4.2 rmind * internally) to pass a cookie through.
270 1.3.4.2 rmind */
271 1.3.4.2 rmind
272 1.3.4.2 rmind static inline int /* XXX inline? */
273 1.3.4.2 rmind pci_kludgey_match_bus0_dev0_func0(const struct pci_attach_args *pa)
274 1.3.4.2 rmind {
275 1.3.4.2 rmind
276 1.3.4.2 rmind if (pa->pa_bus != 0)
277 1.3.4.2 rmind return 0;
278 1.3.4.2 rmind if (pa->pa_device != 0)
279 1.3.4.2 rmind return 0;
280 1.3.4.2 rmind if (pa->pa_function != 0)
281 1.3.4.2 rmind return 0;
282 1.3.4.2 rmind
283 1.3.4.2 rmind return 1;
284 1.3.4.2 rmind }
285 1.3.4.2 rmind
286 1.3.4.2 rmind static inline struct pci_dev *
287 1.3.4.2 rmind pci_get_bus_and_slot(int bus, int slot)
288 1.3.4.2 rmind {
289 1.3.4.2 rmind struct pci_attach_args pa;
290 1.3.4.2 rmind
291 1.3.4.2 rmind KASSERT(bus == 0);
292 1.3.4.2 rmind KASSERT(slot == PCI_DEVFN(0, 0));
293 1.3.4.2 rmind
294 1.3.4.2 rmind if (!pci_find_device(&pa, &pci_kludgey_match_bus0_dev0_func0))
295 1.3.4.2 rmind return NULL;
296 1.3.4.2 rmind
297 1.3.4.2 rmind struct pci_dev *const pdev = kmem_zalloc(sizeof(*pdev), KM_SLEEP);
298 1.3.4.2 rmind linux_pci_dev_init(pdev, NULL, &pa, NBPCI_KLUDGE_GET_MUMBLE);
299 1.3.4.2 rmind
300 1.3.4.2 rmind return pdev;
301 1.3.4.2 rmind }
302 1.3.4.2 rmind
303 1.3.4.2 rmind static inline int /* XXX inline? */
304 1.3.4.2 rmind pci_kludgey_match_isa_bridge(const struct pci_attach_args *pa)
305 1.3.4.2 rmind {
306 1.3.4.2 rmind
307 1.3.4.2 rmind if (PCI_CLASS(pa->pa_class) != PCI_CLASS_BRIDGE)
308 1.3.4.2 rmind return 0;
309 1.3.4.2 rmind if (PCI_SUBCLASS(pa->pa_class) != PCI_SUBCLASS_BRIDGE_ISA)
310 1.3.4.2 rmind return 0;
311 1.3.4.2 rmind
312 1.3.4.2 rmind return 1;
313 1.3.4.2 rmind }
314 1.3.4.2 rmind
315 1.3.4.2 rmind static inline struct pci_dev *
316 1.3.4.2 rmind pci_get_class(uint32_t class_subclass_shifted __unused,
317 1.3.4.2 rmind struct pci_dev *from __unused)
318 1.3.4.2 rmind {
319 1.3.4.2 rmind struct pci_attach_args pa;
320 1.3.4.2 rmind
321 1.3.4.2 rmind KASSERT(class_subclass_shifted == (PCI_CLASS_BRIDGE_ISA << 8));
322 1.3.4.2 rmind KASSERT(from == NULL);
323 1.3.4.2 rmind
324 1.3.4.2 rmind if (!pci_find_device(&pa, &pci_kludgey_match_isa_bridge))
325 1.3.4.2 rmind return NULL;
326 1.3.4.2 rmind
327 1.3.4.2 rmind struct pci_dev *const pdev = kmem_zalloc(sizeof(*pdev), KM_SLEEP);
328 1.3.4.2 rmind linux_pci_dev_init(pdev, NULL, &pa, NBPCI_KLUDGE_GET_MUMBLE);
329 1.3.4.2 rmind
330 1.3.4.2 rmind return pdev;
331 1.3.4.2 rmind }
332 1.3.4.2 rmind
333 1.3.4.2 rmind static inline void
334 1.3.4.2 rmind pci_dev_put(struct pci_dev *pdev)
335 1.3.4.2 rmind {
336 1.3.4.2 rmind
337 1.3.4.2 rmind KASSERT(ISSET(pdev->pd_kludges, NBPCI_KLUDGE_GET_MUMBLE));
338 1.3.4.2 rmind kmem_free(pdev, sizeof(*pdev));
339 1.3.4.2 rmind }
340 1.3.4.2 rmind
341 1.3.4.2 rmind #define __pci_rom_iomem
342 1.3.4.2 rmind
343 1.3.4.2 rmind static inline void
344 1.3.4.2 rmind pci_unmap_rom(struct pci_dev *pdev, void __pci_rom_iomem *vaddr __unused)
345 1.3.4.2 rmind {
346 1.3.4.2 rmind
347 1.3.4.2 rmind KASSERT(ISSET(pdev->pd_kludges, NBPCI_KLUDGE_MAP_ROM));
348 1.3.4.2 rmind KASSERT(vaddr == pdev->pd_rom_vaddr);
349 1.3.4.2 rmind bus_space_unmap(pdev->pd_rom_bst, pdev->pd_rom_bsh, pdev->pd_rom_size);
350 1.3.4.2 rmind pdev->pd_kludges &= ~NBPCI_KLUDGE_MAP_ROM;
351 1.3.4.2 rmind pdev->pd_rom_vaddr = NULL;
352 1.3.4.2 rmind }
353 1.3.4.2 rmind
354 1.3.4.2 rmind static inline void __pci_rom_iomem *
355 1.3.4.2 rmind pci_map_rom(struct pci_dev *pdev, size_t *sizep)
356 1.3.4.2 rmind {
357 1.3.4.2 rmind bus_space_handle_t bsh;
358 1.3.4.2 rmind bus_size_t size;
359 1.3.4.2 rmind
360 1.3.4.2 rmind KASSERT(!ISSET(pdev->pd_kludges, NBPCI_KLUDGE_MAP_ROM));
361 1.3.4.2 rmind
362 1.3.4.2 rmind if (pci_mapreg_map(&pdev->pd_pa, PCI_MAPREG_ROM, PCI_MAPREG_TYPE_ROM,
363 1.3.4.2 rmind (BUS_SPACE_MAP_PREFETCHABLE | BUS_SPACE_MAP_LINEAR),
364 1.3.4.2 rmind &pdev->pd_rom_bst, &pdev->pd_rom_bsh, NULL, &pdev->pd_rom_size)
365 1.3.4.2 rmind != 0) {
366 1.3.4.2 rmind aprint_error_dev(pdev->pd_dev, "unable to map ROM\n");
367 1.3.4.2 rmind return NULL;
368 1.3.4.2 rmind }
369 1.3.4.2 rmind pdev->pd_kludges |= NBPCI_KLUDGE_MAP_ROM;
370 1.3.4.2 rmind
371 1.3.4.2 rmind /* XXX This type is obviously wrong in general... */
372 1.3.4.2 rmind if (pci_find_rom(&pdev->pd_pa, pdev->pd_rom_bst, pdev->pd_rom_bsh,
373 1.3.4.2 rmind PCI_ROM_CODE_TYPE_X86, &bsh, &size)) {
374 1.3.4.2 rmind aprint_error_dev(pdev->pd_dev, "unable to find ROM\n");
375 1.3.4.2 rmind pci_unmap_rom(pdev, NULL);
376 1.3.4.2 rmind return NULL;
377 1.3.4.2 rmind }
378 1.3.4.2 rmind
379 1.3.4.2 rmind KASSERT(size <= SIZE_T_MAX);
380 1.3.4.2 rmind *sizep = size;
381 1.3.4.2 rmind pdev->pd_rom_vaddr = bus_space_vaddr(pdev->pd_rom_bst, bsh);
382 1.3.4.2 rmind return pdev->pd_rom_vaddr;
383 1.3.4.2 rmind }
384 1.3.4.2 rmind
385 1.3.4.2 rmind #endif /* _LINUX_PCI_H_ */
386