diff options
author | Jeff Fan <jeff.fan@intel.com> | 2017-03-07 19:23:12 +0800 |
---|---|---|
committer | Jeff Fan <jeff.fan@intel.com> | 2017-03-22 10:12:02 +0800 |
commit | 82e75ac65abdfca034cfb38edcee8a7cbc6e6271 (patch) | |
tree | 4f1656d84b3e5e5116a5a606c11c8c1727d1b998 /UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c | |
parent | 0a70d1c3042956c418c89a703d40d3262e4d6c87 (diff) | |
download | edk2-82e75ac65abdfca034cfb38edcee8a7cbc6e6271.tar.gz edk2-82e75ac65abdfca034cfb38edcee8a7cbc6e6271.tar.bz2 edk2-82e75ac65abdfca034cfb38edcee8a7cbc6e6271.zip |
UefiCpuPkg: Add CPU Features PEI/DXE drivers
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 <feng.tian@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
Diffstat (limited to 'UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c')
-rw-r--r-- | UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c b/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c new file mode 100644 index 0000000000..6292f5bf87 --- /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.<BR> + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include <PiPei.h> + +#include <Library/BaseLib.h> +#include <Library/DebugLib.h> +#include <Library/PeiServicesLib.h> +#include <Library/RegisterCpuFeaturesLib.h> + +#include <Guid/CpuFeaturesInitDone.h> + +EFI_PEI_PPI_DESCRIPTOR mPeiCpuFeaturesInitDonePpiDesc = { + (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 = PeiServicesGetBootMode (&BootMode); + ASSERT_EFI_ERROR (Status); + + if (BootMode == 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 = PeiServicesInstallPpi(&mPeiCpuFeaturesInitDonePpiDesc); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + |