* [PATCH 0/7] Remove PcdPeiCoreMaxXXX PCDs
@ 2018-12-14 10:28 Star Zeng
2018-12-14 10:28 ` [PATCH 1/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPeimPerFv Star Zeng
` (6 more replies)
0 siblings, 7 replies; 23+ messages in thread
From: Star Zeng @ 2018-12-14 10:28 UTC (permalink / raw)
To: edk2-devel; +Cc: Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405
Repo: git@github.com:lzeng14/edk2.git
Branch: RemovePcdPeiCoreMaxXXX
Background as below.
Problem:
As static configuration from the PCDs, the binary PeiCore (for example
in FSP binary with dispatch mode) could not predict how many FVs,
Files or PPIs for different platforms.
Burden:
Platform developers need configure the PCDs accordingly for different
platforms.
To solve the problem and remove the burden, we can update code to
remove the using of PcdPeiCoreMaxFvSupported, PcdPeiCoreMaxPeimPerFv
and PcdPeiCoreMaxPpiSupported by extending buffer dynamically for FV,
File and PPI management.
Test done:
Build code with VS2012, VS2015 and GCC49.
Boot Nt32, Ovmf (including 32, 3264 and 64 with no SMM) to UEFI SHELL.
Boot some internal platforms (including a platform with dispatch mode
FSP binary) to UEFI SHELL and Windows.
More test will be welcome and appreciated. :)
Patches to update edk2-platforms Repo will be sent out separately.
Star Zeng (7):
MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPeimPerFv
SecurityPkg Tcg(2)Pei: Remove the using of PcdPeiCoreMaxFvSupported
MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxFvSupported
MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPpiSupported
OvmfPkg: Remove PcdPeiCoreMaxXXX PCDs' statement
Vlv2TbltDevicePkg: Remove PcdPeiCoreMaxXXX PCDs' statement
MdeModulePkg: Remove PcdPeiCoreMaxXXX PCDs
MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 207 +++++++++------
MdeModulePkg/Core/Pei/FwVol/FwVol.c | 67 ++++-
MdeModulePkg/Core/Pei/PeiMain.h | 91 +++++--
MdeModulePkg/Core/Pei/PeiMain.inf | 3 -
MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 94 +++----
MdeModulePkg/Core/Pei/Ppi/Ppi.c | 355 ++++++++++++++------------
MdeModulePkg/MdeModulePkg.dec | 13 -
MdeModulePkg/MdeModulePkg.uni | 12 -
OvmfPkg/OvmfPkgIa32.dsc | 2 -
OvmfPkg/OvmfPkgIa32X64.dsc | 2 -
OvmfPkg/OvmfPkgX64.dsc | 2 -
SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c | 59 +++--
SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf | 1 -
SecurityPkg/Tcg/TcgPei/TcgPei.c | 59 +++--
SecurityPkg/Tcg/TcgPei/TcgPei.inf | 1 -
Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 2 -
Vlv2TbltDevicePkg/PlatformPkgIA32.dsc | 2 -
Vlv2TbltDevicePkg/PlatformPkgX64.dsc | 2 -
18 files changed, 560 insertions(+), 414 deletions(-)
--
2.7.0.windows.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 1/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPeimPerFv
2018-12-14 10:28 [PATCH 0/7] Remove PcdPeiCoreMaxXXX PCDs Star Zeng
@ 2018-12-14 10:28 ` Star Zeng
2018-12-17 23:20 ` Chiu, Chasel
2018-12-18 2:04 ` Wang, Jian J
2018-12-14 10:28 ` [PATCH 2/7] SecurityPkg Tcg(2)Pei: Remove the using of PcdPeiCoreMaxFvSupported Star Zeng
` (5 subsequent siblings)
6 siblings, 2 replies; 23+ messages in thread
From: Star Zeng @ 2018-12-14 10:28 UTC (permalink / raw)
To: edk2-devel
Cc: Star Zeng, Jian J Wang, Hao Wu, Liming Gao, Ruiyu Ni,
Michael D Kinney, Nate DeSimone, Chasel Chiu
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405
Background as below.
Problem:
As static configuration from the PCDs, the binary PeiCore (for example
in FSP binary with dispatch mode) could not predict how many FVs,
Files or PPIs for different platforms.
Burden:
Platform developers need configure the PCDs accordingly for different
platforms.
To solve the problem and remove the burden, we can update code to
remove the using of PcdPeiCoreMaxFvSupported, PcdPeiCoreMaxPeimPerFv
and PcdPeiCoreMaxPpiSupported by extending buffer dynamically for FV,
File and PPI management.
This patch removes the using of PcdPeiCoreMaxPeimPerFv in PeiCore.
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 199 ++++++++++++++++----------
MdeModulePkg/Core/Pei/PeiMain.h | 17 ++-
MdeModulePkg/Core/Pei/PeiMain.inf | 1 -
MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 48 +++----
4 files changed, 157 insertions(+), 108 deletions(-)
diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
index f6bb35a5fe8d..71440bab9488 100644
--- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
@@ -41,7 +41,8 @@ DiscoverPeimsAndOrderWithApriori (
UINTN PeimCount;
EFI_GUID *Guid;
EFI_PEI_FILE_HANDLE *TempFileHandles;
- EFI_GUID *FileGuid;
+ EFI_GUID *TempFileGuid;
+ UINTN TempPeimCount;
EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi;
EFI_FV_FILE_INFO FileInfo;
@@ -51,38 +52,106 @@ DiscoverPeimsAndOrderWithApriori (
// Walk the FV and find all the PEIMs and the Apriori file.
//
AprioriFileHandle = NULL;
- Private->CurrentFvFileHandles[0] = NULL;
+ Private->CurrentFvFileHandles = NULL;
Guid = NULL;
- FileHandle = NULL;
- TempFileHandles = Private->FileHandles;
- FileGuid = Private->FileGuid;
//
- // If the current Fv has been scanned, directly get its cachable record.
+ // If the current Fv has been scanned, directly get its cached records.
//
- if (Private->Fv[Private->CurrentPeimFvCount].ScanFv) {
- CopyMem (Private->CurrentFvFileHandles, Private->Fv[Private->CurrentPeimFvCount].FvFileHandles, sizeof (EFI_PEI_FILE_HANDLE) * PcdGet32 (PcdPeiCoreMaxPeimPerFv));
+ if (CoreFileHandle->ScanFv) {
+ Private->CurrentFvFileHandles = CoreFileHandle->FvFileHandles;
return;
}
+ if (Private->TempPeimCount == 0) {
+ //
+ // Initialize the temp buffers.
+ //
+ Private->TempPeimCount = 32;
+ Private->TempFileHandles = AllocatePool (sizeof (EFI_PEI_FILE_HANDLE) * 32);
+ ASSERT (Private->TempFileHandles != NULL);
+ Private->TempFileGuid = AllocatePool (sizeof (EFI_GUID) * 32);
+ ASSERT (Private->TempFileGuid != NULL);
+ }
+ TempFileHandles = Private->TempFileHandles;
+ TempFileGuid = Private->TempFileGuid;
+
//
- // Go ahead to scan this Fv, and cache FileHandles within it.
+ // Go ahead to scan this Fv, get PeimCount and cache FileHandles within it to TempFileHandles.
//
- Status = EFI_NOT_FOUND;
- for (PeimCount = 0; PeimCount <= PcdGet32 (PcdPeiCoreMaxPeimPerFv); PeimCount++) {
+ PeimCount = 0;
+ FileHandle = NULL;
+ TempPeimCount = 0;
+ do {
Status = FvPpi->FindFileByType (FvPpi, PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE, CoreFileHandle->FvHandle, &FileHandle);
- if (Status != EFI_SUCCESS || PeimCount == PcdGet32 (PcdPeiCoreMaxPeimPerFv)) {
- break;
+ if (!EFI_ERROR (Status)) {
+ if (TempPeimCount < Private->TempPeimCount) {
+ TempFileHandles[TempPeimCount] = FileHandle;
+ TempPeimCount++;
+ }
+ PeimCount++;
}
+ } while (!EFI_ERROR (Status));
- Private->CurrentFvFileHandles[PeimCount] = FileHandle;
+ DEBUG ((
+ DEBUG_INFO,
+ "%a(): Found 0x%x PEI FFS files in the %dth FV\n",
+ __FUNCTION__,
+ PeimCount,
+ Private->CurrentPeimFvCount
+ ));
+
+ if (PeimCount == 0) {
+ //
+ // No PEIM FFS file is found, set ScanFv flag and return.
+ //
+ CoreFileHandle->ScanFv = TRUE;
+ return;
+ }
+
+ if (PeimCount > Private->TempPeimCount) {
+ //
+ // The temp buffers are too small, allocate bigger ones.
+ //
+ TempFileHandles = AllocatePool (sizeof (EFI_PEI_FILE_HANDLE) * PeimCount);
+ ASSERT (TempFileHandles != NULL);
+ CopyMem (
+ TempFileHandles,
+ Private->TempFileHandles,
+ sizeof (EFI_PEI_FILE_HANDLE) * Private->TempPeimCount
+ );
+ Private->TempFileHandles = TempFileHandles;
+ TempFileGuid = AllocatePool (sizeof (EFI_GUID) * PeimCount);
+ ASSERT (TempFileGuid != NULL);
+ CopyMem (
+ TempFileGuid,
+ Private->TempFileGuid,
+ sizeof (EFI_GUID) * Private->TempPeimCount
+ );
+ Private->TempFileGuid = TempFileGuid;
+ Private->TempPeimCount = PeimCount;
}
//
- // Check whether the count of files exceeds the max support files in a FV image
- // If more files are required in a FV image, PcdPeiCoreMaxPeimPerFv can be set to a larger value in DSC file.
+ // Record PeimCount, allocate buffer for PeimState and FvFileHandles.
+ //
+ CoreFileHandle->PeimCount = PeimCount;
+ CoreFileHandle->PeimState = AllocateZeroPool (sizeof (UINT8) * PeimCount);
+ ASSERT (CoreFileHandle->PeimState != NULL);
+ CoreFileHandle->FvFileHandles = AllocateZeroPool (sizeof (EFI_PEI_FILE_HANDLE) * PeimCount);
+ ASSERT (CoreFileHandle->FvFileHandles != NULL);
+
//
- ASSERT ((Status != EFI_SUCCESS) || (PeimCount < PcdGet32 (PcdPeiCoreMaxPeimPerFv)));
+ // TempFileHandles may be not big enough in last scan.
+ // Go ahead to rescan this Fv, and cache remaining FileHandles within it to TempFileHandles.
+ //
+ FileHandle = TempFileHandles[TempPeimCount - 1];
+ for (; TempPeimCount < PeimCount; TempPeimCount++) {
+ Status = FvPpi->FindFileByType (FvPpi, PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE, CoreFileHandle->FvHandle, &FileHandle);
+ ASSERT_EFI_ERROR (Status);
+
+ TempFileHandles[TempPeimCount] = FileHandle;
+ }
//
// Get Apriori File handle
@@ -96,7 +165,7 @@ DiscoverPeimsAndOrderWithApriori (
Status = FvPpi->FindSectionByType (FvPpi, EFI_SECTION_RAW, AprioriFileHandle, (VOID **) &Apriori);
if (!EFI_ERROR (Status)) {
//
- // Calculate the number of PEIMs in the A Priori list
+ // Calculate the number of PEIMs in the Apriori file
//
Status = FvPpi->GetFileInfo (FvPpi, AprioriFileHandle, &FileInfo);
ASSERT_EFI_ERROR (Status);
@@ -113,71 +182,55 @@ DiscoverPeimsAndOrderWithApriori (
// Make an array of file name guids that matches the FileHandle array so we can convert
// quickly from file name to file handle
//
- Status = FvPpi->GetFileInfo (FvPpi, Private->CurrentFvFileHandles[Index], &FileInfo);
- CopyMem (&FileGuid[Index], &FileInfo.FileName, sizeof(EFI_GUID));
+ Status = FvPpi->GetFileInfo (FvPpi, TempFileHandles[Index], &FileInfo);
+ ASSERT_EFI_ERROR (Status);
+ CopyMem (&TempFileGuid[Index], &FileInfo.FileName, sizeof(EFI_GUID));
}
//
- // Walk through FileGuid array to find out who is invalid PEIM guid in Apriori file.
- // Add available PEIMs in Apriori file into TempFileHandles array at first.
+ // Walk through TempFileGuid array to find out who is invalid PEIM guid in Apriori file.
+ // Add available PEIMs in Apriori file into FvFileHandles array.
//
- Index2 = 0;
- for (Index = 0; Index2 < Private->AprioriCount; Index++) {
- while (Index2 < Private->AprioriCount) {
- Guid = ScanGuid (FileGuid, PeimCount * sizeof (EFI_GUID), &Apriori[Index2++]);
- if (Guid != NULL) {
- break;
- }
- }
- if (Guid == NULL) {
- break;
- }
- PeimIndex = ((UINTN)Guid - (UINTN)&FileGuid[0])/sizeof (EFI_GUID);
- TempFileHandles[Index] = Private->CurrentFvFileHandles[PeimIndex];
+ Index = 0;
+ for (Index2 = 0; Index2 < Private->AprioriCount; Index2++) {
+ Guid = ScanGuid (TempFileGuid, PeimCount * sizeof (EFI_GUID), &Apriori[Index2]);
+ if (Guid != NULL) {
+ PeimIndex = ((UINTN)Guid - (UINTN)&TempFileGuid[0])/sizeof (EFI_GUID);
+ CoreFileHandle->FvFileHandles[Index++] = TempFileHandles[PeimIndex];
- //
- // Since we have copied the file handle we can remove it from this list.
- //
- Private->CurrentFvFileHandles[PeimIndex] = NULL;
+ //
+ // Since we have copied the file handle we can remove it from this list.
+ //
+ TempFileHandles[PeimIndex] = NULL;
+ }
}
//
- // Update valid Aprioricount
+ // Update valid AprioriCount
//
Private->AprioriCount = Index;
//
// Add in any PEIMs not in the Apriori file
//
- for (;Index < PeimCount; Index++) {
- for (Index2 = 0; Index2 < PeimCount; Index2++) {
- if (Private->CurrentFvFileHandles[Index2] != NULL) {
- TempFileHandles[Index] = Private->CurrentFvFileHandles[Index2];
- Private->CurrentFvFileHandles[Index2] = NULL;
- break;
- }
+ for (Index2 = 0; Index2 < PeimCount; Index2++) {
+ if (TempFileHandles[Index2] != NULL) {
+ CoreFileHandle->FvFileHandles[Index++] = TempFileHandles[Index2];
+ TempFileHandles[Index2] = NULL;
}
}
- //
- //Index the end of array contains re-range Pei moudle.
- //
- TempFileHandles[Index] = NULL;
-
- //
- // Private->CurrentFvFileHandles is currently in PEIM in the FV order.
- // We need to update it to start with files in the A Priori list and
- // then the remaining files in PEIM order.
- //
- CopyMem (Private->CurrentFvFileHandles, TempFileHandles, sizeof (EFI_PEI_FILE_HANDLE) * PcdGet32 (PcdPeiCoreMaxPeimPerFv));
+ ASSERT (Index == PeimCount);
}
+ } else {
+ CopyMem (CoreFileHandle->FvFileHandles, TempFileHandles, sizeof (EFI_PEI_FILE_HANDLE) * PeimCount);
}
+
//
- // Cache the current Fv File Handle. So that we don't have to scan the Fv again.
- // Instead, we can retrieve the file handles within this Fv from cachable data.
+ // The current Fv File Handles have been cached. So that we don't have to scan the Fv again.
+ // Instead, we can retrieve the file handles within this Fv from cached records.
//
- Private->Fv[Private->CurrentPeimFvCount].ScanFv = TRUE;
- CopyMem (Private->Fv[Private->CurrentPeimFvCount].FvFileHandles, Private->CurrentFvFileHandles, sizeof (EFI_PEI_FILE_HANDLE) * PcdGet32 (PcdPeiCoreMaxPeimPerFv));
-
+ CoreFileHandle->ScanFv = TRUE;
+ Private->CurrentFvFileHandles = CoreFileHandle->FvFileHandles;
}
//
@@ -977,7 +1030,7 @@ PeiDispatcher (
SaveCurrentFileHandle = Private->CurrentFileHandle;
for (Index1 = 0; Index1 < Private->FvCount; Index1++) {
- for (Index2 = 0; (Index2 < PcdGet32 (PcdPeiCoreMaxPeimPerFv)) && (Private->Fv[Index1].FvFileHandles[Index2] != NULL); Index2++) {
+ for (Index2 = 0; Index2 < Private->Fv[Index1].PeimCount; Index2++) {
if (Private->Fv[Index1].PeimState[Index2] == PEIM_STATE_REGISTER_FOR_SHADOW) {
PeimFileHandle = Private->Fv[Index1].FvFileHandles[Index2];
Private->CurrentFileHandle = PeimFileHandle;
@@ -1063,7 +1116,7 @@ PeiDispatcher (
// Start to dispatch all modules within the current Fv.
//
for (PeimCount = Private->CurrentPeimCount;
- (PeimCount < PcdGet32 (PcdPeiCoreMaxPeimPerFv)) && (Private->CurrentFvFileHandles[PeimCount] != NULL);
+ PeimCount < Private->Fv[FvCount].PeimCount;
PeimCount++) {
Private->CurrentPeimCount = PeimCount;
PeimFileHandle = Private->CurrentFileHandle = Private->CurrentFvFileHandles[PeimCount];
@@ -1207,21 +1260,17 @@ PeiDispatcher (
}
//
- // We set to NULL here to optimize the 2nd entry to this routine after
- // memory is found. This reprevents rescanning of the FV. We set to
- // NULL here so we start at the begining of the next FV
+ // Before walking through the next FV, we should set them to NULL/0 to
+ // start at the begining of the next FV.
//
Private->CurrentFileHandle = NULL;
Private->CurrentPeimCount = 0;
- //
- // Before walking through the next FV,Private->CurrentFvFileHandles[]should set to NULL
- //
- SetMem (Private->CurrentFvFileHandles, sizeof (EFI_PEI_FILE_HANDLE) * PcdGet32 (PcdPeiCoreMaxPeimPerFv), 0);
+ Private->CurrentFvFileHandles = NULL;
}
//
- // Before making another pass, we should set Private->CurrentPeimFvCount =0 to go
- // through all the FV.
+ // Before making another pass, we should set it to 0 to
+ // go through all the FVs.
//
Private->CurrentPeimFvCount = 0;
@@ -1300,7 +1349,7 @@ DepexSatisfied (
if (PeimCount < Private->AprioriCount) {
//
- // If its in the A priori file then we set Depex to TRUE
+ // If it's in the Apriori file then we set Depex to TRUE
//
DEBUG ((DEBUG_DISPATCH, " RESULT = TRUE (Apriori)\n"));
return TRUE;
diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h
index 6469436b8f79..ab914c7d2e44 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.h
+++ b/MdeModulePkg/Core/Pei/PeiMain.h
@@ -111,12 +111,13 @@ typedef struct {
EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi;
EFI_PEI_FV_HANDLE FvHandle;
+ UINTN PeimCount;
//
- // Ponter to the buffer with the PcdPeiCoreMaxPeimPerFv number of Entries.
+ // Ponter to the buffer with the PeimCount number of Entries.
//
UINT8 *PeimState;
//
- // Ponter to the buffer with the PcdPeiCoreMaxPeimPerFv number of Entries.
+ // Ponter to the buffer with the PeimCount number of Entries.
//
EFI_PEI_FILE_HANDLE *FvFileHandles;
BOOLEAN ScanFv;
@@ -209,7 +210,7 @@ struct _PEI_CORE_INSTANCE {
UINTN UnknownFvInfoCount;
///
- /// Pointer to the buffer with the PcdPeiCoreMaxPeimPerFv number of entries.
+ /// Pointer to the buffer FvFileHandlers in PEI_CORE_FV_HANDLE specified by CurrentPeimFvCount.
///
EFI_PEI_FILE_HANDLE *CurrentFvFileHandles;
UINTN AprioriCount;
@@ -256,14 +257,16 @@ struct _PEI_CORE_INSTANCE {
//
PE_COFF_LOADER_READ_FILE ShadowedImageRead;
+ UINTN TempPeimCount;
+
//
- // Pointer to the temp buffer with the PcdPeiCoreMaxPeimPerFv + 1 number of entries.
+ // Pointer to the temp buffer with the TempPeimCount number of entries.
//
- EFI_PEI_FILE_HANDLE *FileHandles;
+ EFI_PEI_FILE_HANDLE *TempFileHandles;
//
- // Pointer to the temp buffer with the PcdPeiCoreMaxPeimPerFv number of entries.
+ // Pointer to the temp buffer with the TempPeimCount number of entries.
//
- EFI_GUID *FileGuid;
+ EFI_GUID *TempFileGuid;
//
// Temp Memory Range is not covered by PeiTempMem and Stack.
diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf b/MdeModulePkg/Core/Pei/PeiMain.inf
index 4e1581a926d9..d106c3606e97 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.inf
+++ b/MdeModulePkg/Core/Pei/PeiMain.inf
@@ -105,7 +105,6 @@ [Ppis]
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreImageLoaderSearchTeSectionFirst ## CONSUMES
diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
index e3a301dfe0f2..52adefeb44b4 100644
--- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
+++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
@@ -185,27 +185,39 @@ PeiCore (
if (OldCoreData->HeapOffsetPositive) {
OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw + OldCoreData->HeapOffset);
OldCoreData->UnknownFvInfo = (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData->UnknownFvInfo + OldCoreData->HeapOffset);
- OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles + OldCoreData->HeapOffset);
+ if (OldCoreData->CurrentFvFileHandles != NULL) {
+ OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles + OldCoreData->HeapOffset);
+ }
OldCoreData->PpiData.PpiListPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiListPtrs + OldCoreData->HeapOffset);
OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *) OldCoreData->Fv + OldCoreData->HeapOffset);
for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {
- OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData->Fv[Index].PeimState + OldCoreData->HeapOffset;
- OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles + OldCoreData->HeapOffset);
+ if (OldCoreData->Fv[Index].PeimState != NULL) {
+ OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData->Fv[Index].PeimState + OldCoreData->HeapOffset;
+ }
+ if (OldCoreData->Fv[Index].FvFileHandles != NULL) {
+ OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles + OldCoreData->HeapOffset);
+ }
}
- OldCoreData->FileGuid = (EFI_GUID *) ((UINT8 *) OldCoreData->FileGuid + OldCoreData->HeapOffset);
- OldCoreData->FileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->FileHandles + OldCoreData->HeapOffset);
+ OldCoreData->TempFileGuid = (EFI_GUID *) ((UINT8 *) OldCoreData->TempFileGuid + OldCoreData->HeapOffset);
+ OldCoreData->TempFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->TempFileHandles + OldCoreData->HeapOffset);
} else {
OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw - OldCoreData->HeapOffset);
OldCoreData->UnknownFvInfo = (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData->UnknownFvInfo - OldCoreData->HeapOffset);
- OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles - OldCoreData->HeapOffset);
+ if (OldCoreData->CurrentFvFileHandles != NULL) {
+ OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles - OldCoreData->HeapOffset);
+ }
OldCoreData->PpiData.PpiListPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiListPtrs - OldCoreData->HeapOffset);
OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *) OldCoreData->Fv - OldCoreData->HeapOffset);
for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {
- OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData->Fv[Index].PeimState - OldCoreData->HeapOffset;
- OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles - OldCoreData->HeapOffset);
+ if (OldCoreData->Fv[Index].PeimState != NULL) {
+ OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData->Fv[Index].PeimState - OldCoreData->HeapOffset;
+ }
+ if (OldCoreData->Fv[Index].FvFileHandles != NULL) {
+ OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles - OldCoreData->HeapOffset);
+ }
}
- OldCoreData->FileGuid = (EFI_GUID *) ((UINT8 *) OldCoreData->FileGuid - OldCoreData->HeapOffset);
- OldCoreData->FileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->FileHandles - OldCoreData->HeapOffset);
+ OldCoreData->TempFileGuid = (EFI_GUID *) ((UINT8 *) OldCoreData->TempFileGuid - OldCoreData->HeapOffset);
+ OldCoreData->TempFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->TempFileHandles - OldCoreData->HeapOffset);
}
//
@@ -320,7 +332,7 @@ PeiCore (
//
// Initialize PEI Core Services
//
- InitializeMemoryServices (&PrivateData, SecCoreData, OldCoreData);
+ InitializeMemoryServices (&PrivateData, SecCoreData, OldCoreData);
if (OldCoreData == NULL) {
//
// Initialize PEI Core Private Data Buffer
@@ -329,22 +341,8 @@ PeiCore (
ASSERT (PrivateData.PpiData.PpiListPtrs != NULL);
PrivateData.Fv = AllocateZeroPool (sizeof (PEI_CORE_FV_HANDLE) * PcdGet32 (PcdPeiCoreMaxFvSupported));
ASSERT (PrivateData.Fv != NULL);
- PrivateData.Fv[0].PeimState = AllocateZeroPool (sizeof (UINT8) * PcdGet32 (PcdPeiCoreMaxPeimPerFv) * PcdGet32 (PcdPeiCoreMaxFvSupported));
- ASSERT (PrivateData.Fv[0].PeimState != NULL);
- PrivateData.Fv[0].FvFileHandles = AllocateZeroPool (sizeof (EFI_PEI_FILE_HANDLE) * PcdGet32 (PcdPeiCoreMaxPeimPerFv) * PcdGet32 (PcdPeiCoreMaxFvSupported));
- ASSERT (PrivateData.Fv[0].FvFileHandles != NULL);
- for (Index = 1; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {
- PrivateData.Fv[Index].PeimState = PrivateData.Fv[Index - 1].PeimState + PcdGet32 (PcdPeiCoreMaxPeimPerFv);
- PrivateData.Fv[Index].FvFileHandles = PrivateData.Fv[Index - 1].FvFileHandles + PcdGet32 (PcdPeiCoreMaxPeimPerFv);
- }
PrivateData.UnknownFvInfo = AllocateZeroPool (sizeof (PEI_CORE_UNKNOW_FORMAT_FV_INFO) * PcdGet32 (PcdPeiCoreMaxFvSupported));
ASSERT (PrivateData.UnknownFvInfo != NULL);
- PrivateData.CurrentFvFileHandles = AllocateZeroPool (sizeof (EFI_PEI_FILE_HANDLE) * PcdGet32 (PcdPeiCoreMaxPeimPerFv));
- ASSERT (PrivateData.CurrentFvFileHandles != NULL);
- PrivateData.FileGuid = AllocatePool (sizeof (EFI_GUID) * PcdGet32 (PcdPeiCoreMaxPeimPerFv));
- ASSERT (PrivateData.FileGuid != NULL);
- PrivateData.FileHandles = AllocatePool (sizeof (EFI_PEI_FILE_HANDLE) * (PcdGet32 (PcdPeiCoreMaxPeimPerFv) + 1));
- ASSERT (PrivateData.FileHandles != NULL);
}
InitializePpiServices (&PrivateData, OldCoreData);
--
2.7.0.windows.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 2/7] SecurityPkg Tcg(2)Pei: Remove the using of PcdPeiCoreMaxFvSupported
2018-12-14 10:28 [PATCH 0/7] Remove PcdPeiCoreMaxXXX PCDs Star Zeng
2018-12-14 10:28 ` [PATCH 1/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPeimPerFv Star Zeng
@ 2018-12-14 10:28 ` Star Zeng
2018-12-17 5:06 ` Zhang, Chao B
2018-12-14 10:28 ` [PATCH 3/7] MdeModulePkg PeiCore: " Star Zeng
` (4 subsequent siblings)
6 siblings, 1 reply; 23+ messages in thread
From: Star Zeng @ 2018-12-14 10:28 UTC (permalink / raw)
To: edk2-devel; +Cc: Star Zeng, Chao Zhang, Jiewen Yao
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405
Background as below.
Problem:
As static configuration from the PCDs, the binary PeiCore (for example
in FSP binary with dispatch mode) could not predict how many FVs,
Files or PPIs for different platforms.
Burden:
Platform developers need configure the PCDs accordingly for different
platforms.
To solve the problem and remove the burden, we can update PeiCore to
remove the using of PcdPeiCoreMaxFvSupported, PcdPeiCoreMaxPeimPerFv
and PcdPeiCoreMaxPpiSupported by extending buffer dynamically for FV,
File and PPI management.
This patch removes the using of PcdPeiCoreMaxFvSupported in Tcg(2)Pei.
Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c | 59 +++++++++++++++++++++++--------------
SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf | 1 -
SecurityPkg/Tcg/TcgPei/TcgPei.c | 59 +++++++++++++++++++++++--------------
SecurityPkg/Tcg/TcgPei/TcgPei.inf | 1 -
4 files changed, 74 insertions(+), 46 deletions(-)
diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
index 09ef0c70a50b..152e3f737b56 100644
--- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
+++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
@@ -71,10 +71,17 @@ EFI_PEI_PPI_DESCRIPTOR mTpmInitializationDonePpiList = {
NULL
};
+//
+// Number of firmware blobs to grow by each time we run out of room
+//
+#define FIRMWARE_BLOB_GROWTH_STEP 4
+
EFI_PLATFORM_FIRMWARE_BLOB *mMeasuredBaseFvInfo;
+UINT32 mMeasuredMaxBaseFvIndex = 0;
UINT32 mMeasuredBaseFvIndex = 0;
EFI_PLATFORM_FIRMWARE_BLOB *mMeasuredChildFvInfo;
+UINT32 mMeasuredMaxChildFvIndex = 0;
UINT32 mMeasuredChildFvIndex = 0;
/**
@@ -615,13 +622,20 @@ MeasureFvImage (
//
// Add new FV into the measured FV list.
//
- ASSERT (mMeasuredBaseFvIndex < PcdGet32 (PcdPeiCoreMaxFvSupported));
- if (mMeasuredBaseFvIndex < PcdGet32 (PcdPeiCoreMaxFvSupported)) {
- mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobBase = FvBase;
- mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobLength = FvLength;
- mMeasuredBaseFvIndex++;
+ if (mMeasuredBaseFvIndex >= mMeasuredMaxBaseFvIndex) {
+ mMeasuredBaseFvInfo = ReallocatePool (
+ sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * mMeasuredMaxBaseFvIndex,
+ sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * (mMeasuredMaxBaseFvIndex + FIRMWARE_BLOB_GROWTH_STEP),
+ mMeasuredBaseFvInfo
+ );
+ ASSERT (mMeasuredBaseFvInfo != NULL);
+ mMeasuredMaxBaseFvIndex = mMeasuredMaxBaseFvIndex + FIRMWARE_BLOB_GROWTH_STEP;
}
+ mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobBase = FvBase;
+ mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobLength = FvLength;
+ mMeasuredBaseFvIndex++;
+
return Status;
}
@@ -724,20 +738,26 @@ FirmwareVolmeInfoPpiNotifyCallback (
//
if (Fv->ParentFvName != NULL || Fv->ParentFileName != NULL ) {
- ASSERT (mMeasuredChildFvIndex < PcdGet32 (PcdPeiCoreMaxFvSupported));
- if (mMeasuredChildFvIndex < PcdGet32 (PcdPeiCoreMaxFvSupported)) {
- //
- // Check whether FV is in the measured child FV list.
- //
- for (Index = 0; Index < mMeasuredChildFvIndex; Index++) {
- if (mMeasuredChildFvInfo[Index].BlobBase == (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo) {
- return EFI_SUCCESS;
- }
+ if (mMeasuredChildFvIndex >= mMeasuredMaxChildFvIndex) {
+ mMeasuredChildFvInfo = ReallocatePool (
+ sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * mMeasuredMaxChildFvIndex,
+ sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * (mMeasuredMaxChildFvIndex + FIRMWARE_BLOB_GROWTH_STEP),
+ mMeasuredChildFvInfo
+ );
+ ASSERT (mMeasuredChildFvInfo != NULL);
+ mMeasuredMaxChildFvIndex = mMeasuredMaxChildFvIndex + FIRMWARE_BLOB_GROWTH_STEP;
+ }
+ //
+ // Check whether FV is in the measured child FV list.
+ //
+ for (Index = 0; Index < mMeasuredChildFvIndex; Index++) {
+ if (mMeasuredChildFvInfo[Index].BlobBase == (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo) {
+ return EFI_SUCCESS;
}
- mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobBase = (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo;
- mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobLength = Fv->FvInfoSize;
- mMeasuredChildFvIndex++;
}
+ mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobBase = (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo;
+ mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobLength = Fv->FvInfoSize;
+ mMeasuredChildFvIndex++;
return EFI_SUCCESS;
}
@@ -761,11 +781,6 @@ PeimEntryMP (
{
EFI_STATUS Status;
- mMeasuredBaseFvInfo = (EFI_PLATFORM_FIRMWARE_BLOB *) AllocateZeroPool (sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * PcdGet32 (PcdPeiCoreMaxFvSupported));
- ASSERT (mMeasuredBaseFvInfo != NULL);
- mMeasuredChildFvInfo = (EFI_PLATFORM_FIRMWARE_BLOB *) AllocateZeroPool (sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * PcdGet32 (PcdPeiCoreMaxFvSupported));
- ASSERT (mMeasuredChildFvInfo != NULL);
-
if (PcdGet8 (PcdTpm2ScrtmPolicy) == 1) {
Status = MeasureCRTMVersion ();
}
diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
index ea9dc759ab0a..2f3dcb7e812b 100644
--- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
+++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
@@ -83,7 +83,6 @@ [Pcd]
gEfiSecurityPkgTokenSpaceGuid.PcdTpm2InitializationPolicy ## CONSUMES
gEfiSecurityPkgTokenSpaceGuid.PcdTpm2SelfTestPolicy ## SOMETIMES_CONSUMES
gEfiSecurityPkgTokenSpaceGuid.PcdTpm2ScrtmPolicy ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported ## CONSUMES
gEfiSecurityPkgTokenSpaceGuid.PcdStatusCodeSubClassTpmDevice ## SOMETIMES_CONSUMES
## SOMETIMES_CONSUMES
## SOMETIMES_PRODUCES
diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.c b/SecurityPkg/Tcg/TcgPei/TcgPei.c
index d07047580c5b..8b063c081b52 100644
--- a/SecurityPkg/Tcg/TcgPei/TcgPei.c
+++ b/SecurityPkg/Tcg/TcgPei/TcgPei.c
@@ -57,10 +57,17 @@ EFI_PEI_PPI_DESCRIPTOR mTpmInitializationDonePpiList = {
NULL
};
+//
+// Number of firmware blobs to grow by each time we run out of room
+//
+#define FIRMWARE_BLOB_GROWTH_STEP 4
+
EFI_PLATFORM_FIRMWARE_BLOB *mMeasuredBaseFvInfo;
+UINT32 mMeasuredMaxBaseFvIndex = 0;
UINT32 mMeasuredBaseFvIndex = 0;
EFI_PLATFORM_FIRMWARE_BLOB *mMeasuredChildFvInfo;
+UINT32 mMeasuredMaxChildFvIndex = 0;
UINT32 mMeasuredChildFvIndex = 0;
EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_PPI *mMeasurementExcludedFvPpi;
@@ -424,13 +431,20 @@ MeasureFvImage (
//
// Add new FV into the measured FV list.
//
- ASSERT (mMeasuredBaseFvIndex < PcdGet32 (PcdPeiCoreMaxFvSupported));
- if (mMeasuredBaseFvIndex < PcdGet32 (PcdPeiCoreMaxFvSupported)) {
- mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobBase = FvBase;
- mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobLength = FvLength;
- mMeasuredBaseFvIndex++;
+ if (mMeasuredBaseFvIndex >= mMeasuredMaxBaseFvIndex) {
+ mMeasuredBaseFvInfo = ReallocatePool (
+ sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * mMeasuredMaxBaseFvIndex,
+ sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * (mMeasuredMaxBaseFvIndex + FIRMWARE_BLOB_GROWTH_STEP),
+ mMeasuredBaseFvInfo
+ );
+ ASSERT (mMeasuredBaseFvInfo != NULL);
+ mMeasuredMaxBaseFvIndex = mMeasuredMaxBaseFvIndex + FIRMWARE_BLOB_GROWTH_STEP;
}
+ mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobBase = FvBase;
+ mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobLength = FvLength;
+ mMeasuredBaseFvIndex++;
+
return Status;
}
@@ -537,20 +551,26 @@ FirmwareVolmeInfoPpiNotifyCallback (
//
if (Fv->ParentFvName != NULL || Fv->ParentFileName != NULL ) {
- ASSERT (mMeasuredChildFvIndex < PcdGet32 (PcdPeiCoreMaxFvSupported));
- if (mMeasuredChildFvIndex < PcdGet32 (PcdPeiCoreMaxFvSupported)) {
- //
- // Check whether FV is in the measured child FV list.
- //
- for (Index = 0; Index < mMeasuredChildFvIndex; Index++) {
- if (mMeasuredChildFvInfo[Index].BlobBase == (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo) {
- return EFI_SUCCESS;
- }
+ if (mMeasuredChildFvIndex >= mMeasuredMaxChildFvIndex) {
+ mMeasuredChildFvInfo = ReallocatePool (
+ sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * mMeasuredMaxChildFvIndex,
+ sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * (mMeasuredMaxChildFvIndex + FIRMWARE_BLOB_GROWTH_STEP),
+ mMeasuredChildFvInfo
+ );
+ ASSERT (mMeasuredChildFvInfo != NULL);
+ mMeasuredMaxChildFvIndex = mMeasuredMaxChildFvIndex + FIRMWARE_BLOB_GROWTH_STEP;
+ }
+ //
+ // Check whether FV is in the measured child FV list.
+ //
+ for (Index = 0; Index < mMeasuredChildFvIndex; Index++) {
+ if (mMeasuredChildFvInfo[Index].BlobBase == (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo) {
+ return EFI_SUCCESS;
}
- mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobBase = (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo;
- mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobLength = Fv->FvInfoSize;
- mMeasuredChildFvIndex++;
}
+ mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobBase = (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo;
+ mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobLength = Fv->FvInfoSize;
+ mMeasuredChildFvIndex++;
return EFI_SUCCESS;
}
@@ -707,11 +727,6 @@ PeimEntryMP (
);
// Do not check status, because it is optional
- mMeasuredBaseFvInfo = (EFI_PLATFORM_FIRMWARE_BLOB *) AllocateZeroPool (sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * PcdGet32 (PcdPeiCoreMaxFvSupported));
- ASSERT (mMeasuredBaseFvInfo != NULL);
- mMeasuredChildFvInfo = (EFI_PLATFORM_FIRMWARE_BLOB *) AllocateZeroPool (sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * PcdGet32 (PcdPeiCoreMaxFvSupported));
- ASSERT (mMeasuredChildFvInfo != NULL);
-
Status = Tpm12RequestUseTpm ();
if (EFI_ERROR (Status)) {
return Status;
diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.inf b/SecurityPkg/Tcg/TcgPei/TcgPei.inf
index 4c8a055c6ca5..8db93b908fe4 100644
--- a/SecurityPkg/Tcg/TcgPei/TcgPei.inf
+++ b/SecurityPkg/Tcg/TcgPei/TcgPei.inf
@@ -81,7 +81,6 @@ [Pcd]
gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid ## CONSUMES
gEfiSecurityPkgTokenSpaceGuid.PcdTpmInitializationPolicy ## CONSUMES
gEfiSecurityPkgTokenSpaceGuid.PcdTpmScrtmPolicy ## SOMETIMES_CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported ## CONSUMES
gEfiSecurityPkgTokenSpaceGuid.PcdStatusCodeSubClassTpmDevice ## SOMETIMES_CONSUMES
[Depex]
--
2.7.0.windows.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 3/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxFvSupported
2018-12-14 10:28 [PATCH 0/7] Remove PcdPeiCoreMaxXXX PCDs Star Zeng
2018-12-14 10:28 ` [PATCH 1/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPeimPerFv Star Zeng
2018-12-14 10:28 ` [PATCH 2/7] SecurityPkg Tcg(2)Pei: Remove the using of PcdPeiCoreMaxFvSupported Star Zeng
@ 2018-12-14 10:28 ` Star Zeng
2018-12-17 23:20 ` Chiu, Chasel
2018-12-18 2:10 ` Wang, Jian J
2018-12-14 10:28 ` [PATCH 4/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPpiSupported Star Zeng
` (3 subsequent siblings)
6 siblings, 2 replies; 23+ messages in thread
From: Star Zeng @ 2018-12-14 10:28 UTC (permalink / raw)
To: edk2-devel
Cc: Star Zeng, Jian J Wang, Hao Wu, Liming Gao, Ruiyu Ni,
Michael D Kinney, Nate DeSimone, Chasel Chiu
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405
Background as below.
Problem:
As static configuration from the PCDs, the binary PeiCore (for example
in FSP binary with dispatch mode) could not predict how many FVs,
Files or PPIs for different platforms.
Burden:
Platform developers need configure the PCDs accordingly for different
platforms.
To solve the problem and remove the burden, we can update PeiCore to
remove the using of PcdPeiCoreMaxFvSupported, PcdPeiCoreMaxPeimPerFv
and PcdPeiCoreMaxPpiSupported by extending buffer dynamically for FV,
File and PPI management.
This patch removes the using of PcdPeiCoreMaxFvSupported in PeiCore.
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
MdeModulePkg/Core/Pei/FwVol/FwVol.c | 67 ++++++++++++++++++++++++++-------
MdeModulePkg/Core/Pei/PeiMain.h | 15 +++++++-
MdeModulePkg/Core/Pei/PeiMain.inf | 1 -
MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 16 ++++----
4 files changed, 75 insertions(+), 24 deletions(-)
diff --git a/MdeModulePkg/Core/Pei/FwVol/FwVol.c b/MdeModulePkg/Core/Pei/FwVol/FwVol.c
index 5629c9a1ce20..0a67b96bf1e3 100644
--- a/MdeModulePkg/Core/Pei/FwVol/FwVol.c
+++ b/MdeModulePkg/Core/Pei/FwVol/FwVol.c
@@ -503,6 +503,10 @@ PeiInitializeFv (
);
ASSERT_EFI_ERROR (Status);
+ PrivateData->Fv = AllocateZeroPool (sizeof (PEI_CORE_FV_HANDLE) * FV_GROWTH_STEP);
+ ASSERT (PrivateData->Fv != NULL);
+ PrivateData->MaxFvCount = FV_GROWTH_STEP;
+
//
// Update internal PEI_CORE_FV array.
//
@@ -560,6 +564,7 @@ FirmwareVolmeInfoPpiNotifyCallback (
VOID *DepexData;
BOOLEAN IsFvInfo2;
UINTN CurFvCount;
+ VOID *TempPtr;
Status = EFI_SUCCESS;
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
@@ -626,10 +631,21 @@ FirmwareVolmeInfoPpiNotifyCallback (
}
}
- if (PrivateData->FvCount >= PcdGet32 (PcdPeiCoreMaxFvSupported)) {
- DEBUG ((EFI_D_ERROR, "The number of Fv Images (%d) exceed the max supported FVs (%d) in Pei", PrivateData->FvCount + 1, PcdGet32 (PcdPeiCoreMaxFvSupported)));
- DEBUG ((EFI_D_ERROR, "PcdPeiCoreMaxFvSupported value need be reconfigurated in DSC"));
- ASSERT (FALSE);
+ if (PrivateData->FvCount >= PrivateData->MaxFvCount) {
+ //
+ // Run out of room, grow the buffer.
+ //
+ TempPtr = AllocateZeroPool (
+ sizeof (PEI_CORE_FV_HANDLE) * (PrivateData->MaxFvCount + FV_GROWTH_STEP)
+ );
+ ASSERT (TempPtr != NULL);
+ CopyMem (
+ TempPtr,
+ PrivateData->Fv,
+ sizeof (PEI_CORE_FV_HANDLE) * PrivateData->MaxFvCount
+ );
+ PrivateData->Fv = TempPtr;
+ PrivateData->MaxFvCount = PrivateData->MaxFvCount + FV_GROWTH_STEP;
}
//
@@ -2157,7 +2173,6 @@ FindNextCoreFvHandle (
}
}
- ASSERT (Private->FvCount <= PcdGet32 (PcdPeiCoreMaxFvSupported));
if (Instance >= Private->FvCount) {
return NULL;
}
@@ -2205,7 +2220,7 @@ PeiReinitializeFv (
//
// Fixup all FvPpi pointers for the implementation in flash to permanent memory.
//
- for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {
+ for (Index = 0; Index < PrivateData->FvCount; Index ++) {
if (PrivateData->Fv[Index].FvPpi == OldFfsFvPpi) {
PrivateData->Fv[Index].FvPpi = &mPeiFfs2FwVol.Fv;
}
@@ -2233,7 +2248,7 @@ PeiReinitializeFv (
//
// Fixup all FvPpi pointers for the implementation in flash to permanent memory.
//
- for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {
+ for (Index = 0; Index < PrivateData->FvCount; Index ++) {
if (PrivateData->Fv[Index].FvPpi == OldFfsFvPpi) {
PrivateData->Fv[Index].FvPpi = &mPeiFfs3FwVol.Fv;
}
@@ -2263,9 +2278,23 @@ AddUnknownFormatFvInfo (
)
{
PEI_CORE_UNKNOW_FORMAT_FV_INFO *NewUnknownFv;
+ VOID *TempPtr;
- if (PrivateData->UnknownFvInfoCount + 1 >= PcdGet32 (PcdPeiCoreMaxFvSupported)) {
- return EFI_OUT_OF_RESOURCES;
+ if (PrivateData->UnknownFvInfoCount >= PrivateData->MaxUnknownFvInfoCount) {
+ //
+ // Run out of room, grow the buffer.
+ //
+ TempPtr = AllocateZeroPool (
+ sizeof (PEI_CORE_UNKNOW_FORMAT_FV_INFO) * (PrivateData->MaxUnknownFvInfoCount + FV_GROWTH_STEP)
+ );
+ ASSERT (TempPtr != NULL);
+ CopyMem (
+ TempPtr,
+ PrivateData->UnknownFvInfo,
+ sizeof (PEI_CORE_UNKNOW_FORMAT_FV_INFO) * PrivateData->MaxUnknownFvInfoCount
+ );
+ PrivateData->UnknownFvInfo = TempPtr;
+ PrivateData->MaxUnknownFvInfoCount = PrivateData->MaxUnknownFvInfoCount + FV_GROWTH_STEP;
}
NewUnknownFv = &PrivateData->UnknownFvInfo[PrivateData->UnknownFvInfoCount];
@@ -2368,6 +2397,7 @@ ThirdPartyFvPpiNotifyCallback (
EFI_PEI_FILE_HANDLE FileHandle;
VOID *DepexData;
UINTN CurFvCount;
+ VOID *TempPtr;
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
FvPpi = (EFI_PEI_FIRMWARE_VOLUME_PPI*) Ppi;
@@ -2403,10 +2433,21 @@ ThirdPartyFvPpiNotifyCallback (
continue;
}
- if (PrivateData->FvCount >= PcdGet32 (PcdPeiCoreMaxFvSupported)) {
- DEBUG ((EFI_D_ERROR, "The number of Fv Images (%d) exceed the max supported FVs (%d) in Pei", PrivateData->FvCount + 1, PcdGet32 (PcdPeiCoreMaxFvSupported)));
- DEBUG ((EFI_D_ERROR, "PcdPeiCoreMaxFvSupported value need be reconfigurated in DSC"));
- ASSERT (FALSE);
+ if (PrivateData->FvCount >= PrivateData->MaxFvCount) {
+ //
+ // Run out of room, grow the buffer.
+ //
+ TempPtr = AllocateZeroPool (
+ sizeof (PEI_CORE_FV_HANDLE) * (PrivateData->MaxFvCount + FV_GROWTH_STEP)
+ );
+ ASSERT (TempPtr != NULL);
+ CopyMem (
+ TempPtr,
+ PrivateData->Fv,
+ sizeof (PEI_CORE_FV_HANDLE) * PrivateData->MaxFvCount
+ );
+ PrivateData->Fv = TempPtr;
+ PrivateData->MaxFvCount = PrivateData->MaxFvCount + FV_GROWTH_STEP;
}
//
diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h
index ab914c7d2e44..b248118087ad 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.h
+++ b/MdeModulePkg/Core/Pei/PeiMain.h
@@ -107,6 +107,11 @@ typedef struct {
#define PEIM_STATE_REGISTER_FOR_SHADOW 0x02
#define PEIM_STATE_DONE 0x03
+//
+// Number of FV instances to grow by each time we run out of room
+//
+#define FV_GROWTH_STEP 8
+
typedef struct {
EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi;
@@ -197,16 +202,22 @@ struct _PEI_CORE_INSTANCE {
UINTN FvCount;
///
- /// Pointer to the buffer with the PcdPeiCoreMaxFvSupported number of entries.
+ /// The max count of FVs which contains FFS and could be dispatched by PeiCore.
+ ///
+ UINTN MaxFvCount;
+
+ ///
+ /// Pointer to the buffer with the MaxFvCount number of entries.
/// Each entry is for one FV which contains FFS and could be dispatched by PeiCore.
///
PEI_CORE_FV_HANDLE *Fv;
///
- /// Pointer to the buffer with the PcdPeiCoreMaxFvSupported number of entries.
+ /// Pointer to the buffer with the MaxUnknownFvInfoCount number of entries.
/// Each entry is for one FV which could not be dispatched by PeiCore.
///
PEI_CORE_UNKNOW_FORMAT_FV_INFO *UnknownFvInfo;
+ UINTN MaxUnknownFvInfoCount;
UINTN UnknownFvInfoCount;
///
diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf b/MdeModulePkg/Core/Pei/PeiMain.inf
index d106c3606e97..dd41fe41bc89 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.inf
+++ b/MdeModulePkg/Core/Pei/PeiMain.inf
@@ -104,7 +104,6 @@ [Ppis]
gEfiSecHobDataPpiGuid ## SOMETIMES_CONSUMES
[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreImageLoaderSearchTeSectionFirst ## CONSUMES
diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
index 52adefeb44b4..4869bf18f005 100644
--- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
+++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
@@ -184,13 +184,15 @@ PeiCore (
OldCoreData->CpuIo = &OldCoreData->ServiceTableShadow.CpuIo;
if (OldCoreData->HeapOffsetPositive) {
OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw + OldCoreData->HeapOffset);
- OldCoreData->UnknownFvInfo = (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData->UnknownFvInfo + OldCoreData->HeapOffset);
+ if (OldCoreData->UnknownFvInfo != NULL) {
+ OldCoreData->UnknownFvInfo = (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData->UnknownFvInfo + OldCoreData->HeapOffset);
+ }
if (OldCoreData->CurrentFvFileHandles != NULL) {
OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles + OldCoreData->HeapOffset);
}
OldCoreData->PpiData.PpiListPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiListPtrs + OldCoreData->HeapOffset);
OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *) OldCoreData->Fv + OldCoreData->HeapOffset);
- for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {
+ for (Index = 0; Index < OldCoreData->FvCount; Index ++) {
if (OldCoreData->Fv[Index].PeimState != NULL) {
OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData->Fv[Index].PeimState + OldCoreData->HeapOffset;
}
@@ -202,13 +204,15 @@ PeiCore (
OldCoreData->TempFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->TempFileHandles + OldCoreData->HeapOffset);
} else {
OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw - OldCoreData->HeapOffset);
- OldCoreData->UnknownFvInfo = (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData->UnknownFvInfo - OldCoreData->HeapOffset);
+ if (OldCoreData->UnknownFvInfo != NULL) {
+ OldCoreData->UnknownFvInfo = (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData->UnknownFvInfo - OldCoreData->HeapOffset);
+ }
if (OldCoreData->CurrentFvFileHandles != NULL) {
OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles - OldCoreData->HeapOffset);
}
OldCoreData->PpiData.PpiListPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiListPtrs - OldCoreData->HeapOffset);
OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *) OldCoreData->Fv - OldCoreData->HeapOffset);
- for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {
+ for (Index = 0; Index < OldCoreData->FvCount; Index ++) {
if (OldCoreData->Fv[Index].PeimState != NULL) {
OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData->Fv[Index].PeimState - OldCoreData->HeapOffset;
}
@@ -339,10 +343,6 @@ PeiCore (
//
PrivateData.PpiData.PpiListPtrs = AllocateZeroPool (sizeof (PEI_PPI_LIST_POINTERS) * PcdGet32 (PcdPeiCoreMaxPpiSupported));
ASSERT (PrivateData.PpiData.PpiListPtrs != NULL);
- PrivateData.Fv = AllocateZeroPool (sizeof (PEI_CORE_FV_HANDLE) * PcdGet32 (PcdPeiCoreMaxFvSupported));
- ASSERT (PrivateData.Fv != NULL);
- PrivateData.UnknownFvInfo = AllocateZeroPool (sizeof (PEI_CORE_UNKNOW_FORMAT_FV_INFO) * PcdGet32 (PcdPeiCoreMaxFvSupported));
- ASSERT (PrivateData.UnknownFvInfo != NULL);
}
InitializePpiServices (&PrivateData, OldCoreData);
--
2.7.0.windows.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 4/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPpiSupported
2018-12-14 10:28 [PATCH 0/7] Remove PcdPeiCoreMaxXXX PCDs Star Zeng
` (2 preceding siblings ...)
2018-12-14 10:28 ` [PATCH 3/7] MdeModulePkg PeiCore: " Star Zeng
@ 2018-12-14 10:28 ` Star Zeng
2018-12-17 23:20 ` Chiu, Chasel
2018-12-18 2:24 ` Wang, Jian J
2018-12-14 10:28 ` [PATCH 5/7] OvmfPkg: Remove PcdPeiCoreMaxXXX PCDs' statement Star Zeng
` (2 subsequent siblings)
6 siblings, 2 replies; 23+ messages in thread
From: Star Zeng @ 2018-12-14 10:28 UTC (permalink / raw)
To: edk2-devel
Cc: Star Zeng, Jian J Wang, Hao Wu, Liming Gao, Ruiyu Ni,
Michael D Kinney, Nate DeSimone, Chasel Chiu
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405
Background as below.
Problem:
As static configuration from the PCDs, the binary PeiCore (for example
in FSP binary with dispatch mode) could not predict how many FVs,
Files or PPIs for different platforms.
Burden:
Platform developers need configure the PCDs accordingly for different
platforms.
To solve the problem and remove the burden, we can update code to
remove the using of PcdPeiCoreMaxFvSupported, PcdPeiCoreMaxPeimPerFv
and PcdPeiCoreMaxPpiSupported by extending buffer dynamically for FV,
File and PPI management.
This patch removes the using of PcdPeiCoreMaxPpiSupported in PeiCore.
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 8 +-
MdeModulePkg/Core/Pei/PeiMain.h | 59 +++--
MdeModulePkg/Core/Pei/PeiMain.inf | 1 -
MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 30 ++-
MdeModulePkg/Core/Pei/Ppi/Ppi.c | 355 ++++++++++++++------------
5 files changed, 254 insertions(+), 199 deletions(-)
diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
index 71440bab9488..55a300adbdb8 100644
--- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
@@ -1062,7 +1062,7 @@ PeiDispatcher (
// Process the Notify list and dispatch any notifies for
// newly installed PPIs.
//
- ProcessNotifyList (Private);
+ ProcessDispatchNotifyList (Private);
}
}
}
@@ -1209,10 +1209,10 @@ PeiDispatcher (
// Process the Notify list and dispatch any notifies for
// newly installed PPIs.
//
- ProcessNotifyList (Private);
+ ProcessDispatchNotifyList (Private);
//
- // Recheck SwitchStackSignal after ProcessNotifyList()
+ // Recheck SwitchStackSignal after ProcessDispatchNotifyList()
// in case PeiInstallPeiMemory() is done in a callback with
// EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH.
//
@@ -1253,7 +1253,7 @@ PeiDispatcher (
// Process the Notify list and dispatch any notifies for
// newly installed PPIs.
//
- ProcessNotifyList (Private);
+ ProcessDispatchNotifyList (Private);
}
}
}
diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h
index b248118087ad..c6c932c3e233 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.h
+++ b/MdeModulePkg/Core/Pei/PeiMain.h
@@ -66,37 +66,60 @@ typedef union {
} PEI_PPI_LIST_POINTERS;
///
-/// PPI database structure which contains two link: PpiList and NotifyList. PpiList
-/// is in head of PpiListPtrs array and notify is in end of PpiListPtrs.
+/// Number of PEI_PPI_LIST_POINTERS to grow by each time we run out of room
///
+#define PPI_GROWTH_STEP 64
+#define CALLBACK_NOTIFY_GROWTH_STEP 32
+#define DISPATCH_NOTIFY_GROWTH_STEP 8
+
typedef struct {
+ UINTN CurrentCount;
+ UINTN MaxCount;
+ UINTN LastDispatchedCount;
///
- /// index of end of PpiList link list.
+ /// MaxCount number of entries.
///
- INTN PpiListEnd;
+ PEI_PPI_LIST_POINTERS *PpiPtrs;
+} PEI_PPI_LIST;
+
+typedef struct {
+ UINTN CurrentCount;
+ UINTN MaxCount;
///
- /// index of end of notify link list.
+ /// MaxCount number of entries.
///
- INTN NotifyListEnd;
+ PEI_PPI_LIST_POINTERS *NotifyPtrs;
+} PEI_CALLBACK_NOTIFY_LIST;
+
+typedef struct {
+ UINTN CurrentCount;
+ UINTN MaxCount;
+ UINTN LastDispatchedCount;
///
- /// index of the dispatched notify list.
+ /// MaxCount number of entries.
///
- INTN DispatchListEnd;
+ PEI_PPI_LIST_POINTERS *NotifyPtrs;
+} PEI_DISPATCH_NOTIFY_LIST;
+
+///
+/// PPI database structure which contains three links:
+/// PpiList, CallbackNotifyList and DispatchNotifyList.
+///
+typedef struct {
///
- /// index of last installed Ppi description in PpiList link list.
+ /// PPI List.
///
- INTN LastDispatchedInstall;
+ PEI_PPI_LIST PpiList;
///
- /// index of last dispatched notify in Notify link list.
+ /// Notify List at dispatch level.
///
- INTN LastDispatchedNotify;
+ PEI_CALLBACK_NOTIFY_LIST CallbackNotifyList;
///
- /// Ppi database has the PcdPeiCoreMaxPpiSupported number of entries.
+ /// Notify List at callback level.
///
- PEI_PPI_LIST_POINTERS *PpiListPtrs;
+ PEI_DISPATCH_NOTIFY_LIST DispatchNotifyList;
} PEI_PPI_DATABASE;
-
//
// PEI_CORE_FV_HANDE.PeimState
// Do not change these values as there is code doing math to change states.
@@ -550,13 +573,13 @@ PeiNotifyPpi (
**/
VOID
-ProcessNotifyList (
+ProcessDispatchNotifyList (
IN PEI_CORE_INSTANCE *PrivateData
);
/**
- Dispatch notifications.
+ Process notifications.
@param PrivateData PeiCore's private data structure
@param NotifyType Type of notify to fire.
@@ -567,7 +590,7 @@ ProcessNotifyList (
**/
VOID
-DispatchNotify (
+ProcessNotify (
IN PEI_CORE_INSTANCE *PrivateData,
IN UINTN NotifyType,
IN INTN InstallStartIndex,
diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf b/MdeModulePkg/Core/Pei/PeiMain.inf
index dd41fe41bc89..140c4444b107 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.inf
+++ b/MdeModulePkg/Core/Pei/PeiMain.inf
@@ -104,7 +104,6 @@ [Ppis]
gEfiSecHobDataPpiGuid ## SOMETIMES_CONSUMES
[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreImageLoaderSearchTeSectionFirst ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFrameworkCompatibilitySupport ## CONSUMES
diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
index 4869bf18f005..4da80a8222bc 100644
--- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
+++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
@@ -190,7 +190,15 @@ PeiCore (
if (OldCoreData->CurrentFvFileHandles != NULL) {
OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles + OldCoreData->HeapOffset);
}
- OldCoreData->PpiData.PpiListPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiListPtrs + OldCoreData->HeapOffset);
+ if (OldCoreData->PpiData.PpiList.PpiPtrs != NULL) {
+ OldCoreData->PpiData.PpiList.PpiPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiList.PpiPtrs + OldCoreData->HeapOffset);
+ }
+ if (OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs != NULL) {
+ OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs + OldCoreData->HeapOffset);
+ }
+ if (OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs != NULL) {
+ OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs + OldCoreData->HeapOffset);
+ }
OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *) OldCoreData->Fv + OldCoreData->HeapOffset);
for (Index = 0; Index < OldCoreData->FvCount; Index ++) {
if (OldCoreData->Fv[Index].PeimState != NULL) {
@@ -210,7 +218,15 @@ PeiCore (
if (OldCoreData->CurrentFvFileHandles != NULL) {
OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles - OldCoreData->HeapOffset);
}
- OldCoreData->PpiData.PpiListPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiListPtrs - OldCoreData->HeapOffset);
+ if (OldCoreData->PpiData.PpiList.PpiPtrs != NULL) {
+ OldCoreData->PpiData.PpiList.PpiPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiList.PpiPtrs - OldCoreData->HeapOffset);
+ }
+ if (OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs != NULL) {
+ OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs - OldCoreData->HeapOffset);
+ }
+ if (OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs != NULL) {
+ OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs - OldCoreData->HeapOffset);
+ }
OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *) OldCoreData->Fv - OldCoreData->HeapOffset);
for (Index = 0; Index < OldCoreData->FvCount; Index ++) {
if (OldCoreData->Fv[Index].PeimState != NULL) {
@@ -337,14 +353,6 @@ PeiCore (
// Initialize PEI Core Services
//
InitializeMemoryServices (&PrivateData, SecCoreData, OldCoreData);
- if (OldCoreData == NULL) {
- //
- // Initialize PEI Core Private Data Buffer
- //
- PrivateData.PpiData.PpiListPtrs = AllocateZeroPool (sizeof (PEI_PPI_LIST_POINTERS) * PcdGet32 (PcdPeiCoreMaxPpiSupported));
- ASSERT (PrivateData.PpiData.PpiListPtrs != NULL);
- }
- InitializePpiServices (&PrivateData, OldCoreData);
//
// Update performance measurements
@@ -414,7 +422,7 @@ PeiCore (
//
// Process the Notify list and dispatch any notifies for the Memory Discovered PPI
//
- ProcessNotifyList (&PrivateData);
+ ProcessDispatchNotifyList (&PrivateData);
PERF_INMODULE_END ("DisMem");
}
diff --git a/MdeModulePkg/Core/Pei/Ppi/Ppi.c b/MdeModulePkg/Core/Pei/Ppi/Ppi.c
index 6f03858b8a94..907b2bbcf466 100644
--- a/MdeModulePkg/Core/Pei/Ppi/Ppi.c
+++ b/MdeModulePkg/Core/Pei/Ppi/Ppi.c
@@ -16,28 +16,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
/**
- Initialize PPI services.
-
- @param PrivateData Pointer to the PEI Core data.
- @param OldCoreData Pointer to old PEI Core data.
- NULL if being run in non-permament memory mode.
-
-**/
-VOID
-InitializePpiServices (
- IN PEI_CORE_INSTANCE *PrivateData,
- IN PEI_CORE_INSTANCE *OldCoreData
- )
-{
- if (OldCoreData == NULL) {
- PrivateData->PpiData.NotifyListEnd = PcdGet32 (PcdPeiCoreMaxPpiSupported)-1;
- PrivateData->PpiData.DispatchListEnd = PcdGet32 (PcdPeiCoreMaxPpiSupported)-1;
- PrivateData->PpiData.LastDispatchedNotify = PcdGet32 (PcdPeiCoreMaxPpiSupported)-1;
- }
-}
-
-/**
-
Migrate Pointer from the temporary memory to PEI installed memory.
@param Pointer Pointer to the Pointer needs to be converted.
@@ -192,14 +170,37 @@ ConvertPpiPointers (
{
UINT8 Index;
- for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxPpiSupported); Index++) {
- if (Index < PrivateData->PpiData.PpiListEnd || Index > PrivateData->PpiData.NotifyListEnd) {
- ConvertSinglePpiPointer (
- SecCoreData,
- PrivateData,
- &PrivateData->PpiData.PpiListPtrs[Index]
- );
- }
+ //
+ // Convert normal PPIs.
+ //
+ for (Index = 0; Index < PrivateData->PpiData.PpiList.CurrentCount; Index++) {
+ ConvertSinglePpiPointer (
+ SecCoreData,
+ PrivateData,
+ &PrivateData->PpiData.PpiList.PpiPtrs[Index]
+ );
+ }
+
+ //
+ // Convert Callback Notification PPIs.
+ //
+ for (Index = 0; Index < PrivateData->PpiData.CallbackNotifyList.CurrentCount; Index++) {
+ ConvertSinglePpiPointer (
+ SecCoreData,
+ PrivateData,
+ &PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index]
+ );
+ }
+
+ //
+ // Convert Dispatch Notification PPIs.
+ //
+ for (Index = 0; Index < PrivateData->PpiData.DispatchNotifyList.CurrentCount; Index++) {
+ ConvertSinglePpiPointer (
+ SecCoreData,
+ PrivateData,
+ &PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index]
+ );
}
}
@@ -228,10 +229,11 @@ InternalPeiInstallPpi (
IN BOOLEAN Single
)
{
- PEI_CORE_INSTANCE *PrivateData;
- INTN Index;
- INTN LastCallbackInstall;
-
+ PEI_CORE_INSTANCE *PrivateData;
+ PEI_PPI_LIST *PpiListPointer;
+ UINTN Index;
+ UINTN LastCount;
+ VOID *TempPtr;
if (PpiList == NULL) {
return EFI_INVALID_PARAMETER;
@@ -239,8 +241,9 @@ InternalPeiInstallPpi (
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
- Index = PrivateData->PpiData.PpiListEnd;
- LastCallbackInstall = Index;
+ PpiListPointer = &PrivateData->PpiData.PpiList;
+ Index = PpiListPointer->CurrentCount;
+ LastCount = Index;
//
// This is loop installs all PPI descriptors in the PpiList. It is terminated
@@ -250,27 +253,37 @@ InternalPeiInstallPpi (
for (;;) {
//
- // Since PpiData is used for NotifyList and PpiList, max resource
- // is reached if the Install reaches the NotifyList
- // PcdPeiCoreMaxPpiSupported can be set to a larger value in DSC to satisfy more PPI requirement.
- //
- if (Index == PrivateData->PpiData.NotifyListEnd + 1) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
// Check if it is a valid PPI.
// If not, rollback list to exclude all in this list.
// Try to indicate which item failed.
//
if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_PPI) == 0) {
- PrivateData->PpiData.PpiListEnd = LastCallbackInstall;
+ PpiListPointer->CurrentCount = LastCount;
DEBUG((EFI_D_ERROR, "ERROR -> InstallPpi: %g %p\n", PpiList->Guid, PpiList->Ppi));
return EFI_INVALID_PARAMETER;
}
+ if (Index == PpiListPointer->MaxCount) {
+ //
+ // Run out of room, grow the buffer.
+ //
+ TempPtr = AllocateZeroPool (
+ sizeof (PEI_PPI_LIST_POINTERS) * (PpiListPointer->MaxCount + PPI_GROWTH_STEP)
+ );
+ ASSERT (TempPtr != NULL);
+ CopyMem (
+ TempPtr,
+ PpiListPointer->PpiPtrs,
+ sizeof (PEI_PPI_LIST_POINTERS) * PpiListPointer->MaxCount
+ );
+ PpiListPointer->PpiPtrs = TempPtr;
+ PpiListPointer->MaxCount = PpiListPointer->MaxCount + PPI_GROWTH_STEP;
+ }
+
DEBUG((EFI_D_INFO, "Install PPI: %g\n", PpiList->Guid));
- PrivateData->PpiData.PpiListPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR*) PpiList;
- PrivateData->PpiData.PpiListEnd++;
+ PpiListPointer->PpiPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *) PpiList;
+ Index++;
+ PpiListPointer->CurrentCount++;
if (Single) {
//
@@ -284,23 +297,24 @@ InternalPeiInstallPpi (
//
break;
}
+ //
+ // Go to the next descriptor.
+ //
PpiList++;
- Index++;
}
//
- // Dispatch any callback level notifies for newly installed PPIs.
+ // Process any callback level notifies for newly installed PPIs.
//
- DispatchNotify (
+ ProcessNotify (
PrivateData,
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
- LastCallbackInstall,
- PrivateData->PpiData.PpiListEnd,
- PrivateData->PpiData.DispatchListEnd,
- PrivateData->PpiData.NotifyListEnd
+ LastCount,
+ PpiListPointer->CurrentCount,
+ 0,
+ PrivateData->PpiData.CallbackNotifyList.CurrentCount
);
-
return EFI_SUCCESS;
}
@@ -355,7 +369,7 @@ PeiReInstallPpi (
)
{
PEI_CORE_INSTANCE *PrivateData;
- INTN Index;
+ UINTN Index;
if ((OldPpi == NULL) || (NewPpi == NULL)) {
@@ -372,35 +386,33 @@ PeiReInstallPpi (
// Find the old PPI instance in the database. If we can not find it,
// return the EFI_NOT_FOUND error.
//
- for (Index = 0; Index < PrivateData->PpiData.PpiListEnd; Index++) {
- if (OldPpi == PrivateData->PpiData.PpiListPtrs[Index].Ppi) {
+ for (Index = 0; Index < PrivateData->PpiData.PpiList.CurrentCount; Index++) {
+ if (OldPpi == PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi) {
break;
}
}
- if (Index == PrivateData->PpiData.PpiListEnd) {
+ if (Index == PrivateData->PpiData.PpiList.CurrentCount) {
return EFI_NOT_FOUND;
}
//
- // Remove the old PPI from the database, add the new one.
+ // Replace the old PPI with the new one.
//
DEBUG((EFI_D_INFO, "Reinstall PPI: %g\n", NewPpi->Guid));
- ASSERT (Index < (INTN)(PcdGet32 (PcdPeiCoreMaxPpiSupported)));
- PrivateData->PpiData.PpiListPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *) NewPpi;
+ PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *) NewPpi;
//
- // Dispatch any callback level notifies for the newly installed PPI.
+ // Process any callback level notifies for the newly installed PPI.
//
- DispatchNotify (
+ ProcessNotify (
PrivateData,
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
Index,
Index+1,
- PrivateData->PpiData.DispatchListEnd,
- PrivateData->PpiData.NotifyListEnd
+ 0,
+ PrivateData->PpiData.CallbackNotifyList.CurrentCount
);
-
return EFI_SUCCESS;
}
@@ -430,10 +442,10 @@ PeiLocatePpi (
IN OUT VOID **Ppi
)
{
- PEI_CORE_INSTANCE *PrivateData;
- INTN Index;
- EFI_GUID *CheckGuid;
- EFI_PEI_PPI_DESCRIPTOR *TempPtr;
+ PEI_CORE_INSTANCE *PrivateData;
+ UINTN Index;
+ EFI_GUID *CheckGuid;
+ EFI_PEI_PPI_DESCRIPTOR *TempPtr;
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
@@ -441,8 +453,8 @@ PeiLocatePpi (
//
// Search the data base for the matching instance of the GUIDed PPI.
//
- for (Index = 0; Index < PrivateData->PpiData.PpiListEnd; Index++) {
- TempPtr = PrivateData->PpiData.PpiListPtrs[Index].Ppi;
+ for (Index = 0; Index < PrivateData->PpiData.PpiList.CurrentCount; Index++) {
+ TempPtr = PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi;
CheckGuid = TempPtr->Guid;
//
@@ -498,15 +510,14 @@ InternalPeiNotifyPpi (
IN BOOLEAN Single
)
{
- PEI_CORE_INSTANCE *PrivateData;
- INTN Index;
- INTN NotifyIndex;
- INTN LastCallbackNotify;
- EFI_PEI_NOTIFY_DESCRIPTOR *NotifyPtr;
- UINTN NotifyDispatchCount;
-
-
- NotifyDispatchCount = 0;
+ PEI_CORE_INSTANCE *PrivateData;
+ PEI_CALLBACK_NOTIFY_LIST *CallbackNotifyListPointer;
+ UINTN CallbackNotifyIndex;
+ UINTN LastCallbackNotifyCount;
+ PEI_DISPATCH_NOTIFY_LIST *DispatchNotifyListPointer;
+ UINTN DispatchNotifyIndex;
+ UINTN LastDispatchNotifyCount;
+ VOID *TempPtr;
if (NotifyList == NULL) {
return EFI_INVALID_PARAMETER;
@@ -514,8 +525,13 @@ InternalPeiNotifyPpi (
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
- Index = PrivateData->PpiData.NotifyListEnd;
- LastCallbackNotify = Index;
+ CallbackNotifyListPointer = &PrivateData->PpiData.CallbackNotifyList;
+ CallbackNotifyIndex = CallbackNotifyListPointer->CurrentCount;
+ LastCallbackNotifyCount = CallbackNotifyIndex;
+
+ DispatchNotifyListPointer = &PrivateData->PpiData.DispatchNotifyList;
+ DispatchNotifyIndex = DispatchNotifyListPointer->CurrentCount;
+ LastDispatchNotifyCount = DispatchNotifyIndex;
//
// This is loop installs all Notify descriptors in the NotifyList. It is
@@ -525,31 +541,59 @@ InternalPeiNotifyPpi (
for (;;) {
//
- // Since PpiData is used for NotifyList and InstallList, max resource
- // is reached if the Install reaches the PpiList
- // PcdPeiCoreMaxPpiSupported can be set to a larger value in DSC to satisfy more Notify PPIs requirement.
- //
- if (Index == PrivateData->PpiData.PpiListEnd - 1) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- //
// If some of the PPI data is invalid restore original Notify PPI database value
//
if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES) == 0) {
- PrivateData->PpiData.NotifyListEnd = LastCallbackNotify;
- DEBUG((EFI_D_ERROR, "ERROR -> InstallNotify: %g %p\n", NotifyList->Guid, NotifyList->Notify));
+ CallbackNotifyListPointer->CurrentCount = LastCallbackNotifyCount;
+ DispatchNotifyListPointer->CurrentCount = LastDispatchNotifyCount;
+ DEBUG((EFI_D_ERROR, "ERROR -> NotifyPpi: %g %p\n", NotifyList->Guid, NotifyList->Notify));
return EFI_INVALID_PARAMETER;
}
- if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH) != 0) {
- NotifyDispatchCount ++;
+ if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK) != 0) {
+ if (CallbackNotifyIndex == CallbackNotifyListPointer->MaxCount) {
+ //
+ // Run out of room, grow the buffer.
+ //
+ TempPtr = AllocateZeroPool (
+ sizeof (PEI_PPI_LIST_POINTERS) * (CallbackNotifyListPointer->MaxCount + CALLBACK_NOTIFY_GROWTH_STEP)
+ );
+ ASSERT (TempPtr != NULL);
+ CopyMem (
+ TempPtr,
+ CallbackNotifyListPointer->NotifyPtrs,
+ sizeof (PEI_PPI_LIST_POINTERS) * CallbackNotifyListPointer->MaxCount
+ );
+ CallbackNotifyListPointer->NotifyPtrs = TempPtr;
+ CallbackNotifyListPointer->MaxCount = CallbackNotifyListPointer->MaxCount + CALLBACK_NOTIFY_GROWTH_STEP;
+ }
+ CallbackNotifyListPointer->NotifyPtrs[CallbackNotifyIndex].Notify = (EFI_PEI_NOTIFY_DESCRIPTOR *) NotifyList;
+ CallbackNotifyIndex++;
+ CallbackNotifyListPointer->CurrentCount++;
+ } else {
+ if (DispatchNotifyIndex == DispatchNotifyListPointer->MaxCount) {
+ //
+ // Run out of room, grow the buffer.
+ //
+ TempPtr = AllocateZeroPool (
+ sizeof (PEI_PPI_LIST_POINTERS) * (DispatchNotifyListPointer->MaxCount + DISPATCH_NOTIFY_GROWTH_STEP)
+ );
+ ASSERT (TempPtr != NULL);
+ CopyMem (
+ TempPtr,
+ DispatchNotifyListPointer->NotifyPtrs,
+ sizeof (PEI_PPI_LIST_POINTERS) * DispatchNotifyListPointer->MaxCount
+ );
+ DispatchNotifyListPointer->NotifyPtrs = TempPtr;
+ DispatchNotifyListPointer->MaxCount = DispatchNotifyListPointer->MaxCount + DISPATCH_NOTIFY_GROWTH_STEP;
+ }
+ DispatchNotifyListPointer->NotifyPtrs[DispatchNotifyIndex].Notify = (EFI_PEI_NOTIFY_DESCRIPTOR *) NotifyList;
+ DispatchNotifyIndex++;
+ DispatchNotifyListPointer->CurrentCount++;
}
- PrivateData->PpiData.PpiListPtrs[Index].Notify = (EFI_PEI_NOTIFY_DESCRIPTOR *) NotifyList;
-
- PrivateData->PpiData.NotifyListEnd--;
DEBUG((EFI_D_INFO, "Register PPI Notify: %g\n", NotifyList->Guid));
+
if (Single) {
//
// Only single entry in the NotifyList.
@@ -563,41 +607,21 @@ InternalPeiNotifyPpi (
break;
}
//
- // Go the next descriptor. Remember the NotifyList moves down.
+ // Go to the next descriptor.
//
NotifyList++;
- Index--;
- }
-
- //
- // If there is Dispatch Notify PPI installed put them on the bottom
- //
- if (NotifyDispatchCount > 0) {
- for (NotifyIndex = LastCallbackNotify; NotifyIndex > PrivateData->PpiData.NotifyListEnd; NotifyIndex--) {
- if ((PrivateData->PpiData.PpiListPtrs[NotifyIndex].Notify->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH) != 0) {
- NotifyPtr = PrivateData->PpiData.PpiListPtrs[NotifyIndex].Notify;
-
- for (Index = NotifyIndex; Index < PrivateData->PpiData.DispatchListEnd; Index++){
- PrivateData->PpiData.PpiListPtrs[Index].Notify = PrivateData->PpiData.PpiListPtrs[Index + 1].Notify;
- }
- PrivateData->PpiData.PpiListPtrs[Index].Notify = NotifyPtr;
- PrivateData->PpiData.DispatchListEnd--;
- }
- }
-
- LastCallbackNotify -= NotifyDispatchCount;
}
//
- // Dispatch any callback level notifies for all previously installed PPIs.
+ // Process any callback level notifies for all previously installed PPIs.
//
- DispatchNotify (
+ ProcessNotify (
PrivateData,
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
0,
- PrivateData->PpiData.PpiListEnd,
- LastCallbackNotify,
- PrivateData->PpiData.NotifyListEnd
+ PrivateData->PpiData.PpiList.CurrentCount,
+ LastCallbackNotifyCount,
+ CallbackNotifyListPointer->CurrentCount
);
return EFI_SUCCESS;
@@ -627,7 +651,6 @@ PeiNotifyPpi (
return InternalPeiNotifyPpi (PeiServices, NotifyList, FALSE);
}
-
/**
Process the Notify List at dispatch level.
@@ -636,55 +659,56 @@ PeiNotifyPpi (
**/
VOID
-ProcessNotifyList (
+ProcessDispatchNotifyList (
IN PEI_CORE_INSTANCE *PrivateData
)
{
- INTN TempValue;
+ UINTN TempValue;
while (TRUE) {
//
// Check if the PEIM that was just dispatched resulted in any
// Notifies getting installed. If so, go process any dispatch
// level Notifies that match the previouly installed PPIs.
- // Use "while" instead of "if" since DispatchNotify can modify
- // DispatchListEnd (with NotifyPpi) so we have to iterate until the same.
+ // Use "while" instead of "if" since ProcessNotify can modify
+ // DispatchNotifyList.CurrentCount (with NotifyPpi) so we have
+ // to iterate until the same.
//
- while (PrivateData->PpiData.LastDispatchedNotify != PrivateData->PpiData.DispatchListEnd) {
- TempValue = PrivateData->PpiData.DispatchListEnd;
- DispatchNotify (
+ while (PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount != PrivateData->PpiData.DispatchNotifyList.CurrentCount) {
+ TempValue = PrivateData->PpiData.DispatchNotifyList.CurrentCount;
+ ProcessNotify (
PrivateData,
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH,
0,
- PrivateData->PpiData.LastDispatchedInstall,
- PrivateData->PpiData.LastDispatchedNotify,
- PrivateData->PpiData.DispatchListEnd
+ PrivateData->PpiData.PpiList.LastDispatchedCount,
+ PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount,
+ PrivateData->PpiData.DispatchNotifyList.CurrentCount
);
- PrivateData->PpiData.LastDispatchedNotify = TempValue;
+ PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount = TempValue;
}
-
//
// Check if the PEIM that was just dispatched resulted in any
// PPIs getting installed. If so, go process any dispatch
// level Notifies that match the installed PPIs.
- // Use "while" instead of "if" since DispatchNotify can modify
- // PpiListEnd (with InstallPpi) so we have to iterate until the same.
+ // Use "while" instead of "if" since ProcessNotify can modify
+ // PpiList.CurrentCount (with InstallPpi) so we have to iterate
+ // until the same.
//
- while (PrivateData->PpiData.LastDispatchedInstall != PrivateData->PpiData.PpiListEnd) {
- TempValue = PrivateData->PpiData.PpiListEnd;
- DispatchNotify (
+ while (PrivateData->PpiData.PpiList.LastDispatchedCount != PrivateData->PpiData.PpiList.CurrentCount) {
+ TempValue = PrivateData->PpiData.PpiList.CurrentCount;
+ ProcessNotify (
PrivateData,
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH,
- PrivateData->PpiData.LastDispatchedInstall,
- PrivateData->PpiData.PpiListEnd,
- PcdGet32 (PcdPeiCoreMaxPpiSupported)-1,
- PrivateData->PpiData.DispatchListEnd
+ PrivateData->PpiData.PpiList.LastDispatchedCount,
+ PrivateData->PpiData.PpiList.CurrentCount,
+ 0,
+ PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount
);
- PrivateData->PpiData.LastDispatchedInstall = TempValue;
+ PrivateData->PpiData.PpiList.LastDispatchedCount = TempValue;
}
- if (PrivateData->PpiData.LastDispatchedNotify == PrivateData->PpiData.DispatchListEnd) {
+ if (PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount == PrivateData->PpiData.DispatchNotifyList.CurrentCount) {
break;
}
}
@@ -693,7 +717,7 @@ ProcessNotifyList (
/**
- Dispatch notifications.
+ Process notifications.
@param PrivateData PeiCore's private data structure
@param NotifyType Type of notify to fire.
@@ -704,7 +728,7 @@ ProcessNotifyList (
**/
VOID
-DispatchNotify (
+ProcessNotify (
IN PEI_CORE_INSTANCE *PrivateData,
IN UINTN NotifyType,
IN INTN InstallStartIndex,
@@ -713,22 +737,23 @@ DispatchNotify (
IN INTN NotifyStopIndex
)
{
- INTN Index1;
- INTN Index2;
- EFI_GUID *SearchGuid;
- EFI_GUID *CheckGuid;
- EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;
-
- //
- // Remember that Installs moves up and Notifies moves down.
- //
- for (Index1 = NotifyStartIndex; Index1 > NotifyStopIndex; Index1--) {
- NotifyDescriptor = PrivateData->PpiData.PpiListPtrs[Index1].Notify;
+ INTN Index1;
+ INTN Index2;
+ EFI_GUID *SearchGuid;
+ EFI_GUID *CheckGuid;
+ EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;
+
+ for (Index1 = NotifyStartIndex; Index1 < NotifyStopIndex; Index1++) {
+ if (NotifyType == EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK) {
+ NotifyDescriptor = PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index1].Notify;
+ } else {
+ NotifyDescriptor = PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index1].Notify;
+ }
CheckGuid = NotifyDescriptor->Guid;
for (Index2 = InstallStartIndex; Index2 < InstallStopIndex; Index2++) {
- SearchGuid = PrivateData->PpiData.PpiListPtrs[Index2].Ppi->Guid;
+ SearchGuid = PrivateData->PpiData.PpiList.PpiPtrs[Index2].Ppi->Guid;
//
// Don't use CompareGuid function here for performance reasons.
// Instead we compare the GUID as INT32 at a time and branch
@@ -745,7 +770,7 @@ DispatchNotify (
NotifyDescriptor->Notify (
(EFI_PEI_SERVICES **) GetPeiServicesTablePointer (),
NotifyDescriptor,
- (PrivateData->PpiData.PpiListPtrs[Index2].Ppi)->Ppi
+ (PrivateData->PpiData.PpiList.PpiPtrs[Index2].Ppi)->Ppi
);
}
}
--
2.7.0.windows.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 5/7] OvmfPkg: Remove PcdPeiCoreMaxXXX PCDs' statement
2018-12-14 10:28 [PATCH 0/7] Remove PcdPeiCoreMaxXXX PCDs Star Zeng
` (3 preceding siblings ...)
2018-12-14 10:28 ` [PATCH 4/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPpiSupported Star Zeng
@ 2018-12-14 10:28 ` Star Zeng
2018-12-14 10:57 ` Ard Biesheuvel
2018-12-14 13:20 ` Laszlo Ersek
2018-12-14 10:28 ` [PATCH 6/7] Vlv2TbltDevicePkg: " Star Zeng
2018-12-14 10:28 ` [PATCH 7/7] MdeModulePkg: Remove PcdPeiCoreMaxXXX PCDs Star Zeng
6 siblings, 2 replies; 23+ messages in thread
From: Star Zeng @ 2018-12-14 10:28 UTC (permalink / raw)
To: edk2-devel
Cc: Star Zeng, Jordan Justen, Laszlo Ersek, Ard Biesheuvel,
Anthony Perard, Julien Grall
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405
The codes have been updated to not use PcdPeiCoreMaxFvSupported,
PcdPeiCoreMaxPeimPerFv and PcdPeiCoreMaxPpiSupported, so their
statement in platform DSC could be removed.
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Julien Grall <julien.grall@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
OvmfPkg/OvmfPkgIa32.dsc | 2 --
OvmfPkg/OvmfPkgIa32X64.dsc | 2 --
OvmfPkg/OvmfPkgX64.dsc | 2 --
3 files changed, 6 deletions(-)
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index eccf34d3d1cb..f61ad8105728 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -437,8 +437,6 @@ [PcdsFixedAtBuild]
gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported|6
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|32
!if ($(FD_SIZE_IN_KB) == 1024) || ($(FD_SIZE_IN_KB) == 2048)
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 4ac4faf5dc18..914f809d4bac 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -442,8 +442,6 @@ [PcdsFixedAtBuild]
gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported|6
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|32
!if ($(FD_SIZE_IN_KB) == 1024) || ($(FD_SIZE_IN_KB) == 2048)
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index ecd5db416c47..4605970f30c9 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -442,8 +442,6 @@ [PcdsFixedAtBuild]
gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported|6
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|32
!if ($(FD_SIZE_IN_KB) == 1024) || ($(FD_SIZE_IN_KB) == 2048)
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800
--
2.7.0.windows.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 6/7] Vlv2TbltDevicePkg: Remove PcdPeiCoreMaxXXX PCDs' statement
2018-12-14 10:28 [PATCH 0/7] Remove PcdPeiCoreMaxXXX PCDs Star Zeng
` (4 preceding siblings ...)
2018-12-14 10:28 ` [PATCH 5/7] OvmfPkg: Remove PcdPeiCoreMaxXXX PCDs' statement Star Zeng
@ 2018-12-14 10:28 ` Star Zeng
[not found] ` <A6DBF04CB9C4D045926EB50EBFFE5A2950865373@shsmsx102.ccr.corp.intel.com>
2018-12-14 10:28 ` [PATCH 7/7] MdeModulePkg: Remove PcdPeiCoreMaxXXX PCDs Star Zeng
6 siblings, 1 reply; 23+ messages in thread
From: Star Zeng @ 2018-12-14 10:28 UTC (permalink / raw)
To: edk2-devel; +Cc: Star Zeng, Zailiang Sun, Yi Qian
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405
The codes have been updated to not use PcdPeiCoreMaxFvSupported,
PcdPeiCoreMaxPeimPerFv and PcdPeiCoreMaxPpiSupported, so their
statement in platform DSC could be removed.
Cc: Zailiang Sun <zailiang.sun@intel.com>
Cc: Yi Qian <yi.qian@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 2 --
Vlv2TbltDevicePkg/PlatformPkgIA32.dsc | 2 --
Vlv2TbltDevicePkg/PlatformPkgX64.dsc | 2 --
3 files changed, 6 deletions(-)
diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
index f8ad29df5986..d43611550285 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
@@ -663,10 +663,8 @@ [PcdsFixedAtBuild.common]
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x400
gEfiCpuTokenSpaceGuid.PcdCpuIEDRamSize|0x400000
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize|0x10000
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|50
gEfiMdeModulePkgTokenSpaceGuid.PcdSrIovSupport|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport|FALSE
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported|128
gEfiCpuTokenSpaceGuid.PcdCpuSmmApSyncTimeout|1000
!if $(S4_ENABLE) == TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|TRUE
diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
index ca3b2ff90287..a33816c4d18b 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
@@ -663,10 +663,8 @@ [PcdsFixedAtBuild.common]
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x400
gEfiCpuTokenSpaceGuid.PcdCpuIEDRamSize|0x400000
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize|0x10000
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|50
gEfiMdeModulePkgTokenSpaceGuid.PcdSrIovSupport|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport|FALSE
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported|128
gEfiCpuTokenSpaceGuid.PcdCpuSmmApSyncTimeout|1000
!if $(S4_ENABLE) == TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|TRUE
diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
index 81f36bd73b28..b50731f25ffb 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
@@ -663,10 +663,8 @@ [PcdsFixedAtBuild.common]
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x400
gEfiCpuTokenSpaceGuid.PcdCpuIEDRamSize|0x400000
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize|0x10000
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|50
gEfiMdeModulePkgTokenSpaceGuid.PcdSrIovSupport|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport|FALSE
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported|128
gEfiCpuTokenSpaceGuid.PcdCpuSmmApSyncTimeout|1000
!if $(S4_ENABLE) == TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|TRUE
--
2.7.0.windows.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 7/7] MdeModulePkg: Remove PcdPeiCoreMaxXXX PCDs
2018-12-14 10:28 [PATCH 0/7] Remove PcdPeiCoreMaxXXX PCDs Star Zeng
` (5 preceding siblings ...)
2018-12-14 10:28 ` [PATCH 6/7] Vlv2TbltDevicePkg: " Star Zeng
@ 2018-12-14 10:28 ` Star Zeng
2018-12-17 23:19 ` Chiu, Chasel
6 siblings, 1 reply; 23+ messages in thread
From: Star Zeng @ 2018-12-14 10:28 UTC (permalink / raw)
To: edk2-devel
Cc: Star Zeng, Jian J Wang, Hao Wu, Liming Gao, Ruiyu Ni,
Michael D Kinney, Nate DeSimone, Chasel Chiu
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405
The codes have been updated to not use PcdPeiCoreMaxFvSupported,
PcdPeiCoreMaxPeimPerFv and PcdPeiCoreMaxPpiSupported.
The patch removes them in MdeModulePkg.dec.
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
MdeModulePkg/MdeModulePkg.dec | 13 -------------
MdeModulePkg/MdeModulePkg.uni | 12 ------------
2 files changed, 25 deletions(-)
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 0abacc1a901f..5585ce603596 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1053,23 +1053,10 @@ [PcdsFixedAtBuild, PcdsPatchableInModule]
# @Prompt VPD base address.
gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress|0x0|UINT32|0x00010010
- ## Maximum number of FV is supported by PeiCore's dispatching.
- # @Prompt Maximum number of FV supported by PeiCore.
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported|6|UINT32|0x00010030
-
- ## Maximum File count in every FV is supported by PeiCore's dispatching.
- # PeiCore supported File type includes PEIM, Combined PEIM and FV.
- # @Prompt Maximum File count per FV supported by PeiCore.
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|32|UINT32|0x00010031
-
## Maximum stack size for PeiCore.
# @Prompt Maximum stack size for PeiCore.
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize|0x20000|UINT32|0x00010032
- ## Maximum PPI count is supported by PeiCore's PPI database.
- # @Prompt Maximum PPI count supported by PeiCore.
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported|64|UINT32|0x00010033
-
## The maximum size of a single non-HwErr type variable.
# @Prompt Maximum variable size.
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x400|UINT32|0x30000003
diff --git a/MdeModulePkg/MdeModulePkg.uni b/MdeModulePkg/MdeModulePkg.uni
index 038e8485054b..fbea62dac8da 100644
--- a/MdeModulePkg/MdeModulePkg.uni
+++ b/MdeModulePkg/MdeModulePkg.uni
@@ -69,22 +69,10 @@
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdVpdBaseAddress_HELP #language en-US "VPD type PCD allows a developer to point to an absolute physical address PCDVPDBASEADDRESS to store PCD value."
-#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdPeiCoreMaxFvSupported_PROMPT #language en-US "Maximum number of FV supported by PeiCore"
-
-#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdPeiCoreMaxFvSupported_HELP #language en-US "Maximum number of FV is supported by PeiCore's dispatching."
-
-#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdPeiCoreMaxPeimPerFv_PROMPT #language en-US "Maximum File count per FV supported by PeiCore"
-
-#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdPeiCoreMaxPeimPerFv_HELP #language en-US "Maximum File count in every FV is supported by PeiCore's dispatching. PeiCore supported File type includes PEIM, Combined PEIM and FV."
-
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdPeiCoreMaxPeiStackSize_PROMPT #language en-US "Maximum stack size for PeiCore"
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdPeiCoreMaxPeiStackSize_HELP #language en-US "Maximum stack size for PeiCore."
-#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdPeiCoreMaxPpiSupported_PROMPT #language en-US "Maximum PPI count supported by PeiCore"
-
-#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdPeiCoreMaxPpiSupported_HELP #language en-US "Maximum PPI count is supported by PeiCore's PPI database."
-
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMaxVariableSize_PROMPT #language en-US "Maximum variable size"
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMaxVariableSize_HELP #language en-US "The maximum size of a single non-HwErr type variable."
--
2.7.0.windows.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH 5/7] OvmfPkg: Remove PcdPeiCoreMaxXXX PCDs' statement
2018-12-14 10:28 ` [PATCH 5/7] OvmfPkg: Remove PcdPeiCoreMaxXXX PCDs' statement Star Zeng
@ 2018-12-14 10:57 ` Ard Biesheuvel
2018-12-14 13:20 ` Laszlo Ersek
1 sibling, 0 replies; 23+ messages in thread
From: Ard Biesheuvel @ 2018-12-14 10:57 UTC (permalink / raw)
To: Star Zeng
Cc: edk2-devel@lists.01.org, Jordan Justen, Laszlo Ersek,
Anthony Perard, Julien Grall
On Fri, 14 Dec 2018 at 11:29, Star Zeng <star.zeng@intel.com> wrote:
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405
>
> The codes have been updated to not use PcdPeiCoreMaxFvSupported,
> PcdPeiCoreMaxPeimPerFv and PcdPeiCoreMaxPpiSupported, so their
> statement in platform DSC could be removed.
>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Anthony Perard <anthony.perard@citrix.com>
> Cc: Julien Grall <julien.grall@linaro.org>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> OvmfPkg/OvmfPkgIa32.dsc | 2 --
> OvmfPkg/OvmfPkgIa32X64.dsc | 2 --
> OvmfPkg/OvmfPkgX64.dsc | 2 --
> 3 files changed, 6 deletions(-)
>
> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> index eccf34d3d1cb..f61ad8105728 100644
> --- a/OvmfPkg/OvmfPkgIa32.dsc
> +++ b/OvmfPkg/OvmfPkgIa32.dsc
> @@ -437,8 +437,6 @@ [PcdsFixedAtBuild]
> gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
> gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
> gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10
> - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported|6
> - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|32
> !if ($(FD_SIZE_IN_KB) == 1024) || ($(FD_SIZE_IN_KB) == 2048)
> gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
> gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800
> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> index 4ac4faf5dc18..914f809d4bac 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> @@ -442,8 +442,6 @@ [PcdsFixedAtBuild]
> gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
> gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
> gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10
> - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported|6
> - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|32
> !if ($(FD_SIZE_IN_KB) == 1024) || ($(FD_SIZE_IN_KB) == 2048)
> gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
> gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800
> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index ecd5db416c47..4605970f30c9 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -442,8 +442,6 @@ [PcdsFixedAtBuild]
> gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
> gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
> gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10
> - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported|6
> - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|32
> !if ($(FD_SIZE_IN_KB) == 1024) || ($(FD_SIZE_IN_KB) == 2048)
> gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
> gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800
> --
> 2.7.0.windows.1
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 5/7] OvmfPkg: Remove PcdPeiCoreMaxXXX PCDs' statement
2018-12-14 10:28 ` [PATCH 5/7] OvmfPkg: Remove PcdPeiCoreMaxXXX PCDs' statement Star Zeng
2018-12-14 10:57 ` Ard Biesheuvel
@ 2018-12-14 13:20 ` Laszlo Ersek
1 sibling, 0 replies; 23+ messages in thread
From: Laszlo Ersek @ 2018-12-14 13:20 UTC (permalink / raw)
To: Star Zeng, edk2-devel
Cc: Jordan Justen, Ard Biesheuvel, Anthony Perard, Julien Grall
On 12/14/18 11:28, Star Zeng wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405
>
> The codes have been updated to not use PcdPeiCoreMaxFvSupported,
> PcdPeiCoreMaxPeimPerFv and PcdPeiCoreMaxPpiSupported, so their
> statement in platform DSC could be removed.
>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Anthony Perard <anthony.perard@citrix.com>
> Cc: Julien Grall <julien.grall@linaro.org>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng <star.zeng@intel.com>
> ---
> OvmfPkg/OvmfPkgIa32.dsc | 2 --
> OvmfPkg/OvmfPkgIa32X64.dsc | 2 --
> OvmfPkg/OvmfPkgX64.dsc | 2 --
> 3 files changed, 6 deletions(-)
>
> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> index eccf34d3d1cb..f61ad8105728 100644
> --- a/OvmfPkg/OvmfPkgIa32.dsc
> +++ b/OvmfPkg/OvmfPkgIa32.dsc
> @@ -437,8 +437,6 @@ [PcdsFixedAtBuild]
> gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
> gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
> gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10
> - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported|6
> - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|32
> !if ($(FD_SIZE_IN_KB) == 1024) || ($(FD_SIZE_IN_KB) == 2048)
> gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
> gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800
> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> index 4ac4faf5dc18..914f809d4bac 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> @@ -442,8 +442,6 @@ [PcdsFixedAtBuild]
> gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
> gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
> gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10
> - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported|6
> - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|32
> !if ($(FD_SIZE_IN_KB) == 1024) || ($(FD_SIZE_IN_KB) == 2048)
> gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
> gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800
> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index ecd5db416c47..4605970f30c9 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -442,8 +442,6 @@ [PcdsFixedAtBuild]
> gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
> gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
> gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10
> - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported|6
> - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|32
> !if ($(FD_SIZE_IN_KB) == 1024) || ($(FD_SIZE_IN_KB) == 2048)
> gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
> gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800
>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Thanks!
Laszlo
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 2/7] SecurityPkg Tcg(2)Pei: Remove the using of PcdPeiCoreMaxFvSupported
2018-12-14 10:28 ` [PATCH 2/7] SecurityPkg Tcg(2)Pei: Remove the using of PcdPeiCoreMaxFvSupported Star Zeng
@ 2018-12-17 5:06 ` Zhang, Chao B
0 siblings, 0 replies; 23+ messages in thread
From: Zhang, Chao B @ 2018-12-17 5:06 UTC (permalink / raw)
To: Zeng, Star, edk2-devel@lists.01.org; +Cc: Yao, Jiewen
Star :
Reviewed -by : Chao Zhang <chao.b.zhang@intel.com>
-----Original Message-----
From: Zeng, Star
Sent: Friday, December 14, 2018 6:29 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star <star.zeng@intel.com>; Zhang, Chao B <chao.b.zhang@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
Subject: [PATCH 2/7] SecurityPkg Tcg(2)Pei: Remove the using of PcdPeiCoreMaxFvSupported
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405
Background as below.
Problem:
As static configuration from the PCDs, the binary PeiCore (for example in FSP binary with dispatch mode) could not predict how many FVs, Files or PPIs for different platforms.
Burden:
Platform developers need configure the PCDs accordingly for different platforms.
To solve the problem and remove the burden, we can update PeiCore to remove the using of PcdPeiCoreMaxFvSupported, PcdPeiCoreMaxPeimPerFv and PcdPeiCoreMaxPpiSupported by extending buffer dynamically for FV, File and PPI management.
This patch removes the using of PcdPeiCoreMaxFvSupported in Tcg(2)Pei.
Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c | 59 +++++++++++++++++++++++--------------
SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf | 1 -
SecurityPkg/Tcg/TcgPei/TcgPei.c | 59 +++++++++++++++++++++++--------------
SecurityPkg/Tcg/TcgPei/TcgPei.inf | 1 -
4 files changed, 74 insertions(+), 46 deletions(-)
diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
index 09ef0c70a50b..152e3f737b56 100644
--- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
+++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
@@ -71,10 +71,17 @@ EFI_PEI_PPI_DESCRIPTOR mTpmInitializationDonePpiList = {
NULL
};
+//
+// Number of firmware blobs to grow by each time we run out of room //
+#define FIRMWARE_BLOB_GROWTH_STEP 4
+
EFI_PLATFORM_FIRMWARE_BLOB *mMeasuredBaseFvInfo;
+UINT32 mMeasuredMaxBaseFvIndex = 0;
UINT32 mMeasuredBaseFvIndex = 0;
EFI_PLATFORM_FIRMWARE_BLOB *mMeasuredChildFvInfo;
+UINT32 mMeasuredMaxChildFvIndex = 0;
UINT32 mMeasuredChildFvIndex = 0;
/**
@@ -615,13 +622,20 @@ MeasureFvImage (
//
// Add new FV into the measured FV list.
//
- ASSERT (mMeasuredBaseFvIndex < PcdGet32 (PcdPeiCoreMaxFvSupported));
- if (mMeasuredBaseFvIndex < PcdGet32 (PcdPeiCoreMaxFvSupported)) {
- mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobBase = FvBase;
- mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobLength = FvLength;
- mMeasuredBaseFvIndex++;
+ if (mMeasuredBaseFvIndex >= mMeasuredMaxBaseFvIndex) {
+ mMeasuredBaseFvInfo = ReallocatePool (
+ sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * mMeasuredMaxBaseFvIndex,
+ sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * (mMeasuredMaxBaseFvIndex + FIRMWARE_BLOB_GROWTH_STEP),
+ mMeasuredBaseFvInfo
+ );
+ ASSERT (mMeasuredBaseFvInfo != NULL);
+ mMeasuredMaxBaseFvIndex = mMeasuredMaxBaseFvIndex +
+ FIRMWARE_BLOB_GROWTH_STEP;
}
+ mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobBase = FvBase;
+ mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobLength = FvLength;
+ mMeasuredBaseFvIndex++;
+
return Status;
}
@@ -724,20 +738,26 @@ FirmwareVolmeInfoPpiNotifyCallback (
//
if (Fv->ParentFvName != NULL || Fv->ParentFileName != NULL ) {
- ASSERT (mMeasuredChildFvIndex < PcdGet32 (PcdPeiCoreMaxFvSupported));
- if (mMeasuredChildFvIndex < PcdGet32 (PcdPeiCoreMaxFvSupported)) {
- //
- // Check whether FV is in the measured child FV list.
- //
- for (Index = 0; Index < mMeasuredChildFvIndex; Index++) {
- if (mMeasuredChildFvInfo[Index].BlobBase == (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo) {
- return EFI_SUCCESS;
- }
+ if (mMeasuredChildFvIndex >= mMeasuredMaxChildFvIndex) {
+ mMeasuredChildFvInfo = ReallocatePool (
+ sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * mMeasuredMaxChildFvIndex,
+ sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * (mMeasuredMaxChildFvIndex + FIRMWARE_BLOB_GROWTH_STEP),
+ mMeasuredChildFvInfo
+ );
+ ASSERT (mMeasuredChildFvInfo != NULL);
+ mMeasuredMaxChildFvIndex = mMeasuredMaxChildFvIndex + FIRMWARE_BLOB_GROWTH_STEP;
+ }
+ //
+ // Check whether FV is in the measured child FV list.
+ //
+ for (Index = 0; Index < mMeasuredChildFvIndex; Index++) {
+ if (mMeasuredChildFvInfo[Index].BlobBase == (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo) {
+ return EFI_SUCCESS;
}
- mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobBase = (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo;
- mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobLength = Fv->FvInfoSize;
- mMeasuredChildFvIndex++;
}
+ mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobBase = (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo;
+ mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobLength = Fv->FvInfoSize;
+ mMeasuredChildFvIndex++;
return EFI_SUCCESS;
}
@@ -761,11 +781,6 @@ PeimEntryMP (
{
EFI_STATUS Status;
- mMeasuredBaseFvInfo = (EFI_PLATFORM_FIRMWARE_BLOB *) AllocateZeroPool (sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * PcdGet32 (PcdPeiCoreMaxFvSupported));
- ASSERT (mMeasuredBaseFvInfo != NULL);
- mMeasuredChildFvInfo = (EFI_PLATFORM_FIRMWARE_BLOB *) AllocateZeroPool (sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * PcdGet32 (PcdPeiCoreMaxFvSupported));
- ASSERT (mMeasuredChildFvInfo != NULL);
-
if (PcdGet8 (PcdTpm2ScrtmPolicy) == 1) {
Status = MeasureCRTMVersion ();
}
diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
index ea9dc759ab0a..2f3dcb7e812b 100644
--- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
+++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
@@ -83,7 +83,6 @@ [Pcd]
gEfiSecurityPkgTokenSpaceGuid.PcdTpm2InitializationPolicy ## CONSUMES
gEfiSecurityPkgTokenSpaceGuid.PcdTpm2SelfTestPolicy ## SOMETIMES_CONSUMES
gEfiSecurityPkgTokenSpaceGuid.PcdTpm2ScrtmPolicy ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported ## CONSUMES
gEfiSecurityPkgTokenSpaceGuid.PcdStatusCodeSubClassTpmDevice ## SOMETIMES_CONSUMES
## SOMETIMES_CONSUMES
## SOMETIMES_PRODUCES
diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.c b/SecurityPkg/Tcg/TcgPei/TcgPei.c index d07047580c5b..8b063c081b52 100644
--- a/SecurityPkg/Tcg/TcgPei/TcgPei.c
+++ b/SecurityPkg/Tcg/TcgPei/TcgPei.c
@@ -57,10 +57,17 @@ EFI_PEI_PPI_DESCRIPTOR mTpmInitializationDonePpiList = {
NULL
};
+//
+// Number of firmware blobs to grow by each time we run out of room //
+#define FIRMWARE_BLOB_GROWTH_STEP 4
+
EFI_PLATFORM_FIRMWARE_BLOB *mMeasuredBaseFvInfo;
+UINT32 mMeasuredMaxBaseFvIndex = 0;
UINT32 mMeasuredBaseFvIndex = 0;
EFI_PLATFORM_FIRMWARE_BLOB *mMeasuredChildFvInfo;
+UINT32 mMeasuredMaxChildFvIndex = 0;
UINT32 mMeasuredChildFvIndex = 0;
EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_PPI *mMeasurementExcludedFvPpi; @@ -424,13 +431,20 @@ MeasureFvImage (
//
// Add new FV into the measured FV list.
//
- ASSERT (mMeasuredBaseFvIndex < PcdGet32 (PcdPeiCoreMaxFvSupported));
- if (mMeasuredBaseFvIndex < PcdGet32 (PcdPeiCoreMaxFvSupported)) {
- mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobBase = FvBase;
- mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobLength = FvLength;
- mMeasuredBaseFvIndex++;
+ if (mMeasuredBaseFvIndex >= mMeasuredMaxBaseFvIndex) {
+ mMeasuredBaseFvInfo = ReallocatePool (
+ sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * mMeasuredMaxBaseFvIndex,
+ sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * (mMeasuredMaxBaseFvIndex + FIRMWARE_BLOB_GROWTH_STEP),
+ mMeasuredBaseFvInfo
+ );
+ ASSERT (mMeasuredBaseFvInfo != NULL);
+ mMeasuredMaxBaseFvIndex = mMeasuredMaxBaseFvIndex +
+ FIRMWARE_BLOB_GROWTH_STEP;
}
+ mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobBase = FvBase;
+ mMeasuredBaseFvInfo[mMeasuredBaseFvIndex].BlobLength = FvLength;
+ mMeasuredBaseFvIndex++;
+
return Status;
}
@@ -537,20 +551,26 @@ FirmwareVolmeInfoPpiNotifyCallback (
//
if (Fv->ParentFvName != NULL || Fv->ParentFileName != NULL ) {
- ASSERT (mMeasuredChildFvIndex < PcdGet32 (PcdPeiCoreMaxFvSupported));
- if (mMeasuredChildFvIndex < PcdGet32 (PcdPeiCoreMaxFvSupported)) {
- //
- // Check whether FV is in the measured child FV list.
- //
- for (Index = 0; Index < mMeasuredChildFvIndex; Index++) {
- if (mMeasuredChildFvInfo[Index].BlobBase == (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo) {
- return EFI_SUCCESS;
- }
+ if (mMeasuredChildFvIndex >= mMeasuredMaxChildFvIndex) {
+ mMeasuredChildFvInfo = ReallocatePool (
+ sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * mMeasuredMaxChildFvIndex,
+ sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * (mMeasuredMaxChildFvIndex + FIRMWARE_BLOB_GROWTH_STEP),
+ mMeasuredChildFvInfo
+ );
+ ASSERT (mMeasuredChildFvInfo != NULL);
+ mMeasuredMaxChildFvIndex = mMeasuredMaxChildFvIndex + FIRMWARE_BLOB_GROWTH_STEP;
+ }
+ //
+ // Check whether FV is in the measured child FV list.
+ //
+ for (Index = 0; Index < mMeasuredChildFvIndex; Index++) {
+ if (mMeasuredChildFvInfo[Index].BlobBase == (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo) {
+ return EFI_SUCCESS;
}
- mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobBase = (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo;
- mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobLength = Fv->FvInfoSize;
- mMeasuredChildFvIndex++;
}
+ mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobBase = (EFI_PHYSICAL_ADDRESS) (UINTN) Fv->FvInfo;
+ mMeasuredChildFvInfo[mMeasuredChildFvIndex].BlobLength = Fv->FvInfoSize;
+ mMeasuredChildFvIndex++;
return EFI_SUCCESS;
}
@@ -707,11 +727,6 @@ PeimEntryMP (
);
// Do not check status, because it is optional
- mMeasuredBaseFvInfo = (EFI_PLATFORM_FIRMWARE_BLOB *) AllocateZeroPool (sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * PcdGet32 (PcdPeiCoreMaxFvSupported));
- ASSERT (mMeasuredBaseFvInfo != NULL);
- mMeasuredChildFvInfo = (EFI_PLATFORM_FIRMWARE_BLOB *) AllocateZeroPool (sizeof (EFI_PLATFORM_FIRMWARE_BLOB) * PcdGet32 (PcdPeiCoreMaxFvSupported));
- ASSERT (mMeasuredChildFvInfo != NULL);
-
Status = Tpm12RequestUseTpm ();
if (EFI_ERROR (Status)) {
return Status;
diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.inf b/SecurityPkg/Tcg/TcgPei/TcgPei.inf
index 4c8a055c6ca5..8db93b908fe4 100644
--- a/SecurityPkg/Tcg/TcgPei/TcgPei.inf
+++ b/SecurityPkg/Tcg/TcgPei/TcgPei.inf
@@ -81,7 +81,6 @@ [Pcd]
gEfiSecurityPkgTokenSpaceGuid.PcdTpmInstanceGuid ## CONSUMES
gEfiSecurityPkgTokenSpaceGuid.PcdTpmInitializationPolicy ## CONSUMES
gEfiSecurityPkgTokenSpaceGuid.PcdTpmScrtmPolicy ## SOMETIMES_CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported ## CONSUMES
gEfiSecurityPkgTokenSpaceGuid.PcdStatusCodeSubClassTpmDevice ## SOMETIMES_CONSUMES
[Depex]
--
2.7.0.windows.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH 7/7] MdeModulePkg: Remove PcdPeiCoreMaxXXX PCDs
2018-12-14 10:28 ` [PATCH 7/7] MdeModulePkg: Remove PcdPeiCoreMaxXXX PCDs Star Zeng
@ 2018-12-17 23:19 ` Chiu, Chasel
0 siblings, 0 replies; 23+ messages in thread
From: Chiu, Chasel @ 2018-12-17 23:19 UTC (permalink / raw)
To: Zeng, Star, edk2-devel@lists.01.org
Cc: Wang, Jian J, Wu, Hao A, Gao, Liming, Ni, Ruiyu,
Kinney, Michael D, Desimone, Nathaniel L
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
-----Original Message-----
From: Zeng, Star
Sent: Friday, December 14, 2018 6:29 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star <star.zeng@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Liming <liming.gao@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Chiu, Chasel <chasel.chiu@intel.com>
Subject: [PATCH 7/7] MdeModulePkg: Remove PcdPeiCoreMaxXXX PCDs
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405
The codes have been updated to not use PcdPeiCoreMaxFvSupported, PcdPeiCoreMaxPeimPerFv and PcdPeiCoreMaxPpiSupported.
The patch removes them in MdeModulePkg.dec.
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
MdeModulePkg/MdeModulePkg.dec | 13 ------------- MdeModulePkg/MdeModulePkg.uni | 12 ------------
2 files changed, 25 deletions(-)
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 0abacc1a901f..5585ce603596 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1053,23 +1053,10 @@ [PcdsFixedAtBuild, PcdsPatchableInModule]
# @Prompt VPD base address.
gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress|0x0|UINT32|0x00010010
- ## Maximum number of FV is supported by PeiCore's dispatching.
- # @Prompt Maximum number of FV supported by PeiCore.
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported|6|UINT32|0x00010030
-
- ## Maximum File count in every FV is supported by PeiCore's dispatching.
- # PeiCore supported File type includes PEIM, Combined PEIM and FV.
- # @Prompt Maximum File count per FV supported by PeiCore.
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|32|UINT32|0x00010031
-
## Maximum stack size for PeiCore.
# @Prompt Maximum stack size for PeiCore.
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize|0x20000|UINT32|0x00010032
- ## Maximum PPI count is supported by PeiCore's PPI database.
- # @Prompt Maximum PPI count supported by PeiCore.
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported|64|UINT32|0x00010033
-
## The maximum size of a single non-HwErr type variable.
# @Prompt Maximum variable size.
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x400|UINT32|0x30000003
diff --git a/MdeModulePkg/MdeModulePkg.uni b/MdeModulePkg/MdeModulePkg.uni index 038e8485054b..fbea62dac8da 100644
--- a/MdeModulePkg/MdeModulePkg.uni
+++ b/MdeModulePkg/MdeModulePkg.uni
@@ -69,22 +69,10 @@
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdVpdBaseAddress_HELP #language en-US "VPD type PCD allows a developer to point to an absolute physical address PCDVPDBASEADDRESS to store PCD value."
-#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdPeiCoreMaxFvSupported_PROMPT #language en-US "Maximum number of FV supported by PeiCore"
-
-#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdPeiCoreMaxFvSupported_HELP #language en-US "Maximum number of FV is supported by PeiCore's dispatching."
-
-#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdPeiCoreMaxPeimPerFv_PROMPT #language en-US "Maximum File count per FV supported by PeiCore"
-
-#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdPeiCoreMaxPeimPerFv_HELP #language en-US "Maximum File count in every FV is supported by PeiCore's dispatching. PeiCore supported File type includes PEIM, Combined PEIM and FV."
-
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdPeiCoreMaxPeiStackSize_PROMPT #language en-US "Maximum stack size for PeiCore"
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdPeiCoreMaxPeiStackSize_HELP #language en-US "Maximum stack size for PeiCore."
-#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdPeiCoreMaxPpiSupported_PROMPT #language en-US "Maximum PPI count supported by PeiCore"
-
-#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdPeiCoreMaxPpiSupported_HELP #language en-US "Maximum PPI count is supported by PeiCore's PPI database."
-
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMaxVariableSize_PROMPT #language en-US "Maximum variable size"
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMaxVariableSize_HELP #language en-US "The maximum size of a single non-HwErr type variable."
--
2.7.0.windows.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 3/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxFvSupported
2018-12-14 10:28 ` [PATCH 3/7] MdeModulePkg PeiCore: " Star Zeng
@ 2018-12-17 23:20 ` Chiu, Chasel
2018-12-18 2:10 ` Wang, Jian J
1 sibling, 0 replies; 23+ messages in thread
From: Chiu, Chasel @ 2018-12-17 23:20 UTC (permalink / raw)
To: Zeng, Star, edk2-devel@lists.01.org
Cc: Wang, Jian J, Wu, Hao A, Gao, Liming, Ni, Ruiyu,
Kinney, Michael D, Desimone, Nathaniel L
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
-----Original Message-----
From: Zeng, Star
Sent: Friday, December 14, 2018 6:29 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star <star.zeng@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Liming <liming.gao@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Chiu, Chasel <chasel.chiu@intel.com>
Subject: [PATCH 3/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxFvSupported
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405
Background as below.
Problem:
As static configuration from the PCDs, the binary PeiCore (for example in FSP binary with dispatch mode) could not predict how many FVs, Files or PPIs for different platforms.
Burden:
Platform developers need configure the PCDs accordingly for different platforms.
To solve the problem and remove the burden, we can update PeiCore to remove the using of PcdPeiCoreMaxFvSupported, PcdPeiCoreMaxPeimPerFv and PcdPeiCoreMaxPpiSupported by extending buffer dynamically for FV, File and PPI management.
This patch removes the using of PcdPeiCoreMaxFvSupported in PeiCore.
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
MdeModulePkg/Core/Pei/FwVol/FwVol.c | 67 ++++++++++++++++++++++++++-------
MdeModulePkg/Core/Pei/PeiMain.h | 15 +++++++-
MdeModulePkg/Core/Pei/PeiMain.inf | 1 -
MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 16 ++++----
4 files changed, 75 insertions(+), 24 deletions(-)
diff --git a/MdeModulePkg/Core/Pei/FwVol/FwVol.c b/MdeModulePkg/Core/Pei/FwVol/FwVol.c
index 5629c9a1ce20..0a67b96bf1e3 100644
--- a/MdeModulePkg/Core/Pei/FwVol/FwVol.c
+++ b/MdeModulePkg/Core/Pei/FwVol/FwVol.c
@@ -503,6 +503,10 @@ PeiInitializeFv (
);
ASSERT_EFI_ERROR (Status);
+ PrivateData->Fv = AllocateZeroPool (sizeof (PEI_CORE_FV_HANDLE) *
+ FV_GROWTH_STEP); ASSERT (PrivateData->Fv != NULL);
+ PrivateData->MaxFvCount = FV_GROWTH_STEP;
+
//
// Update internal PEI_CORE_FV array.
//
@@ -560,6 +564,7 @@ FirmwareVolmeInfoPpiNotifyCallback (
VOID *DepexData;
BOOLEAN IsFvInfo2;
UINTN CurFvCount;
+ VOID *TempPtr;
Status = EFI_SUCCESS;
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices); @@ -626,10 +631,21 @@ FirmwareVolmeInfoPpiNotifyCallback (
}
}
- if (PrivateData->FvCount >= PcdGet32 (PcdPeiCoreMaxFvSupported)) {
- DEBUG ((EFI_D_ERROR, "The number of Fv Images (%d) exceed the max supported FVs (%d) in Pei", PrivateData->FvCount + 1, PcdGet32 (PcdPeiCoreMaxFvSupported)));
- DEBUG ((EFI_D_ERROR, "PcdPeiCoreMaxFvSupported value need be reconfigurated in DSC"));
- ASSERT (FALSE);
+ if (PrivateData->FvCount >= PrivateData->MaxFvCount) {
+ //
+ // Run out of room, grow the buffer.
+ //
+ TempPtr = AllocateZeroPool (
+ sizeof (PEI_CORE_FV_HANDLE) * (PrivateData->MaxFvCount + FV_GROWTH_STEP)
+ );
+ ASSERT (TempPtr != NULL);
+ CopyMem (
+ TempPtr,
+ PrivateData->Fv,
+ sizeof (PEI_CORE_FV_HANDLE) * PrivateData->MaxFvCount
+ );
+ PrivateData->Fv = TempPtr;
+ PrivateData->MaxFvCount = PrivateData->MaxFvCount +
+ FV_GROWTH_STEP;
}
//
@@ -2157,7 +2173,6 @@ FindNextCoreFvHandle (
}
}
- ASSERT (Private->FvCount <= PcdGet32 (PcdPeiCoreMaxFvSupported));
if (Instance >= Private->FvCount) {
return NULL;
}
@@ -2205,7 +2220,7 @@ PeiReinitializeFv (
//
// Fixup all FvPpi pointers for the implementation in flash to permanent memory.
//
- for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {
+ for (Index = 0; Index < PrivateData->FvCount; Index ++) {
if (PrivateData->Fv[Index].FvPpi == OldFfsFvPpi) {
PrivateData->Fv[Index].FvPpi = &mPeiFfs2FwVol.Fv;
}
@@ -2233,7 +2248,7 @@ PeiReinitializeFv (
//
// Fixup all FvPpi pointers for the implementation in flash to permanent memory.
//
- for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {
+ for (Index = 0; Index < PrivateData->FvCount; Index ++) {
if (PrivateData->Fv[Index].FvPpi == OldFfsFvPpi) {
PrivateData->Fv[Index].FvPpi = &mPeiFfs3FwVol.Fv;
}
@@ -2263,9 +2278,23 @@ AddUnknownFormatFvInfo (
)
{
PEI_CORE_UNKNOW_FORMAT_FV_INFO *NewUnknownFv;
+ VOID *TempPtr;
- if (PrivateData->UnknownFvInfoCount + 1 >= PcdGet32 (PcdPeiCoreMaxFvSupported)) {
- return EFI_OUT_OF_RESOURCES;
+ if (PrivateData->UnknownFvInfoCount >= PrivateData->MaxUnknownFvInfoCount) {
+ //
+ // Run out of room, grow the buffer.
+ //
+ TempPtr = AllocateZeroPool (
+ sizeof (PEI_CORE_UNKNOW_FORMAT_FV_INFO) * (PrivateData->MaxUnknownFvInfoCount + FV_GROWTH_STEP)
+ );
+ ASSERT (TempPtr != NULL);
+ CopyMem (
+ TempPtr,
+ PrivateData->UnknownFvInfo,
+ sizeof (PEI_CORE_UNKNOW_FORMAT_FV_INFO) * PrivateData->MaxUnknownFvInfoCount
+ );
+ PrivateData->UnknownFvInfo = TempPtr;
+ PrivateData->MaxUnknownFvInfoCount =
+ PrivateData->MaxUnknownFvInfoCount + FV_GROWTH_STEP;
}
NewUnknownFv = &PrivateData->UnknownFvInfo[PrivateData->UnknownFvInfoCount];
@@ -2368,6 +2397,7 @@ ThirdPartyFvPpiNotifyCallback (
EFI_PEI_FILE_HANDLE FileHandle;
VOID *DepexData;
UINTN CurFvCount;
+ VOID *TempPtr;
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
FvPpi = (EFI_PEI_FIRMWARE_VOLUME_PPI*) Ppi; @@ -2403,10 +2433,21 @@ ThirdPartyFvPpiNotifyCallback (
continue;
}
- if (PrivateData->FvCount >= PcdGet32 (PcdPeiCoreMaxFvSupported)) {
- DEBUG ((EFI_D_ERROR, "The number of Fv Images (%d) exceed the max supported FVs (%d) in Pei", PrivateData->FvCount + 1, PcdGet32 (PcdPeiCoreMaxFvSupported)));
- DEBUG ((EFI_D_ERROR, "PcdPeiCoreMaxFvSupported value need be reconfigurated in DSC"));
- ASSERT (FALSE);
+ if (PrivateData->FvCount >= PrivateData->MaxFvCount) {
+ //
+ // Run out of room, grow the buffer.
+ //
+ TempPtr = AllocateZeroPool (
+ sizeof (PEI_CORE_FV_HANDLE) * (PrivateData->MaxFvCount + FV_GROWTH_STEP)
+ );
+ ASSERT (TempPtr != NULL);
+ CopyMem (
+ TempPtr,
+ PrivateData->Fv,
+ sizeof (PEI_CORE_FV_HANDLE) * PrivateData->MaxFvCount
+ );
+ PrivateData->Fv = TempPtr;
+ PrivateData->MaxFvCount = PrivateData->MaxFvCount +
+ FV_GROWTH_STEP;
}
//
diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h index ab914c7d2e44..b248118087ad 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.h
+++ b/MdeModulePkg/Core/Pei/PeiMain.h
@@ -107,6 +107,11 @@ typedef struct {
#define PEIM_STATE_REGISTER_FOR_SHADOW 0x02
#define PEIM_STATE_DONE 0x03
+//
+// Number of FV instances to grow by each time we run out of room //
+#define FV_GROWTH_STEP 8
+
typedef struct {
EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi;
@@ -197,16 +202,22 @@ struct _PEI_CORE_INSTANCE {
UINTN FvCount;
///
- /// Pointer to the buffer with the PcdPeiCoreMaxFvSupported number of entries.
+ /// The max count of FVs which contains FFS and could be dispatched by PeiCore.
+ ///
+ UINTN MaxFvCount;
+
+ ///
+ /// Pointer to the buffer with the MaxFvCount number of entries.
/// Each entry is for one FV which contains FFS and could be dispatched by PeiCore.
///
PEI_CORE_FV_HANDLE *Fv;
///
- /// Pointer to the buffer with the PcdPeiCoreMaxFvSupported number of entries.
+ /// Pointer to the buffer with the MaxUnknownFvInfoCount number of entries.
/// Each entry is for one FV which could not be dispatched by PeiCore.
///
PEI_CORE_UNKNOW_FORMAT_FV_INFO *UnknownFvInfo;
+ UINTN MaxUnknownFvInfoCount;
UINTN UnknownFvInfoCount;
///
diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf b/MdeModulePkg/Core/Pei/PeiMain.inf
index d106c3606e97..dd41fe41bc89 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.inf
+++ b/MdeModulePkg/Core/Pei/PeiMain.inf
@@ -104,7 +104,6 @@ [Ppis]
gEfiSecHobDataPpiGuid ## SOMETIMES_CONSUMES
[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreImageLoaderSearchTeSectionFirst ## CONSUMES diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
index 52adefeb44b4..4869bf18f005 100644
--- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
+++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
@@ -184,13 +184,15 @@ PeiCore (
OldCoreData->CpuIo = &OldCoreData->ServiceTableShadow.CpuIo;
if (OldCoreData->HeapOffsetPositive) {
OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw + OldCoreData->HeapOffset);
- OldCoreData->UnknownFvInfo = (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData->UnknownFvInfo + OldCoreData->HeapOffset);
+ if (OldCoreData->UnknownFvInfo != NULL) {
+ OldCoreData->UnknownFvInfo = (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData->UnknownFvInfo + OldCoreData->HeapOffset);
+ }
if (OldCoreData->CurrentFvFileHandles != NULL) {
OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles + OldCoreData->HeapOffset);
}
OldCoreData->PpiData.PpiListPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiListPtrs + OldCoreData->HeapOffset);
OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *) OldCoreData->Fv + OldCoreData->HeapOffset);
- for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {
+ for (Index = 0; Index < OldCoreData->FvCount; Index ++) {
if (OldCoreData->Fv[Index].PeimState != NULL) {
OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData->Fv[Index].PeimState + OldCoreData->HeapOffset;
}
@@ -202,13 +204,15 @@ PeiCore (
OldCoreData->TempFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->TempFileHandles + OldCoreData->HeapOffset);
} else {
OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw - OldCoreData->HeapOffset);
- OldCoreData->UnknownFvInfo = (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData->UnknownFvInfo - OldCoreData->HeapOffset);
+ if (OldCoreData->UnknownFvInfo != NULL) {
+ OldCoreData->UnknownFvInfo = (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData->UnknownFvInfo - OldCoreData->HeapOffset);
+ }
if (OldCoreData->CurrentFvFileHandles != NULL) {
OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles - OldCoreData->HeapOffset);
}
OldCoreData->PpiData.PpiListPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiListPtrs - OldCoreData->HeapOffset);
OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *) OldCoreData->Fv - OldCoreData->HeapOffset);
- for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {
+ for (Index = 0; Index < OldCoreData->FvCount; Index ++) {
if (OldCoreData->Fv[Index].PeimState != NULL) {
OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData->Fv[Index].PeimState - OldCoreData->HeapOffset;
}
@@ -339,10 +343,6 @@ PeiCore (
//
PrivateData.PpiData.PpiListPtrs = AllocateZeroPool (sizeof (PEI_PPI_LIST_POINTERS) * PcdGet32 (PcdPeiCoreMaxPpiSupported));
ASSERT (PrivateData.PpiData.PpiListPtrs != NULL);
- PrivateData.Fv = AllocateZeroPool (sizeof (PEI_CORE_FV_HANDLE) * PcdGet32 (PcdPeiCoreMaxFvSupported));
- ASSERT (PrivateData.Fv != NULL);
- PrivateData.UnknownFvInfo = AllocateZeroPool (sizeof (PEI_CORE_UNKNOW_FORMAT_FV_INFO) * PcdGet32 (PcdPeiCoreMaxFvSupported));
- ASSERT (PrivateData.UnknownFvInfo != NULL);
}
InitializePpiServices (&PrivateData, OldCoreData);
--
2.7.0.windows.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH 4/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPpiSupported
2018-12-14 10:28 ` [PATCH 4/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPpiSupported Star Zeng
@ 2018-12-17 23:20 ` Chiu, Chasel
2018-12-18 2:24 ` Wang, Jian J
1 sibling, 0 replies; 23+ messages in thread
From: Chiu, Chasel @ 2018-12-17 23:20 UTC (permalink / raw)
To: Zeng, Star, edk2-devel@lists.01.org
Cc: Wang, Jian J, Wu, Hao A, Gao, Liming, Ni, Ruiyu,
Kinney, Michael D, Desimone, Nathaniel L
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
-----Original Message-----
From: Zeng, Star
Sent: Friday, December 14, 2018 6:29 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star <star.zeng@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Liming <liming.gao@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Chiu, Chasel <chasel.chiu@intel.com>
Subject: [PATCH 4/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPpiSupported
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405
Background as below.
Problem:
As static configuration from the PCDs, the binary PeiCore (for example in FSP binary with dispatch mode) could not predict how many FVs, Files or PPIs for different platforms.
Burden:
Platform developers need configure the PCDs accordingly for different platforms.
To solve the problem and remove the burden, we can update code to remove the using of PcdPeiCoreMaxFvSupported, PcdPeiCoreMaxPeimPerFv and PcdPeiCoreMaxPpiSupported by extending buffer dynamically for FV, File and PPI management.
This patch removes the using of PcdPeiCoreMaxPpiSupported in PeiCore.
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 8 +-
MdeModulePkg/Core/Pei/PeiMain.h | 59 +++--
MdeModulePkg/Core/Pei/PeiMain.inf | 1 -
MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 30 ++-
MdeModulePkg/Core/Pei/Ppi/Ppi.c | 355 ++++++++++++++------------
5 files changed, 254 insertions(+), 199 deletions(-)
diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
index 71440bab9488..55a300adbdb8 100644
--- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
@@ -1062,7 +1062,7 @@ PeiDispatcher (
// Process the Notify list and dispatch any notifies for
// newly installed PPIs.
//
- ProcessNotifyList (Private);
+ ProcessDispatchNotifyList (Private);
}
}
}
@@ -1209,10 +1209,10 @@ PeiDispatcher (
// Process the Notify list and dispatch any notifies for
// newly installed PPIs.
//
- ProcessNotifyList (Private);
+ ProcessDispatchNotifyList (Private);
//
- // Recheck SwitchStackSignal after ProcessNotifyList()
+ // Recheck SwitchStackSignal after
+ ProcessDispatchNotifyList()
// in case PeiInstallPeiMemory() is done in a callback with
// EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH.
//
@@ -1253,7 +1253,7 @@ PeiDispatcher (
// Process the Notify list and dispatch any notifies for
// newly installed PPIs.
//
- ProcessNotifyList (Private);
+ ProcessDispatchNotifyList (Private);
}
}
}
diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h index b248118087ad..c6c932c3e233 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.h
+++ b/MdeModulePkg/Core/Pei/PeiMain.h
@@ -66,37 +66,60 @@ typedef union {
} PEI_PPI_LIST_POINTERS;
///
-/// PPI database structure which contains two link: PpiList and NotifyList. PpiList -/// is in head of PpiListPtrs array and notify is in end of PpiListPtrs.
+/// Number of PEI_PPI_LIST_POINTERS to grow by each time we run out of
+room
///
+#define PPI_GROWTH_STEP 64
+#define CALLBACK_NOTIFY_GROWTH_STEP 32
+#define DISPATCH_NOTIFY_GROWTH_STEP 8
+
typedef struct {
+ UINTN CurrentCount;
+ UINTN MaxCount;
+ UINTN LastDispatchedCount;
///
- /// index of end of PpiList link list.
+ /// MaxCount number of entries.
///
- INTN PpiListEnd;
+ PEI_PPI_LIST_POINTERS *PpiPtrs;
+} PEI_PPI_LIST;
+
+typedef struct {
+ UINTN CurrentCount;
+ UINTN MaxCount;
///
- /// index of end of notify link list.
+ /// MaxCount number of entries.
///
- INTN NotifyListEnd;
+ PEI_PPI_LIST_POINTERS *NotifyPtrs;
+} PEI_CALLBACK_NOTIFY_LIST;
+
+typedef struct {
+ UINTN CurrentCount;
+ UINTN MaxCount;
+ UINTN LastDispatchedCount;
///
- /// index of the dispatched notify list.
+ /// MaxCount number of entries.
///
- INTN DispatchListEnd;
+ PEI_PPI_LIST_POINTERS *NotifyPtrs;
+} PEI_DISPATCH_NOTIFY_LIST;
+
+///
+/// PPI database structure which contains three links:
+/// PpiList, CallbackNotifyList and DispatchNotifyList.
+///
+typedef struct {
///
- /// index of last installed Ppi description in PpiList link list.
+ /// PPI List.
///
- INTN LastDispatchedInstall;
+ PEI_PPI_LIST PpiList;
///
- /// index of last dispatched notify in Notify link list.
+ /// Notify List at dispatch level.
///
- INTN LastDispatchedNotify;
+ PEI_CALLBACK_NOTIFY_LIST CallbackNotifyList;
///
- /// Ppi database has the PcdPeiCoreMaxPpiSupported number of entries.
+ /// Notify List at callback level.
///
- PEI_PPI_LIST_POINTERS *PpiListPtrs;
+ PEI_DISPATCH_NOTIFY_LIST DispatchNotifyList;
} PEI_PPI_DATABASE;
-
//
// PEI_CORE_FV_HANDE.PeimState
// Do not change these values as there is code doing math to change states.
@@ -550,13 +573,13 @@ PeiNotifyPpi (
**/
VOID
-ProcessNotifyList (
+ProcessDispatchNotifyList (
IN PEI_CORE_INSTANCE *PrivateData
);
/**
- Dispatch notifications.
+ Process notifications.
@param PrivateData PeiCore's private data structure
@param NotifyType Type of notify to fire.
@@ -567,7 +590,7 @@ ProcessNotifyList (
**/
VOID
-DispatchNotify (
+ProcessNotify (
IN PEI_CORE_INSTANCE *PrivateData,
IN UINTN NotifyType,
IN INTN InstallStartIndex,
diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf b/MdeModulePkg/Core/Pei/PeiMain.inf
index dd41fe41bc89..140c4444b107 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.inf
+++ b/MdeModulePkg/Core/Pei/PeiMain.inf
@@ -104,7 +104,6 @@ [Ppis]
gEfiSecHobDataPpiGuid ## SOMETIMES_CONSUMES
[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreImageLoaderSearchTeSectionFirst ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFrameworkCompatibilitySupport ## CONSUMES
diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
index 4869bf18f005..4da80a8222bc 100644
--- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
+++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
@@ -190,7 +190,15 @@ PeiCore (
if (OldCoreData->CurrentFvFileHandles != NULL) {
OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles + OldCoreData->HeapOffset);
}
- OldCoreData->PpiData.PpiListPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiListPtrs + OldCoreData->HeapOffset);
+ if (OldCoreData->PpiData.PpiList.PpiPtrs != NULL) {
+ OldCoreData->PpiData.PpiList.PpiPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiList.PpiPtrs + OldCoreData->HeapOffset);
+ }
+ if (OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs != NULL) {
+ OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs + OldCoreData->HeapOffset);
+ }
+ if (OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs != NULL) {
+ OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs + OldCoreData->HeapOffset);
+ }
OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *) OldCoreData->Fv + OldCoreData->HeapOffset);
for (Index = 0; Index < OldCoreData->FvCount; Index ++) {
if (OldCoreData->Fv[Index].PeimState != NULL) { @@ -210,7 +218,15 @@ PeiCore (
if (OldCoreData->CurrentFvFileHandles != NULL) {
OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles - OldCoreData->HeapOffset);
}
- OldCoreData->PpiData.PpiListPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiListPtrs - OldCoreData->HeapOffset);
+ if (OldCoreData->PpiData.PpiList.PpiPtrs != NULL) {
+ OldCoreData->PpiData.PpiList.PpiPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiList.PpiPtrs - OldCoreData->HeapOffset);
+ }
+ if (OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs != NULL) {
+ OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs - OldCoreData->HeapOffset);
+ }
+ if (OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs != NULL) {
+ OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs - OldCoreData->HeapOffset);
+ }
OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *) OldCoreData->Fv - OldCoreData->HeapOffset);
for (Index = 0; Index < OldCoreData->FvCount; Index ++) {
if (OldCoreData->Fv[Index].PeimState != NULL) { @@ -337,14 +353,6 @@ PeiCore (
// Initialize PEI Core Services
//
InitializeMemoryServices (&PrivateData, SecCoreData, OldCoreData);
- if (OldCoreData == NULL) {
- //
- // Initialize PEI Core Private Data Buffer
- //
- PrivateData.PpiData.PpiListPtrs = AllocateZeroPool (sizeof (PEI_PPI_LIST_POINTERS) * PcdGet32 (PcdPeiCoreMaxPpiSupported));
- ASSERT (PrivateData.PpiData.PpiListPtrs != NULL);
- }
- InitializePpiServices (&PrivateData, OldCoreData);
//
// Update performance measurements
@@ -414,7 +422,7 @@ PeiCore (
//
// Process the Notify list and dispatch any notifies for the Memory Discovered PPI
//
- ProcessNotifyList (&PrivateData);
+ ProcessDispatchNotifyList (&PrivateData);
PERF_INMODULE_END ("DisMem");
}
diff --git a/MdeModulePkg/Core/Pei/Ppi/Ppi.c b/MdeModulePkg/Core/Pei/Ppi/Ppi.c index 6f03858b8a94..907b2bbcf466 100644
--- a/MdeModulePkg/Core/Pei/Ppi/Ppi.c
+++ b/MdeModulePkg/Core/Pei/Ppi/Ppi.c
@@ -16,28 +16,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
/**
- Initialize PPI services.
-
- @param PrivateData Pointer to the PEI Core data.
- @param OldCoreData Pointer to old PEI Core data.
- NULL if being run in non-permament memory mode.
-
-**/
-VOID
-InitializePpiServices (
- IN PEI_CORE_INSTANCE *PrivateData,
- IN PEI_CORE_INSTANCE *OldCoreData
- )
-{
- if (OldCoreData == NULL) {
- PrivateData->PpiData.NotifyListEnd = PcdGet32 (PcdPeiCoreMaxPpiSupported)-1;
- PrivateData->PpiData.DispatchListEnd = PcdGet32 (PcdPeiCoreMaxPpiSupported)-1;
- PrivateData->PpiData.LastDispatchedNotify = PcdGet32 (PcdPeiCoreMaxPpiSupported)-1;
- }
-}
-
-/**
-
Migrate Pointer from the temporary memory to PEI installed memory.
@param Pointer Pointer to the Pointer needs to be converted.
@@ -192,14 +170,37 @@ ConvertPpiPointers ( {
UINT8 Index;
- for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxPpiSupported); Index++) {
- if (Index < PrivateData->PpiData.PpiListEnd || Index > PrivateData->PpiData.NotifyListEnd) {
- ConvertSinglePpiPointer (
- SecCoreData,
- PrivateData,
- &PrivateData->PpiData.PpiListPtrs[Index]
- );
- }
+ //
+ // Convert normal PPIs.
+ //
+ for (Index = 0; Index < PrivateData->PpiData.PpiList.CurrentCount; Index++) {
+ ConvertSinglePpiPointer (
+ SecCoreData,
+ PrivateData,
+ &PrivateData->PpiData.PpiList.PpiPtrs[Index]
+ );
+ }
+
+ //
+ // Convert Callback Notification PPIs.
+ //
+ for (Index = 0; Index < PrivateData->PpiData.CallbackNotifyList.CurrentCount; Index++) {
+ ConvertSinglePpiPointer (
+ SecCoreData,
+ PrivateData,
+ &PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index]
+ );
+ }
+
+ //
+ // Convert Dispatch Notification PPIs.
+ //
+ for (Index = 0; Index < PrivateData->PpiData.DispatchNotifyList.CurrentCount; Index++) {
+ ConvertSinglePpiPointer (
+ SecCoreData,
+ PrivateData,
+ &PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index]
+ );
}
}
@@ -228,10 +229,11 @@ InternalPeiInstallPpi (
IN BOOLEAN Single
)
{
- PEI_CORE_INSTANCE *PrivateData;
- INTN Index;
- INTN LastCallbackInstall;
-
+ PEI_CORE_INSTANCE *PrivateData;
+ PEI_PPI_LIST *PpiListPointer;
+ UINTN Index;
+ UINTN LastCount;
+ VOID *TempPtr;
if (PpiList == NULL) {
return EFI_INVALID_PARAMETER;
@@ -239,8 +241,9 @@ InternalPeiInstallPpi (
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
- Index = PrivateData->PpiData.PpiListEnd;
- LastCallbackInstall = Index;
+ PpiListPointer = &PrivateData->PpiData.PpiList; Index =
+ PpiListPointer->CurrentCount; LastCount = Index;
//
// This is loop installs all PPI descriptors in the PpiList. It is terminated @@ -250,27 +253,37 @@ InternalPeiInstallPpi (
for (;;) {
//
- // Since PpiData is used for NotifyList and PpiList, max resource
- // is reached if the Install reaches the NotifyList
- // PcdPeiCoreMaxPpiSupported can be set to a larger value in DSC to satisfy more PPI requirement.
- //
- if (Index == PrivateData->PpiData.NotifyListEnd + 1) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
// Check if it is a valid PPI.
// If not, rollback list to exclude all in this list.
// Try to indicate which item failed.
//
if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_PPI) == 0) {
- PrivateData->PpiData.PpiListEnd = LastCallbackInstall;
+ PpiListPointer->CurrentCount = LastCount;
DEBUG((EFI_D_ERROR, "ERROR -> InstallPpi: %g %p\n", PpiList->Guid, PpiList->Ppi));
return EFI_INVALID_PARAMETER;
}
+ if (Index == PpiListPointer->MaxCount) {
+ //
+ // Run out of room, grow the buffer.
+ //
+ TempPtr = AllocateZeroPool (
+ sizeof (PEI_PPI_LIST_POINTERS) * (PpiListPointer->MaxCount + PPI_GROWTH_STEP)
+ );
+ ASSERT (TempPtr != NULL);
+ CopyMem (
+ TempPtr,
+ PpiListPointer->PpiPtrs,
+ sizeof (PEI_PPI_LIST_POINTERS) * PpiListPointer->MaxCount
+ );
+ PpiListPointer->PpiPtrs = TempPtr;
+ PpiListPointer->MaxCount = PpiListPointer->MaxCount + PPI_GROWTH_STEP;
+ }
+
DEBUG((EFI_D_INFO, "Install PPI: %g\n", PpiList->Guid));
- PrivateData->PpiData.PpiListPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR*) PpiList;
- PrivateData->PpiData.PpiListEnd++;
+ PpiListPointer->PpiPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *) PpiList;
+ Index++;
+ PpiListPointer->CurrentCount++;
if (Single) {
//
@@ -284,23 +297,24 @@ InternalPeiInstallPpi (
//
break;
}
+ //
+ // Go to the next descriptor.
+ //
PpiList++;
- Index++;
}
//
- // Dispatch any callback level notifies for newly installed PPIs.
+ // Process any callback level notifies for newly installed PPIs.
//
- DispatchNotify (
+ ProcessNotify (
PrivateData,
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
- LastCallbackInstall,
- PrivateData->PpiData.PpiListEnd,
- PrivateData->PpiData.DispatchListEnd,
- PrivateData->PpiData.NotifyListEnd
+ LastCount,
+ PpiListPointer->CurrentCount,
+ 0,
+ PrivateData->PpiData.CallbackNotifyList.CurrentCount
);
-
return EFI_SUCCESS;
}
@@ -355,7 +369,7 @@ PeiReInstallPpi (
)
{
PEI_CORE_INSTANCE *PrivateData;
- INTN Index;
+ UINTN Index;
if ((OldPpi == NULL) || (NewPpi == NULL)) { @@ -372,35 +386,33 @@ PeiReInstallPpi (
// Find the old PPI instance in the database. If we can not find it,
// return the EFI_NOT_FOUND error.
//
- for (Index = 0; Index < PrivateData->PpiData.PpiListEnd; Index++) {
- if (OldPpi == PrivateData->PpiData.PpiListPtrs[Index].Ppi) {
+ for (Index = 0; Index < PrivateData->PpiData.PpiList.CurrentCount; Index++) {
+ if (OldPpi == PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi) {
break;
}
}
- if (Index == PrivateData->PpiData.PpiListEnd) {
+ if (Index == PrivateData->PpiData.PpiList.CurrentCount) {
return EFI_NOT_FOUND;
}
//
- // Remove the old PPI from the database, add the new one.
+ // Replace the old PPI with the new one.
//
DEBUG((EFI_D_INFO, "Reinstall PPI: %g\n", NewPpi->Guid));
- ASSERT (Index < (INTN)(PcdGet32 (PcdPeiCoreMaxPpiSupported)));
- PrivateData->PpiData.PpiListPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *) NewPpi;
+ PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi =
+ (EFI_PEI_PPI_DESCRIPTOR *) NewPpi;
//
- // Dispatch any callback level notifies for the newly installed PPI.
+ // Process any callback level notifies for the newly installed PPI.
//
- DispatchNotify (
+ ProcessNotify (
PrivateData,
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
Index,
Index+1,
- PrivateData->PpiData.DispatchListEnd,
- PrivateData->PpiData.NotifyListEnd
+ 0,
+ PrivateData->PpiData.CallbackNotifyList.CurrentCount
);
-
return EFI_SUCCESS;
}
@@ -430,10 +442,10 @@ PeiLocatePpi (
IN OUT VOID **Ppi
)
{
- PEI_CORE_INSTANCE *PrivateData;
- INTN Index;
- EFI_GUID *CheckGuid;
- EFI_PEI_PPI_DESCRIPTOR *TempPtr;
+ PEI_CORE_INSTANCE *PrivateData;
+ UINTN Index;
+ EFI_GUID *CheckGuid;
+ EFI_PEI_PPI_DESCRIPTOR *TempPtr;
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
@@ -441,8 +453,8 @@ PeiLocatePpi (
//
// Search the data base for the matching instance of the GUIDed PPI.
//
- for (Index = 0; Index < PrivateData->PpiData.PpiListEnd; Index++) {
- TempPtr = PrivateData->PpiData.PpiListPtrs[Index].Ppi;
+ for (Index = 0; Index < PrivateData->PpiData.PpiList.CurrentCount; Index++) {
+ TempPtr = PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi;
CheckGuid = TempPtr->Guid;
//
@@ -498,15 +510,14 @@ InternalPeiNotifyPpi (
IN BOOLEAN Single
)
{
- PEI_CORE_INSTANCE *PrivateData;
- INTN Index;
- INTN NotifyIndex;
- INTN LastCallbackNotify;
- EFI_PEI_NOTIFY_DESCRIPTOR *NotifyPtr;
- UINTN NotifyDispatchCount;
-
-
- NotifyDispatchCount = 0;
+ PEI_CORE_INSTANCE *PrivateData;
+ PEI_CALLBACK_NOTIFY_LIST *CallbackNotifyListPointer;
+ UINTN CallbackNotifyIndex;
+ UINTN LastCallbackNotifyCount;
+ PEI_DISPATCH_NOTIFY_LIST *DispatchNotifyListPointer;
+ UINTN DispatchNotifyIndex;
+ UINTN LastDispatchNotifyCount;
+ VOID *TempPtr;
if (NotifyList == NULL) {
return EFI_INVALID_PARAMETER;
@@ -514,8 +525,13 @@ InternalPeiNotifyPpi (
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
- Index = PrivateData->PpiData.NotifyListEnd;
- LastCallbackNotify = Index;
+ CallbackNotifyListPointer = &PrivateData->PpiData.CallbackNotifyList;
+ CallbackNotifyIndex = CallbackNotifyListPointer->CurrentCount;
+ LastCallbackNotifyCount = CallbackNotifyIndex;
+
+ DispatchNotifyListPointer = &PrivateData->PpiData.DispatchNotifyList;
+ DispatchNotifyIndex = DispatchNotifyListPointer->CurrentCount;
+ LastDispatchNotifyCount = DispatchNotifyIndex;
//
// This is loop installs all Notify descriptors in the NotifyList. It is @@ -525,31 +541,59 @@ InternalPeiNotifyPpi (
for (;;) {
//
- // Since PpiData is used for NotifyList and InstallList, max resource
- // is reached if the Install reaches the PpiList
- // PcdPeiCoreMaxPpiSupported can be set to a larger value in DSC to satisfy more Notify PPIs requirement.
- //
- if (Index == PrivateData->PpiData.PpiListEnd - 1) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- //
// If some of the PPI data is invalid restore original Notify PPI database value
//
if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES) == 0) {
- PrivateData->PpiData.NotifyListEnd = LastCallbackNotify;
- DEBUG((EFI_D_ERROR, "ERROR -> InstallNotify: %g %p\n", NotifyList->Guid, NotifyList->Notify));
+ CallbackNotifyListPointer->CurrentCount = LastCallbackNotifyCount;
+ DispatchNotifyListPointer->CurrentCount = LastDispatchNotifyCount;
+ DEBUG((EFI_D_ERROR, "ERROR -> NotifyPpi: %g %p\n",
+ NotifyList->Guid, NotifyList->Notify));
return EFI_INVALID_PARAMETER;
}
- if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH) != 0) {
- NotifyDispatchCount ++;
+ if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK) != 0) {
+ if (CallbackNotifyIndex == CallbackNotifyListPointer->MaxCount) {
+ //
+ // Run out of room, grow the buffer.
+ //
+ TempPtr = AllocateZeroPool (
+ sizeof (PEI_PPI_LIST_POINTERS) * (CallbackNotifyListPointer->MaxCount + CALLBACK_NOTIFY_GROWTH_STEP)
+ );
+ ASSERT (TempPtr != NULL);
+ CopyMem (
+ TempPtr,
+ CallbackNotifyListPointer->NotifyPtrs,
+ sizeof (PEI_PPI_LIST_POINTERS) * CallbackNotifyListPointer->MaxCount
+ );
+ CallbackNotifyListPointer->NotifyPtrs = TempPtr;
+ CallbackNotifyListPointer->MaxCount = CallbackNotifyListPointer->MaxCount + CALLBACK_NOTIFY_GROWTH_STEP;
+ }
+ CallbackNotifyListPointer->NotifyPtrs[CallbackNotifyIndex].Notify = (EFI_PEI_NOTIFY_DESCRIPTOR *) NotifyList;
+ CallbackNotifyIndex++;
+ CallbackNotifyListPointer->CurrentCount++;
+ } else {
+ if (DispatchNotifyIndex == DispatchNotifyListPointer->MaxCount) {
+ //
+ // Run out of room, grow the buffer.
+ //
+ TempPtr = AllocateZeroPool (
+ sizeof (PEI_PPI_LIST_POINTERS) * (DispatchNotifyListPointer->MaxCount + DISPATCH_NOTIFY_GROWTH_STEP)
+ );
+ ASSERT (TempPtr != NULL);
+ CopyMem (
+ TempPtr,
+ DispatchNotifyListPointer->NotifyPtrs,
+ sizeof (PEI_PPI_LIST_POINTERS) * DispatchNotifyListPointer->MaxCount
+ );
+ DispatchNotifyListPointer->NotifyPtrs = TempPtr;
+ DispatchNotifyListPointer->MaxCount = DispatchNotifyListPointer->MaxCount + DISPATCH_NOTIFY_GROWTH_STEP;
+ }
+ DispatchNotifyListPointer->NotifyPtrs[DispatchNotifyIndex].Notify = (EFI_PEI_NOTIFY_DESCRIPTOR *) NotifyList;
+ DispatchNotifyIndex++;
+ DispatchNotifyListPointer->CurrentCount++;
}
- PrivateData->PpiData.PpiListPtrs[Index].Notify = (EFI_PEI_NOTIFY_DESCRIPTOR *) NotifyList;
-
- PrivateData->PpiData.NotifyListEnd--;
DEBUG((EFI_D_INFO, "Register PPI Notify: %g\n", NotifyList->Guid));
+
if (Single) {
//
// Only single entry in the NotifyList.
@@ -563,41 +607,21 @@ InternalPeiNotifyPpi (
break;
}
//
- // Go the next descriptor. Remember the NotifyList moves down.
+ // Go to the next descriptor.
//
NotifyList++;
- Index--;
- }
-
- //
- // If there is Dispatch Notify PPI installed put them on the bottom
- //
- if (NotifyDispatchCount > 0) {
- for (NotifyIndex = LastCallbackNotify; NotifyIndex > PrivateData->PpiData.NotifyListEnd; NotifyIndex--) {
- if ((PrivateData->PpiData.PpiListPtrs[NotifyIndex].Notify->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH) != 0) {
- NotifyPtr = PrivateData->PpiData.PpiListPtrs[NotifyIndex].Notify;
-
- for (Index = NotifyIndex; Index < PrivateData->PpiData.DispatchListEnd; Index++){
- PrivateData->PpiData.PpiListPtrs[Index].Notify = PrivateData->PpiData.PpiListPtrs[Index + 1].Notify;
- }
- PrivateData->PpiData.PpiListPtrs[Index].Notify = NotifyPtr;
- PrivateData->PpiData.DispatchListEnd--;
- }
- }
-
- LastCallbackNotify -= NotifyDispatchCount;
}
//
- // Dispatch any callback level notifies for all previously installed PPIs.
+ // Process any callback level notifies for all previously installed PPIs.
//
- DispatchNotify (
+ ProcessNotify (
PrivateData,
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
0,
- PrivateData->PpiData.PpiListEnd,
- LastCallbackNotify,
- PrivateData->PpiData.NotifyListEnd
+ PrivateData->PpiData.PpiList.CurrentCount,
+ LastCallbackNotifyCount,
+ CallbackNotifyListPointer->CurrentCount
);
return EFI_SUCCESS;
@@ -627,7 +651,6 @@ PeiNotifyPpi (
return InternalPeiNotifyPpi (PeiServices, NotifyList, FALSE); }
-
/**
Process the Notify List at dispatch level.
@@ -636,55 +659,56 @@ PeiNotifyPpi (
**/
VOID
-ProcessNotifyList (
+ProcessDispatchNotifyList (
IN PEI_CORE_INSTANCE *PrivateData
)
{
- INTN TempValue;
+ UINTN TempValue;
while (TRUE) {
//
// Check if the PEIM that was just dispatched resulted in any
// Notifies getting installed. If so, go process any dispatch
// level Notifies that match the previouly installed PPIs.
- // Use "while" instead of "if" since DispatchNotify can modify
- // DispatchListEnd (with NotifyPpi) so we have to iterate until the same.
+ // Use "while" instead of "if" since ProcessNotify can modify
+ // DispatchNotifyList.CurrentCount (with NotifyPpi) so we have
+ // to iterate until the same.
//
- while (PrivateData->PpiData.LastDispatchedNotify != PrivateData->PpiData.DispatchListEnd) {
- TempValue = PrivateData->PpiData.DispatchListEnd;
- DispatchNotify (
+ while (PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount != PrivateData->PpiData.DispatchNotifyList.CurrentCount) {
+ TempValue = PrivateData->PpiData.DispatchNotifyList.CurrentCount;
+ ProcessNotify (
PrivateData,
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH,
0,
- PrivateData->PpiData.LastDispatchedInstall,
- PrivateData->PpiData.LastDispatchedNotify,
- PrivateData->PpiData.DispatchListEnd
+ PrivateData->PpiData.PpiList.LastDispatchedCount,
+ PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount,
+ PrivateData->PpiData.DispatchNotifyList.CurrentCount
);
- PrivateData->PpiData.LastDispatchedNotify = TempValue;
+ PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount =
+ TempValue;
}
-
//
// Check if the PEIM that was just dispatched resulted in any
// PPIs getting installed. If so, go process any dispatch
// level Notifies that match the installed PPIs.
- // Use "while" instead of "if" since DispatchNotify can modify
- // PpiListEnd (with InstallPpi) so we have to iterate until the same.
+ // Use "while" instead of "if" since ProcessNotify can modify
+ // PpiList.CurrentCount (with InstallPpi) so we have to iterate
+ // until the same.
//
- while (PrivateData->PpiData.LastDispatchedInstall != PrivateData->PpiData.PpiListEnd) {
- TempValue = PrivateData->PpiData.PpiListEnd;
- DispatchNotify (
+ while (PrivateData->PpiData.PpiList.LastDispatchedCount != PrivateData->PpiData.PpiList.CurrentCount) {
+ TempValue = PrivateData->PpiData.PpiList.CurrentCount;
+ ProcessNotify (
PrivateData,
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH,
- PrivateData->PpiData.LastDispatchedInstall,
- PrivateData->PpiData.PpiListEnd,
- PcdGet32 (PcdPeiCoreMaxPpiSupported)-1,
- PrivateData->PpiData.DispatchListEnd
+ PrivateData->PpiData.PpiList.LastDispatchedCount,
+ PrivateData->PpiData.PpiList.CurrentCount,
+ 0,
+ PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount
);
- PrivateData->PpiData.LastDispatchedInstall = TempValue;
+ PrivateData->PpiData.PpiList.LastDispatchedCount = TempValue;
}
- if (PrivateData->PpiData.LastDispatchedNotify == PrivateData->PpiData.DispatchListEnd) {
+ if (PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount ==
+ PrivateData->PpiData.DispatchNotifyList.CurrentCount) {
break;
}
}
@@ -693,7 +717,7 @@ ProcessNotifyList (
/**
- Dispatch notifications.
+ Process notifications.
@param PrivateData PeiCore's private data structure
@param NotifyType Type of notify to fire.
@@ -704,7 +728,7 @@ ProcessNotifyList (
**/
VOID
-DispatchNotify (
+ProcessNotify (
IN PEI_CORE_INSTANCE *PrivateData,
IN UINTN NotifyType,
IN INTN InstallStartIndex,
@@ -713,22 +737,23 @@ DispatchNotify (
IN INTN NotifyStopIndex
)
{
- INTN Index1;
- INTN Index2;
- EFI_GUID *SearchGuid;
- EFI_GUID *CheckGuid;
- EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;
-
- //
- // Remember that Installs moves up and Notifies moves down.
- //
- for (Index1 = NotifyStartIndex; Index1 > NotifyStopIndex; Index1--) {
- NotifyDescriptor = PrivateData->PpiData.PpiListPtrs[Index1].Notify;
+ INTN Index1;
+ INTN Index2;
+ EFI_GUID *SearchGuid;
+ EFI_GUID *CheckGuid;
+ EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;
+
+ for (Index1 = NotifyStartIndex; Index1 < NotifyStopIndex; Index1++) {
+ if (NotifyType == EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK) {
+ NotifyDescriptor = PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index1].Notify;
+ } else {
+ NotifyDescriptor = PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index1].Notify;
+ }
CheckGuid = NotifyDescriptor->Guid;
for (Index2 = InstallStartIndex; Index2 < InstallStopIndex; Index2++) {
- SearchGuid = PrivateData->PpiData.PpiListPtrs[Index2].Ppi->Guid;
+ SearchGuid =
+ PrivateData->PpiData.PpiList.PpiPtrs[Index2].Ppi->Guid;
//
// Don't use CompareGuid function here for performance reasons.
// Instead we compare the GUID as INT32 at a time and branch @@ -745,7 +770,7 @@ DispatchNotify (
NotifyDescriptor->Notify (
(EFI_PEI_SERVICES **) GetPeiServicesTablePointer (),
NotifyDescriptor,
- (PrivateData->PpiData.PpiListPtrs[Index2].Ppi)->Ppi
+
+ (PrivateData->PpiData.PpiList.PpiPtrs[Index2].Ppi)->Ppi
);
}
}
--
2.7.0.windows.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH 1/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPeimPerFv
2018-12-14 10:28 ` [PATCH 1/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPeimPerFv Star Zeng
@ 2018-12-17 23:20 ` Chiu, Chasel
2018-12-18 2:04 ` Wang, Jian J
1 sibling, 0 replies; 23+ messages in thread
From: Chiu, Chasel @ 2018-12-17 23:20 UTC (permalink / raw)
To: Zeng, Star, edk2-devel@lists.01.org
Cc: Wang, Jian J, Wu, Hao A, Gao, Liming, Ni, Ruiyu,
Kinney, Michael D, Desimone, Nathaniel L
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
-----Original Message-----
From: Zeng, Star
Sent: Friday, December 14, 2018 6:29 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star <star.zeng@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Liming <liming.gao@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Chiu, Chasel <chasel.chiu@intel.com>
Subject: [PATCH 1/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPeimPerFv
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405
Background as below.
Problem:
As static configuration from the PCDs, the binary PeiCore (for example in FSP binary with dispatch mode) could not predict how many FVs, Files or PPIs for different platforms.
Burden:
Platform developers need configure the PCDs accordingly for different platforms.
To solve the problem and remove the burden, we can update code to remove the using of PcdPeiCoreMaxFvSupported, PcdPeiCoreMaxPeimPerFv and PcdPeiCoreMaxPpiSupported by extending buffer dynamically for FV, File and PPI management.
This patch removes the using of PcdPeiCoreMaxPeimPerFv in PeiCore.
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 199 ++++++++++++++++----------
MdeModulePkg/Core/Pei/PeiMain.h | 17 ++-
MdeModulePkg/Core/Pei/PeiMain.inf | 1 -
MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 48 +++----
4 files changed, 157 insertions(+), 108 deletions(-)
diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
index f6bb35a5fe8d..71440bab9488 100644
--- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
@@ -41,7 +41,8 @@ DiscoverPeimsAndOrderWithApriori (
UINTN PeimCount;
EFI_GUID *Guid;
EFI_PEI_FILE_HANDLE *TempFileHandles;
- EFI_GUID *FileGuid;
+ EFI_GUID *TempFileGuid;
+ UINTN TempPeimCount;
EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi;
EFI_FV_FILE_INFO FileInfo;
@@ -51,38 +52,106 @@ DiscoverPeimsAndOrderWithApriori (
// Walk the FV and find all the PEIMs and the Apriori file.
//
AprioriFileHandle = NULL;
- Private->CurrentFvFileHandles[0] = NULL;
+ Private->CurrentFvFileHandles = NULL;
Guid = NULL;
- FileHandle = NULL;
- TempFileHandles = Private->FileHandles;
- FileGuid = Private->FileGuid;
//
- // If the current Fv has been scanned, directly get its cachable record.
+ // If the current Fv has been scanned, directly get its cached records.
//
- if (Private->Fv[Private->CurrentPeimFvCount].ScanFv) {
- CopyMem (Private->CurrentFvFileHandles, Private->Fv[Private->CurrentPeimFvCount].FvFileHandles, sizeof (EFI_PEI_FILE_HANDLE) * PcdGet32 (PcdPeiCoreMaxPeimPerFv));
+ if (CoreFileHandle->ScanFv) {
+ Private->CurrentFvFileHandles = CoreFileHandle->FvFileHandles;
return;
}
+ if (Private->TempPeimCount == 0) {
+ //
+ // Initialize the temp buffers.
+ //
+ Private->TempPeimCount = 32;
+ Private->TempFileHandles = AllocatePool (sizeof (EFI_PEI_FILE_HANDLE) * 32);
+ ASSERT (Private->TempFileHandles != NULL);
+ Private->TempFileGuid = AllocatePool (sizeof (EFI_GUID) * 32);
+ ASSERT (Private->TempFileGuid != NULL); } TempFileHandles =
+ Private->TempFileHandles;
+ TempFileGuid = Private->TempFileGuid;
+
//
- // Go ahead to scan this Fv, and cache FileHandles within it.
+ // Go ahead to scan this Fv, get PeimCount and cache FileHandles within it to TempFileHandles.
//
- Status = EFI_NOT_FOUND;
- for (PeimCount = 0; PeimCount <= PcdGet32 (PcdPeiCoreMaxPeimPerFv); PeimCount++) {
+ PeimCount = 0;
+ FileHandle = NULL;
+ TempPeimCount = 0;
+ do {
Status = FvPpi->FindFileByType (FvPpi, PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE, CoreFileHandle->FvHandle, &FileHandle);
- if (Status != EFI_SUCCESS || PeimCount == PcdGet32 (PcdPeiCoreMaxPeimPerFv)) {
- break;
+ if (!EFI_ERROR (Status)) {
+ if (TempPeimCount < Private->TempPeimCount) {
+ TempFileHandles[TempPeimCount] = FileHandle;
+ TempPeimCount++;
+ }
+ PeimCount++;
}
+ } while (!EFI_ERROR (Status));
- Private->CurrentFvFileHandles[PeimCount] = FileHandle;
+ DEBUG ((
+ DEBUG_INFO,
+ "%a(): Found 0x%x PEI FFS files in the %dth FV\n",
+ __FUNCTION__,
+ PeimCount,
+ Private->CurrentPeimFvCount
+ ));
+
+ if (PeimCount == 0) {
+ //
+ // No PEIM FFS file is found, set ScanFv flag and return.
+ //
+ CoreFileHandle->ScanFv = TRUE;
+ return;
+ }
+
+ if (PeimCount > Private->TempPeimCount) {
+ //
+ // The temp buffers are too small, allocate bigger ones.
+ //
+ TempFileHandles = AllocatePool (sizeof (EFI_PEI_FILE_HANDLE) * PeimCount);
+ ASSERT (TempFileHandles != NULL);
+ CopyMem (
+ TempFileHandles,
+ Private->TempFileHandles,
+ sizeof (EFI_PEI_FILE_HANDLE) * Private->TempPeimCount
+ );
+ Private->TempFileHandles = TempFileHandles;
+ TempFileGuid = AllocatePool (sizeof (EFI_GUID) * PeimCount);
+ ASSERT (TempFileGuid != NULL);
+ CopyMem (
+ TempFileGuid,
+ Private->TempFileGuid,
+ sizeof (EFI_GUID) * Private->TempPeimCount
+ );
+ Private->TempFileGuid = TempFileGuid;
+ Private->TempPeimCount = PeimCount;
}
//
- // Check whether the count of files exceeds the max support files in a FV image
- // If more files are required in a FV image, PcdPeiCoreMaxPeimPerFv can be set to a larger value in DSC file.
+ // Record PeimCount, allocate buffer for PeimState and FvFileHandles.
+ //
+ CoreFileHandle->PeimCount = PeimCount; CoreFileHandle->PeimState =
+ AllocateZeroPool (sizeof (UINT8) * PeimCount); ASSERT
+ (CoreFileHandle->PeimState != NULL); CoreFileHandle->FvFileHandles =
+ AllocateZeroPool (sizeof (EFI_PEI_FILE_HANDLE) * PeimCount); ASSERT
+ (CoreFileHandle->FvFileHandles != NULL);
+
//
- ASSERT ((Status != EFI_SUCCESS) || (PeimCount < PcdGet32 (PcdPeiCoreMaxPeimPerFv)));
+ // TempFileHandles may be not big enough in last scan.
+ // Go ahead to rescan this Fv, and cache remaining FileHandles within it to TempFileHandles.
+ //
+ FileHandle = TempFileHandles[TempPeimCount - 1]; for (;
+ TempPeimCount < PeimCount; TempPeimCount++) {
+ Status = FvPpi->FindFileByType (FvPpi, PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE, CoreFileHandle->FvHandle, &FileHandle);
+ ASSERT_EFI_ERROR (Status);
+
+ TempFileHandles[TempPeimCount] = FileHandle; }
//
// Get Apriori File handle
@@ -96,7 +165,7 @@ DiscoverPeimsAndOrderWithApriori (
Status = FvPpi->FindSectionByType (FvPpi, EFI_SECTION_RAW, AprioriFileHandle, (VOID **) &Apriori);
if (!EFI_ERROR (Status)) {
//
- // Calculate the number of PEIMs in the A Priori list
+ // Calculate the number of PEIMs in the Apriori file
//
Status = FvPpi->GetFileInfo (FvPpi, AprioriFileHandle, &FileInfo);
ASSERT_EFI_ERROR (Status);
@@ -113,71 +182,55 @@ DiscoverPeimsAndOrderWithApriori (
// Make an array of file name guids that matches the FileHandle array so we can convert
// quickly from file name to file handle
//
- Status = FvPpi->GetFileInfo (FvPpi, Private->CurrentFvFileHandles[Index], &FileInfo);
- CopyMem (&FileGuid[Index], &FileInfo.FileName, sizeof(EFI_GUID));
+ Status = FvPpi->GetFileInfo (FvPpi, TempFileHandles[Index], &FileInfo);
+ ASSERT_EFI_ERROR (Status);
+ CopyMem (&TempFileGuid[Index], &FileInfo.FileName,
+ sizeof(EFI_GUID));
}
//
- // Walk through FileGuid array to find out who is invalid PEIM guid in Apriori file.
- // Add available PEIMs in Apriori file into TempFileHandles array at first.
+ // Walk through TempFileGuid array to find out who is invalid PEIM guid in Apriori file.
+ // Add available PEIMs in Apriori file into FvFileHandles array.
//
- Index2 = 0;
- for (Index = 0; Index2 < Private->AprioriCount; Index++) {
- while (Index2 < Private->AprioriCount) {
- Guid = ScanGuid (FileGuid, PeimCount * sizeof (EFI_GUID), &Apriori[Index2++]);
- if (Guid != NULL) {
- break;
- }
- }
- if (Guid == NULL) {
- break;
- }
- PeimIndex = ((UINTN)Guid - (UINTN)&FileGuid[0])/sizeof (EFI_GUID);
- TempFileHandles[Index] = Private->CurrentFvFileHandles[PeimIndex];
+ Index = 0;
+ for (Index2 = 0; Index2 < Private->AprioriCount; Index2++) {
+ Guid = ScanGuid (TempFileGuid, PeimCount * sizeof (EFI_GUID), &Apriori[Index2]);
+ if (Guid != NULL) {
+ PeimIndex = ((UINTN)Guid - (UINTN)&TempFileGuid[0])/sizeof (EFI_GUID);
+ CoreFileHandle->FvFileHandles[Index++] =
+ TempFileHandles[PeimIndex];
- //
- // Since we have copied the file handle we can remove it from this list.
- //
- Private->CurrentFvFileHandles[PeimIndex] = NULL;
+ //
+ // Since we have copied the file handle we can remove it from this list.
+ //
+ TempFileHandles[PeimIndex] = NULL;
+ }
}
//
- // Update valid Aprioricount
+ // Update valid AprioriCount
//
Private->AprioriCount = Index;
//
// Add in any PEIMs not in the Apriori file
//
- for (;Index < PeimCount; Index++) {
- for (Index2 = 0; Index2 < PeimCount; Index2++) {
- if (Private->CurrentFvFileHandles[Index2] != NULL) {
- TempFileHandles[Index] = Private->CurrentFvFileHandles[Index2];
- Private->CurrentFvFileHandles[Index2] = NULL;
- break;
- }
+ for (Index2 = 0; Index2 < PeimCount; Index2++) {
+ if (TempFileHandles[Index2] != NULL) {
+ CoreFileHandle->FvFileHandles[Index++] = TempFileHandles[Index2];
+ TempFileHandles[Index2] = NULL;
}
}
- //
- //Index the end of array contains re-range Pei moudle.
- //
- TempFileHandles[Index] = NULL;
-
- //
- // Private->CurrentFvFileHandles is currently in PEIM in the FV order.
- // We need to update it to start with files in the A Priori list and
- // then the remaining files in PEIM order.
- //
- CopyMem (Private->CurrentFvFileHandles, TempFileHandles, sizeof (EFI_PEI_FILE_HANDLE) * PcdGet32 (PcdPeiCoreMaxPeimPerFv));
+ ASSERT (Index == PeimCount);
}
+ } else {
+ CopyMem (CoreFileHandle->FvFileHandles, TempFileHandles, sizeof
+ (EFI_PEI_FILE_HANDLE) * PeimCount);
}
+
//
- // Cache the current Fv File Handle. So that we don't have to scan the Fv again.
- // Instead, we can retrieve the file handles within this Fv from cachable data.
+ // The current Fv File Handles have been cached. So that we don't have to scan the Fv again.
+ // Instead, we can retrieve the file handles within this Fv from cached records.
//
- Private->Fv[Private->CurrentPeimFvCount].ScanFv = TRUE;
- CopyMem (Private->Fv[Private->CurrentPeimFvCount].FvFileHandles, Private->CurrentFvFileHandles, sizeof (EFI_PEI_FILE_HANDLE) * PcdGet32 (PcdPeiCoreMaxPeimPerFv));
-
+ CoreFileHandle->ScanFv = TRUE;
+ Private->CurrentFvFileHandles = CoreFileHandle->FvFileHandles;
}
//
@@ -977,7 +1030,7 @@ PeiDispatcher (
SaveCurrentFileHandle = Private->CurrentFileHandle;
for (Index1 = 0; Index1 < Private->FvCount; Index1++) {
- for (Index2 = 0; (Index2 < PcdGet32 (PcdPeiCoreMaxPeimPerFv)) && (Private->Fv[Index1].FvFileHandles[Index2] != NULL); Index2++) {
+ for (Index2 = 0; Index2 < Private->Fv[Index1].PeimCount;
+ Index2++) {
if (Private->Fv[Index1].PeimState[Index2] == PEIM_STATE_REGISTER_FOR_SHADOW) {
PeimFileHandle = Private->Fv[Index1].FvFileHandles[Index2];
Private->CurrentFileHandle = PeimFileHandle;
@@ -1063,7 +1116,7 @@ PeiDispatcher (
// Start to dispatch all modules within the current Fv.
//
for (PeimCount = Private->CurrentPeimCount;
- (PeimCount < PcdGet32 (PcdPeiCoreMaxPeimPerFv)) && (Private->CurrentFvFileHandles[PeimCount] != NULL);
+ PeimCount < Private->Fv[FvCount].PeimCount;
PeimCount++) {
Private->CurrentPeimCount = PeimCount;
PeimFileHandle = Private->CurrentFileHandle = Private->CurrentFvFileHandles[PeimCount];
@@ -1207,21 +1260,17 @@ PeiDispatcher (
}
//
- // We set to NULL here to optimize the 2nd entry to this routine after
- // memory is found. This reprevents rescanning of the FV. We set to
- // NULL here so we start at the begining of the next FV
+ // Before walking through the next FV, we should set them to NULL/0 to
+ // start at the begining of the next FV.
//
Private->CurrentFileHandle = NULL;
Private->CurrentPeimCount = 0;
- //
- // Before walking through the next FV,Private->CurrentFvFileHandles[]should set to NULL
- //
- SetMem (Private->CurrentFvFileHandles, sizeof (EFI_PEI_FILE_HANDLE) * PcdGet32 (PcdPeiCoreMaxPeimPerFv), 0);
+ Private->CurrentFvFileHandles = NULL;
}
//
- // Before making another pass, we should set Private->CurrentPeimFvCount =0 to go
- // through all the FV.
+ // Before making another pass, we should set it to 0 to
+ // go through all the FVs.
//
Private->CurrentPeimFvCount = 0;
@@ -1300,7 +1349,7 @@ DepexSatisfied (
if (PeimCount < Private->AprioriCount) {
//
- // If its in the A priori file then we set Depex to TRUE
+ // If it's in the Apriori file then we set Depex to TRUE
//
DEBUG ((DEBUG_DISPATCH, " RESULT = TRUE (Apriori)\n"));
return TRUE;
diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h index 6469436b8f79..ab914c7d2e44 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.h
+++ b/MdeModulePkg/Core/Pei/PeiMain.h
@@ -111,12 +111,13 @@ typedef struct {
EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi;
EFI_PEI_FV_HANDLE FvHandle;
+ UINTN PeimCount;
//
- // Ponter to the buffer with the PcdPeiCoreMaxPeimPerFv number of Entries.
+ // Ponter to the buffer with the PeimCount number of Entries.
//
UINT8 *PeimState;
//
- // Ponter to the buffer with the PcdPeiCoreMaxPeimPerFv number of Entries.
+ // Ponter to the buffer with the PeimCount number of Entries.
//
EFI_PEI_FILE_HANDLE *FvFileHandles;
BOOLEAN ScanFv;
@@ -209,7 +210,7 @@ struct _PEI_CORE_INSTANCE {
UINTN UnknownFvInfoCount;
///
- /// Pointer to the buffer with the PcdPeiCoreMaxPeimPerFv number of entries.
+ /// Pointer to the buffer FvFileHandlers in PEI_CORE_FV_HANDLE specified by CurrentPeimFvCount.
///
EFI_PEI_FILE_HANDLE *CurrentFvFileHandles;
UINTN AprioriCount;
@@ -256,14 +257,16 @@ struct _PEI_CORE_INSTANCE {
//
PE_COFF_LOADER_READ_FILE ShadowedImageRead;
+ UINTN TempPeimCount;
+
//
- // Pointer to the temp buffer with the PcdPeiCoreMaxPeimPerFv + 1 number of entries.
+ // Pointer to the temp buffer with the TempPeimCount number of entries.
//
- EFI_PEI_FILE_HANDLE *FileHandles;
+ EFI_PEI_FILE_HANDLE *TempFileHandles;
//
- // Pointer to the temp buffer with the PcdPeiCoreMaxPeimPerFv number of entries.
+ // Pointer to the temp buffer with the TempPeimCount number of entries.
//
- EFI_GUID *FileGuid;
+ EFI_GUID *TempFileGuid;
//
// Temp Memory Range is not covered by PeiTempMem and Stack.
diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf b/MdeModulePkg/Core/Pei/PeiMain.inf
index 4e1581a926d9..d106c3606e97 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.inf
+++ b/MdeModulePkg/Core/Pei/PeiMain.inf
@@ -105,7 +105,6 @@ [Ppis]
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreImageLoaderSearchTeSectionFirst ## CONSUMES diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
index e3a301dfe0f2..52adefeb44b4 100644
--- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
+++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
@@ -185,27 +185,39 @@ PeiCore (
if (OldCoreData->HeapOffsetPositive) {
OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw + OldCoreData->HeapOffset);
OldCoreData->UnknownFvInfo = (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData->UnknownFvInfo + OldCoreData->HeapOffset);
- OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles + OldCoreData->HeapOffset);
+ if (OldCoreData->CurrentFvFileHandles != NULL) {
+ OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles + OldCoreData->HeapOffset);
+ }
OldCoreData->PpiData.PpiListPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiListPtrs + OldCoreData->HeapOffset);
OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *) OldCoreData->Fv + OldCoreData->HeapOffset);
for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {
- OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData->Fv[Index].PeimState + OldCoreData->HeapOffset;
- OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles + OldCoreData->HeapOffset);
+ if (OldCoreData->Fv[Index].PeimState != NULL) {
+ OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData->Fv[Index].PeimState + OldCoreData->HeapOffset;
+ }
+ if (OldCoreData->Fv[Index].FvFileHandles != NULL) {
+ OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles + OldCoreData->HeapOffset);
+ }
}
- OldCoreData->FileGuid = (EFI_GUID *) ((UINT8 *) OldCoreData->FileGuid + OldCoreData->HeapOffset);
- OldCoreData->FileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->FileHandles + OldCoreData->HeapOffset);
+ OldCoreData->TempFileGuid = (EFI_GUID *) ((UINT8 *) OldCoreData->TempFileGuid + OldCoreData->HeapOffset);
+ OldCoreData->TempFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->TempFileHandles + OldCoreData->HeapOffset);
} else {
OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw - OldCoreData->HeapOffset);
OldCoreData->UnknownFvInfo = (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData->UnknownFvInfo - OldCoreData->HeapOffset);
- OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles - OldCoreData->HeapOffset);
+ if (OldCoreData->CurrentFvFileHandles != NULL) {
+ OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles - OldCoreData->HeapOffset);
+ }
OldCoreData->PpiData.PpiListPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiListPtrs - OldCoreData->HeapOffset);
OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *) OldCoreData->Fv - OldCoreData->HeapOffset);
for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {
- OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData->Fv[Index].PeimState - OldCoreData->HeapOffset;
- OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles - OldCoreData->HeapOffset);
+ if (OldCoreData->Fv[Index].PeimState != NULL) {
+ OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData->Fv[Index].PeimState - OldCoreData->HeapOffset;
+ }
+ if (OldCoreData->Fv[Index].FvFileHandles != NULL) {
+ OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles - OldCoreData->HeapOffset);
+ }
}
- OldCoreData->FileGuid = (EFI_GUID *) ((UINT8 *) OldCoreData->FileGuid - OldCoreData->HeapOffset);
- OldCoreData->FileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->FileHandles - OldCoreData->HeapOffset);
+ OldCoreData->TempFileGuid = (EFI_GUID *) ((UINT8 *) OldCoreData->TempFileGuid - OldCoreData->HeapOffset);
+ OldCoreData->TempFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->TempFileHandles - OldCoreData->HeapOffset);
}
//
@@ -320,7 +332,7 @@ PeiCore (
//
// Initialize PEI Core Services
//
- InitializeMemoryServices (&PrivateData, SecCoreData, OldCoreData);
+ InitializeMemoryServices (&PrivateData, SecCoreData, OldCoreData);
if (OldCoreData == NULL) {
//
// Initialize PEI Core Private Data Buffer @@ -329,22 +341,8 @@ PeiCore (
ASSERT (PrivateData.PpiData.PpiListPtrs != NULL);
PrivateData.Fv = AllocateZeroPool (sizeof (PEI_CORE_FV_HANDLE) * PcdGet32 (PcdPeiCoreMaxFvSupported));
ASSERT (PrivateData.Fv != NULL);
- PrivateData.Fv[0].PeimState = AllocateZeroPool (sizeof (UINT8) * PcdGet32 (PcdPeiCoreMaxPeimPerFv) * PcdGet32 (PcdPeiCoreMaxFvSupported));
- ASSERT (PrivateData.Fv[0].PeimState != NULL);
- PrivateData.Fv[0].FvFileHandles = AllocateZeroPool (sizeof (EFI_PEI_FILE_HANDLE) * PcdGet32 (PcdPeiCoreMaxPeimPerFv) * PcdGet32 (PcdPeiCoreMaxFvSupported));
- ASSERT (PrivateData.Fv[0].FvFileHandles != NULL);
- for (Index = 1; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {
- PrivateData.Fv[Index].PeimState = PrivateData.Fv[Index - 1].PeimState + PcdGet32 (PcdPeiCoreMaxPeimPerFv);
- PrivateData.Fv[Index].FvFileHandles = PrivateData.Fv[Index - 1].FvFileHandles + PcdGet32 (PcdPeiCoreMaxPeimPerFv);
- }
PrivateData.UnknownFvInfo = AllocateZeroPool (sizeof (PEI_CORE_UNKNOW_FORMAT_FV_INFO) * PcdGet32 (PcdPeiCoreMaxFvSupported));
ASSERT (PrivateData.UnknownFvInfo != NULL);
- PrivateData.CurrentFvFileHandles = AllocateZeroPool (sizeof (EFI_PEI_FILE_HANDLE) * PcdGet32 (PcdPeiCoreMaxPeimPerFv));
- ASSERT (PrivateData.CurrentFvFileHandles != NULL);
- PrivateData.FileGuid = AllocatePool (sizeof (EFI_GUID) * PcdGet32 (PcdPeiCoreMaxPeimPerFv));
- ASSERT (PrivateData.FileGuid != NULL);
- PrivateData.FileHandles = AllocatePool (sizeof (EFI_PEI_FILE_HANDLE) * (PcdGet32 (PcdPeiCoreMaxPeimPerFv) + 1));
- ASSERT (PrivateData.FileHandles != NULL);
}
InitializePpiServices (&PrivateData, OldCoreData);
--
2.7.0.windows.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH 1/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPeimPerFv
2018-12-14 10:28 ` [PATCH 1/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPeimPerFv Star Zeng
2018-12-17 23:20 ` Chiu, Chasel
@ 2018-12-18 2:04 ` Wang, Jian J
2018-12-18 2:45 ` Zeng, Star
1 sibling, 1 reply; 23+ messages in thread
From: Wang, Jian J @ 2018-12-18 2:04 UTC (permalink / raw)
To: Zeng, Star, edk2-devel@lists.01.org
Cc: Wu, Hao A, Gao, Liming, Ni, Ruiyu, Kinney, Michael D,
Desimone, Nathaniel L, Chiu, Chasel
Star,
Just one place which might need refine. Please see it below.
Regards,
Jian
> -----Original Message-----
> From: Zeng, Star
> Sent: Friday, December 14, 2018 6:29 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star <star.zeng@intel.com>; Wang, Jian J <jian.j.wang@intel.com>;
> Wu, Hao A <hao.a.wu@intel.com>; Gao, Liming <liming.gao@intel.com>; Ni,
> Ruiyu <ruiyu.ni@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>;
> Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Chiu, Chasel
> <chasel.chiu@intel.com>
> Subject: [PATCH 1/7] MdeModulePkg PeiCore: Remove the using of
> PcdPeiCoreMaxPeimPerFv
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405
>
> Background as below.
>
> Problem:
> As static configuration from the PCDs, the binary PeiCore (for example
> in FSP binary with dispatch mode) could not predict how many FVs,
> Files or PPIs for different platforms.
>
> Burden:
> Platform developers need configure the PCDs accordingly for different
> platforms.
>
> To solve the problem and remove the burden, we can update code to
> remove the using of PcdPeiCoreMaxFvSupported, PcdPeiCoreMaxPeimPerFv
> and PcdPeiCoreMaxPpiSupported by extending buffer dynamically for FV,
> File and PPI management.
>
> This patch removes the using of PcdPeiCoreMaxPeimPerFv in PeiCore.
>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao Wu <hao.a.wu@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng <star.zeng@intel.com>
> ---
> MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 199 ++++++++++++++++----
> ------
> MdeModulePkg/Core/Pei/PeiMain.h | 17 ++-
> MdeModulePkg/Core/Pei/PeiMain.inf | 1 -
> MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 48 +++----
> 4 files changed, 157 insertions(+), 108 deletions(-)
>
> diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> index f6bb35a5fe8d..71440bab9488 100644
> --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> @@ -41,7 +41,8 @@ DiscoverPeimsAndOrderWithApriori (
> UINTN PeimCount;
> EFI_GUID *Guid;
> EFI_PEI_FILE_HANDLE *TempFileHandles;
> - EFI_GUID *FileGuid;
> + EFI_GUID *TempFileGuid;
> + UINTN TempPeimCount;
> EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi;
> EFI_FV_FILE_INFO FileInfo;
>
> @@ -51,38 +52,106 @@ DiscoverPeimsAndOrderWithApriori (
> // Walk the FV and find all the PEIMs and the Apriori file.
> //
> AprioriFileHandle = NULL;
> - Private->CurrentFvFileHandles[0] = NULL;
> + Private->CurrentFvFileHandles = NULL;
> Guid = NULL;
> - FileHandle = NULL;
> - TempFileHandles = Private->FileHandles;
> - FileGuid = Private->FileGuid;
>
> //
> - // If the current Fv has been scanned, directly get its cachable record.
> + // If the current Fv has been scanned, directly get its cached records.
> //
> - if (Private->Fv[Private->CurrentPeimFvCount].ScanFv) {
> - CopyMem (Private->CurrentFvFileHandles, Private->Fv[Private-
> >CurrentPeimFvCount].FvFileHandles, sizeof (EFI_PEI_FILE_HANDLE) * PcdGet32
> (PcdPeiCoreMaxPeimPerFv));
> + if (CoreFileHandle->ScanFv) {
> + Private->CurrentFvFileHandles = CoreFileHandle->FvFileHandles;
> return;
> }
>
> + if (Private->TempPeimCount == 0) {
> + //
> + // Initialize the temp buffers.
> + //
> + Private->TempPeimCount = 32;
> + Private->TempFileHandles = AllocatePool (sizeof (EFI_PEI_FILE_HANDLE) *
> 32);
> + ASSERT (Private->TempFileHandles != NULL);
> + Private->TempFileGuid = AllocatePool (sizeof (EFI_GUID) * 32);
> + ASSERT (Private->TempFileGuid != NULL);
> + }
> + TempFileHandles = Private->TempFileHandles;
> + TempFileGuid = Private->TempFileGuid;
> +
> //
> - // Go ahead to scan this Fv, and cache FileHandles within it.
> + // Go ahead to scan this Fv, get PeimCount and cache FileHandles within it to
> TempFileHandles.
> //
> - Status = EFI_NOT_FOUND;
> - for (PeimCount = 0; PeimCount <= PcdGet32 (PcdPeiCoreMaxPeimPerFv);
> PeimCount++) {
> + PeimCount = 0;
> + FileHandle = NULL;
> + TempPeimCount = 0;
> + do {
> Status = FvPpi->FindFileByType (FvPpi,
> PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE, CoreFileHandle->FvHandle,
> &FileHandle);
> - if (Status != EFI_SUCCESS || PeimCount == PcdGet32
> (PcdPeiCoreMaxPeimPerFv)) {
> - break;
> + if (!EFI_ERROR (Status)) {
> + if (TempPeimCount < Private->TempPeimCount) {
> + TempFileHandles[TempPeimCount] = FileHandle;
> + TempPeimCount++;
> + }
> + PeimCount++;
> }
> + } while (!EFI_ERROR (Status));
>
> - Private->CurrentFvFileHandles[PeimCount] = FileHandle;
> + DEBUG ((
> + DEBUG_INFO,
> + "%a(): Found 0x%x PEI FFS files in the %dth FV\n",
> + __FUNCTION__,
> + PeimCount,
> + Private->CurrentPeimFvCount
> + ));
> +
> + if (PeimCount == 0) {
> + //
> + // No PEIM FFS file is found, set ScanFv flag and return.
> + //
> + CoreFileHandle->ScanFv = TRUE;
> + return;
> + }
> +
> + if (PeimCount > Private->TempPeimCount) {
> + //
> + // The temp buffers are too small, allocate bigger ones.
> + //
> + TempFileHandles = AllocatePool (sizeof (EFI_PEI_FILE_HANDLE) *
> PeimCount);
> + ASSERT (TempFileHandles != NULL);
> + CopyMem (
> + TempFileHandles,
> + Private->TempFileHandles,
> + sizeof (EFI_PEI_FILE_HANDLE) * Private->TempPeimCount
> + );
> + Private->TempFileHandles = TempFileHandles;
> + TempFileGuid = AllocatePool (sizeof (EFI_GUID) * PeimCount);
> + ASSERT (TempFileGuid != NULL);
> + CopyMem (
> + TempFileGuid,
> + Private->TempFileGuid,
> + sizeof (EFI_GUID) * Private->TempPeimCount
> + );
> + Private->TempFileGuid = TempFileGuid;
> + Private->TempPeimCount = PeimCount;
> }
>
> //
> - // Check whether the count of files exceeds the max support files in a FV
> image
> - // If more files are required in a FV image, PcdPeiCoreMaxPeimPerFv can be
> set to a larger value in DSC file.
> + // Record PeimCount, allocate buffer for PeimState and FvFileHandles.
> + //
> + CoreFileHandle->PeimCount = PeimCount;
> + CoreFileHandle->PeimState = AllocateZeroPool (sizeof (UINT8) * PeimCount);
> + ASSERT (CoreFileHandle->PeimState != NULL);
> + CoreFileHandle->FvFileHandles = AllocateZeroPool (sizeof
> (EFI_PEI_FILE_HANDLE) * PeimCount);
> + ASSERT (CoreFileHandle->FvFileHandles != NULL);
> +
> //
> - ASSERT ((Status != EFI_SUCCESS) || (PeimCount < PcdGet32
> (PcdPeiCoreMaxPeimPerFv)));
> + // TempFileHandles may be not big enough in last scan.
> + // Go ahead to rescan this Fv, and cache remaining FileHandles within it to
> TempFileHandles.
> + //
> + FileHandle = TempFileHandles[TempPeimCount - 1];
> + for (; TempPeimCount < PeimCount; TempPeimCount++) {
> + Status = FvPpi->FindFileByType (FvPpi,
> PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE, CoreFileHandle->FvHandle,
> &FileHandle);
> + ASSERT_EFI_ERROR (Status);
> +
> + TempFileHandles[TempPeimCount] = FileHandle;
> + }
>
Above logic looks have some redundant code. And the FV might be re-scanned if
there're more than 32 PEIMs in it. If the scan is time consuming task, maybe it'd be
better to refine the logic. Maybe something like below (just show the idea, not
verified yet).
PeimCount = 0;
FileHandle = NULL;
TempPeimCount = 0;
TempFileHandles = Private->TempFileHandles;
TempFileGuid = Private->TempFileGuid;
do {
Status = FvPpi->FindFileByType(FvPpi, PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE, CoreFileHandle->FvHandle, &FileHandle);
if (!EFI_ERROR (Status)) {
PeimCount++;
//
// Have enought buffer?
//
if (Private->TempPeimCount < PeimCount) {
Private->TempPeimCount += 32;
TempFileHandles = Private->TempFileHandles;
TempFileGuid = Private->TempFileGuid;
Private->TempFileHandles = AllocatePool (sizeof (EFI_PEI_FILE_HANDLE) * Private->TempPeimCount);
ASSERT (Private->TempFileHandles != NULL);
Private->TempFileGuid = AllocatePool (sizeof (EFI_GUID) * Private->TempPeimCount);
ASSERT (Private->TempFileGuid != NULL);
if (TempFileHandles != NULL) {
CopyMem (
Private->TempFileHandles,
TempFileHandles,
sizeof (EFI_PEI_FILE_HANDLE) * (PeimCount - 1)
);
}
if (TempFileGuid != NULL) {
CopyMem (
Private->TempFileGuid,
TempFileGuid,
sizeof (EFI_GUID) * (PeimCount - 1)
);
}
TempPeimCount = 0;
TempFileHandles = Private->TempFileHandles + PeimCount - 1;
TempFileGuid = Private->TempFileGuid + PeimCount - 1;
}
TempFileHandles[TempPeimCount++] = FileHandle;
}
} while (!EFI_ERROR (Status));
> //
> // Get Apriori File handle
> @@ -96,7 +165,7 @@ DiscoverPeimsAndOrderWithApriori (
> Status = FvPpi->FindSectionByType (FvPpi, EFI_SECTION_RAW,
> AprioriFileHandle, (VOID **) &Apriori);
> if (!EFI_ERROR (Status)) {
> //
> - // Calculate the number of PEIMs in the A Priori list
> + // Calculate the number of PEIMs in the Apriori file
> //
> Status = FvPpi->GetFileInfo (FvPpi, AprioriFileHandle, &FileInfo);
> ASSERT_EFI_ERROR (Status);
> @@ -113,71 +182,55 @@ DiscoverPeimsAndOrderWithApriori (
> // Make an array of file name guids that matches the FileHandle array so
> we can convert
> // quickly from file name to file handle
> //
> - Status = FvPpi->GetFileInfo (FvPpi, Private->CurrentFvFileHandles[Index],
> &FileInfo);
> - CopyMem (&FileGuid[Index], &FileInfo.FileName, sizeof(EFI_GUID));
> + Status = FvPpi->GetFileInfo (FvPpi, TempFileHandles[Index], &FileInfo);
> + ASSERT_EFI_ERROR (Status);
> + CopyMem (&TempFileGuid[Index], &FileInfo.FileName, sizeof(EFI_GUID));
> }
>
> //
> - // Walk through FileGuid array to find out who is invalid PEIM guid in Apriori
> file.
> - // Add available PEIMs in Apriori file into TempFileHandles array at first.
> + // Walk through TempFileGuid array to find out who is invalid PEIM guid in
> Apriori file.
> + // Add available PEIMs in Apriori file into FvFileHandles array.
> //
> - Index2 = 0;
> - for (Index = 0; Index2 < Private->AprioriCount; Index++) {
> - while (Index2 < Private->AprioriCount) {
> - Guid = ScanGuid (FileGuid, PeimCount * sizeof (EFI_GUID),
> &Apriori[Index2++]);
> - if (Guid != NULL) {
> - break;
> - }
> - }
> - if (Guid == NULL) {
> - break;
> - }
> - PeimIndex = ((UINTN)Guid - (UINTN)&FileGuid[0])/sizeof (EFI_GUID);
> - TempFileHandles[Index] = Private->CurrentFvFileHandles[PeimIndex];
> + Index = 0;
> + for (Index2 = 0; Index2 < Private->AprioriCount; Index2++) {
> + Guid = ScanGuid (TempFileGuid, PeimCount * sizeof (EFI_GUID),
> &Apriori[Index2]);
> + if (Guid != NULL) {
> + PeimIndex = ((UINTN)Guid - (UINTN)&TempFileGuid[0])/sizeof (EFI_GUID);
> + CoreFileHandle->FvFileHandles[Index++] = TempFileHandles[PeimIndex];
>
> - //
> - // Since we have copied the file handle we can remove it from this list.
> - //
> - Private->CurrentFvFileHandles[PeimIndex] = NULL;
> + //
> + // Since we have copied the file handle we can remove it from this list.
> + //
> + TempFileHandles[PeimIndex] = NULL;
> + }
> }
>
> //
> - // Update valid Aprioricount
> + // Update valid AprioriCount
> //
> Private->AprioriCount = Index;
>
> //
> // Add in any PEIMs not in the Apriori file
> //
> - for (;Index < PeimCount; Index++) {
> - for (Index2 = 0; Index2 < PeimCount; Index2++) {
> - if (Private->CurrentFvFileHandles[Index2] != NULL) {
> - TempFileHandles[Index] = Private->CurrentFvFileHandles[Index2];
> - Private->CurrentFvFileHandles[Index2] = NULL;
> - break;
> - }
> + for (Index2 = 0; Index2 < PeimCount; Index2++) {
> + if (TempFileHandles[Index2] != NULL) {
> + CoreFileHandle->FvFileHandles[Index++] = TempFileHandles[Index2];
> + TempFileHandles[Index2] = NULL;
> }
> }
> - //
> - //Index the end of array contains re-range Pei moudle.
> - //
> - TempFileHandles[Index] = NULL;
> -
> - //
> - // Private->CurrentFvFileHandles is currently in PEIM in the FV order.
> - // We need to update it to start with files in the A Priori list and
> - // then the remaining files in PEIM order.
> - //
> - CopyMem (Private->CurrentFvFileHandles, TempFileHandles, sizeof
> (EFI_PEI_FILE_HANDLE) * PcdGet32 (PcdPeiCoreMaxPeimPerFv));
> + ASSERT (Index == PeimCount);
> }
> + } else {
> + CopyMem (CoreFileHandle->FvFileHandles, TempFileHandles, sizeof
> (EFI_PEI_FILE_HANDLE) * PeimCount);
> }
> +
> //
> - // Cache the current Fv File Handle. So that we don't have to scan the Fv again.
> - // Instead, we can retrieve the file handles within this Fv from cachable data.
> + // The current Fv File Handles have been cached. So that we don't have to
> scan the Fv again.
> + // Instead, we can retrieve the file handles within this Fv from cached records.
> //
> - Private->Fv[Private->CurrentPeimFvCount].ScanFv = TRUE;
> - CopyMem (Private->Fv[Private->CurrentPeimFvCount].FvFileHandles, Private-
> >CurrentFvFileHandles, sizeof (EFI_PEI_FILE_HANDLE) * PcdGet32
> (PcdPeiCoreMaxPeimPerFv));
> -
> + CoreFileHandle->ScanFv = TRUE;
> + Private->CurrentFvFileHandles = CoreFileHandle->FvFileHandles;
> }
>
> //
> @@ -977,7 +1030,7 @@ PeiDispatcher (
> SaveCurrentFileHandle = Private->CurrentFileHandle;
>
> for (Index1 = 0; Index1 < Private->FvCount; Index1++) {
> - for (Index2 = 0; (Index2 < PcdGet32 (PcdPeiCoreMaxPeimPerFv)) &&
> (Private->Fv[Index1].FvFileHandles[Index2] != NULL); Index2++) {
> + for (Index2 = 0; Index2 < Private->Fv[Index1].PeimCount; Index2++) {
> if (Private->Fv[Index1].PeimState[Index2] ==
> PEIM_STATE_REGISTER_FOR_SHADOW) {
> PeimFileHandle = Private->Fv[Index1].FvFileHandles[Index2];
> Private->CurrentFileHandle = PeimFileHandle;
> @@ -1063,7 +1116,7 @@ PeiDispatcher (
> // Start to dispatch all modules within the current Fv.
> //
> for (PeimCount = Private->CurrentPeimCount;
> - (PeimCount < PcdGet32 (PcdPeiCoreMaxPeimPerFv)) && (Private-
> >CurrentFvFileHandles[PeimCount] != NULL);
> + PeimCount < Private->Fv[FvCount].PeimCount;
> PeimCount++) {
> Private->CurrentPeimCount = PeimCount;
> PeimFileHandle = Private->CurrentFileHandle = Private-
> >CurrentFvFileHandles[PeimCount];
> @@ -1207,21 +1260,17 @@ PeiDispatcher (
> }
>
> //
> - // We set to NULL here to optimize the 2nd entry to this routine after
> - // memory is found. This reprevents rescanning of the FV. We set to
> - // NULL here so we start at the begining of the next FV
> + // Before walking through the next FV, we should set them to NULL/0 to
> + // start at the begining of the next FV.
> //
> Private->CurrentFileHandle = NULL;
> Private->CurrentPeimCount = 0;
> - //
> - // Before walking through the next FV,Private-
> >CurrentFvFileHandles[]should set to NULL
> - //
> - SetMem (Private->CurrentFvFileHandles, sizeof (EFI_PEI_FILE_HANDLE) *
> PcdGet32 (PcdPeiCoreMaxPeimPerFv), 0);
> + Private->CurrentFvFileHandles = NULL;
> }
>
> //
> - // Before making another pass, we should set Private->CurrentPeimFvCount
> =0 to go
> - // through all the FV.
> + // Before making another pass, we should set it to 0 to
> + // go through all the FVs.
> //
> Private->CurrentPeimFvCount = 0;
>
> @@ -1300,7 +1349,7 @@ DepexSatisfied (
>
> if (PeimCount < Private->AprioriCount) {
> //
> - // If its in the A priori file then we set Depex to TRUE
> + // If it's in the Apriori file then we set Depex to TRUE
> //
> DEBUG ((DEBUG_DISPATCH, " RESULT = TRUE (Apriori)\n"));
> return TRUE;
> diff --git a/MdeModulePkg/Core/Pei/PeiMain.h
> b/MdeModulePkg/Core/Pei/PeiMain.h
> index 6469436b8f79..ab914c7d2e44 100644
> --- a/MdeModulePkg/Core/Pei/PeiMain.h
> +++ b/MdeModulePkg/Core/Pei/PeiMain.h
> @@ -111,12 +111,13 @@ typedef struct {
> EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
> EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi;
> EFI_PEI_FV_HANDLE FvHandle;
> + UINTN PeimCount;
> //
> - // Ponter to the buffer with the PcdPeiCoreMaxPeimPerFv number of Entries.
> + // Ponter to the buffer with the PeimCount number of Entries.
> //
> UINT8 *PeimState;
> //
> - // Ponter to the buffer with the PcdPeiCoreMaxPeimPerFv number of Entries.
> + // Ponter to the buffer with the PeimCount number of Entries.
> //
> EFI_PEI_FILE_HANDLE *FvFileHandles;
> BOOLEAN ScanFv;
> @@ -209,7 +210,7 @@ struct _PEI_CORE_INSTANCE {
> UINTN UnknownFvInfoCount;
>
> ///
> - /// Pointer to the buffer with the PcdPeiCoreMaxPeimPerFv number of entries.
> + /// Pointer to the buffer FvFileHandlers in PEI_CORE_FV_HANDLE specified by
> CurrentPeimFvCount.
> ///
> EFI_PEI_FILE_HANDLE *CurrentFvFileHandles;
> UINTN AprioriCount;
> @@ -256,14 +257,16 @@ struct _PEI_CORE_INSTANCE {
> //
> PE_COFF_LOADER_READ_FILE ShadowedImageRead;
>
> + UINTN TempPeimCount;
> +
> //
> - // Pointer to the temp buffer with the PcdPeiCoreMaxPeimPerFv + 1 number
> of entries.
> + // Pointer to the temp buffer with the TempPeimCount number of entries.
> //
> - EFI_PEI_FILE_HANDLE *FileHandles;
> + EFI_PEI_FILE_HANDLE *TempFileHandles;
> //
> - // Pointer to the temp buffer with the PcdPeiCoreMaxPeimPerFv number of
> entries.
> + // Pointer to the temp buffer with the TempPeimCount number of entries.
> //
> - EFI_GUID *FileGuid;
> + EFI_GUID *TempFileGuid;
>
> //
> // Temp Memory Range is not covered by PeiTempMem and Stack.
> diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf
> b/MdeModulePkg/Core/Pei/PeiMain.inf
> index 4e1581a926d9..d106c3606e97 100644
> --- a/MdeModulePkg/Core/Pei/PeiMain.inf
> +++ b/MdeModulePkg/Core/Pei/PeiMain.inf
> @@ -105,7 +105,6 @@ [Ppis]
>
> [Pcd]
> gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported ##
> CONSUMES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv ##
> CONSUMES
> gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported ##
> CONSUMES
> gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize ##
> CONSUMES
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreImageLoaderSearchTeSectionFir
> st ## CONSUMES
> diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> index e3a301dfe0f2..52adefeb44b4 100644
> --- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> +++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> @@ -185,27 +185,39 @@ PeiCore (
> if (OldCoreData->HeapOffsetPositive) {
> OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw +
> OldCoreData->HeapOffset);
> OldCoreData->UnknownFvInfo =
> (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData-
> >UnknownFvInfo + OldCoreData->HeapOffset);
> - OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *)
> OldCoreData->CurrentFvFileHandles + OldCoreData->HeapOffset);
> + if (OldCoreData->CurrentFvFileHandles != NULL) {
> + OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8
> *) OldCoreData->CurrentFvFileHandles + OldCoreData->HeapOffset);
> + }
> OldCoreData->PpiData.PpiListPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *)
> OldCoreData->PpiData.PpiListPtrs + OldCoreData->HeapOffset);
> OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *)
> OldCoreData->Fv + OldCoreData->HeapOffset);
> for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {
> - OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData-
> >Fv[Index].PeimState + OldCoreData->HeapOffset;
> - OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *)
> ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles + OldCoreData->HeapOffset);
> + if (OldCoreData->Fv[Index].PeimState != NULL) {
> + OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData-
> >Fv[Index].PeimState + OldCoreData->HeapOffset;
> + }
> + if (OldCoreData->Fv[Index].FvFileHandles != NULL) {
> + OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *)
> ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles + OldCoreData->HeapOffset);
> + }
> }
> - OldCoreData->FileGuid = (EFI_GUID *) ((UINT8 *) OldCoreData-
> >FileGuid + OldCoreData->HeapOffset);
> - OldCoreData->FileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *)
> OldCoreData->FileHandles + OldCoreData->HeapOffset);
> + OldCoreData->TempFileGuid = (EFI_GUID *) ((UINT8 *) OldCoreData-
> >TempFileGuid + OldCoreData->HeapOffset);
> + OldCoreData->TempFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *)
> OldCoreData->TempFileHandles + OldCoreData->HeapOffset);
> } else {
> OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw -
> OldCoreData->HeapOffset);
> OldCoreData->UnknownFvInfo =
> (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData-
> >UnknownFvInfo - OldCoreData->HeapOffset);
> - OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *)
> OldCoreData->CurrentFvFileHandles - OldCoreData->HeapOffset);
> + if (OldCoreData->CurrentFvFileHandles != NULL) {
> + OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8
> *) OldCoreData->CurrentFvFileHandles - OldCoreData->HeapOffset);
> + }
> OldCoreData->PpiData.PpiListPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *)
> OldCoreData->PpiData.PpiListPtrs - OldCoreData->HeapOffset);
> OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *)
> OldCoreData->Fv - OldCoreData->HeapOffset);
> for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {
> - OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData-
> >Fv[Index].PeimState - OldCoreData->HeapOffset;
> - OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *)
> ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles - OldCoreData->HeapOffset);
> + if (OldCoreData->Fv[Index].PeimState != NULL) {
> + OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData-
> >Fv[Index].PeimState - OldCoreData->HeapOffset;
> + }
> + if (OldCoreData->Fv[Index].FvFileHandles != NULL) {
> + OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *)
> ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles - OldCoreData->HeapOffset);
> + }
> }
> - OldCoreData->FileGuid = (EFI_GUID *) ((UINT8 *) OldCoreData-
> >FileGuid - OldCoreData->HeapOffset);
> - OldCoreData->FileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *)
> OldCoreData->FileHandles - OldCoreData->HeapOffset);
> + OldCoreData->TempFileGuid = (EFI_GUID *) ((UINT8 *) OldCoreData-
> >TempFileGuid - OldCoreData->HeapOffset);
> + OldCoreData->TempFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *)
> OldCoreData->TempFileHandles - OldCoreData->HeapOffset);
> }
>
> //
> @@ -320,7 +332,7 @@ PeiCore (
> //
> // Initialize PEI Core Services
> //
> - InitializeMemoryServices (&PrivateData, SecCoreData, OldCoreData);
> + InitializeMemoryServices (&PrivateData, SecCoreData, OldCoreData);
> if (OldCoreData == NULL) {
> //
> // Initialize PEI Core Private Data Buffer
> @@ -329,22 +341,8 @@ PeiCore (
> ASSERT (PrivateData.PpiData.PpiListPtrs != NULL);
> PrivateData.Fv = AllocateZeroPool (sizeof (PEI_CORE_FV_HANDLE)
> * PcdGet32 (PcdPeiCoreMaxFvSupported));
> ASSERT (PrivateData.Fv != NULL);
> - PrivateData.Fv[0].PeimState = AllocateZeroPool (sizeof (UINT8) *
> PcdGet32 (PcdPeiCoreMaxPeimPerFv) * PcdGet32 (PcdPeiCoreMaxFvSupported));
> - ASSERT (PrivateData.Fv[0].PeimState != NULL);
> - PrivateData.Fv[0].FvFileHandles = AllocateZeroPool (sizeof
> (EFI_PEI_FILE_HANDLE) * PcdGet32 (PcdPeiCoreMaxPeimPerFv) * PcdGet32
> (PcdPeiCoreMaxFvSupported));
> - ASSERT (PrivateData.Fv[0].FvFileHandles != NULL);
> - for (Index = 1; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {
> - PrivateData.Fv[Index].PeimState = PrivateData.Fv[Index - 1].PeimState +
> PcdGet32 (PcdPeiCoreMaxPeimPerFv);
> - PrivateData.Fv[Index].FvFileHandles = PrivateData.Fv[Index -
> 1].FvFileHandles + PcdGet32 (PcdPeiCoreMaxPeimPerFv);
> - }
> PrivateData.UnknownFvInfo = AllocateZeroPool (sizeof
> (PEI_CORE_UNKNOW_FORMAT_FV_INFO) * PcdGet32
> (PcdPeiCoreMaxFvSupported));
> ASSERT (PrivateData.UnknownFvInfo != NULL);
> - PrivateData.CurrentFvFileHandles = AllocateZeroPool (sizeof
> (EFI_PEI_FILE_HANDLE) * PcdGet32 (PcdPeiCoreMaxPeimPerFv));
> - ASSERT (PrivateData.CurrentFvFileHandles != NULL);
> - PrivateData.FileGuid = AllocatePool (sizeof (EFI_GUID) * PcdGet32
> (PcdPeiCoreMaxPeimPerFv));
> - ASSERT (PrivateData.FileGuid != NULL);
> - PrivateData.FileHandles = AllocatePool (sizeof (EFI_PEI_FILE_HANDLE) *
> (PcdGet32 (PcdPeiCoreMaxPeimPerFv) + 1));
> - ASSERT (PrivateData.FileHandles != NULL);
> }
> InitializePpiServices (&PrivateData, OldCoreData);
>
> --
> 2.7.0.windows.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 3/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxFvSupported
2018-12-14 10:28 ` [PATCH 3/7] MdeModulePkg PeiCore: " Star Zeng
2018-12-17 23:20 ` Chiu, Chasel
@ 2018-12-18 2:10 ` Wang, Jian J
1 sibling, 0 replies; 23+ messages in thread
From: Wang, Jian J @ 2018-12-18 2:10 UTC (permalink / raw)
To: Zeng, Star, edk2-devel@lists.01.org
Cc: Wu, Hao A, Gao, Liming, Ni, Ruiyu, Kinney, Michael D,
Desimone, Nathaniel L, Chiu, Chasel
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
> -----Original Message-----
> From: Zeng, Star
> Sent: Friday, December 14, 2018 6:29 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star <star.zeng@intel.com>; Wang, Jian J <jian.j.wang@intel.com>;
> Wu, Hao A <hao.a.wu@intel.com>; Gao, Liming <liming.gao@intel.com>; Ni,
> Ruiyu <ruiyu.ni@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>;
> Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Chiu, Chasel
> <chasel.chiu@intel.com>
> Subject: [PATCH 3/7] MdeModulePkg PeiCore: Remove the using of
> PcdPeiCoreMaxFvSupported
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405
>
> Background as below.
>
> Problem:
> As static configuration from the PCDs, the binary PeiCore (for example
> in FSP binary with dispatch mode) could not predict how many FVs,
> Files or PPIs for different platforms.
>
> Burden:
> Platform developers need configure the PCDs accordingly for different
> platforms.
>
> To solve the problem and remove the burden, we can update PeiCore to
> remove the using of PcdPeiCoreMaxFvSupported, PcdPeiCoreMaxPeimPerFv
> and PcdPeiCoreMaxPpiSupported by extending buffer dynamically for FV,
> File and PPI management.
>
> This patch removes the using of PcdPeiCoreMaxFvSupported in PeiCore.
>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao Wu <hao.a.wu@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng <star.zeng@intel.com>
> ---
> MdeModulePkg/Core/Pei/FwVol/FwVol.c | 67
> ++++++++++++++++++++++++++-------
> MdeModulePkg/Core/Pei/PeiMain.h | 15 +++++++-
> MdeModulePkg/Core/Pei/PeiMain.inf | 1 -
> MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 16 ++++----
> 4 files changed, 75 insertions(+), 24 deletions(-)
>
> diff --git a/MdeModulePkg/Core/Pei/FwVol/FwVol.c
> b/MdeModulePkg/Core/Pei/FwVol/FwVol.c
> index 5629c9a1ce20..0a67b96bf1e3 100644
> --- a/MdeModulePkg/Core/Pei/FwVol/FwVol.c
> +++ b/MdeModulePkg/Core/Pei/FwVol/FwVol.c
> @@ -503,6 +503,10 @@ PeiInitializeFv (
> );
> ASSERT_EFI_ERROR (Status);
>
> + PrivateData->Fv = AllocateZeroPool (sizeof (PEI_CORE_FV_HANDLE) *
> FV_GROWTH_STEP);
> + ASSERT (PrivateData->Fv != NULL);
> + PrivateData->MaxFvCount = FV_GROWTH_STEP;
> +
> //
> // Update internal PEI_CORE_FV array.
> //
> @@ -560,6 +564,7 @@ FirmwareVolmeInfoPpiNotifyCallback (
> VOID *DepexData;
> BOOLEAN IsFvInfo2;
> UINTN CurFvCount;
> + VOID *TempPtr;
>
> Status = EFI_SUCCESS;
> PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
> @@ -626,10 +631,21 @@ FirmwareVolmeInfoPpiNotifyCallback (
> }
> }
>
> - if (PrivateData->FvCount >= PcdGet32 (PcdPeiCoreMaxFvSupported)) {
> - DEBUG ((EFI_D_ERROR, "The number of Fv Images (%d) exceed the max
> supported FVs (%d) in Pei", PrivateData->FvCount + 1, PcdGet32
> (PcdPeiCoreMaxFvSupported)));
> - DEBUG ((EFI_D_ERROR, "PcdPeiCoreMaxFvSupported value need be
> reconfigurated in DSC"));
> - ASSERT (FALSE);
> + if (PrivateData->FvCount >= PrivateData->MaxFvCount) {
> + //
> + // Run out of room, grow the buffer.
> + //
> + TempPtr = AllocateZeroPool (
> + sizeof (PEI_CORE_FV_HANDLE) * (PrivateData->MaxFvCount +
> FV_GROWTH_STEP)
> + );
> + ASSERT (TempPtr != NULL);
> + CopyMem (
> + TempPtr,
> + PrivateData->Fv,
> + sizeof (PEI_CORE_FV_HANDLE) * PrivateData->MaxFvCount
> + );
> + PrivateData->Fv = TempPtr;
> + PrivateData->MaxFvCount = PrivateData->MaxFvCount +
> FV_GROWTH_STEP;
> }
>
> //
> @@ -2157,7 +2173,6 @@ FindNextCoreFvHandle (
> }
> }
>
> - ASSERT (Private->FvCount <= PcdGet32 (PcdPeiCoreMaxFvSupported));
> if (Instance >= Private->FvCount) {
> return NULL;
> }
> @@ -2205,7 +2220,7 @@ PeiReinitializeFv (
> //
> // Fixup all FvPpi pointers for the implementation in flash to permanent
> memory.
> //
> - for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {
> + for (Index = 0; Index < PrivateData->FvCount; Index ++) {
> if (PrivateData->Fv[Index].FvPpi == OldFfsFvPpi) {
> PrivateData->Fv[Index].FvPpi = &mPeiFfs2FwVol.Fv;
> }
> @@ -2233,7 +2248,7 @@ PeiReinitializeFv (
> //
> // Fixup all FvPpi pointers for the implementation in flash to permanent
> memory.
> //
> - for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {
> + for (Index = 0; Index < PrivateData->FvCount; Index ++) {
> if (PrivateData->Fv[Index].FvPpi == OldFfsFvPpi) {
> PrivateData->Fv[Index].FvPpi = &mPeiFfs3FwVol.Fv;
> }
> @@ -2263,9 +2278,23 @@ AddUnknownFormatFvInfo (
> )
> {
> PEI_CORE_UNKNOW_FORMAT_FV_INFO *NewUnknownFv;
> + VOID *TempPtr;
>
> - if (PrivateData->UnknownFvInfoCount + 1 >= PcdGet32
> (PcdPeiCoreMaxFvSupported)) {
> - return EFI_OUT_OF_RESOURCES;
> + if (PrivateData->UnknownFvInfoCount >= PrivateData-
> >MaxUnknownFvInfoCount) {
> + //
> + // Run out of room, grow the buffer.
> + //
> + TempPtr = AllocateZeroPool (
> + sizeof (PEI_CORE_UNKNOW_FORMAT_FV_INFO) * (PrivateData-
> >MaxUnknownFvInfoCount + FV_GROWTH_STEP)
> + );
> + ASSERT (TempPtr != NULL);
> + CopyMem (
> + TempPtr,
> + PrivateData->UnknownFvInfo,
> + sizeof (PEI_CORE_UNKNOW_FORMAT_FV_INFO) * PrivateData-
> >MaxUnknownFvInfoCount
> + );
> + PrivateData->UnknownFvInfo = TempPtr;
> + PrivateData->MaxUnknownFvInfoCount = PrivateData-
> >MaxUnknownFvInfoCount + FV_GROWTH_STEP;
> }
>
> NewUnknownFv = &PrivateData->UnknownFvInfo[PrivateData-
> >UnknownFvInfoCount];
> @@ -2368,6 +2397,7 @@ ThirdPartyFvPpiNotifyCallback (
> EFI_PEI_FILE_HANDLE FileHandle;
> VOID *DepexData;
> UINTN CurFvCount;
> + VOID *TempPtr;
>
> PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
> FvPpi = (EFI_PEI_FIRMWARE_VOLUME_PPI*) Ppi;
> @@ -2403,10 +2433,21 @@ ThirdPartyFvPpiNotifyCallback (
> continue;
> }
>
> - if (PrivateData->FvCount >= PcdGet32 (PcdPeiCoreMaxFvSupported)) {
> - DEBUG ((EFI_D_ERROR, "The number of Fv Images (%d) exceed the max
> supported FVs (%d) in Pei", PrivateData->FvCount + 1, PcdGet32
> (PcdPeiCoreMaxFvSupported)));
> - DEBUG ((EFI_D_ERROR, "PcdPeiCoreMaxFvSupported value need be
> reconfigurated in DSC"));
> - ASSERT (FALSE);
> + if (PrivateData->FvCount >= PrivateData->MaxFvCount) {
> + //
> + // Run out of room, grow the buffer.
> + //
> + TempPtr = AllocateZeroPool (
> + sizeof (PEI_CORE_FV_HANDLE) * (PrivateData->MaxFvCount +
> FV_GROWTH_STEP)
> + );
> + ASSERT (TempPtr != NULL);
> + CopyMem (
> + TempPtr,
> + PrivateData->Fv,
> + sizeof (PEI_CORE_FV_HANDLE) * PrivateData->MaxFvCount
> + );
> + PrivateData->Fv = TempPtr;
> + PrivateData->MaxFvCount = PrivateData->MaxFvCount +
> FV_GROWTH_STEP;
> }
>
> //
> diff --git a/MdeModulePkg/Core/Pei/PeiMain.h
> b/MdeModulePkg/Core/Pei/PeiMain.h
> index ab914c7d2e44..b248118087ad 100644
> --- a/MdeModulePkg/Core/Pei/PeiMain.h
> +++ b/MdeModulePkg/Core/Pei/PeiMain.h
> @@ -107,6 +107,11 @@ typedef struct {
> #define PEIM_STATE_REGISTER_FOR_SHADOW 0x02
> #define PEIM_STATE_DONE 0x03
>
> +//
> +// Number of FV instances to grow by each time we run out of room
> +//
> +#define FV_GROWTH_STEP 8
> +
> typedef struct {
> EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
> EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi;
> @@ -197,16 +202,22 @@ struct _PEI_CORE_INSTANCE {
> UINTN FvCount;
>
> ///
> - /// Pointer to the buffer with the PcdPeiCoreMaxFvSupported number of
> entries.
> + /// The max count of FVs which contains FFS and could be dispatched by
> PeiCore.
> + ///
> + UINTN MaxFvCount;
> +
> + ///
> + /// Pointer to the buffer with the MaxFvCount number of entries.
> /// Each entry is for one FV which contains FFS and could be dispatched by
> PeiCore.
> ///
> PEI_CORE_FV_HANDLE *Fv;
>
> ///
> - /// Pointer to the buffer with the PcdPeiCoreMaxFvSupported number of
> entries.
> + /// Pointer to the buffer with the MaxUnknownFvInfoCount number of entries.
> /// Each entry is for one FV which could not be dispatched by PeiCore.
> ///
> PEI_CORE_UNKNOW_FORMAT_FV_INFO *UnknownFvInfo;
> + UINTN MaxUnknownFvInfoCount;
> UINTN UnknownFvInfoCount;
>
> ///
> diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf
> b/MdeModulePkg/Core/Pei/PeiMain.inf
> index d106c3606e97..dd41fe41bc89 100644
> --- a/MdeModulePkg/Core/Pei/PeiMain.inf
> +++ b/MdeModulePkg/Core/Pei/PeiMain.inf
> @@ -104,7 +104,6 @@ [Ppis]
> gEfiSecHobDataPpiGuid ## SOMETIMES_CONSUMES
>
> [Pcd]
> - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported ##
> CONSUMES
> gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported ##
> CONSUMES
> gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize ##
> CONSUMES
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreImageLoaderSearchTeSectionFir
> st ## CONSUMES
> diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> index 52adefeb44b4..4869bf18f005 100644
> --- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> +++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> @@ -184,13 +184,15 @@ PeiCore (
> OldCoreData->CpuIo = &OldCoreData->ServiceTableShadow.CpuIo;
> if (OldCoreData->HeapOffsetPositive) {
> OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw +
> OldCoreData->HeapOffset);
> - OldCoreData->UnknownFvInfo =
> (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData-
> >UnknownFvInfo + OldCoreData->HeapOffset);
> + if (OldCoreData->UnknownFvInfo != NULL) {
> + OldCoreData->UnknownFvInfo =
> (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData-
> >UnknownFvInfo + OldCoreData->HeapOffset);
> + }
> if (OldCoreData->CurrentFvFileHandles != NULL) {
> OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *)
> OldCoreData->CurrentFvFileHandles + OldCoreData->HeapOffset);
> }
> OldCoreData->PpiData.PpiListPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *)
> OldCoreData->PpiData.PpiListPtrs + OldCoreData->HeapOffset);
> OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *)
> OldCoreData->Fv + OldCoreData->HeapOffset);
> - for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {
> + for (Index = 0; Index < OldCoreData->FvCount; Index ++) {
> if (OldCoreData->Fv[Index].PeimState != NULL) {
> OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData-
> >Fv[Index].PeimState + OldCoreData->HeapOffset;
> }
> @@ -202,13 +204,15 @@ PeiCore (
> OldCoreData->TempFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *)
> OldCoreData->TempFileHandles + OldCoreData->HeapOffset);
> } else {
> OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw -
> OldCoreData->HeapOffset);
> - OldCoreData->UnknownFvInfo =
> (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData-
> >UnknownFvInfo - OldCoreData->HeapOffset);
> + if (OldCoreData->UnknownFvInfo != NULL) {
> + OldCoreData->UnknownFvInfo =
> (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData-
> >UnknownFvInfo - OldCoreData->HeapOffset);
> + }
> if (OldCoreData->CurrentFvFileHandles != NULL) {
> OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *)
> OldCoreData->CurrentFvFileHandles - OldCoreData->HeapOffset);
> }
> OldCoreData->PpiData.PpiListPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *)
> OldCoreData->PpiData.PpiListPtrs - OldCoreData->HeapOffset);
> OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *)
> OldCoreData->Fv - OldCoreData->HeapOffset);
> - for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {
> + for (Index = 0; Index < OldCoreData->FvCount; Index ++) {
> if (OldCoreData->Fv[Index].PeimState != NULL) {
> OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData-
> >Fv[Index].PeimState - OldCoreData->HeapOffset;
> }
> @@ -339,10 +343,6 @@ PeiCore (
> //
> PrivateData.PpiData.PpiListPtrs = AllocateZeroPool (sizeof
> (PEI_PPI_LIST_POINTERS) * PcdGet32 (PcdPeiCoreMaxPpiSupported));
> ASSERT (PrivateData.PpiData.PpiListPtrs != NULL);
> - PrivateData.Fv = AllocateZeroPool (sizeof (PEI_CORE_FV_HANDLE)
> * PcdGet32 (PcdPeiCoreMaxFvSupported));
> - ASSERT (PrivateData.Fv != NULL);
> - PrivateData.UnknownFvInfo = AllocateZeroPool (sizeof
> (PEI_CORE_UNKNOW_FORMAT_FV_INFO) * PcdGet32
> (PcdPeiCoreMaxFvSupported));
> - ASSERT (PrivateData.UnknownFvInfo != NULL);
> }
> InitializePpiServices (&PrivateData, OldCoreData);
>
> --
> 2.7.0.windows.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 4/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPpiSupported
2018-12-14 10:28 ` [PATCH 4/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPpiSupported Star Zeng
2018-12-17 23:20 ` Chiu, Chasel
@ 2018-12-18 2:24 ` Wang, Jian J
2018-12-18 3:12 ` Zeng, Star
1 sibling, 1 reply; 23+ messages in thread
From: Wang, Jian J @ 2018-12-18 2:24 UTC (permalink / raw)
To: Zeng, Star, edk2-devel@lists.01.org
Cc: Wu, Hao A, Gao, Liming, Ni, Ruiyu, Kinney, Michael D,
Desimone, Nathaniel L, Chiu, Chasel
Star,
Please consider to extract the code to expand PPI buffer as a function or macro.
I found it repeated 3 times in this patch.
Regards,
Jian
> -----Original Message-----
> From: Zeng, Star
> Sent: Friday, December 14, 2018 6:29 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star <star.zeng@intel.com>; Wang, Jian J <jian.j.wang@intel.com>;
> Wu, Hao A <hao.a.wu@intel.com>; Gao, Liming <liming.gao@intel.com>; Ni,
> Ruiyu <ruiyu.ni@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>;
> Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Chiu, Chasel
> <chasel.chiu@intel.com>
> Subject: [PATCH 4/7] MdeModulePkg PeiCore: Remove the using of
> PcdPeiCoreMaxPpiSupported
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405
>
> Background as below.
>
> Problem:
> As static configuration from the PCDs, the binary PeiCore (for example
> in FSP binary with dispatch mode) could not predict how many FVs,
> Files or PPIs for different platforms.
>
> Burden:
> Platform developers need configure the PCDs accordingly for different
> platforms.
>
> To solve the problem and remove the burden, we can update code to
> remove the using of PcdPeiCoreMaxFvSupported, PcdPeiCoreMaxPeimPerFv
> and PcdPeiCoreMaxPpiSupported by extending buffer dynamically for FV,
> File and PPI management.
>
> This patch removes the using of PcdPeiCoreMaxPpiSupported in PeiCore.
>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao Wu <hao.a.wu@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng <star.zeng@intel.com>
> ---
> MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 8 +-
> MdeModulePkg/Core/Pei/PeiMain.h | 59 +++--
> MdeModulePkg/Core/Pei/PeiMain.inf | 1 -
> MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 30 ++-
> MdeModulePkg/Core/Pei/Ppi/Ppi.c | 355 ++++++++++++++------------
> 5 files changed, 254 insertions(+), 199 deletions(-)
>
> diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> index 71440bab9488..55a300adbdb8 100644
> --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> @@ -1062,7 +1062,7 @@ PeiDispatcher (
> // Process the Notify list and dispatch any notifies for
> // newly installed PPIs.
> //
> - ProcessNotifyList (Private);
> + ProcessDispatchNotifyList (Private);
> }
> }
> }
> @@ -1209,10 +1209,10 @@ PeiDispatcher (
> // Process the Notify list and dispatch any notifies for
> // newly installed PPIs.
> //
> - ProcessNotifyList (Private);
> + ProcessDispatchNotifyList (Private);
>
> //
> - // Recheck SwitchStackSignal after ProcessNotifyList()
> + // Recheck SwitchStackSignal after ProcessDispatchNotifyList()
> // in case PeiInstallPeiMemory() is done in a callback with
> // EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH.
> //
> @@ -1253,7 +1253,7 @@ PeiDispatcher (
> // Process the Notify list and dispatch any notifies for
> // newly installed PPIs.
> //
> - ProcessNotifyList (Private);
> + ProcessDispatchNotifyList (Private);
> }
> }
> }
> diff --git a/MdeModulePkg/Core/Pei/PeiMain.h
> b/MdeModulePkg/Core/Pei/PeiMain.h
> index b248118087ad..c6c932c3e233 100644
> --- a/MdeModulePkg/Core/Pei/PeiMain.h
> +++ b/MdeModulePkg/Core/Pei/PeiMain.h
> @@ -66,37 +66,60 @@ typedef union {
> } PEI_PPI_LIST_POINTERS;
>
> ///
> -/// PPI database structure which contains two link: PpiList and NotifyList. PpiList
> -/// is in head of PpiListPtrs array and notify is in end of PpiListPtrs.
> +/// Number of PEI_PPI_LIST_POINTERS to grow by each time we run out of
> room
> ///
> +#define PPI_GROWTH_STEP 64
> +#define CALLBACK_NOTIFY_GROWTH_STEP 32
> +#define DISPATCH_NOTIFY_GROWTH_STEP 8
> +
> typedef struct {
> + UINTN CurrentCount;
> + UINTN MaxCount;
> + UINTN LastDispatchedCount;
> ///
> - /// index of end of PpiList link list.
> + /// MaxCount number of entries.
> ///
> - INTN PpiListEnd;
> + PEI_PPI_LIST_POINTERS *PpiPtrs;
> +} PEI_PPI_LIST;
> +
> +typedef struct {
> + UINTN CurrentCount;
> + UINTN MaxCount;
> ///
> - /// index of end of notify link list.
> + /// MaxCount number of entries.
> ///
> - INTN NotifyListEnd;
> + PEI_PPI_LIST_POINTERS *NotifyPtrs;
> +} PEI_CALLBACK_NOTIFY_LIST;
> +
> +typedef struct {
> + UINTN CurrentCount;
> + UINTN MaxCount;
> + UINTN LastDispatchedCount;
> ///
> - /// index of the dispatched notify list.
> + /// MaxCount number of entries.
> ///
> - INTN DispatchListEnd;
> + PEI_PPI_LIST_POINTERS *NotifyPtrs;
> +} PEI_DISPATCH_NOTIFY_LIST;
> +
> +///
> +/// PPI database structure which contains three links:
> +/// PpiList, CallbackNotifyList and DispatchNotifyList.
> +///
> +typedef struct {
> ///
> - /// index of last installed Ppi description in PpiList link list.
> + /// PPI List.
> ///
> - INTN LastDispatchedInstall;
> + PEI_PPI_LIST PpiList;
> ///
> - /// index of last dispatched notify in Notify link list.
> + /// Notify List at dispatch level.
> ///
> - INTN LastDispatchedNotify;
> + PEI_CALLBACK_NOTIFY_LIST CallbackNotifyList;
> ///
> - /// Ppi database has the PcdPeiCoreMaxPpiSupported number of entries.
> + /// Notify List at callback level.
> ///
> - PEI_PPI_LIST_POINTERS *PpiListPtrs;
> + PEI_DISPATCH_NOTIFY_LIST DispatchNotifyList;
> } PEI_PPI_DATABASE;
>
> -
> //
> // PEI_CORE_FV_HANDE.PeimState
> // Do not change these values as there is code doing math to change states.
> @@ -550,13 +573,13 @@ PeiNotifyPpi (
>
> **/
> VOID
> -ProcessNotifyList (
> +ProcessDispatchNotifyList (
> IN PEI_CORE_INSTANCE *PrivateData
> );
>
> /**
>
> - Dispatch notifications.
> + Process notifications.
>
> @param PrivateData PeiCore's private data structure
> @param NotifyType Type of notify to fire.
> @@ -567,7 +590,7 @@ ProcessNotifyList (
>
> **/
> VOID
> -DispatchNotify (
> +ProcessNotify (
> IN PEI_CORE_INSTANCE *PrivateData,
> IN UINTN NotifyType,
> IN INTN InstallStartIndex,
> diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf
> b/MdeModulePkg/Core/Pei/PeiMain.inf
> index dd41fe41bc89..140c4444b107 100644
> --- a/MdeModulePkg/Core/Pei/PeiMain.inf
> +++ b/MdeModulePkg/Core/Pei/PeiMain.inf
> @@ -104,7 +104,6 @@ [Ppis]
> gEfiSecHobDataPpiGuid ## SOMETIMES_CONSUMES
>
> [Pcd]
> - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported ##
> CONSUMES
> gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize ##
> CONSUMES
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreImageLoaderSearchTeSectionFir
> st ## CONSUMES
> gEfiMdeModulePkgTokenSpaceGuid.PcdFrameworkCompatibilitySupport
> ## CONSUMES
> diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> index 4869bf18f005..4da80a8222bc 100644
> --- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> +++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> @@ -190,7 +190,15 @@ PeiCore (
> if (OldCoreData->CurrentFvFileHandles != NULL) {
> OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *)
> OldCoreData->CurrentFvFileHandles + OldCoreData->HeapOffset);
> }
> - OldCoreData->PpiData.PpiListPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *)
> OldCoreData->PpiData.PpiListPtrs + OldCoreData->HeapOffset);
> + if (OldCoreData->PpiData.PpiList.PpiPtrs != NULL) {
> + OldCoreData->PpiData.PpiList.PpiPtrs = (PEI_PPI_LIST_POINTERS *)
> ((UINT8 *) OldCoreData->PpiData.PpiList.PpiPtrs + OldCoreData->HeapOffset);
> + }
> + if (OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs != NULL) {
> + OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs =
> (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData-
> >PpiData.CallbackNotifyList.NotifyPtrs + OldCoreData->HeapOffset);
> + }
> + if (OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs != NULL) {
> + OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs =
> (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData-
> >PpiData.DispatchNotifyList.NotifyPtrs + OldCoreData->HeapOffset);
> + }
> OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *)
> OldCoreData->Fv + OldCoreData->HeapOffset);
> for (Index = 0; Index < OldCoreData->FvCount; Index ++) {
> if (OldCoreData->Fv[Index].PeimState != NULL) {
> @@ -210,7 +218,15 @@ PeiCore (
> if (OldCoreData->CurrentFvFileHandles != NULL) {
> OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *)
> OldCoreData->CurrentFvFileHandles - OldCoreData->HeapOffset);
> }
> - OldCoreData->PpiData.PpiListPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *)
> OldCoreData->PpiData.PpiListPtrs - OldCoreData->HeapOffset);
> + if (OldCoreData->PpiData.PpiList.PpiPtrs != NULL) {
> + OldCoreData->PpiData.PpiList.PpiPtrs = (PEI_PPI_LIST_POINTERS *)
> ((UINT8 *) OldCoreData->PpiData.PpiList.PpiPtrs - OldCoreData->HeapOffset);
> + }
> + if (OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs != NULL) {
> + OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs =
> (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData-
> >PpiData.CallbackNotifyList.NotifyPtrs - OldCoreData->HeapOffset);
> + }
> + if (OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs != NULL) {
> + OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs =
> (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData-
> >PpiData.DispatchNotifyList.NotifyPtrs - OldCoreData->HeapOffset);
> + }
> OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *)
> OldCoreData->Fv - OldCoreData->HeapOffset);
> for (Index = 0; Index < OldCoreData->FvCount; Index ++) {
> if (OldCoreData->Fv[Index].PeimState != NULL) {
> @@ -337,14 +353,6 @@ PeiCore (
> // Initialize PEI Core Services
> //
> InitializeMemoryServices (&PrivateData, SecCoreData, OldCoreData);
> - if (OldCoreData == NULL) {
> - //
> - // Initialize PEI Core Private Data Buffer
> - //
> - PrivateData.PpiData.PpiListPtrs = AllocateZeroPool (sizeof
> (PEI_PPI_LIST_POINTERS) * PcdGet32 (PcdPeiCoreMaxPpiSupported));
> - ASSERT (PrivateData.PpiData.PpiListPtrs != NULL);
> - }
> - InitializePpiServices (&PrivateData, OldCoreData);
>
> //
> // Update performance measurements
> @@ -414,7 +422,7 @@ PeiCore (
> //
> // Process the Notify list and dispatch any notifies for the Memory Discovered
> PPI
> //
> - ProcessNotifyList (&PrivateData);
> + ProcessDispatchNotifyList (&PrivateData);
>
> PERF_INMODULE_END ("DisMem");
> }
> diff --git a/MdeModulePkg/Core/Pei/Ppi/Ppi.c
> b/MdeModulePkg/Core/Pei/Ppi/Ppi.c
> index 6f03858b8a94..907b2bbcf466 100644
> --- a/MdeModulePkg/Core/Pei/Ppi/Ppi.c
> +++ b/MdeModulePkg/Core/Pei/Ppi/Ppi.c
> @@ -16,28 +16,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY
> KIND, EITHER EXPRESS OR IMPLIED.
>
> /**
>
> - Initialize PPI services.
> -
> - @param PrivateData Pointer to the PEI Core data.
> - @param OldCoreData Pointer to old PEI Core data.
> - NULL if being run in non-permament memory mode.
> -
> -**/
> -VOID
> -InitializePpiServices (
> - IN PEI_CORE_INSTANCE *PrivateData,
> - IN PEI_CORE_INSTANCE *OldCoreData
> - )
> -{
> - if (OldCoreData == NULL) {
> - PrivateData->PpiData.NotifyListEnd = PcdGet32
> (PcdPeiCoreMaxPpiSupported)-1;
> - PrivateData->PpiData.DispatchListEnd = PcdGet32
> (PcdPeiCoreMaxPpiSupported)-1;
> - PrivateData->PpiData.LastDispatchedNotify = PcdGet32
> (PcdPeiCoreMaxPpiSupported)-1;
> - }
> -}
> -
> -/**
> -
> Migrate Pointer from the temporary memory to PEI installed memory.
>
> @param Pointer Pointer to the Pointer needs to be converted.
> @@ -192,14 +170,37 @@ ConvertPpiPointers (
> {
> UINT8 Index;
>
> - for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxPpiSupported); Index++) {
> - if (Index < PrivateData->PpiData.PpiListEnd || Index > PrivateData-
> >PpiData.NotifyListEnd) {
> - ConvertSinglePpiPointer (
> - SecCoreData,
> - PrivateData,
> - &PrivateData->PpiData.PpiListPtrs[Index]
> - );
> - }
> + //
> + // Convert normal PPIs.
> + //
> + for (Index = 0; Index < PrivateData->PpiData.PpiList.CurrentCount; Index++) {
> + ConvertSinglePpiPointer (
> + SecCoreData,
> + PrivateData,
> + &PrivateData->PpiData.PpiList.PpiPtrs[Index]
> + );
> + }
> +
> + //
> + // Convert Callback Notification PPIs.
> + //
> + for (Index = 0; Index < PrivateData->PpiData.CallbackNotifyList.CurrentCount;
> Index++) {
> + ConvertSinglePpiPointer (
> + SecCoreData,
> + PrivateData,
> + &PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index]
> + );
> + }
> +
> + //
> + // Convert Dispatch Notification PPIs.
> + //
> + for (Index = 0; Index < PrivateData->PpiData.DispatchNotifyList.CurrentCount;
> Index++) {
> + ConvertSinglePpiPointer (
> + SecCoreData,
> + PrivateData,
> + &PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index]
> + );
> }
> }
>
> @@ -228,10 +229,11 @@ InternalPeiInstallPpi (
> IN BOOLEAN Single
> )
> {
> - PEI_CORE_INSTANCE *PrivateData;
> - INTN Index;
> - INTN LastCallbackInstall;
> -
> + PEI_CORE_INSTANCE *PrivateData;
> + PEI_PPI_LIST *PpiListPointer;
> + UINTN Index;
> + UINTN LastCount;
> + VOID *TempPtr;
>
> if (PpiList == NULL) {
> return EFI_INVALID_PARAMETER;
> @@ -239,8 +241,9 @@ InternalPeiInstallPpi (
>
> PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
>
> - Index = PrivateData->PpiData.PpiListEnd;
> - LastCallbackInstall = Index;
> + PpiListPointer = &PrivateData->PpiData.PpiList;
> + Index = PpiListPointer->CurrentCount;
> + LastCount = Index;
>
> //
> // This is loop installs all PPI descriptors in the PpiList. It is terminated
> @@ -250,27 +253,37 @@ InternalPeiInstallPpi (
>
> for (;;) {
> //
> - // Since PpiData is used for NotifyList and PpiList, max resource
> - // is reached if the Install reaches the NotifyList
> - // PcdPeiCoreMaxPpiSupported can be set to a larger value in DSC to satisfy
> more PPI requirement.
> - //
> - if (Index == PrivateData->PpiData.NotifyListEnd + 1) {
> - return EFI_OUT_OF_RESOURCES;
> - }
> - //
> // Check if it is a valid PPI.
> // If not, rollback list to exclude all in this list.
> // Try to indicate which item failed.
> //
> if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_PPI) == 0) {
> - PrivateData->PpiData.PpiListEnd = LastCallbackInstall;
> + PpiListPointer->CurrentCount = LastCount;
> DEBUG((EFI_D_ERROR, "ERROR -> InstallPpi: %g %p\n", PpiList->Guid,
> PpiList->Ppi));
> return EFI_INVALID_PARAMETER;
> }
>
> + if (Index == PpiListPointer->MaxCount) {
> + //
> + // Run out of room, grow the buffer.
> + //
> + TempPtr = AllocateZeroPool (
> + sizeof (PEI_PPI_LIST_POINTERS) * (PpiListPointer->MaxCount +
> PPI_GROWTH_STEP)
> + );
> + ASSERT (TempPtr != NULL);
> + CopyMem (
> + TempPtr,
> + PpiListPointer->PpiPtrs,
> + sizeof (PEI_PPI_LIST_POINTERS) * PpiListPointer->MaxCount
> + );
> + PpiListPointer->PpiPtrs = TempPtr;
> + PpiListPointer->MaxCount = PpiListPointer->MaxCount +
> PPI_GROWTH_STEP;
> + }
> +
It looks that he above PPI buffer expansion code have 3 copied in this patch.
Please consider to extract it as a function or macro.
> DEBUG((EFI_D_INFO, "Install PPI: %g\n", PpiList->Guid));
> - PrivateData->PpiData.PpiListPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR*)
> PpiList;
> - PrivateData->PpiData.PpiListEnd++;
> + PpiListPointer->PpiPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *) PpiList;
> + Index++;
> + PpiListPointer->CurrentCount++;
>
> if (Single) {
> //
> @@ -284,23 +297,24 @@ InternalPeiInstallPpi (
> //
> break;
> }
> + //
> + // Go to the next descriptor.
> + //
> PpiList++;
> - Index++;
> }
>
> //
> - // Dispatch any callback level notifies for newly installed PPIs.
> + // Process any callback level notifies for newly installed PPIs.
> //
> - DispatchNotify (
> + ProcessNotify (
> PrivateData,
> EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
> - LastCallbackInstall,
> - PrivateData->PpiData.PpiListEnd,
> - PrivateData->PpiData.DispatchListEnd,
> - PrivateData->PpiData.NotifyListEnd
> + LastCount,
> + PpiListPointer->CurrentCount,
> + 0,
> + PrivateData->PpiData.CallbackNotifyList.CurrentCount
> );
>
> -
> return EFI_SUCCESS;
> }
>
> @@ -355,7 +369,7 @@ PeiReInstallPpi (
> )
> {
> PEI_CORE_INSTANCE *PrivateData;
> - INTN Index;
> + UINTN Index;
>
>
> if ((OldPpi == NULL) || (NewPpi == NULL)) {
> @@ -372,35 +386,33 @@ PeiReInstallPpi (
> // Find the old PPI instance in the database. If we can not find it,
> // return the EFI_NOT_FOUND error.
> //
> - for (Index = 0; Index < PrivateData->PpiData.PpiListEnd; Index++) {
> - if (OldPpi == PrivateData->PpiData.PpiListPtrs[Index].Ppi) {
> + for (Index = 0; Index < PrivateData->PpiData.PpiList.CurrentCount; Index++) {
> + if (OldPpi == PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi) {
> break;
> }
> }
> - if (Index == PrivateData->PpiData.PpiListEnd) {
> + if (Index == PrivateData->PpiData.PpiList.CurrentCount) {
> return EFI_NOT_FOUND;
> }
>
> //
> - // Remove the old PPI from the database, add the new one.
> + // Replace the old PPI with the new one.
> //
> DEBUG((EFI_D_INFO, "Reinstall PPI: %g\n", NewPpi->Guid));
> - ASSERT (Index < (INTN)(PcdGet32 (PcdPeiCoreMaxPpiSupported)));
> - PrivateData->PpiData.PpiListPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *)
> NewPpi;
> + PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *)
> NewPpi;
>
> //
> - // Dispatch any callback level notifies for the newly installed PPI.
> + // Process any callback level notifies for the newly installed PPI.
> //
> - DispatchNotify (
> + ProcessNotify (
> PrivateData,
> EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
> Index,
> Index+1,
> - PrivateData->PpiData.DispatchListEnd,
> - PrivateData->PpiData.NotifyListEnd
> + 0,
> + PrivateData->PpiData.CallbackNotifyList.CurrentCount
> );
>
> -
> return EFI_SUCCESS;
> }
>
> @@ -430,10 +442,10 @@ PeiLocatePpi (
> IN OUT VOID **Ppi
> )
> {
> - PEI_CORE_INSTANCE *PrivateData;
> - INTN Index;
> - EFI_GUID *CheckGuid;
> - EFI_PEI_PPI_DESCRIPTOR *TempPtr;
> + PEI_CORE_INSTANCE *PrivateData;
> + UINTN Index;
> + EFI_GUID *CheckGuid;
> + EFI_PEI_PPI_DESCRIPTOR *TempPtr;
>
>
> PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
> @@ -441,8 +453,8 @@ PeiLocatePpi (
> //
> // Search the data base for the matching instance of the GUIDed PPI.
> //
> - for (Index = 0; Index < PrivateData->PpiData.PpiListEnd; Index++) {
> - TempPtr = PrivateData->PpiData.PpiListPtrs[Index].Ppi;
> + for (Index = 0; Index < PrivateData->PpiData.PpiList.CurrentCount; Index++) {
> + TempPtr = PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi;
> CheckGuid = TempPtr->Guid;
>
> //
> @@ -498,15 +510,14 @@ InternalPeiNotifyPpi (
> IN BOOLEAN Single
> )
> {
> - PEI_CORE_INSTANCE *PrivateData;
> - INTN Index;
> - INTN NotifyIndex;
> - INTN LastCallbackNotify;
> - EFI_PEI_NOTIFY_DESCRIPTOR *NotifyPtr;
> - UINTN NotifyDispatchCount;
> -
> -
> - NotifyDispatchCount = 0;
> + PEI_CORE_INSTANCE *PrivateData;
> + PEI_CALLBACK_NOTIFY_LIST *CallbackNotifyListPointer;
> + UINTN CallbackNotifyIndex;
> + UINTN LastCallbackNotifyCount;
> + PEI_DISPATCH_NOTIFY_LIST *DispatchNotifyListPointer;
> + UINTN DispatchNotifyIndex;
> + UINTN LastDispatchNotifyCount;
> + VOID *TempPtr;
>
> if (NotifyList == NULL) {
> return EFI_INVALID_PARAMETER;
> @@ -514,8 +525,13 @@ InternalPeiNotifyPpi (
>
> PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
>
> - Index = PrivateData->PpiData.NotifyListEnd;
> - LastCallbackNotify = Index;
> + CallbackNotifyListPointer = &PrivateData->PpiData.CallbackNotifyList;
> + CallbackNotifyIndex = CallbackNotifyListPointer->CurrentCount;
> + LastCallbackNotifyCount = CallbackNotifyIndex;
> +
> + DispatchNotifyListPointer = &PrivateData->PpiData.DispatchNotifyList;
> + DispatchNotifyIndex = DispatchNotifyListPointer->CurrentCount;
> + LastDispatchNotifyCount = DispatchNotifyIndex;
>
> //
> // This is loop installs all Notify descriptors in the NotifyList. It is
> @@ -525,31 +541,59 @@ InternalPeiNotifyPpi (
>
> for (;;) {
> //
> - // Since PpiData is used for NotifyList and InstallList, max resource
> - // is reached if the Install reaches the PpiList
> - // PcdPeiCoreMaxPpiSupported can be set to a larger value in DSC to satisfy
> more Notify PPIs requirement.
> - //
> - if (Index == PrivateData->PpiData.PpiListEnd - 1) {
> - return EFI_OUT_OF_RESOURCES;
> - }
> -
> - //
> // If some of the PPI data is invalid restore original Notify PPI database value
> //
> if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES) == 0) {
> - PrivateData->PpiData.NotifyListEnd = LastCallbackNotify;
> - DEBUG((EFI_D_ERROR, "ERROR -> InstallNotify: %g %p\n", NotifyList-
> >Guid, NotifyList->Notify));
> + CallbackNotifyListPointer->CurrentCount = LastCallbackNotifyCount;
> + DispatchNotifyListPointer->CurrentCount = LastDispatchNotifyCount;
> + DEBUG((EFI_D_ERROR, "ERROR -> NotifyPpi: %g %p\n", NotifyList->Guid,
> NotifyList->Notify));
> return EFI_INVALID_PARAMETER;
> }
>
> - if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH) != 0) {
> - NotifyDispatchCount ++;
> + if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK) != 0) {
> + if (CallbackNotifyIndex == CallbackNotifyListPointer->MaxCount) {
> + //
> + // Run out of room, grow the buffer.
> + //
> + TempPtr = AllocateZeroPool (
> + sizeof (PEI_PPI_LIST_POINTERS) * (CallbackNotifyListPointer-
> >MaxCount + CALLBACK_NOTIFY_GROWTH_STEP)
> + );
> + ASSERT (TempPtr != NULL);
> + CopyMem (
> + TempPtr,
> + CallbackNotifyListPointer->NotifyPtrs,
> + sizeof (PEI_PPI_LIST_POINTERS) * CallbackNotifyListPointer->MaxCount
> + );
> + CallbackNotifyListPointer->NotifyPtrs = TempPtr;
> + CallbackNotifyListPointer->MaxCount = CallbackNotifyListPointer-
> >MaxCount + CALLBACK_NOTIFY_GROWTH_STEP;
> + }
> + CallbackNotifyListPointer->NotifyPtrs[CallbackNotifyIndex].Notify =
> (EFI_PEI_NOTIFY_DESCRIPTOR *) NotifyList;
> + CallbackNotifyIndex++;
> + CallbackNotifyListPointer->CurrentCount++;
> + } else {
> + if (DispatchNotifyIndex == DispatchNotifyListPointer->MaxCount) {
> + //
> + // Run out of room, grow the buffer.
> + //
> + TempPtr = AllocateZeroPool (
> + sizeof (PEI_PPI_LIST_POINTERS) * (DispatchNotifyListPointer-
> >MaxCount + DISPATCH_NOTIFY_GROWTH_STEP)
> + );
> + ASSERT (TempPtr != NULL);
> + CopyMem (
> + TempPtr,
> + DispatchNotifyListPointer->NotifyPtrs,
> + sizeof (PEI_PPI_LIST_POINTERS) * DispatchNotifyListPointer->MaxCount
> + );
> + DispatchNotifyListPointer->NotifyPtrs = TempPtr;
> + DispatchNotifyListPointer->MaxCount = DispatchNotifyListPointer-
> >MaxCount + DISPATCH_NOTIFY_GROWTH_STEP;
> + }
> + DispatchNotifyListPointer->NotifyPtrs[DispatchNotifyIndex].Notify =
> (EFI_PEI_NOTIFY_DESCRIPTOR *) NotifyList;
> + DispatchNotifyIndex++;
> + DispatchNotifyListPointer->CurrentCount++;
> }
>
> - PrivateData->PpiData.PpiListPtrs[Index].Notify =
> (EFI_PEI_NOTIFY_DESCRIPTOR *) NotifyList;
> -
> - PrivateData->PpiData.NotifyListEnd--;
> DEBUG((EFI_D_INFO, "Register PPI Notify: %g\n", NotifyList->Guid));
> +
> if (Single) {
> //
> // Only single entry in the NotifyList.
> @@ -563,41 +607,21 @@ InternalPeiNotifyPpi (
> break;
> }
> //
> - // Go the next descriptor. Remember the NotifyList moves down.
> + // Go to the next descriptor.
> //
> NotifyList++;
> - Index--;
> - }
> -
> - //
> - // If there is Dispatch Notify PPI installed put them on the bottom
> - //
> - if (NotifyDispatchCount > 0) {
> - for (NotifyIndex = LastCallbackNotify; NotifyIndex > PrivateData-
> >PpiData.NotifyListEnd; NotifyIndex--) {
> - if ((PrivateData->PpiData.PpiListPtrs[NotifyIndex].Notify->Flags &
> EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH) != 0) {
> - NotifyPtr = PrivateData->PpiData.PpiListPtrs[NotifyIndex].Notify;
> -
> - for (Index = NotifyIndex; Index < PrivateData->PpiData.DispatchListEnd;
> Index++){
> - PrivateData->PpiData.PpiListPtrs[Index].Notify = PrivateData-
> >PpiData.PpiListPtrs[Index + 1].Notify;
> - }
> - PrivateData->PpiData.PpiListPtrs[Index].Notify = NotifyPtr;
> - PrivateData->PpiData.DispatchListEnd--;
> - }
> - }
> -
> - LastCallbackNotify -= NotifyDispatchCount;
> }
>
> //
> - // Dispatch any callback level notifies for all previously installed PPIs.
> + // Process any callback level notifies for all previously installed PPIs.
> //
> - DispatchNotify (
> + ProcessNotify (
> PrivateData,
> EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
> 0,
> - PrivateData->PpiData.PpiListEnd,
> - LastCallbackNotify,
> - PrivateData->PpiData.NotifyListEnd
> + PrivateData->PpiData.PpiList.CurrentCount,
> + LastCallbackNotifyCount,
> + CallbackNotifyListPointer->CurrentCount
> );
>
> return EFI_SUCCESS;
> @@ -627,7 +651,6 @@ PeiNotifyPpi (
> return InternalPeiNotifyPpi (PeiServices, NotifyList, FALSE);
> }
>
> -
> /**
>
> Process the Notify List at dispatch level.
> @@ -636,55 +659,56 @@ PeiNotifyPpi (
>
> **/
> VOID
> -ProcessNotifyList (
> +ProcessDispatchNotifyList (
> IN PEI_CORE_INSTANCE *PrivateData
> )
> {
> - INTN TempValue;
> + UINTN TempValue;
>
> while (TRUE) {
> //
> // Check if the PEIM that was just dispatched resulted in any
> // Notifies getting installed. If so, go process any dispatch
> // level Notifies that match the previouly installed PPIs.
> - // Use "while" instead of "if" since DispatchNotify can modify
> - // DispatchListEnd (with NotifyPpi) so we have to iterate until the same.
> + // Use "while" instead of "if" since ProcessNotify can modify
> + // DispatchNotifyList.CurrentCount (with NotifyPpi) so we have
> + // to iterate until the same.
> //
> - while (PrivateData->PpiData.LastDispatchedNotify != PrivateData-
> >PpiData.DispatchListEnd) {
> - TempValue = PrivateData->PpiData.DispatchListEnd;
> - DispatchNotify (
> + while (PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount !=
> PrivateData->PpiData.DispatchNotifyList.CurrentCount) {
> + TempValue = PrivateData->PpiData.DispatchNotifyList.CurrentCount;
> + ProcessNotify (
> PrivateData,
> EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH,
> 0,
> - PrivateData->PpiData.LastDispatchedInstall,
> - PrivateData->PpiData.LastDispatchedNotify,
> - PrivateData->PpiData.DispatchListEnd
> + PrivateData->PpiData.PpiList.LastDispatchedCount,
> + PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount,
> + PrivateData->PpiData.DispatchNotifyList.CurrentCount
> );
> - PrivateData->PpiData.LastDispatchedNotify = TempValue;
> + PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount =
> TempValue;
> }
>
> -
> //
> // Check if the PEIM that was just dispatched resulted in any
> // PPIs getting installed. If so, go process any dispatch
> // level Notifies that match the installed PPIs.
> - // Use "while" instead of "if" since DispatchNotify can modify
> - // PpiListEnd (with InstallPpi) so we have to iterate until the same.
> + // Use "while" instead of "if" since ProcessNotify can modify
> + // PpiList.CurrentCount (with InstallPpi) so we have to iterate
> + // until the same.
> //
> - while (PrivateData->PpiData.LastDispatchedInstall != PrivateData-
> >PpiData.PpiListEnd) {
> - TempValue = PrivateData->PpiData.PpiListEnd;
> - DispatchNotify (
> + while (PrivateData->PpiData.PpiList.LastDispatchedCount != PrivateData-
> >PpiData.PpiList.CurrentCount) {
> + TempValue = PrivateData->PpiData.PpiList.CurrentCount;
> + ProcessNotify (
> PrivateData,
> EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH,
> - PrivateData->PpiData.LastDispatchedInstall,
> - PrivateData->PpiData.PpiListEnd,
> - PcdGet32 (PcdPeiCoreMaxPpiSupported)-1,
> - PrivateData->PpiData.DispatchListEnd
> + PrivateData->PpiData.PpiList.LastDispatchedCount,
> + PrivateData->PpiData.PpiList.CurrentCount,
> + 0,
> + PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount
> );
> - PrivateData->PpiData.LastDispatchedInstall = TempValue;
> + PrivateData->PpiData.PpiList.LastDispatchedCount = TempValue;
> }
>
> - if (PrivateData->PpiData.LastDispatchedNotify == PrivateData-
> >PpiData.DispatchListEnd) {
> + if (PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount ==
> PrivateData->PpiData.DispatchNotifyList.CurrentCount) {
> break;
> }
> }
> @@ -693,7 +717,7 @@ ProcessNotifyList (
>
> /**
>
> - Dispatch notifications.
> + Process notifications.
>
> @param PrivateData PeiCore's private data structure
> @param NotifyType Type of notify to fire.
> @@ -704,7 +728,7 @@ ProcessNotifyList (
>
> **/
> VOID
> -DispatchNotify (
> +ProcessNotify (
> IN PEI_CORE_INSTANCE *PrivateData,
> IN UINTN NotifyType,
> IN INTN InstallStartIndex,
> @@ -713,22 +737,23 @@ DispatchNotify (
> IN INTN NotifyStopIndex
> )
> {
> - INTN Index1;
> - INTN Index2;
> - EFI_GUID *SearchGuid;
> - EFI_GUID *CheckGuid;
> - EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;
> -
> - //
> - // Remember that Installs moves up and Notifies moves down.
> - //
> - for (Index1 = NotifyStartIndex; Index1 > NotifyStopIndex; Index1--) {
> - NotifyDescriptor = PrivateData->PpiData.PpiListPtrs[Index1].Notify;
> + INTN Index1;
> + INTN Index2;
> + EFI_GUID *SearchGuid;
> + EFI_GUID *CheckGuid;
> + EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;
> +
> + for (Index1 = NotifyStartIndex; Index1 < NotifyStopIndex; Index1++) {
> + if (NotifyType == EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK) {
> + NotifyDescriptor = PrivateData-
> >PpiData.CallbackNotifyList.NotifyPtrs[Index1].Notify;
> + } else {
> + NotifyDescriptor = PrivateData-
> >PpiData.DispatchNotifyList.NotifyPtrs[Index1].Notify;
> + }
>
> CheckGuid = NotifyDescriptor->Guid;
>
> for (Index2 = InstallStartIndex; Index2 < InstallStopIndex; Index2++) {
> - SearchGuid = PrivateData->PpiData.PpiListPtrs[Index2].Ppi->Guid;
> + SearchGuid = PrivateData->PpiData.PpiList.PpiPtrs[Index2].Ppi->Guid;
> //
> // Don't use CompareGuid function here for performance reasons.
> // Instead we compare the GUID as INT32 at a time and branch
> @@ -745,7 +770,7 @@ DispatchNotify (
> NotifyDescriptor->Notify (
> (EFI_PEI_SERVICES **) GetPeiServicesTablePointer (),
> NotifyDescriptor,
> - (PrivateData->PpiData.PpiListPtrs[Index2].Ppi)->Ppi
> + (PrivateData->PpiData.PpiList.PpiPtrs[Index2].Ppi)->Ppi
> );
> }
> }
> --
> 2.7.0.windows.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 1/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPeimPerFv
2018-12-18 2:04 ` Wang, Jian J
@ 2018-12-18 2:45 ` Zeng, Star
0 siblings, 0 replies; 23+ messages in thread
From: Zeng, Star @ 2018-12-18 2:45 UTC (permalink / raw)
To: Wang, Jian J, edk2-devel@lists.01.org
Cc: Wu, Hao A, Gao, Liming, Ni, Ruiyu, Kinney, Michael D,
Desimone, Nathaniel L, Chiu, Chasel, Zeng, Star
Good suggestion. It will make the buffer extension log consistent.
I will send V2 to cover it with some test.
Thanks,
Star
-----Original Message-----
From: Wang, Jian J
Sent: Tuesday, December 18, 2018 10:04 AM
To: Zeng, Star <star.zeng@intel.com>; edk2-devel@lists.01.org
Cc: Wu, Hao A <hao.a.wu@intel.com>; Gao, Liming <liming.gao@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Chiu, Chasel <chasel.chiu@intel.com>
Subject: RE: [PATCH 1/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPeimPerFv
Star,
Just one place which might need refine. Please see it below.
Regards,
Jian
> -----Original Message-----
> From: Zeng, Star
> Sent: Friday, December 14, 2018 6:29 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star <star.zeng@intel.com>; Wang, Jian J
> <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Liming
> <liming.gao@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; Kinney,
> Michael D <michael.d.kinney@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>; Chiu, Chasel <chasel.chiu@intel.com>
> Subject: [PATCH 1/7] MdeModulePkg PeiCore: Remove the using of
> PcdPeiCoreMaxPeimPerFv
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405
>
> Background as below.
>
> Problem:
> As static configuration from the PCDs, the binary PeiCore (for example
> in FSP binary with dispatch mode) could not predict how many FVs,
> Files or PPIs for different platforms.
>
> Burden:
> Platform developers need configure the PCDs accordingly for different
> platforms.
>
> To solve the problem and remove the burden, we can update code to
> remove the using of PcdPeiCoreMaxFvSupported, PcdPeiCoreMaxPeimPerFv
> and PcdPeiCoreMaxPpiSupported by extending buffer dynamically for FV,
> File and PPI management.
>
> This patch removes the using of PcdPeiCoreMaxPeimPerFv in PeiCore.
>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao Wu <hao.a.wu@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng <star.zeng@intel.com>
> ---
> MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 199
> ++++++++++++++++----
> ------
> MdeModulePkg/Core/Pei/PeiMain.h | 17 ++-
> MdeModulePkg/Core/Pei/PeiMain.inf | 1 -
> MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 48 +++----
> 4 files changed, 157 insertions(+), 108 deletions(-)
>
> diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> index f6bb35a5fe8d..71440bab9488 100644
> --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> @@ -41,7 +41,8 @@ DiscoverPeimsAndOrderWithApriori (
> UINTN PeimCount;
> EFI_GUID *Guid;
> EFI_PEI_FILE_HANDLE *TempFileHandles;
> - EFI_GUID *FileGuid;
> + EFI_GUID *TempFileGuid;
> + UINTN TempPeimCount;
> EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi;
> EFI_FV_FILE_INFO FileInfo;
>
> @@ -51,38 +52,106 @@ DiscoverPeimsAndOrderWithApriori (
> // Walk the FV and find all the PEIMs and the Apriori file.
> //
> AprioriFileHandle = NULL;
> - Private->CurrentFvFileHandles[0] = NULL;
> + Private->CurrentFvFileHandles = NULL;
> Guid = NULL;
> - FileHandle = NULL;
> - TempFileHandles = Private->FileHandles;
> - FileGuid = Private->FileGuid;
>
> //
> - // If the current Fv has been scanned, directly get its cachable record.
> + // If the current Fv has been scanned, directly get its cached records.
> //
> - if (Private->Fv[Private->CurrentPeimFvCount].ScanFv) {
> - CopyMem (Private->CurrentFvFileHandles, Private->Fv[Private-
> >CurrentPeimFvCount].FvFileHandles, sizeof (EFI_PEI_FILE_HANDLE) *
> >PcdGet32
> (PcdPeiCoreMaxPeimPerFv));
> + if (CoreFileHandle->ScanFv) {
> + Private->CurrentFvFileHandles = CoreFileHandle->FvFileHandles;
> return;
> }
>
> + if (Private->TempPeimCount == 0) {
> + //
> + // Initialize the temp buffers.
> + //
> + Private->TempPeimCount = 32;
> + Private->TempFileHandles = AllocatePool (sizeof
> + (EFI_PEI_FILE_HANDLE) *
> 32);
> + ASSERT (Private->TempFileHandles != NULL);
> + Private->TempFileGuid = AllocatePool (sizeof (EFI_GUID) * 32);
> + ASSERT (Private->TempFileGuid != NULL); } TempFileHandles =
> + Private->TempFileHandles;
> + TempFileGuid = Private->TempFileGuid;
> +
> //
> - // Go ahead to scan this Fv, and cache FileHandles within it.
> + // Go ahead to scan this Fv, get PeimCount and cache FileHandles
> + within it to
> TempFileHandles.
> //
> - Status = EFI_NOT_FOUND;
> - for (PeimCount = 0; PeimCount <= PcdGet32 (PcdPeiCoreMaxPeimPerFv);
> PeimCount++) {
> + PeimCount = 0;
> + FileHandle = NULL;
> + TempPeimCount = 0;
> + do {
> Status = FvPpi->FindFileByType (FvPpi,
> PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE, CoreFileHandle->FvHandle,
> &FileHandle);
> - if (Status != EFI_SUCCESS || PeimCount == PcdGet32
> (PcdPeiCoreMaxPeimPerFv)) {
> - break;
> + if (!EFI_ERROR (Status)) {
> + if (TempPeimCount < Private->TempPeimCount) {
> + TempFileHandles[TempPeimCount] = FileHandle;
> + TempPeimCount++;
> + }
> + PeimCount++;
> }
> + } while (!EFI_ERROR (Status));
>
> - Private->CurrentFvFileHandles[PeimCount] = FileHandle;
> + DEBUG ((
> + DEBUG_INFO,
> + "%a(): Found 0x%x PEI FFS files in the %dth FV\n",
> + __FUNCTION__,
> + PeimCount,
> + Private->CurrentPeimFvCount
> + ));
> +
> + if (PeimCount == 0) {
> + //
> + // No PEIM FFS file is found, set ScanFv flag and return.
> + //
> + CoreFileHandle->ScanFv = TRUE;
> + return;
> + }
> +
> + if (PeimCount > Private->TempPeimCount) {
> + //
> + // The temp buffers are too small, allocate bigger ones.
> + //
> + TempFileHandles = AllocatePool (sizeof (EFI_PEI_FILE_HANDLE) *
> PeimCount);
> + ASSERT (TempFileHandles != NULL);
> + CopyMem (
> + TempFileHandles,
> + Private->TempFileHandles,
> + sizeof (EFI_PEI_FILE_HANDLE) * Private->TempPeimCount
> + );
> + Private->TempFileHandles = TempFileHandles;
> + TempFileGuid = AllocatePool (sizeof (EFI_GUID) * PeimCount);
> + ASSERT (TempFileGuid != NULL);
> + CopyMem (
> + TempFileGuid,
> + Private->TempFileGuid,
> + sizeof (EFI_GUID) * Private->TempPeimCount
> + );
> + Private->TempFileGuid = TempFileGuid;
> + Private->TempPeimCount = PeimCount;
> }
>
> //
> - // Check whether the count of files exceeds the max support files
> in a FV image
> - // If more files are required in a FV image, PcdPeiCoreMaxPeimPerFv
> can be set to a larger value in DSC file.
> + // Record PeimCount, allocate buffer for PeimState and FvFileHandles.
> + //
> + CoreFileHandle->PeimCount = PeimCount; CoreFileHandle->PeimState =
> + AllocateZeroPool (sizeof (UINT8) * PeimCount); ASSERT
> + (CoreFileHandle->PeimState != NULL); CoreFileHandle->FvFileHandles
> + = AllocateZeroPool (sizeof
> (EFI_PEI_FILE_HANDLE) * PeimCount);
> + ASSERT (CoreFileHandle->FvFileHandles != NULL);
> +
> //
> - ASSERT ((Status != EFI_SUCCESS) || (PeimCount < PcdGet32
> (PcdPeiCoreMaxPeimPerFv)));
> + // TempFileHandles may be not big enough in last scan.
> + // Go ahead to rescan this Fv, and cache remaining FileHandles
> + within it to
> TempFileHandles.
> + //
> + FileHandle = TempFileHandles[TempPeimCount - 1]; for (;
> + TempPeimCount < PeimCount; TempPeimCount++) {
> + Status = FvPpi->FindFileByType (FvPpi,
> PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE, CoreFileHandle->FvHandle,
> &FileHandle);
> + ASSERT_EFI_ERROR (Status);
> +
> + TempFileHandles[TempPeimCount] = FileHandle; }
>
Above logic looks have some redundant code. And the FV might be re-scanned if there're more than 32 PEIMs in it. If the scan is time consuming task, maybe it'd be better to refine the logic. Maybe something like below (just show the idea, not verified yet).
PeimCount = 0;
FileHandle = NULL;
TempPeimCount = 0;
TempFileHandles = Private->TempFileHandles;
TempFileGuid = Private->TempFileGuid;
do {
Status = FvPpi->FindFileByType(FvPpi, PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE, CoreFileHandle->FvHandle, &FileHandle);
if (!EFI_ERROR (Status)) {
PeimCount++;
//
// Have enought buffer?
//
if (Private->TempPeimCount < PeimCount) {
Private->TempPeimCount += 32;
TempFileHandles = Private->TempFileHandles;
TempFileGuid = Private->TempFileGuid;
Private->TempFileHandles = AllocatePool (sizeof (EFI_PEI_FILE_HANDLE) * Private->TempPeimCount);
ASSERT (Private->TempFileHandles != NULL);
Private->TempFileGuid = AllocatePool (sizeof (EFI_GUID) * Private->TempPeimCount);
ASSERT (Private->TempFileGuid != NULL);
if (TempFileHandles != NULL) {
CopyMem (
Private->TempFileHandles,
TempFileHandles,
sizeof (EFI_PEI_FILE_HANDLE) * (PeimCount - 1)
);
}
if (TempFileGuid != NULL) {
CopyMem (
Private->TempFileGuid,
TempFileGuid,
sizeof (EFI_GUID) * (PeimCount - 1)
);
}
TempPeimCount = 0;
TempFileHandles = Private->TempFileHandles + PeimCount - 1;
TempFileGuid = Private->TempFileGuid + PeimCount - 1;
}
TempFileHandles[TempPeimCount++] = FileHandle;
}
} while (!EFI_ERROR (Status));
> //
> // Get Apriori File handle
> @@ -96,7 +165,7 @@ DiscoverPeimsAndOrderWithApriori (
> Status = FvPpi->FindSectionByType (FvPpi, EFI_SECTION_RAW,
> AprioriFileHandle, (VOID **) &Apriori);
> if (!EFI_ERROR (Status)) {
> //
> - // Calculate the number of PEIMs in the A Priori list
> + // Calculate the number of PEIMs in the Apriori file
> //
> Status = FvPpi->GetFileInfo (FvPpi, AprioriFileHandle, &FileInfo);
> ASSERT_EFI_ERROR (Status);
> @@ -113,71 +182,55 @@ DiscoverPeimsAndOrderWithApriori (
> // Make an array of file name guids that matches the
> FileHandle array so we can convert
> // quickly from file name to file handle
> //
> - Status = FvPpi->GetFileInfo (FvPpi, Private->CurrentFvFileHandles[Index],
> &FileInfo);
> - CopyMem (&FileGuid[Index], &FileInfo.FileName, sizeof(EFI_GUID));
> + Status = FvPpi->GetFileInfo (FvPpi, TempFileHandles[Index], &FileInfo);
> + ASSERT_EFI_ERROR (Status);
> + CopyMem (&TempFileGuid[Index], &FileInfo.FileName,
> + sizeof(EFI_GUID));
> }
>
> //
> - // Walk through FileGuid array to find out who is invalid PEIM guid in Apriori
> file.
> - // Add available PEIMs in Apriori file into TempFileHandles array at first.
> + // Walk through TempFileGuid array to find out who is invalid
> + PEIM guid in
> Apriori file.
> + // Add available PEIMs in Apriori file into FvFileHandles array.
> //
> - Index2 = 0;
> - for (Index = 0; Index2 < Private->AprioriCount; Index++) {
> - while (Index2 < Private->AprioriCount) {
> - Guid = ScanGuid (FileGuid, PeimCount * sizeof (EFI_GUID),
> &Apriori[Index2++]);
> - if (Guid != NULL) {
> - break;
> - }
> - }
> - if (Guid == NULL) {
> - break;
> - }
> - PeimIndex = ((UINTN)Guid - (UINTN)&FileGuid[0])/sizeof (EFI_GUID);
> - TempFileHandles[Index] = Private->CurrentFvFileHandles[PeimIndex];
> + Index = 0;
> + for (Index2 = 0; Index2 < Private->AprioriCount; Index2++) {
> + Guid = ScanGuid (TempFileGuid, PeimCount * sizeof (EFI_GUID),
> &Apriori[Index2]);
> + if (Guid != NULL) {
> + PeimIndex = ((UINTN)Guid - (UINTN)&TempFileGuid[0])/sizeof (EFI_GUID);
> + CoreFileHandle->FvFileHandles[Index++] =
> + TempFileHandles[PeimIndex];
>
> - //
> - // Since we have copied the file handle we can remove it from this list.
> - //
> - Private->CurrentFvFileHandles[PeimIndex] = NULL;
> + //
> + // Since we have copied the file handle we can remove it from this list.
> + //
> + TempFileHandles[PeimIndex] = NULL;
> + }
> }
>
> //
> - // Update valid Aprioricount
> + // Update valid AprioriCount
> //
> Private->AprioriCount = Index;
>
> //
> // Add in any PEIMs not in the Apriori file
> //
> - for (;Index < PeimCount; Index++) {
> - for (Index2 = 0; Index2 < PeimCount; Index2++) {
> - if (Private->CurrentFvFileHandles[Index2] != NULL) {
> - TempFileHandles[Index] = Private->CurrentFvFileHandles[Index2];
> - Private->CurrentFvFileHandles[Index2] = NULL;
> - break;
> - }
> + for (Index2 = 0; Index2 < PeimCount; Index2++) {
> + if (TempFileHandles[Index2] != NULL) {
> + CoreFileHandle->FvFileHandles[Index++] = TempFileHandles[Index2];
> + TempFileHandles[Index2] = NULL;
> }
> }
> - //
> - //Index the end of array contains re-range Pei moudle.
> - //
> - TempFileHandles[Index] = NULL;
> -
> - //
> - // Private->CurrentFvFileHandles is currently in PEIM in the FV order.
> - // We need to update it to start with files in the A Priori list and
> - // then the remaining files in PEIM order.
> - //
> - CopyMem (Private->CurrentFvFileHandles, TempFileHandles, sizeof
> (EFI_PEI_FILE_HANDLE) * PcdGet32 (PcdPeiCoreMaxPeimPerFv));
> + ASSERT (Index == PeimCount);
> }
> + } else {
> + CopyMem (CoreFileHandle->FvFileHandles, TempFileHandles, sizeof
> (EFI_PEI_FILE_HANDLE) * PeimCount);
> }
> +
> //
> - // Cache the current Fv File Handle. So that we don't have to scan the Fv again.
> - // Instead, we can retrieve the file handles within this Fv from cachable data.
> + // The current Fv File Handles have been cached. So that we don't
> + have to
> scan the Fv again.
> + // Instead, we can retrieve the file handles within this Fv from cached records.
> //
> - Private->Fv[Private->CurrentPeimFvCount].ScanFv = TRUE;
> - CopyMem (Private->Fv[Private->CurrentPeimFvCount].FvFileHandles,
> Private-
> >CurrentFvFileHandles, sizeof (EFI_PEI_FILE_HANDLE) * PcdGet32
> (PcdPeiCoreMaxPeimPerFv));
> -
> + CoreFileHandle->ScanFv = TRUE;
> + Private->CurrentFvFileHandles = CoreFileHandle->FvFileHandles;
> }
>
> //
> @@ -977,7 +1030,7 @@ PeiDispatcher (
> SaveCurrentFileHandle = Private->CurrentFileHandle;
>
> for (Index1 = 0; Index1 < Private->FvCount; Index1++) {
> - for (Index2 = 0; (Index2 < PcdGet32 (PcdPeiCoreMaxPeimPerFv)) &&
> (Private->Fv[Index1].FvFileHandles[Index2] != NULL); Index2++) {
> + for (Index2 = 0; Index2 < Private->Fv[Index1].PeimCount;
> + Index2++) {
> if (Private->Fv[Index1].PeimState[Index2] ==
> PEIM_STATE_REGISTER_FOR_SHADOW) {
> PeimFileHandle = Private->Fv[Index1].FvFileHandles[Index2];
> Private->CurrentFileHandle = PeimFileHandle;
> @@ -1063,7 +1116,7 @@ PeiDispatcher (
> // Start to dispatch all modules within the current Fv.
> //
> for (PeimCount = Private->CurrentPeimCount;
> - (PeimCount < PcdGet32 (PcdPeiCoreMaxPeimPerFv)) && (Private-
> >CurrentFvFileHandles[PeimCount] != NULL);
> + PeimCount < Private->Fv[FvCount].PeimCount;
> PeimCount++) {
> Private->CurrentPeimCount = PeimCount;
> PeimFileHandle = Private->CurrentFileHandle = Private-
> >CurrentFvFileHandles[PeimCount];
> @@ -1207,21 +1260,17 @@ PeiDispatcher (
> }
>
> //
> - // We set to NULL here to optimize the 2nd entry to this routine after
> - // memory is found. This reprevents rescanning of the FV. We set to
> - // NULL here so we start at the begining of the next FV
> + // Before walking through the next FV, we should set them to NULL/0 to
> + // start at the begining of the next FV.
> //
> Private->CurrentFileHandle = NULL;
> Private->CurrentPeimCount = 0;
> - //
> - // Before walking through the next FV,Private-
> >CurrentFvFileHandles[]should set to NULL
> - //
> - SetMem (Private->CurrentFvFileHandles, sizeof (EFI_PEI_FILE_HANDLE) *
> PcdGet32 (PcdPeiCoreMaxPeimPerFv), 0);
> + Private->CurrentFvFileHandles = NULL;
> }
>
> //
> - // Before making another pass, we should set Private->CurrentPeimFvCount
> =0 to go
> - // through all the FV.
> + // Before making another pass, we should set it to 0 to
> + // go through all the FVs.
> //
> Private->CurrentPeimFvCount = 0;
>
> @@ -1300,7 +1349,7 @@ DepexSatisfied (
>
> if (PeimCount < Private->AprioriCount) {
> //
> - // If its in the A priori file then we set Depex to TRUE
> + // If it's in the Apriori file then we set Depex to TRUE
> //
> DEBUG ((DEBUG_DISPATCH, " RESULT = TRUE (Apriori)\n"));
> return TRUE;
> diff --git a/MdeModulePkg/Core/Pei/PeiMain.h
> b/MdeModulePkg/Core/Pei/PeiMain.h index 6469436b8f79..ab914c7d2e44
> 100644
> --- a/MdeModulePkg/Core/Pei/PeiMain.h
> +++ b/MdeModulePkg/Core/Pei/PeiMain.h
> @@ -111,12 +111,13 @@ typedef struct {
> EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
> EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi;
> EFI_PEI_FV_HANDLE FvHandle;
> + UINTN PeimCount;
> //
> - // Ponter to the buffer with the PcdPeiCoreMaxPeimPerFv number of Entries.
> + // Ponter to the buffer with the PeimCount number of Entries.
> //
> UINT8 *PeimState;
> //
> - // Ponter to the buffer with the PcdPeiCoreMaxPeimPerFv number of Entries.
> + // Ponter to the buffer with the PeimCount number of Entries.
> //
> EFI_PEI_FILE_HANDLE *FvFileHandles;
> BOOLEAN ScanFv;
> @@ -209,7 +210,7 @@ struct _PEI_CORE_INSTANCE {
> UINTN UnknownFvInfoCount;
>
> ///
> - /// Pointer to the buffer with the PcdPeiCoreMaxPeimPerFv number of entries.
> + /// Pointer to the buffer FvFileHandlers in PEI_CORE_FV_HANDLE
> + specified by
> CurrentPeimFvCount.
> ///
> EFI_PEI_FILE_HANDLE *CurrentFvFileHandles;
> UINTN AprioriCount;
> @@ -256,14 +257,16 @@ struct _PEI_CORE_INSTANCE {
> //
> PE_COFF_LOADER_READ_FILE ShadowedImageRead;
>
> + UINTN TempPeimCount;
> +
> //
> - // Pointer to the temp buffer with the PcdPeiCoreMaxPeimPerFv + 1
> number of entries.
> + // Pointer to the temp buffer with the TempPeimCount number of entries.
> //
> - EFI_PEI_FILE_HANDLE *FileHandles;
> + EFI_PEI_FILE_HANDLE *TempFileHandles;
> //
> - // Pointer to the temp buffer with the PcdPeiCoreMaxPeimPerFv
> number of entries.
> + // Pointer to the temp buffer with the TempPeimCount number of entries.
> //
> - EFI_GUID *FileGuid;
> + EFI_GUID *TempFileGuid;
>
> //
> // Temp Memory Range is not covered by PeiTempMem and Stack.
> diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf
> b/MdeModulePkg/Core/Pei/PeiMain.inf
> index 4e1581a926d9..d106c3606e97 100644
> --- a/MdeModulePkg/Core/Pei/PeiMain.inf
> +++ b/MdeModulePkg/Core/Pei/PeiMain.inf
> @@ -105,7 +105,6 @@ [Ppis]
>
> [Pcd]
> gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported ##
> CONSUMES
> - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv ##
> CONSUMES
> gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported ##
> CONSUMES
> gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize ##
> CONSUMES
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreImageLoaderSearchTeSectionFir
> st ## CONSUMES
> diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> index e3a301dfe0f2..52adefeb44b4 100644
> --- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> +++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> @@ -185,27 +185,39 @@ PeiCore (
> if (OldCoreData->HeapOffsetPositive) {
> OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw
> +
> OldCoreData->HeapOffset);
> OldCoreData->UnknownFvInfo =
> (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData-
> >UnknownFvInfo + OldCoreData->HeapOffset);
> - OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *)
> OldCoreData->CurrentFvFileHandles + OldCoreData->HeapOffset);
> + if (OldCoreData->CurrentFvFileHandles != NULL) {
> + OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *)
> + ((UINT8
> *) OldCoreData->CurrentFvFileHandles + OldCoreData->HeapOffset);
> + }
> OldCoreData->PpiData.PpiListPtrs = (PEI_PPI_LIST_POINTERS *)
> ((UINT8 *)
> OldCoreData->PpiData.PpiListPtrs + OldCoreData->HeapOffset);
> OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *)
> OldCoreData->Fv + OldCoreData->HeapOffset);
> for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {
> - OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData-
> >Fv[Index].PeimState + OldCoreData->HeapOffset;
> - OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *)
> ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles +
> OldCoreData->HeapOffset);
> + if (OldCoreData->Fv[Index].PeimState != NULL) {
> + OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData-
> >Fv[Index].PeimState + OldCoreData->HeapOffset;
> + }
> + if (OldCoreData->Fv[Index].FvFileHandles != NULL) {
> + OldCoreData->Fv[Index].FvFileHandles =
> + (EFI_PEI_FILE_HANDLE *)
> ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles +
> OldCoreData->HeapOffset);
> + }
> }
> - OldCoreData->FileGuid = (EFI_GUID *) ((UINT8 *) OldCoreData-
> >FileGuid + OldCoreData->HeapOffset);
> - OldCoreData->FileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *)
> OldCoreData->FileHandles + OldCoreData->HeapOffset);
> + OldCoreData->TempFileGuid = (EFI_GUID *) ((UINT8 *) OldCoreData-
> >TempFileGuid + OldCoreData->HeapOffset);
> + OldCoreData->TempFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *)
> OldCoreData->TempFileHandles + OldCoreData->HeapOffset);
> } else {
> OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw
> -
> OldCoreData->HeapOffset);
> OldCoreData->UnknownFvInfo =
> (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData-
> >UnknownFvInfo - OldCoreData->HeapOffset);
> - OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *)
> OldCoreData->CurrentFvFileHandles - OldCoreData->HeapOffset);
> + if (OldCoreData->CurrentFvFileHandles != NULL) {
> + OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *)
> + ((UINT8
> *) OldCoreData->CurrentFvFileHandles - OldCoreData->HeapOffset);
> + }
> OldCoreData->PpiData.PpiListPtrs = (PEI_PPI_LIST_POINTERS *)
> ((UINT8 *)
> OldCoreData->PpiData.PpiListPtrs - OldCoreData->HeapOffset);
> OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *)
> OldCoreData->Fv - OldCoreData->HeapOffset);
> for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {
> - OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData-
> >Fv[Index].PeimState - OldCoreData->HeapOffset;
> - OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *)
> ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles -
> OldCoreData->HeapOffset);
> + if (OldCoreData->Fv[Index].PeimState != NULL) {
> + OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData-
> >Fv[Index].PeimState - OldCoreData->HeapOffset;
> + }
> + if (OldCoreData->Fv[Index].FvFileHandles != NULL) {
> + OldCoreData->Fv[Index].FvFileHandles =
> + (EFI_PEI_FILE_HANDLE *)
> ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles -
> OldCoreData->HeapOffset);
> + }
> }
> - OldCoreData->FileGuid = (EFI_GUID *) ((UINT8 *) OldCoreData-
> >FileGuid - OldCoreData->HeapOffset);
> - OldCoreData->FileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *)
> OldCoreData->FileHandles - OldCoreData->HeapOffset);
> + OldCoreData->TempFileGuid = (EFI_GUID *) ((UINT8 *) OldCoreData-
> >TempFileGuid - OldCoreData->HeapOffset);
> + OldCoreData->TempFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *)
> OldCoreData->TempFileHandles - OldCoreData->HeapOffset);
> }
>
> //
> @@ -320,7 +332,7 @@ PeiCore (
> //
> // Initialize PEI Core Services
> //
> - InitializeMemoryServices (&PrivateData, SecCoreData, OldCoreData);
> + InitializeMemoryServices (&PrivateData, SecCoreData, OldCoreData);
> if (OldCoreData == NULL) {
> //
> // Initialize PEI Core Private Data Buffer @@ -329,22 +341,8 @@
> PeiCore (
> ASSERT (PrivateData.PpiData.PpiListPtrs != NULL);
> PrivateData.Fv = AllocateZeroPool (sizeof (PEI_CORE_FV_HANDLE)
> * PcdGet32 (PcdPeiCoreMaxFvSupported));
> ASSERT (PrivateData.Fv != NULL);
> - PrivateData.Fv[0].PeimState = AllocateZeroPool (sizeof (UINT8) *
> PcdGet32 (PcdPeiCoreMaxPeimPerFv) * PcdGet32 (PcdPeiCoreMaxFvSupported));
> - ASSERT (PrivateData.Fv[0].PeimState != NULL);
> - PrivateData.Fv[0].FvFileHandles = AllocateZeroPool (sizeof
> (EFI_PEI_FILE_HANDLE) * PcdGet32 (PcdPeiCoreMaxPeimPerFv) * PcdGet32
> (PcdPeiCoreMaxFvSupported));
> - ASSERT (PrivateData.Fv[0].FvFileHandles != NULL);
> - for (Index = 1; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {
> - PrivateData.Fv[Index].PeimState = PrivateData.Fv[Index - 1].PeimState +
> PcdGet32 (PcdPeiCoreMaxPeimPerFv);
> - PrivateData.Fv[Index].FvFileHandles = PrivateData.Fv[Index -
> 1].FvFileHandles + PcdGet32 (PcdPeiCoreMaxPeimPerFv);
> - }
> PrivateData.UnknownFvInfo = AllocateZeroPool (sizeof
> (PEI_CORE_UNKNOW_FORMAT_FV_INFO) * PcdGet32
> (PcdPeiCoreMaxFvSupported));
> ASSERT (PrivateData.UnknownFvInfo != NULL);
> - PrivateData.CurrentFvFileHandles = AllocateZeroPool (sizeof
> (EFI_PEI_FILE_HANDLE) * PcdGet32 (PcdPeiCoreMaxPeimPerFv));
> - ASSERT (PrivateData.CurrentFvFileHandles != NULL);
> - PrivateData.FileGuid = AllocatePool (sizeof (EFI_GUID) * PcdGet32
> (PcdPeiCoreMaxPeimPerFv));
> - ASSERT (PrivateData.FileGuid != NULL);
> - PrivateData.FileHandles = AllocatePool (sizeof (EFI_PEI_FILE_HANDLE) *
> (PcdGet32 (PcdPeiCoreMaxPeimPerFv) + 1));
> - ASSERT (PrivateData.FileHandles != NULL);
> }
> InitializePpiServices (&PrivateData, OldCoreData);
>
> --
> 2.7.0.windows.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 4/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPpiSupported
2018-12-18 2:24 ` Wang, Jian J
@ 2018-12-18 3:12 ` Zeng, Star
0 siblings, 0 replies; 23+ messages in thread
From: Zeng, Star @ 2018-12-18 3:12 UTC (permalink / raw)
To: Wang, Jian J, edk2-devel@lists.01.org
Cc: Wu, Hao A, Gao, Liming, Ni, Ruiyu, Kinney, Michael D,
Desimone, Nathaniel L, Chiu, Chasel, Zeng, Star
Jian,
Good observation.
I did consider it. But they are handling different structures.
Thanks,
Star
-----Original Message-----
From: Wang, Jian J
Sent: Tuesday, December 18, 2018 10:24 AM
To: Zeng, Star <star.zeng@intel.com>; edk2-devel@lists.01.org
Cc: Wu, Hao A <hao.a.wu@intel.com>; Gao, Liming <liming.gao@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Chiu, Chasel <chasel.chiu@intel.com>
Subject: RE: [PATCH 4/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPpiSupported
Star,
Please consider to extract the code to expand PPI buffer as a function or macro.
I found it repeated 3 times in this patch.
Regards,
Jian
> -----Original Message-----
> From: Zeng, Star
> Sent: Friday, December 14, 2018 6:29 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star <star.zeng@intel.com>; Wang, Jian J
> <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao, Liming
> <liming.gao@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; Kinney,
> Michael D <michael.d.kinney@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>; Chiu, Chasel <chasel.chiu@intel.com>
> Subject: [PATCH 4/7] MdeModulePkg PeiCore: Remove the using of
> PcdPeiCoreMaxPpiSupported
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405
>
> Background as below.
>
> Problem:
> As static configuration from the PCDs, the binary PeiCore (for example
> in FSP binary with dispatch mode) could not predict how many FVs,
> Files or PPIs for different platforms.
>
> Burden:
> Platform developers need configure the PCDs accordingly for different
> platforms.
>
> To solve the problem and remove the burden, we can update code to
> remove the using of PcdPeiCoreMaxFvSupported, PcdPeiCoreMaxPeimPerFv
> and PcdPeiCoreMaxPpiSupported by extending buffer dynamically for FV,
> File and PPI management.
>
> This patch removes the using of PcdPeiCoreMaxPpiSupported in PeiCore.
>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao Wu <hao.a.wu@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng <star.zeng@intel.com>
> ---
> MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 8 +-
> MdeModulePkg/Core/Pei/PeiMain.h | 59 +++--
> MdeModulePkg/Core/Pei/PeiMain.inf | 1 -
> MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 30 ++-
> MdeModulePkg/Core/Pei/Ppi/Ppi.c | 355 ++++++++++++++------------
> 5 files changed, 254 insertions(+), 199 deletions(-)
>
> diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> index 71440bab9488..55a300adbdb8 100644
> --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
> @@ -1062,7 +1062,7 @@ PeiDispatcher (
> // Process the Notify list and dispatch any notifies for
> // newly installed PPIs.
> //
> - ProcessNotifyList (Private);
> + ProcessDispatchNotifyList (Private);
> }
> }
> }
> @@ -1209,10 +1209,10 @@ PeiDispatcher (
> // Process the Notify list and dispatch any notifies for
> // newly installed PPIs.
> //
> - ProcessNotifyList (Private);
> + ProcessDispatchNotifyList (Private);
>
> //
> - // Recheck SwitchStackSignal after ProcessNotifyList()
> + // Recheck SwitchStackSignal after
> + ProcessDispatchNotifyList()
> // in case PeiInstallPeiMemory() is done in a callback with
> // EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH.
> //
> @@ -1253,7 +1253,7 @@ PeiDispatcher (
> // Process the Notify list and dispatch any notifies for
> // newly installed PPIs.
> //
> - ProcessNotifyList (Private);
> + ProcessDispatchNotifyList (Private);
> }
> }
> }
> diff --git a/MdeModulePkg/Core/Pei/PeiMain.h
> b/MdeModulePkg/Core/Pei/PeiMain.h index b248118087ad..c6c932c3e233
> 100644
> --- a/MdeModulePkg/Core/Pei/PeiMain.h
> +++ b/MdeModulePkg/Core/Pei/PeiMain.h
> @@ -66,37 +66,60 @@ typedef union {
> } PEI_PPI_LIST_POINTERS;
>
> ///
> -/// PPI database structure which contains two link: PpiList and
> NotifyList. PpiList -/// is in head of PpiListPtrs array and notify is in end of PpiListPtrs.
> +/// Number of PEI_PPI_LIST_POINTERS to grow by each time we run out
> +of
> room
> ///
> +#define PPI_GROWTH_STEP 64
> +#define CALLBACK_NOTIFY_GROWTH_STEP 32 #define
> +DISPATCH_NOTIFY_GROWTH_STEP 8
> +
> typedef struct {
> + UINTN CurrentCount;
> + UINTN MaxCount;
> + UINTN LastDispatchedCount;
> ///
> - /// index of end of PpiList link list.
> + /// MaxCount number of entries.
> ///
> - INTN PpiListEnd;
> + PEI_PPI_LIST_POINTERS *PpiPtrs;
> +} PEI_PPI_LIST;
> +
> +typedef struct {
> + UINTN CurrentCount;
> + UINTN MaxCount;
> ///
> - /// index of end of notify link list.
> + /// MaxCount number of entries.
> ///
> - INTN NotifyListEnd;
> + PEI_PPI_LIST_POINTERS *NotifyPtrs;
> +} PEI_CALLBACK_NOTIFY_LIST;
> +
> +typedef struct {
> + UINTN CurrentCount;
> + UINTN MaxCount;
> + UINTN LastDispatchedCount;
> ///
> - /// index of the dispatched notify list.
> + /// MaxCount number of entries.
> ///
> - INTN DispatchListEnd;
> + PEI_PPI_LIST_POINTERS *NotifyPtrs;
> +} PEI_DISPATCH_NOTIFY_LIST;
> +
> +///
> +/// PPI database structure which contains three links:
> +/// PpiList, CallbackNotifyList and DispatchNotifyList.
> +///
> +typedef struct {
> ///
> - /// index of last installed Ppi description in PpiList link list.
> + /// PPI List.
> ///
> - INTN LastDispatchedInstall;
> + PEI_PPI_LIST PpiList;
> ///
> - /// index of last dispatched notify in Notify link list.
> + /// Notify List at dispatch level.
> ///
> - INTN LastDispatchedNotify;
> + PEI_CALLBACK_NOTIFY_LIST CallbackNotifyList;
> ///
> - /// Ppi database has the PcdPeiCoreMaxPpiSupported number of entries.
> + /// Notify List at callback level.
> ///
> - PEI_PPI_LIST_POINTERS *PpiListPtrs;
> + PEI_DISPATCH_NOTIFY_LIST DispatchNotifyList;
> } PEI_PPI_DATABASE;
>
> -
> //
> // PEI_CORE_FV_HANDE.PeimState
> // Do not change these values as there is code doing math to change states.
> @@ -550,13 +573,13 @@ PeiNotifyPpi (
>
> **/
> VOID
> -ProcessNotifyList (
> +ProcessDispatchNotifyList (
> IN PEI_CORE_INSTANCE *PrivateData
> );
>
> /**
>
> - Dispatch notifications.
> + Process notifications.
>
> @param PrivateData PeiCore's private data structure
> @param NotifyType Type of notify to fire.
> @@ -567,7 +590,7 @@ ProcessNotifyList (
>
> **/
> VOID
> -DispatchNotify (
> +ProcessNotify (
> IN PEI_CORE_INSTANCE *PrivateData,
> IN UINTN NotifyType,
> IN INTN InstallStartIndex,
> diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf
> b/MdeModulePkg/Core/Pei/PeiMain.inf
> index dd41fe41bc89..140c4444b107 100644
> --- a/MdeModulePkg/Core/Pei/PeiMain.inf
> +++ b/MdeModulePkg/Core/Pei/PeiMain.inf
> @@ -104,7 +104,6 @@ [Ppis]
> gEfiSecHobDataPpiGuid ## SOMETIMES_CONSUMES
>
> [Pcd]
> - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported ##
> CONSUMES
> gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize ##
> CONSUMES
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreImageLoaderSearchTeSectionFir
> st ## CONSUMES
> gEfiMdeModulePkgTokenSpaceGuid.PcdFrameworkCompatibilitySupport
> ## CONSUMES
> diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> index 4869bf18f005..4da80a8222bc 100644
> --- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> +++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
> @@ -190,7 +190,15 @@ PeiCore (
> if (OldCoreData->CurrentFvFileHandles != NULL) {
> OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *)
> ((UINT8 *)
> OldCoreData->CurrentFvFileHandles + OldCoreData->HeapOffset);
> }
> - OldCoreData->PpiData.PpiListPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *)
> OldCoreData->PpiData.PpiListPtrs + OldCoreData->HeapOffset);
> + if (OldCoreData->PpiData.PpiList.PpiPtrs != NULL) {
> + OldCoreData->PpiData.PpiList.PpiPtrs =
> + (PEI_PPI_LIST_POINTERS *)
> ((UINT8 *) OldCoreData->PpiData.PpiList.PpiPtrs +
> OldCoreData->HeapOffset);
> + }
> + if (OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs != NULL) {
> + OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs =
> (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData-
> >PpiData.CallbackNotifyList.NotifyPtrs + OldCoreData->HeapOffset);
> + }
> + if (OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs != NULL) {
> + OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs =
> (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData-
> >PpiData.DispatchNotifyList.NotifyPtrs + OldCoreData->HeapOffset);
> + }
> OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *)
> OldCoreData->Fv + OldCoreData->HeapOffset);
> for (Index = 0; Index < OldCoreData->FvCount; Index ++) {
> if (OldCoreData->Fv[Index].PeimState != NULL) { @@ -210,7
> +218,15 @@ PeiCore (
> if (OldCoreData->CurrentFvFileHandles != NULL) {
> OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *)
> ((UINT8 *)
> OldCoreData->CurrentFvFileHandles - OldCoreData->HeapOffset);
> }
> - OldCoreData->PpiData.PpiListPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *)
> OldCoreData->PpiData.PpiListPtrs - OldCoreData->HeapOffset);
> + if (OldCoreData->PpiData.PpiList.PpiPtrs != NULL) {
> + OldCoreData->PpiData.PpiList.PpiPtrs =
> + (PEI_PPI_LIST_POINTERS *)
> ((UINT8 *) OldCoreData->PpiData.PpiList.PpiPtrs -
> OldCoreData->HeapOffset);
> + }
> + if (OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs != NULL) {
> + OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs =
> (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData-
> >PpiData.CallbackNotifyList.NotifyPtrs - OldCoreData->HeapOffset);
> + }
> + if (OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs != NULL) {
> + OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs =
> (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData-
> >PpiData.DispatchNotifyList.NotifyPtrs - OldCoreData->HeapOffset);
> + }
> OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *)
> OldCoreData->Fv - OldCoreData->HeapOffset);
> for (Index = 0; Index < OldCoreData->FvCount; Index ++) {
> if (OldCoreData->Fv[Index].PeimState != NULL) { @@ -337,14
> +353,6 @@ PeiCore (
> // Initialize PEI Core Services
> //
> InitializeMemoryServices (&PrivateData, SecCoreData, OldCoreData);
> - if (OldCoreData == NULL) {
> - //
> - // Initialize PEI Core Private Data Buffer
> - //
> - PrivateData.PpiData.PpiListPtrs = AllocateZeroPool (sizeof
> (PEI_PPI_LIST_POINTERS) * PcdGet32 (PcdPeiCoreMaxPpiSupported));
> - ASSERT (PrivateData.PpiData.PpiListPtrs != NULL);
> - }
> - InitializePpiServices (&PrivateData, OldCoreData);
>
> //
> // Update performance measurements
> @@ -414,7 +422,7 @@ PeiCore (
> //
> // Process the Notify list and dispatch any notifies for the
> Memory Discovered PPI
> //
> - ProcessNotifyList (&PrivateData);
> + ProcessDispatchNotifyList (&PrivateData);
>
> PERF_INMODULE_END ("DisMem");
> }
> diff --git a/MdeModulePkg/Core/Pei/Ppi/Ppi.c
> b/MdeModulePkg/Core/Pei/Ppi/Ppi.c index 6f03858b8a94..907b2bbcf466
> 100644
> --- a/MdeModulePkg/Core/Pei/Ppi/Ppi.c
> +++ b/MdeModulePkg/Core/Pei/Ppi/Ppi.c
> @@ -16,28 +16,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND,
> EITHER EXPRESS OR IMPLIED.
>
> /**
>
> - Initialize PPI services.
> -
> - @param PrivateData Pointer to the PEI Core data.
> - @param OldCoreData Pointer to old PEI Core data.
> - NULL if being run in non-permament memory mode.
> -
> -**/
> -VOID
> -InitializePpiServices (
> - IN PEI_CORE_INSTANCE *PrivateData,
> - IN PEI_CORE_INSTANCE *OldCoreData
> - )
> -{
> - if (OldCoreData == NULL) {
> - PrivateData->PpiData.NotifyListEnd = PcdGet32
> (PcdPeiCoreMaxPpiSupported)-1;
> - PrivateData->PpiData.DispatchListEnd = PcdGet32
> (PcdPeiCoreMaxPpiSupported)-1;
> - PrivateData->PpiData.LastDispatchedNotify = PcdGet32
> (PcdPeiCoreMaxPpiSupported)-1;
> - }
> -}
> -
> -/**
> -
> Migrate Pointer from the temporary memory to PEI installed memory.
>
> @param Pointer Pointer to the Pointer needs to be converted.
> @@ -192,14 +170,37 @@ ConvertPpiPointers ( {
> UINT8 Index;
>
> - for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxPpiSupported); Index++) {
> - if (Index < PrivateData->PpiData.PpiListEnd || Index > PrivateData-
> >PpiData.NotifyListEnd) {
> - ConvertSinglePpiPointer (
> - SecCoreData,
> - PrivateData,
> - &PrivateData->PpiData.PpiListPtrs[Index]
> - );
> - }
> + //
> + // Convert normal PPIs.
> + //
> + for (Index = 0; Index < PrivateData->PpiData.PpiList.CurrentCount; Index++) {
> + ConvertSinglePpiPointer (
> + SecCoreData,
> + PrivateData,
> + &PrivateData->PpiData.PpiList.PpiPtrs[Index]
> + );
> + }
> +
> + //
> + // Convert Callback Notification PPIs.
> + //
> + for (Index = 0; Index <
> + PrivateData->PpiData.CallbackNotifyList.CurrentCount;
> Index++) {
> + ConvertSinglePpiPointer (
> + SecCoreData,
> + PrivateData,
> + &PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index]
> + );
> + }
> +
> + //
> + // Convert Dispatch Notification PPIs.
> + //
> + for (Index = 0; Index <
> + PrivateData->PpiData.DispatchNotifyList.CurrentCount;
> Index++) {
> + ConvertSinglePpiPointer (
> + SecCoreData,
> + PrivateData,
> + &PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index]
> + );
> }
> }
>
> @@ -228,10 +229,11 @@ InternalPeiInstallPpi (
> IN BOOLEAN Single
> )
> {
> - PEI_CORE_INSTANCE *PrivateData;
> - INTN Index;
> - INTN LastCallbackInstall;
> -
> + PEI_CORE_INSTANCE *PrivateData;
> + PEI_PPI_LIST *PpiListPointer;
> + UINTN Index;
> + UINTN LastCount;
> + VOID *TempPtr;
>
> if (PpiList == NULL) {
> return EFI_INVALID_PARAMETER;
> @@ -239,8 +241,9 @@ InternalPeiInstallPpi (
>
> PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
>
> - Index = PrivateData->PpiData.PpiListEnd;
> - LastCallbackInstall = Index;
> + PpiListPointer = &PrivateData->PpiData.PpiList; Index =
> + PpiListPointer->CurrentCount; LastCount = Index;
>
> //
> // This is loop installs all PPI descriptors in the PpiList. It is
> terminated @@ -250,27 +253,37 @@ InternalPeiInstallPpi (
>
> for (;;) {
> //
> - // Since PpiData is used for NotifyList and PpiList, max resource
> - // is reached if the Install reaches the NotifyList
> - // PcdPeiCoreMaxPpiSupported can be set to a larger value in DSC to satisfy
> more PPI requirement.
> - //
> - if (Index == PrivateData->PpiData.NotifyListEnd + 1) {
> - return EFI_OUT_OF_RESOURCES;
> - }
> - //
> // Check if it is a valid PPI.
> // If not, rollback list to exclude all in this list.
> // Try to indicate which item failed.
> //
> if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_PPI) == 0) {
> - PrivateData->PpiData.PpiListEnd = LastCallbackInstall;
> + PpiListPointer->CurrentCount = LastCount;
> DEBUG((EFI_D_ERROR, "ERROR -> InstallPpi: %g %p\n",
> PpiList->Guid,
> PpiList->Ppi));
> return EFI_INVALID_PARAMETER;
> }
>
> + if (Index == PpiListPointer->MaxCount) {
> + //
> + // Run out of room, grow the buffer.
> + //
> + TempPtr = AllocateZeroPool (
> + sizeof (PEI_PPI_LIST_POINTERS) *
> + (PpiListPointer->MaxCount +
> PPI_GROWTH_STEP)
> + );
> + ASSERT (TempPtr != NULL);
> + CopyMem (
> + TempPtr,
> + PpiListPointer->PpiPtrs,
> + sizeof (PEI_PPI_LIST_POINTERS) * PpiListPointer->MaxCount
> + );
> + PpiListPointer->PpiPtrs = TempPtr;
> + PpiListPointer->MaxCount = PpiListPointer->MaxCount +
> PPI_GROWTH_STEP;
> + }
> +
It looks that he above PPI buffer expansion code have 3 copied in this patch.
Please consider to extract it as a function or macro.
> DEBUG((EFI_D_INFO, "Install PPI: %g\n", PpiList->Guid));
> - PrivateData->PpiData.PpiListPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR*)
> PpiList;
> - PrivateData->PpiData.PpiListEnd++;
> + PpiListPointer->PpiPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *) PpiList;
> + Index++;
> + PpiListPointer->CurrentCount++;
>
> if (Single) {
> //
> @@ -284,23 +297,24 @@ InternalPeiInstallPpi (
> //
> break;
> }
> + //
> + // Go to the next descriptor.
> + //
> PpiList++;
> - Index++;
> }
>
> //
> - // Dispatch any callback level notifies for newly installed PPIs.
> + // Process any callback level notifies for newly installed PPIs.
> //
> - DispatchNotify (
> + ProcessNotify (
> PrivateData,
> EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
> - LastCallbackInstall,
> - PrivateData->PpiData.PpiListEnd,
> - PrivateData->PpiData.DispatchListEnd,
> - PrivateData->PpiData.NotifyListEnd
> + LastCount,
> + PpiListPointer->CurrentCount,
> + 0,
> + PrivateData->PpiData.CallbackNotifyList.CurrentCount
> );
>
> -
> return EFI_SUCCESS;
> }
>
> @@ -355,7 +369,7 @@ PeiReInstallPpi (
> )
> {
> PEI_CORE_INSTANCE *PrivateData;
> - INTN Index;
> + UINTN Index;
>
>
> if ((OldPpi == NULL) || (NewPpi == NULL)) { @@ -372,35 +386,33 @@
> PeiReInstallPpi (
> // Find the old PPI instance in the database. If we can not find it,
> // return the EFI_NOT_FOUND error.
> //
> - for (Index = 0; Index < PrivateData->PpiData.PpiListEnd; Index++) {
> - if (OldPpi == PrivateData->PpiData.PpiListPtrs[Index].Ppi) {
> + for (Index = 0; Index < PrivateData->PpiData.PpiList.CurrentCount; Index++) {
> + if (OldPpi == PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi) {
> break;
> }
> }
> - if (Index == PrivateData->PpiData.PpiListEnd) {
> + if (Index == PrivateData->PpiData.PpiList.CurrentCount) {
> return EFI_NOT_FOUND;
> }
>
> //
> - // Remove the old PPI from the database, add the new one.
> + // Replace the old PPI with the new one.
> //
> DEBUG((EFI_D_INFO, "Reinstall PPI: %g\n", NewPpi->Guid));
> - ASSERT (Index < (INTN)(PcdGet32 (PcdPeiCoreMaxPpiSupported)));
> - PrivateData->PpiData.PpiListPtrs[Index].Ppi =
> (EFI_PEI_PPI_DESCRIPTOR *) NewPpi;
> + PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi =
> + (EFI_PEI_PPI_DESCRIPTOR *)
> NewPpi;
>
> //
> - // Dispatch any callback level notifies for the newly installed PPI.
> + // Process any callback level notifies for the newly installed PPI.
> //
> - DispatchNotify (
> + ProcessNotify (
> PrivateData,
> EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
> Index,
> Index+1,
> - PrivateData->PpiData.DispatchListEnd,
> - PrivateData->PpiData.NotifyListEnd
> + 0,
> + PrivateData->PpiData.CallbackNotifyList.CurrentCount
> );
>
> -
> return EFI_SUCCESS;
> }
>
> @@ -430,10 +442,10 @@ PeiLocatePpi (
> IN OUT VOID **Ppi
> )
> {
> - PEI_CORE_INSTANCE *PrivateData;
> - INTN Index;
> - EFI_GUID *CheckGuid;
> - EFI_PEI_PPI_DESCRIPTOR *TempPtr;
> + PEI_CORE_INSTANCE *PrivateData;
> + UINTN Index;
> + EFI_GUID *CheckGuid;
> + EFI_PEI_PPI_DESCRIPTOR *TempPtr;
>
>
> PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
> @@ -441,8 +453,8 @@ PeiLocatePpi (
> //
> // Search the data base for the matching instance of the GUIDed PPI.
> //
> - for (Index = 0; Index < PrivateData->PpiData.PpiListEnd; Index++) {
> - TempPtr = PrivateData->PpiData.PpiListPtrs[Index].Ppi;
> + for (Index = 0; Index < PrivateData->PpiData.PpiList.CurrentCount; Index++) {
> + TempPtr = PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi;
> CheckGuid = TempPtr->Guid;
>
> //
> @@ -498,15 +510,14 @@ InternalPeiNotifyPpi (
> IN BOOLEAN Single
> )
> {
> - PEI_CORE_INSTANCE *PrivateData;
> - INTN Index;
> - INTN NotifyIndex;
> - INTN LastCallbackNotify;
> - EFI_PEI_NOTIFY_DESCRIPTOR *NotifyPtr;
> - UINTN NotifyDispatchCount;
> -
> -
> - NotifyDispatchCount = 0;
> + PEI_CORE_INSTANCE *PrivateData;
> + PEI_CALLBACK_NOTIFY_LIST *CallbackNotifyListPointer;
> + UINTN CallbackNotifyIndex;
> + UINTN LastCallbackNotifyCount;
> + PEI_DISPATCH_NOTIFY_LIST *DispatchNotifyListPointer;
> + UINTN DispatchNotifyIndex;
> + UINTN LastDispatchNotifyCount;
> + VOID *TempPtr;
>
> if (NotifyList == NULL) {
> return EFI_INVALID_PARAMETER;
> @@ -514,8 +525,13 @@ InternalPeiNotifyPpi (
>
> PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
>
> - Index = PrivateData->PpiData.NotifyListEnd;
> - LastCallbackNotify = Index;
> + CallbackNotifyListPointer =
> + &PrivateData->PpiData.CallbackNotifyList;
> + CallbackNotifyIndex = CallbackNotifyListPointer->CurrentCount;
> + LastCallbackNotifyCount = CallbackNotifyIndex;
> +
> + DispatchNotifyListPointer =
> + &PrivateData->PpiData.DispatchNotifyList;
> + DispatchNotifyIndex = DispatchNotifyListPointer->CurrentCount;
> + LastDispatchNotifyCount = DispatchNotifyIndex;
>
> //
> // This is loop installs all Notify descriptors in the NotifyList.
> It is @@ -525,31 +541,59 @@ InternalPeiNotifyPpi (
>
> for (;;) {
> //
> - // Since PpiData is used for NotifyList and InstallList, max resource
> - // is reached if the Install reaches the PpiList
> - // PcdPeiCoreMaxPpiSupported can be set to a larger value in DSC to satisfy
> more Notify PPIs requirement.
> - //
> - if (Index == PrivateData->PpiData.PpiListEnd - 1) {
> - return EFI_OUT_OF_RESOURCES;
> - }
> -
> - //
> // If some of the PPI data is invalid restore original Notify PPI database value
> //
> if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES) == 0) {
> - PrivateData->PpiData.NotifyListEnd = LastCallbackNotify;
> - DEBUG((EFI_D_ERROR, "ERROR -> InstallNotify: %g %p\n", NotifyList-
> >Guid, NotifyList->Notify));
> + CallbackNotifyListPointer->CurrentCount = LastCallbackNotifyCount;
> + DispatchNotifyListPointer->CurrentCount = LastDispatchNotifyCount;
> + DEBUG((EFI_D_ERROR, "ERROR -> NotifyPpi: %g %p\n",
> + NotifyList->Guid,
> NotifyList->Notify));
> return EFI_INVALID_PARAMETER;
> }
>
> - if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH) != 0) {
> - NotifyDispatchCount ++;
> + if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK) != 0) {
> + if (CallbackNotifyIndex == CallbackNotifyListPointer->MaxCount) {
> + //
> + // Run out of room, grow the buffer.
> + //
> + TempPtr = AllocateZeroPool (
> + sizeof (PEI_PPI_LIST_POINTERS) *
> + (CallbackNotifyListPointer-
> >MaxCount + CALLBACK_NOTIFY_GROWTH_STEP)
> + );
> + ASSERT (TempPtr != NULL);
> + CopyMem (
> + TempPtr,
> + CallbackNotifyListPointer->NotifyPtrs,
> + sizeof (PEI_PPI_LIST_POINTERS) * CallbackNotifyListPointer->MaxCount
> + );
> + CallbackNotifyListPointer->NotifyPtrs = TempPtr;
> + CallbackNotifyListPointer->MaxCount =
> + CallbackNotifyListPointer-
> >MaxCount + CALLBACK_NOTIFY_GROWTH_STEP;
> + }
> +
> + CallbackNotifyListPointer->NotifyPtrs[CallbackNotifyIndex].Notify =
> (EFI_PEI_NOTIFY_DESCRIPTOR *) NotifyList;
> + CallbackNotifyIndex++;
> + CallbackNotifyListPointer->CurrentCount++;
> + } else {
> + if (DispatchNotifyIndex == DispatchNotifyListPointer->MaxCount) {
> + //
> + // Run out of room, grow the buffer.
> + //
> + TempPtr = AllocateZeroPool (
> + sizeof (PEI_PPI_LIST_POINTERS) *
> + (DispatchNotifyListPointer-
> >MaxCount + DISPATCH_NOTIFY_GROWTH_STEP)
> + );
> + ASSERT (TempPtr != NULL);
> + CopyMem (
> + TempPtr,
> + DispatchNotifyListPointer->NotifyPtrs,
> + sizeof (PEI_PPI_LIST_POINTERS) * DispatchNotifyListPointer->MaxCount
> + );
> + DispatchNotifyListPointer->NotifyPtrs = TempPtr;
> + DispatchNotifyListPointer->MaxCount =
> + DispatchNotifyListPointer-
> >MaxCount + DISPATCH_NOTIFY_GROWTH_STEP;
> + }
> +
> + DispatchNotifyListPointer->NotifyPtrs[DispatchNotifyIndex].Notify =
> (EFI_PEI_NOTIFY_DESCRIPTOR *) NotifyList;
> + DispatchNotifyIndex++;
> + DispatchNotifyListPointer->CurrentCount++;
> }
>
> - PrivateData->PpiData.PpiListPtrs[Index].Notify =
> (EFI_PEI_NOTIFY_DESCRIPTOR *) NotifyList;
> -
> - PrivateData->PpiData.NotifyListEnd--;
> DEBUG((EFI_D_INFO, "Register PPI Notify: %g\n",
> NotifyList->Guid));
> +
> if (Single) {
> //
> // Only single entry in the NotifyList.
> @@ -563,41 +607,21 @@ InternalPeiNotifyPpi (
> break;
> }
> //
> - // Go the next descriptor. Remember the NotifyList moves down.
> + // Go to the next descriptor.
> //
> NotifyList++;
> - Index--;
> - }
> -
> - //
> - // If there is Dispatch Notify PPI installed put them on the bottom
> - //
> - if (NotifyDispatchCount > 0) {
> - for (NotifyIndex = LastCallbackNotify; NotifyIndex > PrivateData-
> >PpiData.NotifyListEnd; NotifyIndex--) {
> - if ((PrivateData->PpiData.PpiListPtrs[NotifyIndex].Notify->Flags &
> EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH) != 0) {
> - NotifyPtr = PrivateData->PpiData.PpiListPtrs[NotifyIndex].Notify;
> -
> - for (Index = NotifyIndex; Index < PrivateData->PpiData.DispatchListEnd;
> Index++){
> - PrivateData->PpiData.PpiListPtrs[Index].Notify = PrivateData-
> >PpiData.PpiListPtrs[Index + 1].Notify;
> - }
> - PrivateData->PpiData.PpiListPtrs[Index].Notify = NotifyPtr;
> - PrivateData->PpiData.DispatchListEnd--;
> - }
> - }
> -
> - LastCallbackNotify -= NotifyDispatchCount;
> }
>
> //
> - // Dispatch any callback level notifies for all previously installed PPIs.
> + // Process any callback level notifies for all previously installed PPIs.
> //
> - DispatchNotify (
> + ProcessNotify (
> PrivateData,
> EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
> 0,
> - PrivateData->PpiData.PpiListEnd,
> - LastCallbackNotify,
> - PrivateData->PpiData.NotifyListEnd
> + PrivateData->PpiData.PpiList.CurrentCount,
> + LastCallbackNotifyCount,
> + CallbackNotifyListPointer->CurrentCount
> );
>
> return EFI_SUCCESS;
> @@ -627,7 +651,6 @@ PeiNotifyPpi (
> return InternalPeiNotifyPpi (PeiServices, NotifyList, FALSE); }
>
> -
> /**
>
> Process the Notify List at dispatch level.
> @@ -636,55 +659,56 @@ PeiNotifyPpi (
>
> **/
> VOID
> -ProcessNotifyList (
> +ProcessDispatchNotifyList (
> IN PEI_CORE_INSTANCE *PrivateData
> )
> {
> - INTN TempValue;
> + UINTN TempValue;
>
> while (TRUE) {
> //
> // Check if the PEIM that was just dispatched resulted in any
> // Notifies getting installed. If so, go process any dispatch
> // level Notifies that match the previouly installed PPIs.
> - // Use "while" instead of "if" since DispatchNotify can modify
> - // DispatchListEnd (with NotifyPpi) so we have to iterate until the same.
> + // Use "while" instead of "if" since ProcessNotify can modify
> + // DispatchNotifyList.CurrentCount (with NotifyPpi) so we have
> + // to iterate until the same.
> //
> - while (PrivateData->PpiData.LastDispatchedNotify != PrivateData-
> >PpiData.DispatchListEnd) {
> - TempValue = PrivateData->PpiData.DispatchListEnd;
> - DispatchNotify (
> + while
> + (PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount !=
> PrivateData->PpiData.DispatchNotifyList.CurrentCount) {
> + TempValue = PrivateData->PpiData.DispatchNotifyList.CurrentCount;
> + ProcessNotify (
> PrivateData,
> EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH,
> 0,
> - PrivateData->PpiData.LastDispatchedInstall,
> - PrivateData->PpiData.LastDispatchedNotify,
> - PrivateData->PpiData.DispatchListEnd
> + PrivateData->PpiData.PpiList.LastDispatchedCount,
> + PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount,
> + PrivateData->PpiData.DispatchNotifyList.CurrentCount
> );
> - PrivateData->PpiData.LastDispatchedNotify = TempValue;
> + PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount =
> TempValue;
> }
>
> -
> //
> // Check if the PEIM that was just dispatched resulted in any
> // PPIs getting installed. If so, go process any dispatch
> // level Notifies that match the installed PPIs.
> - // Use "while" instead of "if" since DispatchNotify can modify
> - // PpiListEnd (with InstallPpi) so we have to iterate until the same.
> + // Use "while" instead of "if" since ProcessNotify can modify
> + // PpiList.CurrentCount (with InstallPpi) so we have to iterate
> + // until the same.
> //
> - while (PrivateData->PpiData.LastDispatchedInstall != PrivateData-
> >PpiData.PpiListEnd) {
> - TempValue = PrivateData->PpiData.PpiListEnd;
> - DispatchNotify (
> + while (PrivateData->PpiData.PpiList.LastDispatchedCount !=
> + PrivateData-
> >PpiData.PpiList.CurrentCount) {
> + TempValue = PrivateData->PpiData.PpiList.CurrentCount;
> + ProcessNotify (
> PrivateData,
> EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH,
> - PrivateData->PpiData.LastDispatchedInstall,
> - PrivateData->PpiData.PpiListEnd,
> - PcdGet32 (PcdPeiCoreMaxPpiSupported)-1,
> - PrivateData->PpiData.DispatchListEnd
> + PrivateData->PpiData.PpiList.LastDispatchedCount,
> + PrivateData->PpiData.PpiList.CurrentCount,
> + 0,
> + PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount
> );
> - PrivateData->PpiData.LastDispatchedInstall = TempValue;
> + PrivateData->PpiData.PpiList.LastDispatchedCount = TempValue;
> }
>
> - if (PrivateData->PpiData.LastDispatchedNotify == PrivateData-
> >PpiData.DispatchListEnd) {
> + if (PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount
> + ==
> PrivateData->PpiData.DispatchNotifyList.CurrentCount) {
> break;
> }
> }
> @@ -693,7 +717,7 @@ ProcessNotifyList (
>
> /**
>
> - Dispatch notifications.
> + Process notifications.
>
> @param PrivateData PeiCore's private data structure
> @param NotifyType Type of notify to fire.
> @@ -704,7 +728,7 @@ ProcessNotifyList (
>
> **/
> VOID
> -DispatchNotify (
> +ProcessNotify (
> IN PEI_CORE_INSTANCE *PrivateData,
> IN UINTN NotifyType,
> IN INTN InstallStartIndex,
> @@ -713,22 +737,23 @@ DispatchNotify (
> IN INTN NotifyStopIndex
> )
> {
> - INTN Index1;
> - INTN Index2;
> - EFI_GUID *SearchGuid;
> - EFI_GUID *CheckGuid;
> - EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;
> -
> - //
> - // Remember that Installs moves up and Notifies moves down.
> - //
> - for (Index1 = NotifyStartIndex; Index1 > NotifyStopIndex; Index1--) {
> - NotifyDescriptor = PrivateData->PpiData.PpiListPtrs[Index1].Notify;
> + INTN Index1;
> + INTN Index2;
> + EFI_GUID *SearchGuid;
> + EFI_GUID *CheckGuid;
> + EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;
> +
> + for (Index1 = NotifyStartIndex; Index1 < NotifyStopIndex; Index1++) {
> + if (NotifyType == EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK) {
> + NotifyDescriptor = PrivateData-
> >PpiData.CallbackNotifyList.NotifyPtrs[Index1].Notify;
> + } else {
> + NotifyDescriptor = PrivateData-
> >PpiData.DispatchNotifyList.NotifyPtrs[Index1].Notify;
> + }
>
> CheckGuid = NotifyDescriptor->Guid;
>
> for (Index2 = InstallStartIndex; Index2 < InstallStopIndex; Index2++) {
> - SearchGuid = PrivateData->PpiData.PpiListPtrs[Index2].Ppi->Guid;
> + SearchGuid =
> + PrivateData->PpiData.PpiList.PpiPtrs[Index2].Ppi->Guid;
> //
> // Don't use CompareGuid function here for performance reasons.
> // Instead we compare the GUID as INT32 at a time and branch @@
> -745,7 +770,7 @@ DispatchNotify (
> NotifyDescriptor->Notify (
> (EFI_PEI_SERVICES **) GetPeiServicesTablePointer (),
> NotifyDescriptor,
> - (PrivateData->PpiData.PpiListPtrs[Index2].Ppi)->Ppi
> +
> + (PrivateData->PpiData.PpiList.PpiPtrs[Index2].Ppi)->Ppi
> );
> }
> }
> --
> 2.7.0.windows.1
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 6/7] Vlv2TbltDevicePkg: Remove PcdPeiCoreMaxXXX PCDs' statement
[not found] ` <A6DBF04CB9C4D045926EB50EBFFE5A2950865373@shsmsx102.ccr.corp.intel.com>
@ 2018-12-18 11:00 ` Zeng, Star
[not found] ` <A6DBF04CB9C4D045926EB50EBFFE5A29508656F9@shsmsx102.ccr.corp.intel.com>
0 siblings, 1 reply; 23+ messages in thread
From: Zeng, Star @ 2018-12-18 11:00 UTC (permalink / raw)
To: Qian, Yi, edk2-devel@lists.01.org; +Cc: Sun, Zailiang, Wei, David, Zeng, Star
Yi,
Good question.
With the patch, the code can be compiled and the image can boot to setup.
The image could not find shell, but that is not related to the patch.
It is because https://github.com/tianocore/edk2/commit/2840bb51040bb79c1ad53b1eb1cbb86e5edf80ca#diff-0318cca23f8f1c46d1076b3a5891fadd updated the platform dsc and fdf to use 2.0 shell source build (with 2.0 shell file GUID), but the code at https://github.com/tianocore/edk2/blob/master/Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c#L1365 is still using PcdShellFile (which matches to EDK shell) to find shell file.
Thanks,
Star
-----Original Message-----
From: Qian, Yi
Sent: Tuesday, December 18, 2018 10:08 AM
To: Zeng, Star <star.zeng@intel.com>; edk2-devel@lists.01.org
Cc: Sun, Zailiang <zailiang.sun@intel.com>
Subject: RE: [PATCH 6/7] Vlv2TbltDevicePkg: Remove PcdPeiCoreMaxXXX PCDs' statement
Hi Star,
This patch is good to me. Only one thing I need to know is whether you have done the unit test, at least, compilation, and boot into shell.
Thanks
Qian Yi
-----Original Message-----
From: Zeng, Star
Sent: Friday, December 14, 2018 6:29 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star <star.zeng@intel.com>; Sun, Zailiang <zailiang.sun@intel.com>; Qian, Yi <yi.qian@intel.com>
Subject: [PATCH 6/7] Vlv2TbltDevicePkg: Remove PcdPeiCoreMaxXXX PCDs' statement
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405
The codes have been updated to not use PcdPeiCoreMaxFvSupported, PcdPeiCoreMaxPeimPerFv and PcdPeiCoreMaxPpiSupported, so their statement in platform DSC could be removed.
Cc: Zailiang Sun <zailiang.sun@intel.com>
Cc: Yi Qian <yi.qian@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 2 --
Vlv2TbltDevicePkg/PlatformPkgIA32.dsc | 2 --
Vlv2TbltDevicePkg/PlatformPkgX64.dsc | 2 --
3 files changed, 6 deletions(-)
diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
index f8ad29df5986..d43611550285 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
@@ -663,10 +663,8 @@ [PcdsFixedAtBuild.common]
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x400
gEfiCpuTokenSpaceGuid.PcdCpuIEDRamSize|0x400000
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize|0x10000
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|50
gEfiMdeModulePkgTokenSpaceGuid.PcdSrIovSupport|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport|FALSE
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported|128
gEfiCpuTokenSpaceGuid.PcdCpuSmmApSyncTimeout|1000
!if $(S4_ENABLE) == TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|TRUE
diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
index ca3b2ff90287..a33816c4d18b 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
@@ -663,10 +663,8 @@ [PcdsFixedAtBuild.common]
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x400
gEfiCpuTokenSpaceGuid.PcdCpuIEDRamSize|0x400000
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize|0x10000
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|50
gEfiMdeModulePkgTokenSpaceGuid.PcdSrIovSupport|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport|FALSE
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported|128
gEfiCpuTokenSpaceGuid.PcdCpuSmmApSyncTimeout|1000
!if $(S4_ENABLE) == TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|TRUE
diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
index 81f36bd73b28..b50731f25ffb 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
@@ -663,10 +663,8 @@ [PcdsFixedAtBuild.common]
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x400
gEfiCpuTokenSpaceGuid.PcdCpuIEDRamSize|0x400000
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize|0x10000
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|50
gEfiMdeModulePkgTokenSpaceGuid.PcdSrIovSupport|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport|FALSE
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported|128
gEfiCpuTokenSpaceGuid.PcdCpuSmmApSyncTimeout|1000
!if $(S4_ENABLE) == TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|TRUE
--
2.7.0.windows.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH 6/7] Vlv2TbltDevicePkg: Remove PcdPeiCoreMaxXXX PCDs' statement
[not found] ` <A6DBF04CB9C4D045926EB50EBFFE5A29508656F9@shsmsx102.ccr.corp.intel.com>
@ 2018-12-19 1:23 ` Zeng, Star
[not found] ` <A6DBF04CB9C4D045926EB50EBFFE5A2950865882@shsmsx102.ccr.corp.intel.com>
0 siblings, 1 reply; 23+ messages in thread
From: Zeng, Star @ 2018-12-19 1:23 UTC (permalink / raw)
To: Qian, Yi, edk2-devel@lists.01.org; +Cc: Sun, Zailiang, Wei, David, Zeng, Star
Yi, Zailiang and David,
So, is it ok to give RB to the patch from you? :)
Thanks,
Star
-----Original Message-----
From: Qian, Yi
Sent: Wednesday, December 19, 2018 9:21 AM
To: Zeng, Star <star.zeng@intel.com>; edk2-devel@lists.01.org
Cc: Sun, Zailiang <zailiang.sun@intel.com>; Wei, David <david.wei@intel.com>
Subject: RE: [PATCH 6/7] Vlv2TbltDevicePkg: Remove PcdPeiCoreMaxXXX PCDs' statement
It's fine. Thank you for your update.
Thanks
Qian Yi
-----Original Message-----
From: Zeng, Star
Sent: Tuesday, December 18, 2018 7:01 PM
To: Qian, Yi <yi.qian@intel.com>; edk2-devel@lists.01.org
Cc: Sun, Zailiang <zailiang.sun@intel.com>; Wei, David <david.wei@intel.com>; Zeng, Star <star.zeng@intel.com>
Subject: RE: [PATCH 6/7] Vlv2TbltDevicePkg: Remove PcdPeiCoreMaxXXX PCDs' statement
Yi,
Good question.
With the patch, the code can be compiled and the image can boot to setup.
The image could not find shell, but that is not related to the patch.
It is because https://github.com/tianocore/edk2/commit/2840bb51040bb79c1ad53b1eb1cbb86e5edf80ca#diff-0318cca23f8f1c46d1076b3a5891fadd updated the platform dsc and fdf to use 2.0 shell source build (with 2.0 shell file GUID), but the code at https://github.com/tianocore/edk2/blob/master/Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c#L1365 is still using PcdShellFile (which matches to EDK shell) to find shell file.
Thanks,
Star
-----Original Message-----
From: Qian, Yi
Sent: Tuesday, December 18, 2018 10:08 AM
To: Zeng, Star <star.zeng@intel.com>; edk2-devel@lists.01.org
Cc: Sun, Zailiang <zailiang.sun@intel.com>
Subject: RE: [PATCH 6/7] Vlv2TbltDevicePkg: Remove PcdPeiCoreMaxXXX PCDs' statement
Hi Star,
This patch is good to me. Only one thing I need to know is whether you have done the unit test, at least, compilation, and boot into shell.
Thanks
Qian Yi
-----Original Message-----
From: Zeng, Star
Sent: Friday, December 14, 2018 6:29 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star <star.zeng@intel.com>; Sun, Zailiang <zailiang.sun@intel.com>; Qian, Yi <yi.qian@intel.com>
Subject: [PATCH 6/7] Vlv2TbltDevicePkg: Remove PcdPeiCoreMaxXXX PCDs' statement
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405
The codes have been updated to not use PcdPeiCoreMaxFvSupported, PcdPeiCoreMaxPeimPerFv and PcdPeiCoreMaxPpiSupported, so their statement in platform DSC could be removed.
Cc: Zailiang Sun <zailiang.sun@intel.com>
Cc: Yi Qian <yi.qian@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 2 --
Vlv2TbltDevicePkg/PlatformPkgIA32.dsc | 2 --
Vlv2TbltDevicePkg/PlatformPkgX64.dsc | 2 --
3 files changed, 6 deletions(-)
diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
index f8ad29df5986..d43611550285 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
@@ -663,10 +663,8 @@ [PcdsFixedAtBuild.common]
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x400
gEfiCpuTokenSpaceGuid.PcdCpuIEDRamSize|0x400000
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize|0x10000
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|50
gEfiMdeModulePkgTokenSpaceGuid.PcdSrIovSupport|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport|FALSE
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported|128
gEfiCpuTokenSpaceGuid.PcdCpuSmmApSyncTimeout|1000
!if $(S4_ENABLE) == TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|TRUE
diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
index ca3b2ff90287..a33816c4d18b 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
@@ -663,10 +663,8 @@ [PcdsFixedAtBuild.common]
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x400
gEfiCpuTokenSpaceGuid.PcdCpuIEDRamSize|0x400000
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize|0x10000
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|50
gEfiMdeModulePkgTokenSpaceGuid.PcdSrIovSupport|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport|FALSE
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported|128
gEfiCpuTokenSpaceGuid.PcdCpuSmmApSyncTimeout|1000
!if $(S4_ENABLE) == TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|TRUE
diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
index 81f36bd73b28..b50731f25ffb 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
@@ -663,10 +663,8 @@ [PcdsFixedAtBuild.common]
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x400
gEfiCpuTokenSpaceGuid.PcdCpuIEDRamSize|0x400000
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize|0x10000
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|50
gEfiMdeModulePkgTokenSpaceGuid.PcdSrIovSupport|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport|FALSE
- gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported|128
gEfiCpuTokenSpaceGuid.PcdCpuSmmApSyncTimeout|1000
!if $(S4_ENABLE) == TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|TRUE
--
2.7.0.windows.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH 6/7] Vlv2TbltDevicePkg: Remove PcdPeiCoreMaxXXX PCDs' statement
[not found] ` <A6DBF04CB9C4D045926EB50EBFFE5A2950865882@shsmsx102.ccr.corp.intel.com>
@ 2018-12-19 3:12 ` Sun, Zailiang
0 siblings, 0 replies; 23+ messages in thread
From: Sun, Zailiang @ 2018-12-19 3:12 UTC (permalink / raw)
To: Qian, Yi, Zeng, Star, edk2-devel@lists.01.org; +Cc: Wei, David
Reviewed-by: Zailiang Sun <zailiang.sun@intel.com>
> -----Original Message-----
> From: Qian, Yi
> Sent: Wednesday, December 19, 2018 11:08 AM
> To: Zeng, Star <star.zeng@intel.com>; edk2-devel@lists.01.org
> Cc: Sun, Zailiang <zailiang.sun@intel.com>; Wei, David <david.wei@intel.com>
> Subject: RE: [PATCH 6/7] Vlv2TbltDevicePkg: Remove PcdPeiCoreMaxXXX PCDs'
> statement
>
> Reviewed-by: Yi Qian <yi.qian@intel.com>
>
> Thanks
> Qian Yi
>
> -----Original Message-----
> From: Zeng, Star
> Sent: Wednesday, December 19, 2018 9:23 AM
> To: Qian, Yi <yi.qian@intel.com>; edk2-devel@lists.01.org
> Cc: Sun, Zailiang <zailiang.sun@intel.com>; Wei, David <david.wei@intel.com>;
> Zeng, Star <star.zeng@intel.com>
> Subject: RE: [PATCH 6/7] Vlv2TbltDevicePkg: Remove PcdPeiCoreMaxXXX PCDs'
> statement
>
> Yi, Zailiang and David,
>
> So, is it ok to give RB to the patch from you? :)
>
>
> Thanks,
> Star
> -----Original Message-----
> From: Qian, Yi
> Sent: Wednesday, December 19, 2018 9:21 AM
> To: Zeng, Star <star.zeng@intel.com>; edk2-devel@lists.01.org
> Cc: Sun, Zailiang <zailiang.sun@intel.com>; Wei, David <david.wei@intel.com>
> Subject: RE: [PATCH 6/7] Vlv2TbltDevicePkg: Remove PcdPeiCoreMaxXXX PCDs'
> statement
>
> It's fine. Thank you for your update.
>
> Thanks
> Qian Yi
>
> -----Original Message-----
> From: Zeng, Star
> Sent: Tuesday, December 18, 2018 7:01 PM
> To: Qian, Yi <yi.qian@intel.com>; edk2-devel@lists.01.org
> Cc: Sun, Zailiang <zailiang.sun@intel.com>; Wei, David <david.wei@intel.com>;
> Zeng, Star <star.zeng@intel.com>
> Subject: RE: [PATCH 6/7] Vlv2TbltDevicePkg: Remove PcdPeiCoreMaxXXX PCDs'
> statement
>
> Yi,
>
> Good question.
>
> With the patch, the code can be compiled and the image can boot to setup.
> The image could not find shell, but that is not related to the patch.
> It is because
> https://github.com/tianocore/edk2/commit/2840bb51040bb79c1ad53b1eb1cbb
> 86e5edf80ca#diff-0318cca23f8f1c46d1076b3a5891fadd updated the platform
> dsc and fdf to use 2.0 shell source build (with 2.0 shell file GUID), but the code at
> https://github.com/tianocore/edk2/blob/master/Vlv2TbltDevicePkg/Library/Pla
> tformBdsLib/BdsPlatform.c#L1365 is still using PcdShellFile (which matches to
> EDK shell) to find shell file.
>
>
> Thanks,
> Star
> -----Original Message-----
> From: Qian, Yi
> Sent: Tuesday, December 18, 2018 10:08 AM
> To: Zeng, Star <star.zeng@intel.com>; edk2-devel@lists.01.org
> Cc: Sun, Zailiang <zailiang.sun@intel.com>
> Subject: RE: [PATCH 6/7] Vlv2TbltDevicePkg: Remove PcdPeiCoreMaxXXX PCDs'
> statement
>
> Hi Star,
> This patch is good to me. Only one thing I need to know is whether you have
> done the unit test, at least, compilation, and boot into shell.
>
> Thanks
> Qian Yi
>
> -----Original Message-----
> From: Zeng, Star
> Sent: Friday, December 14, 2018 6:29 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star <star.zeng@intel.com>; Sun, Zailiang <zailiang.sun@intel.com>;
> Qian, Yi <yi.qian@intel.com>
> Subject: [PATCH 6/7] Vlv2TbltDevicePkg: Remove PcdPeiCoreMaxXXX PCDs'
> statement
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1405
>
> The codes have been updated to not use PcdPeiCoreMaxFvSupported,
> PcdPeiCoreMaxPeimPerFv and PcdPeiCoreMaxPpiSupported, so their statement
> in platform DSC could be removed.
>
> Cc: Zailiang Sun <zailiang.sun@intel.com>
> Cc: Yi Qian <yi.qian@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng <star.zeng@intel.com>
> ---
> Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 2 --
> Vlv2TbltDevicePkg/PlatformPkgIA32.dsc | 2 --
> Vlv2TbltDevicePkg/PlatformPkgX64.dsc | 2 --
> 3 files changed, 6 deletions(-)
>
> diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> index f8ad29df5986..d43611550285 100644
> --- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> +++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> @@ -663,10 +663,8 @@ [PcdsFixedAtBuild.common]
> gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x400
> gEfiCpuTokenSpaceGuid.PcdCpuIEDRamSize|0x400000
>
> gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize
> |0x10000
> - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|50
> gEfiMdeModulePkgTokenSpaceGuid.PcdSrIovSupport|FALSE
> gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport|FALSE
> - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported|128
> gEfiCpuTokenSpaceGuid.PcdCpuSmmApSyncTimeout|1000
> !if $(S4_ENABLE) == TRUE
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChang
> e|TRUE
> diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> index ca3b2ff90287..a33816c4d18b 100644
> --- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> +++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> @@ -663,10 +663,8 @@ [PcdsFixedAtBuild.common]
> gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x400
> gEfiCpuTokenSpaceGuid.PcdCpuIEDRamSize|0x400000
>
> gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize
> |0x10000
> - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|50
> gEfiMdeModulePkgTokenSpaceGuid.PcdSrIovSupport|FALSE
> gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport|FALSE
> - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported|128
> gEfiCpuTokenSpaceGuid.PcdCpuSmmApSyncTimeout|1000
> !if $(S4_ENABLE) == TRUE
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChang
> e|TRUE
> diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> index 81f36bd73b28..b50731f25ffb 100644
> --- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> +++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> @@ -663,10 +663,8 @@ [PcdsFixedAtBuild.common]
> gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x400
> gEfiCpuTokenSpaceGuid.PcdCpuIEDRamSize|0x400000
>
> gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize
> |0x10000
> - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv|50
> gEfiMdeModulePkgTokenSpaceGuid.PcdSrIovSupport|FALSE
> gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport|FALSE
> - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported|128
> gEfiCpuTokenSpaceGuid.PcdCpuSmmApSyncTimeout|1000
> !if $(S4_ENABLE) == TRUE
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChang
> e|TRUE
> --
> 2.7.0.windows.1
^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2018-12-19 3:13 UTC | newest]
Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-14 10:28 [PATCH 0/7] Remove PcdPeiCoreMaxXXX PCDs Star Zeng
2018-12-14 10:28 ` [PATCH 1/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPeimPerFv Star Zeng
2018-12-17 23:20 ` Chiu, Chasel
2018-12-18 2:04 ` Wang, Jian J
2018-12-18 2:45 ` Zeng, Star
2018-12-14 10:28 ` [PATCH 2/7] SecurityPkg Tcg(2)Pei: Remove the using of PcdPeiCoreMaxFvSupported Star Zeng
2018-12-17 5:06 ` Zhang, Chao B
2018-12-14 10:28 ` [PATCH 3/7] MdeModulePkg PeiCore: " Star Zeng
2018-12-17 23:20 ` Chiu, Chasel
2018-12-18 2:10 ` Wang, Jian J
2018-12-14 10:28 ` [PATCH 4/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPpiSupported Star Zeng
2018-12-17 23:20 ` Chiu, Chasel
2018-12-18 2:24 ` Wang, Jian J
2018-12-18 3:12 ` Zeng, Star
2018-12-14 10:28 ` [PATCH 5/7] OvmfPkg: Remove PcdPeiCoreMaxXXX PCDs' statement Star Zeng
2018-12-14 10:57 ` Ard Biesheuvel
2018-12-14 13:20 ` Laszlo Ersek
2018-12-14 10:28 ` [PATCH 6/7] Vlv2TbltDevicePkg: " Star Zeng
[not found] ` <A6DBF04CB9C4D045926EB50EBFFE5A2950865373@shsmsx102.ccr.corp.intel.com>
2018-12-18 11:00 ` Zeng, Star
[not found] ` <A6DBF04CB9C4D045926EB50EBFFE5A29508656F9@shsmsx102.ccr.corp.intel.com>
2018-12-19 1:23 ` Zeng, Star
[not found] ` <A6DBF04CB9C4D045926EB50EBFFE5A2950865882@shsmsx102.ccr.corp.intel.com>
2018-12-19 3:12 ` Sun, Zailiang
2018-12-14 10:28 ` [PATCH 7/7] MdeModulePkg: Remove PcdPeiCoreMaxXXX PCDs Star Zeng
2018-12-17 23:19 ` Chiu, Chasel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox