Home | History | Annotate | Line # | Download | only in pci
pcibios.c revision 1.17
      1 /*	$NetBSD: pcibios.c,v 1.17 2004/04/24 15:09:54 uwe Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1999 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9  * NASA Ames Research Center.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  * 3. All advertising materials mentioning features or use of this software
     20  *    must display the following acknowledgement:
     21  *	This product includes software developed by the NetBSD
     22  *	Foundation, Inc. and its contributors.
     23  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24  *    contributors may be used to endorse or promote products derived
     25  *    from this software without specific prior written permission.
     26  *
     27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37  * POSSIBILITY OF SUCH DAMAGE.
     38  */
     39 
     40 /*
     41  * Copyright (c) 1999, by UCHIYAMA Yasushi
     42  * All rights reserved.
     43  *
     44  * Redistribution and use in source and binary forms, with or without
     45  * modification, are permitted provided that the following conditions
     46  * are met:
     47  * 1. Redistributions of source code must retain the above copyright
     48  *    notice, this list of conditions and the following disclaimer.
     49  * 2. The name of the developer may NOT be used to endorse or promote products
     50  *    derived from this software without specific prior written permission.
     51  *
     52  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     53  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     54  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     55  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     56  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     57  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     58  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     59  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     60  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     61  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     62  * SUCH DAMAGE.
     63  */
     64 
     65 /*
     66  * Interface to the PCI BIOS and PCI Interrupt Routing table.
     67  */
     68 
     69 #include <sys/cdefs.h>
     70 __KERNEL_RCSID(0, "$NetBSD: pcibios.c,v 1.17 2004/04/24 15:09:54 uwe Exp $");
     71 
     72 #include "opt_pcibios.h"
     73 
     74 #include <sys/param.h>
     75 #include <sys/systm.h>
     76 #include <sys/device.h>
     77 #include <sys/malloc.h>
     78 
     79 #include <dev/isa/isareg.h>
     80 #include <machine/isa_machdep.h>
     81 
     82 #include <dev/pci/pcireg.h>
     83 #include <dev/pci/pcivar.h>
     84 #include <dev/pci/pcidevs.h>
     85 
     86 #include <i386/pci/pcibios.h>
     87 #ifdef PCIBIOS_INTR_FIXUP
     88 #include <i386/pci/pci_intr_fixup.h>
     89 #endif
     90 #ifdef PCIBIOS_BUS_FIXUP
     91 #include <i386/pci/pci_bus_fixup.h>
     92 #endif
     93 #ifdef PCIBIOS_ADDR_FIXUP
     94 #include <i386/pci/pci_addr_fixup.h>
     95 #endif
     96 
     97 #include <machine/bios32.h>
     98 
     99 #ifdef PCIBIOSVERBOSE
    100 int	pcibiosverbose = 1;
    101 #endif
    102 
    103 int pcibios_present;
    104 
    105 struct pcibios_pir_header pcibios_pir_header;
    106 struct pcibios_intr_routing *pcibios_pir_table;
    107 int pcibios_pir_table_nentries;
    108 int pcibios_max_bus;
    109 
    110 struct bios32_entry pcibios_entry;
    111 
    112 void	pcibios_pir_init(void);
    113 
    114 int	pcibios_get_status(u_int32_t *, u_int32_t *, u_int32_t *,
    115 	    u_int32_t *, u_int32_t *, u_int32_t *, u_int32_t *);
    116 int	pcibios_get_intr_routing(struct pcibios_intr_routing *,
    117 	    int *, u_int16_t *);
    118 
    119 int	pcibios_return_code(u_int16_t, const char *);
    120 
    121 void	pcibios_print_exclirq(void);
    122 #ifdef PCIINTR_DEBUG
    123 void	pcibios_print_pir_table(void);
    124 #endif
    125 
    126 #define	PCI_IRQ_TABLE_START	0xf0000
    127 #define	PCI_IRQ_TABLE_END	0xfffff
    128 
    129 static void pci_bridge_hook(pci_chipset_tag_t, pcitag_t, void *);
    130 struct pci_bridge_hook_arg {
    131 	void (*func)(pci_chipset_tag_t, pcitag_t, void *);
    132 	void *arg;
    133 };
    134 
    135 void
    136 pcibios_init()
    137 {
    138 	struct bios32_entry_info ei;
    139 	u_int32_t rev_maj, rev_min, mech1, mech2, scmech1, scmech2;
    140 
    141 	if (bios32_service(BIOS32_MAKESIG('$', 'P', 'C', 'I'),
    142 	    &pcibios_entry, &ei) == 0) {
    143 		/*
    144 		 * No PCI BIOS found; will fall back on old
    145 		 * mechanism.
    146 		 */
    147 		return;
    148 	}
    149 
    150 	/*
    151 	 * We've located the PCI BIOS service; get some information
    152 	 * about it.
    153 	 */
    154 	if (pcibios_get_status(&rev_maj, &rev_min, &mech1, &mech2,
    155 	    &scmech1, &scmech2, &pcibios_max_bus) != PCIBIOS_SUCCESS) {
    156 		/*
    157 		 * We can't use the PCI BIOS; will fall back on old
    158 		 * mechanism.
    159 		 */
    160 		return;
    161 	}
    162 
    163 	printf("PCI BIOS rev. %d.%d found at 0x%lx\n", rev_maj, rev_min >> 4,
    164 	    ei.bei_entry);
    165 #ifdef PCIBIOSVERBOSE
    166 	printf("pcibios: config mechanism %s%s, special cycles %s%s, "
    167 	    "last bus %d\n",
    168 	    mech1 ? "[1]" : "[x]",
    169 	    mech2 ? "[2]" : "[x]",
    170 	    scmech1 ? "[1]" : "[x]",
    171 	    scmech2 ? "[2]" : "[x]",
    172 	    pcibios_max_bus);
    173 
    174 #endif
    175 
    176 	/*
    177 	 * The PCI BIOS tells us the config mechanism; fill it in now
    178 	 * so that pci_mode_detect() doesn't have to look for it.
    179 	 */
    180 	pci_mode = mech1 ? 1 : 2;
    181 
    182 	pcibios_present = 1;
    183 
    184 	/*
    185 	 * Find the PCI IRQ Routing table.
    186 	 */
    187 	pcibios_pir_init();
    188 
    189 #ifdef PCIBIOS_INTR_FIXUP
    190 	if (pcibios_pir_table != NULL) {
    191 		int rv;
    192 		u_int16_t pciirq;
    193 
    194 		/*
    195 		 * Fixup interrupt routing.
    196 		 */
    197 		rv = pci_intr_fixup(NULL, X86_BUS_SPACE_IO, &pciirq);
    198 		switch (rv) {
    199 		case -1:
    200 			/* Non-fatal error. */
    201 			printf("Warning: unable to fix up PCI interrupt "
    202 			    "routing\n");
    203 			break;
    204 
    205 		case 1:
    206 			/* Fatal error. */
    207 			panic("pcibios_init: interrupt fixup failed");
    208 			break;
    209 		}
    210 
    211 		/*
    212 		 * XXX Clear `pciirq' from the ISA interrupt allocation
    213 		 * XXX mask.
    214 		 */
    215 	}
    216 #endif
    217 
    218 #ifdef PCIBIOS_BUS_FIXUP
    219 	pcibios_max_bus = pci_bus_fixup(NULL, 0);
    220 #ifdef PCIBIOSVERBOSE
    221 	printf("PCI bus #%d is the last bus\n", pcibios_max_bus);
    222 #endif
    223 #endif
    224 
    225 #ifdef PCIBIOS_ADDR_FIXUP
    226 	pci_addr_fixup(NULL, pcibios_max_bus);
    227 #endif
    228 }
    229 
    230 void
    231 pcibios_pir_init()
    232 {
    233 	char devinfo[256];
    234 	paddr_t pa;
    235 	caddr_t p;
    236 	unsigned char cksum;
    237 	u_int16_t tablesize;
    238 	u_int8_t rev_maj, rev_min;
    239 	int i;
    240 
    241 	for (pa = PCI_IRQ_TABLE_START; pa < PCI_IRQ_TABLE_END; pa += 16) {
    242 		p = (caddr_t)ISA_HOLE_VADDR(pa);
    243 		if (*(int *)p != BIOS32_MAKESIG('$', 'P', 'I', 'R')) {
    244 			/*
    245 			 * XXX: Some laptops (Toshiba/Libretto L series)
    246 			 * use _PIR instead of $PIR. So we try that too.
    247 			 */
    248 			if (*(int *)p != BIOS32_MAKESIG('_', 'P', 'I', 'R'))
    249 				continue;
    250 		}
    251 
    252 		rev_min = *(p + 4);
    253 		rev_maj = *(p + 5);
    254 		tablesize = *(u_int16_t *)(p + 6);
    255 
    256 		cksum = 0;
    257 		for (i = 0; i < tablesize; i++)
    258 			cksum += *(unsigned char *)(p + i);
    259 
    260 		printf("PCI IRQ Routing Table rev. %d.%d found at 0x%lx, "
    261 		    "size %d bytes (%d entries)\n", rev_maj, rev_min, pa,
    262 		    tablesize, (tablesize - 32) / 16);
    263 
    264 		if (cksum != 0) {
    265 			printf("pcibios_pir_init: bad IRQ table checksum\n");
    266 			continue;
    267 		}
    268 
    269 		if (tablesize < 32 || (tablesize % 16) != 0) {
    270 			printf("pcibios_pir_init: bad IRQ table size\n");
    271 			continue;
    272 		}
    273 
    274 		if (rev_maj != 1 || rev_min != 0) {
    275 			printf("pcibios_pir_init: unsupported IRQ table "
    276 			    "version\n");
    277 			continue;
    278 		}
    279 
    280 		/*
    281 		 * We can handle this table!  Make a copy of it.
    282 		 */
    283 		memcpy(&pcibios_pir_header, p, 32);
    284 		pcibios_pir_table = malloc(tablesize - 32, M_DEVBUF,
    285 		    M_NOWAIT);
    286 		if (pcibios_pir_table == NULL) {
    287 			printf("pcibios_pir_init: no memory for $PIR\n");
    288 			return;
    289 		}
    290 		memcpy(pcibios_pir_table, p + 32, tablesize - 32);
    291 		pcibios_pir_table_nentries = (tablesize - 32) / 16;
    292 
    293 		printf("PCI Interrupt Router at %03d:%02d:%01d",
    294 		    pcibios_pir_header.router_bus,
    295 		    PIR_DEVFUNC_DEVICE(pcibios_pir_header.router_devfunc),
    296 		    PIR_DEVFUNC_FUNCTION(pcibios_pir_header.router_devfunc));
    297 		if (pcibios_pir_header.compat_router != 0) {
    298 			pci_devinfo(pcibios_pir_header.compat_router, 0, 0,
    299 			    devinfo, sizeof(devinfo));
    300 			printf(" (%s compatible)", devinfo);
    301 		}
    302 		printf("\n");
    303 		pcibios_print_exclirq();
    304 #ifdef PCIINTR_DEBUG
    305 		pcibios_print_pir_table();
    306 #endif
    307 		return;
    308 	}
    309 
    310 	/*
    311 	 * If there was no PIR table found, try using the PCI BIOS
    312 	 * Get Interrupt Routing call.
    313 	 *
    314 	 * XXX The interface to this call sucks; just allocate enough
    315 	 * XXX room for 32 entries.
    316 	 */
    317 	pcibios_pir_table_nentries = 32;
    318 	pcibios_pir_table = malloc(pcibios_pir_table_nentries *
    319 	    sizeof(*pcibios_pir_table), M_DEVBUF, M_NOWAIT);
    320 	if (pcibios_pir_table == NULL) {
    321 		printf("pcibios_pir_init: no memory for $PIR\n");
    322 		return;
    323 	}
    324 	if (pcibios_get_intr_routing(pcibios_pir_table,
    325 	    &pcibios_pir_table_nentries,
    326 	    &pcibios_pir_header.exclusive_irq) != PCIBIOS_SUCCESS) {
    327 		printf("No PCI IRQ Routing information available.\n");
    328 		free(pcibios_pir_table, M_DEVBUF);
    329 		pcibios_pir_table = NULL;
    330 		pcibios_pir_table_nentries = 0;
    331 		return;
    332 	}
    333 	printf("PCI BIOS has %d Interrupt Routing table entries\n",
    334 	    pcibios_pir_table_nentries);
    335 	pcibios_print_exclirq();
    336 #ifdef PCIINTR_DEBUG
    337 	pcibios_print_pir_table();
    338 #endif
    339 }
    340 
    341 int
    342 pcibios_get_status(u_int32_t *rev_maj, u_int32_t *rev_min,
    343     u_int32_t *mech1, u_int32_t *mech2, u_int32_t *scmech1, u_int32_t *scmech2,
    344     u_int32_t *maxbus)
    345 {
    346 	u_int16_t ax, bx, cx;
    347 	u_int32_t edx;
    348 	int rv;
    349 
    350 	__asm __volatile("lcall *(%%edi)				; \
    351 			jc 1f						; \
    352 			xor %%ah, %%ah					; \
    353 		1:"
    354 		: "=a" (ax), "=b" (bx), "=c" (cx), "=d" (edx)
    355 		: "0" (0xb101), "D" (&pcibios_entry));
    356 
    357 	rv = pcibios_return_code(ax, "pcibios_get_status");
    358 	if (rv != PCIBIOS_SUCCESS)
    359 		return (rv);
    360 
    361 	if (edx != BIOS32_MAKESIG('P', 'C', 'I', ' '))
    362 		return (PCIBIOS_SERVICE_NOT_PRESENT);	/* XXX */
    363 
    364 	/*
    365 	 * Fill in the various pieces if info we're looking for.
    366 	 */
    367 	*mech1 = ax & 1;
    368 	*mech2 = ax & (1 << 1);
    369 	*scmech1 = ax & (1 << 4);
    370 	*scmech2 = ax & (1 << 5);
    371 	*rev_maj = (bx >> 8) & 0xff;
    372 	*rev_min = bx & 0xff;
    373 	*maxbus = cx & 0xff;
    374 
    375 	return (PCIBIOS_SUCCESS);
    376 }
    377 
    378 int
    379 pcibios_get_intr_routing(struct pcibios_intr_routing *table,
    380     int *nentries, u_int16_t *exclirq)
    381 {
    382 	u_int16_t ax, bx;
    383 	int rv;
    384 	struct {
    385 		u_int16_t size;
    386 		caddr_t offset;
    387 		u_int16_t segment;
    388 	} __attribute__((__packed__)) args;
    389 
    390 	args.size = *nentries * sizeof(*table);
    391 	args.offset = (caddr_t)table;
    392 	args.segment = GSEL(GDATA_SEL, SEL_KPL);
    393 
    394 	memset(table, 0, args.size);
    395 
    396 	__asm __volatile("lcall *(%%esi)				; \
    397 			jc 1f						; \
    398 			xor %%ah, %%ah					; \
    399 		1:	movw %w2, %%ds					; \
    400 			movw %w2, %%es"
    401 		: "=a" (ax), "=b" (bx)
    402 		: "r" GSEL(GDATA_SEL, SEL_KPL), "0" (0xb10e), "1" (0),
    403 		  "D" (&args), "S" (&pcibios_entry));
    404 
    405 	rv = pcibios_return_code(ax, "pcibios_get_intr_routing");
    406 	if (rv != PCIBIOS_SUCCESS)
    407 		return (rv);
    408 
    409 	*nentries = args.size / sizeof(*table);
    410 	*exclirq = bx;
    411 
    412 	return (PCIBIOS_SUCCESS);
    413 }
    414 
    415 int
    416 pcibios_return_code(u_int16_t ax, const char *func)
    417 {
    418 	const char *errstr;
    419 	int rv = ax >> 8;
    420 
    421 	switch (rv) {
    422 	case PCIBIOS_SUCCESS:
    423 		return (PCIBIOS_SUCCESS);
    424 
    425 	case PCIBIOS_SERVICE_NOT_PRESENT:
    426 		errstr = "service not present";
    427 		break;
    428 
    429 	case PCIBIOS_FUNCTION_NOT_SUPPORTED:
    430 		errstr = "function not supported";
    431 		break;
    432 
    433 	case PCIBIOS_BAD_VENDOR_ID:
    434 		errstr = "bad vendor ID";
    435 		break;
    436 
    437 	case PCIBIOS_DEVICE_NOT_FOUND:
    438 		errstr = "device not found";
    439 		break;
    440 
    441 	case PCIBIOS_BAD_REGISTER_NUMBER:
    442 		errstr = "bad register number";
    443 		break;
    444 
    445 	case PCIBIOS_SET_FAILED:
    446 		errstr = "set failed";
    447 		break;
    448 
    449 	case PCIBIOS_BUFFER_TOO_SMALL:
    450 		errstr = "buffer too small";
    451 		break;
    452 
    453 	default:
    454 		printf("%s: unknown return code 0x%x\n", func, rv);
    455 		return (rv);
    456 	}
    457 
    458 	printf("%s: %s\n", func, errstr);
    459 	return (rv);
    460 }
    461 
    462 void
    463 pcibios_print_exclirq()
    464 {
    465 	int i;
    466 
    467 	if (pcibios_pir_header.exclusive_irq) {
    468 		printf("PCI Exclusive IRQs:");
    469 		for (i = 0; i < 16; i++) {
    470 			if (pcibios_pir_header.exclusive_irq & (1 << i))
    471 				printf(" %d", i);
    472 		}
    473 		printf("\n");
    474 	}
    475 }
    476 
    477 #ifdef PCIINTR_DEBUG
    478 void
    479 pcibios_print_pir_table()
    480 {
    481 	int i, j;
    482 
    483 	for (i = 0; i < pcibios_pir_table_nentries; i++) {
    484 		printf("PIR Entry %d:\n", i);
    485 		printf("\tBus: %d  Device: %d\n",
    486 		    pcibios_pir_table[i].bus,
    487 		    PIR_DEVFUNC_DEVICE(pcibios_pir_table[i].device));
    488 		for (j = 0; j < 4; j++) {
    489 			printf("\t\tINT%c: link 0x%02x bitmap 0x%04x\n",
    490 			    'A' + j,
    491 			    pcibios_pir_table[i].linkmap[j].link,
    492 			    pcibios_pir_table[i].linkmap[j].bitmap);
    493 		}
    494 	}
    495 }
    496 #endif
    497 
    498 void
    499 pci_device_foreach(pci_chipset_tag_t pc, int maxbus,
    500     void (*func)(pci_chipset_tag_t, pcitag_t, void *), void *context)
    501 {
    502 	pci_device_foreach_min(pc, 0, maxbus, func, context);
    503 }
    504 
    505 void
    506 pci_device_foreach_min(pci_chipset_tag_t pc, int minbus, int maxbus,
    507     void (*func)(pci_chipset_tag_t, pcitag_t, void *), void *context)
    508 {
    509 	const struct pci_quirkdata *qd;
    510 	int bus, device, function, maxdevs, nfuncs;
    511 	pcireg_t id, bhlcr;
    512 	pcitag_t tag;
    513 
    514 	for (bus = minbus; bus <= maxbus; bus++) {
    515 		maxdevs = pci_bus_maxdevs(pc, bus);
    516 		for (device = 0; device < maxdevs; device++) {
    517 			tag = pci_make_tag(pc, bus, device, 0);
    518 			id = pci_conf_read(pc, tag, PCI_ID_REG);
    519 
    520 			/* Invalid vendor ID value? */
    521 			if (PCI_VENDOR(id) == PCI_VENDOR_INVALID)
    522 				continue;
    523 			/* XXX Not invalid, but we've done this ~forever. */
    524 			if (PCI_VENDOR(id) == 0)
    525 				continue;
    526 
    527 			qd = pci_lookup_quirkdata(PCI_VENDOR(id),
    528 			    PCI_PRODUCT(id));
    529 
    530 			bhlcr = pci_conf_read(pc, tag, PCI_BHLC_REG);
    531 			if (PCI_HDRTYPE_MULTIFN(bhlcr) ||
    532 			    (qd != NULL &&
    533 			     (qd->quirks & PCI_QUIRK_MULTIFUNCTION) != 0))
    534 				nfuncs = 8;
    535 			else
    536 				nfuncs = 1;
    537 
    538 			for (function = 0; function < nfuncs; function++) {
    539 				tag = pci_make_tag(pc, bus, device, function);
    540 				id = pci_conf_read(pc, tag, PCI_ID_REG);
    541 
    542 				/* Invalid vendor ID value? */
    543 				if (PCI_VENDOR(id) == PCI_VENDOR_INVALID)
    544 					continue;
    545 				/*
    546 				 * XXX Not invalid, but we've done this
    547 				 * ~forever.
    548 				 */
    549 				if (PCI_VENDOR(id) == 0)
    550 					continue;
    551 				(*func)(pc, tag, context);
    552 			}
    553 		}
    554 	}
    555 }
    556 
    557 void
    558 pci_bridge_foreach(pci_chipset_tag_t pc, int minbus, int maxbus,
    559     void (*func)(pci_chipset_tag_t, pcitag_t, void *), void *ctx)
    560 {
    561 	struct pci_bridge_hook_arg bridge_hook;
    562 
    563 	bridge_hook.func = func;
    564 	bridge_hook.arg = ctx;
    565 
    566 	pci_device_foreach_min(pc, minbus, maxbus, pci_bridge_hook,
    567 	    &bridge_hook);
    568 }
    569 
    570 void
    571 pci_bridge_hook(pci_chipset_tag_t pc, pcitag_t tag, void *ctx)
    572 {
    573 	struct pci_bridge_hook_arg *bridge_hook = (void *)ctx;
    574 	pcireg_t reg;
    575 
    576 	reg = pci_conf_read(pc, tag, PCI_CLASS_REG);
    577 	if (PCI_CLASS(reg) == PCI_CLASS_BRIDGE &&
    578 	    (PCI_SUBCLASS(reg) == PCI_SUBCLASS_BRIDGE_PCI ||
    579 		PCI_SUBCLASS(reg) == PCI_SUBCLASS_BRIDGE_CARDBUS)) {
    580 		(*bridge_hook->func)(pc, tag, bridge_hook->arg);
    581 	}
    582 }
    583