X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FBus%2FPci%2FPciBusDxe%2FPciEnumerator.c;h=d5d3c07393e27a65f8b251a107bec0ee862efed1;hb=42e8bc7d16aa2ef8d65a19b327d33c64cae54a9c;hp=76e35ff038cfd547d94627c0cba211b2bdcef3ae;hpb=724f26a9d02e6c6fb87d85243d2849c153cffbb5;p=mirror_edk2.git diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c index 76e35ff038..d5d3c07393 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c @@ -1,7 +1,8 @@ /** @file PCI eunmeration implementation on entire PCI bus system for PCI Bus module. -Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+(C) Copyright 2015 Hewlett Packard Enterprise Development LP
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -18,7 +19,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. This routine is used to enumerate entire pci bus system in a given platform. - @param Controller Parent controller handle. + @param Controller Parent controller handle. + @param HostBridgeHandle Host bridge handle. @retval EFI_SUCCESS PCI enumeration finished successfully. @retval other Some error occurred when enumerating the pci bus system. @@ -26,42 +28,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ EFI_STATUS PciEnumerator ( - IN EFI_HANDLE Controller + IN EFI_HANDLE Controller, + IN EFI_HANDLE HostBridgeHandle ) { - EFI_HANDLE Handle; - EFI_HANDLE HostBridgeHandle; EFI_STATUS Status; EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *PciResAlloc; - EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo; - - // - // If PCI bus has already done the full enumeration, never do it again - // - if (!gFullEnumeration) { - return PciEnumeratorLight (Controller); - } - - // - // Get the rootbridge Io protocol to find the host bridge handle - // - Status = gBS->OpenProtocol ( - Controller, - &gEfiPciRootBridgeIoProtocolGuid, - (VOID **) &PciRootBridgeIo, - gPciBusDriverBinding.DriverBindingHandle, - Controller, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Get the host bridge handle - // - HostBridgeHandle = PciRootBridgeIo->ParentHandle; // // Get the pci host bridge resource allocation protocol @@ -82,7 +54,11 @@ PciEnumerator ( // // Notify the pci bus enumeration is about to begin // - NotifyPhase (PciResAlloc, EfiPciHostBridgeBeginEnumeration); + Status = NotifyPhase (PciResAlloc, EfiPciHostBridgeBeginEnumeration); + + if (EFI_ERROR (Status)) { + return Status; + } // // Start the bus allocation phase @@ -105,7 +81,11 @@ PciEnumerator ( // // Notify the pci bus enumeration is about to complete // - NotifyPhase (PciResAlloc, EfiPciHostBridgeEndEnumeration); + Status = NotifyPhase (PciResAlloc, EfiPciHostBridgeEndEnumeration); + + if (EFI_ERROR (Status)) { + return Status; + } // // Process P2C @@ -124,19 +104,6 @@ PciEnumerator ( return Status; } - gFullEnumeration = FALSE; - - Handle = NULL; - Status = gBS->InstallProtocolInterface ( - &Handle, - &gEfiPciEnumerationCompleteProtocolGuid, - EFI_NATIVE_INTERFACE, - NULL - ); - if (EFI_ERROR (Status)) { - return Status; - } - return EFI_SUCCESS; } @@ -401,6 +368,13 @@ PciAssignBusNumber ( Func ); + if (EFI_ERROR (Status) && Func == 0) { + // + // go to next device if there is no Function 0 + // + break; + } + if (!EFI_ERROR (Status) && (IS_PCI_BRIDGE (&Pci) || IS_CARDBUS_BRIDGE (&Pci))) { @@ -794,7 +768,6 @@ RejectPciDevice ( if (Temp == PciDevice) { InitializePciDevice (Temp); RemoveEntryList (CurrentLink); - FreePciDevice (Temp); return EFI_SUCCESS; } @@ -949,7 +922,7 @@ GetMaxResourceConsumerDevice ( @param Mem64ResStatus Status of 64-bit memory resource node. @param PMem64ResStatus Status of 64-bit Prefetchable memory resource node. - @retval EFI_SUCCESS Successfully adjusted resoruce on host bridge. + @retval EFI_SUCCESS Successfully adjusted resource on host bridge. @retval EFI_ABORTED Host bridge hasn't this resource type or no resource be adjusted. **/ @@ -1078,7 +1051,7 @@ PciHostBridgeAdjustAllocation ( } /** - Summary requests for all resource type, and contruct ACPI resource + Summary requests for all resource type, and construct ACPI resource requestor instance. @param Bridge detecting bridge @@ -1090,7 +1063,7 @@ PciHostBridgeAdjustAllocation ( @param Config Output buffer holding new constructed APCI resource requestor @retval EFI_SUCCESS Successfully constructed ACPI resource. - @retval EFI_OUT_OF_RESOURCES No memory availabe. + @retval EFI_OUT_OF_RESOURCES No memory available. **/ EFI_STATUS @@ -1294,15 +1267,12 @@ ConstructAcpiResourceRequestor ( // // If there is no resource request // - Configuration = AllocateZeroPool (sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR)); + Configuration = AllocateZeroPool (sizeof (EFI_ACPI_END_TAG_DESCRIPTOR)); if (Configuration == NULL) { return EFI_OUT_OF_RESOURCES; } - Ptr = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) (Configuration); - Ptr->Desc = ACPI_ADDRESS_SPACE_DESCRIPTOR; - - PtrEnd = (EFI_ACPI_END_TAG_DESCRIPTOR *) (Ptr + 1); + PtrEnd = (EFI_ACPI_END_TAG_DESCRIPTOR *) (Configuration); PtrEnd->Desc = ACPI_END_TAG_DESCRIPTOR; PtrEnd->Checksum = 0; }