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 if (EFI_ERROR (Status
)) {
249 IN PCI_IO_DEVICE
*Bridge
,
257 This routine is used to process option rom on a certain root bridge
266 // TODO: Bridge - add argument and description to function comment
267 // TODO: RomBase - add argument and description to function comment
268 // TODO: MaxLength - add argument and description to function comment
269 // TODO: EFI_SUCCESS - add return value to function comment
271 LIST_ENTRY
*CurrentLink
;
275 // Go through bridges to reach all devices
277 CurrentLink
= Bridge
->ChildList
.ForwardLink
;
278 while (CurrentLink
&& CurrentLink
!= &Bridge
->ChildList
) {
279 Temp
= PCI_IO_DEVICE_FROM_LINK (CurrentLink
);
280 if (!IsListEmpty (&Temp
->ChildList
)) {
283 // Go further to process the option rom under this bridge
285 ProcessOptionRom (Temp
, RomBase
, MaxLength
);
288 if (Temp
->RomSize
!= 0 && Temp
->RomSize
<= MaxLength
) {
291 // Load and process the option rom
293 LoadOpRomImage (Temp
, RomBase
);
296 CurrentLink
= CurrentLink
->ForwardLink
;
304 IN PCI_IO_DEVICE
*Bridge
,
305 IN UINT8 StartBusNumber
,
306 OUT UINT8
*SubBusNumber
312 This routine is used to assign bus number to the given PCI bus system
321 // TODO: Bridge - add argument and description to function comment
322 // TODO: StartBusNumber - add argument and description to function comment
323 // TODO: SubBusNumber - add argument and description to function comment
324 // TODO: EFI_DEVICE_ERROR - add return value to function comment
325 // TODO: EFI_SUCCESS - add return value to function comment
335 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
;
337 PciRootBridgeIo
= Bridge
->PciRootBridgeIo
;
342 *SubBusNumber
= StartBusNumber
;
345 // First check to see whether the parent is ppb
347 for (Device
= 0; Device
<= PCI_MAX_DEVICE
; Device
++) {
348 for (Func
= 0; Func
<= PCI_MAX_FUNC
; Func
++) {
351 // Check to see whether a pci device is present
354 Status
= PciDevicePresent (
362 if (!EFI_ERROR (Status
) &&
363 (IS_PCI_BRIDGE (&Pci
) || IS_CARDBUS_BRIDGE (&Pci
))) {
366 // Reserved one bus for cardbus bridge
368 SecondBus
= ++(*SubBusNumber
);
370 Register
= (UINT16
) ((SecondBus
<< 8) | (UINT16
) StartBusNumber
);
372 Address
= EFI_PCI_ADDRESS (StartBusNumber
, Device
, Func
, 0x18);
374 Status
= PciRootBridgeIoWrite (
384 // Initialize SubBusNumber to SecondBus
386 Address
= EFI_PCI_ADDRESS (StartBusNumber
, Device
, Func
, 0x1A);
387 Status
= PciRootBridgeIoWrite (
396 // If it is PPB, resursively search down this bridge
398 if (IS_PCI_BRIDGE (&Pci
)) {
401 Status
= PciRootBridgeIoWrite (
410 Status
= PciAssignBusNumber (
416 if (EFI_ERROR (Status
)) {
417 return EFI_DEVICE_ERROR
;
422 // Set the current maximum bus number under the PPB
425 Address
= EFI_PCI_ADDRESS (StartBusNumber
, Device
, Func
, 0x1A);
427 Status
= PciRootBridgeIoWrite (
438 if (Func
== 0 && !IS_PCI_MULTI_FUNC (&Pci
)) {
441 // Skip sub functions, this is not a multi function device
453 DetermineRootBridgeAttributes (
454 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
,
455 IN PCI_IO_DEVICE
*RootBridgeDev
461 This routine is used to determine the root bridge attribute by interfacing
462 the host bridge resource allocation protocol.
471 // TODO: PciResAlloc - add argument and description to function comment
472 // TODO: RootBridgeDev - add argument and description to function comment
473 // TODO: EFI_SUCCESS - add return value to function comment
477 EFI_HANDLE RootBridgeHandle
;
480 RootBridgeHandle
= RootBridgeDev
->Handle
;
483 // Get root bridge attribute by calling into pci host bridge resource allocation protocol
485 Status
= PciResAlloc
->GetAllocAttributes (
491 if (EFI_ERROR (Status
)) {
496 // Here is the point where PCI bus driver calls HOST bridge allocation protocol
497 // Currently we hardcoded for ea815
500 if (Attributes
& EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM
) {
501 RootBridgeDev
->Decodes
|= EFI_BRIDGE_PMEM_MEM_COMBINE_SUPPORTED
;
504 if (Attributes
& EFI_PCI_HOST_BRIDGE_MEM64_DECODE
) {
505 RootBridgeDev
->Decodes
|= EFI_BRIDGE_PMEM64_DECODE_SUPPORTED
;
508 RootBridgeDev
->Decodes
|= EFI_BRIDGE_MEM32_DECODE_SUPPORTED
;
509 RootBridgeDev
->Decodes
|= EFI_BRIDGE_PMEM32_DECODE_SUPPORTED
;
510 RootBridgeDev
->Decodes
|= EFI_BRIDGE_IO16_DECODE_SUPPORTED
;
516 GetMaxOptionRomSize (
517 IN PCI_IO_DEVICE
*Bridge
523 Get Max Option Rom size on this bridge
532 // TODO: Bridge - add argument and description to function comment
534 LIST_ENTRY
*CurrentLink
;
536 UINT64 MaxOptionRomSize
;
537 UINT64 TempOptionRomSize
;
539 MaxOptionRomSize
= 0;
542 // Go through bridges to reach all devices
544 CurrentLink
= Bridge
->ChildList
.ForwardLink
;
545 while (CurrentLink
&& CurrentLink
!= &Bridge
->ChildList
) {
546 Temp
= PCI_IO_DEVICE_FROM_LINK (CurrentLink
);
547 if (!IsListEmpty (&Temp
->ChildList
)) {
550 // Get max option rom size under this bridge
552 TempOptionRomSize
= GetMaxOptionRomSize (Temp
);
555 // Compare with the option rom size of the bridge
556 // Get the larger one
558 if (Temp
->RomSize
> TempOptionRomSize
) {
559 TempOptionRomSize
= Temp
->RomSize
;
565 // For devices get the rom size directly
567 TempOptionRomSize
= Temp
->RomSize
;
571 // Get the largest rom size on this bridge
573 if (TempOptionRomSize
> MaxOptionRomSize
) {
574 MaxOptionRomSize
= TempOptionRomSize
;
577 CurrentLink
= CurrentLink
->ForwardLink
;
580 return MaxOptionRomSize
;
584 PciHostBridgeDeviceAttribute (
585 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
591 Process attributes of devices on this host bridge
600 // TODO: PciResAlloc - add argument and description to function comment
601 // TODO: EFI_NOT_FOUND - add return value to function comment
602 // TODO: EFI_SUCCESS - add return value to function comment
604 EFI_HANDLE RootBridgeHandle
;
605 PCI_IO_DEVICE
*RootBridgeDev
;
608 RootBridgeHandle
= NULL
;
610 while (PciResAlloc
->GetNextRootBridge (PciResAlloc
, &RootBridgeHandle
) == EFI_SUCCESS
) {
613 // Get RootBridg Device by handle
615 RootBridgeDev
= GetRootBridgeByHandle (RootBridgeHandle
);
617 if (RootBridgeDev
== NULL
) {
618 return EFI_NOT_FOUND
;
622 // Set the attributes for devcies behind the Root Bridge
624 Status
= DetermineDeviceAttribute (RootBridgeDev
);
625 if (EFI_ERROR (Status
)) {
635 GetResourceAllocationStatus (
637 OUT UINT64
*IoResStatus
,
638 OUT UINT64
*Mem32ResStatus
,
639 OUT UINT64
*PMem32ResStatus
,
640 OUT UINT64
*Mem64ResStatus
,
641 OUT UINT64
*PMem64ResStatus
647 Get resource allocation status from the ACPI pointer
656 // TODO: AcpiConfig - add argument and description to function comment
657 // TODO: IoResStatus - add argument and description to function comment
658 // TODO: Mem32ResStatus - add argument and description to function comment
659 // TODO: PMem32ResStatus - add argument and description to function comment
660 // TODO: Mem64ResStatus - add argument and description to function comment
661 // TODO: PMem64ResStatus - add argument and description to function comment
662 // TODO: EFI_SUCCESS - add return value to function comment
667 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*ptr
;
669 Temp
= (UINT8
*) AcpiConfig
;
671 while (*Temp
== ACPI_ADDRESS_SPACE_DESCRIPTOR
) {
673 ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) Temp
;
674 ResStatus
= ptr
->AddrTranslationOffset
;
676 switch (ptr
->ResType
) {
678 if (ptr
->AddrSpaceGranularity
== 32) {
679 if (ptr
->SpecificFlag
== 0x06) {
683 *PMem32ResStatus
= ResStatus
;
688 *Mem32ResStatus
= ResStatus
;
692 if (ptr
->AddrSpaceGranularity
== 64) {
693 if (ptr
->SpecificFlag
== 0x06) {
697 *PMem64ResStatus
= ResStatus
;
702 *Mem64ResStatus
= ResStatus
;
712 *IoResStatus
= ResStatus
;
719 Temp
+= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
);
727 IN PCI_IO_DEVICE
*PciDevice
733 Remove a PCI device from device pool and mark its bar
742 // TODO: PciDevice - add argument and description to function comment
743 // TODO: EFI_SUCCESS - add return value to function comment
744 // TODO: EFI_ABORTED - add return value to function comment
745 // TODO: EFI_SUCCESS - add return value to function comment
746 // TODO: EFI_ABORTED - add return value to function comment
748 PCI_IO_DEVICE
*Bridge
;
750 LIST_ENTRY
*CurrentLink
;
753 // Remove the padding resource from a bridge
755 if ( IS_PCI_BRIDGE(&PciDevice
->Pci
) && \
756 PciDevice
->ResourcePaddingDescriptors
) {
757 gBS
->FreePool (PciDevice
->ResourcePaddingDescriptors
);
758 PciDevice
->ResourcePaddingDescriptors
= NULL
;
765 if (IS_PCI_BRIDGE (&PciDevice
->Pci
) || (!PciDevice
->Parent
)) {
769 if (IS_CARDBUS_BRIDGE (&PciDevice
->Pci
)) {
771 // Get the root bridge device
774 while (Bridge
->Parent
) {
775 Bridge
= Bridge
->Parent
;
778 RemoveAllPciDeviceOnBridge (Bridge
->Handle
, PciDevice
);
783 InitializeP2C (PciDevice
);
789 Bridge
= PciDevice
->Parent
;
790 CurrentLink
= Bridge
->ChildList
.ForwardLink
;
791 while (CurrentLink
&& CurrentLink
!= &Bridge
->ChildList
) {
792 Temp
= PCI_IO_DEVICE_FROM_LINK (CurrentLink
);
793 if (Temp
== PciDevice
) {
794 InitializePciDevice (Temp
);
795 RemoveEntryList (CurrentLink
);
796 FreePciDevice (Temp
);
800 CurrentLink
= CurrentLink
->ForwardLink
;
808 IN PCI_RESOURCE_NODE
*PciResNode
814 Determine whethter a PCI device can be rejected
823 // TODO: PciResNode - add argument and description to function comment
827 Temp
= PciResNode
->PciDev
;
830 // Ensure the device is present
837 // PPB and RB should go ahead
839 if (IS_PCI_BRIDGE (&Temp
->Pci
) || (!Temp
->Parent
)) {
844 // Skip device on Bus0
846 if ((Temp
->Parent
) && (Temp
->BusNumber
== 0)) {
853 if (IS_PCI_VGA (&Temp
->Pci
)) {
861 GetLargerConsumerDevice (
862 IN PCI_RESOURCE_NODE
*PciResNode1
,
863 IN PCI_RESOURCE_NODE
*PciResNode2
869 Get the larger resource consumer
878 // TODO: PciResNode1 - add argument and description to function comment
879 // TODO: PciResNode2 - add argument and description to function comment
885 if ((IS_PCI_BRIDGE(&(PciResNode2
->PciDev
->Pci
)) || !(PciResNode2
->PciDev
->Parent
)) \
886 && (PciResNode2
->ResourceUsage
!= PciResUsagePadding
) )
895 if ((PciResNode1
->Length
) > (PciResNode2
->Length
)) {
904 GetMaxResourceConsumerDevice (
905 IN PCI_RESOURCE_NODE
*ResPool
911 Get the max resource consumer in the host resource pool
920 // TODO: ResPool - add argument and description to function comment
922 PCI_RESOURCE_NODE
*Temp
;
923 LIST_ENTRY
*CurrentLink
;
924 PCI_RESOURCE_NODE
*PciResNode
;
925 PCI_RESOURCE_NODE
*PPBResNode
;
929 CurrentLink
= ResPool
->ChildList
.ForwardLink
;
930 while (CurrentLink
&& CurrentLink
!= &ResPool
->ChildList
) {
932 Temp
= RESOURCE_NODE_FROM_LINK (CurrentLink
);
934 if (!IsRejectiveDevice (Temp
)) {
935 CurrentLink
= CurrentLink
->ForwardLink
;
939 if ((IS_PCI_BRIDGE (&(Temp
->PciDev
->Pci
)) || (!Temp
->PciDev
->Parent
)) \
940 && (Temp
->ResourceUsage
!= PciResUsagePadding
))
942 PPBResNode
= GetMaxResourceConsumerDevice (Temp
);
943 PciResNode
= GetLargerConsumerDevice (PciResNode
, PPBResNode
);
945 PciResNode
= GetLargerConsumerDevice (PciResNode
, Temp
);
948 CurrentLink
= CurrentLink
->ForwardLink
;
955 PciHostBridgeAdjustAllocation (
956 IN PCI_RESOURCE_NODE
*IoPool
,
957 IN PCI_RESOURCE_NODE
*Mem32Pool
,
958 IN PCI_RESOURCE_NODE
*PMem32Pool
,
959 IN PCI_RESOURCE_NODE
*Mem64Pool
,
960 IN PCI_RESOURCE_NODE
*PMem64Pool
,
961 IN UINT64 IoResStatus
,
962 IN UINT64 Mem32ResStatus
,
963 IN UINT64 PMem32ResStatus
,
964 IN UINT64 Mem64ResStatus
,
965 IN UINT64 PMem64ResStatus
971 Adjust host bridge allocation so as to reduce resource requirement
980 // TODO: IoPool - add argument and description to function comment
981 // TODO: Mem32Pool - add argument and description to function comment
982 // TODO: PMem32Pool - add argument and description to function comment
983 // TODO: Mem64Pool - add argument and description to function comment
984 // TODO: PMem64Pool - add argument and description to function comment
985 // TODO: IoResStatus - add argument and description to function comment
986 // TODO: Mem32ResStatus - add argument and description to function comment
987 // TODO: PMem32ResStatus - add argument and description to function comment
988 // TODO: Mem64ResStatus - add argument and description to function comment
989 // TODO: PMem64ResStatus - add argument and description to function comment
990 // TODO: EFI_ABORTED - add return value to function comment
991 // TODO: EFI_SUCCESS - add return value to function comment
992 // TODO: EFI_ABORTED - add return value to function comment
994 BOOLEAN AllocationAjusted
;
995 PCI_RESOURCE_NODE
*PciResNode
;
996 PCI_RESOURCE_NODE
*ResPool
[5];
997 PCI_IO_DEVICE
*RemovedPciDev
[5];
999 UINTN RemovedPciDevNum
;
1003 EFI_RESOURCE_ALLOC_FAILURE_ERROR_DATA_PAYLOAD AllocFailExtendedData
;
1006 ZeroMem (RemovedPciDev
, 5 * sizeof (PCI_IO_DEVICE
*));
1007 RemovedPciDevNum
= 0;
1009 ResPool
[0] = IoPool
;
1010 ResPool
[1] = Mem32Pool
;
1011 ResPool
[2] = PMem32Pool
;
1012 ResPool
[3] = Mem64Pool
;
1013 ResPool
[4] = PMem64Pool
;
1015 ResStatus
[0] = IoResStatus
;
1016 ResStatus
[1] = Mem32ResStatus
;
1017 ResStatus
[2] = PMem32ResStatus
;
1018 ResStatus
[3] = Mem64ResStatus
;
1019 ResStatus
[4] = PMem64ResStatus
;
1021 AllocationAjusted
= FALSE
;
1023 for (ResType
= 0; ResType
< 5; ResType
++) {
1025 if (ResStatus
[ResType
] == EFI_RESOURCE_SATISFIED
) {
1029 if (ResStatus
[ResType
] == EFI_RESOURCE_NONEXISTENT
) {
1031 // Hostbridge hasn't this resource type
1037 // Hostbridge hasn't enough resource
1039 PciResNode
= GetMaxResourceConsumerDevice (ResPool
[ResType
]);
1045 // Check if the device has been removed before
1047 for (DevIndex
= 0; DevIndex
< RemovedPciDevNum
; DevIndex
++) {
1048 if (PciResNode
->PciDev
== RemovedPciDev
[DevIndex
]) {
1053 if (DevIndex
!= RemovedPciDevNum
) {
1058 // Remove the device if it isn't in the array
1060 Status
= RejectPciDevice (PciResNode
->PciDev
);
1061 if (Status
== EFI_SUCCESS
) {
1064 // Raise the EFI_IOB_EC_RESOURCE_CONFLICT status code
1067 // Have no way to get ReqRes, AllocRes & Bar here
1069 ZeroMem (&AllocFailExtendedData
, sizeof (AllocFailExtendedData
));
1070 AllocFailExtendedData
.DevicePathSize
= sizeof (EFI_DEVICE_PATH_PROTOCOL
);
1071 AllocFailExtendedData
.DevicePath
= (UINT8
*) PciResNode
->PciDev
->DevicePath
;
1072 AllocFailExtendedData
.Bar
= PciResNode
->Bar
;
1074 REPORT_STATUS_CODE_WITH_EXTENDED_DATA (
1076 EFI_IO_BUS_PCI
| EFI_IOB_EC_RESOURCE_CONFLICT
,
1077 (VOID
*) &AllocFailExtendedData
,
1078 sizeof (AllocFailExtendedData
)
1082 // Add it to the array and indicate at least a device has been rejected
1084 RemovedPciDev
[RemovedPciDevNum
++] = PciResNode
->PciDev
;
1085 AllocationAjusted
= TRUE
;
1092 if (AllocationAjusted
) {
1100 ConstructAcpiResourceRequestor (
1101 IN PCI_IO_DEVICE
*Bridge
,
1102 IN PCI_RESOURCE_NODE
*IoNode
,
1103 IN PCI_RESOURCE_NODE
*Mem32Node
,
1104 IN PCI_RESOURCE_NODE
*PMem32Node
,
1105 IN PCI_RESOURCE_NODE
*Mem64Node
,
1106 IN PCI_RESOURCE_NODE
*PMem64Node
,
1111 Routine Description:
1120 // TODO: Bridge - add argument and description to function comment
1121 // TODO: IoNode - add argument and description to function comment
1122 // TODO: Mem32Node - add argument and description to function comment
1123 // TODO: PMem32Node - add argument and description to function comment
1124 // TODO: Mem64Node - add argument and description to function comment
1125 // TODO: PMem64Node - add argument and description to function comment
1126 // TODO: pConfig - add argument and description to function comment
1127 // TODO: EFI_OUT_OF_RESOURCES - add return value to function comment
1128 // TODO: EFI_OUT_OF_RESOURCES - add return value to function comment
1129 // TODO: EFI_SUCCESS - add return value to function comment
1133 UINT8
*Configuration
;
1134 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Ptr
;
1135 EFI_ACPI_END_TAG_DESCRIPTOR
*PtrEnd
;
1143 // if there is io request, add to the io aperture
1145 if (ResourceRequestExisted (IoNode
)) {
1151 // if there is mem32 request, add to the mem32 aperture
1153 if (ResourceRequestExisted (Mem32Node
)) {
1159 // if there is pmem32 request, add to the pmem32 aperture
1161 if (ResourceRequestExisted (PMem32Node
)) {
1167 // if there is mem64 request, add to the mem64 aperture
1169 if (ResourceRequestExisted (Mem64Node
)) {
1175 // if there is pmem64 request, add to the pmem64 aperture
1177 if (ResourceRequestExisted (PMem64Node
)) {
1182 if (NumConfig
!= 0) {
1185 // If there is at least one type of resource request,
1186 // allocate a acpi resource node
1188 Configuration
= AllocatePool (sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) * NumConfig
+ sizeof (EFI_ACPI_END_TAG_DESCRIPTOR
));
1189 if (Configuration
== NULL
) {
1190 return EFI_OUT_OF_RESOURCES
;
1195 sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) * NumConfig
+ sizeof (EFI_ACPI_END_TAG_DESCRIPTOR
)
1198 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) Configuration
;
1201 // Deal with io aperture
1203 if (Aperture
& 0x01) {
1204 Ptr
->Desc
= ACPI_ADDRESS_SPACE_DESCRIPTOR
;
1205 Ptr
->Len
= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) - 3;
1209 Ptr
->ResType
= ACPI_ADDRESS_SPACE_TYPE_IO
;
1213 Ptr
->SpecificFlag
= 1;
1214 Ptr
->AddrLen
= IoNode
->Length
;
1215 Ptr
->AddrRangeMax
= IoNode
->Alignment
;
1217 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) ((UINT8
*) Ptr
+ sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
));
1220 // Deal with mem32 aperture
1222 if (Aperture
& 0x02) {
1223 Ptr
->Desc
= ACPI_ADDRESS_SPACE_DESCRIPTOR
;
1224 Ptr
->Len
= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) - 3;
1228 Ptr
->ResType
= ACPI_ADDRESS_SPACE_TYPE_MEM
;
1232 Ptr
->SpecificFlag
= 0;
1236 Ptr
->AddrSpaceGranularity
= 32;
1237 Ptr
->AddrLen
= Mem32Node
->Length
;
1238 Ptr
->AddrRangeMax
= Mem32Node
->Alignment
;
1240 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) ((UINT8
*) Ptr
+ sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
));
1244 // Deal with Pmem32 aperture
1246 if (Aperture
& 0x04) {
1247 Ptr
->Desc
= ACPI_ADDRESS_SPACE_DESCRIPTOR
;
1248 Ptr
->Len
= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) - 3;
1252 Ptr
->ResType
= ACPI_ADDRESS_SPACE_TYPE_MEM
;
1256 Ptr
->SpecificFlag
= 0x6;
1260 Ptr
->AddrSpaceGranularity
= 32;
1261 Ptr
->AddrLen
= PMem32Node
->Length
;
1262 Ptr
->AddrRangeMax
= PMem32Node
->Alignment
;
1264 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) ((UINT8
*) Ptr
+ sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
));
1267 // Deal with mem64 aperture
1269 if (Aperture
& 0x08) {
1270 Ptr
->Desc
= ACPI_ADDRESS_SPACE_DESCRIPTOR
;
1271 Ptr
->Len
= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) - 3;
1275 Ptr
->ResType
= ACPI_ADDRESS_SPACE_TYPE_MEM
;
1279 Ptr
->SpecificFlag
= 0;
1283 Ptr
->AddrSpaceGranularity
= 64;
1284 Ptr
->AddrLen
= Mem64Node
->Length
;
1285 Ptr
->AddrRangeMax
= Mem64Node
->Alignment
;
1287 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) ((UINT8
*) Ptr
+ sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
));
1290 // Deal with Pmem64 aperture
1292 if (Aperture
& 0x10) {
1293 Ptr
->Desc
= ACPI_ADDRESS_SPACE_DESCRIPTOR
;
1294 Ptr
->Len
= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) - 3;
1298 Ptr
->ResType
= ACPI_ADDRESS_SPACE_TYPE_MEM
;
1302 Ptr
->SpecificFlag
= 0x06;
1306 Ptr
->AddrSpaceGranularity
= 64;
1307 Ptr
->AddrLen
= PMem64Node
->Length
;
1308 Ptr
->AddrRangeMax
= PMem64Node
->Alignment
;
1310 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) (Configuration
+ sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
));
1316 PtrEnd
= (EFI_ACPI_END_TAG_DESCRIPTOR
*) ((UINT8
*) Ptr
);
1318 PtrEnd
->Desc
= ACPI_END_TAG_DESCRIPTOR
;
1319 PtrEnd
->Checksum
= 0;
1324 // If there is no resource request
1326 Configuration
= AllocatePool (sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR
));
1327 if (Configuration
== NULL
) {
1328 return EFI_OUT_OF_RESOURCES
;
1331 ZeroMem (Configuration
, sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR
));
1333 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) (Configuration
);
1334 Ptr
->Desc
= ACPI_ADDRESS_SPACE_DESCRIPTOR
;
1336 PtrEnd
= (EFI_ACPI_END_TAG_DESCRIPTOR
*) (Configuration
+ sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
));
1337 PtrEnd
->Desc
= ACPI_END_TAG_DESCRIPTOR
;
1338 PtrEnd
->Checksum
= 0;
1341 *pConfig
= Configuration
;
1350 OUT UINT64
*Mem32Base
,
1351 OUT UINT64
*PMem32Base
,
1352 OUT UINT64
*Mem64Base
,
1353 OUT UINT64
*PMem64Base
1357 Routine Description:
1366 // TODO: pConfig - add argument and description to function comment
1367 // TODO: IoBase - add argument and description to function comment
1368 // TODO: Mem32Base - add argument and description to function comment
1369 // TODO: PMem32Base - add argument and description to function comment
1370 // TODO: Mem64Base - add argument and description to function comment
1371 // TODO: PMem64Base - add argument and description to function comment
1372 // TODO: EFI_SUCCESS - add return value to function comment
1375 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Ptr
;
1378 *IoBase
= 0xFFFFFFFFFFFFFFFFULL
;
1379 *Mem32Base
= 0xFFFFFFFFFFFFFFFFULL
;
1380 *PMem32Base
= 0xFFFFFFFFFFFFFFFFULL
;
1381 *Mem64Base
= 0xFFFFFFFFFFFFFFFFULL
;
1382 *PMem64Base
= 0xFFFFFFFFFFFFFFFFULL
;
1384 Temp
= (UINT8
*) pConfig
;
1386 while (*Temp
== ACPI_ADDRESS_SPACE_DESCRIPTOR
) {
1388 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) Temp
;
1389 ResStatus
= Ptr
->AddrTranslationOffset
;
1391 if (ResStatus
== EFI_RESOURCE_SATISFIED
) {
1393 switch (Ptr
->ResType
) {
1396 // Memory type aperture
1401 // Check to see the granularity
1403 if (Ptr
->AddrSpaceGranularity
== 32) {
1404 if (Ptr
->SpecificFlag
& 0x06) {
1405 *PMem32Base
= Ptr
->AddrRangeMin
;
1407 *Mem32Base
= Ptr
->AddrRangeMin
;
1411 if (Ptr
->AddrSpaceGranularity
== 64) {
1412 if (Ptr
->SpecificFlag
& 0x06) {
1413 *PMem64Base
= Ptr
->AddrRangeMin
;
1415 *Mem64Base
= Ptr
->AddrRangeMin
;
1425 *IoBase
= Ptr
->AddrRangeMin
;
1439 Temp
+= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
);
1446 PciBridgeEnumerator (
1447 IN PCI_IO_DEVICE
*BridgeDev
1451 Routine Description:
1460 // TODO: BridgeDev - add argument and description to function comment
1461 // TODO: EFI_SUCCESS - add return value to function comment
1464 UINT8 StartBusNumber
;
1465 EFI_PCI_IO_PROTOCOL
*PciIo
;
1470 PciIo
= &(BridgeDev
->PciIo
);
1471 Status
= PciIoRead (PciIo
, EfiPciIoWidthUint8
, 0x19, 1, &StartBusNumber
);
1473 if (EFI_ERROR (Status
)) {
1477 Status
= PciAssignBusNumber (
1483 if (EFI_ERROR (Status
)) {
1487 Status
= PciPciDeviceInfoCollector (BridgeDev
, StartBusNumber
);
1489 if (EFI_ERROR (Status
)) {
1493 Status
= PciBridgeResourceAllocator (BridgeDev
);
1495 if (EFI_ERROR (Status
)) {
1499 Status
= DetermineDeviceAttribute (BridgeDev
);
1501 if (EFI_ERROR (Status
)) {
1510 PciBridgeResourceAllocator (
1511 IN PCI_IO_DEVICE
*Bridge
1515 Routine Description:
1524 // TODO: Bridge - add argument and description to function comment
1525 // TODO: EFI_SUCCESS - add return value to function comment
1527 PCI_RESOURCE_NODE
*IoBridge
;
1528 PCI_RESOURCE_NODE
*Mem32Bridge
;
1529 PCI_RESOURCE_NODE
*PMem32Bridge
;
1530 PCI_RESOURCE_NODE
*Mem64Bridge
;
1531 PCI_RESOURCE_NODE
*PMem64Bridge
;
1539 IoBridge
= CreateResourceNode (
1548 Mem32Bridge
= CreateResourceNode (
1557 PMem32Bridge
= CreateResourceNode (
1566 Mem64Bridge
= CreateResourceNode (
1575 PMem64Bridge
= CreateResourceNode (
1585 // Create resourcemap by going through all the devices subject to this root bridge
1587 Status
= CreateResourceMap (
1596 if (EFI_ERROR (Status
)) {
1600 Status
= GetResourceBaseFromBridge (
1609 if (EFI_ERROR (Status
)) {
1614 // Program IO resources
1622 // Program Mem32 resources
1630 // Program PMem32 resources
1638 // Program Mem64 resources
1646 // Program PMem64 resources
1653 DestroyResourceTree (IoBridge
);
1654 DestroyResourceTree (Mem32Bridge
);
1655 DestroyResourceTree (PMem32Bridge
);
1656 DestroyResourceTree (PMem64Bridge
);
1657 DestroyResourceTree (Mem64Bridge
);
1659 gBS
->FreePool (IoBridge
);
1660 gBS
->FreePool (Mem32Bridge
);
1661 gBS
->FreePool (PMem32Bridge
);
1662 gBS
->FreePool (PMem64Bridge
);
1663 gBS
->FreePool (Mem64Bridge
);
1669 GetResourceBaseFromBridge (
1670 IN PCI_IO_DEVICE
*Bridge
,
1672 OUT UINT64
*Mem32Base
,
1673 OUT UINT64
*PMem32Base
,
1674 OUT UINT64
*Mem64Base
,
1675 OUT UINT64
*PMem64Base
1679 Routine Description:
1688 // TODO: Bridge - add argument and description to function comment
1689 // TODO: IoBase - add argument and description to function comment
1690 // TODO: Mem32Base - add argument and description to function comment
1691 // TODO: PMem32Base - add argument and description to function comment
1692 // TODO: Mem64Base - add argument and description to function comment
1693 // TODO: PMem64Base - add argument and description to function comment
1694 // TODO: EFI_OUT_OF_RESOURCES - add return value to function comment
1695 // TODO: EFI_SUCCESS - add return value to function comment
1697 if (!Bridge
->Allocated
) {
1698 return EFI_OUT_OF_RESOURCES
;
1702 *Mem32Base
= gAllOne
;
1703 *PMem32Base
= gAllOne
;
1704 *Mem64Base
= gAllOne
;
1705 *PMem64Base
= gAllOne
;
1707 if (IS_PCI_BRIDGE (&Bridge
->Pci
)) {
1709 if (Bridge
->PciBar
[PPB_IO_RANGE
].Length
) {
1710 *IoBase
= Bridge
->PciBar
[PPB_IO_RANGE
].BaseAddress
;
1713 if (Bridge
->PciBar
[PPB_MEM32_RANGE
].Length
) {
1714 *Mem32Base
= Bridge
->PciBar
[PPB_MEM32_RANGE
].BaseAddress
;
1717 if (Bridge
->PciBar
[PPB_PMEM32_RANGE
].Length
) {
1718 *PMem32Base
= Bridge
->PciBar
[PPB_PMEM32_RANGE
].BaseAddress
;
1721 if (Bridge
->PciBar
[PPB_PMEM64_RANGE
].Length
) {
1722 *PMem64Base
= Bridge
->PciBar
[PPB_PMEM64_RANGE
].BaseAddress
;
1724 *PMem64Base
= gAllOne
;
1729 if (IS_CARDBUS_BRIDGE (&Bridge
->Pci
)) {
1730 if (Bridge
->PciBar
[P2C_IO_1
].Length
) {
1731 *IoBase
= Bridge
->PciBar
[P2C_IO_1
].BaseAddress
;
1733 if (Bridge
->PciBar
[P2C_IO_2
].Length
) {
1734 *IoBase
= Bridge
->PciBar
[P2C_IO_2
].BaseAddress
;
1738 if (Bridge
->PciBar
[P2C_MEM_1
].Length
) {
1739 if (Bridge
->PciBar
[P2C_MEM_1
].BarType
== PciBarTypePMem32
) {
1740 *PMem32Base
= Bridge
->PciBar
[P2C_MEM_1
].BaseAddress
;
1743 if (Bridge
->PciBar
[P2C_MEM_1
].BarType
== PciBarTypeMem32
) {
1744 *Mem32Base
= Bridge
->PciBar
[P2C_MEM_1
].BaseAddress
;
1748 if (Bridge
->PciBar
[P2C_MEM_2
].Length
) {
1749 if (Bridge
->PciBar
[P2C_MEM_2
].BarType
== PciBarTypePMem32
) {
1750 *PMem32Base
= Bridge
->PciBar
[P2C_MEM_2
].BaseAddress
;
1753 if (Bridge
->PciBar
[P2C_MEM_2
].BarType
== PciBarTypeMem32
) {
1754 *Mem32Base
= Bridge
->PciBar
[P2C_MEM_2
].BaseAddress
;
1764 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
,
1765 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase
1769 Routine Description:
1778 // TODO: PciResAlloc - add argument and description to function comment
1779 // TODO: Phase - add argument and description to function comment
1780 // TODO: EFI_NOT_FOUND - add return value to function comment
1781 // TODO: EFI_SUCCESS - add return value to function comment
1783 EFI_HANDLE HostBridgeHandle
;
1784 EFI_HANDLE RootBridgeHandle
;
1785 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
;
1788 HostBridgeHandle
= NULL
;
1789 RootBridgeHandle
= NULL
;
1790 if (gPciPlatformProtocol
!= NULL
) {
1792 // Get Host Bridge Handle.
1794 PciResAlloc
->GetNextRootBridge (PciResAlloc
, &RootBridgeHandle
);
1797 // Get the rootbridge Io protocol to find the host bridge handle
1799 Status
= gBS
->HandleProtocol (
1801 &gEfiPciRootBridgeIoProtocolGuid
,
1802 (VOID
**) &PciRootBridgeIo
1805 if (EFI_ERROR (Status
)) {
1806 return EFI_NOT_FOUND
;
1809 HostBridgeHandle
= PciRootBridgeIo
->ParentHandle
;
1812 // Call PlatformPci::PhaseNotify() if the protocol is present.
1814 gPciPlatformProtocol
->PhaseNotify (
1815 gPciPlatformProtocol
,
1822 Status
= PciResAlloc
->NotifyPhase (
1827 if (gPciPlatformProtocol
!= NULL
) {
1829 // Call PlatformPci::PhaseNotify() if the protocol is present.
1831 gPciPlatformProtocol
->PhaseNotify (
1832 gPciPlatformProtocol
,
1844 PreprocessController (
1845 IN PCI_IO_DEVICE
*Bridge
,
1849 IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase
1853 Routine Description:
1862 // TODO: Bridge - add argument and description to function comment
1863 // TODO: Bus - add argument and description to function comment
1864 // TODO: Device - add argument and description to function comment
1865 // TODO: Func - add argument and description to function comment
1866 // TODO: Phase - add argument and description to function comment
1867 // TODO: EFI_UNSUPPORTED - add return value to function comment
1868 // TODO: EFI_SUCCESS - add return value to function comment
1870 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS RootBridgePciAddress
;
1871 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
;
1872 EFI_HANDLE RootBridgeHandle
;
1873 EFI_HANDLE HostBridgeHandle
;
1877 // Get the host bridge handle
1879 HostBridgeHandle
= Bridge
->PciRootBridgeIo
->ParentHandle
;
1882 // Get the pci host bridge resource allocation protocol
1884 Status
= gBS
->OpenProtocol (
1886 &gEfiPciHostBridgeResourceAllocationProtocolGuid
,
1887 (VOID
**) &PciResAlloc
,
1890 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1893 if (EFI_ERROR (Status
)) {
1894 return EFI_UNSUPPORTED
;
1898 // Get Root Brige Handle
1900 while (Bridge
->Parent
) {
1901 Bridge
= Bridge
->Parent
;
1904 RootBridgeHandle
= Bridge
->Handle
;
1906 RootBridgePciAddress
.Register
= 0;
1907 RootBridgePciAddress
.Function
= Func
;
1908 RootBridgePciAddress
.Device
= Device
;
1909 RootBridgePciAddress
.Bus
= Bus
;
1910 RootBridgePciAddress
.ExtendedRegister
= 0;
1912 if (gPciPlatformProtocol
!= NULL
) {
1914 // Call PlatformPci::PrepController() if the protocol is present.
1916 gPciPlatformProtocol
->PlatformPrepController (
1917 gPciPlatformProtocol
,
1920 RootBridgePciAddress
,
1926 Status
= PciResAlloc
->PreprocessController (
1929 RootBridgePciAddress
,
1933 if (gPciPlatformProtocol
!= NULL
) {
1935 // Call PlatformPci::PrepController() if the protocol is present.
1937 gPciPlatformProtocol
->PlatformPrepController (
1938 gPciPlatformProtocol
,
1941 RootBridgePciAddress
,
1952 PciHotPlugRequestNotify (
1953 IN EFI_PCI_HOTPLUG_REQUEST_PROTOCOL
* This
,
1954 IN EFI_PCI_HOTPLUG_OPERATION Operation
,
1955 IN EFI_HANDLE Controller
,
1956 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
,
1957 IN OUT UINT8
*NumberOfChildren
,
1958 IN OUT EFI_HANDLE
* ChildHandleBuffer
1962 Routine Description:
1964 Hot plug request notify.
1968 This - A pointer to the hot plug request protocol.
1969 Operation - The operation.
1970 Controller - A pointer to the controller.
1971 RemainningDevicePath - A pointer to the device path.
1972 NumberOfChildren - A the number of child handle in the ChildHandleBuffer.
1973 ChildHandleBuffer - A pointer to the array contain the child handle.
1980 // TODO: RemainingDevicePath - add argument and description to function comment
1981 // TODO: EFI_NOT_FOUND - add return value to function comment
1982 // TODO: EFI_SUCCESS - add return value to function comment
1983 // TODO: EFI_SUCCESS - add return value to function comment
1984 // TODO: EFI_SUCCESS - add return value to function comment
1986 PCI_IO_DEVICE
*Bridge
;
1987 PCI_IO_DEVICE
*Temp
;
1988 EFI_PCI_IO_PROTOCOL
*PciIo
;
1990 EFI_HANDLE RootBridgeHandle
;
1993 Status
= gBS
->OpenProtocol (
1995 &gEfiPciIoProtocolGuid
,
1997 gPciBusDriverBinding
.DriverBindingHandle
,
1999 EFI_OPEN_PROTOCOL_GET_PROTOCOL
2002 if (EFI_ERROR (Status
)) {
2003 return EFI_NOT_FOUND
;
2006 Bridge
= PCI_IO_DEVICE_FROM_PCI_IO_THIS (PciIo
);
2009 // Get root bridge handle
2012 while (Temp
->Parent
) {
2013 Temp
= Temp
->Parent
;
2016 RootBridgeHandle
= Temp
->Handle
;
2018 if (Operation
== EfiPciHotPlugRequestAdd
) {
2020 if (NumberOfChildren
!= NULL
) {
2021 *NumberOfChildren
= 0;
2024 if (IsListEmpty (&Bridge
->ChildList
)) {
2026 Status
= PciBridgeEnumerator (Bridge
);
2028 if (EFI_ERROR (Status
)) {
2033 Status
= StartPciDevicesOnBridge (
2036 RemainingDevicePath
,
2044 if (Operation
== EfiPciHotplugRequestRemove
) {
2046 if (*NumberOfChildren
== 0) {
2048 // Remove all devices on the bridge
2050 Status
= RemoveAllPciDeviceOnBridge (RootBridgeHandle
, Bridge
);
2055 for (Index
= 0; Index
< *NumberOfChildren
; Index
++) {
2057 // De register all the pci device
2059 Status
= DeRegisterPciDevice (RootBridgeHandle
, ChildHandleBuffer
[Index
]);
2061 if (EFI_ERROR (Status
)) {
2076 SearchHostBridgeHandle (
2077 IN EFI_HANDLE RootBridgeHandle
2081 Routine Description:
2090 // TODO: RootBridgeHandle - add argument and description to function comment
2092 EFI_HANDLE HostBridgeHandle
;
2093 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
;
2098 // Get the rootbridge Io protocol to find the host bridge handle
2100 Status
= gBS
->OpenProtocol (
2102 &gEfiPciRootBridgeIoProtocolGuid
,
2103 (VOID
**) &PciRootBridgeIo
,
2104 gPciBusDriverBinding
.DriverBindingHandle
,
2106 EFI_OPEN_PROTOCOL_GET_PROTOCOL
2109 if (EFI_ERROR (Status
)) {
2113 HostBridgeHandle
= PciRootBridgeIo
->ParentHandle
;
2114 for (Index
= 0; Index
< gPciHostBridgeNumber
; Index
++) {
2115 if (HostBridgeHandle
== gPciHostBrigeHandles
[Index
]) {
2124 AddHostBridgeEnumerator (
2125 IN EFI_HANDLE HostBridgeHandle
2129 Routine Description:
2138 // TODO: HostBridgeHandle - add argument and description to function comment
2139 // TODO: EFI_ABORTED - add return value to function comment
2140 // TODO: EFI_ABORTED - add return value to function comment
2141 // TODO: EFI_SUCCESS - add return value to function comment
2145 if (!HostBridgeHandle
) {
2149 for (Index
= 0; Index
< gPciHostBridgeNumber
; Index
++) {
2150 if (HostBridgeHandle
== gPciHostBrigeHandles
[Index
]) {
2155 if (Index
< PCI_MAX_HOST_BRIDGE_NUM
) {
2156 gPciHostBrigeHandles
[Index
] = HostBridgeHandle
;
2157 gPciHostBridgeNumber
++;