]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c
UefiCpuPkg/CpuDxe: Enable protection for newly added page table
[mirror_edk2.git] / UefiCpuPkg / CpuFeatures / CpuFeaturesPei.c
index 6292f5bf873c1dcf08a2b9e3229ea5f50f747317..72ee19b4507eb40745493970d0d625110e9e1e13 100644 (file)
@@ -1,75 +1,81 @@
-/** @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;
-}
-
+/** @file\r
+  CPU Features PEIM driver to initialize CPU features.\r
+\r
+  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <PiPei.h>\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/PeiServicesLib.h>\r
+#include <Library/RegisterCpuFeaturesLib.h>\r
+#include <Library/HobLib.h>\r
+\r
+#include <Guid/CpuFeaturesInitDone.h>\r
+\r
+EFI_PEI_PPI_DESCRIPTOR           mPeiCpuFeaturesInitDonePpiDesc = {\r
+  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+  &gEdkiiCpuFeaturesInitDoneGuid,\r
+  NULL\r
+};\r
+\r
+/**\r
+  CPU Features driver entry point function.\r
+\r
+  It will perform CPU features initialization, except for\r
+  PcdCpuFeaturesInitOnS3Resume is FALSE on S3 resume.\r
+\r
+  @param  FileHandle    Handle of the file being invoked.\r
+  @param  PeiServices   Describes the list of possible PEI Services.\r
+\r
+  @retval EFI_SUCCESS   CPU Features is initialized successfully.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CpuFeaturesPeimInitialize (\r
+  IN       EFI_PEI_FILE_HANDLE  FileHandle,\r
+  IN CONST EFI_PEI_SERVICES     **PeiServices\r
+  )\r
+{\r
+  EFI_STATUS                 Status;\r
+  EFI_BOOT_MODE              BootMode;\r
+\r
+  Status = PeiServicesGetBootMode (&BootMode);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  if (BootMode == BOOT_ON_S3_RESUME &&\r
+      !PcdGetBool (PcdCpuFeaturesInitOnS3Resume)) {\r
+    //\r
+    // Does nothing when if PcdCpuFeaturesInitOnS3Resume is FLASE\r
+    // on S3 boot mode\r
+    //\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  CpuFeaturesDetect ();\r
+\r
+  CpuFeaturesInitialize ();\r
+\r
+  //\r
+  // Install CPU Features Init Done PPI\r
+  //\r
+  Status = PeiServicesInstallPpi(&mPeiCpuFeaturesInitDonePpiDesc);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Build HOB to let CpuFeatureDxe driver skip the initialization process.\r
+  //\r
+  BuildGuidHob (&gEdkiiCpuFeaturesInitDoneGuid, 0);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r