acpi_pci.c revision 1.2.2.3 1 1.2 njoly /* $NetBSD: acpi_pci.c,v 1.2.2.3 2010/10/22 07:21:53 uebayasi Exp $ */
2 1.1 cegger
3 1.1 cegger /*
4 1.2.2.1 uebayasi * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
5 1.1 cegger * All rights reserved.
6 1.1 cegger *
7 1.1 cegger * This code is derived from software contributed to The NetBSD Foundation
8 1.2.2.1 uebayasi * by Christoph Egger and Gregoire Sutre.
9 1.1 cegger *
10 1.1 cegger * Redistribution and use in source and binary forms, with or without
11 1.1 cegger * modification, are permitted provided that the following conditions
12 1.1 cegger * are met:
13 1.1 cegger * 1. Redistributions of source code must retain the above copyright
14 1.1 cegger * notice, this list of conditions and the following disclaimer.
15 1.1 cegger * 2. The name of the author may not be used to endorse or promote products
16 1.1 cegger * derived from this software without specific prior written permission.
17 1.1 cegger *
18 1.1 cegger * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 1.1 cegger * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 1.1 cegger * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 1.1 cegger * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 1.1 cegger * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 1.1 cegger * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 1.1 cegger * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 1.1 cegger * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 1.1 cegger * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 1.1 cegger * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 1.1 cegger * SUCH DAMAGE.
29 1.1 cegger */
30 1.1 cegger
31 1.1 cegger #include <sys/cdefs.h>
32 1.2.2.1 uebayasi __KERNEL_RCSID(0, "$NetBSD: acpi_pci.c,v 1.2.2.3 2010/10/22 07:21:53 uebayasi Exp $");
33 1.1 cegger
34 1.1 cegger #include <sys/param.h>
35 1.1 cegger #include <sys/device.h>
36 1.1 cegger #include <sys/kmem.h>
37 1.2.2.1 uebayasi #include <sys/systm.h>
38 1.2.2.1 uebayasi
39 1.2.2.1 uebayasi #include <dev/pci/pcireg.h>
40 1.2.2.1 uebayasi #include <dev/pci/pcidevs.h>
41 1.2.2.1 uebayasi #include <dev/pci/ppbreg.h>
42 1.1 cegger
43 1.1 cegger #include <dev/acpi/acpireg.h>
44 1.1 cegger #include <dev/acpi/acpivar.h>
45 1.1 cegger #include <dev/acpi/acpi_pci.h>
46 1.1 cegger
47 1.2.2.1 uebayasi #define _COMPONENT ACPI_BUS_COMPONENT
48 1.2.2.1 uebayasi ACPI_MODULE_NAME ("acpi_pci")
49 1.2.2.1 uebayasi
50 1.2.2.1 uebayasi #define ACPI_HILODWORD(x) ACPI_HIWORD(ACPI_LODWORD((x)))
51 1.2.2.1 uebayasi #define ACPI_LOLODWORD(x) ACPI_LOWORD(ACPI_LODWORD((x)))
52 1.2.2.1 uebayasi
53 1.2.2.1 uebayasi static ACPI_STATUS acpi_pcidev_pciroot_bus(ACPI_HANDLE, uint16_t *);
54 1.2.2.1 uebayasi static ACPI_STATUS acpi_pcidev_pciroot_bus_callback(ACPI_RESOURCE *,
55 1.2.2.1 uebayasi void *);
56 1.1 cegger
57 1.2.2.1 uebayasi /*
58 1.2.2.1 uebayasi * Regarding PCI Segment Groups (ACPI 4.0, p. 277):
59 1.2.2.1 uebayasi *
60 1.2.2.1 uebayasi * "The optional _SEG object is located under a PCI host bridge and
61 1.2.2.1 uebayasi * evaluates to an integer that describes the PCI Segment Group (see PCI
62 1.2.2.1 uebayasi * Firmware Specification v3.0)."
63 1.2.2.1 uebayasi *
64 1.2.2.1 uebayasi * "PCI Segment Group is purely a software concept managed by system
65 1.2.2.1 uebayasi * firmware and used by OSPM. It is a logical collection of PCI buses
66 1.2.2.1 uebayasi * (or bus segments). It is a way to logically group the PCI bus segments
67 1.2.2.1 uebayasi * and PCI Express Hierarchies. _SEG is a level higher than _BBN."
68 1.2.2.1 uebayasi *
69 1.2.2.1 uebayasi * "PCI Segment Group supports more than 256 buses in a system by allowing
70 1.2.2.1 uebayasi * the reuse of the PCI bus numbers. Within each PCI Segment Group, the bus
71 1.2.2.1 uebayasi * numbers for the PCI buses must be unique. PCI buses in different PCI
72 1.2.2.1 uebayasi * Segment Group are permitted to have the same bus number."
73 1.2.2.1 uebayasi */
74 1.1 cegger
75 1.2.2.1 uebayasi /*
76 1.2.2.1 uebayasi * Regarding PCI Base Bus Numbers (ACPI 4.0, p. 277):
77 1.2.2.1 uebayasi *
78 1.2.2.1 uebayasi * "For multi-root PCI platforms, the _BBN object evaluates to the PCI bus
79 1.2.2.1 uebayasi * number that the BIOS assigns. This is needed to access a PCI_Config
80 1.2.2.1 uebayasi * operation region for the specified bus. The _BBN object is located under
81 1.2.2.1 uebayasi * a PCI host bridge and must be unique for every host bridge within a
82 1.2.2.1 uebayasi * segment since it is the PCI bus number."
83 1.2.2.1 uebayasi *
84 1.2.2.1 uebayasi * Moreover, the ACPI FAQ (http://www.acpi.info/acpi_faq.htm) says:
85 1.2.2.1 uebayasi *
86 1.2.2.1 uebayasi * "For a multiple root bus machine, _BBN is required for each bus. _BBN
87 1.2.2.1 uebayasi * should provide the bus number assigned to this bus by the BIOS at boot
88 1.2.2.1 uebayasi * time."
89 1.2.2.1 uebayasi */
90 1.1 cegger
91 1.2.2.1 uebayasi /*
92 1.2.2.1 uebayasi * acpi_pcidev_pciroot_bus:
93 1.2.2.1 uebayasi *
94 1.2.2.1 uebayasi * Derive the PCI bus number of a PCI root bridge from its resources.
95 1.2.2.1 uebayasi * If successful, return AE_OK and fill *busp. Otherwise, return an
96 1.2.2.1 uebayasi * exception code and leave *busp unchanged.
97 1.2.2.1 uebayasi */
98 1.2.2.1 uebayasi static ACPI_STATUS
99 1.2.2.1 uebayasi acpi_pcidev_pciroot_bus(ACPI_HANDLE handle, uint16_t *busp)
100 1.1 cegger {
101 1.1 cegger ACPI_STATUS rv;
102 1.2.2.1 uebayasi int32_t bus;
103 1.2.2.1 uebayasi
104 1.2.2.1 uebayasi bus = -1;
105 1.1 cegger
106 1.1 cegger /*
107 1.2.2.1 uebayasi * XXX: Use the ACPI resource parsing functions (acpi_resource.c)
108 1.2.2.1 uebayasi * once bus number ranges have been implemented there.
109 1.1 cegger */
110 1.2.2.1 uebayasi rv = AcpiWalkResources(handle, "_CRS",
111 1.2.2.1 uebayasi acpi_pcidev_pciroot_bus_callback, &bus);
112 1.2.2.1 uebayasi
113 1.1 cegger if (ACPI_FAILURE(rv))
114 1.2.2.1 uebayasi return rv;
115 1.2.2.1 uebayasi
116 1.2.2.3 uebayasi if (bus == -1)
117 1.2.2.1 uebayasi return AE_NOT_EXIST;
118 1.2.2.1 uebayasi
119 1.2.2.3 uebayasi /* Here it holds that 0 <= bus <= 0xFFFF. */
120 1.2.2.1 uebayasi *busp = (uint16_t)bus;
121 1.2.2.1 uebayasi
122 1.2.2.1 uebayasi return rv;
123 1.2.2.1 uebayasi }
124 1.2.2.1 uebayasi
125 1.2.2.1 uebayasi static ACPI_STATUS
126 1.2.2.1 uebayasi acpi_pcidev_pciroot_bus_callback(ACPI_RESOURCE *res, void *context)
127 1.2.2.1 uebayasi {
128 1.2.2.1 uebayasi ACPI_RESOURCE_ADDRESS64 addr64;
129 1.2.2.1 uebayasi int32_t *bus = context;
130 1.2.2.1 uebayasi
131 1.2.2.1 uebayasi /* Always continue the walk by returning AE_OK. */
132 1.2.2.1 uebayasi if ((res->Type != ACPI_RESOURCE_TYPE_ADDRESS16) &&
133 1.2.2.1 uebayasi (res->Type != ACPI_RESOURCE_TYPE_ADDRESS32) &&
134 1.2.2.1 uebayasi (res->Type != ACPI_RESOURCE_TYPE_ADDRESS64))
135 1.2.2.1 uebayasi return AE_OK;
136 1.2.2.1 uebayasi
137 1.2.2.1 uebayasi if (ACPI_FAILURE(AcpiResourceToAddress64(res, &addr64)))
138 1.2.2.1 uebayasi return AE_OK;
139 1.2.2.1 uebayasi
140 1.2.2.1 uebayasi if (addr64.ResourceType != ACPI_BUS_NUMBER_RANGE)
141 1.2.2.1 uebayasi return AE_OK;
142 1.2.2.1 uebayasi
143 1.2.2.1 uebayasi if (*bus != -1)
144 1.2.2.1 uebayasi return AE_ALREADY_EXISTS;
145 1.2.2.1 uebayasi
146 1.2.2.3 uebayasi if (addr64.Minimum > 0xFFFF)
147 1.2.2.3 uebayasi return AE_BAD_DATA;
148 1.2.2.3 uebayasi
149 1.2.2.3 uebayasi *bus = (int32_t)addr64.Minimum;
150 1.2.2.1 uebayasi
151 1.2.2.1 uebayasi return AE_OK;
152 1.2.2.1 uebayasi }
153 1.2.2.1 uebayasi
154 1.2.2.1 uebayasi /*
155 1.2.2.1 uebayasi * acpi_pcidev_scan:
156 1.2.2.1 uebayasi *
157 1.2.2.1 uebayasi * Scan the ACPI device tree for PCI devices. A node is detected as a
158 1.2.2.1 uebayasi * PCI device if it has an ancestor that is a PCI root bridge and such
159 1.2.2.1 uebayasi * that all intermediate nodes are PCI-to-PCI bridges. Depth-first
160 1.2.2.1 uebayasi * recursive implementation.
161 1.2.2.1 uebayasi */
162 1.2.2.1 uebayasi ACPI_STATUS
163 1.2.2.1 uebayasi acpi_pcidev_scan(struct acpi_devnode *ad)
164 1.2.2.1 uebayasi {
165 1.2.2.1 uebayasi struct acpi_devnode *child;
166 1.2.2.1 uebayasi struct acpi_pci_info *ap;
167 1.2.2.1 uebayasi ACPI_INTEGER val;
168 1.2.2.1 uebayasi ACPI_STATUS rv;
169 1.2.2.1 uebayasi
170 1.2.2.2 uebayasi ad->ad_pciinfo = NULL;
171 1.2.2.2 uebayasi
172 1.2.2.1 uebayasi if (ad->ad_devinfo->Type != ACPI_TYPE_DEVICE ||
173 1.2.2.2 uebayasi !(ad->ad_devinfo->Valid & ACPI_VALID_ADR))
174 1.2.2.2 uebayasi goto rec;
175 1.2.2.2 uebayasi
176 1.2.2.2 uebayasi /*
177 1.2.2.2 uebayasi * We attach PCI information only to devices that are present,
178 1.2.2.2 uebayasi * enabled, and functioning properly.
179 1.2.2.2 uebayasi * Note: there is a possible race condition, because _STA may
180 1.2.2.2 uebayasi * have changed since ad->ad_devinfo->CurrentStatus was set.
181 1.2.2.2 uebayasi */
182 1.2.2.2 uebayasi if ((ad->ad_devinfo->Valid & ACPI_VALID_STA) != 0 &&
183 1.2.2.2 uebayasi (ad->ad_devinfo->CurrentStatus & ACPI_STA_OK) != ACPI_STA_OK)
184 1.2.2.1 uebayasi goto rec;
185 1.2.2.1 uebayasi
186 1.2.2.1 uebayasi if (ad->ad_devinfo->Flags & ACPI_PCI_ROOT_BRIDGE) {
187 1.2.2.1 uebayasi
188 1.2.2.1 uebayasi ap = kmem_zalloc(sizeof(*ap), KM_SLEEP);
189 1.2.2.1 uebayasi
190 1.2.2.1 uebayasi if (ap == NULL)
191 1.2.2.1 uebayasi return AE_NO_MEMORY;
192 1.1 cegger
193 1.1 cegger /*
194 1.2.2.1 uebayasi * If no _SEG exist, all PCI bus segments are assumed
195 1.2.2.1 uebayasi * to be in the PCI segment group 0 (ACPI 4.0, p. 277).
196 1.2.2.1 uebayasi * The segment group number is conveyed in the lower
197 1.2.2.1 uebayasi * 16 bits of _SEG (the other bits are all reserved).
198 1.1 cegger */
199 1.2.2.1 uebayasi rv = acpi_eval_integer(ad->ad_handle, "_SEG", &val);
200 1.2.2.1 uebayasi
201 1.2.2.1 uebayasi if (ACPI_SUCCESS(rv))
202 1.2.2.1 uebayasi ap->ap_segment = ACPI_LOWORD(val);
203 1.2.2.1 uebayasi
204 1.2.2.1 uebayasi /* Try to get bus number using _CRS first. */
205 1.2.2.1 uebayasi rv = acpi_pcidev_pciroot_bus(ad->ad_handle, &ap->ap_bus);
206 1.2.2.1 uebayasi
207 1.2.2.1 uebayasi if (ACPI_FAILURE(rv)) {
208 1.2.2.1 uebayasi rv = acpi_eval_integer(ad->ad_handle, "_BBN", &val);
209 1.2.2.1 uebayasi
210 1.2.2.1 uebayasi if (ACPI_SUCCESS(rv))
211 1.2.2.1 uebayasi ap->ap_bus = ACPI_LOWORD(val);
212 1.2.2.1 uebayasi }
213 1.1 cegger
214 1.2.2.1 uebayasi ap->ap_device = ACPI_HILODWORD(ad->ad_devinfo->Address);
215 1.2.2.1 uebayasi ap->ap_function = ACPI_LOLODWORD(ad->ad_devinfo->Address);
216 1.2.2.1 uebayasi
217 1.2.2.2 uebayasi if (ap->ap_bus > 255 || ap->ap_device > 31 ||
218 1.2.2.3 uebayasi (ap->ap_function > 7 && ap->ap_function != 0xFFFF)) {
219 1.2.2.2 uebayasi aprint_error_dev(ad->ad_root,
220 1.2.2.2 uebayasi "invalid PCI address for %s\n", ad->ad_name);
221 1.2.2.2 uebayasi kmem_free(ap, sizeof(*ap));
222 1.2.2.2 uebayasi goto rec;
223 1.2.2.2 uebayasi }
224 1.2.2.2 uebayasi
225 1.2.2.1 uebayasi ap->ap_bridge = true;
226 1.2.2.1 uebayasi ap->ap_downbus = ap->ap_bus;
227 1.2.2.1 uebayasi
228 1.2.2.1 uebayasi ad->ad_pciinfo = ap;
229 1.2.2.1 uebayasi
230 1.2.2.1 uebayasi goto rec;
231 1.1 cegger }
232 1.1 cegger
233 1.2.2.1 uebayasi if ((ad->ad_parent != NULL) &&
234 1.2.2.1 uebayasi (ad->ad_parent->ad_pciinfo != NULL) &&
235 1.2.2.1 uebayasi (ad->ad_parent->ad_pciinfo->ap_bridge)) {
236 1.2.2.1 uebayasi
237 1.2.2.1 uebayasi /*
238 1.2.2.1 uebayasi * Our parent is a PCI root bridge or a PCI-to-PCI
239 1.2.2.1 uebayasi * bridge. We have the same PCI segment number, and
240 1.2.2.1 uebayasi * our bus number is its downstream bus number.
241 1.2.2.1 uebayasi */
242 1.2.2.1 uebayasi ap = kmem_zalloc(sizeof(*ap), KM_SLEEP);
243 1.1 cegger
244 1.2.2.1 uebayasi if (ap == NULL)
245 1.2.2.1 uebayasi return AE_NO_MEMORY;
246 1.1 cegger
247 1.2.2.1 uebayasi ap->ap_segment = ad->ad_parent->ad_pciinfo->ap_segment;
248 1.2.2.1 uebayasi ap->ap_bus = ad->ad_parent->ad_pciinfo->ap_downbus;
249 1.1 cegger
250 1.2.2.1 uebayasi ap->ap_device = ACPI_HILODWORD(ad->ad_devinfo->Address);
251 1.2.2.1 uebayasi ap->ap_function = ACPI_LOLODWORD(ad->ad_devinfo->Address);
252 1.1 cegger
253 1.2.2.3 uebayasi if (ap->ap_device > 31 ||
254 1.2.2.3 uebayasi (ap->ap_function > 7 && ap->ap_function != 0xFFFF)) {
255 1.2.2.2 uebayasi aprint_error_dev(ad->ad_root,
256 1.2.2.2 uebayasi "invalid PCI address for %s\n", ad->ad_name);
257 1.2.2.2 uebayasi kmem_free(ap, sizeof(*ap));
258 1.2.2.2 uebayasi goto rec;
259 1.2.2.2 uebayasi }
260 1.2.2.2 uebayasi
261 1.2.2.3 uebayasi if (ap->ap_function == 0xFFFF) {
262 1.2.2.3 uebayasi /*
263 1.2.2.3 uebayasi * Assume that this device is not a PCI-to-PCI bridge.
264 1.2.2.3 uebayasi * XXX: Do we need to be smarter?
265 1.2.2.3 uebayasi */
266 1.2.2.3 uebayasi ap->ap_bridge = false;
267 1.2.2.3 uebayasi } else {
268 1.2.2.3 uebayasi /*
269 1.2.2.3 uebayasi * Check whether this device is a PCI-to-PCI
270 1.2.2.3 uebayasi * bridge and get its secondary bus number.
271 1.2.2.3 uebayasi */
272 1.2.2.3 uebayasi rv = acpi_pcidev_ppb_downbus(ap->ap_segment, ap->ap_bus,
273 1.2.2.3 uebayasi ap->ap_device, ap->ap_function, &ap->ap_downbus);
274 1.2.2.3 uebayasi
275 1.2.2.3 uebayasi ap->ap_bridge = (rv != AE_OK) ? false : true;
276 1.2.2.3 uebayasi }
277 1.2.2.1 uebayasi
278 1.2.2.1 uebayasi ad->ad_pciinfo = ap;
279 1.2.2.1 uebayasi
280 1.2.2.1 uebayasi goto rec;
281 1.2.2.1 uebayasi }
282 1.2.2.1 uebayasi
283 1.2.2.1 uebayasi rec:
284 1.2.2.1 uebayasi SIMPLEQ_FOREACH(child, &ad->ad_child_head, ad_child_list) {
285 1.2.2.1 uebayasi rv = acpi_pcidev_scan(child);
286 1.2.2.1 uebayasi
287 1.2.2.1 uebayasi if (ACPI_FAILURE(rv))
288 1.2.2.1 uebayasi return rv;
289 1.2.2.1 uebayasi }
290 1.2.2.1 uebayasi
291 1.2.2.1 uebayasi return AE_OK;
292 1.1 cegger }
293 1.1 cegger
294 1.2.2.1 uebayasi /*
295 1.2.2.1 uebayasi * acpi_pcidev_ppb_downbus:
296 1.2.2.1 uebayasi *
297 1.2.2.1 uebayasi * Retrieve the secondary bus number of the PCI-to-PCI bridge having the
298 1.2.2.2 uebayasi * given PCI id. If successful, return AE_OK and fill *downbus.
299 1.2.2.2 uebayasi * Otherwise, return an exception code and leave *downbus unchanged.
300 1.2.2.1 uebayasi *
301 1.2.2.1 uebayasi * XXX Need to deal with PCI segment groups (see also acpica/OsdHardware.c).
302 1.2.2.1 uebayasi */
303 1.2.2.1 uebayasi ACPI_STATUS
304 1.2.2.1 uebayasi acpi_pcidev_ppb_downbus(uint16_t segment, uint16_t bus, uint16_t device,
305 1.2.2.1 uebayasi uint16_t function, uint16_t *downbus)
306 1.1 cegger {
307 1.2.2.1 uebayasi struct acpi_softc *sc = acpi_softc;
308 1.2.2.1 uebayasi pci_chipset_tag_t pc;
309 1.2.2.1 uebayasi pcitag_t tag;
310 1.2.2.1 uebayasi pcireg_t val;
311 1.2.2.1 uebayasi
312 1.2.2.1 uebayasi if (bus > 255 || device > 31 || function > 7)
313 1.2.2.1 uebayasi return AE_BAD_PARAMETER;
314 1.2.2.1 uebayasi
315 1.2.2.2 uebayasi pc = sc->sc_pc;
316 1.2.2.1 uebayasi
317 1.2.2.1 uebayasi tag = pci_make_tag(pc, bus, device, function);
318 1.1 cegger
319 1.2.2.1 uebayasi /* Check that this device exists. */
320 1.2.2.1 uebayasi val = pci_conf_read(pc, tag, PCI_ID_REG);
321 1.1 cegger
322 1.2.2.1 uebayasi if (PCI_VENDOR(val) == PCI_VENDOR_INVALID ||
323 1.2.2.1 uebayasi PCI_VENDOR(val) == 0)
324 1.2.2.1 uebayasi return AE_NOT_EXIST;
325 1.1 cegger
326 1.2.2.1 uebayasi /* Check that this device is a PCI-to-PCI bridge. */
327 1.2.2.1 uebayasi val = pci_conf_read(pc, tag, PCI_BHLC_REG);
328 1.1 cegger
329 1.2.2.1 uebayasi if (PCI_HDRTYPE_TYPE(val) != PCI_HDRTYPE_PPB)
330 1.2.2.1 uebayasi return AE_TYPE;
331 1.2.2.1 uebayasi
332 1.2.2.1 uebayasi /* This is a PCI-to-PCI bridge. Get its secondary bus#. */
333 1.2.2.1 uebayasi val = pci_conf_read(pc, tag, PPB_REG_BUSINFO);
334 1.2.2.1 uebayasi *downbus = PPB_BUSINFO_SECONDARY(val);
335 1.2.2.1 uebayasi
336 1.2.2.1 uebayasi return AE_OK;
337 1.1 cegger }
338 1.1 cegger
339 1.1 cegger /*
340 1.1 cegger * acpi_pcidev_find:
341 1.1 cegger *
342 1.1 cegger * Finds a PCI device in the ACPI name space.
343 1.2.2.1 uebayasi *
344 1.2.2.1 uebayasi * Returns an ACPI device node on success and NULL on failure.
345 1.1 cegger */
346 1.2.2.1 uebayasi struct acpi_devnode *
347 1.2.2.1 uebayasi acpi_pcidev_find(uint16_t segment, uint16_t bus,
348 1.2.2.1 uebayasi uint16_t device, uint16_t function)
349 1.1 cegger {
350 1.2.2.1 uebayasi struct acpi_softc *sc = acpi_softc;
351 1.2.2.1 uebayasi struct acpi_devnode *ad;
352 1.2.2.1 uebayasi
353 1.2.2.1 uebayasi if (sc == NULL)
354 1.2.2.1 uebayasi return NULL;
355 1.1 cegger
356 1.2.2.1 uebayasi SIMPLEQ_FOREACH(ad, &sc->ad_head, ad_list) {
357 1.1 cegger
358 1.2.2.1 uebayasi if (ad->ad_pciinfo != NULL &&
359 1.2.2.1 uebayasi ad->ad_pciinfo->ap_segment == segment &&
360 1.2.2.1 uebayasi ad->ad_pciinfo->ap_bus == bus &&
361 1.2.2.1 uebayasi ad->ad_pciinfo->ap_device == device &&
362 1.2.2.1 uebayasi ad->ad_pciinfo->ap_function == function)
363 1.2.2.1 uebayasi return ad;
364 1.1 cegger }
365 1.1 cegger
366 1.2.2.1 uebayasi return NULL;
367 1.1 cegger }
368