]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix bug in PciCfg to support PCI express address.
authoryshang1 <yshang1@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 6 Aug 2007 03:52:01 +0000 (03:52 +0000)
committeryshang1 <yshang1@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 6 Aug 2007 03:52:01 +0000 (03:52 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3549 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Universal/PcatSingleSegmentPciCfgPei/PciCfg.c
IntelFrameworkModulePkg/Universal/PcatSingleSegmentPciCfgPei/PciCfg2.c
IntelFrameworkModulePkg/Universal/PcatSingleSegmentPciCfgPei/PciCfgInternal.h
MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
MdeModulePkg/MdeModulePkg.dsc
MdeModulePkg/Universal/PcatSingleSegmentPciCfg2Pei/PciCfg2.c
MdePkg/Library/PeiSmbusLibSmbus2Ppi/PeiSmbusLib.inf [deleted file]
MdePkg/Library/PeiSmbusLibSmbus2Ppi/PeiSmbusLibSmbus2Ppi.inf [new file with mode: 0644]
MdePkg/MdePkg.dsc
Nt32Pkg/Nt32Pkg.dsc

index 20bee53355cf8fa8e39949bded6da6c687a5aae7..361f5be40b549c218c6eb6aa128be9282fb8b825 100644 (file)
@@ -53,7 +53,7 @@ PciCfgRead (
 {\r
   UINTN  PciLibAddress;\r
 \r
-  PciLibAddress = COMMON_TO_PCILIB_ADDRESS (Address);\r
+  PciLibAddress = PciCfgAddressConvert ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &Address);\r
        switch (Width) {\r
     case EfiPeiPciCfgWidthUint8:\r
       * (UINT8 *) Buffer = PciRead8 (PciLibAddress);\r
@@ -103,7 +103,7 @@ PciCfgWrite (
 {\r
   UINTN  PciLibAddress;\r
 \r
-  PciLibAddress = COMMON_TO_PCILIB_ADDRESS (Address);\r
+  PciLibAddress = PciCfgAddressConvert ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &Address);\r
   switch (Width) {\r
     case EfiPeiPciCfgWidthUint8:\r
       PciWrite8 (PciLibAddress, *(UINT8 *) Buffer);\r
@@ -153,7 +153,7 @@ PciCfgModify (
 {\r
   UINTN  PciLibAddress;\r
 \r
-  PciLibAddress = COMMON_TO_PCILIB_ADDRESS (Address);\r
+  PciLibAddress = PciCfgAddressConvert ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &Address);\r
        switch (Width) {\r
     case EfiPeiPciCfgWidthUint8:\r
       PciAndThenOr8 (PciLibAddress, (UINT8)~ClearBits, (UINT8)SetBits);\r
index 214a505478e8e93ce9915825175c4ba7aa9df0e5..28af898b98161cb66da9b197f0b7e0d477e3279d 100644 (file)
@@ -71,6 +71,28 @@ EFI_PEI_PPI_DESCRIPTOR gPciCfgPpiList = {
   &gPciCfgPpi\r
 };\r
 \r
+\r
+/**\r
+   Convert EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS to PCI_LIB_ADDRESS.\r
+\r
+   @param Address   PCI address with\r
+                    EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS format.\r
+   \r
+   @return The PCI address with PCI_LIB_ADDRESS format.\r
+   \r
+**/\r
+UINTN\r
+PciCfgAddressConvert (\r
+  EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *Address\r
+  )\r
+{\r
+  if (Address->ExtendedRegister == 0) {\r
+    return PCI_LIB_ADDRESS (Address->Bus, Address->Device, Address->Function, Address->Register);\r
+  }\r
+\r
+  return PCI_LIB_ADDRESS (Address->Bus, Address->Device, Address->Function, Address->ExtendedRegister);\r
+}\r
+\r
 /**\r
   Reads from a given location in the PCI configuration space.\r
 \r
@@ -107,7 +129,7 @@ PciCfg2Read (
 {\r
   UINTN  PciLibAddress;\r
 \r
-  PciLibAddress = COMMON_TO_PCILIB_ADDRESS (Address);\r
+  PciLibAddress = PciCfgAddressConvert ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &Address);\r
 \r
   if (Width == EfiPeiPciCfgWidthUint8) {\r
     *((UINT8 *) Buffer) = PciRead8 (PciLibAddress);\r
@@ -158,7 +180,7 @@ PciCfg2Write (
 {\r
   UINTN  PciLibAddress;\r
 \r
-  PciLibAddress = COMMON_TO_PCILIB_ADDRESS (Address);\r
+  PciLibAddress = PciCfgAddressConvert ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &Address);\r
 \r
   if (Width == EfiPeiPciCfgWidthUint8) {\r
     PciWrite8 (PciLibAddress, *((UINT8 *) Buffer));\r
@@ -216,7 +238,7 @@ PciCfg2Modify (
 {\r
   UINTN  PciLibAddress;\r
 \r
-  PciLibAddress = COMMON_TO_PCILIB_ADDRESS (Address);\r
+  PciLibAddress = PciCfgAddressConvert ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &Address);\r
 \r
   if (Width == EfiPeiPciCfgWidthUint8) {\r
     PciAndThenOr8 (PciLibAddress, ~(*(UINT8 *)ClearBits), *((UINT8 *) SetBits));\r
index 2b6faa56f0dd190ff633eedefb61eeeadded763c..fed8f7277ca8de70ac71fbd92ac7536bc3205cf7 100644 (file)
 \r
 #include <IndustryStandard\Pci.h>\r
 \r
-#define COMMON_TO_PCILIB_ADDRESS(A) (UINTN)PCI_LIB_ADDRESS( \\r
-       ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &A)->Bus, \\r
-       ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &A)->Device, \\r
-       ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &A)->Function, \\r
-       ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &A)->Register \\r
-       )\r
+\r
+/**\r
+   Convert EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS to PCI_LIB_ADDRESS.\r
+\r
+   @param Address   PCI address with\r
+                    EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS format.\r
+   \r
+   @return The PCI address with PCI_LIB_ADDRESS format.\r
+   \r
+**/\r
+UINTN\r
+PciCfgAddressConvert (\r
+  EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *Address\r
+  );\r
 \r
 \r
 /**\r
index 05ece78b7b7748403bcfb5abab25fb2e445ce81a..77991e987d867bf8693a71155601d1f582dbcf15 100644 (file)
@@ -67,7 +67,6 @@
   BaseMemoryLib\r
   PeiServicesTablePointerLib\r
   CustomDecompressLib\r
-  TianoDecompressLib\r
   UefiDecompressLib\r
   PeCoffLoaderLib\r
   CacheMaintenanceLib\r
index 4f2d8bf9468f253e2affd12d427ba6d9c17539fb..e19e463513eed70dc316ba5b2d02847cd48d4e30 100644 (file)
@@ -79,7 +79,7 @@
   ReportStatusCodeLib|IntelFrameworkPkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf\r
   PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf\r
   PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf\r
-  SmBusLib|MdePkg/Library/PeiSmbusLibSmbus2Ppi/PeiSmbusLib.inf\r
+  SmBusLib|MdePkg/Library/PeiSmbusLibSmbus2Ppi/PeiSmbusLibSmbus2Ppi.inf\r
 \r
 [LibraryClasses.common.DXE_CORE]\r
   HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf\r
index cab55126f82424c0524494b5e5dae2292a2c8c14..3542bdd6465c9af93bd29b8e8b9f1a74c7f5a66c 100644 (file)
 \r
 #include <IndustryStandard\Pci.h>\r
 \r
-#define COMMON_TO_PCILIB_ADDRESS(A) (UINTN)PCI_LIB_ADDRESS( \\r
-       ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &A)->Bus, \\r
-       ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &A)->Device, \\r
-       ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &A)->Function, \\r
-       ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &A)->Register \\r
-       )\r
+/**\r
+   Convert EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS to PCI_LIB_ADDRESS.\r
 \r
+   @param Address   PCI address with\r
+                    EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS format.\r
+   \r
+   @return The PCI address with PCI_LIB_ADDRESS format.\r
+   \r
+**/\r
+STATIC\r
+UINTN\r
+PciCfgAddressConvert (\r
+  EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *Address\r
+  )\r
+{\r
+  if (Address->ExtendedRegister == 0) {\r
+    return PCI_LIB_ADDRESS (Address->Bus, Address->Device, Address->Function, Address->Register);\r
+  }\r
+\r
+  return PCI_LIB_ADDRESS (Address->Bus, Address->Device, Address->Function, Address->ExtendedRegister);\r
+}\r
 \r
 /**\r
   Reads from a given location in the PCI configuration space.\r
@@ -206,7 +220,7 @@ PciCfg2Read (
 {\r
   UINTN  PciLibAddress;\r
 \r
-  PciLibAddress = COMMON_TO_PCILIB_ADDRESS (Address);\r
+  PciLibAddress = PciCfgAddressConvert ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &Address);\r
 \r
   if (Width == EfiPeiPciCfgWidthUint8) {\r
     *((UINT8 *) Buffer) = PciRead8 (PciLibAddress);\r
@@ -257,7 +271,7 @@ PciCfg2Write (
 {\r
   UINTN  PciLibAddress;\r
 \r
-  PciLibAddress = COMMON_TO_PCILIB_ADDRESS (Address);\r
+  PciLibAddress = PciCfgAddressConvert ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &Address);\r
 \r
   if (Width == EfiPeiPciCfgWidthUint8) {\r
     PciWrite8 (PciLibAddress, *((UINT8 *) Buffer));\r
@@ -315,7 +329,7 @@ PciCfg2Modify (
 {\r
   UINTN  PciLibAddress;\r
 \r
-  PciLibAddress = COMMON_TO_PCILIB_ADDRESS (Address);\r
+  PciLibAddress = PciCfgAddressConvert ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &Address);\r
 \r
   if (Width == EfiPeiPciCfgWidthUint8) {\r
     PciAndThenOr8 (PciLibAddress, ~(*(UINT8 *)ClearBits), *((UINT8 *) SetBits));\r
diff --git a/MdePkg/Library/PeiSmbusLibSmbus2Ppi/PeiSmbusLib.inf b/MdePkg/Library/PeiSmbusLibSmbus2Ppi/PeiSmbusLib.inf
deleted file mode 100644 (file)
index 1e0a9f2..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#/** @file\r
-# Component description file for Pei Smbus Library.\r
-#\r
-# SMBUS library that layers on top of the SMBUS PPI.\r
-# Copyright (c) 2006 - 2007, Intel Corporation\r
-#\r
-#  All rights reserved. This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-#**/\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = PeiSmbusLibSmbus2Ppi\r
-  FILE_GUID                      = 2A1E1C92-AABA-4d62-AC40-F3A4C3387356\r
-  MODULE_TYPE                    = PEIM\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = SmbusLib|PEIM\r
-  EDK_RELEASE_VERSION            = 0x00020000\r
-  EFI_SPECIFICATION_VERSION      = 0x00020000\r
-\r
-\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources.common]\r
-  SmbusLib.c\r
-  PeiSmbusLib.c\r
-  InternalSmbusLib.h\r
-\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-\r
-\r
-[LibraryClasses]\r
-  BaseMemoryLib\r
-  PeiServicesTablePointerLib\r
-  DebugLib\r
-\r
-[Ppis]\r
-  gEfiPeiSmbus2PpiGuid                           # PPI ALWAYS_CONSUMED\r
-\r
-[Depex]\r
-  gEfiPeiSmbus2PpiGuid \r
diff --git a/MdePkg/Library/PeiSmbusLibSmbus2Ppi/PeiSmbusLibSmbus2Ppi.inf b/MdePkg/Library/PeiSmbusLibSmbus2Ppi/PeiSmbusLibSmbus2Ppi.inf
new file mode 100644 (file)
index 0000000..1e0a9f2
--- /dev/null
@@ -0,0 +1,51 @@
+#/** @file\r
+# Component description file for Pei Smbus Library.\r
+#\r
+# SMBUS library that layers on top of the SMBUS PPI.\r
+# Copyright (c) 2006 - 2007, Intel Corporation\r
+#\r
+#  All rights reserved. This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = PeiSmbusLibSmbus2Ppi\r
+  FILE_GUID                      = 2A1E1C92-AABA-4d62-AC40-F3A4C3387356\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = SmbusLib|PEIM\r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources.common]\r
+  SmbusLib.c\r
+  PeiSmbusLib.c\r
+  InternalSmbusLib.h\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+\r
+\r
+[LibraryClasses]\r
+  BaseMemoryLib\r
+  PeiServicesTablePointerLib\r
+  DebugLib\r
+\r
+[Ppis]\r
+  gEfiPeiSmbus2PpiGuid                           # PPI ALWAYS_CONSUMED\r
+\r
+[Depex]\r
+  gEfiPeiSmbus2PpiGuid \r
index eaa23f97ca1fab242f6776c612d03d9ebda08cca..5ece2f0e5a890d4fc98f8331e480b66d12fbcb72 100644 (file)
@@ -84,7 +84,7 @@
   MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf\r
   MdePkg/Library/PeiServicesLib/PeiServicesLib.inf\r
   MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf\r
-  MdePkg/Library/PeiSmbusLibSmbus2Ppi/PeiSmbusLib.inf\r
+  MdePkg/Library/PeiSmbusLibSmbus2Ppi/PeiSmbusLibSmbus2Ppi.inf\r
   MdePkg/Library/SerialPortLibNull/SerialPortLibNull.inf\r
   MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf\r
   MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf\r
index 5588c39ad04d43398a3f86fd55e6e8546d0c8021..b6d5bbc9eed6a30a3a17d318e1cfab414f2191c5 100644 (file)
   PeCoffLoaderLib|MdeModulePkg/Library/DxePeCoffLoaderFromHobLib/DxePeCoffLoaderFromHobLib.inf\r
   UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf\r
   DebugLib|IntelFrameworkPkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf\r
+  PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf\r
 \r
 \r
 [LibraryClasses.common.DXE_SMM_DRIVER]\r
   PcdReportStatusCodePropertyMask|gEfiMdePkgTokenSpaceGuid|0x0f\r
   PcdDebugPropertyMask|gEfiMdePkgTokenSpaceGuid|0x1f\r
   PcdDebugClearMemoryValue|gEfiMdePkgTokenSpaceGuid|0xAF\r
-  PcdDebugPrintErrorLevel|gEfiMdePkgTokenSpaceGuid|0x80000040\r
   PcdPerformanceLibraryPropertyMask|gEfiMdePkgTokenSpaceGuid|0\r
   PcdMaxPeiPcdCallBackNumberPerPcdEntry|gEfiMdeModulePkgTokenSpaceGuid|0x08\r
   PcdVpdBaseAddress|gEfiMdeModulePkgTokenSpaceGuid|0x0\r
   PcdFlashNvStorageFtwWorkingBase|gEfiMdeModulePkgTokenSpaceGuid|0\r
   PcdFlashNvStorageVariableBase|gEfiMdeModulePkgTokenSpaceGuid|0\r
 \r
+\r
+  PcdDebugPrintErrorLevel|gEfiMdePkgTokenSpaceGuid|0x80000040\r
 ################################################################################\r
 #\r
 # Components Section - list of all EDK II Modules needed by this Platform\r