From: yshang1 Date: Mon, 6 Aug 2007 03:52:01 +0000 (+0000) Subject: Fix bug in PciCfg to support PCI express address. X-Git-Tag: edk2-stable201903~22412 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=d8b61daacca489c69b3f21d2f8d6bd6e33e16e13 Fix bug in PciCfg to support PCI express address. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3549 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/IntelFrameworkModulePkg/Universal/PcatSingleSegmentPciCfgPei/PciCfg.c b/IntelFrameworkModulePkg/Universal/PcatSingleSegmentPciCfgPei/PciCfg.c index 20bee53355..361f5be40b 100644 --- a/IntelFrameworkModulePkg/Universal/PcatSingleSegmentPciCfgPei/PciCfg.c +++ b/IntelFrameworkModulePkg/Universal/PcatSingleSegmentPciCfgPei/PciCfg.c @@ -53,7 +53,7 @@ PciCfgRead ( { UINTN PciLibAddress; - PciLibAddress = COMMON_TO_PCILIB_ADDRESS (Address); + PciLibAddress = PciCfgAddressConvert ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &Address); switch (Width) { case EfiPeiPciCfgWidthUint8: * (UINT8 *) Buffer = PciRead8 (PciLibAddress); @@ -103,7 +103,7 @@ PciCfgWrite ( { UINTN PciLibAddress; - PciLibAddress = COMMON_TO_PCILIB_ADDRESS (Address); + PciLibAddress = PciCfgAddressConvert ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &Address); switch (Width) { case EfiPeiPciCfgWidthUint8: PciWrite8 (PciLibAddress, *(UINT8 *) Buffer); @@ -153,7 +153,7 @@ PciCfgModify ( { UINTN PciLibAddress; - PciLibAddress = COMMON_TO_PCILIB_ADDRESS (Address); + PciLibAddress = PciCfgAddressConvert ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &Address); switch (Width) { case EfiPeiPciCfgWidthUint8: PciAndThenOr8 (PciLibAddress, (UINT8)~ClearBits, (UINT8)SetBits); diff --git a/IntelFrameworkModulePkg/Universal/PcatSingleSegmentPciCfgPei/PciCfg2.c b/IntelFrameworkModulePkg/Universal/PcatSingleSegmentPciCfgPei/PciCfg2.c index 214a505478..28af898b98 100644 --- a/IntelFrameworkModulePkg/Universal/PcatSingleSegmentPciCfgPei/PciCfg2.c +++ b/IntelFrameworkModulePkg/Universal/PcatSingleSegmentPciCfgPei/PciCfg2.c @@ -71,6 +71,28 @@ EFI_PEI_PPI_DESCRIPTOR gPciCfgPpiList = { &gPciCfgPpi }; + +/** + Convert EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS to PCI_LIB_ADDRESS. + + @param Address PCI address with + EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS format. + + @return The PCI address with PCI_LIB_ADDRESS format. + +**/ +UINTN +PciCfgAddressConvert ( + EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *Address + ) +{ + if (Address->ExtendedRegister == 0) { + return PCI_LIB_ADDRESS (Address->Bus, Address->Device, Address->Function, Address->Register); + } + + return PCI_LIB_ADDRESS (Address->Bus, Address->Device, Address->Function, Address->ExtendedRegister); +} + /** Reads from a given location in the PCI configuration space. @@ -107,7 +129,7 @@ PciCfg2Read ( { UINTN PciLibAddress; - PciLibAddress = COMMON_TO_PCILIB_ADDRESS (Address); + PciLibAddress = PciCfgAddressConvert ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &Address); if (Width == EfiPeiPciCfgWidthUint8) { *((UINT8 *) Buffer) = PciRead8 (PciLibAddress); @@ -158,7 +180,7 @@ PciCfg2Write ( { UINTN PciLibAddress; - PciLibAddress = COMMON_TO_PCILIB_ADDRESS (Address); + PciLibAddress = PciCfgAddressConvert ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &Address); if (Width == EfiPeiPciCfgWidthUint8) { PciWrite8 (PciLibAddress, *((UINT8 *) Buffer)); @@ -216,7 +238,7 @@ PciCfg2Modify ( { UINTN PciLibAddress; - PciLibAddress = COMMON_TO_PCILIB_ADDRESS (Address); + PciLibAddress = PciCfgAddressConvert ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &Address); if (Width == EfiPeiPciCfgWidthUint8) { PciAndThenOr8 (PciLibAddress, ~(*(UINT8 *)ClearBits), *((UINT8 *) SetBits)); diff --git a/IntelFrameworkModulePkg/Universal/PcatSingleSegmentPciCfgPei/PciCfgInternal.h b/IntelFrameworkModulePkg/Universal/PcatSingleSegmentPciCfgPei/PciCfgInternal.h index 2b6faa56f0..fed8f7277c 100644 --- a/IntelFrameworkModulePkg/Universal/PcatSingleSegmentPciCfgPei/PciCfgInternal.h +++ b/IntelFrameworkModulePkg/Universal/PcatSingleSegmentPciCfgPei/PciCfgInternal.h @@ -28,12 +28,20 @@ #include -#define COMMON_TO_PCILIB_ADDRESS(A) (UINTN)PCI_LIB_ADDRESS( \ - ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &A)->Bus, \ - ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &A)->Device, \ - ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &A)->Function, \ - ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &A)->Register \ - ) + +/** + Convert EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS to PCI_LIB_ADDRESS. + + @param Address PCI address with + EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS format. + + @return The PCI address with PCI_LIB_ADDRESS format. + +**/ +UINTN +PciCfgAddressConvert ( + EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *Address + ); /** diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf index 05ece78b7b..77991e987d 100644 --- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf +++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf @@ -67,7 +67,6 @@ BaseMemoryLib PeiServicesTablePointerLib CustomDecompressLib - TianoDecompressLib UefiDecompressLib PeCoffLoaderLib CacheMaintenanceLib diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index 4f2d8bf946..e19e463513 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -79,7 +79,7 @@ ReportStatusCodeLib|IntelFrameworkPkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf - SmBusLib|MdePkg/Library/PeiSmbusLibSmbus2Ppi/PeiSmbusLib.inf + SmBusLib|MdePkg/Library/PeiSmbusLibSmbus2Ppi/PeiSmbusLibSmbus2Ppi.inf [LibraryClasses.common.DXE_CORE] HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf diff --git a/MdeModulePkg/Universal/PcatSingleSegmentPciCfg2Pei/PciCfg2.c b/MdeModulePkg/Universal/PcatSingleSegmentPciCfg2Pei/PciCfg2.c index cab55126f8..3542bdd646 100644 --- a/MdeModulePkg/Universal/PcatSingleSegmentPciCfg2Pei/PciCfg2.c +++ b/MdeModulePkg/Universal/PcatSingleSegmentPciCfg2Pei/PciCfg2.c @@ -22,13 +22,27 @@ #include -#define COMMON_TO_PCILIB_ADDRESS(A) (UINTN)PCI_LIB_ADDRESS( \ - ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &A)->Bus, \ - ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &A)->Device, \ - ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &A)->Function, \ - ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &A)->Register \ - ) +/** + Convert EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS to PCI_LIB_ADDRESS. + @param Address PCI address with + EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS format. + + @return The PCI address with PCI_LIB_ADDRESS format. + +**/ +STATIC +UINTN +PciCfgAddressConvert ( + EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *Address + ) +{ + if (Address->ExtendedRegister == 0) { + return PCI_LIB_ADDRESS (Address->Bus, Address->Device, Address->Function, Address->Register); + } + + return PCI_LIB_ADDRESS (Address->Bus, Address->Device, Address->Function, Address->ExtendedRegister); +} /** Reads from a given location in the PCI configuration space. @@ -206,7 +220,7 @@ PciCfg2Read ( { UINTN PciLibAddress; - PciLibAddress = COMMON_TO_PCILIB_ADDRESS (Address); + PciLibAddress = PciCfgAddressConvert ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &Address); if (Width == EfiPeiPciCfgWidthUint8) { *((UINT8 *) Buffer) = PciRead8 (PciLibAddress); @@ -257,7 +271,7 @@ PciCfg2Write ( { UINTN PciLibAddress; - PciLibAddress = COMMON_TO_PCILIB_ADDRESS (Address); + PciLibAddress = PciCfgAddressConvert ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &Address); if (Width == EfiPeiPciCfgWidthUint8) { PciWrite8 (PciLibAddress, *((UINT8 *) Buffer)); @@ -315,7 +329,7 @@ PciCfg2Modify ( { UINTN PciLibAddress; - PciLibAddress = COMMON_TO_PCILIB_ADDRESS (Address); + PciLibAddress = PciCfgAddressConvert ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &Address); if (Width == EfiPeiPciCfgWidthUint8) { PciAndThenOr8 (PciLibAddress, ~(*(UINT8 *)ClearBits), *((UINT8 *) SetBits)); diff --git a/MdePkg/Library/PeiSmbusLibSmbus2Ppi/PeiSmbusLib.inf b/MdePkg/Library/PeiSmbusLibSmbus2Ppi/PeiSmbusLib.inf deleted file mode 100644 index 1e0a9f225e..0000000000 --- a/MdePkg/Library/PeiSmbusLibSmbus2Ppi/PeiSmbusLib.inf +++ /dev/null @@ -1,51 +0,0 @@ -#/** @file -# Component description file for Pei Smbus Library. -# -# SMBUS library that layers on top of the SMBUS PPI. -# Copyright (c) 2006 - 2007, 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 -# http://opensource.org/licenses/bsd-license.php -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -# -#**/ - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = PeiSmbusLibSmbus2Ppi - FILE_GUID = 2A1E1C92-AABA-4d62-AC40-F3A4C3387356 - MODULE_TYPE = PEIM - VERSION_STRING = 1.0 - LIBRARY_CLASS = SmbusLib|PEIM - EDK_RELEASE_VERSION = 0x00020000 - EFI_SPECIFICATION_VERSION = 0x00020000 - - -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources.common] - SmbusLib.c - PeiSmbusLib.c - InternalSmbusLib.h - - -[Packages] - MdePkg/MdePkg.dec - - -[LibraryClasses] - BaseMemoryLib - PeiServicesTablePointerLib - DebugLib - -[Ppis] - gEfiPeiSmbus2PpiGuid # PPI ALWAYS_CONSUMED - -[Depex] - gEfiPeiSmbus2PpiGuid diff --git a/MdePkg/Library/PeiSmbusLibSmbus2Ppi/PeiSmbusLibSmbus2Ppi.inf b/MdePkg/Library/PeiSmbusLibSmbus2Ppi/PeiSmbusLibSmbus2Ppi.inf new file mode 100644 index 0000000000..1e0a9f225e --- /dev/null +++ b/MdePkg/Library/PeiSmbusLibSmbus2Ppi/PeiSmbusLibSmbus2Ppi.inf @@ -0,0 +1,51 @@ +#/** @file +# Component description file for Pei Smbus Library. +# +# SMBUS library that layers on top of the SMBUS PPI. +# Copyright (c) 2006 - 2007, 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 +# http://opensource.org/licenses/bsd-license.php +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# +#**/ + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = PeiSmbusLibSmbus2Ppi + FILE_GUID = 2A1E1C92-AABA-4d62-AC40-F3A4C3387356 + MODULE_TYPE = PEIM + VERSION_STRING = 1.0 + LIBRARY_CLASS = SmbusLib|PEIM + EDK_RELEASE_VERSION = 0x00020000 + EFI_SPECIFICATION_VERSION = 0x00020000 + + +# +# VALID_ARCHITECTURES = IA32 X64 IPF EBC +# + +[Sources.common] + SmbusLib.c + PeiSmbusLib.c + InternalSmbusLib.h + + +[Packages] + MdePkg/MdePkg.dec + + +[LibraryClasses] + BaseMemoryLib + PeiServicesTablePointerLib + DebugLib + +[Ppis] + gEfiPeiSmbus2PpiGuid # PPI ALWAYS_CONSUMED + +[Depex] + gEfiPeiSmbus2PpiGuid diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc index eaa23f97ca..5ece2f0e5a 100644 --- a/MdePkg/MdePkg.dsc +++ b/MdePkg/MdePkg.dsc @@ -84,7 +84,7 @@ MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf MdePkg/Library/PeiServicesLib/PeiServicesLib.inf MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf - MdePkg/Library/PeiSmbusLibSmbus2Ppi/PeiSmbusLib.inf + MdePkg/Library/PeiSmbusLibSmbus2Ppi/PeiSmbusLibSmbus2Ppi.inf MdePkg/Library/SerialPortLibNull/SerialPortLibNull.inf MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf diff --git a/Nt32Pkg/Nt32Pkg.dsc b/Nt32Pkg/Nt32Pkg.dsc index 5588c39ad0..b6d5bbc9ee 100644 --- a/Nt32Pkg/Nt32Pkg.dsc +++ b/Nt32Pkg/Nt32Pkg.dsc @@ -101,6 +101,7 @@ PeCoffLoaderLib|MdeModulePkg/Library/DxePeCoffLoaderFromHobLib/DxePeCoffLoaderFromHobLib.inf UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf DebugLib|IntelFrameworkPkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf + PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf [LibraryClasses.common.DXE_SMM_DRIVER] @@ -250,7 +251,6 @@ PcdReportStatusCodePropertyMask|gEfiMdePkgTokenSpaceGuid|0x0f PcdDebugPropertyMask|gEfiMdePkgTokenSpaceGuid|0x1f PcdDebugClearMemoryValue|gEfiMdePkgTokenSpaceGuid|0xAF - PcdDebugPrintErrorLevel|gEfiMdePkgTokenSpaceGuid|0x80000040 PcdPerformanceLibraryPropertyMask|gEfiMdePkgTokenSpaceGuid|0 PcdMaxPeiPcdCallBackNumberPerPcdEntry|gEfiMdeModulePkgTokenSpaceGuid|0x08 PcdVpdBaseAddress|gEfiMdeModulePkgTokenSpaceGuid|0x0 @@ -349,6 +349,8 @@ PcdFlashNvStorageFtwWorkingBase|gEfiMdeModulePkgTokenSpaceGuid|0 PcdFlashNvStorageVariableBase|gEfiMdeModulePkgTokenSpaceGuid|0 + + PcdDebugPrintErrorLevel|gEfiMdePkgTokenSpaceGuid|0x80000040 ################################################################################ # # Components Section - list of all EDK II Modules needed by this Platform