X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=PcAtChipsetPkg%2FPciHostBridgeDxe%2FPciHostBridge.c;h=a6c1d130ab058a43ab9bf23f23dad63bbc8566fa;hb=b9d5fe03e660b6b3c423d9ceefd10864cbfcdc6c;hp=c2f04ec8072ea6a4f765ec987b3b9e1222dcedd2;hpb=18c97f53ea089437a3e053c834deb737ccbc9576;p=mirror_edk2.git diff --git a/PcAtChipsetPkg/PciHostBridgeDxe/PciHostBridge.c b/PcAtChipsetPkg/PciHostBridgeDxe/PciHostBridge.c index c2f04ec807..a6c1d130ab 100644 --- a/PcAtChipsetPkg/PciHostBridgeDxe/PciHostBridge.c +++ b/PcAtChipsetPkg/PciHostBridgeDxe/PciHostBridge.c @@ -1,7 +1,7 @@ /** @file Provides the basic interfaces to abstract a PCI Host Bridge Resource Allocation -Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.
+Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.
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 @@ -14,17 +14,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "PciHostBridge.h" -// -// Support 64 K IO space -// -#define RES_IO_BASE 0x1000 -#define RES_IO_LIMIT 0xFFFF -// -// Support 4G address space -// -#define RES_MEM_BASE_1 0xF8000000 -#define RES_MEM_LIMIT_1 (0xFEC00000 - 1) - // // Hard code: Root Bridge Number within the host bridge // Root Bridge's attribute @@ -51,7 +40,7 @@ EFI_PCI_ROOT_BRIDGE_DEVICE_PATH mEfiPciRootBridgeDevicePath[1][1] = { }; PCI_ROOT_BRIDGE_RESOURCE_APPETURE mResAppeture[1][1] = { - {0, 0, 0, 0xffffffff, 0, 1 << 16} + {0, 0xff, 0x80000000, 0xffffffff, 0, 0xffff} }; EFI_HANDLE mDriverImageHandle; @@ -78,6 +67,7 @@ PCI_HOST_BRIDGE_INSTANCE mPciHostBridgeInstanceTemplate = { // // Implementation // + /** Entry point of this driver @@ -100,8 +90,6 @@ InitializePciHostBridge ( UINTN Loop2; PCI_HOST_BRIDGE_INSTANCE *HostBridge; PCI_ROOT_BRIDGE_INSTANCE *PrivateData; - IN EFI_PHYSICAL_ADDRESS BaseAddress; - IN UINT64 Length; mDriverImageHandle = ImageHandle; @@ -162,29 +150,6 @@ InitializePciHostBridge ( } } - Status = gDS->AddIoSpace ( - EfiGcdIoTypeIo, - RES_IO_BASE, - RES_IO_LIMIT - RES_IO_BASE + 1 - ); - - // PCI memory space from 3.75Gbytes->(4GBytes - BIOSFWH local APIC etc) - Status = gDS->AddMemorySpace ( - EfiGcdMemoryTypeMemoryMappedIo, - RES_MEM_BASE_1, - (RES_MEM_LIMIT_1 - RES_MEM_BASE_1 + 1), - 0 - ); - - BaseAddress = 0x80000000; - Length = RES_MEM_BASE_1 - BaseAddress; - Status = gDS->AddMemorySpace ( - EfiGcdMemoryTypeMemoryMappedIo, - BaseAddress, - Length, - 0 - ); - return EFI_SUCCESS; } @@ -236,7 +201,7 @@ InitializePciHostBridge ( required here. This notification can be used to perform any chipsetspecific programming. - @param[in] PciResAlloc The instance pointer of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL + @param[in] This The instance pointer of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL @param[in] Phase The phase during enumeration @retval EFI_NOT_READY This phase cannot be entered at this time. For example, this error @@ -345,7 +310,7 @@ NotifyPhase( // // Get the number of '1' in Alignment. // - BitsOfAlignment = HighBitSet64 (RootBridgeInstance->ResAllocNode[Index].Alignment) + 1; + BitsOfAlignment = (UINTN) (HighBitSet64 (RootBridgeInstance->ResAllocNode[Index].Alignment) + 1); switch (Index) { @@ -521,7 +486,7 @@ NotifyPhase( For D945 implementation, there is only one root bridge in PCI host bridge. @param[in] This The instance pointer of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL - @param[in][out] RootBridgeHandle Returns the device handle of the next PCI root bridge. + @param[in, out] RootBridgeHandle Returns the device handle of the next PCI root bridge. @retval EFI_SUCCESS If parameter RootBridgeHandle = NULL, then return the first Rootbridge handle of the specific Host bridge and return EFI_SUCCESS. @@ -871,7 +836,7 @@ SubmitResources( PCI_HOST_BRIDGE_INSTANCE *HostBridgeInstance; PCI_ROOT_BRIDGE_INSTANCE *RootBridgeInstance; UINT8 *Temp; - EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *ptr; + EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Ptr; UINT64 AddrLen; UINT64 Alignment; @@ -898,30 +863,30 @@ SubmitResources( RootBridgeInstance = DRIVER_INSTANCE_FROM_LIST_ENTRY (List); if (RootBridgeHandle == RootBridgeInstance->Handle) { while ( *Temp == 0x8A) { - ptr = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Temp ; + Ptr = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Temp ; // // Check Address Length // - if (ptr->AddrLen > 0xffffffff) { + if (Ptr->AddrLen > 0xffffffff) { return EFI_INVALID_PARAMETER; } // // Check address range alignment // - if (ptr->AddrRangeMax >= 0xffffffff || ptr->AddrRangeMax != (GetPowerOfTwo64 (ptr->AddrRangeMax + 1) - 1)) { + if (Ptr->AddrRangeMax >= 0xffffffff || Ptr->AddrRangeMax != (GetPowerOfTwo64 (Ptr->AddrRangeMax + 1) - 1)) { return EFI_INVALID_PARAMETER; } - switch (ptr->ResType) { + switch (Ptr->ResType) { case 0: // // Check invalid Address Sapce Granularity // - if (ptr->AddrSpaceGranularity != 32) { + if (Ptr->AddrSpaceGranularity != 32) { return EFI_INVALID_PARAMETER; } @@ -929,14 +894,14 @@ SubmitResources( // check the memory resource request is supported by PCI root bridge // if (RootBridgeInstance->RootBridgeAttrib == EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM && - ptr->SpecificFlag == 0x06) { + Ptr->SpecificFlag == 0x06) { return EFI_INVALID_PARAMETER; } - AddrLen = ptr->AddrLen; - Alignment = ptr->AddrRangeMax; - if (ptr->AddrSpaceGranularity == 32) { - if (ptr->SpecificFlag == 0x06) { + AddrLen = Ptr->AddrLen; + Alignment = Ptr->AddrRangeMax; + if (Ptr->AddrSpaceGranularity == 32) { + if (Ptr->SpecificFlag == 0x06) { // // Apply from GCD // @@ -949,8 +914,8 @@ SubmitResources( } } - if (ptr->AddrSpaceGranularity == 64) { - if (ptr->SpecificFlag == 0x06) { + if (Ptr->AddrSpaceGranularity == 64) { + if (Ptr->SpecificFlag == 0x06) { RootBridgeInstance->ResAllocNode[TypePMem64].Status = ResSubmitted; } else { RootBridgeInstance->ResAllocNode[TypeMem64].Status = ResSubmitted; @@ -959,8 +924,8 @@ SubmitResources( break; case 1: - AddrLen = (UINTN)ptr->AddrLen; - Alignment = (UINTN)ptr->AddrRangeMax; + AddrLen = (UINTN) Ptr->AddrLen; + Alignment = (UINTN) Ptr->AddrRangeMax; RootBridgeInstance->ResAllocNode[TypeIo].Length = AddrLen; RootBridgeInstance->ResAllocNode[TypeIo].Alignment = Alignment; RootBridgeInstance->ResAllocNode[TypeIo].Status = ResRequested; @@ -1018,7 +983,7 @@ GetProposedResources( UINTN Number; VOID *Buffer; UINT8 *Temp; - EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *ptr; + EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Ptr; UINT64 ResStatus; Buffer = NULL; @@ -1053,7 +1018,7 @@ GetProposedResources( Temp = Buffer; for (Index = 0; Index < TypeBus; Index ++) { if (RootBridgeInstance->ResAllocNode[Index].Status != ResNone) { - ptr = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Temp ; + Ptr = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Temp ; ResStatus = RootBridgeInstance->ResAllocNode[Index].Status; switch (Index) { @@ -1062,81 +1027,81 @@ GetProposedResources( // // Io // - ptr->Desc = 0x8A; - ptr->Len = 0x2B; - ptr->ResType = 1; - ptr->GenFlag = 0; - ptr->SpecificFlag = 0; - ptr->AddrRangeMin = RootBridgeInstance->ResAllocNode[Index].Base; - ptr->AddrRangeMax = 0; - ptr->AddrTranslationOffset = \ + Ptr->Desc = 0x8A; + Ptr->Len = 0x2B; + Ptr->ResType = 1; + Ptr->GenFlag = 0; + Ptr->SpecificFlag = 0; + Ptr->AddrRangeMin = RootBridgeInstance->ResAllocNode[Index].Base; + Ptr->AddrRangeMax = 0; + Ptr->AddrTranslationOffset = \ (ResStatus == ResAllocated) ? EFI_RESOURCE_SATISFIED : EFI_RESOURCE_LESS; - ptr->AddrLen = RootBridgeInstance->ResAllocNode[Index].Length; + Ptr->AddrLen = RootBridgeInstance->ResAllocNode[Index].Length; break; case TypeMem32: // // Memory 32 // - ptr->Desc = 0x8A; - ptr->Len = 0x2B; - ptr->ResType = 0; - ptr->GenFlag = 0; - ptr->SpecificFlag = 0; - ptr->AddrSpaceGranularity = 32; - ptr->AddrRangeMin = RootBridgeInstance->ResAllocNode[Index].Base; - ptr->AddrRangeMax = 0; - ptr->AddrTranslationOffset = \ + Ptr->Desc = 0x8A; + Ptr->Len = 0x2B; + Ptr->ResType = 0; + Ptr->GenFlag = 0; + Ptr->SpecificFlag = 0; + Ptr->AddrSpaceGranularity = 32; + Ptr->AddrRangeMin = RootBridgeInstance->ResAllocNode[Index].Base; + Ptr->AddrRangeMax = 0; + Ptr->AddrTranslationOffset = \ (ResStatus == ResAllocated) ? EFI_RESOURCE_SATISFIED : EFI_RESOURCE_LESS; - ptr->AddrLen = RootBridgeInstance->ResAllocNode[Index].Length; + Ptr->AddrLen = RootBridgeInstance->ResAllocNode[Index].Length; break; case TypePMem32: // // Prefetch memory 32 // - ptr->Desc = 0x8A; - ptr->Len = 0x2B; - ptr->ResType = 0; - ptr->GenFlag = 0; - ptr->SpecificFlag = 6; - ptr->AddrSpaceGranularity = 32; - ptr->AddrRangeMin = 0; - ptr->AddrRangeMax = 0; - ptr->AddrTranslationOffset = EFI_RESOURCE_NONEXISTENT; - ptr->AddrLen = 0; + Ptr->Desc = 0x8A; + Ptr->Len = 0x2B; + Ptr->ResType = 0; + Ptr->GenFlag = 0; + Ptr->SpecificFlag = 6; + Ptr->AddrSpaceGranularity = 32; + Ptr->AddrRangeMin = 0; + Ptr->AddrRangeMax = 0; + Ptr->AddrTranslationOffset = EFI_RESOURCE_NONEXISTENT; + Ptr->AddrLen = 0; break; case TypeMem64: // // Memory 64 // - ptr->Desc = 0x8A; - ptr->Len = 0x2B; - ptr->ResType = 0; - ptr->GenFlag = 0; - ptr->SpecificFlag = 0; - ptr->AddrSpaceGranularity = 64; - ptr->AddrRangeMin = 0; - ptr->AddrRangeMax = 0; - ptr->AddrTranslationOffset = EFI_RESOURCE_NONEXISTENT; - ptr->AddrLen = 0; + Ptr->Desc = 0x8A; + Ptr->Len = 0x2B; + Ptr->ResType = 0; + Ptr->GenFlag = 0; + Ptr->SpecificFlag = 0; + Ptr->AddrSpaceGranularity = 64; + Ptr->AddrRangeMin = 0; + Ptr->AddrRangeMax = 0; + Ptr->AddrTranslationOffset = EFI_RESOURCE_NONEXISTENT; + Ptr->AddrLen = 0; break; case TypePMem64: // // Prefetch memory 64 // - ptr->Desc = 0x8A; - ptr->Len = 0x2B; - ptr->ResType = 0; - ptr->GenFlag = 0; - ptr->SpecificFlag = 6; - ptr->AddrSpaceGranularity = 64; - ptr->AddrRangeMin = 0; - ptr->AddrRangeMax = 0; - ptr->AddrTranslationOffset = EFI_RESOURCE_NONEXISTENT; - ptr->AddrLen = 0; + Ptr->Desc = 0x8A; + Ptr->Len = 0x2B; + Ptr->ResType = 0; + Ptr->GenFlag = 0; + Ptr->SpecificFlag = 6; + Ptr->AddrSpaceGranularity = 64; + Ptr->AddrRangeMin = 0; + Ptr->AddrRangeMax = 0; + Ptr->AddrTranslationOffset = EFI_RESOURCE_NONEXISTENT; + Ptr->AddrLen = 0; break; }; @@ -1158,110 +1123,6 @@ GetProposedResources( return EFI_INVALID_PARAMETER; } -/** - Update attribute for PCI root bridge for specifc device. - - @param RootBridge Point to PCI root bridge. - @param PciAddress The specific device PCI address -**/ -STATIC -VOID -UpdateRootBridgeAttributes ( - IN PCI_ROOT_BRIDGE_INSTANCE *RootBridge, - IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress - ) -{ - EFI_STATUS Status; - PCI_TYPE01 PciConfigurationHeader; - UINT64 Attributes; - - // - // Read the PCI Configuration Header for the device - // - Status = RootBridge->Io.Pci.Read ( - &RootBridge->Io, - EfiPciWidthUint16, - EFI_PCI_ADDRESS( - PciAddress.Bus, - PciAddress.Device, - PciAddress.Function, - 0 - ), - sizeof (PciConfigurationHeader) / sizeof (UINT16), - &PciConfigurationHeader - ); - if (EFI_ERROR (Status)) { - return; - } - - Attributes = RootBridge->Attributes; - - // - // Look for devices with the VGA Palette Snoop enabled in the COMMAND register of the PCI Config Header - // - if (PciConfigurationHeader.Hdr.Command & 0x20) { - Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO; - } - - // - // If the device is a PCI-PCI Bridge, then look at the Subordinate Bus Number - // - if (IS_PCI_BRIDGE(&PciConfigurationHeader)) { - // - // Look at the PPB Configuration for legacy decoding attributes - // - if (PciConfigurationHeader.Bridge.BridgeControl & 0x04) { - Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO; - Attributes |= EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO; - } - if (PciConfigurationHeader.Bridge.BridgeControl & 0x08) { - Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO; - Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY; - Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO; - } - } else { - // - // See if the PCI device is an IDE controller - // - if (PciConfigurationHeader.Hdr.ClassCode[2] == 0x01 && - PciConfigurationHeader.Hdr.ClassCode[1] == 0x01 ) { - if (PciConfigurationHeader.Hdr.ClassCode[0] & 0x80) { - Attributes |= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO; - Attributes |= EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO; - } - if (PciConfigurationHeader.Hdr.ClassCode[0] & 0x01) { - Attributes |= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO; - } - if (PciConfigurationHeader.Hdr.ClassCode[0] & 0x04) { - Attributes |= EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO; - } - } - - // - // See if the PCI device is a legacy VGA controller - // - if (PciConfigurationHeader.Hdr.ClassCode[2] == 0x00 && - PciConfigurationHeader.Hdr.ClassCode[1] == 0x01 ) { - Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO; - Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY; - Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO; - } - - // - // See if the PCI device is a standard VGA controller - // - if (PciConfigurationHeader.Hdr.ClassCode[2] == 0x03 && - PciConfigurationHeader.Hdr.ClassCode[1] == 0x00 ) { - Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO; - Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY; - Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO; - } - } - - RootBridge->Attributes = Attributes; - RootBridge->Supports = Attributes; -} - /** Provides the hooks from the PCI bus driver to every PCI controller (device/function) at various stages of the PCI enumeration process that allow the host bridge driver to preinitialize individual @@ -1292,7 +1153,7 @@ UpdateRootBridgeAttributes ( EFI_STATUS EFIAPI PreprocessController ( - IN struct _EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This, + IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This, IN EFI_HANDLE RootBridgeHandle, IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress, IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase @@ -1311,14 +1172,17 @@ PreprocessController ( while (List != &HostBridgeInstance->Head) { RootBridgeInstance = DRIVER_INSTANCE_FROM_LIST_ENTRY (List); if (RootBridgeHandle == RootBridgeInstance->Handle) { - UpdateRootBridgeAttributes ( - RootBridgeInstance, - PciAddress - ); - return EFI_SUCCESS; + break; } List = List->ForwardLink; } + if (List == &HostBridgeInstance->Head) { + return EFI_INVALID_PARAMETER; + } - return EFI_INVALID_PARAMETER; + if (Phase < EfiPciBeforeChildBusEnumeration || Phase > EfiPciBeforeResourceCollection) { + return EFI_INVALID_PARAMETER; + } + + return EFI_SUCCESS; }