3 Copyright (c) 2006 - 2007, 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
= PciRootBridgeIoWrite (
395 // Initialize SubBusNumber to SecondBus
397 Address
= EFI_PCI_ADDRESS (StartBusNumber
, Device
, Func
, 0x1A);
398 Status
= PciRootBridgeIoWrite (
407 // If it is PPB, resursively search down this bridge
409 if (IS_PCI_BRIDGE (&Pci
)) {
412 Status
= PciRootBridgeIoWrite (
421 Status
= PciAssignBusNumber (
427 if (EFI_ERROR (Status
)) {
428 return EFI_DEVICE_ERROR
;
433 // Set the current maximum bus number under the PPB
436 Address
= EFI_PCI_ADDRESS (StartBusNumber
, Device
, Func
, 0x1A);
438 Status
= PciRootBridgeIoWrite (
449 if (Func
== 0 && !IS_PCI_MULTI_FUNC (&Pci
)) {
452 // Skip sub functions, this is not a multi function device
464 DetermineRootBridgeAttributes (
465 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
,
466 IN PCI_IO_DEVICE
*RootBridgeDev
472 This routine is used to determine the root bridge attribute by interfacing
473 the host bridge resource allocation protocol.
482 // TODO: PciResAlloc - add argument and description to function comment
483 // TODO: RootBridgeDev - add argument and description to function comment
484 // TODO: EFI_SUCCESS - add return value to function comment
488 EFI_HANDLE RootBridgeHandle
;
491 RootBridgeHandle
= RootBridgeDev
->Handle
;
494 // Get root bridge attribute by calling into pci host bridge resource allocation protocol
496 Status
= PciResAlloc
->GetAllocAttributes (
502 if (EFI_ERROR (Status
)) {
507 // Here is the point where PCI bus driver calls HOST bridge allocation protocol
508 // Currently we hardcoded for ea815
511 if (Attributes
& EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM
) {
512 RootBridgeDev
->Decodes
|= EFI_BRIDGE_PMEM_MEM_COMBINE_SUPPORTED
;
515 if (Attributes
& EFI_PCI_HOST_BRIDGE_MEM64_DECODE
) {
516 RootBridgeDev
->Decodes
|= EFI_BRIDGE_PMEM64_DECODE_SUPPORTED
;
519 RootBridgeDev
->Decodes
|= EFI_BRIDGE_MEM32_DECODE_SUPPORTED
;
520 RootBridgeDev
->Decodes
|= EFI_BRIDGE_PMEM32_DECODE_SUPPORTED
;
521 RootBridgeDev
->Decodes
|= EFI_BRIDGE_IO16_DECODE_SUPPORTED
;
527 GetMaxOptionRomSize (
528 IN PCI_IO_DEVICE
*Bridge
534 Get Max Option Rom size on this bridge
543 // TODO: Bridge - add argument and description to function comment
545 LIST_ENTRY
*CurrentLink
;
547 UINT64 MaxOptionRomSize
;
548 UINT64 TempOptionRomSize
;
550 MaxOptionRomSize
= 0;
553 // Go through bridges to reach all devices
555 CurrentLink
= Bridge
->ChildList
.ForwardLink
;
556 while (CurrentLink
&& CurrentLink
!= &Bridge
->ChildList
) {
557 Temp
= PCI_IO_DEVICE_FROM_LINK (CurrentLink
);
558 if (!IsListEmpty (&Temp
->ChildList
)) {
561 // Get max option rom size under this bridge
563 TempOptionRomSize
= GetMaxOptionRomSize (Temp
);
566 // Compare with the option rom size of the bridge
567 // Get the larger one
569 if (Temp
->RomSize
> TempOptionRomSize
) {
570 TempOptionRomSize
= Temp
->RomSize
;
576 // For devices get the rom size directly
578 TempOptionRomSize
= Temp
->RomSize
;
582 // Get the largest rom size on this bridge
584 if (TempOptionRomSize
> MaxOptionRomSize
) {
585 MaxOptionRomSize
= TempOptionRomSize
;
588 CurrentLink
= CurrentLink
->ForwardLink
;
591 return MaxOptionRomSize
;
595 PciHostBridgeDeviceAttribute (
596 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
602 Process attributes of devices on this host bridge
611 // TODO: PciResAlloc - add argument and description to function comment
612 // TODO: EFI_NOT_FOUND - add return value to function comment
613 // TODO: EFI_SUCCESS - add return value to function comment
615 EFI_HANDLE RootBridgeHandle
;
616 PCI_IO_DEVICE
*RootBridgeDev
;
619 RootBridgeHandle
= NULL
;
621 while (PciResAlloc
->GetNextRootBridge (PciResAlloc
, &RootBridgeHandle
) == EFI_SUCCESS
) {
624 // Get RootBridg Device by handle
626 RootBridgeDev
= GetRootBridgeByHandle (RootBridgeHandle
);
628 if (RootBridgeDev
== NULL
) {
629 return EFI_NOT_FOUND
;
633 // Set the attributes for devcies behind the Root Bridge
635 Status
= DetermineDeviceAttribute (RootBridgeDev
);
636 if (EFI_ERROR (Status
)) {
646 GetResourceAllocationStatus (
648 OUT UINT64
*IoResStatus
,
649 OUT UINT64
*Mem32ResStatus
,
650 OUT UINT64
*PMem32ResStatus
,
651 OUT UINT64
*Mem64ResStatus
,
652 OUT UINT64
*PMem64ResStatus
658 Get resource allocation status from the ACPI pointer
667 // TODO: AcpiConfig - add argument and description to function comment
668 // TODO: IoResStatus - add argument and description to function comment
669 // TODO: Mem32ResStatus - add argument and description to function comment
670 // TODO: PMem32ResStatus - add argument and description to function comment
671 // TODO: Mem64ResStatus - add argument and description to function comment
672 // TODO: PMem64ResStatus - add argument and description to function comment
673 // TODO: EFI_SUCCESS - add return value to function comment
678 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*ptr
;
680 Temp
= (UINT8
*) AcpiConfig
;
682 while (*Temp
== ACPI_ADDRESS_SPACE_DESCRIPTOR
) {
684 ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) Temp
;
685 ResStatus
= ptr
->AddrTranslationOffset
;
687 switch (ptr
->ResType
) {
689 if (ptr
->AddrSpaceGranularity
== 32) {
690 if (ptr
->SpecificFlag
== 0x06) {
694 *PMem32ResStatus
= ResStatus
;
699 *Mem32ResStatus
= ResStatus
;
703 if (ptr
->AddrSpaceGranularity
== 64) {
704 if (ptr
->SpecificFlag
== 0x06) {
708 *PMem64ResStatus
= ResStatus
;
713 *Mem64ResStatus
= ResStatus
;
723 *IoResStatus
= ResStatus
;
730 Temp
+= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
);
738 IN PCI_IO_DEVICE
*PciDevice
744 Remove a PCI device from device pool and mark its bar
753 // TODO: PciDevice - add argument and description to function comment
754 // TODO: EFI_SUCCESS - add return value to function comment
755 // TODO: EFI_ABORTED - add return value to function comment
756 // TODO: EFI_SUCCESS - add return value to function comment
757 // TODO: EFI_ABORTED - add return value to function comment
759 PCI_IO_DEVICE
*Bridge
;
761 LIST_ENTRY
*CurrentLink
;
764 // Remove the padding resource from a bridge
766 if ( IS_PCI_BRIDGE(&PciDevice
->Pci
) && \
767 PciDevice
->ResourcePaddingDescriptors
) {
768 gBS
->FreePool (PciDevice
->ResourcePaddingDescriptors
);
769 PciDevice
->ResourcePaddingDescriptors
= NULL
;
776 if (IS_PCI_BRIDGE (&PciDevice
->Pci
) || (!PciDevice
->Parent
)) {
780 if (IS_CARDBUS_BRIDGE (&PciDevice
->Pci
)) {
782 // Get the root bridge device
785 while (Bridge
->Parent
) {
786 Bridge
= Bridge
->Parent
;
789 RemoveAllPciDeviceOnBridge (Bridge
->Handle
, PciDevice
);
794 InitializeP2C (PciDevice
);
800 Bridge
= PciDevice
->Parent
;
801 CurrentLink
= Bridge
->ChildList
.ForwardLink
;
802 while (CurrentLink
&& CurrentLink
!= &Bridge
->ChildList
) {
803 Temp
= PCI_IO_DEVICE_FROM_LINK (CurrentLink
);
804 if (Temp
== PciDevice
) {
805 InitializePciDevice (Temp
);
806 RemoveEntryList (CurrentLink
);
807 FreePciDevice (Temp
);
811 CurrentLink
= CurrentLink
->ForwardLink
;
819 IN PCI_RESOURCE_NODE
*PciResNode
825 Determine whethter a PCI device can be rejected
834 // TODO: PciResNode - add argument and description to function comment
838 Temp
= PciResNode
->PciDev
;
841 // Ensure the device is present
848 // PPB and RB should go ahead
850 if (IS_PCI_BRIDGE (&Temp
->Pci
) || (!Temp
->Parent
)) {
855 // Skip device on Bus0
857 if ((Temp
->Parent
) && (Temp
->BusNumber
== 0)) {
864 if (IS_PCI_VGA (&Temp
->Pci
)) {
872 GetLargerConsumerDevice (
873 IN PCI_RESOURCE_NODE
*PciResNode1
,
874 IN PCI_RESOURCE_NODE
*PciResNode2
880 Get the larger resource consumer
889 // TODO: PciResNode1 - add argument and description to function comment
890 // TODO: PciResNode2 - add argument and description to function comment
896 if ((IS_PCI_BRIDGE(&(PciResNode2
->PciDev
->Pci
)) || !(PciResNode2
->PciDev
->Parent
)) \
897 && (PciResNode2
->ResourceUsage
!= PciResUsagePadding
) )
906 if ((PciResNode1
->Length
) > (PciResNode2
->Length
)) {
915 GetMaxResourceConsumerDevice (
916 IN PCI_RESOURCE_NODE
*ResPool
922 Get the max resource consumer in the host resource pool
931 // TODO: ResPool - add argument and description to function comment
933 PCI_RESOURCE_NODE
*Temp
;
934 LIST_ENTRY
*CurrentLink
;
935 PCI_RESOURCE_NODE
*PciResNode
;
936 PCI_RESOURCE_NODE
*PPBResNode
;
940 CurrentLink
= ResPool
->ChildList
.ForwardLink
;
941 while (CurrentLink
&& CurrentLink
!= &ResPool
->ChildList
) {
943 Temp
= RESOURCE_NODE_FROM_LINK (CurrentLink
);
945 if (!IsRejectiveDevice (Temp
)) {
946 CurrentLink
= CurrentLink
->ForwardLink
;
950 if ((IS_PCI_BRIDGE (&(Temp
->PciDev
->Pci
)) || (!Temp
->PciDev
->Parent
)) \
951 && (Temp
->ResourceUsage
!= PciResUsagePadding
))
953 PPBResNode
= GetMaxResourceConsumerDevice (Temp
);
954 PciResNode
= GetLargerConsumerDevice (PciResNode
, PPBResNode
);
956 PciResNode
= GetLargerConsumerDevice (PciResNode
, Temp
);
959 CurrentLink
= CurrentLink
->ForwardLink
;
966 PciHostBridgeAdjustAllocation (
967 IN PCI_RESOURCE_NODE
*IoPool
,
968 IN PCI_RESOURCE_NODE
*Mem32Pool
,
969 IN PCI_RESOURCE_NODE
*PMem32Pool
,
970 IN PCI_RESOURCE_NODE
*Mem64Pool
,
971 IN PCI_RESOURCE_NODE
*PMem64Pool
,
972 IN UINT64 IoResStatus
,
973 IN UINT64 Mem32ResStatus
,
974 IN UINT64 PMem32ResStatus
,
975 IN UINT64 Mem64ResStatus
,
976 IN UINT64 PMem64ResStatus
982 Adjust host bridge allocation so as to reduce resource requirement
991 // TODO: IoPool - add argument and description to function comment
992 // TODO: Mem32Pool - add argument and description to function comment
993 // TODO: PMem32Pool - add argument and description to function comment
994 // TODO: Mem64Pool - add argument and description to function comment
995 // TODO: PMem64Pool - add argument and description to function comment
996 // TODO: IoResStatus - add argument and description to function comment
997 // TODO: Mem32ResStatus - add argument and description to function comment
998 // TODO: PMem32ResStatus - add argument and description to function comment
999 // TODO: Mem64ResStatus - add argument and description to function comment
1000 // TODO: PMem64ResStatus - add argument and description to function comment
1001 // TODO: EFI_ABORTED - add return value to function comment
1002 // TODO: EFI_SUCCESS - add return value to function comment
1003 // TODO: EFI_ABORTED - add return value to function comment
1005 BOOLEAN AllocationAjusted
;
1006 PCI_RESOURCE_NODE
*PciResNode
;
1007 PCI_RESOURCE_NODE
*ResPool
[5];
1008 PCI_IO_DEVICE
*RemovedPciDev
[5];
1009 UINT64 ResStatus
[5];
1010 UINTN RemovedPciDevNum
;
1014 REPORT_STATUS_CODE_LIBRARY_RESOURCE_ALLOC_FAILURE_ERROR_DATA AllocFailExtendedData
;
1017 ZeroMem (RemovedPciDev
, 5 * sizeof (PCI_IO_DEVICE
*));
1018 RemovedPciDevNum
= 0;
1020 ResPool
[0] = IoPool
;
1021 ResPool
[1] = Mem32Pool
;
1022 ResPool
[2] = PMem32Pool
;
1023 ResPool
[3] = Mem64Pool
;
1024 ResPool
[4] = PMem64Pool
;
1026 ResStatus
[0] = IoResStatus
;
1027 ResStatus
[1] = Mem32ResStatus
;
1028 ResStatus
[2] = PMem32ResStatus
;
1029 ResStatus
[3] = Mem64ResStatus
;
1030 ResStatus
[4] = PMem64ResStatus
;
1032 AllocationAjusted
= FALSE
;
1034 for (ResType
= 0; ResType
< 5; ResType
++) {
1036 if (ResStatus
[ResType
] == EFI_RESOURCE_SATISFIED
) {
1040 if (ResStatus
[ResType
] == EFI_RESOURCE_NONEXISTENT
) {
1042 // Hostbridge hasn't this resource type
1048 // Hostbridge hasn't enough resource
1050 PciResNode
= GetMaxResourceConsumerDevice (ResPool
[ResType
]);
1056 // Check if the device has been removed before
1058 for (DevIndex
= 0; DevIndex
< RemovedPciDevNum
; DevIndex
++) {
1059 if (PciResNode
->PciDev
== RemovedPciDev
[DevIndex
]) {
1065 // Remove the device if it isn't in the array
1067 Status
= RejectPciDevice (PciResNode
->PciDev
);
1068 if (Status
== EFI_SUCCESS
) {
1071 // Raise the EFI_IOB_EC_RESOURCE_CONFLICT status code
1074 // Have no way to get ReqRes, AllocRes & Bar here
1076 ZeroMem (&AllocFailExtendedData
, sizeof (AllocFailExtendedData
));
1077 AllocFailExtendedData
.DevicePathSize
= sizeof (EFI_DEVICE_PATH_PROTOCOL
);
1078 AllocFailExtendedData
.DevicePath
= (UINT8
*) PciResNode
->PciDev
->DevicePath
;
1079 AllocFailExtendedData
.Bar
= PciResNode
->Bar
;
1081 REPORT_STATUS_CODE_WITH_EXTENDED_DATA (
1083 EFI_IO_BUS_PCI
| EFI_IOB_EC_RESOURCE_CONFLICT
,
1084 (VOID
*) &AllocFailExtendedData
,
1085 sizeof (AllocFailExtendedData
)
1089 // Add it to the array and indicate at least a device has been rejected
1091 RemovedPciDev
[RemovedPciDevNum
++] = PciResNode
->PciDev
;
1092 AllocationAjusted
= TRUE
;
1099 if (AllocationAjusted
) {
1107 ConstructAcpiResourceRequestor (
1108 IN PCI_IO_DEVICE
*Bridge
,
1109 IN PCI_RESOURCE_NODE
*IoNode
,
1110 IN PCI_RESOURCE_NODE
*Mem32Node
,
1111 IN PCI_RESOURCE_NODE
*PMem32Node
,
1112 IN PCI_RESOURCE_NODE
*Mem64Node
,
1113 IN PCI_RESOURCE_NODE
*PMem64Node
,
1118 Routine Description:
1127 // TODO: Bridge - add argument and description to function comment
1128 // TODO: IoNode - add argument and description to function comment
1129 // TODO: Mem32Node - add argument and description to function comment
1130 // TODO: PMem32Node - add argument and description to function comment
1131 // TODO: Mem64Node - add argument and description to function comment
1132 // TODO: PMem64Node - add argument and description to function comment
1133 // TODO: pConfig - add argument and description to function comment
1134 // TODO: EFI_OUT_OF_RESOURCES - add return value to function comment
1135 // TODO: EFI_OUT_OF_RESOURCES - add return value to function comment
1136 // TODO: EFI_SUCCESS - add return value to function comment
1140 UINT8
*Configuration
;
1141 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Ptr
;
1142 EFI_ACPI_END_TAG_DESCRIPTOR
*PtrEnd
;
1150 // if there is io request, add to the io aperture
1152 if (ResourceRequestExisted (IoNode
)) {
1158 // if there is mem32 request, add to the mem32 aperture
1160 if (ResourceRequestExisted (Mem32Node
)) {
1166 // if there is pmem32 request, add to the pmem32 aperture
1168 if (ResourceRequestExisted (PMem32Node
)) {
1174 // if there is mem64 request, add to the mem64 aperture
1176 if (ResourceRequestExisted (Mem64Node
)) {
1182 // if there is pmem64 request, add to the pmem64 aperture
1184 if (ResourceRequestExisted (PMem64Node
)) {
1189 if (NumConfig
!= 0) {
1192 // If there is at least one type of resource request,
1193 // allocate a acpi resource node
1195 Configuration
= AllocatePool (sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) * NumConfig
+ sizeof (EFI_ACPI_END_TAG_DESCRIPTOR
));
1196 if (Configuration
== NULL
) {
1197 return EFI_OUT_OF_RESOURCES
;
1202 sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) * NumConfig
+ sizeof (EFI_ACPI_END_TAG_DESCRIPTOR
)
1205 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) Configuration
;
1208 // Deal with io aperture
1210 if (Aperture
& 0x01) {
1211 Ptr
->Desc
= ACPI_ADDRESS_SPACE_DESCRIPTOR
;
1212 Ptr
->Len
= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) - 3;
1216 Ptr
->ResType
= ACPI_ADDRESS_SPACE_TYPE_IO
;
1220 Ptr
->SpecificFlag
= 1;
1221 Ptr
->AddrLen
= IoNode
->Length
;
1222 Ptr
->AddrRangeMax
= IoNode
->Alignment
;
1224 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) ((UINT8
*) Ptr
+ sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
));
1227 // Deal with mem32 aperture
1229 if (Aperture
& 0x02) {
1230 Ptr
->Desc
= ACPI_ADDRESS_SPACE_DESCRIPTOR
;
1231 Ptr
->Len
= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) - 3;
1235 Ptr
->ResType
= ACPI_ADDRESS_SPACE_TYPE_MEM
;
1239 Ptr
->SpecificFlag
= 0;
1243 Ptr
->AddrSpaceGranularity
= 32;
1244 Ptr
->AddrLen
= Mem32Node
->Length
;
1245 Ptr
->AddrRangeMax
= Mem32Node
->Alignment
;
1247 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) ((UINT8
*) Ptr
+ sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
));
1251 // Deal with Pmem32 aperture
1253 if (Aperture
& 0x04) {
1254 Ptr
->Desc
= ACPI_ADDRESS_SPACE_DESCRIPTOR
;
1255 Ptr
->Len
= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) - 3;
1259 Ptr
->ResType
= ACPI_ADDRESS_SPACE_TYPE_MEM
;
1263 Ptr
->SpecificFlag
= 0x6;
1267 Ptr
->AddrSpaceGranularity
= 32;
1268 Ptr
->AddrLen
= PMem32Node
->Length
;
1269 Ptr
->AddrRangeMax
= PMem32Node
->Alignment
;
1271 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) ((UINT8
*) Ptr
+ sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
));
1274 // Deal with mem64 aperture
1276 if (Aperture
& 0x08) {
1277 Ptr
->Desc
= ACPI_ADDRESS_SPACE_DESCRIPTOR
;
1278 Ptr
->Len
= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) - 3;
1282 Ptr
->ResType
= ACPI_ADDRESS_SPACE_TYPE_MEM
;
1286 Ptr
->SpecificFlag
= 0;
1290 Ptr
->AddrSpaceGranularity
= 64;
1291 Ptr
->AddrLen
= Mem64Node
->Length
;
1292 Ptr
->AddrRangeMax
= Mem64Node
->Alignment
;
1294 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) ((UINT8
*) Ptr
+ sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
));
1297 // Deal with Pmem64 aperture
1299 if (Aperture
& 0x10) {
1300 Ptr
->Desc
= ACPI_ADDRESS_SPACE_DESCRIPTOR
;
1301 Ptr
->Len
= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) - 3;
1305 Ptr
->ResType
= ACPI_ADDRESS_SPACE_TYPE_MEM
;
1309 Ptr
->SpecificFlag
= 0x06;
1313 Ptr
->AddrSpaceGranularity
= 64;
1314 Ptr
->AddrLen
= PMem64Node
->Length
;
1315 Ptr
->AddrRangeMax
= PMem64Node
->Alignment
;
1317 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) (Configuration
+ sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
));
1323 PtrEnd
= (EFI_ACPI_END_TAG_DESCRIPTOR
*) ((UINT8
*) Ptr
);
1325 PtrEnd
->Desc
= ACPI_END_TAG_DESCRIPTOR
;
1326 PtrEnd
->Checksum
= 0;
1331 // If there is no resource request
1333 Configuration
= AllocatePool (sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR
));
1334 if (Configuration
== NULL
) {
1335 return EFI_OUT_OF_RESOURCES
;
1338 ZeroMem (Configuration
, sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
) + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR
));
1340 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) (Configuration
);
1341 Ptr
->Desc
= ACPI_ADDRESS_SPACE_DESCRIPTOR
;
1343 PtrEnd
= (EFI_ACPI_END_TAG_DESCRIPTOR
*) (Configuration
+ sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
));
1344 PtrEnd
->Desc
= ACPI_END_TAG_DESCRIPTOR
;
1345 PtrEnd
->Checksum
= 0;
1348 *pConfig
= Configuration
;
1357 OUT UINT64
*Mem32Base
,
1358 OUT UINT64
*PMem32Base
,
1359 OUT UINT64
*Mem64Base
,
1360 OUT UINT64
*PMem64Base
1364 Routine Description:
1373 // TODO: pConfig - add argument and description to function comment
1374 // TODO: IoBase - add argument and description to function comment
1375 // TODO: Mem32Base - add argument and description to function comment
1376 // TODO: PMem32Base - add argument and description to function comment
1377 // TODO: Mem64Base - add argument and description to function comment
1378 // TODO: PMem64Base - add argument and description to function comment
1379 // TODO: EFI_SUCCESS - add return value to function comment
1382 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*Ptr
;
1385 *IoBase
= 0xFFFFFFFFFFFFFFFFULL
;
1386 *Mem32Base
= 0xFFFFFFFFFFFFFFFFULL
;
1387 *PMem32Base
= 0xFFFFFFFFFFFFFFFFULL
;
1388 *Mem64Base
= 0xFFFFFFFFFFFFFFFFULL
;
1389 *PMem64Base
= 0xFFFFFFFFFFFFFFFFULL
;
1391 Temp
= (UINT8
*) pConfig
;
1393 while (*Temp
== ACPI_ADDRESS_SPACE_DESCRIPTOR
) {
1395 Ptr
= (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
*) Temp
;
1396 ResStatus
= Ptr
->AddrTranslationOffset
;
1398 if (ResStatus
== EFI_RESOURCE_SATISFIED
) {
1400 switch (Ptr
->ResType
) {
1403 // Memory type aperture
1408 // Check to see the granularity
1410 if (Ptr
->AddrSpaceGranularity
== 32) {
1411 if (Ptr
->SpecificFlag
& 0x06) {
1412 *PMem32Base
= Ptr
->AddrRangeMin
;
1414 *Mem32Base
= Ptr
->AddrRangeMin
;
1418 if (Ptr
->AddrSpaceGranularity
== 64) {
1419 if (Ptr
->SpecificFlag
& 0x06) {
1420 *PMem64Base
= Ptr
->AddrRangeMin
;
1422 *Mem64Base
= Ptr
->AddrRangeMin
;
1432 *IoBase
= Ptr
->AddrRangeMin
;
1446 Temp
+= sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
);
1453 PciBridgeEnumerator (
1454 IN PCI_IO_DEVICE
*BridgeDev
1458 Routine Description:
1467 // TODO: BridgeDev - add argument and description to function comment
1468 // TODO: EFI_SUCCESS - add return value to function comment
1471 UINT8 StartBusNumber
;
1472 EFI_PCI_IO_PROTOCOL
*PciIo
;
1477 PciIo
= &(BridgeDev
->PciIo
);
1478 Status
= PciIoRead (PciIo
, EfiPciIoWidthUint8
, 0x19, 1, &StartBusNumber
);
1480 if (EFI_ERROR (Status
)) {
1484 Status
= PciAssignBusNumber (
1490 if (EFI_ERROR (Status
)) {
1494 Status
= PciPciDeviceInfoCollector (BridgeDev
, StartBusNumber
);
1496 if (EFI_ERROR (Status
)) {
1500 Status
= PciBridgeResourceAllocator (BridgeDev
);
1502 if (EFI_ERROR (Status
)) {
1506 Status
= DetermineDeviceAttribute (BridgeDev
);
1508 if (EFI_ERROR (Status
)) {
1517 PciBridgeResourceAllocator (
1518 IN PCI_IO_DEVICE
*Bridge
1522 Routine Description:
1531 // TODO: Bridge - add argument and description to function comment
1532 // TODO: EFI_SUCCESS - add return value to function comment
1534 PCI_RESOURCE_NODE
*IoBridge
;
1535 PCI_RESOURCE_NODE
*Mem32Bridge
;
1536 PCI_RESOURCE_NODE
*PMem32Bridge
;
1537 PCI_RESOURCE_NODE
*Mem64Bridge
;
1538 PCI_RESOURCE_NODE
*PMem64Bridge
;
1546 IoBridge
= CreateResourceNode (
1555 Mem32Bridge
= CreateResourceNode (
1564 PMem32Bridge
= CreateResourceNode (
1573 Mem64Bridge
= CreateResourceNode (
1582 PMem64Bridge
= CreateResourceNode (
1592 // Create resourcemap by going through all the devices subject to this root bridge
1594 Status
= CreateResourceMap (
1603 if (EFI_ERROR (Status
)) {
1607 Status
= GetResourceBaseFromBridge (
1616 if (EFI_ERROR (Status
)) {
1621 // Program IO resources
1629 // Program Mem32 resources
1637 // Program PMem32 resources
1645 // Program Mem64 resources
1653 // Program PMem64 resources
1660 DestroyResourceTree (IoBridge
);
1661 DestroyResourceTree (Mem32Bridge
);
1662 DestroyResourceTree (PMem32Bridge
);
1663 DestroyResourceTree (PMem64Bridge
);
1664 DestroyResourceTree (Mem64Bridge
);
1666 gBS
->FreePool (IoBridge
);
1667 gBS
->FreePool (Mem32Bridge
);
1668 gBS
->FreePool (PMem32Bridge
);
1669 gBS
->FreePool (PMem64Bridge
);
1670 gBS
->FreePool (Mem64Bridge
);
1676 GetResourceBaseFromBridge (
1677 IN PCI_IO_DEVICE
*Bridge
,
1679 OUT UINT64
*Mem32Base
,
1680 OUT UINT64
*PMem32Base
,
1681 OUT UINT64
*Mem64Base
,
1682 OUT UINT64
*PMem64Base
1686 Routine Description:
1695 // TODO: Bridge - add argument and description to function comment
1696 // TODO: IoBase - add argument and description to function comment
1697 // TODO: Mem32Base - add argument and description to function comment
1698 // TODO: PMem32Base - add argument and description to function comment
1699 // TODO: Mem64Base - add argument and description to function comment
1700 // TODO: PMem64Base - add argument and description to function comment
1701 // TODO: EFI_OUT_OF_RESOURCES - add return value to function comment
1702 // TODO: EFI_SUCCESS - add return value to function comment
1704 if (!Bridge
->Allocated
) {
1705 return EFI_OUT_OF_RESOURCES
;
1709 *Mem32Base
= gAllOne
;
1710 *PMem32Base
= gAllOne
;
1711 *Mem64Base
= gAllOne
;
1712 *PMem64Base
= gAllOne
;
1714 if (IS_PCI_BRIDGE (&Bridge
->Pci
)) {
1716 if (Bridge
->PciBar
[PPB_IO_RANGE
].Length
) {
1717 *IoBase
= Bridge
->PciBar
[PPB_IO_RANGE
].BaseAddress
;
1720 if (Bridge
->PciBar
[PPB_MEM32_RANGE
].Length
) {
1721 *Mem32Base
= Bridge
->PciBar
[PPB_MEM32_RANGE
].BaseAddress
;
1724 if (Bridge
->PciBar
[PPB_PMEM32_RANGE
].Length
) {
1725 *PMem32Base
= Bridge
->PciBar
[PPB_PMEM32_RANGE
].BaseAddress
;
1728 if (Bridge
->PciBar
[PPB_PMEM64_RANGE
].Length
) {
1729 *PMem64Base
= Bridge
->PciBar
[PPB_PMEM64_RANGE
].BaseAddress
;
1731 *PMem64Base
= gAllOne
;
1736 if (IS_CARDBUS_BRIDGE (&Bridge
->Pci
)) {
1737 if (Bridge
->PciBar
[P2C_IO_1
].Length
) {
1738 *IoBase
= Bridge
->PciBar
[P2C_IO_1
].BaseAddress
;
1740 if (Bridge
->PciBar
[P2C_IO_2
].Length
) {
1741 *IoBase
= Bridge
->PciBar
[P2C_IO_2
].BaseAddress
;
1745 if (Bridge
->PciBar
[P2C_MEM_1
].Length
) {
1746 if (Bridge
->PciBar
[P2C_MEM_1
].BarType
== PciBarTypePMem32
) {
1747 *PMem32Base
= Bridge
->PciBar
[P2C_MEM_1
].BaseAddress
;
1750 if (Bridge
->PciBar
[P2C_MEM_1
].BarType
== PciBarTypeMem32
) {
1751 *Mem32Base
= Bridge
->PciBar
[P2C_MEM_1
].BaseAddress
;
1755 if (Bridge
->PciBar
[P2C_MEM_2
].Length
) {
1756 if (Bridge
->PciBar
[P2C_MEM_2
].BarType
== PciBarTypePMem32
) {
1757 *PMem32Base
= Bridge
->PciBar
[P2C_MEM_2
].BaseAddress
;
1760 if (Bridge
->PciBar
[P2C_MEM_2
].BarType
== PciBarTypeMem32
) {
1761 *Mem32Base
= Bridge
->PciBar
[P2C_MEM_2
].BaseAddress
;
1771 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
,
1772 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase
1776 Routine Description:
1785 // TODO: PciResAlloc - add argument and description to function comment
1786 // TODO: Phase - add argument and description to function comment
1787 // TODO: EFI_NOT_FOUND - add return value to function comment
1788 // TODO: EFI_SUCCESS - add return value to function comment
1790 EFI_HANDLE HostBridgeHandle
;
1791 EFI_HANDLE RootBridgeHandle
;
1792 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
;
1795 HostBridgeHandle
= NULL
;
1796 RootBridgeHandle
= NULL
;
1797 if (gPciPlatformProtocol
!= NULL
) {
1799 // Get Host Bridge Handle.
1801 PciResAlloc
->GetNextRootBridge (PciResAlloc
, &RootBridgeHandle
);
1804 // Get the rootbridge Io protocol to find the host bridge handle
1806 Status
= gBS
->HandleProtocol (
1808 &gEfiPciRootBridgeIoProtocolGuid
,
1809 (VOID
**) &PciRootBridgeIo
1812 if (EFI_ERROR (Status
)) {
1813 return EFI_NOT_FOUND
;
1816 HostBridgeHandle
= PciRootBridgeIo
->ParentHandle
;
1819 // Call PlatformPci::PhaseNotify() if the protocol is present.
1821 gPciPlatformProtocol
->PhaseNotify (
1822 gPciPlatformProtocol
,
1829 Status
= PciResAlloc
->NotifyPhase (
1834 if (gPciPlatformProtocol
!= NULL
) {
1836 // Call PlatformPci::PhaseNotify() if the protocol is present.
1838 gPciPlatformProtocol
->PhaseNotify (
1839 gPciPlatformProtocol
,
1851 PreprocessController (
1852 IN PCI_IO_DEVICE
*Bridge
,
1856 IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase
1860 Routine Description:
1869 // TODO: Bridge - add argument and description to function comment
1870 // TODO: Bus - add argument and description to function comment
1871 // TODO: Device - add argument and description to function comment
1872 // TODO: Func - add argument and description to function comment
1873 // TODO: Phase - add argument and description to function comment
1874 // TODO: EFI_UNSUPPORTED - add return value to function comment
1875 // TODO: EFI_SUCCESS - add return value to function comment
1877 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS RootBridgePciAddress
;
1878 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
;
1879 EFI_HANDLE RootBridgeHandle
;
1880 EFI_HANDLE HostBridgeHandle
;
1884 // Get the host bridge handle
1886 HostBridgeHandle
= Bridge
->PciRootBridgeIo
->ParentHandle
;
1889 // Get the pci host bridge resource allocation protocol
1891 Status
= gBS
->OpenProtocol (
1893 &gEfiPciHostBridgeResourceAllocationProtocolGuid
,
1894 (VOID
**) &PciResAlloc
,
1897 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1900 if (EFI_ERROR (Status
)) {
1901 return EFI_UNSUPPORTED
;
1905 // Get Root Brige Handle
1907 while (Bridge
->Parent
) {
1908 Bridge
= Bridge
->Parent
;
1911 RootBridgeHandle
= Bridge
->Handle
;
1913 RootBridgePciAddress
.Register
= 0;
1914 RootBridgePciAddress
.Function
= Func
;
1915 RootBridgePciAddress
.Device
= Device
;
1916 RootBridgePciAddress
.Bus
= Bus
;
1917 RootBridgePciAddress
.ExtendedRegister
= 0;
1919 if (gPciPlatformProtocol
!= NULL
) {
1921 // Call PlatformPci::PrepController() if the protocol is present.
1923 gPciPlatformProtocol
->PlatformPrepController (
1924 gPciPlatformProtocol
,
1927 RootBridgePciAddress
,
1933 Status
= PciResAlloc
->PreprocessController (
1936 RootBridgePciAddress
,
1940 if (gPciPlatformProtocol
!= NULL
) {
1942 // Call PlatformPci::PrepController() if the protocol is present.
1944 gPciPlatformProtocol
->PlatformPrepController (
1945 gPciPlatformProtocol
,
1948 RootBridgePciAddress
,
1959 PciHotPlugRequestNotify (
1960 IN EFI_PCI_HOTPLUG_REQUEST_PROTOCOL
* This
,
1961 IN EFI_PCI_HOTPLUG_OPERATION Operation
,
1962 IN EFI_HANDLE Controller
,
1963 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
,
1964 IN OUT UINT8
*NumberOfChildren
,
1965 IN OUT EFI_HANDLE
* ChildHandleBuffer
1969 Routine Description:
1971 Hot plug request notify.
1975 This - A pointer to the hot plug request protocol.
1976 Operation - The operation.
1977 Controller - A pointer to the controller.
1978 RemainningDevicePath - A pointer to the device path.
1979 NumberOfChildren - A the number of child handle in the ChildHandleBuffer.
1980 ChildHandleBuffer - A pointer to the array contain the child handle.
1987 // TODO: RemainingDevicePath - add argument and description to function comment
1988 // TODO: EFI_NOT_FOUND - add return value to function comment
1989 // TODO: EFI_SUCCESS - add return value to function comment
1990 // TODO: EFI_SUCCESS - add return value to function comment
1991 // TODO: EFI_SUCCESS - add return value to function comment
1993 PCI_IO_DEVICE
*Bridge
;
1994 PCI_IO_DEVICE
*Temp
;
1995 EFI_PCI_IO_PROTOCOL
*PciIo
;
1997 EFI_HANDLE RootBridgeHandle
;
2000 Status
= gBS
->OpenProtocol (
2002 &gEfiPciIoProtocolGuid
,
2004 gPciBusDriverBinding
.DriverBindingHandle
,
2006 EFI_OPEN_PROTOCOL_GET_PROTOCOL
2009 if (EFI_ERROR (Status
)) {
2010 return EFI_NOT_FOUND
;
2013 Bridge
= PCI_IO_DEVICE_FROM_PCI_IO_THIS (PciIo
);
2016 // Get root bridge handle
2019 while (Temp
->Parent
) {
2020 Temp
= Temp
->Parent
;
2023 RootBridgeHandle
= Temp
->Handle
;
2025 if (Operation
== EfiPciHotPlugRequestAdd
) {
2027 if (NumberOfChildren
!= NULL
) {
2028 *NumberOfChildren
= 0;
2031 if (IsListEmpty (&Bridge
->ChildList
)) {
2033 Status
= PciBridgeEnumerator (Bridge
);
2035 if (EFI_ERROR (Status
)) {
2040 Status
= StartPciDevicesOnBridge (
2043 RemainingDevicePath
,
2051 if (Operation
== EfiPciHotplugRequestRemove
) {
2053 if (*NumberOfChildren
== 0) {
2055 // Remove all devices on the bridge
2057 Status
= RemoveAllPciDeviceOnBridge (RootBridgeHandle
, Bridge
);
2062 for (Index
= 0; Index
< *NumberOfChildren
; Index
++) {
2064 // De register all the pci device
2066 Status
= DeRegisterPciDevice (RootBridgeHandle
, ChildHandleBuffer
[Index
]);
2068 if (EFI_ERROR (Status
)) {
2083 SearchHostBridgeHandle (
2084 IN EFI_HANDLE RootBridgeHandle
2088 Routine Description:
2097 // TODO: RootBridgeHandle - add argument and description to function comment
2099 EFI_HANDLE HostBridgeHandle
;
2100 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*PciRootBridgeIo
;
2105 // Get the rootbridge Io protocol to find the host bridge handle
2107 Status
= gBS
->OpenProtocol (
2109 &gEfiPciRootBridgeIoProtocolGuid
,
2110 (VOID
**) &PciRootBridgeIo
,
2111 gPciBusDriverBinding
.DriverBindingHandle
,
2113 EFI_OPEN_PROTOCOL_GET_PROTOCOL
2116 if (EFI_ERROR (Status
)) {
2120 HostBridgeHandle
= PciRootBridgeIo
->ParentHandle
;
2121 for (Index
= 0; Index
< gPciHostBridgeNumber
; Index
++) {
2122 if (HostBridgeHandle
== gPciHostBrigeHandles
[Index
]) {
2131 AddHostBridgeEnumerator (
2132 IN EFI_HANDLE HostBridgeHandle
2136 Routine Description:
2145 // TODO: HostBridgeHandle - add argument and description to function comment
2146 // TODO: EFI_ABORTED - add return value to function comment
2147 // TODO: EFI_ABORTED - add return value to function comment
2148 // TODO: EFI_SUCCESS - add return value to function comment
2152 if (!HostBridgeHandle
) {
2156 for (Index
= 0; Index
< gPciHostBridgeNumber
; Index
++) {
2157 if (HostBridgeHandle
== gPciHostBrigeHandles
[Index
]) {
2162 if (Index
< PCI_MAX_HOST_BRIDGE_NUM
) {
2163 gPciHostBrigeHandles
[Index
] = HostBridgeHandle
;
2164 gPciHostBridgeNumber
++;