3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
25 #include "PciEnumerator.h"
26 #include "PciResourceSupport.h"
27 #include "PciOptionRomSupport.h"
31 IN EFI_HANDLE Controller
37 This routine is used to enumerate entire pci bus system
47 // TODO: Controller - add argument and description to function comment
48 // TODO: EFI_SUCCESS - add return value to function comment
49 // TODO: EFI_SUCCESS - add return value to function comment
52 EFI_HANDLE HostBridgeHandle
;
54 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
;
55 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
;
58 // If PCI bus has already done the full enumeration, never do it again
60 if (!gFullEnumeration
) {
61 return PciEnumeratorLight (Controller
);
65 // If this host bridge has been already enumerated, then return successfully
67 if (RootBridgeExisted (Controller
)) {
72 // Get the rootbridge Io protocol to find the host bridge handle
74 Status
= gBS
->OpenProtocol (
76 &gEfiPciRootBridgeIoProtocolGuid
,
77 (VOID
**) &PciRootBridgeIo
,
78 gPciBusDriverBinding
.DriverBindingHandle
,
80 EFI_OPEN_PROTOCOL_GET_PROTOCOL
83 if (EFI_ERROR (Status
)) {
88 // Get the host bridge handle
90 HostBridgeHandle
= PciRootBridgeIo
->ParentHandle
;
93 // Get the pci host bridge resource allocation protocol
95 Status
= gBS
->OpenProtocol (
97 &gEfiPciHostBridgeResourceAllocationProtocolGuid
,
98 (VOID
**) &PciResAlloc
,
99 gPciBusDriverBinding
.DriverBindingHandle
,
101 EFI_OPEN_PROTOCOL_GET_PROTOCOL
104 if (EFI_ERROR (Status
)) {
109 // Notify the pci bus enumeration is about to begin
111 NotifyPhase (PciResAlloc
, EfiPciHostBridgeBeginEnumeration
);
114 // Start the bus allocation phase
116 Status
= PciHostBridgeEnumerator (PciResAlloc
);
118 if (EFI_ERROR (Status
)) {
123 // Submit the resource request
125 Status
= PciHostBridgeResourceAllocator (PciResAlloc
);
127 if (EFI_ERROR (Status
)) {
134 Status
= PciHostBridgeP2CProcess (PciResAlloc
);
136 if (EFI_ERROR (Status
)) {
141 // Process attributes for devices on this host bridge
143 Status
= PciHostBridgeDeviceAttribute (PciResAlloc
);
144 if (EFI_ERROR (Status
)) {
148 gFullEnumeration
= FALSE
;
154 PciRootBridgeEnumerator (
155 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
,
156 IN PCI_IO_DEVICE
*RootBridgeDev
169 // TODO: PciResAlloc - add argument and description to function comment
170 // TODO: RootBridgeDev - add argument and description to function comment
171 // TODO: EFI_SUCCESS - add return value to function comment
174 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*pConfiguration
;
176 UINT8 StartBusNumber
;
177 UINT8 PaddedBusRange
;
178 EFI_HANDLE RootBridgeHandle
;
185 // Get the root bridge handle
187 RootBridgeHandle
= RootBridgeDev
->Handle
;
189 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
191 EFI_IO_BUS_PCI
| EFI_IOB_PCI_PC_BUS_ENUM
,
192 RootBridgeDev
->DevicePath
196 // Get the Bus information
198 Status
= PciResAlloc
->StartBusEnumeration (
201 (VOID
**) &pConfiguration
204 if (EFI_ERROR (Status
)) {
209 // Get the bus number to start with
211 StartBusNumber
= (UINT8
) (pConfiguration
->AddrRangeMin
);
214 // Initialize the subordinate bus number
216 SubBusNumber
= StartBusNumber
;
221 Status
= PciScanBus (
223 (UINT8
) (pConfiguration
->AddrRangeMin
),
228 if (EFI_ERROR (Status
)) {
234 // Assign max bus number scanned
236 pConfiguration
->AddrLen
= SubBusNumber
- StartBusNumber
+ 1 + PaddedBusRange
;
241 Status
= PciResAlloc
->SetBusNumbers (
247 if (EFI_ERROR (Status
)) {
256 IN PCI_IO_DEVICE
*Bridge
,
264 This routine is used to process option rom on a certain root bridge
273 // TODO: Bridge - add argument and description to function comment
274 // TODO: RomBase - add argument and description to function comment
275 // TODO: MaxLength - add argument and description to function comment
276 // TODO: EFI_SUCCESS - add return value to function comment
278 LIST_ENTRY
*CurrentLink
;
283 // Go through bridges to reach all devices
285 CurrentLink
= Bridge
->ChildList
.ForwardLink
;
286 while (CurrentLink
&& CurrentLink
!= &Bridge
->ChildList
) {
287 Temp
= PCI_IO_DEVICE_FROM_LINK (CurrentLink
);
288 if (!IsListEmpty (&Temp
->ChildList
)) {
291 // Go further to process the option rom under this bridge
293 Status
= ProcessOptionRom (Temp
, RomBase
, MaxLength
);
296 if (Temp
->RomSize
!= 0 && Temp
->RomSize
<= MaxLength
) {
299 // Load and process the option rom
301 Status
= LoadOpRomImage (Temp
, RomBase
);
302 if (Status
== EFI_SUCCESS
) {
303 Status
= ProcessOpRomImage (Temp
);
307 CurrentLink
= CurrentLink
->ForwardLink
;
315 IN PCI_IO_DEVICE
*Bridge
,
316 IN UINT8 StartBusNumber
,
317 OUT UINT8
*SubBusNumber
323 This routine is used to assign bus number to the given PCI bus system
332 // TODO: Bridge - add argument and description to function comment
333 // TODO: StartBusNumber - add argument and description to function comment
334 // TODO: SubBusNumber - add argument and description to function comment
335 // TODO: EFI_DEVICE_ERROR - add return value to function comment
336 // TODO: EFI_SUCCESS - add return value to function comment
346 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
;
348 PciRootBridgeIo
= Bridge
->PciRootBridgeIo
;
353 *SubBusNumber
= StartBusNumber
;
356 // First check to see whether the parent is ppb
358 for (Device
= 0; Device
<= PCI_MAX_DEVICE
; Device
++) {
359 for (Func
= 0; Func
<= PCI_MAX_FUNC
; Func
++) {
362 // Check to see whether a pci device is present
365 Status
= PciDevicePresent (
373 if (!EFI_ERROR (Status
) &&
374 (IS_PCI_BRIDGE (&Pci
) || IS_CARDBUS_BRIDGE (&Pci
))) {
377 // Reserved one bus for cardbus bridge
379 SecondBus
= ++(*SubBusNumber
);
381 Register
= (UINT16
) ((SecondBus
<< 8) | (UINT16
) StartBusNumber
);
383 Address
= EFI_PCI_ADDRESS (StartBusNumber
, Device
, Func
, 0x18);
385 Status
= PciRootBridgeIo
->Pci
.Write (
394 // Initialize SubBusNumber to SecondBus
396 Address
= EFI_PCI_ADDRESS (StartBusNumber
, Device
, Func
, 0x1A);
397 Status
= PciRootBridgeIo
->Pci
.Write (
405 // If it is PPB, resursively search down this bridge
407 if (IS_PCI_BRIDGE (&Pci
)) {
410 Status
= PciRootBridgeIo
->Pci
.Write (
418 Status
= PciAssignBusNumber (
424 if (EFI_ERROR (Status
)) {
425 return EFI_DEVICE_ERROR
;
430 // Set the current maximum bus number under the PPB
433 Address
= EFI_PCI_ADDRESS (StartBusNumber
, Device
, Func
, 0x1A);
435 Status
= PciRootBridgeIo
->Pci
.Write (
445 if (Func
== 0 && !IS_PCI_MULTI_FUNC (&Pci
)) {
448 // Skip sub functions, this is not a multi function device
460 DetermineRootBridgeAttributes (
461 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
,
462 IN PCI_IO_DEVICE
*RootBridgeDev
468 This routine is used to determine the root bridge attribute by interfacing
469 the host bridge resource allocation protocol.
478 // TODO: PciResAlloc - add argument and description to function comment
479 // TODO: RootBridgeDev - add argument and description to function comment
480 // TODO: EFI_SUCCESS - add return value to function comment
484 EFI_HANDLE RootBridgeHandle
;
487 RootBridgeHandle
= RootBridgeDev
->Handle
;
490 // Get root bridge attribute by calling into pci host bridge resource allocation protocol
492 Status
= PciResAlloc
->GetAllocAttributes (
498 if (EFI_ERROR (Status
)) {
503 // Here is the point where PCI bus driver calls HOST bridge allocation protocol
504 // Currently we hardcoded for ea815
507 if (Attributes
& EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM
) {
508 RootBridgeDev
->Decodes
|= EFI_BRIDGE_PMEM_MEM_COMBINE_SUPPORTED
;
511 if (Attributes
& EFI_PCI_HOST_BRIDGE_MEM64_DECODE
) {
512 RootBridgeDev
->Decodes
|= EFI_BRIDGE_PMEM64_DECODE_SUPPORTED
;
515 RootBridgeDev
->Decodes
|= EFI_BRIDGE_MEM32_DECODE_SUPPORTED
;
516 RootBridgeDev
->Decodes
|= EFI_BRIDGE_PMEM32_DECODE_SUPPORTED
;
517 RootBridgeDev
->Decodes
|= EFI_BRIDGE_IO16_DECODE_SUPPORTED
;
523 GetMaxOptionRomSize (
524 IN PCI_IO_DEVICE
*Bridge
530 Get Max Option Rom size on this bridge
539 // TODO: Bridge - add argument and description to function comment
541 LIST_ENTRY
*CurrentLink
;
543 UINT64 MaxOptionRomSize
;
544 UINT64 TempOptionRomSize
;
546 MaxOptionRomSize
= 0;
549 // Go through bridges to reach all devices
551 CurrentLink
= Bridge
->ChildList
.ForwardLink
;
552 while (CurrentLink
&& CurrentLink
!= &Bridge
->ChildList
) {
553 Temp
= PCI_IO_DEVICE_FROM_LINK (CurrentLink
);
554 if (!IsListEmpty (&Temp
->ChildList
)) {
557 // Get max option rom size under this bridge
559 TempOptionRomSize
= GetMaxOptionRomSize (Temp
);
562 // Compare with the option rom size of the bridge
563 // Get the larger one
565 if (Temp
->RomSize
> TempOptionRomSize
) {
566 TempOptionRomSize
= Temp
->RomSize
;
572 // For devices get the rom size directly
574 TempOptionRomSize
= Temp
->RomSize
;
578 // Get the largest rom size on this bridge
580 if (TempOptionRomSize
> MaxOptionRomSize
) {
581 MaxOptionRomSize
= TempOptionRomSize
;
584 CurrentLink
= CurrentLink
->ForwardLink
;
587 return MaxOptionRomSize
;
591 PciHostBridgeDeviceAttribute (
592 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
598 Process attributes of devices on this host bridge
607 // TODO: PciResAlloc - add argument and description to function comment
608 // TODO: EFI_NOT_FOUND - add return value to function comment
609 // TODO: EFI_SUCCESS - add return value to function comment
611 EFI_HANDLE RootBridgeHandle
;
612 PCI_IO_DEVICE
*RootBridgeDev
;
615 RootBridgeHandle
= NULL
;
617 while (PciResAlloc
->GetNextRootBridge (PciResAlloc
, &RootBridgeHandle
) == EFI_SUCCESS
) {
620 // Get RootBridg Device by handle
622 RootBridgeDev
= GetRootBridgeByHandle (RootBridgeHandle
);
624 if (RootBridgeDev
== NULL
) {
625 return EFI_NOT_FOUND
;
629 // Set the attributes for devcies behind the Root Bridge
631 Status
= DetermineDeviceAttribute (RootBridgeDev
);
632 if (EFI_ERROR (Status
)) {
642 GetResourceAllocationStatus (
644 OUT UINT64
*IoResStatus
,
645 OUT UINT64
*Mem32ResStatus
,
646 OUT UINT64
*PMem32ResStatus
,
647 OUT UINT64
*Mem64ResStatus
,
648 OUT UINT64
*PMem64ResStatus
654 Get resource allocation status from the ACPI pointer
663 // TODO: AcpiConfig - add argument and description to function comment
664 // TODO: IoResStatus - add argument and description to function comment
665 // TODO: Mem32ResStatus - add argument and description to function comment
666 // TODO: PMem32ResStatus - add argument and description to function comment
667 // TODO: Mem64ResStatus - add argument and description to function comment
668 // TODO: PMem64ResStatus - add argument and description to function comment
669 // TODO: EFI_SUCCESS - add return value to function comment
674 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*ptr
;
676 Temp
= (UINT8
*) AcpiConfig
;
678 while (*Temp
== ACPI_ADDRESS_SPACE_DESCRIPTOR
) {
680 ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) Temp
;
681 ResStatus
= ptr
->AddrTranslationOffset
;
683 switch (ptr
->ResType
) {
685 if (ptr
->AddrSpaceGranularity
== 32) {
686 if (ptr
->SpecificFlag
== 0x06) {
690 *PMem32ResStatus
= ResStatus
;
695 *Mem32ResStatus
= ResStatus
;
699 if (ptr
->AddrSpaceGranularity
== 64) {
700 if (ptr
->SpecificFlag
== 0x06) {
704 *PMem64ResStatus
= ResStatus
;
709 *Mem64ResStatus
= ResStatus
;
719 *IoResStatus
= ResStatus
;
726 Temp
+= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
);
734 IN PCI_IO_DEVICE
*PciDevice
740 Remove a PCI device from device pool and mark its bar
749 // TODO: PciDevice - add argument and description to function comment
750 // TODO: EFI_SUCCESS - add return value to function comment
751 // TODO: EFI_ABORTED - add return value to function comment
752 // TODO: EFI_SUCCESS - add return value to function comment
753 // TODO: EFI_ABORTED - add return value to function comment
755 PCI_IO_DEVICE
*Bridge
;
757 LIST_ENTRY
*CurrentLink
;
760 // Remove the padding resource from a bridge
762 if ( IS_PCI_BRIDGE(&PciDevice
->Pci
) && \
763 PciDevice
->ResourcePaddingDescriptors
) {
764 gBS
->FreePool (PciDevice
->ResourcePaddingDescriptors
);
765 PciDevice
->ResourcePaddingDescriptors
= NULL
;
772 if (IS_PCI_BRIDGE (&PciDevice
->Pci
) || (!PciDevice
->Parent
)) {
776 if (IS_CARDBUS_BRIDGE (&PciDevice
->Pci
)) {
778 // Get the root bridge device
781 while (Bridge
->Parent
) {
782 Bridge
= Bridge
->Parent
;
785 RemoveAllPciDeviceOnBridge (Bridge
->Handle
, PciDevice
);
790 InitializeP2C (PciDevice
);
796 Bridge
= PciDevice
->Parent
;
797 CurrentLink
= Bridge
->ChildList
.ForwardLink
;
798 while (CurrentLink
&& CurrentLink
!= &Bridge
->ChildList
) {
799 Temp
= PCI_IO_DEVICE_FROM_LINK (CurrentLink
);
800 if (Temp
== PciDevice
) {
801 InitializePciDevice (Temp
);
802 RemoveEntryList (CurrentLink
);
803 FreePciDevice (Temp
);
807 CurrentLink
= CurrentLink
->ForwardLink
;
815 IN PCI_RESOURCE_NODE
*PciResNode
821 Determine whethter a PCI device can be rejected
830 // TODO: PciResNode - add argument and description to function comment
834 Temp
= PciResNode
->PciDev
;
837 // Ensure the device is present
844 // PPB and RB should go ahead
846 if (IS_PCI_BRIDGE (&Temp
->Pci
) || (!Temp
->Parent
)) {
851 // Skip device on Bus0
853 if ((Temp
->Parent
) && (Temp
->BusNumber
== 0)) {
860 if (IS_PCI_VGA (&Temp
->Pci
)) {
868 GetLargerConsumerDevice (
869 IN PCI_RESOURCE_NODE
*PciResNode1
,
870 IN PCI_RESOURCE_NODE
*PciResNode2
876 Get the larger resource consumer
885 // TODO: PciResNode1 - add argument and description to function comment
886 // TODO: PciResNode2 - add argument and description to function comment
892 if ((IS_PCI_BRIDGE(&(PciResNode2
->PciDev
->Pci
)) || !(PciResNode2
->PciDev
->Parent
)) \
893 && (PciResNode2
->ResourceUsage
!= PciResUsagePadding
) )
902 if ((PciResNode1
->Length
) > (PciResNode2
->Length
)) {
911 GetMaxResourceConsumerDevice (
912 IN PCI_RESOURCE_NODE
*ResPool
918 Get the max resource consumer in the host resource pool
927 // TODO: ResPool - add argument and description to function comment
929 PCI_RESOURCE_NODE
*Temp
;
930 LIST_ENTRY
*CurrentLink
;
931 PCI_RESOURCE_NODE
*PciResNode
;
932 PCI_RESOURCE_NODE
*PPBResNode
;
936 CurrentLink
= ResPool
->ChildList
.ForwardLink
;
937 while (CurrentLink
&& CurrentLink
!= &ResPool
->ChildList
) {
939 Temp
= RESOURCE_NODE_FROM_LINK (CurrentLink
);
941 if (!IsRejectiveDevice (Temp
)) {
942 CurrentLink
= CurrentLink
->ForwardLink
;
946 if ((IS_PCI_BRIDGE (&(Temp
->PciDev
->Pci
)) || (!Temp
->PciDev
->Parent
)) \
947 && (Temp
->ResourceUsage
!= PciResUsagePadding
))
949 PPBResNode
= GetMaxResourceConsumerDevice (Temp
);
950 PciResNode
= GetLargerConsumerDevice (PciResNode
, PPBResNode
);
952 PciResNode
= GetLargerConsumerDevice (PciResNode
, Temp
);
955 CurrentLink
= CurrentLink
->ForwardLink
;
962 PciHostBridgeAdjustAllocation (
963 IN PCI_RESOURCE_NODE
*IoPool
,
964 IN PCI_RESOURCE_NODE
*Mem32Pool
,
965 IN PCI_RESOURCE_NODE
*PMem32Pool
,
966 IN PCI_RESOURCE_NODE
*Mem64Pool
,
967 IN PCI_RESOURCE_NODE
*PMem64Pool
,
968 IN UINT64 IoResStatus
,
969 IN UINT64 Mem32ResStatus
,
970 IN UINT64 PMem32ResStatus
,
971 IN UINT64 Mem64ResStatus
,
972 IN UINT64 PMem64ResStatus
978 Adjust host bridge allocation so as to reduce resource requirement
987 // TODO: IoPool - add argument and description to function comment
988 // TODO: Mem32Pool - add argument and description to function comment
989 // TODO: PMem32Pool - add argument and description to function comment
990 // TODO: Mem64Pool - add argument and description to function comment
991 // TODO: PMem64Pool - add argument and description to function comment
992 // TODO: IoResStatus - add argument and description to function comment
993 // TODO: Mem32ResStatus - add argument and description to function comment
994 // TODO: PMem32ResStatus - add argument and description to function comment
995 // TODO: Mem64ResStatus - add argument and description to function comment
996 // TODO: PMem64ResStatus - add argument and description to function comment
997 // TODO: EFI_ABORTED - add return value to function comment
998 // TODO: EFI_SUCCESS - add return value to function comment
999 // TODO: EFI_ABORTED - add return value to function comment
1001 BOOLEAN AllocationAjusted
;
1002 PCI_RESOURCE_NODE
*PciResNode
;
1003 PCI_RESOURCE_NODE
*ResPool
[5];
1004 PCI_IO_DEVICE
*RemovedPciDev
[5];
1005 UINT64 ResStatus
[5];
1006 UINTN RemovedPciDevNum
;
1010 REPORT_STATUS_CODE_LIBRARY_RESOURCE_ALLOC_FAILURE_ERROR_DATA AllocFailExtendedData
;
1013 ZeroMem (RemovedPciDev
, 5 * sizeof (PCI_IO_DEVICE
*));
1014 RemovedPciDevNum
= 0;
1016 ResPool
[0] = IoPool
;
1017 ResPool
[1] = Mem32Pool
;
1018 ResPool
[2] = PMem32Pool
;
1019 ResPool
[3] = Mem64Pool
;
1020 ResPool
[4] = PMem64Pool
;
1022 ResStatus
[0] = IoResStatus
;
1023 ResStatus
[1] = Mem32ResStatus
;
1024 ResStatus
[2] = PMem32ResStatus
;
1025 ResStatus
[3] = Mem64ResStatus
;
1026 ResStatus
[4] = PMem64ResStatus
;
1028 AllocationAjusted
= FALSE
;
1030 for (ResType
= 0; ResType
< 5; ResType
++) {
1032 if (ResStatus
[ResType
] == EFI_RESOURCE_SATISFIED
) {
1036 if (ResStatus
[ResType
] == EFI_RESOURCE_NONEXISTENT
) {
1038 // Hostbridge hasn't this resource type
1044 // Hostbridge hasn't enough resource
1046 PciResNode
= GetMaxResourceConsumerDevice (ResPool
[ResType
]);
1052 // Check if the device has been removed before
1054 for (DevIndex
= 0; DevIndex
< RemovedPciDevNum
; DevIndex
++) {
1055 if (PciResNode
->PciDev
== RemovedPciDev
[DevIndex
]) {
1061 // Remove the device if it isn't in the array
1063 Status
= RejectPciDevice (PciResNode
->PciDev
);
1064 if (Status
== EFI_SUCCESS
) {
1067 // Raise the EFI_IOB_EC_RESOURCE_CONFLICT status code
1070 // Have no way to get ReqRes, AllocRes & Bar here
1072 ZeroMem (&AllocFailExtendedData
, sizeof (AllocFailExtendedData
));
1073 AllocFailExtendedData
.DevicePathSize
= sizeof (EFI_DEVICE_PATH_PROTOCOL
);
1074 AllocFailExtendedData
.DevicePath
= (UINT8
*) PciResNode
->PciDev
->DevicePath
;
1075 AllocFailExtendedData
.Bar
= PciResNode
->Bar
;
1077 REPORT_STATUS_CODE_WITH_EXTENDED_DATA (
1079 EFI_IO_BUS_PCI
| EFI_IOB_EC_RESOURCE_CONFLICT
,
1080 (VOID
*) &AllocFailExtendedData
,
1081 sizeof (AllocFailExtendedData
)
1085 // Add it to the array and indicate at least a device has been rejected
1087 RemovedPciDev
[RemovedPciDevNum
++] = PciResNode
->PciDev
;
1088 AllocationAjusted
= TRUE
;
1095 if (AllocationAjusted
) {
1103 ConstructAcpiResourceRequestor (
1104 IN PCI_IO_DEVICE
*Bridge
,
1105 IN PCI_RESOURCE_NODE
*IoNode
,
1106 IN PCI_RESOURCE_NODE
*Mem32Node
,
1107 IN PCI_RESOURCE_NODE
*PMem32Node
,
1108 IN PCI_RESOURCE_NODE
*Mem64Node
,
1109 IN PCI_RESOURCE_NODE
*PMem64Node
,
1114 Routine Description:
1123 // TODO: Bridge - add argument and description to function comment
1124 // TODO: IoNode - add argument and description to function comment
1125 // TODO: Mem32Node - add argument and description to function comment
1126 // TODO: PMem32Node - add argument and description to function comment
1127 // TODO: Mem64Node - add argument and description to function comment
1128 // TODO: PMem64Node - add argument and description to function comment
1129 // TODO: pConfig - add argument and description to function comment
1130 // TODO: EFI_OUT_OF_RESOURCES - add return value to function comment
1131 // TODO: EFI_OUT_OF_RESOURCES - add return value to function comment
1132 // TODO: EFI_SUCCESS - add return value to function comment
1136 UINT8
*Configuration
;
1137 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Ptr
;
1138 EFI_ACPI_END_TAG_DESCRIPTOR
*PtrEnd
;
1146 // if there is io request, add to the io aperture
1148 if (ResourceRequestExisted (IoNode
)) {
1154 // if there is mem32 request, add to the mem32 aperture
1156 if (ResourceRequestExisted (Mem32Node
)) {
1162 // if there is pmem32 request, add to the pmem32 aperture
1164 if (ResourceRequestExisted (PMem32Node
)) {
1170 // if there is mem64 request, add to the mem64 aperture
1172 if (ResourceRequestExisted (Mem64Node
)) {
1178 // if there is pmem64 request, add to the pmem64 aperture
1180 if (ResourceRequestExisted (PMem64Node
)) {
1185 if (NumConfig
!= 0) {
1188 // If there is at least one type of resource request,
1189 // allocate a acpi resource node
1191 Configuration
= AllocatePool (sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) * NumConfig
+ sizeof (EFI_ACPI_END_TAG_DESCRIPTOR
));
1192 if (Configuration
== NULL
) {
1193 return EFI_OUT_OF_RESOURCES
;
1198 sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) * NumConfig
+ sizeof (EFI_ACPI_END_TAG_DESCRIPTOR
)
1201 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) Configuration
;
1204 // Deal with io aperture
1206 if (Aperture
& 0x01) {
1207 Ptr
->Desc
= ACPI_ADDRESS_SPACE_DESCRIPTOR
;
1208 Ptr
->Len
= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) - 3;
1212 Ptr
->ResType
= ACPI_ADDRESS_SPACE_TYPE_IO
;
1216 Ptr
->SpecificFlag
= 1;
1217 Ptr
->AddrLen
= IoNode
->Length
;
1218 Ptr
->AddrRangeMax
= IoNode
->Alignment
;
1220 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) ((UINT8
*) Ptr
+ sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
));
1223 // Deal with mem32 aperture
1225 if (Aperture
& 0x02) {
1226 Ptr
->Desc
= ACPI_ADDRESS_SPACE_DESCRIPTOR
;
1227 Ptr
->Len
= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) - 3;
1231 Ptr
->ResType
= ACPI_ADDRESS_SPACE_TYPE_MEM
;
1235 Ptr
->SpecificFlag
= 0;
1239 Ptr
->AddrSpaceGranularity
= 32;
1240 Ptr
->AddrLen
= Mem32Node
->Length
;
1241 Ptr
->AddrRangeMax
= Mem32Node
->Alignment
;
1243 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) ((UINT8
*) Ptr
+ sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
));
1247 // Deal with Pmem32 aperture
1249 if (Aperture
& 0x04) {
1250 Ptr
->Desc
= ACPI_ADDRESS_SPACE_DESCRIPTOR
;
1251 Ptr
->Len
= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) - 3;
1255 Ptr
->ResType
= ACPI_ADDRESS_SPACE_TYPE_MEM
;
1259 Ptr
->SpecificFlag
= 0x6;
1263 Ptr
->AddrSpaceGranularity
= 32;
1264 Ptr
->AddrLen
= PMem32Node
->Length
;
1265 Ptr
->AddrRangeMax
= PMem32Node
->Alignment
;
1267 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) ((UINT8
*) Ptr
+ sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
));
1270 // Deal with mem64 aperture
1272 if (Aperture
& 0x08) {
1273 Ptr
->Desc
= ACPI_ADDRESS_SPACE_DESCRIPTOR
;
1274 Ptr
->Len
= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) - 3;
1278 Ptr
->ResType
= ACPI_ADDRESS_SPACE_TYPE_MEM
;
1282 Ptr
->SpecificFlag
= 0;
1286 Ptr
->AddrSpaceGranularity
= 64;
1287 Ptr
->AddrLen
= Mem64Node
->Length
;
1288 Ptr
->AddrRangeMax
= Mem64Node
->Alignment
;
1290 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) ((UINT8
*) Ptr
+ sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
));
1293 // Deal with Pmem64 aperture
1295 if (Aperture
& 0x10) {
1296 Ptr
->Desc
= ACPI_ADDRESS_SPACE_DESCRIPTOR
;
1297 Ptr
->Len
= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) - 3;
1301 Ptr
->ResType
= ACPI_ADDRESS_SPACE_TYPE_MEM
;
1305 Ptr
->SpecificFlag
= 0x06;
1309 Ptr
->AddrSpaceGranularity
= 64;
1310 Ptr
->AddrLen
= PMem64Node
->Length
;
1311 Ptr
->AddrRangeMax
= PMem64Node
->Alignment
;
1313 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) (Configuration
+ sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
));
1319 PtrEnd
= (EFI_ACPI_END_TAG_DESCRIPTOR
*) ((UINT8
*) Ptr
);
1321 PtrEnd
->Desc
= ACPI_END_TAG_DESCRIPTOR
;
1322 PtrEnd
->Checksum
= 0;
1327 // If there is no resource request
1329 Configuration
= AllocatePool (sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR
));
1330 if (Configuration
== NULL
) {
1331 return EFI_OUT_OF_RESOURCES
;
1334 ZeroMem (Configuration
, sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR
));
1336 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) (Configuration
);
1337 Ptr
->Desc
= ACPI_ADDRESS_SPACE_DESCRIPTOR
;
1339 PtrEnd
= (EFI_ACPI_END_TAG_DESCRIPTOR
*) (Configuration
+ sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
));
1340 PtrEnd
->Desc
= ACPI_END_TAG_DESCRIPTOR
;
1341 PtrEnd
->Checksum
= 0;
1344 *pConfig
= Configuration
;
1353 OUT UINT64
*Mem32Base
,
1354 OUT UINT64
*PMem32Base
,
1355 OUT UINT64
*Mem64Base
,
1356 OUT UINT64
*PMem64Base
1360 Routine Description:
1369 // TODO: pConfig - add argument and description to function comment
1370 // TODO: IoBase - add argument and description to function comment
1371 // TODO: Mem32Base - add argument and description to function comment
1372 // TODO: PMem32Base - add argument and description to function comment
1373 // TODO: Mem64Base - add argument and description to function comment
1374 // TODO: PMem64Base - add argument and description to function comment
1375 // TODO: EFI_SUCCESS - add return value to function comment
1378 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Ptr
;
1381 *IoBase
= 0xFFFFFFFFFFFFFFFFULL
;
1382 *Mem32Base
= 0xFFFFFFFFFFFFFFFFULL
;
1383 *PMem32Base
= 0xFFFFFFFFFFFFFFFFULL
;
1384 *Mem64Base
= 0xFFFFFFFFFFFFFFFFULL
;
1385 *PMem64Base
= 0xFFFFFFFFFFFFFFFFULL
;
1387 Temp
= (UINT8
*) pConfig
;
1389 while (*Temp
== ACPI_ADDRESS_SPACE_DESCRIPTOR
) {
1391 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) Temp
;
1392 ResStatus
= Ptr
->AddrTranslationOffset
;
1394 if (ResStatus
== EFI_RESOURCE_SATISFIED
) {
1396 switch (Ptr
->ResType
) {
1399 // Memory type aperture
1404 // Check to see the granularity
1406 if (Ptr
->AddrSpaceGranularity
== 32) {
1407 if (Ptr
->SpecificFlag
& 0x06) {
1408 *PMem32Base
= Ptr
->AddrRangeMin
;
1410 *Mem32Base
= Ptr
->AddrRangeMin
;
1414 if (Ptr
->AddrSpaceGranularity
== 64) {
1415 if (Ptr
->SpecificFlag
& 0x06) {
1416 *PMem64Base
= Ptr
->AddrRangeMin
;
1418 *Mem64Base
= Ptr
->AddrRangeMin
;
1428 *IoBase
= Ptr
->AddrRangeMin
;
1442 Temp
+= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
);
1449 PciBridgeEnumerator (
1450 IN PCI_IO_DEVICE
*BridgeDev
1454 Routine Description:
1463 // TODO: BridgeDev - add argument and description to function comment
1464 // TODO: EFI_SUCCESS - add return value to function comment
1467 UINT8 StartBusNumber
;
1468 EFI_PCI_IO_PROTOCOL
*PciIo
;
1473 PciIo
= &(BridgeDev
->PciIo
);
1474 Status
= PciIo
->Pci
.Read (PciIo
, EfiPciIoWidthUint8
, 0x19, 1, &StartBusNumber
);
1476 if (EFI_ERROR (Status
)) {
1480 Status
= PciAssignBusNumber (
1486 if (EFI_ERROR (Status
)) {
1490 Status
= PciPciDeviceInfoCollector (BridgeDev
, StartBusNumber
);
1492 if (EFI_ERROR (Status
)) {
1496 Status
= PciBridgeResourceAllocator (BridgeDev
);
1498 if (EFI_ERROR (Status
)) {
1502 Status
= DetermineDeviceAttribute (BridgeDev
);
1504 if (EFI_ERROR (Status
)) {
1513 PciBridgeResourceAllocator (
1514 IN PCI_IO_DEVICE
*Bridge
1518 Routine Description:
1527 // TODO: Bridge - add argument and description to function comment
1528 // TODO: EFI_SUCCESS - add return value to function comment
1530 PCI_RESOURCE_NODE
*IoBridge
;
1531 PCI_RESOURCE_NODE
*Mem32Bridge
;
1532 PCI_RESOURCE_NODE
*PMem32Bridge
;
1533 PCI_RESOURCE_NODE
*Mem64Bridge
;
1534 PCI_RESOURCE_NODE
*PMem64Bridge
;
1542 IoBridge
= CreateResourceNode (
1551 Mem32Bridge
= CreateResourceNode (
1560 PMem32Bridge
= CreateResourceNode (
1569 Mem64Bridge
= CreateResourceNode (
1578 PMem64Bridge
= CreateResourceNode (
1588 // Create resourcemap by going through all the devices subject to this root bridge
1590 Status
= CreateResourceMap (
1599 if (EFI_ERROR (Status
)) {
1603 Status
= GetResourceBaseFromBridge (
1612 if (EFI_ERROR (Status
)) {
1617 // Program IO resources
1625 // Program Mem32 resources
1633 // Program PMem32 resources
1641 // Program Mem64 resources
1649 // Program PMem64 resources
1656 DestroyResourceTree (IoBridge
);
1657 DestroyResourceTree (Mem32Bridge
);
1658 DestroyResourceTree (PMem32Bridge
);
1659 DestroyResourceTree (PMem64Bridge
);
1660 DestroyResourceTree (Mem64Bridge
);
1662 gBS
->FreePool (IoBridge
);
1663 gBS
->FreePool (Mem32Bridge
);
1664 gBS
->FreePool (PMem32Bridge
);
1665 gBS
->FreePool (PMem64Bridge
);
1666 gBS
->FreePool (Mem64Bridge
);
1672 GetResourceBaseFromBridge (
1673 IN PCI_IO_DEVICE
*Bridge
,
1675 OUT UINT64
*Mem32Base
,
1676 OUT UINT64
*PMem32Base
,
1677 OUT UINT64
*Mem64Base
,
1678 OUT UINT64
*PMem64Base
1682 Routine Description:
1691 // TODO: Bridge - add argument and description to function comment
1692 // TODO: IoBase - add argument and description to function comment
1693 // TODO: Mem32Base - add argument and description to function comment
1694 // TODO: PMem32Base - add argument and description to function comment
1695 // TODO: Mem64Base - add argument and description to function comment
1696 // TODO: PMem64Base - add argument and description to function comment
1697 // TODO: EFI_OUT_OF_RESOURCES - add return value to function comment
1698 // TODO: EFI_SUCCESS - add return value to function comment
1700 if (!Bridge
->Allocated
) {
1701 return EFI_OUT_OF_RESOURCES
;
1705 *Mem32Base
= gAllOne
;
1706 *PMem32Base
= gAllOne
;
1707 *Mem64Base
= gAllOne
;
1708 *PMem64Base
= gAllOne
;
1710 if (IS_PCI_BRIDGE (&Bridge
->Pci
)) {
1712 if (Bridge
->PciBar
[PPB_IO_RANGE
].Length
) {
1713 *IoBase
= Bridge
->PciBar
[PPB_IO_RANGE
].BaseAddress
;
1716 if (Bridge
->PciBar
[PPB_MEM32_RANGE
].Length
) {
1717 *Mem32Base
= Bridge
->PciBar
[PPB_MEM32_RANGE
].BaseAddress
;
1720 if (Bridge
->PciBar
[PPB_PMEM32_RANGE
].Length
) {
1721 *PMem32Base
= Bridge
->PciBar
[PPB_PMEM32_RANGE
].BaseAddress
;
1724 if (Bridge
->PciBar
[PPB_PMEM64_RANGE
].Length
) {
1725 *PMem64Base
= Bridge
->PciBar
[PPB_PMEM64_RANGE
].BaseAddress
;
1727 *PMem64Base
= gAllOne
;
1732 if (IS_CARDBUS_BRIDGE (&Bridge
->Pci
)) {
1733 if (Bridge
->PciBar
[P2C_IO_1
].Length
) {
1734 *IoBase
= Bridge
->PciBar
[P2C_IO_1
].BaseAddress
;
1736 if (Bridge
->PciBar
[P2C_IO_2
].Length
) {
1737 *IoBase
= Bridge
->PciBar
[P2C_IO_2
].BaseAddress
;
1741 if (Bridge
->PciBar
[P2C_MEM_1
].Length
) {
1742 if (Bridge
->PciBar
[P2C_MEM_1
].BarType
== PciBarTypePMem32
) {
1743 *PMem32Base
= Bridge
->PciBar
[P2C_MEM_1
].BaseAddress
;
1746 if (Bridge
->PciBar
[P2C_MEM_1
].BarType
== PciBarTypeMem32
) {
1747 *Mem32Base
= Bridge
->PciBar
[P2C_MEM_1
].BaseAddress
;
1751 if (Bridge
->PciBar
[P2C_MEM_2
].Length
) {
1752 if (Bridge
->PciBar
[P2C_MEM_2
].BarType
== PciBarTypePMem32
) {
1753 *PMem32Base
= Bridge
->PciBar
[P2C_MEM_2
].BaseAddress
;
1756 if (Bridge
->PciBar
[P2C_MEM_2
].BarType
== PciBarTypeMem32
) {
1757 *Mem32Base
= Bridge
->PciBar
[P2C_MEM_2
].BaseAddress
;
1767 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
,
1768 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase
1772 Routine Description:
1781 // TODO: PciResAlloc - add argument and description to function comment
1782 // TODO: Phase - add argument and description to function comment
1783 // TODO: EFI_NOT_FOUND - add return value to function comment
1784 // TODO: EFI_SUCCESS - add return value to function comment
1786 EFI_HANDLE HostBridgeHandle
;
1787 EFI_HANDLE RootBridgeHandle
;
1788 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
;
1791 HostBridgeHandle
= NULL
;
1792 RootBridgeHandle
= NULL
;
1793 if (gPciPlatformProtocol
!= NULL
) {
1795 // Get Host Bridge Handle.
1797 PciResAlloc
->GetNextRootBridge (PciResAlloc
, &RootBridgeHandle
);
1800 // Get the rootbridge Io protocol to find the host bridge handle
1802 Status
= gBS
->HandleProtocol (
1804 &gEfiPciRootBridgeIoProtocolGuid
,
1805 (VOID
**) &PciRootBridgeIo
1808 if (EFI_ERROR (Status
)) {
1809 return EFI_NOT_FOUND
;
1812 HostBridgeHandle
= PciRootBridgeIo
->ParentHandle
;
1815 // Call PlatformPci::PhaseNotify() if the protocol is present.
1817 gPciPlatformProtocol
->PhaseNotify (
1818 gPciPlatformProtocol
,
1825 Status
= PciResAlloc
->NotifyPhase (
1830 if (gPciPlatformProtocol
!= NULL
) {
1832 // Call PlatformPci::PhaseNotify() if the protocol is present.
1834 gPciPlatformProtocol
->PhaseNotify (
1835 gPciPlatformProtocol
,
1847 PreprocessController (
1848 IN PCI_IO_DEVICE
*Bridge
,
1852 IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase
1856 Routine Description:
1865 // TODO: Bridge - add argument and description to function comment
1866 // TODO: Bus - add argument and description to function comment
1867 // TODO: Device - add argument and description to function comment
1868 // TODO: Func - add argument and description to function comment
1869 // TODO: Phase - add argument and description to function comment
1870 // TODO: EFI_UNSUPPORTED - add return value to function comment
1871 // TODO: EFI_SUCCESS - add return value to function comment
1873 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS RootBridgePciAddress
;
1874 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
;
1875 EFI_HANDLE RootBridgeHandle
;
1876 EFI_HANDLE HostBridgeHandle
;
1880 // Get the host bridge handle
1882 HostBridgeHandle
= Bridge
->PciRootBridgeIo
->ParentHandle
;
1885 // Get the pci host bridge resource allocation protocol
1887 Status
= gBS
->OpenProtocol (
1889 &gEfiPciHostBridgeResourceAllocationProtocolGuid
,
1890 (VOID
**) &PciResAlloc
,
1893 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1896 if (EFI_ERROR (Status
)) {
1897 return EFI_UNSUPPORTED
;
1901 // Get Root Brige Handle
1903 while (Bridge
->Parent
) {
1904 Bridge
= Bridge
->Parent
;
1907 RootBridgeHandle
= Bridge
->Handle
;
1909 RootBridgePciAddress
.Register
= 0;
1910 RootBridgePciAddress
.Function
= Func
;
1911 RootBridgePciAddress
.Device
= Device
;
1912 RootBridgePciAddress
.Bus
= Bus
;
1913 RootBridgePciAddress
.ExtendedRegister
= 0;
1915 if (gPciPlatformProtocol
!= NULL
) {
1917 // Call PlatformPci::PrepController() if the protocol is present.
1919 gPciPlatformProtocol
->PlatformPrepController (
1920 gPciPlatformProtocol
,
1923 RootBridgePciAddress
,
1929 Status
= PciResAlloc
->PreprocessController (
1932 RootBridgePciAddress
,
1936 if (gPciPlatformProtocol
!= NULL
) {
1938 // Call PlatformPci::PrepController() if the protocol is present.
1940 gPciPlatformProtocol
->PlatformPrepController (
1941 gPciPlatformProtocol
,
1944 RootBridgePciAddress
,
1955 PciHotPlugRequestNotify (
1956 IN EFI_PCI_HOTPLUG_REQUEST_PROTOCOL
* This
,
1957 IN EFI_PCI_HOTPLUG_OPERATION Operation
,
1958 IN EFI_HANDLE Controller
,
1959 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
,
1960 IN OUT UINT8
*NumberOfChildren
,
1961 IN OUT EFI_HANDLE
* ChildHandleBuffer
1965 Routine Description:
1967 Hot plug request notify.
1971 This - A pointer to the hot plug request protocol.
1972 Operation - The operation.
1973 Controller - A pointer to the controller.
1974 RemainningDevicePath - A pointer to the device path.
1975 NumberOfChildren - A the number of child handle in the ChildHandleBuffer.
1976 ChildHandleBuffer - A pointer to the array contain the child handle.
1983 // TODO: RemainingDevicePath - add argument and description to function comment
1984 // TODO: EFI_NOT_FOUND - add return value to function comment
1985 // TODO: EFI_SUCCESS - add return value to function comment
1986 // TODO: EFI_SUCCESS - add return value to function comment
1987 // TODO: EFI_SUCCESS - add return value to function comment
1989 PCI_IO_DEVICE
*Bridge
;
1990 PCI_IO_DEVICE
*Temp
;
1991 EFI_PCI_IO_PROTOCOL
*PciIo
;
1993 EFI_HANDLE RootBridgeHandle
;
1996 Status
= gBS
->OpenProtocol (
1998 &gEfiPciIoProtocolGuid
,
2000 gPciBusDriverBinding
.DriverBindingHandle
,
2002 EFI_OPEN_PROTOCOL_GET_PROTOCOL
2005 if (EFI_ERROR (Status
)) {
2006 return EFI_NOT_FOUND
;
2009 Bridge
= PCI_IO_DEVICE_FROM_PCI_IO_THIS (PciIo
);
2012 // Get root bridge handle
2015 while (Temp
->Parent
) {
2016 Temp
= Temp
->Parent
;
2019 RootBridgeHandle
= Temp
->Handle
;
2021 if (Operation
== EfiPciHotPlugRequestAdd
) {
2023 if (NumberOfChildren
!= NULL
) {
2024 *NumberOfChildren
= 0;
2027 if (IsListEmpty (&Bridge
->ChildList
)) {
2029 Status
= PciBridgeEnumerator (Bridge
);
2031 if (EFI_ERROR (Status
)) {
2036 Status
= StartPciDevicesOnBridge (
2039 RemainingDevicePath
,
2047 if (Operation
== EfiPciHotplugRequestRemove
) {
2049 if (*NumberOfChildren
== 0) {
2051 // Remove all devices on the bridge
2053 Status
= RemoveAllPciDeviceOnBridge (RootBridgeHandle
, Bridge
);
2058 for (Index
= 0; Index
< *NumberOfChildren
; Index
++) {
2060 // De register all the pci device
2062 Status
= DeRegisterPciDevice (RootBridgeHandle
, ChildHandleBuffer
[Index
]);
2064 if (EFI_ERROR (Status
)) {
2079 SearchHostBridgeHandle (
2080 IN EFI_HANDLE RootBridgeHandle
2084 Routine Description:
2093 // TODO: RootBridgeHandle - add argument and description to function comment
2095 EFI_HANDLE HostBridgeHandle
;
2096 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
;
2101 // Get the rootbridge Io protocol to find the host bridge handle
2103 Status
= gBS
->OpenProtocol (
2105 &gEfiPciRootBridgeIoProtocolGuid
,
2106 (VOID
**) &PciRootBridgeIo
,
2107 gPciBusDriverBinding
.DriverBindingHandle
,
2109 EFI_OPEN_PROTOCOL_GET_PROTOCOL
2112 if (EFI_ERROR (Status
)) {
2116 HostBridgeHandle
= PciRootBridgeIo
->ParentHandle
;
2117 for (Index
= 0; Index
< gPciHostBridgeNumber
; Index
++) {
2118 if (HostBridgeHandle
== gPciHostBrigeHandles
[Index
]) {
2127 AddHostBridgeEnumerator (
2128 IN EFI_HANDLE HostBridgeHandle
2132 Routine Description:
2141 // TODO: HostBridgeHandle - add argument and description to function comment
2142 // TODO: EFI_ABORTED - add return value to function comment
2143 // TODO: EFI_ABORTED - add return value to function comment
2144 // TODO: EFI_SUCCESS - add return value to function comment
2148 if (!HostBridgeHandle
) {
2152 for (Index
= 0; Index
< gPciHostBridgeNumber
; Index
++) {
2153 if (HostBridgeHandle
== gPciHostBrigeHandles
[Index
]) {
2158 if (Index
< PCI_MAX_HOST_BRIDGE_NUM
) {
2159 gPciHostBrigeHandles
[Index
] = HostBridgeHandle
;
2160 gPciHostBridgeNumber
++;