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.
16 #include "PciEnumerator.h"
17 #include "PciResourceSupport.h"
18 #include "PciOptionRomSupport.h"
22 IN EFI_HANDLE Controller
28 This routine is used to enumerate entire pci bus system
38 // TODO: Controller - add argument and description to function comment
39 // TODO: EFI_SUCCESS - add return value to function comment
40 // TODO: EFI_SUCCESS - add return value to function comment
43 EFI_HANDLE HostBridgeHandle
;
45 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
;
46 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
;
49 // If PCI bus has already done the full enumeration, never do it again
51 if (!gFullEnumeration
) {
52 return PciEnumeratorLight (Controller
);
56 // Get the rootbridge Io protocol to find the host bridge handle
58 Status
= gBS
->OpenProtocol (
60 &gEfiPciRootBridgeIoProtocolGuid
,
61 (VOID
**) &PciRootBridgeIo
,
62 gPciBusDriverBinding
.DriverBindingHandle
,
64 EFI_OPEN_PROTOCOL_GET_PROTOCOL
67 if (EFI_ERROR (Status
)) {
72 // Get the host bridge handle
74 HostBridgeHandle
= PciRootBridgeIo
->ParentHandle
;
77 // Get the pci host bridge resource allocation protocol
79 Status
= gBS
->OpenProtocol (
81 &gEfiPciHostBridgeResourceAllocationProtocolGuid
,
82 (VOID
**) &PciResAlloc
,
83 gPciBusDriverBinding
.DriverBindingHandle
,
85 EFI_OPEN_PROTOCOL_GET_PROTOCOL
88 if (EFI_ERROR (Status
)) {
93 // Notify the pci bus enumeration is about to begin
95 NotifyPhase (PciResAlloc
, EfiPciHostBridgeBeginEnumeration
);
98 // Start the bus allocation phase
100 Status
= PciHostBridgeEnumerator (PciResAlloc
);
102 if (EFI_ERROR (Status
)) {
107 // Submit the resource request
109 Status
= PciHostBridgeResourceAllocator (PciResAlloc
);
111 if (EFI_ERROR (Status
)) {
118 Status
= PciHostBridgeP2CProcess (PciResAlloc
);
120 if (EFI_ERROR (Status
)) {
125 // Process attributes for devices on this host bridge
127 Status
= PciHostBridgeDeviceAttribute (PciResAlloc
);
128 if (EFI_ERROR (Status
)) {
132 gFullEnumeration
= FALSE
;
138 PciRootBridgeEnumerator (
139 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
,
140 IN PCI_IO_DEVICE
*RootBridgeDev
153 // TODO: PciResAlloc - add argument and description to function comment
154 // TODO: RootBridgeDev - add argument and description to function comment
155 // TODO: EFI_SUCCESS - add return value to function comment
158 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*pConfiguration
;
160 UINT8 StartBusNumber
;
161 UINT8 PaddedBusRange
;
162 EFI_HANDLE RootBridgeHandle
;
169 // Get the root bridge handle
171 RootBridgeHandle
= RootBridgeDev
->Handle
;
173 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
175 EFI_IO_BUS_PCI
| EFI_IOB_PCI_PC_BUS_ENUM
,
176 RootBridgeDev
->DevicePath
180 // Get the Bus information
182 Status
= PciResAlloc
->StartBusEnumeration (
185 (VOID
**) &pConfiguration
188 if (EFI_ERROR (Status
)) {
193 // Get the bus number to start with
195 StartBusNumber
= (UINT8
) (pConfiguration
->AddrRangeMin
);
196 PaddedBusRange
= (UINT8
) (pConfiguration
->AddrRangeMax
);
199 // Initialize the subordinate bus number
201 SubBusNumber
= StartBusNumber
;
204 // Reset all assigned PCI bus number
206 ResetAllPpbBusNumber (
214 Status
= PciScanBus (
216 (UINT8
) (pConfiguration
->AddrRangeMin
),
221 if (EFI_ERROR (Status
)) {
227 // Assign max bus number scanned
229 pConfiguration
->AddrLen
= SubBusNumber
- StartBusNumber
+ 1 + PaddedBusRange
;
234 Status
= PciResAlloc
->SetBusNumbers (
240 gBS
->FreePool (pConfiguration
);
242 if (EFI_ERROR (Status
)) {
251 IN PCI_IO_DEVICE
*Bridge
,
259 This routine is used to process option rom on a certain root bridge
268 // TODO: Bridge - add argument and description to function comment
269 // TODO: RomBase - add argument and description to function comment
270 // TODO: MaxLength - add argument and description to function comment
271 // TODO: EFI_SUCCESS - add return value to function comment
273 LIST_ENTRY
*CurrentLink
;
277 // Go through bridges to reach all devices
279 CurrentLink
= Bridge
->ChildList
.ForwardLink
;
280 while (CurrentLink
&& CurrentLink
!= &Bridge
->ChildList
) {
281 Temp
= PCI_IO_DEVICE_FROM_LINK (CurrentLink
);
282 if (!IsListEmpty (&Temp
->ChildList
)) {
285 // Go further to process the option rom under this bridge
287 ProcessOptionRom (Temp
, RomBase
, MaxLength
);
290 if (Temp
->RomSize
!= 0 && Temp
->RomSize
<= MaxLength
) {
293 // Load and process the option rom
295 LoadOpRomImage (Temp
, RomBase
);
298 CurrentLink
= CurrentLink
->ForwardLink
;
306 IN PCI_IO_DEVICE
*Bridge
,
307 IN UINT8 StartBusNumber
,
308 OUT UINT8
*SubBusNumber
314 This routine is used to assign bus number to the given PCI bus system
323 // TODO: Bridge - add argument and description to function comment
324 // TODO: StartBusNumber - add argument and description to function comment
325 // TODO: SubBusNumber - add argument and description to function comment
326 // TODO: EFI_DEVICE_ERROR - add return value to function comment
327 // TODO: EFI_SUCCESS - add return value to function comment
337 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
;
339 PciRootBridgeIo
= Bridge
->PciRootBridgeIo
;
344 *SubBusNumber
= StartBusNumber
;
347 // First check to see whether the parent is ppb
349 for (Device
= 0; Device
<= PCI_MAX_DEVICE
; Device
++) {
350 for (Func
= 0; Func
<= PCI_MAX_FUNC
; Func
++) {
353 // Check to see whether a pci device is present
356 Status
= PciDevicePresent (
364 if (!EFI_ERROR (Status
) &&
365 (IS_PCI_BRIDGE (&Pci
) || IS_CARDBUS_BRIDGE (&Pci
))) {
368 // Reserved one bus for cardbus bridge
370 SecondBus
= ++(*SubBusNumber
);
372 Register
= (UINT16
) ((SecondBus
<< 8) | (UINT16
) StartBusNumber
);
374 Address
= EFI_PCI_ADDRESS (StartBusNumber
, Device
, Func
, 0x18);
376 Status
= PciRootBridgeIoWrite (
386 // Initialize SubBusNumber to SecondBus
388 Address
= EFI_PCI_ADDRESS (StartBusNumber
, Device
, Func
, 0x1A);
389 Status
= PciRootBridgeIoWrite (
398 // If it is PPB, resursively search down this bridge
400 if (IS_PCI_BRIDGE (&Pci
)) {
403 Status
= PciRootBridgeIoWrite (
412 Status
= PciAssignBusNumber (
418 if (EFI_ERROR (Status
)) {
419 return EFI_DEVICE_ERROR
;
424 // Set the current maximum bus number under the PPB
427 Address
= EFI_PCI_ADDRESS (StartBusNumber
, Device
, Func
, 0x1A);
429 Status
= PciRootBridgeIoWrite (
440 if (Func
== 0 && !IS_PCI_MULTI_FUNC (&Pci
)) {
443 // Skip sub functions, this is not a multi function device
455 DetermineRootBridgeAttributes (
456 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
,
457 IN PCI_IO_DEVICE
*RootBridgeDev
463 This routine is used to determine the root bridge attribute by interfacing
464 the host bridge resource allocation protocol.
473 // TODO: PciResAlloc - add argument and description to function comment
474 // TODO: RootBridgeDev - add argument and description to function comment
475 // TODO: EFI_SUCCESS - add return value to function comment
479 EFI_HANDLE RootBridgeHandle
;
482 RootBridgeHandle
= RootBridgeDev
->Handle
;
485 // Get root bridge attribute by calling into pci host bridge resource allocation protocol
487 Status
= PciResAlloc
->GetAllocAttributes (
493 if (EFI_ERROR (Status
)) {
498 // Here is the point where PCI bus driver calls HOST bridge allocation protocol
499 // Currently we hardcoded for ea815
502 if (Attributes
& EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM
) {
503 RootBridgeDev
->Decodes
|= EFI_BRIDGE_PMEM_MEM_COMBINE_SUPPORTED
;
506 if (Attributes
& EFI_PCI_HOST_BRIDGE_MEM64_DECODE
) {
507 RootBridgeDev
->Decodes
|= EFI_BRIDGE_PMEM64_DECODE_SUPPORTED
;
510 RootBridgeDev
->Decodes
|= EFI_BRIDGE_MEM32_DECODE_SUPPORTED
;
511 RootBridgeDev
->Decodes
|= EFI_BRIDGE_PMEM32_DECODE_SUPPORTED
;
512 RootBridgeDev
->Decodes
|= EFI_BRIDGE_IO16_DECODE_SUPPORTED
;
518 GetMaxOptionRomSize (
519 IN PCI_IO_DEVICE
*Bridge
525 Get Max Option Rom size on this bridge
534 // TODO: Bridge - add argument and description to function comment
536 LIST_ENTRY
*CurrentLink
;
538 UINT64 MaxOptionRomSize
;
539 UINT64 TempOptionRomSize
;
541 MaxOptionRomSize
= 0;
544 // Go through bridges to reach all devices
546 CurrentLink
= Bridge
->ChildList
.ForwardLink
;
547 while (CurrentLink
&& CurrentLink
!= &Bridge
->ChildList
) {
548 Temp
= PCI_IO_DEVICE_FROM_LINK (CurrentLink
);
549 if (!IsListEmpty (&Temp
->ChildList
)) {
552 // Get max option rom size under this bridge
554 TempOptionRomSize
= GetMaxOptionRomSize (Temp
);
557 // Compare with the option rom size of the bridge
558 // Get the larger one
560 if (Temp
->RomSize
> TempOptionRomSize
) {
561 TempOptionRomSize
= Temp
->RomSize
;
567 // For devices get the rom size directly
569 TempOptionRomSize
= Temp
->RomSize
;
573 // Get the largest rom size on this bridge
575 if (TempOptionRomSize
> MaxOptionRomSize
) {
576 MaxOptionRomSize
= TempOptionRomSize
;
579 CurrentLink
= CurrentLink
->ForwardLink
;
582 return MaxOptionRomSize
;
586 PciHostBridgeDeviceAttribute (
587 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
593 Process attributes of devices on this host bridge
602 // TODO: PciResAlloc - add argument and description to function comment
603 // TODO: EFI_NOT_FOUND - add return value to function comment
604 // TODO: EFI_SUCCESS - add return value to function comment
606 EFI_HANDLE RootBridgeHandle
;
607 PCI_IO_DEVICE
*RootBridgeDev
;
610 RootBridgeHandle
= NULL
;
612 while (PciResAlloc
->GetNextRootBridge (PciResAlloc
, &RootBridgeHandle
) == EFI_SUCCESS
) {
615 // Get RootBridg Device by handle
617 RootBridgeDev
= GetRootBridgeByHandle (RootBridgeHandle
);
619 if (RootBridgeDev
== NULL
) {
620 return EFI_NOT_FOUND
;
624 // Set the attributes for devcies behind the Root Bridge
626 Status
= DetermineDeviceAttribute (RootBridgeDev
);
627 if (EFI_ERROR (Status
)) {
637 GetResourceAllocationStatus (
639 OUT UINT64
*IoResStatus
,
640 OUT UINT64
*Mem32ResStatus
,
641 OUT UINT64
*PMem32ResStatus
,
642 OUT UINT64
*Mem64ResStatus
,
643 OUT UINT64
*PMem64ResStatus
649 Get resource allocation status from the ACPI pointer
658 // TODO: AcpiConfig - add argument and description to function comment
659 // TODO: IoResStatus - add argument and description to function comment
660 // TODO: Mem32ResStatus - add argument and description to function comment
661 // TODO: PMem32ResStatus - add argument and description to function comment
662 // TODO: Mem64ResStatus - add argument and description to function comment
663 // TODO: PMem64ResStatus - add argument and description to function comment
664 // TODO: EFI_SUCCESS - add return value to function comment
669 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*ptr
;
671 Temp
= (UINT8
*) AcpiConfig
;
673 while (*Temp
== ACPI_ADDRESS_SPACE_DESCRIPTOR
) {
675 ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) Temp
;
676 ResStatus
= ptr
->AddrTranslationOffset
;
678 switch (ptr
->ResType
) {
680 if (ptr
->AddrSpaceGranularity
== 32) {
681 if (ptr
->SpecificFlag
== 0x06) {
685 *PMem32ResStatus
= ResStatus
;
690 *Mem32ResStatus
= ResStatus
;
694 if (ptr
->AddrSpaceGranularity
== 64) {
695 if (ptr
->SpecificFlag
== 0x06) {
699 *PMem64ResStatus
= ResStatus
;
704 *Mem64ResStatus
= ResStatus
;
714 *IoResStatus
= ResStatus
;
721 Temp
+= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
);
729 IN PCI_IO_DEVICE
*PciDevice
735 Remove a PCI device from device pool and mark its bar
744 // TODO: PciDevice - add argument and description to function comment
745 // TODO: EFI_SUCCESS - add return value to function comment
746 // TODO: EFI_ABORTED - add return value to function comment
747 // TODO: EFI_SUCCESS - add return value to function comment
748 // TODO: EFI_ABORTED - add return value to function comment
750 PCI_IO_DEVICE
*Bridge
;
752 LIST_ENTRY
*CurrentLink
;
755 // Remove the padding resource from a bridge
757 if ( IS_PCI_BRIDGE(&PciDevice
->Pci
) && \
758 PciDevice
->ResourcePaddingDescriptors
) {
759 gBS
->FreePool (PciDevice
->ResourcePaddingDescriptors
);
760 PciDevice
->ResourcePaddingDescriptors
= NULL
;
767 if (IS_PCI_BRIDGE (&PciDevice
->Pci
) || (!PciDevice
->Parent
)) {
771 if (IS_CARDBUS_BRIDGE (&PciDevice
->Pci
)) {
773 // Get the root bridge device
776 while (Bridge
->Parent
) {
777 Bridge
= Bridge
->Parent
;
780 RemoveAllPciDeviceOnBridge (Bridge
->Handle
, PciDevice
);
785 InitializeP2C (PciDevice
);
791 Bridge
= PciDevice
->Parent
;
792 CurrentLink
= Bridge
->ChildList
.ForwardLink
;
793 while (CurrentLink
&& CurrentLink
!= &Bridge
->ChildList
) {
794 Temp
= PCI_IO_DEVICE_FROM_LINK (CurrentLink
);
795 if (Temp
== PciDevice
) {
796 InitializePciDevice (Temp
);
797 RemoveEntryList (CurrentLink
);
798 FreePciDevice (Temp
);
802 CurrentLink
= CurrentLink
->ForwardLink
;
810 IN PCI_RESOURCE_NODE
*PciResNode
816 Determine whethter a PCI device can be rejected
825 // TODO: PciResNode - add argument and description to function comment
829 Temp
= PciResNode
->PciDev
;
832 // Ensure the device is present
839 // PPB and RB should go ahead
841 if (IS_PCI_BRIDGE (&Temp
->Pci
) || (!Temp
->Parent
)) {
846 // Skip device on Bus0
848 if ((Temp
->Parent
) && (Temp
->BusNumber
== 0)) {
855 if (IS_PCI_VGA (&Temp
->Pci
)) {
863 GetLargerConsumerDevice (
864 IN PCI_RESOURCE_NODE
*PciResNode1
,
865 IN PCI_RESOURCE_NODE
*PciResNode2
871 Get the larger resource consumer
880 // TODO: PciResNode1 - add argument and description to function comment
881 // TODO: PciResNode2 - add argument and description to function comment
887 if ((IS_PCI_BRIDGE(&(PciResNode2
->PciDev
->Pci
)) || !(PciResNode2
->PciDev
->Parent
)) \
888 && (PciResNode2
->ResourceUsage
!= PciResUsagePadding
) )
897 if ((PciResNode1
->Length
) > (PciResNode2
->Length
)) {
906 GetMaxResourceConsumerDevice (
907 IN PCI_RESOURCE_NODE
*ResPool
913 Get the max resource consumer in the host resource pool
922 // TODO: ResPool - add argument and description to function comment
924 PCI_RESOURCE_NODE
*Temp
;
925 LIST_ENTRY
*CurrentLink
;
926 PCI_RESOURCE_NODE
*PciResNode
;
927 PCI_RESOURCE_NODE
*PPBResNode
;
931 CurrentLink
= ResPool
->ChildList
.ForwardLink
;
932 while (CurrentLink
&& CurrentLink
!= &ResPool
->ChildList
) {
934 Temp
= RESOURCE_NODE_FROM_LINK (CurrentLink
);
936 if (!IsRejectiveDevice (Temp
)) {
937 CurrentLink
= CurrentLink
->ForwardLink
;
941 if ((IS_PCI_BRIDGE (&(Temp
->PciDev
->Pci
)) || (!Temp
->PciDev
->Parent
)) \
942 && (Temp
->ResourceUsage
!= PciResUsagePadding
))
944 PPBResNode
= GetMaxResourceConsumerDevice (Temp
);
945 PciResNode
= GetLargerConsumerDevice (PciResNode
, PPBResNode
);
947 PciResNode
= GetLargerConsumerDevice (PciResNode
, Temp
);
950 CurrentLink
= CurrentLink
->ForwardLink
;
957 PciHostBridgeAdjustAllocation (
958 IN PCI_RESOURCE_NODE
*IoPool
,
959 IN PCI_RESOURCE_NODE
*Mem32Pool
,
960 IN PCI_RESOURCE_NODE
*PMem32Pool
,
961 IN PCI_RESOURCE_NODE
*Mem64Pool
,
962 IN PCI_RESOURCE_NODE
*PMem64Pool
,
963 IN UINT64 IoResStatus
,
964 IN UINT64 Mem32ResStatus
,
965 IN UINT64 PMem32ResStatus
,
966 IN UINT64 Mem64ResStatus
,
967 IN UINT64 PMem64ResStatus
973 Adjust host bridge allocation so as to reduce resource requirement
982 // TODO: IoPool - add argument and description to function comment
983 // TODO: Mem32Pool - add argument and description to function comment
984 // TODO: PMem32Pool - add argument and description to function comment
985 // TODO: Mem64Pool - add argument and description to function comment
986 // TODO: PMem64Pool - add argument and description to function comment
987 // TODO: IoResStatus - add argument and description to function comment
988 // TODO: Mem32ResStatus - add argument and description to function comment
989 // TODO: PMem32ResStatus - add argument and description to function comment
990 // TODO: Mem64ResStatus - add argument and description to function comment
991 // TODO: PMem64ResStatus - add argument and description to function comment
992 // TODO: EFI_ABORTED - add return value to function comment
993 // TODO: EFI_SUCCESS - add return value to function comment
994 // TODO: EFI_ABORTED - add return value to function comment
996 BOOLEAN AllocationAjusted
;
997 PCI_RESOURCE_NODE
*PciResNode
;
998 PCI_RESOURCE_NODE
*ResPool
[5];
999 PCI_IO_DEVICE
*RemovedPciDev
[5];
1000 UINT64 ResStatus
[5];
1001 UINTN RemovedPciDevNum
;
1005 EFI_RESOURCE_ALLOC_FAILURE_ERROR_DATA_PAYLOAD AllocFailExtendedData
;
1008 ZeroMem (RemovedPciDev
, 5 * sizeof (PCI_IO_DEVICE
*));
1009 RemovedPciDevNum
= 0;
1011 ResPool
[0] = IoPool
;
1012 ResPool
[1] = Mem32Pool
;
1013 ResPool
[2] = PMem32Pool
;
1014 ResPool
[3] = Mem64Pool
;
1015 ResPool
[4] = PMem64Pool
;
1017 ResStatus
[0] = IoResStatus
;
1018 ResStatus
[1] = Mem32ResStatus
;
1019 ResStatus
[2] = PMem32ResStatus
;
1020 ResStatus
[3] = Mem64ResStatus
;
1021 ResStatus
[4] = PMem64ResStatus
;
1023 AllocationAjusted
= FALSE
;
1025 for (ResType
= 0; ResType
< 5; ResType
++) {
1027 if (ResStatus
[ResType
] == EFI_RESOURCE_SATISFIED
) {
1031 if (ResStatus
[ResType
] == EFI_RESOURCE_NONEXISTENT
) {
1033 // Hostbridge hasn't this resource type
1039 // Hostbridge hasn't enough resource
1041 PciResNode
= GetMaxResourceConsumerDevice (ResPool
[ResType
]);
1047 // Check if the device has been removed before
1049 for (DevIndex
= 0; DevIndex
< RemovedPciDevNum
; DevIndex
++) {
1050 if (PciResNode
->PciDev
== RemovedPciDev
[DevIndex
]) {
1055 if (DevIndex
!= RemovedPciDevNum
) {
1060 // Remove the device if it isn't in the array
1062 Status
= RejectPciDevice (PciResNode
->PciDev
);
1063 if (Status
== EFI_SUCCESS
) {
1066 // Raise the EFI_IOB_EC_RESOURCE_CONFLICT status code
1069 // Have no way to get ReqRes, AllocRes & Bar here
1071 ZeroMem (&AllocFailExtendedData
, sizeof (AllocFailExtendedData
));
1072 AllocFailExtendedData
.DevicePathSize
= sizeof (EFI_DEVICE_PATH_PROTOCOL
);
1073 AllocFailExtendedData
.DevicePath
= (UINT8
*) PciResNode
->PciDev
->DevicePath
;
1074 AllocFailExtendedData
.Bar
= PciResNode
->Bar
;
1076 REPORT_STATUS_CODE_WITH_EXTENDED_DATA (
1078 EFI_IO_BUS_PCI
| EFI_IOB_EC_RESOURCE_CONFLICT
,
1079 (VOID
*) &AllocFailExtendedData
,
1080 sizeof (AllocFailExtendedData
)
1084 // Add it to the array and indicate at least a device has been rejected
1086 RemovedPciDev
[RemovedPciDevNum
++] = PciResNode
->PciDev
;
1087 AllocationAjusted
= TRUE
;
1094 if (AllocationAjusted
) {
1102 ConstructAcpiResourceRequestor (
1103 IN PCI_IO_DEVICE
*Bridge
,
1104 IN PCI_RESOURCE_NODE
*IoNode
,
1105 IN PCI_RESOURCE_NODE
*Mem32Node
,
1106 IN PCI_RESOURCE_NODE
*PMem32Node
,
1107 IN PCI_RESOURCE_NODE
*Mem64Node
,
1108 IN PCI_RESOURCE_NODE
*PMem64Node
,
1113 Routine Description:
1122 // TODO: Bridge - add argument and description to function comment
1123 // TODO: IoNode - add argument and description to function comment
1124 // TODO: Mem32Node - add argument and description to function comment
1125 // TODO: PMem32Node - add argument and description to function comment
1126 // TODO: Mem64Node - add argument and description to function comment
1127 // TODO: PMem64Node - add argument and description to function comment
1128 // TODO: pConfig - add argument and description to function comment
1129 // TODO: EFI_OUT_OF_RESOURCES - add return value to function comment
1130 // TODO: EFI_OUT_OF_RESOURCES - add return value to function comment
1131 // TODO: EFI_SUCCESS - add return value to function comment
1135 UINT8
*Configuration
;
1136 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Ptr
;
1137 EFI_ACPI_END_TAG_DESCRIPTOR
*PtrEnd
;
1145 // if there is io request, add to the io aperture
1147 if (ResourceRequestExisted (IoNode
)) {
1153 // if there is mem32 request, add to the mem32 aperture
1155 if (ResourceRequestExisted (Mem32Node
)) {
1161 // if there is pmem32 request, add to the pmem32 aperture
1163 if (ResourceRequestExisted (PMem32Node
)) {
1169 // if there is mem64 request, add to the mem64 aperture
1171 if (ResourceRequestExisted (Mem64Node
)) {
1177 // if there is pmem64 request, add to the pmem64 aperture
1179 if (ResourceRequestExisted (PMem64Node
)) {
1184 if (NumConfig
!= 0) {
1187 // If there is at least one type of resource request,
1188 // allocate a acpi resource node
1190 Configuration
= AllocatePool (sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) * NumConfig
+ sizeof (EFI_ACPI_END_TAG_DESCRIPTOR
));
1191 if (Configuration
== NULL
) {
1192 return EFI_OUT_OF_RESOURCES
;
1197 sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) * NumConfig
+ sizeof (EFI_ACPI_END_TAG_DESCRIPTOR
)
1200 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) Configuration
;
1203 // Deal with io aperture
1205 if (Aperture
& 0x01) {
1206 Ptr
->Desc
= ACPI_ADDRESS_SPACE_DESCRIPTOR
;
1207 Ptr
->Len
= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) - 3;
1211 Ptr
->ResType
= ACPI_ADDRESS_SPACE_TYPE_IO
;
1215 Ptr
->SpecificFlag
= 1;
1216 Ptr
->AddrLen
= IoNode
->Length
;
1217 Ptr
->AddrRangeMax
= IoNode
->Alignment
;
1219 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) ((UINT8
*) Ptr
+ sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
));
1222 // Deal with mem32 aperture
1224 if (Aperture
& 0x02) {
1225 Ptr
->Desc
= ACPI_ADDRESS_SPACE_DESCRIPTOR
;
1226 Ptr
->Len
= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) - 3;
1230 Ptr
->ResType
= ACPI_ADDRESS_SPACE_TYPE_MEM
;
1234 Ptr
->SpecificFlag
= 0;
1238 Ptr
->AddrSpaceGranularity
= 32;
1239 Ptr
->AddrLen
= Mem32Node
->Length
;
1240 Ptr
->AddrRangeMax
= Mem32Node
->Alignment
;
1242 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) ((UINT8
*) Ptr
+ sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
));
1246 // Deal with Pmem32 aperture
1248 if (Aperture
& 0x04) {
1249 Ptr
->Desc
= ACPI_ADDRESS_SPACE_DESCRIPTOR
;
1250 Ptr
->Len
= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) - 3;
1254 Ptr
->ResType
= ACPI_ADDRESS_SPACE_TYPE_MEM
;
1258 Ptr
->SpecificFlag
= 0x6;
1262 Ptr
->AddrSpaceGranularity
= 32;
1263 Ptr
->AddrLen
= PMem32Node
->Length
;
1264 Ptr
->AddrRangeMax
= PMem32Node
->Alignment
;
1266 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) ((UINT8
*) Ptr
+ sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
));
1269 // Deal with mem64 aperture
1271 if (Aperture
& 0x08) {
1272 Ptr
->Desc
= ACPI_ADDRESS_SPACE_DESCRIPTOR
;
1273 Ptr
->Len
= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) - 3;
1277 Ptr
->ResType
= ACPI_ADDRESS_SPACE_TYPE_MEM
;
1281 Ptr
->SpecificFlag
= 0;
1285 Ptr
->AddrSpaceGranularity
= 64;
1286 Ptr
->AddrLen
= Mem64Node
->Length
;
1287 Ptr
->AddrRangeMax
= Mem64Node
->Alignment
;
1289 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) ((UINT8
*) Ptr
+ sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
));
1292 // Deal with Pmem64 aperture
1294 if (Aperture
& 0x10) {
1295 Ptr
->Desc
= ACPI_ADDRESS_SPACE_DESCRIPTOR
;
1296 Ptr
->Len
= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) - 3;
1300 Ptr
->ResType
= ACPI_ADDRESS_SPACE_TYPE_MEM
;
1304 Ptr
->SpecificFlag
= 0x06;
1308 Ptr
->AddrSpaceGranularity
= 64;
1309 Ptr
->AddrLen
= PMem64Node
->Length
;
1310 Ptr
->AddrRangeMax
= PMem64Node
->Alignment
;
1312 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) (Configuration
+ sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
));
1318 PtrEnd
= (EFI_ACPI_END_TAG_DESCRIPTOR
*) ((UINT8
*) Ptr
);
1320 PtrEnd
->Desc
= ACPI_END_TAG_DESCRIPTOR
;
1321 PtrEnd
->Checksum
= 0;
1326 // If there is no resource request
1328 Configuration
= AllocatePool (sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR
));
1329 if (Configuration
== NULL
) {
1330 return EFI_OUT_OF_RESOURCES
;
1333 ZeroMem (Configuration
, sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR
));
1335 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) (Configuration
);
1336 Ptr
->Desc
= ACPI_ADDRESS_SPACE_DESCRIPTOR
;
1338 PtrEnd
= (EFI_ACPI_END_TAG_DESCRIPTOR
*) (Configuration
+ sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
));
1339 PtrEnd
->Desc
= ACPI_END_TAG_DESCRIPTOR
;
1340 PtrEnd
->Checksum
= 0;
1343 *pConfig
= Configuration
;
1352 OUT UINT64
*Mem32Base
,
1353 OUT UINT64
*PMem32Base
,
1354 OUT UINT64
*Mem64Base
,
1355 OUT UINT64
*PMem64Base
1359 Routine Description:
1368 // TODO: pConfig - add argument and description to function comment
1369 // TODO: IoBase - add argument and description to function comment
1370 // TODO: Mem32Base - add argument and description to function comment
1371 // TODO: PMem32Base - add argument and description to function comment
1372 // TODO: Mem64Base - add argument and description to function comment
1373 // TODO: PMem64Base - add argument and description to function comment
1374 // TODO: EFI_SUCCESS - add return value to function comment
1377 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Ptr
;
1380 *IoBase
= 0xFFFFFFFFFFFFFFFFULL
;
1381 *Mem32Base
= 0xFFFFFFFFFFFFFFFFULL
;
1382 *PMem32Base
= 0xFFFFFFFFFFFFFFFFULL
;
1383 *Mem64Base
= 0xFFFFFFFFFFFFFFFFULL
;
1384 *PMem64Base
= 0xFFFFFFFFFFFFFFFFULL
;
1386 Temp
= (UINT8
*) pConfig
;
1388 while (*Temp
== ACPI_ADDRESS_SPACE_DESCRIPTOR
) {
1390 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) Temp
;
1391 ResStatus
= Ptr
->AddrTranslationOffset
;
1393 if (ResStatus
== EFI_RESOURCE_SATISFIED
) {
1395 switch (Ptr
->ResType
) {
1398 // Memory type aperture
1403 // Check to see the granularity
1405 if (Ptr
->AddrSpaceGranularity
== 32) {
1406 if (Ptr
->SpecificFlag
& 0x06) {
1407 *PMem32Base
= Ptr
->AddrRangeMin
;
1409 *Mem32Base
= Ptr
->AddrRangeMin
;
1413 if (Ptr
->AddrSpaceGranularity
== 64) {
1414 if (Ptr
->SpecificFlag
& 0x06) {
1415 *PMem64Base
= Ptr
->AddrRangeMin
;
1417 *Mem64Base
= Ptr
->AddrRangeMin
;
1427 *IoBase
= Ptr
->AddrRangeMin
;
1441 Temp
+= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
);
1448 PciBridgeEnumerator (
1449 IN PCI_IO_DEVICE
*BridgeDev
1453 Routine Description:
1462 // TODO: BridgeDev - add argument and description to function comment
1463 // TODO: EFI_SUCCESS - add return value to function comment
1466 UINT8 StartBusNumber
;
1467 EFI_PCI_IO_PROTOCOL
*PciIo
;
1472 PciIo
= &(BridgeDev
->PciIo
);
1473 Status
= PciIoRead (PciIo
, EfiPciIoWidthUint8
, 0x19, 1, &StartBusNumber
);
1475 if (EFI_ERROR (Status
)) {
1479 Status
= PciAssignBusNumber (
1485 if (EFI_ERROR (Status
)) {
1489 Status
= PciPciDeviceInfoCollector (BridgeDev
, StartBusNumber
);
1491 if (EFI_ERROR (Status
)) {
1495 Status
= PciBridgeResourceAllocator (BridgeDev
);
1497 if (EFI_ERROR (Status
)) {
1501 Status
= DetermineDeviceAttribute (BridgeDev
);
1503 if (EFI_ERROR (Status
)) {
1512 PciBridgeResourceAllocator (
1513 IN PCI_IO_DEVICE
*Bridge
1517 Routine Description:
1526 // TODO: Bridge - add argument and description to function comment
1527 // TODO: EFI_SUCCESS - add return value to function comment
1529 PCI_RESOURCE_NODE
*IoBridge
;
1530 PCI_RESOURCE_NODE
*Mem32Bridge
;
1531 PCI_RESOURCE_NODE
*PMem32Bridge
;
1532 PCI_RESOURCE_NODE
*Mem64Bridge
;
1533 PCI_RESOURCE_NODE
*PMem64Bridge
;
1541 IoBridge
= CreateResourceNode (
1550 Mem32Bridge
= CreateResourceNode (
1559 PMem32Bridge
= CreateResourceNode (
1568 Mem64Bridge
= CreateResourceNode (
1577 PMem64Bridge
= CreateResourceNode (
1587 // Create resourcemap by going through all the devices subject to this root bridge
1589 Status
= CreateResourceMap (
1598 if (EFI_ERROR (Status
)) {
1602 Status
= GetResourceBaseFromBridge (
1611 if (EFI_ERROR (Status
)) {
1616 // Program IO resources
1624 // Program Mem32 resources
1632 // Program PMem32 resources
1640 // Program Mem64 resources
1648 // Program PMem64 resources
1655 DestroyResourceTree (IoBridge
);
1656 DestroyResourceTree (Mem32Bridge
);
1657 DestroyResourceTree (PMem32Bridge
);
1658 DestroyResourceTree (PMem64Bridge
);
1659 DestroyResourceTree (Mem64Bridge
);
1661 gBS
->FreePool (IoBridge
);
1662 gBS
->FreePool (Mem32Bridge
);
1663 gBS
->FreePool (PMem32Bridge
);
1664 gBS
->FreePool (PMem64Bridge
);
1665 gBS
->FreePool (Mem64Bridge
);
1671 GetResourceBaseFromBridge (
1672 IN PCI_IO_DEVICE
*Bridge
,
1674 OUT UINT64
*Mem32Base
,
1675 OUT UINT64
*PMem32Base
,
1676 OUT UINT64
*Mem64Base
,
1677 OUT UINT64
*PMem64Base
1681 Routine Description:
1690 // TODO: Bridge - add argument and description to function comment
1691 // TODO: IoBase - add argument and description to function comment
1692 // TODO: Mem32Base - add argument and description to function comment
1693 // TODO: PMem32Base - add argument and description to function comment
1694 // TODO: Mem64Base - add argument and description to function comment
1695 // TODO: PMem64Base - add argument and description to function comment
1696 // TODO: EFI_OUT_OF_RESOURCES - add return value to function comment
1697 // TODO: EFI_SUCCESS - add return value to function comment
1699 if (!Bridge
->Allocated
) {
1700 return EFI_OUT_OF_RESOURCES
;
1704 *Mem32Base
= gAllOne
;
1705 *PMem32Base
= gAllOne
;
1706 *Mem64Base
= gAllOne
;
1707 *PMem64Base
= gAllOne
;
1709 if (IS_PCI_BRIDGE (&Bridge
->Pci
)) {
1711 if (Bridge
->PciBar
[PPB_IO_RANGE
].Length
) {
1712 *IoBase
= Bridge
->PciBar
[PPB_IO_RANGE
].BaseAddress
;
1715 if (Bridge
->PciBar
[PPB_MEM32_RANGE
].Length
) {
1716 *Mem32Base
= Bridge
->PciBar
[PPB_MEM32_RANGE
].BaseAddress
;
1719 if (Bridge
->PciBar
[PPB_PMEM32_RANGE
].Length
) {
1720 *PMem32Base
= Bridge
->PciBar
[PPB_PMEM32_RANGE
].BaseAddress
;
1723 if (Bridge
->PciBar
[PPB_PMEM64_RANGE
].Length
) {
1724 *PMem64Base
= Bridge
->PciBar
[PPB_PMEM64_RANGE
].BaseAddress
;
1726 *PMem64Base
= gAllOne
;
1731 if (IS_CARDBUS_BRIDGE (&Bridge
->Pci
)) {
1732 if (Bridge
->PciBar
[P2C_IO_1
].Length
) {
1733 *IoBase
= Bridge
->PciBar
[P2C_IO_1
].BaseAddress
;
1735 if (Bridge
->PciBar
[P2C_IO_2
].Length
) {
1736 *IoBase
= Bridge
->PciBar
[P2C_IO_2
].BaseAddress
;
1740 if (Bridge
->PciBar
[P2C_MEM_1
].Length
) {
1741 if (Bridge
->PciBar
[P2C_MEM_1
].BarType
== PciBarTypePMem32
) {
1742 *PMem32Base
= Bridge
->PciBar
[P2C_MEM_1
].BaseAddress
;
1745 if (Bridge
->PciBar
[P2C_MEM_1
].BarType
== PciBarTypeMem32
) {
1746 *Mem32Base
= Bridge
->PciBar
[P2C_MEM_1
].BaseAddress
;
1750 if (Bridge
->PciBar
[P2C_MEM_2
].Length
) {
1751 if (Bridge
->PciBar
[P2C_MEM_2
].BarType
== PciBarTypePMem32
) {
1752 *PMem32Base
= Bridge
->PciBar
[P2C_MEM_2
].BaseAddress
;
1755 if (Bridge
->PciBar
[P2C_MEM_2
].BarType
== PciBarTypeMem32
) {
1756 *Mem32Base
= Bridge
->PciBar
[P2C_MEM_2
].BaseAddress
;
1766 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
,
1767 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase
1771 Routine Description:
1780 // TODO: PciResAlloc - add argument and description to function comment
1781 // TODO: Phase - add argument and description to function comment
1782 // TODO: EFI_NOT_FOUND - add return value to function comment
1783 // TODO: EFI_SUCCESS - add return value to function comment
1785 EFI_HANDLE HostBridgeHandle
;
1786 EFI_HANDLE RootBridgeHandle
;
1787 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
;
1790 HostBridgeHandle
= NULL
;
1791 RootBridgeHandle
= NULL
;
1792 if (gPciPlatformProtocol
!= NULL
) {
1794 // Get Host Bridge Handle.
1796 PciResAlloc
->GetNextRootBridge (PciResAlloc
, &RootBridgeHandle
);
1799 // Get the rootbridge Io protocol to find the host bridge handle
1801 Status
= gBS
->HandleProtocol (
1803 &gEfiPciRootBridgeIoProtocolGuid
,
1804 (VOID
**) &PciRootBridgeIo
1807 if (EFI_ERROR (Status
)) {
1808 return EFI_NOT_FOUND
;
1811 HostBridgeHandle
= PciRootBridgeIo
->ParentHandle
;
1814 // Call PlatformPci::PhaseNotify() if the protocol is present.
1816 gPciPlatformProtocol
->PhaseNotify (
1817 gPciPlatformProtocol
,
1824 Status
= PciResAlloc
->NotifyPhase (
1829 if (gPciPlatformProtocol
!= NULL
) {
1831 // Call PlatformPci::PhaseNotify() if the protocol is present.
1833 gPciPlatformProtocol
->PhaseNotify (
1834 gPciPlatformProtocol
,
1846 PreprocessController (
1847 IN PCI_IO_DEVICE
*Bridge
,
1851 IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase
1855 Routine Description:
1864 // TODO: Bridge - add argument and description to function comment
1865 // TODO: Bus - add argument and description to function comment
1866 // TODO: Device - add argument and description to function comment
1867 // TODO: Func - add argument and description to function comment
1868 // TODO: Phase - add argument and description to function comment
1869 // TODO: EFI_UNSUPPORTED - add return value to function comment
1870 // TODO: EFI_SUCCESS - add return value to function comment
1872 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS RootBridgePciAddress
;
1873 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
;
1874 EFI_HANDLE RootBridgeHandle
;
1875 EFI_HANDLE HostBridgeHandle
;
1879 // Get the host bridge handle
1881 HostBridgeHandle
= Bridge
->PciRootBridgeIo
->ParentHandle
;
1884 // Get the pci host bridge resource allocation protocol
1886 Status
= gBS
->OpenProtocol (
1888 &gEfiPciHostBridgeResourceAllocationProtocolGuid
,
1889 (VOID
**) &PciResAlloc
,
1892 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1895 if (EFI_ERROR (Status
)) {
1896 return EFI_UNSUPPORTED
;
1900 // Get Root Brige Handle
1902 while (Bridge
->Parent
) {
1903 Bridge
= Bridge
->Parent
;
1906 RootBridgeHandle
= Bridge
->Handle
;
1908 RootBridgePciAddress
.Register
= 0;
1909 RootBridgePciAddress
.Function
= Func
;
1910 RootBridgePciAddress
.Device
= Device
;
1911 RootBridgePciAddress
.Bus
= Bus
;
1912 RootBridgePciAddress
.ExtendedRegister
= 0;
1914 if (gPciPlatformProtocol
!= NULL
) {
1916 // Call PlatformPci::PrepController() if the protocol is present.
1918 gPciPlatformProtocol
->PlatformPrepController (
1919 gPciPlatformProtocol
,
1922 RootBridgePciAddress
,
1928 Status
= PciResAlloc
->PreprocessController (
1931 RootBridgePciAddress
,
1935 if (gPciPlatformProtocol
!= NULL
) {
1937 // Call PlatformPci::PrepController() if the protocol is present.
1939 gPciPlatformProtocol
->PlatformPrepController (
1940 gPciPlatformProtocol
,
1943 RootBridgePciAddress
,
1954 PciHotPlugRequestNotify (
1955 IN EFI_PCI_HOTPLUG_REQUEST_PROTOCOL
* This
,
1956 IN EFI_PCI_HOTPLUG_OPERATION Operation
,
1957 IN EFI_HANDLE Controller
,
1958 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
,
1959 IN OUT UINT8
*NumberOfChildren
,
1960 IN OUT EFI_HANDLE
* ChildHandleBuffer
1964 Routine Description:
1966 Hot plug request notify.
1970 This - A pointer to the hot plug request protocol.
1971 Operation - The operation.
1972 Controller - A pointer to the controller.
1973 RemainningDevicePath - A pointer to the device path.
1974 NumberOfChildren - A the number of child handle in the ChildHandleBuffer.
1975 ChildHandleBuffer - A pointer to the array contain the child handle.
1982 // TODO: RemainingDevicePath - add argument and description to function comment
1983 // TODO: EFI_NOT_FOUND - add return value to function comment
1984 // TODO: EFI_SUCCESS - 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
1988 PCI_IO_DEVICE
*Bridge
;
1989 PCI_IO_DEVICE
*Temp
;
1990 EFI_PCI_IO_PROTOCOL
*PciIo
;
1992 EFI_HANDLE RootBridgeHandle
;
1995 Status
= gBS
->OpenProtocol (
1997 &gEfiPciIoProtocolGuid
,
1999 gPciBusDriverBinding
.DriverBindingHandle
,
2001 EFI_OPEN_PROTOCOL_GET_PROTOCOL
2004 if (EFI_ERROR (Status
)) {
2005 return EFI_NOT_FOUND
;
2008 Bridge
= PCI_IO_DEVICE_FROM_PCI_IO_THIS (PciIo
);
2011 // Get root bridge handle
2014 while (Temp
->Parent
) {
2015 Temp
= Temp
->Parent
;
2018 RootBridgeHandle
= Temp
->Handle
;
2020 if (Operation
== EfiPciHotPlugRequestAdd
) {
2022 if (NumberOfChildren
!= NULL
) {
2023 *NumberOfChildren
= 0;
2026 if (IsListEmpty (&Bridge
->ChildList
)) {
2028 Status
= PciBridgeEnumerator (Bridge
);
2030 if (EFI_ERROR (Status
)) {
2035 Status
= StartPciDevicesOnBridge (
2038 RemainingDevicePath
,
2046 if (Operation
== EfiPciHotplugRequestRemove
) {
2048 if (*NumberOfChildren
== 0) {
2050 // Remove all devices on the bridge
2052 Status
= RemoveAllPciDeviceOnBridge (RootBridgeHandle
, Bridge
);
2057 for (Index
= 0; Index
< *NumberOfChildren
; Index
++) {
2059 // De register all the pci device
2061 Status
= DeRegisterPciDevice (RootBridgeHandle
, ChildHandleBuffer
[Index
]);
2063 if (EFI_ERROR (Status
)) {
2078 SearchHostBridgeHandle (
2079 IN EFI_HANDLE RootBridgeHandle
2083 Routine Description:
2092 // TODO: RootBridgeHandle - add argument and description to function comment
2094 EFI_HANDLE HostBridgeHandle
;
2095 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
;
2100 // Get the rootbridge Io protocol to find the host bridge handle
2102 Status
= gBS
->OpenProtocol (
2104 &gEfiPciRootBridgeIoProtocolGuid
,
2105 (VOID
**) &PciRootBridgeIo
,
2106 gPciBusDriverBinding
.DriverBindingHandle
,
2108 EFI_OPEN_PROTOCOL_GET_PROTOCOL
2111 if (EFI_ERROR (Status
)) {
2115 HostBridgeHandle
= PciRootBridgeIo
->ParentHandle
;
2116 for (Index
= 0; Index
< gPciHostBridgeNumber
; Index
++) {
2117 if (HostBridgeHandle
== gPciHostBrigeHandles
[Index
]) {
2126 AddHostBridgeEnumerator (
2127 IN EFI_HANDLE HostBridgeHandle
2131 Routine Description:
2140 // TODO: HostBridgeHandle - add argument and description to function comment
2141 // TODO: EFI_ABORTED - add return value to function comment
2142 // TODO: EFI_ABORTED - add return value to function comment
2143 // TODO: EFI_SUCCESS - add return value to function comment
2147 if (!HostBridgeHandle
) {
2151 for (Index
= 0; Index
< gPciHostBridgeNumber
; Index
++) {
2152 if (HostBridgeHandle
== gPciHostBrigeHandles
[Index
]) {
2157 if (Index
< PCI_MAX_HOST_BRIDGE_NUM
) {
2158 gPciHostBrigeHandles
[Index
] = HostBridgeHandle
;
2159 gPciHostBridgeNumber
++;