|
Packit |
7d1034 |
/*
|
|
Packit |
7d1034 |
* (C) Copyright IBM Corporation 2006
|
|
Packit |
7d1034 |
* All Rights Reserved.
|
|
Packit |
7d1034 |
*
|
|
Packit |
7d1034 |
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
Packit |
7d1034 |
* copy of this software and associated documentation files (the "Software"),
|
|
Packit |
7d1034 |
* to deal in the Software without restriction, including without limitation
|
|
Packit |
7d1034 |
* on the rights to use, copy, modify, merge, publish, distribute, sub
|
|
Packit |
7d1034 |
* license, and/or sell copies of the Software, and to permit persons to whom
|
|
Packit |
7d1034 |
* the Software is furnished to do so, subject to the following conditions:
|
|
Packit |
7d1034 |
*
|
|
Packit |
7d1034 |
* The above copyright notice and this permission notice (including the next
|
|
Packit |
7d1034 |
* paragraph) shall be included in all copies or substantial portions of the
|
|
Packit |
7d1034 |
* Software.
|
|
Packit |
7d1034 |
*
|
|
Packit |
7d1034 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
Packit |
7d1034 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
Packit |
7d1034 |
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
|
Packit |
7d1034 |
* IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
Packit |
7d1034 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
Packit |
7d1034 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
Packit |
7d1034 |
* DEALINGS IN THE SOFTWARE.
|
|
Packit |
7d1034 |
*/
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
/**
|
|
Packit |
7d1034 |
* \file common_bridge.c
|
|
Packit |
7d1034 |
* Support routines used to process PCI header information for bridges.
|
|
Packit |
7d1034 |
*
|
|
Packit |
7d1034 |
* \author Ian Romanick <idr@us.ibm.com>
|
|
Packit |
7d1034 |
*/
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
7d1034 |
#include "config.h"
|
|
Packit |
7d1034 |
#endif
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
#include <stdio.h>
|
|
Packit |
7d1034 |
#include <stdlib.h>
|
|
Packit |
7d1034 |
#include <ctype.h>
|
|
Packit |
7d1034 |
#include <errno.h>
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
#if defined(HAVE_STRING_H)
|
|
Packit |
7d1034 |
# include <string.h>
|
|
Packit |
7d1034 |
#elif defined(HAVE_STRINGS_H)
|
|
Packit |
7d1034 |
# include <strings.h>
|
|
Packit |
7d1034 |
#endif
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
#if defined(HAVE_INTTYPES_H)
|
|
Packit |
7d1034 |
# include <inttypes.h>
|
|
Packit |
7d1034 |
#elif defined(HAVE_STDINT_H)
|
|
Packit |
7d1034 |
# include <stdint.h>
|
|
Packit |
7d1034 |
#endif
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
#include "pciaccess.h"
|
|
Packit |
7d1034 |
#include "pciaccess_private.h"
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
static int
|
|
Packit |
7d1034 |
read_bridge_info( struct pci_device_private * priv )
|
|
Packit |
7d1034 |
{
|
|
Packit |
7d1034 |
uint8_t buf[0x40];
|
|
Packit |
7d1034 |
pciaddr_t bytes;
|
|
Packit |
7d1034 |
int err;
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
/* Make sure the device has been probed. If not, header_type won't be
|
|
Packit |
7d1034 |
* set and the rest of this function will fail.
|
|
Packit |
7d1034 |
*/
|
|
Packit |
7d1034 |
err = pci_device_probe(& priv->base);
|
|
Packit |
7d1034 |
if (err) {
|
|
Packit |
7d1034 |
return err;
|
|
Packit |
7d1034 |
}
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
switch ( priv->header_type & 0x7f ) {
|
|
Packit |
7d1034 |
case 0x00:
|
|
Packit |
7d1034 |
break;
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
case 0x01: {
|
|
Packit |
7d1034 |
struct pci_bridge_info *info;
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
info = malloc(sizeof(*info));
|
|
Packit |
7d1034 |
if (info != NULL) {
|
|
Packit |
7d1034 |
pci_device_cfg_read( (struct pci_device *) priv, buf + 0x18, 0x18,
|
|
Packit |
7d1034 |
0x40 - 0x18, & bytes );
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
info->primary_bus = buf[0x18];
|
|
Packit |
7d1034 |
info->secondary_bus = buf[0x19];
|
|
Packit |
7d1034 |
info->subordinate_bus = buf[0x1a];
|
|
Packit |
7d1034 |
info->secondary_latency_timer = buf[0x1b];
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
info->io_type = buf[0x1c] & 0x0f;
|
|
Packit |
7d1034 |
info->io_base = (((uint32_t) (buf[0x1c] & 0x0f0)) << 8)
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x30]) << 16)
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x31]) << 24);
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
info->io_limit = 0x00000fff
|
|
Packit |
7d1034 |
+ (((uint32_t) (buf[0x1d] & 0x0f0)) << 8)
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x32]) << 16)
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x33]) << 24);
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
info->mem_type = buf[0x20] & 0x0f;
|
|
Packit |
7d1034 |
info->mem_base = (((uint32_t) (buf[0x20] & 0x0f0)) << 16)
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x21]) << 24);
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
info->mem_limit = 0x0000ffff
|
|
Packit |
7d1034 |
+ (((uint32_t) (buf[0x22] & 0x0f0)) << 16)
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x23]) << 24);
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
info->prefetch_mem_type = buf[0x24] & 0x0f;
|
|
Packit |
7d1034 |
info->prefetch_mem_base = (((uint64_t) (buf[0x24] & 0x0f0)) << 16)
|
|
Packit |
7d1034 |
+ (((uint64_t) buf[0x25]) << 24)
|
|
Packit |
7d1034 |
+ (((uint64_t) buf[0x28]) << 32)
|
|
Packit |
7d1034 |
+ (((uint64_t) buf[0x29]) << 40)
|
|
Packit |
7d1034 |
+ (((uint64_t) buf[0x2a]) << 48)
|
|
Packit |
7d1034 |
+ (((uint64_t) buf[0x2b]) << 56);
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
info->prefetch_mem_limit = 0x0000ffff
|
|
Packit |
7d1034 |
+ (((uint64_t) (buf[0x26] & 0x0f0)) << 16)
|
|
Packit |
7d1034 |
+ (((uint64_t) buf[0x27]) << 24)
|
|
Packit |
7d1034 |
+ (((uint64_t) buf[0x2c]) << 32)
|
|
Packit |
7d1034 |
+ (((uint64_t) buf[0x2d]) << 40)
|
|
Packit |
7d1034 |
+ (((uint64_t) buf[0x2e]) << 48)
|
|
Packit |
7d1034 |
+ (((uint64_t) buf[0x2f]) << 56);
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
info->bridge_control = ((uint16_t) buf[0x3e])
|
|
Packit |
7d1034 |
+ (((uint16_t) buf[0x3f]) << 8);
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
info->secondary_status = ((uint16_t) buf[0x1e])
|
|
Packit |
7d1034 |
+ (((uint16_t) buf[0x1f]) << 8);
|
|
Packit |
7d1034 |
}
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
priv->bridge.pci = info;
|
|
Packit |
7d1034 |
break;
|
|
Packit |
7d1034 |
}
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
case 0x02: {
|
|
Packit |
7d1034 |
struct pci_pcmcia_bridge_info *info;
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
info = malloc(sizeof(*info));
|
|
Packit |
7d1034 |
if (info != NULL) {
|
|
Packit |
7d1034 |
pci_device_cfg_read( (struct pci_device *) priv, buf + 0x16, 0x16,
|
|
Packit |
7d1034 |
0x40 - 0x16, & bytes );
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
info->primary_bus = buf[0x18];
|
|
Packit |
7d1034 |
info->card_bus = buf[0x19];
|
|
Packit |
7d1034 |
info->subordinate_bus = buf[0x1a];
|
|
Packit |
7d1034 |
info->cardbus_latency_timer = buf[0x1b];
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
info->mem[0].base = (((uint32_t) buf[0x1c]))
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x1d]) << 8)
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x1e]) << 16)
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x1f]) << 24);
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
info->mem[0].limit = (((uint32_t) buf[0x20]))
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x21]) << 8)
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x22]) << 16)
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x23]) << 24);
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
info->mem[1].base = (((uint32_t) buf[0x24]))
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x25]) << 8)
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x26]) << 16)
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x27]) << 24);
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
info->mem[1].limit = (((uint32_t) buf[0x28]))
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x29]) << 8)
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x2a]) << 16)
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x2b]) << 24);
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
info->io[0].base = (((uint32_t) buf[0x2c]))
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x2d]) << 8)
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x2e]) << 16)
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x2f]) << 24);
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
info->io[0].limit = (((uint32_t) buf[0x30]))
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x31]) << 8)
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x32]) << 16)
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x33]) << 24);
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
info->io[1].base = (((uint32_t) buf[0x34]))
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x35]) << 8)
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x36]) << 16)
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x37]) << 24);
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
info->io[1].limit = (((uint32_t) buf[0x38]))
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x39]) << 8)
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x3a]) << 16)
|
|
Packit |
7d1034 |
+ (((uint32_t) buf[0x3b]) << 24);
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
info->secondary_status = ((uint16_t) buf[0x16])
|
|
Packit |
7d1034 |
+ (((uint16_t) buf[0x17]) << 8);
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
info->bridge_control = ((uint16_t) buf[0x3e])
|
|
Packit |
7d1034 |
+ (((uint16_t) buf[0x3f]) << 8);
|
|
Packit |
7d1034 |
}
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
priv->bridge.pcmcia = info;
|
|
Packit |
7d1034 |
break;
|
|
Packit |
7d1034 |
}
|
|
Packit |
7d1034 |
}
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
return 0;
|
|
Packit |
7d1034 |
}
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
/**
|
|
Packit |
7d1034 |
* Get the PCI bridge information for a device
|
|
Packit |
7d1034 |
*
|
|
Packit |
7d1034 |
* \returns
|
|
Packit |
7d1034 |
* If \c dev is a PCI-to-PCI bridge, a pointer to a \c pci_bridge_info
|
|
Packit |
7d1034 |
* structure. Otherwise, \c NULL is returned.
|
|
Packit |
7d1034 |
*/
|
|
Packit |
7d1034 |
const struct pci_bridge_info *
|
|
Packit |
7d1034 |
pci_device_get_bridge_info( struct pci_device * dev )
|
|
Packit |
7d1034 |
{
|
|
Packit |
7d1034 |
struct pci_device_private * priv = (struct pci_device_private *) dev;
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
if (priv->bridge.pci == NULL) {
|
|
Packit |
7d1034 |
read_bridge_info(priv);
|
|
Packit |
7d1034 |
}
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
return (priv->header_type == 1) ? priv->bridge.pci : NULL;
|
|
Packit |
7d1034 |
}
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
/**
|
|
Packit |
7d1034 |
* Get the PCMCIA bridge information for a device
|
|
Packit |
7d1034 |
*
|
|
Packit |
7d1034 |
* \returns
|
|
Packit |
7d1034 |
* If \c dev is a PCI-to-PCMCIA bridge, a pointer to a
|
|
Packit |
7d1034 |
* \c pci_pcmcia_bridge_info structure. Otherwise, \c NULL is returned.
|
|
Packit |
7d1034 |
*/
|
|
Packit |
7d1034 |
const struct pci_pcmcia_bridge_info *
|
|
Packit |
7d1034 |
pci_device_get_pcmcia_bridge_info( struct pci_device * dev )
|
|
Packit |
7d1034 |
{
|
|
Packit |
7d1034 |
struct pci_device_private * priv = (struct pci_device_private *) dev;
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
if (priv->bridge.pcmcia == NULL) {
|
|
Packit |
7d1034 |
read_bridge_info(priv);
|
|
Packit |
7d1034 |
}
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
return (priv->header_type == 2) ? priv->bridge.pcmcia : NULL;
|
|
Packit |
7d1034 |
}
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
/**
|
|
Packit |
7d1034 |
* Determine the primary, secondary, and subordinate buses for a bridge
|
|
Packit |
7d1034 |
*
|
|
Packit |
7d1034 |
* Determines the IDs of the primary, secondary, and subordinate buses for
|
|
Packit |
7d1034 |
* a specified bridge. Not all bridges directly store this information
|
|
Packit |
7d1034 |
* (e.g., PCI-to-ISA bridges). For those bridges, no error is returned, but
|
|
Packit |
7d1034 |
* -1 is stored in the bus IDs that don't make sense.
|
|
Packit |
7d1034 |
*
|
|
Packit |
7d1034 |
* For example, for a PCI-to-ISA bridge, \c primary_bus will be set to the ID
|
|
Packit |
7d1034 |
* of the bus containing the device and both \c secondary_bus and
|
|
Packit |
7d1034 |
* \c subordinate_bus will be set to -1.
|
|
Packit |
7d1034 |
*
|
|
Packit |
7d1034 |
* \return
|
|
Packit |
7d1034 |
* On success, zero is returned. If \c dev is not a bridge, \c ENODEV is
|
|
Packit |
7d1034 |
* returned.
|
|
Packit |
7d1034 |
*
|
|
Packit |
7d1034 |
* \bug
|
|
Packit |
7d1034 |
* Host bridges are handled the same way as PCI-to-ISA bridges. This is
|
|
Packit |
7d1034 |
* almost certainly not correct.
|
|
Packit |
7d1034 |
*/
|
|
Packit |
7d1034 |
int
|
|
Packit |
7d1034 |
pci_device_get_bridge_buses(struct pci_device * dev, int *primary_bus,
|
|
Packit |
7d1034 |
int *secondary_bus, int *subordinate_bus)
|
|
Packit |
7d1034 |
{
|
|
Packit |
7d1034 |
struct pci_device_private * priv = (struct pci_device_private *) dev;
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
/* If the device isn't a bridge, return an error.
|
|
Packit |
7d1034 |
*/
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
if (((dev->device_class >> 16) & 0x0ff) != 0x06) {
|
|
Packit |
7d1034 |
return ENODEV;
|
|
Packit |
7d1034 |
}
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
switch ((dev->device_class >> 8) & 0x0ff) {
|
|
Packit |
7d1034 |
case 0x00:
|
|
Packit |
7d1034 |
/* What to do for host bridges? I'm pretty sure this isn't right.
|
|
Packit |
7d1034 |
*/
|
|
Packit |
7d1034 |
*primary_bus = dev->bus;
|
|
Packit |
7d1034 |
*secondary_bus = -1;
|
|
Packit |
7d1034 |
*subordinate_bus = -1;
|
|
Packit |
7d1034 |
break;
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
case 0x01:
|
|
Packit |
7d1034 |
case 0x02:
|
|
Packit |
7d1034 |
case 0x03:
|
|
Packit |
7d1034 |
*primary_bus = dev->bus;
|
|
Packit |
7d1034 |
*secondary_bus = -1;
|
|
Packit |
7d1034 |
*subordinate_bus = -1;
|
|
Packit |
7d1034 |
break;
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
case 0x04:
|
|
Packit |
7d1034 |
if (priv->bridge.pci == NULL)
|
|
Packit |
7d1034 |
read_bridge_info(priv);
|
|
Packit |
7d1034 |
if ((priv->header_type & 0x7f) == 0x01) {
|
|
Packit |
7d1034 |
*primary_bus = priv->bridge.pci->primary_bus;
|
|
Packit |
7d1034 |
*secondary_bus = priv->bridge.pci->secondary_bus;
|
|
Packit |
7d1034 |
*subordinate_bus = priv->bridge.pci->subordinate_bus;
|
|
Packit |
7d1034 |
} else {
|
|
Packit |
7d1034 |
*primary_bus = dev->bus;
|
|
Packit |
7d1034 |
*secondary_bus = -1;
|
|
Packit |
7d1034 |
*subordinate_bus = -1;
|
|
Packit |
7d1034 |
}
|
|
Packit |
7d1034 |
break;
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
case 0x07:
|
|
Packit |
7d1034 |
if (priv->bridge.pcmcia == NULL)
|
|
Packit |
7d1034 |
read_bridge_info(priv);
|
|
Packit |
7d1034 |
if ((priv->header_type & 0x7f) == 0x02) {
|
|
Packit |
7d1034 |
*primary_bus = priv->bridge.pcmcia->primary_bus;
|
|
Packit |
7d1034 |
*secondary_bus = priv->bridge.pcmcia->card_bus;
|
|
Packit |
7d1034 |
*subordinate_bus = priv->bridge.pcmcia->subordinate_bus;
|
|
Packit |
7d1034 |
} else {
|
|
Packit |
7d1034 |
*primary_bus = dev->bus;
|
|
Packit |
7d1034 |
*secondary_bus = -1;
|
|
Packit |
7d1034 |
*subordinate_bus = -1;
|
|
Packit |
7d1034 |
}
|
|
Packit |
7d1034 |
break;
|
|
Packit |
7d1034 |
}
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
return 0;
|
|
Packit |
7d1034 |
}
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
#define PCI_CLASS_BRIDGE 0x06
|
|
Packit |
7d1034 |
#define PCI_SUBCLASS_BRIDGE_PCI 0x04
|
|
Packit |
7d1034 |
#define PCI_CLASS_MASK 0xFF
|
|
Packit |
7d1034 |
#define PCI_SUBCLASS_MASK 0xFF
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
struct pci_device *
|
|
Packit |
7d1034 |
pci_device_get_parent_bridge(struct pci_device *dev)
|
|
Packit |
7d1034 |
{
|
|
Packit |
7d1034 |
struct pci_id_match bridge_match = {
|
|
Packit |
7d1034 |
PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY,
|
|
Packit |
7d1034 |
(PCI_CLASS_BRIDGE << 16) | (PCI_SUBCLASS_BRIDGE_PCI << 8),
|
|
Packit |
7d1034 |
(PCI_CLASS_MASK << 16) | (PCI_SUBCLASS_MASK << 8)
|
|
Packit |
7d1034 |
};
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
struct pci_device *bridge;
|
|
Packit |
7d1034 |
struct pci_device_iterator *iter;
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
if (dev == NULL)
|
|
Packit |
7d1034 |
return NULL;
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
iter = pci_id_match_iterator_create(& bridge_match);
|
|
Packit |
7d1034 |
if (iter == NULL)
|
|
Packit |
7d1034 |
return NULL;
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
while ((bridge = pci_device_next(iter)) != NULL) {
|
|
Packit |
7d1034 |
if (bridge->domain == dev->domain) {
|
|
Packit |
7d1034 |
const struct pci_bridge_info *info =
|
|
Packit |
7d1034 |
pci_device_get_bridge_info(bridge);
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
if (info != NULL) {
|
|
Packit |
7d1034 |
if (info->secondary_bus == dev->bus) {
|
|
Packit |
7d1034 |
break;
|
|
Packit |
7d1034 |
}
|
|
Packit |
7d1034 |
}
|
|
Packit |
7d1034 |
}
|
|
Packit |
7d1034 |
}
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
pci_iterator_destroy(iter);
|
|
Packit |
7d1034 |
|
|
Packit |
7d1034 |
return bridge;
|
|
Packit |
7d1034 |
}
|