From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.120; helo=mga04.intel.com; envelope-from=chasel.chiu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 6CE24201B0414 for ; Tue, 12 Feb 2019 05:20:43 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Feb 2019 05:20:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,362,1544515200"; d="scan'208";a="143578777" Received: from cchiu4-mobl1.gar.corp.intel.com ([10.5.240.60]) by fmsmga004.fm.intel.com with ESMTP; 12 Feb 2019 05:20:41 -0800 From: "Chasel, Chiu" To: edk2-devel@lists.01.org Cc: Jian J Wang , Hao Wu , Ray Ni , Star Zeng , Liming Gao , Chasel Chiu Date: Tue, 12 Feb 2019 21:19:56 +0800 Message-Id: <20190212131957.2576-3-chasel.chiu@intel.com> X-Mailer: git-send-email 2.13.3.windows.1 In-Reply-To: <20190212131957.2576-1-chasel.chiu@intel.com> References: <20190212131957.2576-1-chasel.chiu@intel.com> Subject: [PATCH 2/3] MdeModulePkg/PeiMain: Support EFI_PEI_CORE_FV_LOCATION_PPI X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Feb 2019 13:20:43 -0000 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1524 When shadowing PeiCore the EFI_PEI_CORE_FV_LOCATION_PPI should be checked to see if PeiCore not in BFV, otherwise just shadowing PeiCore from BFV. Test: Verified on internal platform and booting successfully. Cc: Jian J Wang Cc: Hao Wu Cc: Ray Ni Cc: Star Zeng Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Chasel Chiu --- MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 58 +++++++++++++++++++++++++++++++++++++++++++++------------- MdeModulePkg/Core/Pei/PeiMain.h | 3 ++- MdeModulePkg/Core/Pei/PeiMain.inf | 3 ++- 3 files changed, 49 insertions(+), 15 deletions(-) diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c index 4da80a8222..408f24c216 100644 --- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c +++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c @@ -1,7 +1,7 @@ /** @file Pei Core Main Entry Point -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2019, 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 @@ -80,23 +80,55 @@ ShadowPeiCore ( IN PEI_CORE_INSTANCE *PrivateData ) { - EFI_PEI_FILE_HANDLE PeiCoreFileHandle; - EFI_PHYSICAL_ADDRESS EntryPoint; - EFI_STATUS Status; - UINT32 AuthenticationState; + EFI_PEI_FILE_HANDLE PeiCoreFileHandle; + EFI_PHYSICAL_ADDRESS EntryPoint; + EFI_STATUS Status; + UINT32 AuthenticationState; + UINTN Index; + EFI_PEI_CORE_FV_LOCATION_PPI *PeiCoreFvLocationPpi; PeiCoreFileHandle = NULL; // - // Find the PEI Core in the BFV + // Find the PEI Core either from EFI_PEI_CORE_FV_LOCATION_PPI indicated FV or BFV // - Status = PrivateData->Fv[0].FvPpi->FindFileByType ( - PrivateData->Fv[0].FvPpi, - EFI_FV_FILETYPE_PEI_CORE, - PrivateData->Fv[0].FvHandle, - &PeiCoreFileHandle - ); - ASSERT_EFI_ERROR (Status); + Status = PeiServicesLocatePpi ( + &gEfiPeiCoreFvLocationPpiGuid, + 0, + NULL, + (VOID **) &PeiCoreFvLocationPpi + ); + if (!EFI_ERROR (Status) && (PeiCoreFvLocationPpi->PeiCoreFvLocation != NULL)) { + // + // If PeiCoreFvLocation present, the PEI Core should be found from indicated FV. + // + for (Index = 0; Index < PrivateData->FvCount; Index ++) { + if ((UINT32) PrivateData->Fv[Index].FvHandle != (UINT32) PeiCoreFvLocationPpi->PeiCoreFvLocation) { + continue; + } + Status = PrivateData->Fv[Index].FvPpi->FindFileByType ( + PrivateData->Fv[Index].FvPpi, + EFI_FV_FILETYPE_PEI_CORE, + PrivateData->Fv[Index].FvHandle, + &PeiCoreFileHandle + ); + if (!EFI_ERROR (Status)) { + break; + } + } + ASSERT (Index < PrivateData->FvCount); + } else { + // + // Find PEI Core from BFV + // + Status = PrivateData->Fv[0].FvPpi->FindFileByType ( + PrivateData->Fv[0].FvPpi, + EFI_FV_FILETYPE_PEI_CORE, + PrivateData->Fv[0].FvHandle, + &PeiCoreFileHandle + ); + ASSERT_EFI_ERROR (Status); + } // // Shadow PEI Core into memory so it will run faster diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h index 322e7cd845..38542ab072 100644 --- a/MdeModulePkg/Core/Pei/PeiMain.h +++ b/MdeModulePkg/Core/Pei/PeiMain.h @@ -1,7 +1,7 @@ /** @file Definition of Pei Core Structures and Services -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2019, 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 @@ -49,6 +49,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include /// /// It is an FFS type extension used for PeiFindFileEx. It indicates current diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf b/MdeModulePkg/Core/Pei/PeiMain.inf index 140c4444b1..5bab2aab8c 100644 --- a/MdeModulePkg/Core/Pei/PeiMain.inf +++ b/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 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2006 - 2019, 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 @@ -102,6 +102,7 @@ gEfiTemporaryRamDonePpiGuid ## SOMETIMES_CONSUMES gEfiPeiReset2PpiGuid ## SOMETIMES_CONSUMES gEfiSecHobDataPpiGuid ## SOMETIMES_CONSUMES + gEfiPeiCoreFvLocationPpiGuid ## SOMETIMES_CONSUMES [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize ## CONSUMES -- 2.13.3.windows.1