--- /dev/null
+/** @file\r
+ Module produces PciCfgPpi2 on top of PciCfgPpi. It also updates the \r
+ PciCfg2Ppi pointer in the EFI_PEI_SERVICES upon a installation of\r
+ EcpPeiPciCfgPpi. \r
+\r
+ EcpPeiPciCfgPpi is installed by a framework module which\r
+ produce PciCfgPpi originally. Such framework module is updated based on the \r
+ following rule to install EcpPeiPciCfgPpi instead of updating the PciCfg pointer\r
+ in the Framework PeiServicesTable: \r
+ \r
+ Search pattern:\r
+ PeiServices->PciCfg = <*>;\r
+ Replace pattern:\r
+ {\r
+ static EFI_PEI_PPI_DESCRIPTOR gEcpPeiPciCfgPpiList = {\r
+ (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+ &gEcpPeiPciCfgPpiGuid,\r
+ <*>\r
+ };\r
+ (**PeiServices).InstallPpi (PeiServices, gEcpPeiPciCfgPpiList);\r
+ }\r
+ \r
+ In addition, the PeiServicesTable definition in PeiApi.h is updated to\r
+ \r
+ struct _EFI_PEI_SERVICES {\r
+ EFI_TABLE_HEADER Hdr;\r
+ ...\r
+ \r
+ //\r
+ // Pointer to PPI interface\r
+ //\r
+ if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+ \r
+ PEI_CPU_IO_PPI *CpuIo;\r
+ ECP_PEI_PCI_CFG_PPI *PciCfg; //Changed.\r
+ else\r
+ ...\r
+ endif\r
+ \r
+ };\r
+ \r
+ This change enable the detection of code segment which invokes PeiServices->PciCfg->Modify.\r
+ Such code causes a build break as ECP_PEI_PCI_CFG_PPI does not has "Modify" field. \r
+ This should be updated to a call to PeiLibPciCfgModify as shown below:\r
+ \r
+ Search pattern:\r
+ *->Modify(<*>); \r
+ Replace pattern:\r
+ PeiLibPciCfgModify(<*>);\r
+\r
+\r
+\r
+PIWG's PI specification replaces Inte's EFI Specification 1.10.\r
+EFI_PEI_PCI_CFG_PPI defined in Inte's EFI Specification 1.10 is replaced by\r
+EFI_PEI_PCI_CFG2_PPI in PI 1.0.\r
+This module produces PciCfgPpi on top of PciCfgPpi2. This module is used on platform when both of\r
+these two conditions are true:\r
+1) Framework module present that produces PCI CFG PPI AND\r
+2) PI module that produces PCI CFG2 is not present\r
+\r
+Copyright (c) 2006 - 2008 Intel Corporation. <BR>\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
+\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
+#include <PiPei.h>\r
+#include <Ppi/PciCfg.h>\r
+#include <Ppi/PciCfg2.h>\r
+#include <Ppi/EcpPciCfg.h>\r
+#include <Library/DebugLib.h>\r
+\r
+//\r
+// Function Prototypes \r
+//\r
+\r
+/**\r
+ Notification service to be called when gEcpPeiPciCfgPpiGuid is installed.\r
+\r
+ @param PeiServices Indirect reference to the PEI Services Table.\r
+ @param NotifyDescriptor Address of the notification descriptor data structure. Type\r
+ EFI_PEI_NOTIFY_DESCRIPTOR is defined above.\r
+ @param Ppi Address of the PPI that was installed.\r
+\r
+ @retval EFI_STATUS This function will install a PPI to PPI database. The status\r
+ code will be the code for (*PeiServices)->InstallPpi.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EcpPciCfgPpiNotifyCallback (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
+ IN VOID *Ppi\r
+ );\r
+\r
+//\r
+// Function Prototypes\r
+//\r
+/**\r
+ Reads from a given location in the PCI configuration space.\r
+\r
+ @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
+\r
+ @param This Pointer to local data for the interface.\r
+\r
+ @param Width The width of the access. Enumerated in bytes.\r
+ See EFI_PEI_PCI_CFG_PPI_WIDTH above.\r
+\r
+ @param Address The physical address of the access. The format of\r
+ the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.\r
+\r
+ @param Buffer A pointer to the buffer of data..\r
+\r
+\r
+ @retval EFI_SUCCESS The function completed successfully.\r
+\r
+ @retval EFI_DEVICE_ERROR There was a problem with the transaction.\r
+\r
+ @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this\r
+ time.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PciCfg2Read (\r
+ IN CONST EFI_PEI_SERVICES **PeiServices,\r
+ IN CONST EFI_PEI_PCI_CFG2_PPI *This,\r
+ IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
+ IN UINT64 Address,\r
+ IN OUT VOID *Buffer\r
+ );\r
+\r
+/**\r
+ Write to a given location in the PCI configuration space.\r
+\r
+ @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
+\r
+ @param This Pointer to local data for the interface.\r
+\r
+ @param Width The width of the access. Enumerated in bytes.\r
+ See EFI_PEI_PCI_CFG_PPI_WIDTH above.\r
+\r
+ @param Address The physical address of the access. The format of\r
+ the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.\r
+\r
+ @param Buffer A pointer to the buffer of data..\r
+\r
+\r
+ @retval EFI_SUCCESS The function completed successfully.\r
+\r
+ @retval EFI_DEVICE_ERROR There was a problem with the transaction.\r
+\r
+ @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this\r
+ time.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PciCfg2Write (\r
+ IN CONST EFI_PEI_SERVICES **PeiServices,\r
+ IN CONST EFI_PEI_PCI_CFG2_PPI *This,\r
+ IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
+ IN UINT64 Address,\r
+ IN OUT VOID *Buffer\r
+ );\r
+\r
+/**\r
+ PCI read-modify-write operation.\r
+\r
+ @param PeiServices An indirect pointer to the PEI Services Table\r
+ published by the PEI Foundation.\r
+\r
+ @param This Pointer to local data for the interface.\r
+\r
+ @param Width The width of the access. Enumerated in bytes. Type\r
+ EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().\r
+\r
+ @param Address The physical address of the access.\r
+\r
+ @param SetBits Points to value to bitwise-OR with the read configuration value.\r
+ The size of the value is determined by Width.\r
+\r
+ @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value.\r
+ The size of the value is determined by Width.\r
+\r
+\r
+ @retval EFI_SUCCESS The function completed successfully.\r
+\r
+ @retval EFI_DEVICE_ERROR There was a problem with the transaction.\r
+\r
+ @retval EFI_DEVICE_NOT_READY The device is not capable of supporting\r
+ the operation at this time.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PciCfg2Modify (\r
+ IN CONST EFI_PEI_SERVICES **PeiServices,\r
+ IN CONST EFI_PEI_PCI_CFG2_PPI *This,\r
+ IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
+ IN UINT64 Address,\r
+ IN VOID *SetBits,\r
+ IN VOID *ClearBits\r
+ );\r
+\r
+//\r
+// Module globals\r
+//\r
+EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnEcpPciCfgList = {\r
+ (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+ &gEcpPeiPciCfgPpiGuid,\r
+ EcpPciCfgPpiNotifyCallback \r
+};\r
+\r
+EFI_PEI_PCI_CFG2_PPI mPciCfg2Ppi = {\r
+ PciCfg2Read,\r
+ PciCfg2Write,\r
+ PciCfg2Modify,\r
+ 0\r
+};\r
+\r
+EFI_PEI_PPI_DESCRIPTOR mPpiListPciCfg2 = {\r
+ (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+ &gEfiPciCfg2PpiGuid,\r
+ &mPciCfg2Ppi\r
+};\r
+\r
+\r
+/**\r
+\r
+ Standard PEIM entry point.\r
+\r
+ @param FfsHeadher The FFS file header\r
+ @param PeiServices General purpose services available to every PEIM.\r
+\r
+\r
+ @retval EFI_SUCCESS if the interface could be successfully\r
+ installed\r
+\r
+--*/\r
+EFI_STATUS\r
+EFIAPI\r
+PeimInitializePciCfg2 (\r
+ IN EFI_PEI_FILE_HANDLE FfsHeader,\r
+ IN CONST EFI_PEI_SERVICES **PeiServices\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ VOID *Ppi;\r
+\r
+ //\r
+ // Make sure no other module has install the first instance of gEfiPciCfg2PpiGuid.\r
+ //\r
+ Status = (*PeiServices)->LocatePpi (PeiServices, &gEfiPciCfg2PpiGuid, 0, NULL, &Ppi);\r
+ ASSERT (Status == EFI_NOT_FOUND);\r
+\r
+ //\r
+ // Register a notification for ECP PCI CFG PPI\r
+ //\r
+ Status = (*PeiServices)->NotifyPpi (PeiServices, &mNotifyOnEcpPciCfgList);\r
+ ASSERT_EFI_ERROR (Status);\r
+ return Status;\r
+}\r
+\r
+\r
+/**\r
+ Notification service to be called when gEcpPeiPciCfgPpiGuid is installed.\r
+\r
+ @param PeiServices Indirect reference to the PEI Services Table.\r
+ @param NotifyDescriptor Address of the notification descriptor data structure. Type\r
+ EFI_PEI_NOTIFY_DESCRIPTOR is defined above.\r
+ @param Ppi Address of the PPI that was installed.\r
+\r
+ @retval EFI_STATUS This function will install a PPI to PPI database. The status\r
+ code will be the code for (*PeiServices)->InstallPpi.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EcpPciCfgPpiNotifyCallback (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
+ IN VOID *Ppi\r
+ )\r
+{\r
+ //\r
+ // When ECP PCI CFG PPI is installed, publish the PCI CFG2 PPI in the \r
+ // PEI Services Table and the PPI database\r
+ //\r
+ (*PeiServices)->PciCfg = &mPciCfg2Ppi;\r
+ return (*PeiServices)->InstallPpi ((CONST EFI_PEI_SERVICES **)PeiServices, &mPpiListPciCfg2);\r
+}\r
+\r
+/**\r
+ Reads from a given location in the PCI configuration space.\r
+\r
+ @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
+\r
+ @param This Pointer to local data for the interface.\r
+\r
+ @param Width The width of the access. Enumerated in bytes.\r
+ See EFI_PEI_PCI_CFG_PPI_WIDTH above.\r
+\r
+ @param Address The physical address of the access. The format of\r
+ the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.\r
+\r
+ @param Buffer A pointer to the buffer of data..\r
+\r
+\r
+ @retval EFI_SUCCESS The function completed successfully.\r
+\r
+ @retval EFI_DEVICE_ERROR There was a problem with the transaction.\r
+\r
+ @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this\r
+ time.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PciCfg2Read (\r
+ IN CONST EFI_PEI_SERVICES **PeiServices,\r
+ IN CONST EFI_PEI_PCI_CFG2_PPI *This,\r
+ IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
+ IN UINT64 Address,\r
+ IN OUT VOID *Buffer\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_PEI_PCI_CFG_PPI *PciCfg;\r
+\r
+ Status = (*PeiServices)->LocatePpi (\r
+ PeiServices,\r
+ &gEcpPeiPciCfgPpiGuid,\r
+ 0,\r
+ NULL,\r
+ (VOID **)&PciCfg\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return PciCfg->Read ((EFI_PEI_SERVICES **)PeiServices, PciCfg, Width, Address, Buffer);\r
+}\r
+\r
+/**\r
+ Write to a given location in the PCI configuration space.\r
+\r
+ @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
+\r
+ @param This Pointer to local data for the interface.\r
+\r
+ @param Width The width of the access. Enumerated in bytes.\r
+ See EFI_PEI_PCI_CFG_PPI_WIDTH above.\r
+\r
+ @param Address The physical address of the access. The format of\r
+ the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.\r
+\r
+ @param Buffer A pointer to the buffer of data..\r
+\r
+\r
+ @retval EFI_SUCCESS The function completed successfully.\r
+\r
+ @retval EFI_DEVICE_ERROR There was a problem with the transaction.\r
+\r
+ @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this\r
+ time.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PciCfg2Write (\r
+ IN CONST EFI_PEI_SERVICES **PeiServices,\r
+ IN CONST EFI_PEI_PCI_CFG2_PPI *This,\r
+ IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
+ IN UINT64 Address,\r
+ IN OUT VOID *Buffer\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_PEI_PCI_CFG_PPI *PciCfg;\r
+\r
+ Status = (*PeiServices)->LocatePpi (\r
+ PeiServices,\r
+ &gEcpPeiPciCfgPpiGuid,\r
+ 0,\r
+ NULL,\r
+ (VOID **)&PciCfg\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return PciCfg->Write ((EFI_PEI_SERVICES **)PeiServices, PciCfg, Width, Address, Buffer);\r
+}\r
+\r
+/**\r
+ PCI read-modify-write operation.\r
+\r
+ @param PeiServices An indirect pointer to the PEI Services Table\r
+ published by the PEI Foundation.\r
+\r
+ @param This Pointer to local data for the interface.\r
+\r
+ @param Width The width of the access. Enumerated in bytes. Type\r
+ EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().\r
+\r
+ @param Address The physical address of the access.\r
+\r
+ @param SetBits Points to value to bitwise-OR with the read configuration value.\r
+ The size of the value is determined by Width.\r
+\r
+ @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value.\r
+ The size of the value is determined by Width.\r
+\r
+\r
+ @retval EFI_SUCCESS The function completed successfully.\r
+\r
+ @retval EFI_DEVICE_ERROR There was a problem with the transaction.\r
+\r
+ @retval EFI_DEVICE_NOT_READY The device is not capable of supporting\r
+ the operation at this time.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PciCfg2Modify (\r
+ IN CONST EFI_PEI_SERVICES **PeiServices,\r
+ IN CONST EFI_PEI_PCI_CFG2_PPI *This,\r
+ IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
+ IN UINT64 Address,\r
+ IN VOID *SetBits,\r
+ IN VOID *ClearBits\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_PEI_PCI_CFG_PPI *PciCfg;\r
+\r
+ Status = (*PeiServices)->LocatePpi (\r
+ PeiServices,\r
+ &gEfiPciCfgPpiInServiceTableGuid,\r
+ 0,\r
+ NULL,\r
+ (VOID **)&PciCfg\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return PciCfg->Modify ((EFI_PEI_SERVICES **)PeiServices, PciCfg, Width, Address, *(UINTN *)SetBits, *(UINTN *)ClearBits);\r
+}\r
--- /dev/null
+#/** @file\r
+# Module produces PciCfgPpi2 on top of PciCfgPpi. It also updates the \r
+# PciCfg2Ppi pointer in the EFI_PEI_SERVICES upon a installation of\r
+# EcpPeiPciCfgPpi. \r
+#\r
+# EcpPeiPciCfgPpi is installed by a framework module which\r
+# produce PciCfgPpi originally. Such framework module is updated based on the \r
+# following rule to install EcpPeiPciCfgPpi instead of updating the PciCfg pointer\r
+# in the Framework PeiServicesTable: \r
+# \r
+# Search pattern:\r
+# PeiServices->PciCfg = <*>;\r
+# Replace pattern:\r
+# {\r
+# static EFI_PEI_PPI_DESCRIPTOR gEcpPeiPciCfgPpiList = {\r
+# (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+# &gEcpPeiPciCfgPpiGuid,\r
+# <*>\r
+# };\r
+# (**PeiServices).InstallPpi (PeiServices, &gEcpPeiPciCfgPpiList);\r
+# }\r
+# \r
+# In addition, the PeiServicesTable definition in PeiApi.h is updated to\r
+# \r
+# struct _EFI_PEI_SERVICES {\r
+# EFI_TABLE_HEADER Hdr;\r
+# ...\r
+# \r
+# //\r
+# // Pointer to PPI interface\r
+# //\r
+# #if (PI_SPECIFICATION_VERSION < 0x00010000)\r
+# \r
+# PEI_CPU_IO_PPI *CpuIo;\r
+# ECP_PEI_PCI_CFG_PPI *PciCfg; //Changed.\r
+# #else\r
+# ...\r
+# #endif\r
+# \r
+# };\r
+# \r
+# This change enable the detection of code segment which invokes PeiServices->PciCfg->Modify.\r
+# Such code causes a build break as ECP_PEI_PCI_CFG_PPI does not has "Modify" field. \r
+# This should be updated to a call to PeiLibPciCfgModify as shown below:\r
+# \r
+# Search pattern:\r
+# *->Modify(<*>); \r
+# Replace pattern:\r
+# PeiLibPciCfgModify(<*>);\r
+#\r
+# PIWG's PI specification replaces Inte's EFI Specification 1.10.\r
+# EFI_PEI_PCI_CFG_PPI defined in Inte's EFI Specification 1.10 is replaced by\r
+# EFI_PEI_PCI_CFG2_PPI in PI 1.0.\r
+# This module produces PciCfgPpi on top of PciCfgPpi2. This module is used on platform when both of\r
+# these two conditions are true:\r
+# 1) Framework module present that produces PCI CFG PPI AND\r
+# 2) PI module that produces PCI CFG2 is not present\r
+\r
+#\r
+# PEIM to provide the Variable functionality.\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 = PciCfg2OnPciCfgThunk\r
+ FILE_GUID = 41401688-2862-431b-BAAC-6ECADAC384AB\r
+ MODULE_TYPE = PEIM\r
+ VERSION_STRING = 1.0\r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+\r
+ ENTRY_POINT = PeimInitializePciCfg2\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources.common]\r
+ PciCfg2OnPciCfgThunk.c\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ IntelFrameworkPkg/IntelFrameworkPkg.dec\r
+ EdkCompatibilityPkg/EdkCompatibilityPkg.dec\r
+\r
+[LibraryClasses]\r
+ PeimEntryPoint\r
+ DebugLib\r
+\r
+[Ppis]\r
+ gEfiPciCfgPpiInServiceTableGuid\r
+ gEfiPciCfg2PpiGuid\r
+ gEcpPeiPciCfgPpiGuid\r
+\r
+[Depex]\r
+ TRUE\r
+++ /dev/null
-/** @file\r
- Module produces PciCfgPpi2 on top of PciCfgPpi. It also updates the \r
- PciCfg2Ppi pointer in the EFI_PEI_SERVICES upon a installation of\r
- EcpPeiPciCfgPpi. \r
-\r
- EcpPeiPciCfgPpi is installed by a framework module which\r
- produce PciCfgPpi originally. Such framework module is updated based on the \r
- following rule to install EcpPeiPciCfgPpi instead of updating the PciCfg pointer\r
- in the Framework PeiServicesTable: \r
- \r
- Search pattern:\r
- PeiServices->PciCfg = <*>;\r
- Replace pattern:\r
- {\r
- static EFI_PEI_PPI_DESCRIPTOR gEcpPeiPciCfgPpiList = {\r
- (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
- &gEcpPeiPciCfgPpiGuid,\r
- <*>\r
- };\r
- (**PeiServices).InstallPpi (PeiServices, gEcpPeiPciCfgPpiList);\r
- }\r
- \r
- In addition, the PeiServicesTable definition in PeiApi.h is updated to\r
- \r
- struct _EFI_PEI_SERVICES {\r
- EFI_TABLE_HEADER Hdr;\r
- ...\r
- \r
- //\r
- // Pointer to PPI interface\r
- //\r
- if (PI_SPECIFICATION_VERSION < 0x00010000)\r
- \r
- PEI_CPU_IO_PPI *CpuIo;\r
- ECP_PEI_PCI_CFG_PPI *PciCfg; //Changed.\r
- else\r
- ...\r
- endif\r
- \r
- };\r
- \r
- This change enable the detection of code segment which invokes PeiServices->PciCfg->Modify.\r
- Such code causes a build break as ECP_PEI_PCI_CFG_PPI does not has "Modify" field. \r
- This should be updated to a call to PeiLibPciCfgModify as shown below:\r
- \r
- Search pattern:\r
- *->Modify(<*>); \r
- Replace pattern:\r
- PeiLibPciCfgModify(<*>);\r
-\r
-\r
-\r
-PIWG's PI specification replaces Inte's EFI Specification 1.10.\r
-EFI_PEI_PCI_CFG_PPI defined in Inte's EFI Specification 1.10 is replaced by\r
-EFI_PEI_PCI_CFG2_PPI in PI 1.0.\r
-This module produces PciCfgPpi on top of PciCfgPpi2. This module is used on platform when both of\r
-these two conditions are true:\r
-1) Framework module present that produces PCI CFG PPI AND\r
-2) PI module that produces PCI CFG2 is not present\r
-\r
-Copyright (c) 2006 - 2008 Intel Corporation. <BR>\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
-\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
-#include <PiPei.h>\r
-#include <Ppi/PciCfg.h>\r
-#include <Ppi/PciCfg2.h>\r
-#include <Ppi/EcpPciCfg.h>\r
-#include <Library/DebugLib.h>\r
-\r
-//\r
-// Function Prototypes \r
-//\r
-\r
-/**\r
- Notification service to be called when gEcpPeiPciCfgPpiGuid is installed.\r
-\r
- @param PeiServices Indirect reference to the PEI Services Table.\r
- @param NotifyDescriptor Address of the notification descriptor data structure. Type\r
- EFI_PEI_NOTIFY_DESCRIPTOR is defined above.\r
- @param Ppi Address of the PPI that was installed.\r
-\r
- @retval EFI_STATUS This function will install a PPI to PPI database. The status\r
- code will be the code for (*PeiServices)->InstallPpi.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EcpPciCfgPpiNotifyCallback (\r
- IN EFI_PEI_SERVICES **PeiServices,\r
- IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
- IN VOID *Ppi\r
- );\r
-\r
-//\r
-// Function Prototypes\r
-//\r
-/**\r
- Reads from a given location in the PCI configuration space.\r
-\r
- @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
-\r
- @param This Pointer to local data for the interface.\r
-\r
- @param Width The width of the access. Enumerated in bytes.\r
- See EFI_PEI_PCI_CFG_PPI_WIDTH above.\r
-\r
- @param Address The physical address of the access. The format of\r
- the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.\r
-\r
- @param Buffer A pointer to the buffer of data..\r
-\r
-\r
- @retval EFI_SUCCESS The function completed successfully.\r
-\r
- @retval EFI_DEVICE_ERROR There was a problem with the transaction.\r
-\r
- @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this\r
- time.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PciCfg2Read (\r
- IN CONST EFI_PEI_SERVICES **PeiServices,\r
- IN CONST EFI_PEI_PCI_CFG2_PPI *This,\r
- IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
- IN UINT64 Address,\r
- IN OUT VOID *Buffer\r
- );\r
-\r
-/**\r
- Write to a given location in the PCI configuration space.\r
-\r
- @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
-\r
- @param This Pointer to local data for the interface.\r
-\r
- @param Width The width of the access. Enumerated in bytes.\r
- See EFI_PEI_PCI_CFG_PPI_WIDTH above.\r
-\r
- @param Address The physical address of the access. The format of\r
- the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.\r
-\r
- @param Buffer A pointer to the buffer of data..\r
-\r
-\r
- @retval EFI_SUCCESS The function completed successfully.\r
-\r
- @retval EFI_DEVICE_ERROR There was a problem with the transaction.\r
-\r
- @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this\r
- time.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PciCfg2Write (\r
- IN CONST EFI_PEI_SERVICES **PeiServices,\r
- IN CONST EFI_PEI_PCI_CFG2_PPI *This,\r
- IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
- IN UINT64 Address,\r
- IN OUT VOID *Buffer\r
- );\r
-\r
-/**\r
- PCI read-modify-write operation.\r
-\r
- @param PeiServices An indirect pointer to the PEI Services Table\r
- published by the PEI Foundation.\r
-\r
- @param This Pointer to local data for the interface.\r
-\r
- @param Width The width of the access. Enumerated in bytes. Type\r
- EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().\r
-\r
- @param Address The physical address of the access.\r
-\r
- @param SetBits Points to value to bitwise-OR with the read configuration value.\r
- The size of the value is determined by Width.\r
-\r
- @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value.\r
- The size of the value is determined by Width.\r
-\r
-\r
- @retval EFI_SUCCESS The function completed successfully.\r
-\r
- @retval EFI_DEVICE_ERROR There was a problem with the transaction.\r
-\r
- @retval EFI_DEVICE_NOT_READY The device is not capable of supporting\r
- the operation at this time.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PciCfg2Modify (\r
- IN CONST EFI_PEI_SERVICES **PeiServices,\r
- IN CONST EFI_PEI_PCI_CFG2_PPI *This,\r
- IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
- IN UINT64 Address,\r
- IN VOID *SetBits,\r
- IN VOID *ClearBits\r
- );\r
-\r
-//\r
-// Module globals\r
-//\r
-EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnEcpPciCfgList = {\r
- (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
- &gEcpPeiPciCfgPpiGuid,\r
- EcpPciCfgPpiNotifyCallback \r
-};\r
-\r
-EFI_PEI_PCI_CFG2_PPI mPciCfg2Ppi = {\r
- PciCfg2Read,\r
- PciCfg2Write,\r
- PciCfg2Modify,\r
- 0\r
-};\r
-\r
-EFI_PEI_PPI_DESCRIPTOR mPpiListPciCfg2 = {\r
- (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
- &gEfiPciCfg2PpiGuid,\r
- &mPciCfg2Ppi\r
-};\r
-\r
-\r
-/**\r
-\r
- Standard PEIM entry point.\r
-\r
- @param FfsHeadher The FFS file header\r
- @param PeiServices General purpose services available to every PEIM.\r
-\r
-\r
- @retval EFI_SUCCESS if the interface could be successfully\r
- installed\r
-\r
---*/\r
-EFI_STATUS\r
-EFIAPI\r
-PeimInitializePciCfg2 (\r
- IN EFI_PEI_FILE_HANDLE FfsHeader,\r
- IN CONST EFI_PEI_SERVICES **PeiServices\r
- )\r
-{\r
- EFI_STATUS Status;\r
- VOID *Ppi;\r
-\r
- //\r
- // Make sure no other module has install the first instance of gEfiPciCfg2PpiGuid.\r
- //\r
- Status = (*PeiServices)->LocatePpi (PeiServices, &gEfiPciCfg2PpiGuid, 0, NULL, &Ppi);\r
- ASSERT (Status == EFI_NOT_FOUND);\r
-\r
- //\r
- // Register a notification for ECP PCI CFG PPI\r
- //\r
- Status = (*PeiServices)->NotifyPpi (PeiServices, &mNotifyOnEcpPciCfgList);\r
- ASSERT_EFI_ERROR (Status);\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- Notification service to be called when gEcpPeiPciCfgPpiGuid is installed.\r
-\r
- @param PeiServices Indirect reference to the PEI Services Table.\r
- @param NotifyDescriptor Address of the notification descriptor data structure. Type\r
- EFI_PEI_NOTIFY_DESCRIPTOR is defined above.\r
- @param Ppi Address of the PPI that was installed.\r
-\r
- @retval EFI_STATUS This function will install a PPI to PPI database. The status\r
- code will be the code for (*PeiServices)->InstallPpi.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EcpPciCfgPpiNotifyCallback (\r
- IN EFI_PEI_SERVICES **PeiServices,\r
- IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
- IN VOID *Ppi\r
- )\r
-{\r
- //\r
- // When ECP PCI CFG PPI is installed, publish the PCI CFG2 PPI in the \r
- // PEI Services Table and the PPI database\r
- //\r
- (*PeiServices)->PciCfg = &mPciCfg2Ppi;\r
- return (*PeiServices)->InstallPpi ((CONST EFI_PEI_SERVICES **)PeiServices, &mPpiListPciCfg2);\r
-}\r
-\r
-/**\r
- Reads from a given location in the PCI configuration space.\r
-\r
- @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
-\r
- @param This Pointer to local data for the interface.\r
-\r
- @param Width The width of the access. Enumerated in bytes.\r
- See EFI_PEI_PCI_CFG_PPI_WIDTH above.\r
-\r
- @param Address The physical address of the access. The format of\r
- the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.\r
-\r
- @param Buffer A pointer to the buffer of data..\r
-\r
-\r
- @retval EFI_SUCCESS The function completed successfully.\r
-\r
- @retval EFI_DEVICE_ERROR There was a problem with the transaction.\r
-\r
- @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this\r
- time.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PciCfg2Read (\r
- IN CONST EFI_PEI_SERVICES **PeiServices,\r
- IN CONST EFI_PEI_PCI_CFG2_PPI *This,\r
- IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
- IN UINT64 Address,\r
- IN OUT VOID *Buffer\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_PEI_PCI_CFG_PPI *PciCfg;\r
-\r
- Status = (*PeiServices)->LocatePpi (\r
- PeiServices,\r
- &gEcpPeiPciCfgPpiGuid,\r
- 0,\r
- NULL,\r
- (VOID **)&PciCfg\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- return PciCfg->Read ((EFI_PEI_SERVICES **)PeiServices, PciCfg, Width, Address, Buffer);\r
-}\r
-\r
-/**\r
- Write to a given location in the PCI configuration space.\r
-\r
- @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
-\r
- @param This Pointer to local data for the interface.\r
-\r
- @param Width The width of the access. Enumerated in bytes.\r
- See EFI_PEI_PCI_CFG_PPI_WIDTH above.\r
-\r
- @param Address The physical address of the access. The format of\r
- the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.\r
-\r
- @param Buffer A pointer to the buffer of data..\r
-\r
-\r
- @retval EFI_SUCCESS The function completed successfully.\r
-\r
- @retval EFI_DEVICE_ERROR There was a problem with the transaction.\r
-\r
- @retval EFI_DEVICE_NOT_READY The device is not capable of supporting the operation at this\r
- time.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PciCfg2Write (\r
- IN CONST EFI_PEI_SERVICES **PeiServices,\r
- IN CONST EFI_PEI_PCI_CFG2_PPI *This,\r
- IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
- IN UINT64 Address,\r
- IN OUT VOID *Buffer\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_PEI_PCI_CFG_PPI *PciCfg;\r
-\r
- Status = (*PeiServices)->LocatePpi (\r
- PeiServices,\r
- &gEcpPeiPciCfgPpiGuid,\r
- 0,\r
- NULL,\r
- (VOID **)&PciCfg\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- return PciCfg->Write ((EFI_PEI_SERVICES **)PeiServices, PciCfg, Width, Address, Buffer);\r
-}\r
-\r
-/**\r
- PCI read-modify-write operation.\r
-\r
- @param PeiServices An indirect pointer to the PEI Services Table\r
- published by the PEI Foundation.\r
-\r
- @param This Pointer to local data for the interface.\r
-\r
- @param Width The width of the access. Enumerated in bytes. Type\r
- EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().\r
-\r
- @param Address The physical address of the access.\r
-\r
- @param SetBits Points to value to bitwise-OR with the read configuration value.\r
- The size of the value is determined by Width.\r
-\r
- @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value.\r
- The size of the value is determined by Width.\r
-\r
-\r
- @retval EFI_SUCCESS The function completed successfully.\r
-\r
- @retval EFI_DEVICE_ERROR There was a problem with the transaction.\r
-\r
- @retval EFI_DEVICE_NOT_READY The device is not capable of supporting\r
- the operation at this time.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PciCfg2Modify (\r
- IN CONST EFI_PEI_SERVICES **PeiServices,\r
- IN CONST EFI_PEI_PCI_CFG2_PPI *This,\r
- IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
- IN UINT64 Address,\r
- IN VOID *SetBits,\r
- IN VOID *ClearBits\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_PEI_PCI_CFG_PPI *PciCfg;\r
-\r
- Status = (*PeiServices)->LocatePpi (\r
- PeiServices,\r
- &gEfiPciCfgPpiInServiceTableGuid,\r
- 0,\r
- NULL,\r
- (VOID **)&PciCfg\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- return PciCfg->Modify ((EFI_PEI_SERVICES **)PeiServices, PciCfg, Width, Address, *(UINTN *)SetBits, *(UINTN *)ClearBits);\r
-}\r
+++ /dev/null
-#/** @file\r
-# Module produces PciCfgPpi2 on top of PciCfgPpi. It also updates the \r
-# PciCfg2Ppi pointer in the EFI_PEI_SERVICES upon a installation of\r
-# EcpPeiPciCfgPpi. \r
-#\r
-# EcpPeiPciCfgPpi is installed by a framework module which\r
-# produce PciCfgPpi originally. Such framework module is updated based on the \r
-# following rule to install EcpPeiPciCfgPpi instead of updating the PciCfg pointer\r
-# in the Framework PeiServicesTable: \r
-# \r
-# Search pattern:\r
-# PeiServices->PciCfg = <*>;\r
-# Replace pattern:\r
-# {\r
-# static EFI_PEI_PPI_DESCRIPTOR gEcpPeiPciCfgPpiList = {\r
-# (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
-# &gEcpPeiPciCfgPpiGuid,\r
-# <*>\r
-# };\r
-# (**PeiServices).InstallPpi (PeiServices, &gEcpPeiPciCfgPpiList);\r
-# }\r
-# \r
-# In addition, the PeiServicesTable definition in PeiApi.h is updated to\r
-# \r
-# struct _EFI_PEI_SERVICES {\r
-# EFI_TABLE_HEADER Hdr;\r
-# ...\r
-# \r
-# //\r
-# // Pointer to PPI interface\r
-# //\r
-# #if (PI_SPECIFICATION_VERSION < 0x00010000)\r
-# \r
-# PEI_CPU_IO_PPI *CpuIo;\r
-# ECP_PEI_PCI_CFG_PPI *PciCfg; //Changed.\r
-# #else\r
-# ...\r
-# #endif\r
-# \r
-# };\r
-# \r
-# This change enable the detection of code segment which invokes PeiServices->PciCfg->Modify.\r
-# Such code causes a build break as ECP_PEI_PCI_CFG_PPI does not has "Modify" field. \r
-# This should be updated to a call to PeiLibPciCfgModify as shown below:\r
-# \r
-# Search pattern:\r
-# *->Modify(<*>); \r
-# Replace pattern:\r
-# PeiLibPciCfgModify(<*>);\r
-#\r
-# PIWG's PI specification replaces Inte's EFI Specification 1.10.\r
-# EFI_PEI_PCI_CFG_PPI defined in Inte's EFI Specification 1.10 is replaced by\r
-# EFI_PEI_PCI_CFG2_PPI in PI 1.0.\r
-# This module produces PciCfgPpi on top of PciCfgPpi2. This module is used on platform when both of\r
-# these two conditions are true:\r
-# 1) Framework module present that produces PCI CFG PPI AND\r
-# 2) PI module that produces PCI CFG2 is not present\r
-\r
-#\r
-# PEIM to provide the Variable functionality.\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 = PciCfg2OnPciCfgThunk\r
- FILE_GUID = 41401688-2862-431b-BAAC-6ECADAC384AB\r
- MODULE_TYPE = PEIM\r
- VERSION_STRING = 1.0\r
- EDK_RELEASE_VERSION = 0x00020000\r
- EFI_SPECIFICATION_VERSION = 0x00020000\r
-\r
- ENTRY_POINT = PeimInitializePciCfg2\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources.common]\r
- PciCfg2OnPciCfgThunk.c\r
-\r
-[Packages]\r
- MdePkg/MdePkg.dec\r
- IntelFrameworkPkg/IntelFrameworkPkg.dec\r
- EdkCompatibilityPkg/EdkCompatibilityPkg.dec\r
-\r
-[LibraryClasses]\r
- PeimEntryPoint\r
- DebugLib\r
-\r
-[Ppis]\r
- gEfiPciCfgPpiInServiceTableGuid\r
- gEfiPciCfg2PpiGuid\r
- gEcpPeiPciCfgPpiGuid\r
-\r
-[Depex]\r
- TRUE\r