2 Supporting functions implementation for PCI devices management.
4 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
5 (C) Copyright 2018 Hewlett Packard Enterprise Development LP<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
13 // This device structure is serviced as a header.
14 // Its next field points to the first root bridge device node.
16 LIST_ENTRY mPciDevicePool
;
19 Initialize the PCI devices pool.
23 InitializePciDevicePool (
27 InitializeListHead (&mPciDevicePool
);
31 Insert a root bridge into PCI device pool.
33 @param RootBridge A pointer to the PCI_IO_DEVICE.
38 IN PCI_IO_DEVICE
*RootBridge
41 InsertTailList (&mPciDevicePool
, &(RootBridge
->Link
));
45 This function is used to insert a PCI device node under
48 @param Bridge The PCI bridge.
49 @param PciDeviceNode The PCI device needs inserting.
54 IN PCI_IO_DEVICE
*Bridge
,
55 IN PCI_IO_DEVICE
*PciDeviceNode
58 InsertTailList (&Bridge
->ChildList
, &(PciDeviceNode
->Link
));
59 PciDeviceNode
->Parent
= Bridge
;
63 Destroy root bridge and remove it from device tree.
65 @param RootBridge The bridge want to be removed.
70 IN PCI_IO_DEVICE
*RootBridge
73 DestroyPciDeviceTree (RootBridge
);
75 FreePciDevice (RootBridge
);
79 Destroy a pci device node.
81 All direct or indirect allocated resource for this node will be freed.
83 @param PciIoDevice A pointer to the PCI_IO_DEVICE to be destroyed.
88 IN PCI_IO_DEVICE
*PciIoDevice
91 ASSERT (PciIoDevice
!= NULL
);
93 // Assume all children have been removed underneath this device
95 if (PciIoDevice
->ResourcePaddingDescriptors
!= NULL
) {
96 FreePool (PciIoDevice
->ResourcePaddingDescriptors
);
99 if (PciIoDevice
->DevicePath
!= NULL
) {
100 FreePool (PciIoDevice
->DevicePath
);
103 if (PciIoDevice
->BusNumberRanges
!= NULL
) {
104 FreePool (PciIoDevice
->BusNumberRanges
);
107 FreePool (PciIoDevice
);
111 Destroy all the pci device node under the bridge.
112 Bridge itself is not included.
114 @param Bridge A pointer to the PCI_IO_DEVICE.
118 DestroyPciDeviceTree (
119 IN PCI_IO_DEVICE
*Bridge
122 LIST_ENTRY
*CurrentLink
;
125 while (!IsListEmpty (&Bridge
->ChildList
)) {
126 CurrentLink
= Bridge
->ChildList
.ForwardLink
;
129 // Remove this node from the linked list
131 RemoveEntryList (CurrentLink
);
133 Temp
= PCI_IO_DEVICE_FROM_LINK (CurrentLink
);
135 if (!IsListEmpty (&Temp
->ChildList
)) {
136 DestroyPciDeviceTree (Temp
);
139 FreePciDevice (Temp
);
144 Destroy all device nodes under the root bridge
145 specified by Controller.
147 The root bridge itself is also included.
149 @param Controller Root bridge handle.
151 @retval EFI_SUCCESS Destroy all device nodes successfully.
152 @retval EFI_NOT_FOUND Cannot find any PCI device under specified
157 DestroyRootBridgeByHandle (
158 IN EFI_HANDLE Controller
161 LIST_ENTRY
*CurrentLink
;
164 CurrentLink
= mPciDevicePool
.ForwardLink
;
166 while (CurrentLink
!= NULL
&& CurrentLink
!= &mPciDevicePool
) {
167 Temp
= PCI_IO_DEVICE_FROM_LINK (CurrentLink
);
169 if (Temp
->Handle
== Controller
) {
170 RemoveEntryList (CurrentLink
);
172 DestroyPciDeviceTree (Temp
);
174 FreePciDevice (Temp
);
179 CurrentLink
= CurrentLink
->ForwardLink
;
182 return EFI_NOT_FOUND
;
186 This function registers the PCI IO device.
188 It creates a handle for this PCI IO device (if the handle does not exist), attaches
189 appropriate protocols onto the handle, does necessary initialization, and sets up
190 parent/child relationship with its bus controller.
192 @param Controller An EFI handle for the PCI bus controller.
193 @param PciIoDevice A PCI_IO_DEVICE pointer to the PCI IO device to be registered.
194 @param Handle A pointer to hold the returned EFI handle for the PCI IO device.
196 @retval EFI_SUCCESS The PCI device is successfully registered.
197 @retval other An error occurred when registering the PCI device.
202 IN EFI_HANDLE Controller
,
203 IN PCI_IO_DEVICE
*PciIoDevice
,
204 OUT EFI_HANDLE
*Handle OPTIONAL
208 VOID
*PlatformOpRomBuffer
;
209 UINTN PlatformOpRomSize
;
210 EFI_PCI_IO_PROTOCOL
*PciIo
;
215 // Install the pciio protocol, device path protocol
217 Status
= gBS
->InstallMultipleProtocolInterfaces (
218 &PciIoDevice
->Handle
,
219 &gEfiDevicePathProtocolGuid
,
220 PciIoDevice
->DevicePath
,
221 &gEfiPciIoProtocolGuid
,
225 if (EFI_ERROR (Status
)) {
230 // Force Interrupt line to "Unknown" or "No Connection"
232 PciIo
= &(PciIoDevice
->PciIo
);
233 Data8
= PCI_INT_LINE_UNKNOWN
;
234 PciIo
->Pci
.Write (PciIo
, EfiPciIoWidthUint8
, 0x3C, 1, &Data8
);
239 if (!PciIoDevice
->AllOpRomProcessed
) {
241 // Get the OpRom provided by platform
243 if (gPciPlatformProtocol
!= NULL
) {
244 Status
= gPciPlatformProtocol
->GetPciRom (
245 gPciPlatformProtocol
,
247 &PlatformOpRomBuffer
,
250 if (!EFI_ERROR (Status
)) {
251 PciIoDevice
->EmbeddedRom
= FALSE
;
252 PciIoDevice
->RomSize
= (UINT32
)PlatformOpRomSize
;
253 PciIoDevice
->PciIo
.RomSize
= PlatformOpRomSize
;
254 PciIoDevice
->PciIo
.RomImage
= PlatformOpRomBuffer
;
256 // For OpROM read from gPciPlatformProtocol:
257 // Add the Rom Image to internal database for later PCI light enumeration
259 PciRomAddImageMapping (
261 PciIoDevice
->PciRootBridgeIo
->SegmentNumber
,
262 PciIoDevice
->BusNumber
,
263 PciIoDevice
->DeviceNumber
,
264 PciIoDevice
->FunctionNumber
,
265 PciIoDevice
->PciIo
.RomImage
,
266 PciIoDevice
->PciIo
.RomSize
269 } else if (gPciOverrideProtocol
!= NULL
) {
270 Status
= gPciOverrideProtocol
->GetPciRom (
271 gPciOverrideProtocol
,
273 &PlatformOpRomBuffer
,
276 if (!EFI_ERROR (Status
)) {
277 PciIoDevice
->EmbeddedRom
= FALSE
;
278 PciIoDevice
->RomSize
= (UINT32
)PlatformOpRomSize
;
279 PciIoDevice
->PciIo
.RomSize
= PlatformOpRomSize
;
280 PciIoDevice
->PciIo
.RomImage
= PlatformOpRomBuffer
;
282 // For OpROM read from gPciOverrideProtocol:
283 // Add the Rom Image to internal database for later PCI light enumeration
285 PciRomAddImageMapping (
287 PciIoDevice
->PciRootBridgeIo
->SegmentNumber
,
288 PciIoDevice
->BusNumber
,
289 PciIoDevice
->DeviceNumber
,
290 PciIoDevice
->FunctionNumber
,
291 PciIoDevice
->PciIo
.RomImage
,
292 PciIoDevice
->PciIo
.RomSize
299 // Determine if there are EFI images in the option rom
301 HasEfiImage
= ContainEfiImage (PciIoDevice
->PciIo
.RomImage
, PciIoDevice
->PciIo
.RomSize
);
304 Status
= gBS
->InstallMultipleProtocolInterfaces (
305 &PciIoDevice
->Handle
,
306 &gEfiLoadFile2ProtocolGuid
,
307 &PciIoDevice
->LoadFile2
,
310 if (EFI_ERROR (Status
)) {
311 gBS
->UninstallMultipleProtocolInterfaces (
313 &gEfiDevicePathProtocolGuid
,
314 PciIoDevice
->DevicePath
,
315 &gEfiPciIoProtocolGuid
,
323 if (!PciIoDevice
->AllOpRomProcessed
) {
324 PciIoDevice
->AllOpRomProcessed
= TRUE
;
327 // Dispatch the EFI OpRom for the PCI device.
328 // The OpRom is got from platform in the above code
329 // or loaded from device in the previous round of bus enumeration
332 ProcessOpRomImage (PciIoDevice
);
336 if (PciIoDevice
->BusOverride
) {
338 // Install Bus Specific Driver Override Protocol
340 Status
= gBS
->InstallMultipleProtocolInterfaces (
341 &PciIoDevice
->Handle
,
342 &gEfiBusSpecificDriverOverrideProtocolGuid
,
343 &PciIoDevice
->PciDriverOverride
,
346 if (EFI_ERROR (Status
)) {
347 gBS
->UninstallMultipleProtocolInterfaces (
349 &gEfiDevicePathProtocolGuid
,
350 PciIoDevice
->DevicePath
,
351 &gEfiPciIoProtocolGuid
,
356 gBS
->UninstallMultipleProtocolInterfaces (
358 &gEfiLoadFile2ProtocolGuid
,
359 &PciIoDevice
->LoadFile2
,
368 Status
= gBS
->OpenProtocol (
370 &gEfiPciRootBridgeIoProtocolGuid
,
371 (VOID
**)&(PciIoDevice
->PciRootBridgeIo
),
372 gPciBusDriverBinding
.DriverBindingHandle
,
374 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
376 if (EFI_ERROR (Status
)) {
380 if (Handle
!= NULL
) {
381 *Handle
= PciIoDevice
->Handle
;
385 // Indicate the pci device is registered
387 PciIoDevice
->Registered
= TRUE
;
393 This function is used to remove the whole PCI devices on the specified bridge from
396 @param RootBridgeHandle The root bridge device handle.
397 @param Bridge The bridge device to be removed.
401 RemoveAllPciDeviceOnBridge (
402 EFI_HANDLE RootBridgeHandle
,
403 PCI_IO_DEVICE
*Bridge
406 LIST_ENTRY
*CurrentLink
;
409 while (!IsListEmpty (&Bridge
->ChildList
)) {
410 CurrentLink
= Bridge
->ChildList
.ForwardLink
;
411 Temp
= PCI_IO_DEVICE_FROM_LINK (CurrentLink
);
414 // Check if the current node has been deregistered before
415 // If it is not, then deregister it
417 if (Temp
->Registered
) {
418 DeRegisterPciDevice (RootBridgeHandle
, Temp
->Handle
);
422 // Remove this node from the linked list
424 RemoveEntryList (CurrentLink
);
426 if (!IsListEmpty (&Temp
->ChildList
)) {
427 RemoveAllPciDeviceOnBridge (RootBridgeHandle
, Temp
);
430 FreePciDevice (Temp
);
435 This function is used to de-register the PCI IO device.
437 That includes un-installing PciIo protocol from the specified PCI
440 @param Controller An EFI handle for the PCI bus controller.
441 @param Handle PCI device handle.
443 @retval EFI_SUCCESS The PCI device is successfully de-registered.
444 @retval other An error occurred when de-registering the PCI device.
448 DeRegisterPciDevice (
449 IN EFI_HANDLE Controller
,
454 EFI_PCI_IO_PROTOCOL
*PciIo
;
456 PCI_IO_DEVICE
*PciIoDevice
;
458 LIST_ENTRY
*CurrentLink
;
459 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
;
461 Status
= gBS
->OpenProtocol (
463 &gEfiPciIoProtocolGuid
,
465 gPciBusDriverBinding
.DriverBindingHandle
,
467 EFI_OPEN_PROTOCOL_GET_PROTOCOL
469 if (!EFI_ERROR (Status
)) {
470 PciIoDevice
= PCI_IO_DEVICE_FROM_PCI_IO_THIS (PciIo
);
473 // If it is already de-registered
475 if (!PciIoDevice
->Registered
) {
480 // If it is PPB, first de-register its children
483 if (!IsListEmpty (&PciIoDevice
->ChildList
)) {
484 CurrentLink
= PciIoDevice
->ChildList
.ForwardLink
;
486 while (CurrentLink
!= NULL
&& CurrentLink
!= &PciIoDevice
->ChildList
) {
487 Node
= PCI_IO_DEVICE_FROM_LINK (CurrentLink
);
488 Status
= DeRegisterPciDevice (Controller
, Node
->Handle
);
490 if (EFI_ERROR (Status
)) {
494 CurrentLink
= CurrentLink
->ForwardLink
;
499 // Close the child handle
501 Status
= gBS
->CloseProtocol (
503 &gEfiPciRootBridgeIoProtocolGuid
,
504 gPciBusDriverBinding
.DriverBindingHandle
,
509 // Un-install the Device Path protocol and PCI I/O protocol
510 // and Bus Specific Driver Override protocol if needed.
512 if (PciIoDevice
->BusOverride
) {
513 Status
= gBS
->UninstallMultipleProtocolInterfaces (
515 &gEfiDevicePathProtocolGuid
,
516 PciIoDevice
->DevicePath
,
517 &gEfiPciIoProtocolGuid
,
519 &gEfiBusSpecificDriverOverrideProtocolGuid
,
520 &PciIoDevice
->PciDriverOverride
,
524 Status
= gBS
->UninstallMultipleProtocolInterfaces (
526 &gEfiDevicePathProtocolGuid
,
527 PciIoDevice
->DevicePath
,
528 &gEfiPciIoProtocolGuid
,
534 if (!EFI_ERROR (Status
)) {
536 // Try to uninstall LoadFile2 protocol if exists
538 Status
= gBS
->OpenProtocol (
540 &gEfiLoadFile2ProtocolGuid
,
542 gPciBusDriverBinding
.DriverBindingHandle
,
544 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
546 if (!EFI_ERROR (Status
)) {
547 Status
= gBS
->UninstallMultipleProtocolInterfaces (
549 &gEfiLoadFile2ProtocolGuid
,
550 &PciIoDevice
->LoadFile2
,
558 Status
= EFI_SUCCESS
;
561 if (EFI_ERROR (Status
)) {
564 &gEfiPciRootBridgeIoProtocolGuid
,
565 (VOID
**)&PciRootBridgeIo
,
566 gPciBusDriverBinding
.DriverBindingHandle
,
568 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
574 // The Device Driver should disable this device after disconnect
575 // so the Pci Bus driver will not touch this device any more.
576 // Restore the register field to the original value
578 PciIoDevice
->Registered
= FALSE
;
579 PciIoDevice
->Handle
= NULL
;
582 // Handle may be closed before
591 Start to manage the PCI device on the specified root bridge or PCI-PCI Bridge.
593 @param Controller The root bridge handle.
594 @param RootBridge A pointer to the PCI_IO_DEVICE.
595 @param RemainingDevicePath A pointer to the EFI_DEVICE_PATH_PROTOCOL.
596 @param NumberOfChildren Children number.
597 @param ChildHandleBuffer A pointer to the child handle buffer.
599 @retval EFI_NOT_READY Device is not allocated.
600 @retval EFI_UNSUPPORTED Device only support PCI-PCI bridge.
601 @retval EFI_NOT_FOUND Can not find the specific device.
602 @retval EFI_SUCCESS Success to start Pci devices on bridge.
606 StartPciDevicesOnBridge (
607 IN EFI_HANDLE Controller
,
608 IN PCI_IO_DEVICE
*RootBridge
,
609 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
,
610 IN OUT UINT8
*NumberOfChildren
,
611 IN OUT EFI_HANDLE
*ChildHandleBuffer
615 PCI_IO_DEVICE
*PciIoDevice
;
616 EFI_DEV_PATH_PTR Node
;
617 EFI_DEVICE_PATH_PROTOCOL
*CurrentDevicePath
;
619 LIST_ENTRY
*CurrentLink
;
623 CurrentLink
= RootBridge
->ChildList
.ForwardLink
;
625 while (CurrentLink
!= NULL
&& CurrentLink
!= &RootBridge
->ChildList
) {
626 PciIoDevice
= PCI_IO_DEVICE_FROM_LINK (CurrentLink
);
627 if (RemainingDevicePath
!= NULL
) {
628 Node
.DevPath
= RemainingDevicePath
;
630 if ((Node
.Pci
->Device
!= PciIoDevice
->DeviceNumber
) ||
631 (Node
.Pci
->Function
!= PciIoDevice
->FunctionNumber
))
633 CurrentLink
= CurrentLink
->ForwardLink
;
638 // Check if the device has been assigned with required resource
640 if (!PciIoDevice
->Allocated
) {
641 return EFI_NOT_READY
;
645 // Check if the current node has been registered before
646 // If it is not, register it
648 if (!PciIoDevice
->Registered
) {
649 Status
= RegisterPciDevice (
656 if ((NumberOfChildren
!= NULL
) && (ChildHandleBuffer
!= NULL
) && PciIoDevice
->Registered
) {
657 ChildHandleBuffer
[*NumberOfChildren
] = PciIoDevice
->Handle
;
658 (*NumberOfChildren
)++;
662 // Get the next device path
664 CurrentDevicePath
= NextDevicePathNode (RemainingDevicePath
);
665 if (IsDevicePathEnd (CurrentDevicePath
)) {
672 if (IS_PCI_BRIDGE (&PciIoDevice
->Pci
)) {
673 Status
= StartPciDevicesOnBridge (
681 PciIoDevice
->PciIo
.Attributes (
682 &(PciIoDevice
->PciIo
),
683 EfiPciIoAttributeOperationSupported
,
687 Supports
&= (UINT64
)EFI_PCI_DEVICE_ENABLE
;
688 PciIoDevice
->PciIo
.Attributes (
689 &(PciIoDevice
->PciIo
),
690 EfiPciIoAttributeOperationEnable
,
698 // Currently, the PCI bus driver only support PCI-PCI bridge
700 return EFI_UNSUPPORTED
;
704 // If remaining device path is NULL,
705 // try to enable all the pci devices under this bridge
707 if (!PciIoDevice
->Registered
&& PciIoDevice
->Allocated
) {
708 Status
= RegisterPciDevice (
715 if ((NumberOfChildren
!= NULL
) && (ChildHandleBuffer
!= NULL
) && PciIoDevice
->Registered
) {
716 ChildHandleBuffer
[*NumberOfChildren
] = PciIoDevice
->Handle
;
717 (*NumberOfChildren
)++;
720 if (IS_PCI_BRIDGE (&PciIoDevice
->Pci
)) {
721 Status
= StartPciDevicesOnBridge (
729 PciIoDevice
->PciIo
.Attributes (
730 &(PciIoDevice
->PciIo
),
731 EfiPciIoAttributeOperationSupported
,
735 Supports
&= (UINT64
)EFI_PCI_DEVICE_ENABLE
;
736 PciIoDevice
->PciIo
.Attributes (
737 &(PciIoDevice
->PciIo
),
738 EfiPciIoAttributeOperationEnable
,
744 CurrentLink
= CurrentLink
->ForwardLink
;
748 if (PciIoDevice
== NULL
) {
749 return EFI_NOT_FOUND
;
756 Start to manage all the PCI devices it found previously under
757 the entire host bridge.
759 @param Controller The root bridge handle.
761 @retval EFI_NOT_READY Device is not allocated.
762 @retval EFI_SUCCESS Success to start Pci device on host bridge.
767 IN EFI_HANDLE Controller
770 PCI_IO_DEVICE
*RootBridge
;
771 EFI_HANDLE ThisHostBridge
;
772 LIST_ENTRY
*CurrentLink
;
774 RootBridge
= GetRootBridgeByHandle (Controller
);
775 ASSERT (RootBridge
!= NULL
);
776 ThisHostBridge
= RootBridge
->PciRootBridgeIo
->ParentHandle
;
778 CurrentLink
= mPciDevicePool
.ForwardLink
;
780 while (CurrentLink
!= NULL
&& CurrentLink
!= &mPciDevicePool
) {
781 RootBridge
= PCI_IO_DEVICE_FROM_LINK (CurrentLink
);
783 // Locate the right root bridge to start
785 if (RootBridge
->PciRootBridgeIo
->ParentHandle
== ThisHostBridge
) {
786 StartPciDevicesOnBridge (
795 CurrentLink
= CurrentLink
->ForwardLink
;
802 Create root bridge device.
804 @param RootBridgeHandle Specified root bridge handle.
806 @return The crated root bridge device instance, NULL means no
807 root bridge device instance created.
812 IN EFI_HANDLE RootBridgeHandle
817 EFI_DEVICE_PATH_PROTOCOL
*ParentDevicePath
;
818 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
;
820 Dev
= AllocateZeroPool (sizeof (PCI_IO_DEVICE
));
825 Dev
->Signature
= PCI_IO_DEVICE_SIGNATURE
;
826 Dev
->Handle
= RootBridgeHandle
;
827 InitializeListHead (&Dev
->ChildList
);
829 Status
= gBS
->OpenProtocol (
831 &gEfiDevicePathProtocolGuid
,
832 (VOID
**)&ParentDevicePath
,
833 gPciBusDriverBinding
.DriverBindingHandle
,
835 EFI_OPEN_PROTOCOL_GET_PROTOCOL
838 if (EFI_ERROR (Status
)) {
844 // Record the root bridge parent device path
846 Dev
->DevicePath
= DuplicateDevicePath (ParentDevicePath
);
849 // Get the pci root bridge io protocol
851 Status
= gBS
->OpenProtocol (
853 &gEfiPciRootBridgeIoProtocolGuid
,
854 (VOID
**)&PciRootBridgeIo
,
855 gPciBusDriverBinding
.DriverBindingHandle
,
857 EFI_OPEN_PROTOCOL_GET_PROTOCOL
860 if (EFI_ERROR (Status
)) {
865 Dev
->PciRootBridgeIo
= PciRootBridgeIo
;
868 // Initialize the PCI I/O instance structure
870 InitializePciIoInstance (Dev
);
871 InitializePciDriverOverrideInstance (Dev
);
872 InitializePciLoadFile2 (Dev
);
875 // Initialize reserved resource list and
876 // option rom driver list
878 InitializeListHead (&Dev
->ReservedResourceList
);
879 InitializeListHead (&Dev
->OptionRomDriverList
);
885 Get root bridge device instance by specific root bridge handle.
887 @param RootBridgeHandle Given root bridge handle.
889 @return The root bridge device instance, NULL means no root bridge
890 device instance found.
894 GetRootBridgeByHandle (
895 EFI_HANDLE RootBridgeHandle
898 PCI_IO_DEVICE
*RootBridgeDev
;
899 LIST_ENTRY
*CurrentLink
;
901 CurrentLink
= mPciDevicePool
.ForwardLink
;
903 while (CurrentLink
!= NULL
&& CurrentLink
!= &mPciDevicePool
) {
904 RootBridgeDev
= PCI_IO_DEVICE_FROM_LINK (CurrentLink
);
905 if (RootBridgeDev
->Handle
== RootBridgeHandle
) {
906 return RootBridgeDev
;
909 CurrentLink
= CurrentLink
->ForwardLink
;
916 Judge whether Pci device existed.
918 @param Bridge Parent bridge instance.
919 @param PciIoDevice Device instance.
921 @retval TRUE Pci device existed.
922 @retval FALSE Pci device did not exist.
927 IN PCI_IO_DEVICE
*Bridge
,
928 IN PCI_IO_DEVICE
*PciIoDevice
932 LIST_ENTRY
*CurrentLink
;
934 CurrentLink
= Bridge
->ChildList
.ForwardLink
;
936 while (CurrentLink
!= NULL
&& CurrentLink
!= &Bridge
->ChildList
) {
937 Temp
= PCI_IO_DEVICE_FROM_LINK (CurrentLink
);
939 if (Temp
== PciIoDevice
) {
943 if (!IsListEmpty (&Temp
->ChildList
)) {
944 if (PciDeviceExisted (Temp
, PciIoDevice
)) {
949 CurrentLink
= CurrentLink
->ForwardLink
;
956 Get the active VGA device on the specified Host Bridge.
958 @param HostBridgeHandle Host Bridge handle.
960 @return The active VGA device on the specified Host Bridge.
964 LocateVgaDeviceOnHostBridge (
965 IN EFI_HANDLE HostBridgeHandle
968 LIST_ENTRY
*CurrentLink
;
969 PCI_IO_DEVICE
*PciIoDevice
;
971 CurrentLink
= mPciDevicePool
.ForwardLink
;
973 while (CurrentLink
!= NULL
&& CurrentLink
!= &mPciDevicePool
) {
974 PciIoDevice
= PCI_IO_DEVICE_FROM_LINK (CurrentLink
);
976 if (PciIoDevice
->PciRootBridgeIo
->ParentHandle
== HostBridgeHandle
) {
977 PciIoDevice
= LocateVgaDevice (PciIoDevice
);
979 if (PciIoDevice
!= NULL
) {
984 CurrentLink
= CurrentLink
->ForwardLink
;
991 Locate the active VGA device under the bridge.
993 @param Bridge PCI IO instance for the bridge.
995 @return The active VGA device.
1000 IN PCI_IO_DEVICE
*Bridge
1003 LIST_ENTRY
*CurrentLink
;
1004 PCI_IO_DEVICE
*PciIoDevice
;
1006 CurrentLink
= Bridge
->ChildList
.ForwardLink
;
1008 while (CurrentLink
!= NULL
&& CurrentLink
!= &Bridge
->ChildList
) {
1009 PciIoDevice
= PCI_IO_DEVICE_FROM_LINK (CurrentLink
);
1011 if (IS_PCI_VGA (&PciIoDevice
->Pci
) &&
1012 ((PciIoDevice
->Attributes
&
1013 (EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY
|
1014 EFI_PCI_IO_ATTRIBUTE_VGA_IO
|
1015 EFI_PCI_IO_ATTRIBUTE_VGA_IO_16
)) != 0))
1020 if (IS_PCI_BRIDGE (&PciIoDevice
->Pci
)) {
1021 PciIoDevice
= LocateVgaDevice (PciIoDevice
);
1023 if (PciIoDevice
!= NULL
) {
1028 CurrentLink
= CurrentLink
->ForwardLink
;