From 1e55f6a46baee8540ecef845593eb41201cb7c7a Mon Sep 17 00:00:00 2001 From: qwang12 Date: Wed, 21 May 2008 07:21:30 +0000 Subject: [PATCH] 1) Change Framework version of PeiServiceTable's PciCfg from PEI_PCI_CFG_PPI to ECP_PEI_PCI_CFG_PPI. This help to detect if user is calling PeiServiceTable->PciCfg->Modify in a PI platform. Modify between Framework spec and PI spec is not compatible. 2) Add ECP_PEI_PCI_CFG_PPI to EdkFrameworkPpiLib 3) Add PeiLibPciCfgModify which call PciCfg2. This function will used by modified Framework Module which will be working with a PI platform. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5260 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Foundation/Framework/Include/PeiApi.h | 5 + .../Framework/Ppi/EcpPciCfg/EcpPciCfg.c | 28 ++++++ .../Framework/Ppi/EcpPciCfg/EcpPciCfg.h | 50 ++++++++++ .../Framework/Ppi/EdkFrameworkPpiLib.inf | 3 + .../Foundation/Library/Pei/Include/PeiLib.h | 71 ++++++++++++++ .../Foundation/Library/Pei/PeiLib/PeiLib.c | 93 +++++++++++++++++++ 6 files changed, 250 insertions(+) create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/EcpPciCfg/EcpPciCfg.c create mode 100644 EdkCompatibilityPkg/Foundation/Framework/Ppi/EcpPciCfg/EcpPciCfg.h diff --git a/EdkCompatibilityPkg/Foundation/Framework/Include/PeiApi.h b/EdkCompatibilityPkg/Foundation/Framework/Include/PeiApi.h index 674855640f..dde93c3204 100644 --- a/EdkCompatibilityPkg/Foundation/Framework/Include/PeiApi.h +++ b/EdkCompatibilityPkg/Foundation/Framework/Include/PeiApi.h @@ -43,6 +43,7 @@ EFI_FORWARD_DECLARATION (EFI_PEI_SERVICES); #include EFI_PPI_DEFINITION (CpuIo) #include EFI_PPI_DEFINITION (PciCfg) #include EFI_PPI_DEFINITION (PciCfg2) +#include EFI_PPI_DEFINITION (EcpPciCfg) // // PEI Specification Revision information @@ -546,7 +547,11 @@ struct _EFI_PEI_SERVICES { #if (PI_SPECIFICATION_VERSION < 0x00010000) PEI_CPU_IO_PPI *CpuIo; +#if defined (SUPPORT_DEPRECATED_PCI_CFG_PPI) PEI_PCI_CFG_PPI *PciCfg; +#else + ECP_PEI_PCI_CFG_PPI *PciCfg; +#endif #else EFI_PEI_CPU_IO_PPI *CpuIo; EFI_PEI_PCI_CFG2_PPI *PciCfg; diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/EcpPciCfg/EcpPciCfg.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/EcpPciCfg/EcpPciCfg.c new file mode 100644 index 0000000000..6b93c4c45e --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/EcpPciCfg/EcpPciCfg.c @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2004, 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. + +Module Name: + + EcpPciCfg.c + +Abstract: + + This PPI which is same with PciCfg PPI. But Modify API is removed. + +--*/ + +#include "Tiano.h" +#include "Pei.h" +#include EFI_PPI_DEFINITION (EcpPciCfg) + +EFI_GUID gEcpPeiPciCfgPpiGuid = ECP_PEI_PCI_CFG_PPI_GUID; + +EFI_GUID_STRING(&gEcpPeiPciCfgPpiGuid, "Ecp PciCfg", "Ecp PciCfg PPI"); diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/EcpPciCfg/EcpPciCfg.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/EcpPciCfg/EcpPciCfg.h new file mode 100644 index 0000000000..837183b2f6 --- /dev/null +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/EcpPciCfg/EcpPciCfg.h @@ -0,0 +1,50 @@ +/*++ + +Copyright (c) 2008, 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. + +Module Name: + + PciCfg.h + +Abstract: + + This PPI which is same with PciCfg PPI. But Modify API is removed. + +--*/ + +#ifndef _ECP_PEI_PCI_CFG_H_ +#define _ECP_PEI_PCI_CFG_H_ +#include EFI_PPI_DEFINITION (PciCfg) + +#define ECP_PEI_PCI_CFG_PPI_GUID \ + {0xb0ee53d4, 0xa049, 0x4a79, { 0xb2, 0xff, 0x19, 0xd9, 0xfa, 0xef, 0xaa, 0x94 }} + +EFI_FORWARD_DECLARATION (ECP_PEI_PCI_CFG_PPI); + + +typedef +EFI_STATUS +(EFIAPI *ECP_PEI_PCI_CFG_PPI_IO) ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_PCI_CFG_PPI *This, + IN PEI_PCI_CFG_PPI_WIDTH Width, + IN UINT64 Address, + IN OUT VOID *Buffer + ); + +struct _ECP_PEI_PCI_CFG_PPI { + ECP_PEI_PCI_CFG_PPI_IO Read; + ECP_PEI_PCI_CFG_PPI_IO Write; +}; + +extern EFI_GUID gEcpPeiPciCfgPpiGuid; + +#endif + diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/EdkFrameworkPpiLib.inf b/EdkCompatibilityPkg/Foundation/Framework/Ppi/EdkFrameworkPpiLib.inf index 438bbffbf3..d0447053ff 100644 --- a/EdkCompatibilityPkg/Foundation/Framework/Ppi/EdkFrameworkPpiLib.inf +++ b/EdkCompatibilityPkg/Foundation/Framework/Ppi/EdkFrameworkPpiLib.inf @@ -100,3 +100,6 @@ COMPONENT_TYPE= LIBRARY FirmwareVolume/FirmwareVolume.c GuidedSectionExtraction/GuidedSectionExtraction.h GuidedSectionExtraction/GuidedSectionExtraction.c + EcpPciCfg/EcpPciCfg.h + EcpPciCfg/EcpPciCfg.c + diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/Include/PeiLib.h b/EdkCompatibilityPkg/Foundation/Library/Pei/Include/PeiLib.h index bbd3713b90..e3afb4341f 100644 --- a/EdkCompatibilityPkg/Foundation/Library/Pei/Include/PeiLib.h +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/Include/PeiLib.h @@ -1301,4 +1301,75 @@ Returns: --*/ ; + + +EFI_STATUS +EFIAPI +PeiLibPciCfgModify ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_PCI_CFG_PPI_WIDTH Width, + IN UINT64 Address, + IN UINTN SetBits, + IN UINTN ClearBits + ) +/*++ + +Routine Description: + + PCI read-modify-write operations. + + PIWG's PI specification replaces Inte's EFI Specification 1.10. + EFI_PEI_PCI_CFG_PPI defined in Inte's EFI Specification 1.10 is replaced by + EFI_PEI_PCI_CFG2_PPI in PI 1.0. "Modify" function in these two PPI are not + compatibile with each other. + + + For Framework code that make the following call: + + PciCfg->Modify ( + PeiServices, + PciCfg, + Width, + Address, + SetBits, + ClearBits + ); + it will be updated to the following code which call this library API: + PeiLibPciCfgModify ( + PeiServices, + Width, + Address, + SetBits, + ClearBits + ); + + The + +Arguments: + + PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + + Width The width of the access. Enumerated in bytes. Type + EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read(). + + Address The physical address of the access. + + SetBits Points to value to bitwise-OR with the read configuration value. + + The size of the value is determined by Width. + + ClearBits Points to the value to negate and bitwise-AND with the read configuration value. + The size of the value is determined by Width. + + +Returns: + + EFI_SUCCESS The function completed successfully. + + EFI_DEVICE_ERROR There was a problem with the transaction. + +--*/ +; + #endif diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c index 23156bb573..f05549fdcb 100644 --- a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c +++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c @@ -153,6 +153,99 @@ Returns: } +EFI_STATUS +EFIAPI +PeiLibPciCfgModify ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_PCI_CFG_PPI_WIDTH Width, + IN UINT64 Address, + IN UINTN SetBits, + IN UINTN ClearBits + ) +/*++ + +Routine Description: + + PCI read-modify-write operations. + + PIWG's PI specification replaces Inte's EFI Specification 1.10. + EFI_PEI_PCI_CFG_PPI defined in Inte's EFI Specification 1.10 is replaced by + EFI_PEI_PCI_CFG2_PPI in PI 1.0. "Modify" function in these two PPI are not + compatibile with each other. + + + For Framework code that make the following call: + + PciCfg->Modify ( + PeiServices, + PciCfg, + Width, + Address, + SetBits, + ClearBits + ); + it will be updated to the following code which call this library API: + PeiLibPciCfgModify ( + PeiServices, + Width, + Address, + SetBits, + ClearBits + ); + + The + +Arguments: + + PeiServices An indirect pointer to the PEI Services Table + published by the PEI Foundation. + + Width The width of the access. Enumerated in bytes. Type + EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read(). + + Address The physical address of the access. + + SetBits Points to value to bitwise-OR with the read configuration value. + + The size of the value is determined by Width. + + ClearBits Points to the value to negate and bitwise-AND with the read configuration value. + The size of the value is determined by Width. + + +Returns: + + EFI_SUCCESS The function completed successfully. + + EFI_DEVICE_ERROR There was a problem with the transaction. + +--*/ +{ + EFI_STATUS Status; + EFI_PEI_PCI_CFG2_PPI *PciCfg2; + + Status = (*PeiServices)->LocatePpi ( + PeiServices, + &gPeiPciCfg2PpiGuid, + 0, + NULL, + (VOID **) &PciCfg2 + ); + ASSERT_EFI_ERROR (Status); + + Status = PciCfg2->Modify ( + PeiServices, + PciCfg2, + Width, + Address, + &SetBits, + &ClearBits + ); + + return Status; +} + + #if (PI_SPECIFICATION_VERSION >= 0x00010000) VOID * -- 2.39.2