/* Locate the active VGA device under the bridge. */
PCI_IO_DEVICE* LocateVgaDevice(IN PCI_IO_DEVICE *Bridge)
/* Locate the active VGA device under the bridge. */
PCI_IO_DEVICE* LocateVgaDevice(IN PCI_IO_DEVICE *Bridge)
{
  LIST_ENTRY     *CurrentLink;
  PCI_IO_DEVICE  *PciIoDevice;
  CurrentLink = Bridge->ChildList.ForwardLink;
  while (CurrentLink != NULL && CurrentLink != &Bridge->ChildList) {
    PciIoDevice = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
    if (IS_PCI_VGA (&PciIoDevice->Pci) &&
        ((PciIoDevice->Attributes &
          (EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY |
           EFI_PCI_IO_ATTRIBUTE_VGA_IO     |
           EFI_PCI_IO_ATTRIBUTE_VGA_IO_16)) != 0))
    {
      return PciIoDevice;
    }
    if (IS_PCI_BRIDGE (&PciIoDevice->Pci)) {
      PciIoDevice = LocateVgaDevice (PciIoDevice);
      if (PciIoDevice != NULL) {
        return PciIoDevice;
      }
    }
    CurrentLink = CurrentLink->ForwardLink;
  }
  return NULL;
}