From nobody Sat Nov 2 14:42:18 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 148904860024667.3747329220597; Thu, 9 Mar 2017 00:36:40 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5E810803AC; Thu, 9 Mar 2017 00:36:28 -0800 (PST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 E3C3180391 for ; Thu, 9 Mar 2017 00:36:26 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Mar 2017 00:36:26 -0800 Received: from jfan12-desk.ccr.corp.intel.com ([10.239.158.57]) by fmsmga002.fm.intel.com with ESMTP; 09 Mar 2017 00:36:25 -0800 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,268,1486454400"; d="scan'208";a="1139930997" From: Jeff Fan To: edk2-devel@lists.01.org Date: Thu, 9 Mar 2017 16:35:53 +0800 Message-Id: <20170309083553.6016-12-jeff.fan@intel.com> X-Mailer: git-send-email 2.9.3.windows.2 In-Reply-To: <20170309083553.6016-1-jeff.fan@intel.com> References: <20170309083553.6016-1-jeff.fan@intel.com> Subject: [edk2] [PATCH 11/11] UefiCpuPkg: Add CPU Features PEI/DXE drivers X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Kinney , Feng Tian MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" They will consume Register CPU Features library to detect and initialize CPU features. CpuFeaturesPei driver is used to initialize CPU features in PEI phase. CpuFeaturesDxe driver is used to initialize CPU features in DXE phase. Add PcdCpuFeaturesInitAfterSmmRelocation and PcdCpuFeaturesInitOnS3Resume that consumed by CpuFeaturesPei and CpuFeaturesDxe. Cc: Feng Tian Cc: Michael Kinney Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan --- UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c | 122 +++++++++++++++++++++= ++++ UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf | 53 +++++++++++ UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.uni | 22 +++++ UefiCpuPkg/CpuFeatures/CpuFeaturesDxeExtra.uni | 20 ++++ UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c | 75 +++++++++++++++ UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf | 49 ++++++++++ UefiCpuPkg/CpuFeatures/CpuFeaturesPei.uni | 22 +++++ UefiCpuPkg/CpuFeatures/CpuFeaturesPeiExtra.uni | 20 ++++ UefiCpuPkg/UefiCpuPkg.dec | 8 ++ UefiCpuPkg/UefiCpuPkg.dsc | 8 ++ 10 files changed, 399 insertions(+) create mode 100644 UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c create mode 100644 UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf create mode 100644 UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.uni create mode 100644 UefiCpuPkg/CpuFeatures/CpuFeaturesDxeExtra.uni create mode 100644 UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c create mode 100644 UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf create mode 100644 UefiCpuPkg/CpuFeatures/CpuFeaturesPei.uni create mode 100644 UefiCpuPkg/CpuFeatures/CpuFeaturesPeiExtra.uni diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c b/UefiCpuPkg/CpuFeatur= es/CpuFeaturesDxe.c new file mode 100644 index 0000000..f4f70cf --- /dev/null +++ b/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c @@ -0,0 +1,122 @@ +/** @file + CPU Features DXE driver to initialize CPU features. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ + +#include + +#include +#include +#include +#include +#include + +#include +#include + + +/** + Worker function to perform CPU feature initialization. + +**/ +VOID +CpuFeaturesInitializeWorker ( + VOID + ) +{ + EFI_STATUS Status; + EFI_HANDLE Handle; + + CpuFeaturesDetect (); + + CpuFeaturesInitialize (); + + // + // Install CPU Features Init Done Protocol + // + Handle =3D NULL; + Status =3D gBS->InstallProtocolInterface ( + &Handle, + &gEdkiiCpuFeaturesInitDoneGuid, + EFI_NATIVE_INTERFACE, + NULL + ); + ASSERT_EFI_ERROR (Status); +} + +/** + Event notification that initialize CPU features when gEfiSmmConfiguratio= nProtocol installs. + + @param[in] Event The Event that is being processed, not= used. + @param[in] Context Event Context, not used. +**/ +VOID +EFIAPI +SmmConfigurationEventNotify ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + EFI_SMM_CONFIGURATION_PROTOCOL *SmmConfiguration; + + // + // Make sure this notification is for this handler + // + Status =3D gBS->LocateProtocol (&gEfiSmmConfigurationProtocolGuid, NULL,= (VOID **)&SmmConfiguration); + if (EFI_ERROR (Status)) { + return; + } + + CpuFeaturesInitializeWorker (); +} + +/** + CPU Features driver entry point function. + + If PcdCpuFeaturesInitAfterSmmRelocation is TRUE, it will register one + SMM Configuration Protocol notify function to perform CPU features + initialization. Otherwise, it will perform CPU features initialization + directly. + + @param ImageHandle Image handle this driver. + @param SystemTable Pointer to the System Table. + + @retval EFI_SUCCESS CPU Features is initialized successfully. +**/ +EFI_STATUS +EFIAPI +CpuFeaturesDxeInitialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + VOID *Registration; + + if (PcdGetBool (PcdCpuFeaturesInitAfterSmmRelocation)) { + // + // Install notification callback on SMM Configuration Protocol + // + EfiCreateProtocolNotifyEvent ( + &gEfiSmmConfigurationProtocolGuid, + TPL_CALLBACK, + SmmConfigurationEventNotify, + NULL, + &Registration + ); + } else { + CpuFeaturesInitializeWorker (); + } + + return EFI_SUCCESS; +} + diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf b/UefiCpuPkg/CpuFeat= ures/CpuFeaturesDxe.inf new file mode 100644 index 0000000..5a3e4f0 --- /dev/null +++ b/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf @@ -0,0 +1,53 @@ +## @file +# CPU Features DXE driver. +# +# Copyright (c) 2017, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may = be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D CpuFeaturesDxe + MODULE_UNI_FILE =3D CpuFeaturesDxe.uni + FILE_GUID =3D 63EB1B62-10C9-4693-88AC-AE0999EA87F8 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + + ENTRY_POINT =3D CpuFeaturesDxeInitialize + +[Packages] + MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + UefiLib + UefiDriverEntryPoint + UefiBootServicesTableLib + RegisterCpuFeaturesLib + +[Sources] + CpuFeaturesDxe.c + +[Guids] + gEdkiiCpuFeaturesInitDoneGuid ## PRODU= CES + +[Protocols] + gEfiSmmConfigurationProtocolGuid ## SOMET= IME_CONSUMES + +[Pcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitAfterSmmRelocation ## CONSU= MES + +[Depex] + TRUE + +[UserExtensions.TianoCore."ExtraFiles"] + CpuFeaturesDxeExtra.uni diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.uni b/UefiCpuPkg/CpuFeat= ures/CpuFeaturesDxe.uni new file mode 100644 index 0000000..6f27bb9 --- /dev/null +++ b/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.uni @@ -0,0 +1,22 @@ +// /** @file +// CPU Features DXE driver. +// +// CPU Features DXE driver. +// +// Copyright (c) 2017, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the B= SD License +// which accompanies this distribution. The full text of the license may = be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "CPU Features DXE = driver to initialize CPU features." + +#string STR_MODULE_DESCRIPTION #language en-US "CPU Features DXE = driver to initialize CPU features." + diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxeExtra.uni b/UefiCpuPkg/Cp= uFeatures/CpuFeaturesDxeExtra.uni new file mode 100644 index 0000000..a236e1e --- /dev/null +++ b/UefiCpuPkg/CpuFeatures/CpuFeaturesDxeExtra.uni @@ -0,0 +1,20 @@ +// /** @file +// CpuFeaturesDxe Localized Strings and Content +// +// Copyright (c) 2017, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the B= SD License +// which accompanies this distribution. The full text of the license may = be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +// +// **/ + +#string STR_PROPERTIES_MODULE_NAME +#language en-US +"CPU Features DXE Driver" + + diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c b/UefiCpuPkg/CpuFeatur= es/CpuFeaturesPei.c new file mode 100644 index 0000000..6292f5b --- /dev/null +++ b/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c @@ -0,0 +1,75 @@ +/** @file + CPU Features PEIM driver to initialize CPU features. + + Copyright (c) 2017, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ + +#include + +#include +#include +#include +#include + +#include + +EFI_PEI_PPI_DESCRIPTOR mPeiCpuFeaturesInitDonePpiDesc =3D { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEdkiiCpuFeaturesInitDoneGuid, + NULL +}; + +/** + CPU Features driver entry point function. + + It will perform CPU features initialization, except for + PcdCpuFeaturesInitOnS3Resume is FALSE on S3 resume. + + @param FileHandle Handle of the file being invoked. + @param PeiServices Describes the list of possible PEI Services. + + @retval EFI_SUCCESS CPU Features is initialized successfully. +**/ +EFI_STATUS +EFIAPI +CpuFeaturesPeimInitialize ( + IN EFI_PEI_FILE_HANDLE FileHandle, + IN CONST EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + EFI_BOOT_MODE BootMode; + + Status =3D PeiServicesGetBootMode (&BootMode); + ASSERT_EFI_ERROR (Status); + + if (BootMode =3D=3D BOOT_ON_S3_RESUME && + !PcdGetBool (PcdCpuFeaturesInitOnS3Resume)) { + // + // Does nothing when if PcdCpuFeaturesInitOnS3Resume is FLASE + // on S3 boot mode + // + return EFI_SUCCESS; + } + + CpuFeaturesDetect (); + + CpuFeaturesInitialize (); + + // + // Install CPU Features Init Done PPI + // + Status =3D PeiServicesInstallPpi(&mPeiCpuFeaturesInitDonePpiDesc); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf b/UefiCpuPkg/CpuFeat= ures/CpuFeaturesPei.inf new file mode 100644 index 0000000..e306bb2 --- /dev/null +++ b/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf @@ -0,0 +1,49 @@ +## @file +# CPU Features PEIM driver. +# +# Copyright (c) 2017, Intel Corporation. All rights reserved.
+# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may = be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D CpuFeaturesPei + MODULE_UNI_FILE =3D CpuFeaturesPei.uni + FILE_GUID =3D 183BB3E1-A1E5-4445-8AC9-0E83B6547E0E + MODULE_TYPE =3D PEIM + VERSION_STRING =3D 1.0 + + ENTRY_POINT =3D CpuFeaturesPeimInitialize + +[Packages] + MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + PeimEntryPoint + PeiServicesLib + RegisterCpuFeaturesLib + +[Sources] + CpuFeaturesPei.c + +[Guids] + gEdkiiCpuFeaturesInitDoneGuid ## PRODU= CES + +[Pcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitOnS3Resume ## CONSU= MES + +[Depex] + TRUE + +[UserExtensions.TianoCore."ExtraFiles"] + CpuFeaturesPeiExtra.uni diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.uni b/UefiCpuPkg/CpuFeat= ures/CpuFeaturesPei.uni new file mode 100644 index 0000000..f56dbd1 --- /dev/null +++ b/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.uni @@ -0,0 +1,22 @@ +// /** @file +// CPU Features PEIM driver. +// +// CPU Features PEIM driver. +// +// Copyright (c) 2017, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the B= SD License +// which accompanies this distribution. The full text of the license may = be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "CPU Features PEIM= driver to initialize CPU features." + +#string STR_MODULE_DESCRIPTION #language en-US "CPU Features PEIM= driver to initialize CPU features." + diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesPeiExtra.uni b/UefiCpuPkg/Cp= uFeatures/CpuFeaturesPeiExtra.uni new file mode 100644 index 0000000..0ffc619 --- /dev/null +++ b/UefiCpuPkg/CpuFeatures/CpuFeaturesPeiExtra.uni @@ -0,0 +1,20 @@ +// /** @file +// CpuFeaturesPei Localized Strings and Content +// +// Copyright (c) 2017, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the B= SD License +// which accompanies this distribution. The full text of the license may = be found at +// http://opensource.org/licenses/bsd-license.php +// +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +// +// **/ + +#string STR_PROPERTIES_MODULE_NAME +#language en-US +"CPU Features PEIM Driver" + + diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec index 745f986..4a679bd 100644 --- a/UefiCpuPkg/UefiCpuPkg.dec +++ b/UefiCpuPkg/UefiCpuPkg.dec @@ -196,6 +196,14 @@ # @Prompt Supported CPU features gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSupport|{0xFF, 0xFF, 0xFF, 0xFF,= 0xFF, 0xFF, 0xFF, 0xFF}|VOID*|0x00000016 =20 + ## Specifies if CPU features will be initialized after SMM relocation + # @Prompt if CPU features will be initialized after SMM relocation + gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitAfterSmmRelocation|FALSE|BOO= LEAN|0x0000001C + + ## Specifies if CPU features will be initialized during S3 resume + # @Prompt if CPU features will be initialized during S3 resume + gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitOnS3Resume|FALSE|BOOLEAN|0x0= 000001D + [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx] ## Specifies max supported number of Logical Processors. # @Prompt Configure max supported number of Logical Processors diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc index 59a702f..1336b0c 100644 --- a/UefiCpuPkg/UefiCpuPkg.dsc +++ b/UefiCpuPkg/UefiCpuPkg.dsc @@ -114,6 +114,14 @@ =20 [Components.IA32, Components.X64] UefiCpuPkg/CpuDxe/CpuDxe.inf + UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf { + + NULL|UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf + } + UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf { + + NULL|UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf + } UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf UefiCpuPkg/CpuMpPei/CpuMpPei.inf UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf --=20 2.9.3.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel