From 4aaaa831fec4f50d7a155de049cae39b7065dc42 Mon Sep 17 00:00:00 2001 From: Guo Mang Date: Wed, 25 Apr 2018 17:54:17 +0800 Subject: Override PeiCore and PCD driver Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Guo Mang --- .../SampleCode/MdeModulePkg/Core/Pei/FwVol/FwVol.c | 56 ++++++++++++++++++++-- .../SampleCode/MdeModulePkg/Core/Pei/PeiMain.inf | 5 +- .../SampleCode/MdeModulePkg/Core/Pei/Ppi/Ppi.c | 8 ++-- .../MdeModulePkg/Core/Pei/Security/Security.c | 7 ++- 4 files changed, 66 insertions(+), 10 deletions(-) (limited to 'Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Core/Pei') diff --git a/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Core/Pei/FwVol/FwVol.c b/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Core/Pei/FwVol/FwVol.c index 8009546acd..bc14d8dc7b 100644 --- a/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Core/Pei/FwVol/FwVol.c +++ b/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Core/Pei/FwVol/FwVol.c @@ -2,7 +2,7 @@ Pei Core Firmware File System service routines. Copyright (c) 2015 HP Development Company, L.P. -Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -523,8 +523,10 @@ PeiInitializeFv ( // Post a call-back for the FvInfoPPI and FvInfo2PPI services to expose // additional Fvs to PeiCore. // - Status = PeiServicesNotifyPpi (mNotifyOnFvInfoList); - ASSERT_EFI_ERROR (Status); + // bugbug: Platform workaround + // + //Status = PeiServicesNotifyPpi (mNotifyOnFvInfoList); + //ASSERT_EFI_ERROR (Status); } @@ -559,6 +561,11 @@ FirmwareVolmeInfoPpiNotifyCallback ( VOID *DepexData; BOOLEAN IsFvInfo2; UINTN CurFvCount; + EFI_FV_INFO FvInfo; + EFI_FV_INFO TempFvInfo; + BOOLEAN CheckFvName; + UINTN Index; + EFI_PEI_FV_HANDLE OrgFvHandle; Status = EFI_SUCCESS; PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices); @@ -614,6 +621,12 @@ FirmwareVolmeInfoPpiNotifyCallback ( // // Check whether the FV has already been processed. // + CheckFvName = TRUE; + FvPpi->GetVolumeInfo (FvPpi, FvHandle, &FvInfo); + if (CompareGuid (&FvInfo.FvName, &gZeroGuid)) { + CheckFvName = FALSE; + } + for (FvIndex = 0; FvIndex < PrivateData->FvCount; FvIndex ++) { if (PrivateData->Fv[FvIndex].FvHandle == FvHandle) { if (IsFvInfo2 && (FvInfo2Ppi.AuthenticationStatus != PrivateData->Fv[FvIndex].AuthenticationStatus)) { @@ -623,6 +636,34 @@ FirmwareVolmeInfoPpiNotifyCallback ( DEBUG ((EFI_D_INFO, "The Fv %p has already been processed!\n", FvInfo2Ppi.FvInfo)); return EFI_SUCCESS; } + // + // bugbug: Platform workaround + // + if (CheckFvName) { + PrivateData->Fv[FvIndex].FvPpi->GetVolumeInfo (PrivateData->Fv[FvIndex].FvPpi, PrivateData->Fv[FvIndex].FvHandle, &TempFvInfo); + if (CompareGuid (&FvInfo.FvName, &TempFvInfo.FvName)) { + // + // They are same. Switch its data from original Handle to new Handle. + // + OrgFvHandle = PrivateData->Fv[FvIndex].FvHandle; + PrivateData->Fv[FvIndex].FvHandle = FvHandle; + PrivateData->Fv[FvIndex].FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) FvInfo2Ppi.FvInfo; + PrivateData->Fv[FvIndex].FvPpi = FvPpi; + if (PrivateData->Fv[FvIndex].ScanFv) { + for (Index = 0; Index < FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv) && (PrivateData->Fv[FvIndex].FvFileHandles[Index] != NULL); Index ++) { + PrivateData->Fv[FvIndex].FvFileHandles[Index] = (EFI_PEI_FILE_HANDLE *) (VOID *) ((UINTN) (VOID *) PrivateData->Fv[FvIndex].FvFileHandles[Index] - (UINTN) (VOID *) OrgFvHandle + (UINTN) (VOID *) FvHandle); + } + if (PrivateData->CurrentPeimFvCount == FvIndex) { + PrivateData->CurrentFileHandle =(EFI_PEI_FILE_HANDLE *) (VOID *) ((UINTN) (VOID *) PrivateData->CurrentFileHandle - (UINTN) (VOID *) OrgFvHandle + (UINTN) (VOID *) FvHandle); + for (Index = 0; Index < FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv) && (PrivateData->CurrentFvFileHandles[Index] != NULL); Index ++) { + PrivateData->CurrentFvFileHandles[Index] = (EFI_PEI_FILE_HANDLE *) (VOID *) ((UINTN) (VOID *) PrivateData->CurrentFvFileHandles[Index] - (UINTN) (VOID *) OrgFvHandle + (UINTN) (VOID *) FvHandle); + } + } + } + DEBUG ((EFI_D_INFO, "The Fv has been migrated from %p to %p!\n", OrgFvHandle, FvHandle)); + return EFI_SUCCESS; + } + } } if (PrivateData->FvCount >= PcdGet32 (PcdPeiCoreMaxFvSupported)) { @@ -2159,6 +2200,15 @@ PeiReinitializeFv ( UINTN Index; EFI_STATUS Status; + // + // Post a call-back for the FvInfoPPI and FvInfo2PPI services to expose + // additional Fvs to PeiCore. + // + // bugbug: Platform Workaround + // + Status = PeiServicesNotifyPpi (mNotifyOnFvInfoList); + ASSERT_EFI_ERROR (Status); + // // Locate old build-in Ffs2 EFI_PEI_FIRMWARE_VOLUME_PPI which // in flash. diff --git a/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Core/Pei/PeiMain.inf b/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Core/Pei/PeiMain.inf index 7d9cdaa2f0..8c267fdf14 100644 --- a/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Core/Pei/PeiMain.inf +++ b/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Core/Pei/PeiMain.inf @@ -6,7 +6,7 @@ # 2) Dispatch PEIM from discovered FV. # 3) Handoff control to DxeIpl to load DXE core and enter DXE phase. # -# Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -81,7 +81,8 @@ ## CONSUMES ## UNDEFINED # Locate ppi ## CONSUMES ## GUID # Used to compare with FV's file system guid and get the FV's file system format gEfiFirmwareFileSystem3Guid - + gZeroGuid + [Ppis] gEfiPeiStatusCodePpiGuid ## SOMETIMES_CONSUMES # PeiReportStatusService is not ready if this PPI doesn't exist gEfiPeiResetPpiGuid ## SOMETIMES_CONSUMES # PeiResetService is not ready if this PPI doesn't exist diff --git a/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Core/Pei/Ppi/Ppi.c b/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Core/Pei/Ppi/Ppi.c index 082c379458..768508f58e 100644 --- a/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Core/Pei/Ppi/Ppi.c +++ b/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Core/Pei/Ppi/Ppi.c @@ -1,7 +1,7 @@ /** @file EFI PEI Core PPI services -Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -749,8 +749,10 @@ ProcessPpiListFromSec ( // // It is a notification PPI. // - Status = InternalPeiNotifyPpi (PeiServices, (CONST EFI_PEI_NOTIFY_DESCRIPTOR *) PpiList, TRUE); - ASSERT_EFI_ERROR (Status); + // bugbug: Platform workaround + // + //Status = InternalPeiNotifyPpi (PeiServices, (CONST EFI_PEI_NOTIFY_DESCRIPTOR *) PpiList, TRUE); + //ASSERT_EFI_ERROR (Status); } else { // // It is a normal PPI. diff --git a/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Core/Pei/Security/Security.c b/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Core/Pei/Security/Security.c index 763126057d..83c40456d1 100644 --- a/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Core/Pei/Security/Security.c +++ b/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Core/Pei/Security/Security.c @@ -1,7 +1,7 @@ /** @file EFI PEI Core Security services -Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -35,7 +35,10 @@ InitializeSecurityServices ( IN PEI_CORE_INSTANCE *OldCoreData ) { - if (OldCoreData == NULL) { + // + // bugbug: Platform workaround + // + if (OldCoreData != NULL) { PeiServicesNotifyPpi (&mNotifyList); } return; -- cgit v1.2.3